unit wGlobals2;

{ Feel free to use this unit as you want.
  First developped by Bernard Gisin

  This unit defines global constant, types and some global variables.
  For globals procedures and functions see also wUtiles0.pp
  ----------------------------------------------------------------}

// To tell FreePascal that the application is a Graphical User Interface
// i.e. is running in windows, not in text mode.
{$APPTYPE GUI}

INTERFACE
//"""""""

// NO, do not Uses Windows;

const
  // each Window created by the library has a pointer on the corresponding
  // object, and an information on what kind of object it is in the library
  // number of extra bytes reserved in the window to maintain this
  // information.
  // The first eight bytes are used for a signature
  // The next four bytes (9 to 12) do designate the type of the object
  // The next four bytes (13 to 16) do designate the pointer
  // on the window object  PWindowBase0  or a descendent
  // if in [100..199], it defines a dialog window.
  // if bigger than 200, it defines a control window.
  GGLCTE_NB_WND_EXTRA = 16;

  // designate the main window, not an MDI window
  GGLCTE_MAIN_WINDOW = 1;

  // designate the main window, which is an MDI window
  GGLCTE_MAIN_MDI_WINDOW = 2;

  // designate a non MDI window. (might be an independent one.)
  GGLCTE_A_WINDOW = 3;

  // designate the MDI client window
  GGLCTE_CLIENT_MDI_WINDOW = 4;

  // designate an MDI child window
  GGLCTE_CHILD_MDI_WINDOW = 8;

  // designate a popup window
  GGLCTE_POPUP_WINDOW = 9;

  // designate a Modal Dialog
  GGLCTE_A_DIALOG_Modal = 10;

  // designate a Modeless Dialog
  GGLCTE_A_DIALOG_Modeless = 11;

  // designate a toolBar
  GGLCTE_ToolBar = 15;

  GGLCTE_StatusLine         = 50;

  // if bigger than 200, it defines a control window.
  //'''''''''''''''''''''''''''''''''''''''''''''''''

  GGLCTE_CTRL_RichEdit       = 201;
  GGLCTE_CTRL_EditBox        = 202;
  GGLCTE_CTRL_ComboBox       = 203;

  GGLCTE_CTRL_ButtonBase     = 210;
  GGLCTE_CTRL_ButtonPush     = 211;
  GGLCTE_CTRL_ButtonBitMap   = 212;
  GGLCTE_CTRL_ButtonRadio    = 215;
  GGLCTE_CTRL_ButtonCheck    = 216;

  GGLCTE_CTRL_Static         = 220;

  GGLCTE_CTRL_Surf2DFrame    = 230;
  GGLCTE_CTRL_Draw3DFrame    = 231;

  // signature to avoid problems if windows where created
  // without using the library
  GGLCTE_SIGNATURE_WND_EXTRA = 2173465789; // 4 bytes signature

  // number of extra bytes reserved.
//  GGLCTE_NB_WND_EXTRA = 16; defined in wMDIWindow0.pp

type
  TSTRWinName = string[30];
  TSTRLabel   = string[180]; // quite long for a label.

  word32      = Cardinal;  // a 32 bits unsigned integer. [0..4'294'967'295]
  int32       = longint;   // a 32 bits   signed integer. [-2'147'483'648..2'147'483'647]
  word16      = word;      // a 16 bits unsigned integer. [0..65'535]]
  int16       = integer;   // a 16 bits   signed integer. [-32678..32767]
  Float       = Double;    // a real value coded on  8 bytes
  FloatS      = Single;    // a real value coded on  4 bytes (Not Used Often)
  FloatE      = Extended;  // a real value coded on 10 bytes (Not Used Often)
  Complex     = record     // a complex value. TComplex will be an associated object
    Re,Im     : Float;
    end;

  PWord32     = ^Word32;
  PInt32      = ^Int32;
  PFloat      = ^Float;
  PShortString = ^ShortString;

  TypeColor = record
     case byte of
      0 : (wColor : word32);
      1 : (bRed, bGreen, bBlue, bReserved:Byte);
     end;

  TypeArrayWord16  = array[0..100000000] of Word16;
  PTypeArrayWord16 = ^TypeArrayWord16;

  TypeArrayWord32  = array[0..100000000] of Word32;
  PTypeArrayWord32 = ^TypeArrayWord32;

  TypeArrayInt16  = array[0..100000000] of Int16;
  PTypeArrayInt16 = ^TypeArrayInt16;

  TypeArrayInt32  = array[0..100000000] of Int32;
  PTypeArrayInt32 = ^TypeArrayInt32;

  TypeArrayFloat  = array[0..100000000] of Float;
  PTypeArrayFloat = ^TypeArrayFloat;

  TypeArrayFloatS  = array[0..100000000] of FloatS;
  PTypeArrayFloatS = ^TypeArrayFloatS;

var
   gglstrClassWinName : string[30];
  // classname of the main window or later of a new window class name, if needed

  gglstrClassWinMDIChildName : string[30];
  // classname of MDI child windows.

// To use with TypeColor
operator := (wColorP:Word32) colorC:TypeColor;
operator := (colorC:TypeColor) wColorV:Word32;
function COLRGB(bRed,bGreen,bBlue:byte):Word32;

IMPLEMENTATION
//""""""""""""

var glnNotused : integer; // just to avoid an error while compiling with DevPascal

operator := (wColorP:Word32) colorC:TypeColor;
//============================================
begin
colorC.wColor:=wColorP;
end; // operator :=

operator := (colorC:TypeColor) wColorV:Word32;
//============================================
begin
wColorV:=colorC.wColor;
end; // operator :=

function COLRGB(bRed,bGreen,bBlue:byte):Word32;
//=============================================
begin
COLRGB:=(bBlue*256 + bGreen)*256 + bRed;
end;  // COLRGB

End.  // unit wGlobals2;

