
; Design-time information is information that Fresh uses in the process
; of visual design of the windows.
; This info describes what styles are allowed for this control,
; what is his classname, what are the names of styles, what files
; contains executable code for the control (if any) what will be the
; icon on the control panel, etc. (Look at TDesignTimeInfo for full
; description.)
;
; Every control used in the visual form designer must have this
; description, even Windows standard controls like BUTTON.
;
; Design-time info is binary data that is created using FASM compiler.
; For the example look at 'BUTTON.asm' file. It must be compiled
; to get exact binary design-time data file.
;
; Of course it is possible to make Fresh to compile this files on every
; run and to get directly binary info in memory, but I think that first
; version will be with pre-compiled files. ( The reason is simply
; that FASM compiler still doesn't work in Fresh :) )
;
; On running, Fresh will read these files from 'controls' subdir of 'include' dir
; and will add controls to the control palette. Then Fresh will use
; this information in design process to ensure proper handling for different
; controls.

; This is first version of the structure, so, there WILL be changes.
; More, here is not specifyed how Fresh will handle executable code for
; user defined controls. I have some ideas, but still not clear, so, This
; will be specifyed later.

; This is data structure, describing some information about
; Fresh visual components.

struc TDesignTimeInfo {

  .ClassName       dd ?    ; offset to class name string.
  .ControlHint     dd ?    ; offset to hint string.
  .Palette         dd ?    ; offset to palette name string.
  .DefaultText     dd ?    ; offset to default control text.
  .DefaultStyle    dd ?    ; Default window style.
  .DefaultStyleEx  dd ?    ; Default window styleEx.

; Default window width and height on the creation in the form designer when
; the user simply click on the form or the size he specify is too small.
  .DefaultWidth    dd ?
  .DefaultHeight   dd ?

  .StyleNames      dd ?    ; offset to private style names list for this component.
  .StyleExNames    dd ?    ; offset to private styleEx names list for this component.

  .StyleMaskAnd    dd ?    ; Styles that must be 0 for this component.
  .StyleMaskOr     dd ?    ; Styles that must be 1 for this component.

  .StyleExMaskAnd  dd ?    ; The Ex styles that must be 0 for this component.
  .StyleExMaskOr   dd ?    ; Ex Styles that must be 1 for this component.

  .SubtypeMask     dd ?    ; this is the mask for separating subtype part from style word.
                           ; For example for BUTTON class this is $0000000f, because low 4
                           ; bits from Style are not bit flags, but number of button subtype.

  .SubtypeRange    dd ?    ; offset to the list like WinStyles with allowed subtypes numbers,
                           ; names and descriptions.

  .LibFile         dd ?    ; if the component is not standard component, this is
                           ; the name of the file containing the source code for the
                           ; component. NULL for standard windows components.
  .ImageFile       dd ?    ; offset to the image filename 16x16 pixels bitmap for toolbar icon.
}

; NOTE: Don't use "struct" macro here. This file is used sometimes as standalone,
; without "struct" support.
virtual at 0
  TDesignTimeInfo TDesignTimeInfo
  sizeof.TDesignTimeInfo = $
end virtual


macro  WinStyles [_value, _dsc] {

  common
    local index

    index = 0
  forward

    index = index + 1

  common

   dd index             ; The first dword is count of the items in the list.

  forward

    local name, namelen, hint, hintlen

; Style value
            dd  _value

; Style name - Pascal string - the first byte is length of the string.
            db  namelen
    name    db  `_value, 0
    namelen =   $ - name

; Style description - Pascal string.
            db  hintlen
    hint    db  _dsc, 0
    hintlen =   $ - hint
}



macro DesignTimeInfo [ classname,       \; Control class name
                       hint,            \; Short description for the button on the tool palette.
                       palette,         \; The name of the palette, where control will reside.
                       deftext,         \; Default text for the control when it is created.
                       defstyle,        \; Default style for the control.
                       defstyleex,      \; Default StyleEx for the control.
                       defwidth,        \; Default width of the control.
                       defheight,       \; Default height
                       StyleNames,      \; List with names and numbers for styles private for the control.
                       StyleExNames,    \; List with names and numbers for styleEx.
                       StyleMaskAnd,    \; Mask for bits forced to 0 in Style
                       StyleMaskOr,     \; Mask for bits forced to 1 in Style
                       StyleExMaskAnd,  \; Mask for bits forced to 0 in StyleEx
                       StyleExMaskOr,   \; Mask for bits forced to 1 in StyleEx
                       SubtypeMask,     \; Mask for lower x bits, that are subtype number.
                       SubtypeRange,    \; List with names and numbers for subtypes.
                       LibFile,         \; string with library file with design time procedures.
                       ImageFile        \; string with file name for icon in the tool palette. Must be 24x24 icon file.
                     ] {

forward ; Array of TDesignTimeInfo structures.

  local base, namestr, deftxt, subtype, stylenm, styleexnm, filename, image, hintstr, pal

        label base dword
        dd      namestr - base
        dd      hintstr - base
        dd      pal - base
        dd      deftxt - base
        dd      defstyle
        dd      defstyleex
        dd      defwidth
        dd      defheight
        dd      stylenm - base
        dd      styleexnm - base
        dd      StyleMaskAnd xor $ffffffff
        dd      StyleMaskOr
        dd      StyleExMaskAnd xor $ffffffff
        dd      StyleExMaskOr
        dd      SubtypeMask
        dd      subtype - base

  if LibFile eq NONE
        dd      base
  else
        dd      filename - base
  end if

  if ImageFile eq NONE
        dd      base
  else
        dd      image - base
  end if

common

        dd 0    ; End of the array of TDesignTypeInfo.

forward ; Array of classname strings.

namestr db      classname, 0

forward ; Array of hint strings.

hintstr db      hint,0

forward ; Array of Palette names

pal     db      palette,0

forward ; Array of subtype ranges

if ~ (SubtypeRange eq NONE)
  label subtype
          WinStyles SubtypeRange
else
  subtype = base
end if

forward ; List with stylenames.

if ~ (StyleNames eq NONE)
  label stylenm
          WinStyles StyleNames
else
  stylenm = base
end if

forward ; List with styleEx names.

if ~ (StyleExNames eq NONE)
  label styleexnm
          WinStyles StyleExNames
else
  styleexnm = base
end if

forward ; library filenames.

  if ~(LibFile eq NONE)
    filename db LibFile, 0
  end if

forward

  if ~ (ImageFile eq NONE)
    image db ImageFile, 0
  end if

forward ; Array of default text strings.
  deftxt db deftext, 0
}

