unit D_selecsur; interface {Written by Denis bertin le lundi du monday 22.03.2010 pour circle avec delphi 7 (c) bEElOG} uses wbase,col_plan,c_color,Messages; type Tcolor_selon_button = class(c_color.Tcolor_degra_button) function get_color:longint; override; end; dial_selection_selon = class(wbase.tdialog) constructor Create(parent:wbase.twindow; acol_plan:col_plan.TCalque); procedure wmcommand(var Msg: TMessage); override; procedure wmset_painture_control(var Msg: TMessage); override; procedure Ok; override; private une_collection:col_plan.TCalque; radio_dessin:wbase.Tradiobutton; color1,color2: Tcolor_selon_button; check_dessin_ouvert,check_dessin_fermer:wbase.tcheckbox; end; {dial_selection_selon} implementation uses windows,u_object,haide,dialbase,wformes1,wformes2,wformebm; const id_bool_check_ajouter = 100; id_bool_check_encre = 101; id_bool_check_fond = 102; id_bool_check_epaisseur = 103; id_bool_check_dessin_ouvert = 105; id_bool_check_dessin_fermer = 106; id_bool_check_cotation = 114; id_bool_radio_tts_objet = 113; id_bool_radio_dessin = 108; id_bool_radio_texte = 109; id_bool_radio_groupe = 110; id_bool_radio_symetrie = 111; id_bool_radio_bitmap =112; id_epaisseur = 104; id_color_encre = 300; id_color_fond = 301; function Tcolor_selon_button.get_color:longint; begin if self.identifiant=id_color_encre then result:=u_object.ppr.Rec_Select_sur.couleur_encre else if self.identifiant=id_color_fond then result:=u_object.ppr.Rec_Select_sur.couleur_Fond; end; {Tcolor_selon_button.get_color} constructor Dial_selection_selon.Create(parent:wbase.twindow; acol_plan:col_plan.TCalque); begin inherited Create(parent,'DIALOG_SELEC_SUR',haide.HELPIdEdit_Select_sur); Self.TransferBuffer:=@u_object.ppr.Rec_Select_sur; self.une_collection:=acol_plan; {initialisation des contrôle} wbase.tcheckbox.create(self,id_bool_check_ajouter,6075); wbase.tcheckbox.create(self,id_bool_check_encre,6073); wbase.tcheckbox.create(self,id_bool_check_fond,6073); wbase.tcheckbox.create(self,id_bool_check_epaisseur,6073); check_dessin_ouvert:=wbase.tcheckbox.create(self,id_bool_check_dessin_ouvert,6073); check_dessin_fermer:=wbase.tcheckbox.create(self,id_bool_check_dessin_fermer,6073); wbase.tcheckbox.create(self,id_bool_check_cotation,6073); wbase.Tradiobutton.create(self,id_bool_radio_tts_objet,6074); radio_dessin:=wbase.Tradiobutton.create(self,id_bool_radio_dessin,6074); wbase.Tradiobutton.create(self,id_bool_radio_texte,6074); wbase.Tradiobutton.create(self,id_bool_radio_groupe,6074); wbase.Tradiobutton.create(self,id_bool_radio_symetrie,6074); wbase.Tradiobutton.create(self,id_bool_radio_bitmap,6074); dialbase.TNumEdit_plus_moins.Create(self,id_epaisseur,5,0,1000,6073); color1:=Tcolor_selon_button.Create(self,id_color_encre,6036); color2:=Tcolor_selon_button.Create(self,id_color_fond,6036); end; {Dial_selection_selon.Create} procedure Dial_selection_selon.wmset_painture_control(var Msg: TMessage); begin with msg do begin if wparam=color1.hwindow then u_object.ppr.Rec_Select_sur.couleur_encre:=lparam else if wparam=color2.hwindow then u_object.ppr.Rec_Select_sur.couleur_fond:=lparam; end; {with} end; procedure Dial_selection_selon.wmcommand(var Msg: TMessage); begin inherited wmcommand(Msg); if radio_dessin.GetCheck=bf_checked then begin enablewindow(check_dessin_ouvert.hwindow,true); enablewindow(check_dessin_fermer.hwindow,true); end else begin enablewindow(check_dessin_ouvert.hwindow,false); enablewindow(check_dessin_fermer.hwindow,false); end; if loword(msg.wparam)=id_bool_check_dessin_ouvert then if check_dessin_ouvert.GetCheck=bf_checked then check_dessin_fermer.Uncheck; if loword(msg.wparam)=id_bool_check_dessin_fermer then if check_dessin_fermer.GetCheck=bf_checked then check_dessin_ouvert.Uncheck; end; procedure Dial_selection_selon.Ok; var i:integer; ok:boolean; une_forme:u_object.tforme_color; {vérifie que cette index n'est pas déjà sélectionner pour ne pas créer un double dans la sélection} function Verifier_que_cette_index_selection_nexiste_pas(un_integer:integer):boolean; var j:integer; un_index:u_object.Tindex; begin Verifier_que_cette_index_selection_nexiste_pas:=true; for j:=0 to pred(self.une_collection.col_select.Count) do begin un_index:=self.une_collection.col_select.at(j); if un_index<>nil then begin if un_index.pos=un_integer then Verifier_que_cette_index_selection_nexiste_pas:=false; end; end; end; {verifier_que_cette_index_selection_nexiste_pas} begin inherited ok; {si l'on doit ajouter à la sélection ces éléments, ne pas suppr la sélection présente} if not u_object.ppr.Rec_Select_sur.bool_check_ajouter then self.une_collection.col_select.freeall; for i:=0 to pred(self.une_collection.count) do begin {for i} une_forme:=self.une_collection.at(i); if une_forme<>nil then begin ok:=true; if u_object.ppr.Rec_Select_sur.bool_radio_dessin then begin if une_forme.ClassType<>wformes1.tforme_dessin then ok:=false; end; if u_object.ppr.Rec_Select_sur.bool_radio_texte then begin if une_forme.ClassType<>wformes1.tforme_text then ok:=false; end; if u_object.ppr.Rec_Select_sur.bool_radio_groupe then begin if une_forme.ClassType<>wformes2.tforme_groupe then ok:=false; end; if u_object.ppr.Rec_Select_sur.bool_radio_symetrie then begin if not ((une_forme.ClassType=wformes2.tforme_symetrie_verticale) or (une_forme.ClassType=wformes2.tforme_symetrie_horizontale)) then ok:=false; end; if u_object.ppr.Rec_Select_sur.bool_radio_bitmap then begin if une_forme.ClassType<>wformebm.Tforme_TBitMap then ok:=false; end; if ok then begin if u_object.ppr.Rec_Select_sur.bool_check_encre then begin if une_forme.couleur_pinceau<>u_object.ppr.Rec_Select_sur.couleur_encre then ok:=false; end; if u_object.ppr.Rec_Select_sur.bool_check_fond then begin if une_forme.brush1.lbColor<>u_object.ppr.Rec_Select_sur.couleur_fond then ok:=false; end; if u_object.ppr.Rec_Select_sur.bool_check_epaisseur then begin if une_forme.epaisseur<>u_object.ppr.Rec_Select_sur.epaisseur then ok:=false; end; if u_object.ppr.Rec_Select_sur.bool_check_dessin_ouvert then begin if une_forme.ClassType=wformes1.tforme_dessin then begin if wformes1.tforme_dessin(une_forme).is_fermer then ok:=false; end end; if u_object.ppr.Rec_Select_sur.bool_check_dessin_fermer then begin if une_forme.ClassType=wformes1.tforme_dessin then begin if not wformes1.tforme_dessin(une_forme).is_fermer then ok:=false; end end; if u_object.ppr.Rec_Select_sur.bool_check_cotation then if une_forme.ClassType=wformes1.tforme_dessin then begin if (wformes1.tforme_dessin(une_forme).cotation.debut=0) and (wformes1.tforme_dessin(une_forme).cotation.fin=0) then ok:=false; end else ok:=false; end; if ok then if u_object.ppr.Rec_Select_sur.bool_check_ajouter then ok:=verifier_que_cette_index_selection_nexiste_pas(i); if ok then self.une_collection.col_select.Add(u_object.tindex.Create(i)); end; end; {for i} end; {Dial_selection_selon.Ok} end.