# GRAPHIC DRESSING

# - Librairie d'habillage graphique standardisé -

#

## But

Encapsuler la création des composants graphiques de la LIB2D de cryonetworks en utilisant des ressources graphiques standardisées dans un fichier de thème (.THM).

Pour fonctionner, la librairie a besoin des fichiers suivants :

- GRAPHICDRESSING.PKG

- TITLEBAR.PKG

- PROTOGRAPHICDRESSING.PKG

- CREATEWINDOW.PKG

- un fichier thème (par exemple SCS.THM)

- Les ressources graphiques au format PNG correspondant au thème.

## PRINCIPE DE FONCTIONNEMENT

Ce package a été conçu de manière à faciliter au maximum la migration des interfaces basées sur la LIB2D en encapsulant chaque fonction de création de composant graphique en conservant sa déclaration, hormis certains paramètres de bitmaps qui n'ont plus à être passés.

Pour utiliser cette librairie, vous devez l'initialiser une fois pour toute, et ce avant toute utilisation de vos ressources graphiques. Typiquement, il faut appeler la fonction GRAPHICDRESSING_InitDressing() dans le point d'entrée de votre projet. Enfin, vous devez ensuite modifier le code de cette fonction pour positionner certaines variables (cf tableau ci-dessous).

D'autre part, il est important si vous créez des composants de les détruire proprement si vous n'en avez plus besoin en appelant les fonctions correspondantes.

Exemples :

- Création d'un CompText :
  Avec la LIB2D : _CRcompText chan cont fathernode coord flags filterflags width height textmessage font textinfo transparencyinfo alphaBitmap1 alphaBitmap2 ;
  Avec ce package : GRAPHICDRESSING_CRcompText chan cont fathernode coord flags filterflags width height textmessage font textinfo transparencyinfo ;

- Destruction d'un CompRollOver :
  Avec la LIB2D : _DScompRollOver rollover ;
  Avec ce package : GRAPHICDRESSING_DScompRollOver rollover ;

- Apparition ou Dissimulation d'un CompCombo :
  Avec la LIB2D : _CHANGEobjNodeFlags _CONVERTcompComboToObjNode combo ;
  Avec ce package : GRAPHICDRESSING_ShowCompCombo combo [1/0] ;

En pratique et de manière générale, il suffit de préfixer toutes les fonctions de création ou destruction de la LIB2D par le mot clef "GRAPHICDRESSING_" et d'enlever les derniers paramètres concernant les bitmaps de ressources. Les fonctions de dissimulation ou d'apparition d'éléments sont présentes et ont été simplifiées.

##

## DESCRIPTION DU PACKAGE

Voici les fonctions publiques disponibles à l'utilisation. Leur fonctionnement correct est assujetti à la qualité de votre fichier de thème, qui doit recenser toutes les ressources graphiques de votre application de manière précise en suivant le format communément admis. Le fichier SCS.THM est un bon exemple de fichier de thème valide.

- ## Fonctions d'initialisation

- fun GRAPHICDRESSING_InitDressing()

Entry point of whole GraphicDressing package : must be called within your project at an early state, for instance in your entry point function.

Must be followed when needed by a call to these functions, in order to set the proper default variables :

- GRAPHICDRESSING_SetBackgroundColor
- GRAPHICDRESSING_SetCurrentDirectoryPath
- GRAPHICDRESSING_SetDefaultFont
- GRAPHICDRESSING_SetHandleEvents
- GRAPHICDRESSING_SetLocaleFunction
- GRAPHICDRESSING_SetTheme
- GRAPHICDRESSING_SetTransparencyColor
- GRAPHICDRESSING_CBloadBitmap

- fun GRAPHICDRESSING_SetBackgroundColor(rgbcolor)

Sets the default background color used when creating graphic components ;

Typically this info is extracted automatically from the Theme file within the GRAPHICDRESSING_SetTheme function call.

- fun GRAPHICDRESSING_SetCurrentDirectoryPath (path)

Sets the current directory path where bitmap files are to be found.

Typically this info is extracted automatically from the Theme file within the GRAPHICDRESSING_SetTheme function call.

- fun GRAPHICDRESSING_SetDefaultFont (font)

Sets the default font to be used when displaying text within graphic components.

The call to this function is optional since a default font is set in GRAPHICDRESSING_InitDressing to Arial, 14, normal.

