/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : UtilsGui.pkg */ /* Version : 20 juin 2000 */ /* Scs Graphic Interface struct and basic functions */ /* */ /***************************************************************************************/ proto POPUPWIN_HideWhenDestroy = fun [ObjContainer I] ObjContainer ;; proto GRAPHICDRESSING_CRcompText = fun [Chn ObjContainer ObjNode [I I] I I I I S ObjFont [I I I I] [I I]] CompText ;; proto GRAPHICDRESSING_ShowCompText = fun [CompText I] ObjNode ;; proto GRAPHICDRESSING_ShowCompCombo = fun [CompCombo I] ObjNode ;; proto GRAPHICDRESSING_ShowCompRollOver = fun [CompRollOver I] ObjNode ;; proto GRAPHICDRESSING_ShowCompCheck = fun [CompCheck I] ObjNode ;; proto GRAPHICDRESSING_ShowCompList = fun [CompList I] ObjNode ;; /*************************************************************************************** * * - GESTION CLAVIER - * ***************************************************************************************/ fun UTILSGUI_OnKeyUp (cont, param, scancode) = /* Process KEY UP keyboard event */ { KEYBOARD_ProcessKeyUpCode scancode 0 ; } ;; fun UTILSGUI_OnKeyDown (cont, param, scancode, asciiCode) = /* Process KEY UP keyboard event */ { KEYBOARD_ProcessKeyDownCode scancode asciiCode ; } ;; /*************************************************************************************** * * Move a container on cursor move * * use initial x and y position defined in param * ***************************************************************************************/ fun UTILSGUI_Move (cont, param, x, y, bt) = let param -> [_ initx inity] in let _GETcontainerPositionSize cont -> [tx ty _ _] in let tx + (x - initx) -> xx in let ty + (y - inity) -> yy in _MOVEcontainer cont xx yy ;; /*************************************************************************************** * * Set the cursor move container callback on click * ***************************************************************************************/ fun UTILSGUI_Click (cont, param, x, y, bt, mask) = _CBcontainerCursorMove cont @UTILSGUI_Move [param x y] ;; /*************************************************************************************** * * Unset the cursor move container callback on unclick * ***************************************************************************************/ fun UTILSGUI_UnClick (cont, param, x, y, bt, mask) = _CBcontainerCursorMove cont nil nil ;; /*************************************************************************************** * * Unset the cursor move container callback on container kill focus * ***************************************************************************************/ fun UTILSGUI_KillFocus (cont, param) = _CBcontainerCursorMove cont nil nil ;; /*************************************************************************************** * * Set container callbacks for container move on cursor move * ***************************************************************************************/ fun UTILSGUI_MoveWithBackground (cont, param) = { /* _CBcontainerClick cont @UTILSGUI_Click param; _CBcontainerUnClick cont @UTILSGUI_UnClick param;*/ _CBcontainerKillFocus cont @UTILSGUI_KillFocus param ; /* Handles keyboard events */ _CBcontainerKeyUp cont @UTILSGUI_OnKeyUp param ; _CBcontainerKeyDown cont @UTILSGUI_OnKeyDown param ; } ;; /*************************************************************************************** * * Hide obj Node * ***************************************************************************************/ fun UTILSGUI_HideObjNode (objNode) = { _CHANGEobjNodeFlags objNode OBJ_HIDE 1 };; /*************************************************************************************** * * Show and enable obj Node * ***************************************************************************************/ fun UTILSGUI_ShowObjNode (objNode) = _CHANGEobjNodeFlags objNode OBJ_VISIBLE|OBJ_ENABLE 1 ;; /*************************************************************************************** * * Hide Comp Text * ***************************************************************************************/ fun UTILSGUI_HideText (text) = { /* UTILSGUI_HideObjNode _CONVERTcompTextToObjNode text*/ GRAPHICDRESSING_ShowCompText text 0 ; } ;; /*************************************************************************************** * * Hide and Empty Comp Text * ***************************************************************************************/ fun UTILSGUI_HideAndEmptyText (text) = { /* UTILSGUI_HideText _SETcompText text nil nil nil CT_BEGIN*/ GRAPHICDRESSING_ShowCompText (_SETcompText text nil nil nil CT_BEGIN) 0 ; } ;; /*************************************************************************************** * * Hide Comp List * ***************************************************************************************/ fun UTILSGUI_HideList (list) = { /* UTILSGUI_HideObjNode _CONVERTcompListToObjNode list*/ GRAPHICDRESSING_ShowCompList list 0 ; };; /*************************************************************************************** * * Hide and Empty Comp List * ***************************************************************************************/ fun UTILSGUI_HideAndEmptyList (list) = { /* UTILSGUI_HideList _RSTcompList list*/ GRAPHICDRESSING_ShowCompList (_RSTcompList list) 0 ; } ;; /*************************************************************************************** * * Hide Comp Combo * ***************************************************************************************/ fun UTILSGUI_HideCombo (combo) = { if combo == nil then nil else /* UTILSGUI_HideObjNode _CONVERTcompComboToObjNode combo*/ GRAPHICDRESSING_ShowCompCombo combo 0 ; };; /*************************************************************************************** * * Hide and Empty Comp Combo * ***************************************************************************************/ fun UTILSGUI_HideAndEmptyCombo (combo) = { if combo == nil then nil else /* UTILSGUI_HideCombo _RSTcompCombo combo*/ GRAPHICDRESSING_ShowCompCombo (_RSTcompCombo combo) 0 ; };; /*************************************************************************************** * * Hide Comp Roll Over * ***************************************************************************************/ fun UTILSGUI_HideRoll (roll) = { if roll == nil then nil else /* UTILSGUI_HideObjNode _CONVERTcompRollOverToObjNode roll*/ GRAPHICDRESSING_ShowCompRollOver roll 0 ; };; /*************************************************************************************** * * Show Comp Roll Over * ***************************************************************************************/ fun UTILSGUI_ShowRoll (roll) = { if roll == nil then nil else /* UTILSGUI_ShowObjNode _CONVERTcompRollOverToObjNode roll*/ GRAPHICDRESSING_ShowCompRollOver roll 1 ; };; /**************************************************************************************** * * Create or show a text or label interface element * Set the value for the text or label * and set the validation callback for the text * Return the text or label interface element created * * if compText already exist (parameter text) then it is shown and its value * and function callback is set * * Special parameters : * type : can be GUI_TEXT or GUI_LABEL * text : compText to be created or set * textfunction : callback function on text validation (can be nil for no callback) * param : callback function parameter * ****************************************************************************************/ var GUI_TEXT = 1;; var GUI_LABEL = 2;; fun UTILSGUI_SetOrCreateText (Channel, cont, type, text, textVal, pos, size, textfunction, param) = let if type == GUI_LABEL then [ OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_LABEL|CT_WORDWRAP OBJ_CONTAINER_CLICK|OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|(OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_KEYDOWN) ] else [ OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_EDITLINE OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE ] -> [flags filters] in if text == nil then ( let size -> [w h] in if type == GUI_LABEL then set text = _CRcompText Channel cont nil pos flags filters w h textVal scsgui.SCSGUIsmallFont [GD_DEFAULT_TEXT_COLOR nil 0 0] [GD_DEFAULT_TEXT_HIGHLIGHT_COLOR 50] nil nil else set text = GRAPHICDRESSING_CRcompText Channel cont nil pos flags filters w h textVal scsgui.SCSGUIsmallFont [GD_DEFAULT_TEXT_COLOR nil 0 0] [GD_DEFAULT_TEXT_HIGHLIGHT_COLOR 50]; 0 ) else ( GRAPHICDRESSING_ShowCompText text 1 ; _CHANGEobjNodeFlags _CONVERTcompTextToObjNode text flags 0; _SETcompText text textVal scsgui.SCSGUIsmallFont nil CT_NOCHANGE ; 0 ); if type == GUI_TEXT && textfunction != nil then _CBcompTextValidation text textfunction param CT_VALIDENTER|CT_VALIDCLICK else nil; text ;; /**************************************************************************************** * * Create or show a text or label interface element * Set the value for the text or label * and set the validation callback for the text * Return the text or label interface element created * * if compText already exist (parameter text) then it is shown and its value * and function callback is set * * Special parameters : * type : can be GUI_TEXT or GUI_LABEL * text : compText to be created or set * textfunction : callback function on text validation (can be nil for no callback) * param : callback function parameter * flags : CompText creation flags * ****************************************************************************************/ fun UTILSGUI_SetOrCreateTextEx (Channel, cont, type, text, textVal, pos, size, textfunction, param, nflags) = /* Allows to pass creation flags */ let if type == GUI_LABEL then [ nflags OBJ_CONTAINER_CLICK|OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|(OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_KEYDOWN) ] else [ nflags OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE ] -> [flags filters] in if text == nil then ( let size -> [w h] in if type == GUI_LABEL then set text = _CRcompText Channel cont nil pos flags filters w h textVal scsgui.SCSGUIsmallFont [GD_DEFAULT_TEXT_COLOR nil 0 0] [GD_DEFAULT_TEXT_HIGHLIGHT_COLOR 50] nil nil else set text = GRAPHICDRESSING_CRcompText Channel cont nil pos flags filters w h textVal scsgui.SCSGUIsmallFont [GD_DEFAULT_TEXT_COLOR nil 0 0] [GD_DEFAULT_TEXT_HIGHLIGHT_COLOR 50]; 0 ) else ( GRAPHICDRESSING_ShowCompText text 1 ; _CHANGEobjNodeFlags _CONVERTcompTextToObjNode text flags 0; _SETcompText text textVal scsgui.SCSGUIsmallFont nil CT_NOCHANGE ; 0 ); if type == GUI_TEXT && textfunction != nil then _CBcompTextValidation text textfunction param CT_VALIDENTER|CT_VALIDCLICK else nil; text ;; /*************************************************************************************** * * Create an alpha bitmap filled with one color * ***************************************************************************************/ fun UTILSGUI_CreateRect (Channel, color, w, h) = let _FILLbitmap _CRbitmap Channel w h color -> bitmap in let _CRalphaBitmap Channel bitmap nil nil nil -> alpha in ( _DSbitmap bitmap; alpha; ) ;; /*************************************************************************************** * * Create an alpha bitmap filled with one color and with text * ***************************************************************************************/ fun UTILSGUI_CreateRectWithText (Channel, color, w, h, text, textcolor) = let _FILLbitmap _CRbitmap Channel w h color -> bitmap in ( if text == nil then nil else _DRAWrectangleText bitmap scsgui.SCSGUIsmallFont (w-200)/2 (h-15)/2 200 15 textcolor TD_CENTER text; let _CRalphaBitmap Channel bitmap nil nil nil -> alpha in ( _DSbitmap bitmap; alpha; ) ) ;; fun UTILSGUI_TileBitmapOnY (bitmap, fillBitmap, x, y, w, h, maxH) = _CPbitmap16 bitmap x y fillBitmap 0 0 w h nil; if ((y+h) < maxH) then UTILSGUI_TileBitmapOnY bitmap fillBitmap x (y+h) w h maxH else 0 ;; fun UTILSGUI_TileBitmap (bitmap, fillBitmap, x, y, w, h, maxW, maxH) = UTILSGUI_TileBitmapOnY bitmap fillBitmap x y w h maxH; if ((x+w) < maxW) then UTILSGUI_TileBitmap bitmap fillBitmap x+w y w h maxW maxH else 0 ;; fun UTILSGUI_FillBitmapInBitmap (bitmap, bitmapFill, typeBitmap) = let _GETbitmapSize bitmap -> [w1 h1] in let _GETbitmapSize bitmapFill -> [w2 h2] in if typeBitmap & DOCstretched then _SCPbitmap bitmap 0 0 w1-1 h1-1 bitmapFill 0 0 w2-1 h2-1 nil else if typeBitmap & DOCtiled then ( UTILSGUI_TileBitmap bitmap bitmapFill 0 0 w2 h2 w1 h1; nil ) else _CPbitmap16 bitmap (w1-w2)/2 (h1-h2)/2 bitmapFill 0 0 w2 h2 nil ;; /*************************************************************************************** * * Create an alpha bitmap filled with one color, text and bitmap * ***************************************************************************************/ fun UTILSGUI_CreateRectWithTextAndBitmap (Channel, color, w, h, text, textcolor, bitmapFill, typeBitmap) = let _FILLbitmap _CRbitmap Channel w h color -> bitmap in ( if bitmapFill == nil then nil else UTILSGUI_FillBitmapInBitmap bitmap bitmapFill typeBitmap; if text == nil then nil else _DRAWrectangleText bitmap scsgui.SCSGUIsmallFont (w-200)/2 (h-15)/2 200 15 textcolor TD_CENTER text; let _CRalphaBitmap Channel bitmap nil nil nil -> alpha in ( _DSbitmap bitmap; alpha; ) ) ;; fun UTILSGUI_UnrollTree (tree, pos) = if pos == nil then nil else UTILSGUI_UnrollTree tree list_without_last_element pos; _SETcompTreeState tree pos TRE_EXPAND ;; fun UTILSGUI_SETcompTreeClicked (tree, pos) = UTILSGUI_UnrollTree tree list_without_last_element pos; /* _SETcompTreeFirst tree pos; MAT ICI MAC ICI desactive, fonctionnement assez genant a revoir */ _SETcompTreeClicked tree pos ;; fun UTILSGUI_UNSETcompTreeClicked (tree) = _SETcompTreeClicked tree (-1)::nil; _PAINTobjNode _CONVERTcompTreeToObjNode tree ;; fun UTILSGUI_BuildPalette () = let mktab 768 0 -> palette in ( let 0 -> i in while (i<256) do ( set palette.(i*3) = i; set palette.((i*3)+1) = i; set palette.((i*3)+2) = i; set i = i + 1 ); palette ) ;; fun UTILSGUI_GetCuttedText (text, limited, font) = if (realGETstringW font text) <= limited then text else UTILSGUI_GetCuttedText (substr text 0 ((strlen text) -1)) limited font ;; fun UTILSGUI_CutTextToFitSize (text, w, replace, font) = if (text == nil) || (w <0) || (w == nil) then nil else let (realGETstringW font text) -> textSize in if textSize <= w then text else let w - (realGETstringW font replace) -> limited in strcat (UTILSGUI_GetCuttedText text limited font) replace ;; fun UTILSGUI_ForceCBresize (obnode) = let _GETobjNodePositionSizeInFatherRef obnode -> [_ _ w h] in ( _SIZEobjNode obnode w+1 h+1 0; /* MAC ICI force le resize !!! */ _SIZEobjNode obnode w h 1; ) ;;