/* fichier relatif à la création de la ToolBar avec différentes fonctions associées à différents type (button,check,text) */ struct ToolBar=[ TBwin :ObjWin, TBgroupbutton :[[I ObjButton] r1], TBgroupcheck :[[I ObjCheck] r1], TBgrouptext :[[I ObjText] r1], TBenterPos :fun [[I I I] [I I I]] I, TBenterScale :fun [I] I, TBfuncs :[[I fun [I] I] r1] ]mkToolBar;; typeof Tool=ToolBar;; /* Id pour les différentes fonctions */ var CHECK_VIEW =1;; var CHECK_PAN =2;; var CHECK_PROFONDEUR =3;; var CHECK_MOVE =4;; var ROL_MINMAXTOGGLE =5;; var CHECK_ROTATE =6;; var CHECK_SCALE =7;; var TEXT_X =8;; var TEXT_Y =9;; var TEXT_Z =10;; var TEXT_A =11;; var TEXT_B =12;; var TEXT_C =13;; var TEXT_SCALE =14;; var ROL_CLOSE =15;; var ROL_GLOBALREF =16;; var TEXT_W =17;; var TEXT_H =18;; var TEXT_D =19;; var CHECK_POS =20;; var ROL_CENTER =21;; var ROL_SAVE =22;; var APP =23;; /*var CREATE =24;;*/ var TEXT_POS =25;; var TEXT_SIZE =26;; var TEXT_ANGLE =27;; var TEXT_1 =28;; var TEXT_2 =29;; var TEXT_3 =30;; var TEXT_4 =31;; fun searchtypefunc(p, type) = let p -> [t _] in (t==type) ;; /************************************** Fonction reflexe de clic dans un CompRollOver ***************************************/ fun TOOL_Activate (param) = /* execute la bonne fonction en fct du type Rotate,Scale ... */ let param -> [type t] in exec switch t.TBfuncs type with [type] ;; fun TOOL_Quit (win11, param) = _DSwindow win11; set Tool.TBwin = nil; TOOL_Activate param ;; fun TOOL_Close () = if Tool.TBwin != nil then ( _DSwindow Tool.TBwin; set Tool.TBwin = nil ) else nil; 0 ;; fun TOOL_New (x,y,rw,rh,father)= let _CRwindow _channel father x y rw rh WN_MENU _loc this "TOOL_NAME_WIN" nil -> win11 in /* MODIF 11-10 */ let mkToolBar[win11 nil nil nil nil nil nil] -> t in ( _CBwinClose win11 @TOOL_Quit [ROL_CLOSE t]; t ) ;; /************************************ Fonction reflexe de clic dans un Check *************************************/ fun CBcheckClick(check,param,state)= if state then TOOL_Activate param else nil ;; /*********************************** fonction de creation d'un Check ************************************/ fun CHECK_Create(t, name, x, y, w, h, type) = let _CRcheck _channel t.TBwin x y w h CH_RADIO name -> check in ( _CBcheck check @CBcheckClick [type t]; set t.TBgroupcheck=[type check]::t.TBgroupcheck; check ) ;; /************************************ Fonction reflexe de clic dans un Button *************************************/ fun CBrollClick(butt, param) = TOOL_Activate param ;; /****************************************** Fonction de creation d'un Button *******************************************/ fun ROLLOVER_Create (t, name, x, y, w, h, type) = let _CRbutton _channel t.TBwin x y w h 0 name -> but in ( _CBbutton but @CBrollClick [type t]; set t.TBgroupbutton=[type but]::t.TBgroupbutton; but ) ;; fun getTextVal(t, type) = _GETtext switch t.TBgrouptext type ;; fun DegToInt(i)=i*182;; fun IntToDeg(i)=i/182;; /********************************************** Fonction reflexe de 'ENTER' dans texte editable ***********************************************/ fun CBtextValidation(txt, param, s) = let param -> [t type] in ( if !strcmp s "" then _SETtext txt if type==TEXT_SCALE then "100" else "0" else nil; if type==TEXT_SCALE then exec t.TBenterScale with [atoi getTextVal t TEXT_SCALE] else exec t.TBenterPos with [[atoi getTextVal t TEXT_X atoi getTextVal t TEXT_Y atoi getTextVal t TEXT_Z] [DegToInt atoi getTextVal t TEXT_B DegToInt atoi getTextVal t TEXT_A DegToInt atoi getTextVal t TEXT_C] ] ); 0 ;; /**************************************** fonction de creation d'un texte editable *****************************************/ fun TEXT_Create (t, name, x, y, w, h, type) = let strcat name " :" -> label in let _ENtext _CReditLine _channel t.TBwin x+50 y w-50 h ET_BORDER|ET_ALIGN_RIGHT "" 0 -> txt in /* MODIF 11-10 */ ( _CBlineOk txt @CBtextValidation [t type]; set t.TBgrouptext=[type txt]::t.TBgrouptext; _CRtext _channel t.TBwin x y 50 h ET_ALIGN_RIGHT label; txt; ) ;; fun LABEL_Create (t, text, x, y, w, h, type) = /**/ let _CRtext _channel t.TBwin x y w h ET_ALIGN_LEFT text -> txt in ( set t.TBgrouptext=[type txt]::t.TBgrouptext; txt ) ;; /********************************** Fonction de creation de la toolbar /* MODIF 11-10 */ **********************************/ fun TOOL_Create (x, y, father) = set Tool=TOOL_New x y 200 530 father; /* les boutons */ ROLLOVER_Create Tool (_loc this "TOOL_MINMAX" nil) 10 10 150 20 ROL_MINMAXTOGGLE; ROLLOVER_Create Tool (_loc this "TOOL_CENTER" nil) 10 30 150 20 ROL_CENTER; ROLLOVER_Create Tool (_loc this "TOOL_GLOBALREF" nil) 10 50 150 20 ROL_GLOBALREF; CHECK_Create Tool (_loc this "TOOL_VIEW" nil) 10 80 150 20 CHECK_VIEW; CHECK_Create Tool (_loc this "TOOL_PAN" nil) 10 100 150 20 CHECK_PAN; CHECK_Create Tool (_loc this "TOOL_DEEP" nil) 10 120 150 20 CHECK_PROFONDEUR; CHECK_Create Tool (_loc this "TOOL_MOVE" nil) 10 140 150 20 CHECK_MOVE; CHECK_Create Tool (_loc this "TOOL_ROTATE" nil) 10 160 150 20 CHECK_ROTATE; CHECK_Create Tool (_loc this "TOOL_SCALE" nil) 10 180 150 20 CHECK_SCALE; LABEL_Create Tool /*(_loc this "TOOL_POSITION" nil)*/ (_loc this "POS_GLOBAL" nil) 10 220 150 20 TEXT_POS; TEXT_Create Tool "x" 10 240 150 20 TEXT_X; TEXT_Create Tool "y" 10 260 150 20 TEXT_Y; TEXT_Create Tool "z" 10 280 150 20 TEXT_Z; TEXT_Create Tool (_loc this "TOOL_SCALEINF" nil) 10 380 150 20 TEXT_SCALE; LABEL_Create Tool "*" 160 380 20 20 TEXT_1; LABEL_Create Tool (_loc this "TOOL_SIZE" nil) 10 400 150 20 TEXT_SIZE; TEXT_Create Tool "w" 10 420 150 20 TEXT_W; TEXT_Create Tool "h" 10 440 150 20 TEXT_H; TEXT_Create Tool "d" 10 460 150 20 TEXT_D; LABEL_Create Tool (_loc this "TOOL_ANGLES" nil) 10 300 150 20 TEXT_ANGLE; TEXT_Create Tool "a" 10 320 150 20 TEXT_A; LABEL_Create Tool "°" 160 320 20 20 TEXT_2; TEXT_Create Tool "b" 10 340 150 20 TEXT_B; LABEL_Create Tool "°" 160 340 20 20 TEXT_3; TEXT_Create Tool "c" 10 360 150 20 TEXT_C; LABEL_Create Tool "°" 160 360 20 20 TEXT_4; /*ROLLOVER_Create Tool (_loc this "MNU_SAVE" nil) 10 500 150 20 ROL_SAVE;*/ ROLLOVER_Create Tool (_loc this "MNU_APP" nil) 10 500 150 20 APP; _SETcheck (switch Tool.TBgroupcheck CHECK_VIEW) 1; 0 ;; fun addList(l, a) = if a==nil then l else a::l ;; /*********************************** Fonction d'initialisation des callbacks des boutons ************************************/ fun initFuncBtn(t, f) = /* créer une liste de fonction avec [type fct] */ let search_in_list Tool.TBfuncs @searchtypefunc t -> func in if func==nil then set Tool.TBfuncs=addList Tool.TBfuncs [t f] else ( mutate func<-[_ f]; nil ) ;; /*********************************** Fonction d'initialisation de la callbacks des textes de position ************************************/ fun initEnterTextPos(f) = set Tool.TBenterPos = f; 0 ;; /*********************************** Fonction d'initialisation de la callbacks des textes ************************************/ fun initEnterTextScale(f) = set Tool.TBenterScale = f; 0 ;; /*********************************** Fonction d'initialisation des valeurs des texts suivant leurs identifiants ************************************/ fun setTextVal(lid, lval) = if lid==nil then 0 else let lid -> [id nxtid] in let lval-> [val nxtval] in let (switch Tool.TBgrouptext id) -> txt in ( _SETtext txt val; setTextVal nxtid nxtval ) ;; fun BUTTON_Hide (type) = _SHOWbutton (switch Tool.TBgroupbutton type) WINDOW_HIDDEN; 0 ;; fun BUTTON_Show (type) = _SHOWbutton (switch Tool.TBgroupbutton type) WINDOW_UNHIDDEN; 0 ;; fun CHECK_Hide (type) = _SHOWcheck (switch Tool.TBgroupcheck type) WINDOW_HIDDEN; 0 ;; fun CHECK_Show (type) = _SHOWcheck (switch Tool.TBgroupcheck type) WINDOW_UNHIDDEN; 0 ;; fun CHECK_Check (type) = _SETcheck (switch Tool.TBgroupcheck type) 1; 0 ;; fun CHECK_Check2 (type) = /* MODIF 11-10 */ _SETcheck (switch Tool.TBgroupcheck type) 0; 0 ;; fun TEXT_Disable (type) = _ENtext (switch Tool.TBgrouptext type) 0; 0 ;; fun TEXT_Enable (type) = _ENtext (switch Tool.TBgrouptext type) 1; 0 ;;