- fun GRAPHICDRESSING_SetHandleEvents (events)

Sets the default events to pass to the container upon components creation - This argument will be passed as the lib2d filtrageflags parameter.

- fun GRAPHICDRESSING_SetLocaleFunction (funvar)

Sets the default handler function for text locale resolution, of form fun [S key [S param r1]] S.

A default locale function is provided which simply returns the string "Locale error". You should then call this function with your own locale function handler.

- fun GRAPHICDRESSING_SetTransparencyColor (color)

Sets the default transparency color used when loading bitmap files to be blitted onto graphic components ;

Typically this info is extracted automatically from the Theme file within the GRAPHICDRESSING_SetTheme function call.

- fun GRAPHICDRESSING_SetTheme (themeFile)

Sets the current theme to work with - All further graphic dressing function will use the new theme you specify.

WARNING : the call to this function must be accomplished before any attempt to use another "SET" functions, since GRAPHICDRESSING_SetTheme performs inner calls to the "SET" functions from the informations contained in theme file.

- fun GRAPHICDRESSING_CBloadBitmap (loadbitmapfun)

Sets the default handler function for bitmap file loading, of form fun [S filepath Chn channel] AlphaBitmap.

The call to this function is optional since a default function is provided - which simply returns an alphaBitmap as follows :

_LDalphaBitmap channel _checkpack filepath ;

- ## Fonctions de lecture des variables de dressing

- GRAPHICDRESSING_GetCurrentBackgroundColor()

Retrieves the current background color

- GRAPHICDRESSING_GetCurrentDefaultFont

Retrieves the current default font

- GRAPHICDRESSING_GetCurrentDefaultHandleEvents

Retrieves the events passed to the container as parameter filterflags

- GRAPHICDRESSING_GetCurrentTheme

Retrieves the current theme

- GRAPHICDRESSING_GetCurrentTransparencyColor

Retrieves the current transparency color

- ## Fonctions de création de composants

- fun GRAPHICDRESSING_CRcompCheck(chan, cont, fathernode, coord, flags, filterflags)

Encapsulation of _CRcompCheck function of Lib2D

- fun GRAPHICDRESSING_CRcompCheckCustom(chan, cont,fathernode, coord, flags, filterflags, alphaicone, prefix)

Encapsulation of _CRcompCheck function of Lib2D plus a new parameter - prefix.

This parameter is used to select the proper compCheck resources within the theme file, if required.

- fun GRAPHICDRESSING_CRcompCheckMaxi(chan, cont, fathernode, coord, flags, filterflags, alphaicone)

Encapsulation of _CRcompCheck function of Lib2D, same as GRAPHICDRESSING_CRcompCheckCustom using the prefix "MAXI_"

- fun GRAPHICDRESSING_CRcompCheckMiddle(chan, cont, fathernode, coord, flags, filterflags, alphaicone)

Encapsulation of _CRcompCheck function of Lib2D, same as GRAPHICDRESSING_CRcompCheckCustom using the prefix "MIDDLE_"

- fun GRAPHICDRESSING_CRcompCheckMini(chan, cont, fathernode, coord, flags, filterflags, alphaicone)

Encapsulation of _CRcompCheck function of Lib2D, same as GRAPHICDRESSING_CRcompCheckCustom using the prefix "MINI_"

- fun GRAPHICDRESSING_CRcompCheckTransparent(chan, cont,fathernode, coord, flags, filterflags, alphaicone)

Encapsulation of _CRcompCheck function of Lib2D, same as GRAPHICDRESSING_CRcompCheckCustom using no prefix and no background compCheck resource

- fun GRAPHICDRESSING_CRcompCheckOval(chan, cont, fathernode, coord, flags, filterflags, alphaicone)

Encapsulation of _CRcompCheck function of Lib2D, same as GRAPHICDRESSING_CRcompCheckCustom using the prefix "OVAL_"

- fun GRAPHICDRESSING_CRcompCombo(chan, cont, fathernode, coord, flags, filterflags, width, height, font, textinfo , transparencyinfo,reservedbmpspace)

Encapsulation of _CRcompCombo function of Lib2D.

WARNING : Do not forget the last new parameter.

- fun GRAPHICDRESSING_CRcompList(chan, cont, fathernode, coord, flags, filterflags, width, height, nbvisibleitems, direction, font, iconspace, textinfo, transparencyinfo)

Encapsulation of _CRcompList function of Lib2D

- fun GRAPHICDRESSING_CRcompRollOver(chan, cont, fathernode, coord, flags, filterflags)

Encapsulation of _CRcompRollOver function of Lib2D

- fun GRAPHICDRESSING_CRcompRollOverMaxi(chan, cont, fathernode, coord, flags, filterflags, alphaicone)

Encapsulation of _CRcompRollOver function of Lib2D, using prefix "MAXI_" to select the proper resource in theme file.

- fun GRAPHICDRESSING_CRcompRollOverMiddle(chan, cont, fathernode, coord, flags, filterflags, alphaicone)

Encapsulation of _CRcompRollOver function of Lib2D, using prefix "MIDDLE_" to select the proper resource in theme file.

- fun GRAPHICDRESSING_CRcompRollOverMini(chan, cont, fathernode, coord, flags, filterflags, alphaicone)

Encapsulation of _CRcompRollOver function of Lib2D, using prefix "MINI_" to select the proper resource in theme file.

- fun GRAPHICDRESSING_CRcompRollOverOval(chan, cont, fathernode, coord, flags, filterflags, alphaicone)

Encapsulation of _CRcompRollOver function of Lib2D, using prefix "OVAL_" to select the proper resource in theme file.

- fun GRAPHICDRESSING_CRcompRollOverWithText(chan, cont, fathernode, coord, flags, filterflags,width, height, font, slabel, txtcolor)

Encapsulation of _CRcompRollOver function of Lib2D, adding a text message (given a text color and font).

Width and height of Button - Text message will be centered given these values, typically defined by a call to _GETstringSize function.

- fun GRAPHICDRESSING_CRcompText(chan, cont, fathernode, coord, flags, filterflags, width, height, textmessage, font, textinfo , transparencyinfo)

Encapsulation of _CRcompText function of Lib2D

- fun GRAPHICDRESSING_CRcompTree(chan, cont, fathernode, coord, flags, filterflags, width, height, nbvisibleitems, direction, font, reservedspace, levelshift, textinfo , transparencyinfo)

Encapsulation of _CRcompTree function of Lib2D

- fun GRAPHICDRESSING_CRsizeBar(chan,cont,node,coord,flags,filtrageflags,w,h,dir)

Encapsulation of _CRsizeBar function of Lib2D

- ## Fonctions de création de container et barres de titre

- fun GRAPHICDRESSING_CRcontainer (Channel, father, possize, minmaxsize, bgcolor, title, font, textcol, flags, reflexes)

Creates a container as follows

This function creates a container with borders, title bar and buttons according to the flag passed as an argument :

- Channel
- father: the ObjContainer father of the new created container.
- possize: contains x, y, w, and h for the new created window(container).
- minmaxsize: contains min width, min height, max width and max height of the container (if min and max sizes are equal the window is not resizable)
- bgcolor: is the integer for the background color.
- title is the string specifying the container's title label
- font: is the ObjFont for the title text.
- textcol is the title label text color
- flags: specify the kind of window to create, defined as follows :

- var GDWIN_ROLL_OFF = 0b0000000000;; /* la fenêtre ne s'enroule pas */
- var GDWIN_ROLL_DBLCLICK = 0b0000000001;; /* la fenêtre s'enroule si on double click sur la barre de titre */
- var GDWIN_ROLL_CURHOVER = 0b0000000010;; /* la fenêtre s'enroule si le curseur quitte le container */
- var GDWIN_ROLL_MINBUT = 0b0000000011;; /* la fenêtre s'enroule si on clicke sur le bouton minimiser */
- var GDWIN_NO_CALLBACKS = 0b0000000100;; /* aucune callback n'est définie sur le container */
- var GDWIN_BORDERS = 0b0000001000;; /* add a border to the container */
- var GDWIN_TITLE_BAR = 0b0000010000;; /* add title bar to the container */
- var GDWIN_CLOSE_BUTTON = 0b0000110000;; /* add a close button to the titlebar */
- var GDWIN_MAX_BUTTON = 0b0001010000;; /* add a max/restore button to the titlebar */
- var GDWIN_MIN_BUTTON = 0b0010010000;; /* add a minimize button to the titlebar */
- var GDWIN_CENTER_TITLE = 0b0000000000;; /* position of the title (centered by default)*/
- var GDWIN_LEFT_TITLE = 0b0100000000;;
- var GDWIN_RIGHT_TITLE = 0b1000000000;;
- var GDWIN_SIZEBOX = 0b0011111000;; /* complete window with borders and buttons */

- reflexes: are 3 callbacks for the three buttons (min,max,close).

Returns a vector of form [cont compTitle compMin compMax compClose _] containing :
- the created container
- the title label compText
- the three buttons object (CompRollOver for the min button, CompCheck for the max/restore button and a CompRollOver for the close button)
- vector [x y w h] corresponding to the client area inner position of created container

- fun GRAPHICDRESSING_CRcontainerFromObjWin (Channel, father, possize, minmaxsize, bgcolor, title, font, textcol, flags, reflexes)

Same as GRAPHICDRESSING_CRcontainer but father represents a ObjWin. The container will be created a child window.

proto :

fun [Chn ObjWin [I I I I] [I I I I] I S ObjFOnt [I I I I] I [fun[]I fun[]I fun[]I] ] [ObjContainer CompText CompRollOver CompCheck CompRollOver ClientSizePos]

- fun GRAPHICDRESSING_CRcontainerWithObjWin (Channel, win, possize, minmaxsize, bgcolor, title, font, textcol, flags, reflexes)

Same as GRAPHICDRESSING_CRcontainer given an ObjWin within where the new container will be created.

- fun GRAPHICDRESSING_CRtitleBar(chan,cont,minmaxsize,font,text,textinfo,flag,fmin,fmax,fclose)

Creates a title bar to add to your self made containers.

- ## Fonctions de création de boîtes de dialogue

- fun GRAPHICDRESSING_DialogBox(sTitle, sSubTitle, sTextMessage, nCreationFlags, funcallback, yourparam)

Creates a dialog box according to the flags passed in nCreationFlags :

- GDBOXFLAGS_YESNO creates a dialog box with 2 user options as an answer : YES or NO (closing cross in the upper right hand corner means NO)

- GDBOXFLAGS_YESNOCANCEL creates a dialog box with YES, NO and CANCEL buttons (closing cross in the upper right hand corner means CANCEL)

- GDBOXFLAGS_OK creates a dialog box with a simple OK button

- GDBOXFLAGS_OKCANCEL creates a dialog box with YES & CANCEL buttons (closing cross in the upper right hand corner means CANCEL)

You have to specify a function callback of form

fun OnCloseDialogBox(comprollover, param, posx, posy, btn, mask)

to process the dialog box return value (passed as parameter param)

Typically at the beginning of your callback function :

let param -> [ cont retval yourparam] in

where retval can be one of the following values :

- GDBOX_YES
- GDBOX_NO
- GDBOX_OK
- GDBOX_CANCEL

- fun GRAPHICDRESSING_MessageBox(sTitle, sSubTitle, sTextMessage)

Creates a simple dialog box which displays your text message.

No callback function will be called upon the dialog box closing.

##

- ## Fonctions de destruction

- fun GRAPHICDRESSING_DScompCheck(compobj)

- fun GRAPHICDRESSING_DScompCombo(compobj)

- fun GRAPHICDRESSING_DScompRollOver(compobj)

- fun GRAPHICDRESSING_DScompText(compobj)

- fun GRAPHICDRESSING_DScompTree(compobj)

- fun GRAPHICDRESSING_DScompList(compobj)

Destroy the graphic component given as parameter.

- ## Fonctions de dissimulation/apparition de composants

- fun GRAPHICDRESSING_ShowCompCheck(compobj, bool)

- fun GRAPHICDRESSING_ShowCompTree(compobj, bool)

- fun GRAPHICDRESSING_ShowCompList(compobj, bool)

- fun GRAPHICDRESSING_ShowCompText(compobj, bool)

- fun GRAPHICDRESSING_ShowCompRollOver(compobj, bool)

- fun GRAPHICDRESSING_ShowCompCombo(compobj, bool)

Call this function to make visible or to hide a graphic component.

IN parameters :

- compobj (the compobj object you want to make visible or invisible

- bool (bool is a boolean value : TRUE if component must become visible, FALSE otherwise )

RETURN VALUE : returns bool

> File last revision : October, 8th 2000.