diff --git a/.gitattributes b/.gitattributes index e10d58f1e3..9921f5e113 100644 --- a/.gitattributes +++ b/.gitattributes @@ -855,6 +855,7 @@ components/customdrawn/customdrawnimages/android.lrs svneol=native#text/plain components/customdrawn/customdrawnimages/android_checkbox.bmp -text components/customdrawn/customdrawnimages/android_checkbox_checked.bmp -text components/customdrawn/customdrawnlcldrawers.pas svneol=native#text/plain +components/customdrawn/paletteimg.lrs svneol=native#text/plain components/customform/custforms.pp svneol=native#text/plain components/customform/demo/appform.pas svneol=native#text/plain components/customform/demo/appforms.lpk svneol=native#text/plain diff --git a/components/customdrawn/customdrawnextras.pas b/components/customdrawn/customdrawnextras.pas index df82f902ef..7a94779206 100644 --- a/components/customdrawn/customdrawnextras.pas +++ b/components/customdrawn/customdrawnextras.pas @@ -16,7 +16,7 @@ interface uses Classes, SysUtils, Graphics, Controls, LCLType, LCLIntf, IntfGraphics, Math, types, contnrs, componenteditors, LMessages, Messages, - LCLProc, PropEdits, ExtCtrls, ImgList, Forms, Menus, + LCLProc, PropEdits, ExtCtrls, ImgList, Forms, Menus, LResources, customdrawncontrols, // fpimage fpcanvas, fpimgcanv, fpimage @@ -182,6 +182,7 @@ resourcestring procedure Register; begin + {$i paletteimg.lrs} RegisterComponents('Custom Drawn', [ // Standard tab TCDButton, TCDEdit, TCDCheckBox, TCDRadioButton, TCDComboBox, TCDScrollBar, TCDGroupBox, diff --git a/components/customdrawn/paletteimg.lrs b/components/customdrawn/paletteimg.lrs new file mode 100644 index 0000000000..24746aceea --- /dev/null +++ b/components/customdrawn/paletteimg.lrs @@ -0,0 +1,212 @@ +LazarusResources.Add('tcdbutton','PNG',[ +#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 ++#0#2#139'IDATx^'#237'UMKUQ'#20']'#251#156#243#204#7#129#137'QA!'#4'Q'#163#168 ++'h'#212#160#31#208'/'#136#192#240'Q'#208#208'FE'#10'j'#13#210'A$(AR'#8'ZH' ++#244#23'$h\'#163#160#6'FI5'#9'"'#164#30#154#239#189's'#207'G{'#159'{'#159#151 ++#135#209' q'#16#184'`s'#246#217#251#222#181#246#199#133'K!'#4#16#17'v'#10#20 ++'c'#196'NB'#177#253#223#2#244'y'#229'}|'#246#226#13#222'}'#252#6'e4"'#254'>' ++#178#224'='#144#158'!t"'#130'H%'#211'F'#225#202#133#179'8v'#228#16#204#212 ++#243'W'#168#238#239#199#169's'#199#209#180#0#169'm,e'#170#129#135#251'['#204#201 + +'fs^30'#254'_\a.'#158#159#30#231#169#1'I'#132#172'B'#140#241'S'#203'''4p|v' + +#131#194#221#229'?Tj'#155'''.0'#233#212#175#139#20#132'a$g'#183#182'c'''#19 + +#129'6'#221#131#178#184#200#204#140'/'#226#210#158'A'#11#203#195#3''''#3#167 + +#152#30#195#203#174#239#168'`'#130'c'#224#156#177#219#174'SC'#13#204#196#143 + +'1'#18' '#160#175#138#16#9#21#187#27'f'#240#13'tRT'#196#190#205#0'6'#156#202 + +#252#232'3'#174'W'#171#19'FD'#139#178'h'#4'4d'#197',@'#179#24#178#226#128'a' + +#220'aoy'#4#224#253#223'8('#22#251#196'GD'#228#135'<'#153#127#6'o'#158#205'h' + +'8"'#248'.'#169#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('tcdradiobutton','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 + +#0#1'~IDATx^'#237'U=k'#194'P'#20'='#175'?'#160'K'#167'.'#29#132'*Rh'#193#207 + +':'#8'J'#29'T'#226#210#205#159#224#208'Ip'#234'"-'#248#3':'#132#14#14#10#173 + +'[;H2'#4#186'd*A:'#8'UL!'#216'R'#232#212#165'cAS'#238#133#4#164'dxb6'#15#132 + +#203'I'#14#231'<'#30#231#18#177'X, '#132'@X'#16#203#229#18'ab'#7#155#194'6`0' + +#24#184#205'f'#211'U'#20#133''''#241#141#4#12#135'C'#183'Z'#173#186#182'm' + +#163'T*'#161#219#189'E'#185'\'#134#227'8'#160#247#244'}'#221#22#177#185'i' + +#154'('#22#139'H&O'#254#9#166#211'7'#24#134#129'\.'#135'Z'#173'&'#164'['#164 + +#170'j'#144'9#'#30'?D'#165'R!'#157't'#139#248#206#179#217#236#138#249#235#207 + +#30#174#30#127'yz'#136'F#('#20#10#172#151#10#24#141'F'#200'd2+'#230#15'O_L.o' + +#158'WB'#242#249'<'#235#165#2'f'#179#25#18#137'c'#159#179#185#15#14#241'I$r@' + +'z'#185#128'X,'#134#241'x'#226#243#243#179'}'#188'L'#222#249'!\_'#156#194#195 + +'|'#254'Iz'#185#128'T*'#5#203#178'|~'#180#251#237#153#210'd'#238#129#154'Fz' + +#217#154'r'#207'['#173#22#183'%'#0'|'#250'v'#187#13']'#215#229'k'#218'h4'#184 + +#231#182#237#4#154'k'#154'F'#186#181'6'#153#151#135#150#168#211#233#160#215 + +#187#131#227'|'#248#198#253#254'='#159'<'#157'N'#179'Nb'#147#131#247#130#170 + +'Hm'#161#2#208#157#215#235'u'#177#253#225#132#31#176#13#248#3'L'#164#177'A' + +#222#235#132'C'#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('tcdcombobox','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 + +#0#0#243'IDATx^'#221#149'='#170#194'@'#16#128'gM'#250'4)<'#131#133#162#188'R' + +#20'RD<'#131'g'#176#19#19'o'#16#197#206'3x'#5#133' !'#254#148#242#130#22'9' + +#131#151'p'#247#145'<'#194' '#146'd]'#29#17#191'b'#187#217'ovf'#150'a'#156's' + +'`'#140#1#21'L'#8#1#148#232#201#225#186#139#151'Y'#155'> '#192' '#154#23#180'~'#154#160#138#191#137#201 + +#155#252'e'#255'@'#207'Y$'#20'%'#194#149#151','#140'O^'#250#239#157#162'?EtU' + +';'#244#164#221#245#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('tcdscrollbar','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 + +#0#0#218'IDATx^'#237#148'['#10#194'0'#16'E'''#226'&'#186#7#197#5#248#0#149 + +#166#221#140#223#237#18#250#173#139#177#15#234#163#186#1#209'mHw'#144'q'#18 + +#152'*'#134#226#143#253')'#185#16#14#183't'#238'-I'#137'PJ'#129#16#2#186#146 + +'@D'#232'R'#3'B'#207#11'\'#193#240#211#196#241#14#225#15'J'#146#141'h'#12'"' + +#154#21'E['#172'Ng'#172#235'g'#179#244'3'#173'}Z'#182#178'm'#142's'#173'-' + +#186#223#30#224'y'#158#161'V'#154#29' '#12'V'#134#254#23#3'"'#139'g~'#158#129 + +#12'}'#200#211#2#198#147#145#182#28'nX'#16#231#179#165#166#9#207#136','#154 + +#209#179'\b'#21#180#190#200#225#204#203#245#8'RR'#184#241'S`'#249'r'#253#254 + +'0'#251#144#237#18#22#135'7'#148#196'\'#251#5#249#10'XE^'#242#22'[wQ'''#127 + +'Q'#159'.;W'#224#10'\'#193#11'-'#185#180#181#16#168':'#194#0#0#0#0'IEND'#174 + +'B`'#130 +]); +LazarusResources.Add('tcdgroupbox','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 + +#0#0#147'IDATx^'#237#149'A'#10#131'0'#16'E'#255#4#239'!x'#27#233'IJqY'#152'#' + +#184#15#226'yl'#175'!'#146'R'#232'1'#18'i'#23#14#136'#t1'#144'E'#30#204'*C' + +#222'$'#129'|'#138'1'#130#136'`'#5#165#148'`I'#133#3'n'#227'rj'#29#174#13#253 + +'-`'#246#178'i}'#129#134#244#234#244'}'#183#13#224'v'#11#191'R'#145'>'#181 + +#190'<'#167'GR'#175'('#132#25#247#22#10#210's'#196#251#245#193#30#7#3'r'#19 + +#20'A'#17#20'A'#17'T'#202#143'h#`'#246#22''''#144#20#146#160#200' '#244#179 + +'y'#228#21'V%6WL'#253#171#160#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('tcdstatictext','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 + +#0#0#169'IDATx^'#237#149'A'#10#194'0'#20'D'#253#210'K'#185't'#227'A'#220'{' + +#135#220#161']{'#16'7.='#214'H'#16'y'#11#135'D$'#31'E:'#16'~'#249#229#243'&' + +#19#210#134#164'M'#166#182'4'#254#21#176#2#166'Z'#202#249#162#209#128'r<'#196 + +#19'@c'#132'0'#252'~D'#187#211'Uu'#253#230#25#188#186#197#233'm'#222#135'{G' + +#159#158#153#241#17#213#225#186#252'0}*36'#162'O'#243#142#192#168'w'#15#192 + +'G'#144#127#209'p'#218#23#6#155#0#151#189'$'#187'Cj;'#214#201#231#136#251'X' + +#30#143#14#8#4'u'#0#8#247#192'$%_4`'#212#142'BR'#234#199#238#251#255#228#21 + +'p'#7'V'#181'`/'#219#165'Qi'#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('tcdtrackbar','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 + +#0#0#222'IDATx^'#237#149#177#10#194'0'#16#134#255'H'#223#195'R'#156'\'#10'n' + +#14#234'\|'#145#138't'#239'#t/b_'#193#173#131#210#209#209'M'#16#196'I'#165'E' + +#240'5b)'#220#160'G '#164#173'('#244'[J'#142'$'#127'r'#215#251'#'#164#148'h' + +#147#30#128#255#22#176#160'`'#185#190#179#220#173#22#142'hL'#224'x)'#192'q' + +#154#185'A'#24#198#242#16#7#200#243'+'#136'4'#221#150#241#179#140#162'@'#252 + +'V'#13#232#196#208'@w'#238#220's1'#153'M'#197'['#138'|'#223#3#145'$'#25#24'l' + +#158#154'G'#241#4'a'#177#160#254'b'#253#20'}'#22'n'#151#157'$'#20#208#213#141 + +#139'L'#130#227'`'#15#219#30#208#31#132#205#205#173#226#141'u'#242'h'#216#7 + +#137#148#155'W'#227#154'V'#193#187#150'D'#202'o5'#134#1#220'M'#193'-'#131'67' + +#161'}'#187'V5'#143'i'#252#235'V'#209#189'h'#157'@}^s'#235'W'#197'hN+'#192#0 + +#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('tcdprogressbar','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 + +#0#0#174'IDATx^'#237#149#191#14#130'0'#16#198#239#12#155#207#225#194#130#179 + +#179'10'#241#6'>'#129#238'$'#134#137#144#176#243'$'#14#198'''p3'#26'w}'#11 + +#231#150'?'#201#209'.'#208#146#180#3#208'o'#250#190#229'~'#201#245#238#138 + +#140'1@D'#176'%'#228#156#131'M'#173#200#204#23#224#0#30#153'$)'#141#142'SQ' + +#156#177#5'P'#241#195#222#7'S'#162#154#13#196#147#169#151#171#232#216'='#11 + +' J?'#131#185'O'#175#231'[n'#145'Pz'#220'J'#137'+'#179#254#27#16#249#247#239 + +#252'n'#179'V'#229#241#128#219#227#219#249'S'#24#168#242#146#246#128#148#199 + +'L'#158#132':'#195'P'#214'>'#215#214#22'm"'#255#129#3'8@'#5#154#11'I'#254'U' + +#188#163'/'#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('tcdlistview','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 + +#0#0#145'IDATx^'#237#214'1'#10#196' '#20#4#208#249#146#243#164'O%)'#131'g' + +#177#247#8#233'='#139'u'#176#202#173't'#217'"'#16#144'e'#22#241'C'#138'<'#176 + +#25#196'_L'#241#149'R'#10'D'#4'Z'#164#214#138#16'b'#197'`'#219'6'#195'Z+'#6 + +'D'#239#227#151#9'7'#251#238'1B'#206#25#23#3#29'|'#192#226#143#239#233#200 + +#154#1#186'&'#252'p'#198#181'7'#227#3#156's'#184'K)'#253#157#241#1#237'E'#158 + +#189'%'#243#236'-'#153'{r'#201#220#152#146';'#241#146#159#223'A'#179#137#6'3' + +#205#30#213#248'Uh'#250#0#150'*WZ.'#194'('#148#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('tcdpagecontrol','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 + +#0#0#1'sRGB'#0#174#206#28#233#0#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147 + +#0#0#0#9'pHYs'#0#0#11#18#0#0#11#18#1#210#221'~'#252#0#0#0#7'tIME'#7#216#2#27 + +#8#14#17'5A'#235#216#0#0#0#235'IDATH'#199'c'#252#255#255'?'#3'-'#1#19#3#141#1 + +#11#3#3#3#195#234#163#15#254'O^}'#28#167#162#220'PK'#134'Pk'#5'Fr,`'#252#255 + +#255'?'#131']'#193#242#255#135'&D'#226'TdW'#176#28#167#197#216#28#134#236' ' + +#22'd'#137'O'#159#255#224#180#4#155#3#236#10#150#227#20#15#181'V`'#192#176 + +#224#203#215#239'x'#189#251#236#197'g'#162#196'0'#226#0#6#190'~'#249#134'W16' + +'yBz'#24#255#255#255#207'PQ1'#249#191#153#153')NE'#19#14#221''')b'#173'8'#222 + +'0x{'#234'3'#216#218#219'1'#194'}'#16#20'd'#129'S'#3'>9l'#160#162'b2'#246' z' + +#240#224#14#197#233#254#241#195'g'#244#205'h'#163#22#140'Z0j'#1'ZNF'#207#133 + +#212#0#140#176':'#185#162'b2'#213'*goO}'#6#6#6#6#6'[{;F'#184#5#135#15#30#162 + +'j'#237'oko'#199#136#226#131'!'#27#201#0#223#150'X'#226#23#233'FP'#0#0#0#0'I' + +'END'#174'B`'#130 +]); +LazarusResources.Add('tcdtabcontrol','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 + +#0#0#1'sRGB'#0#174#206#28#233#0#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147 + +#0#0#0#9'pHYs'#0#0#11#18#0#0#11#18#1#210#221'~'#252#0#0#0#7'tIME'#7#216#2#27 + +#8#14'.'#131''''#198#229#0#0#0#232'IDATH'#199'c'#252#255#255'?'#3'-'#1#19#3 + +#141#1#11#3#3#3#195#234#163#15#254'O^}'#28#167#162#220'PK'#134'Pk'#5'Fr,`' + +#252#255#255'?'#131']'#193#242#255#135'&D'#226'TdW'#176#28#167#197#216#28#134 + +#236' '#22#152#224#167#207#127#240#186#4#155#3#236#10#150#227#20#15#181'V`@' + +#177#224#229#203#183'x-'#184'}'#231'%I'#226'(q'#192#192#192#192#240#237#235 + +'w'#188#10'q'#201#19#210#199#194#192#192#192'`'#197#241#134#225#238#221#23'x' + +#21#230#206'?N'#180#184#21#199#27#134#195#7#15#253#183#181#183'c'#132#251' (' + +#200#2#167#225#248#228#176#129#138#138#201#152'A'#196#192#192#192#240#224#193 + +#29#138#211#253#227#135#207#232#155#209#232#147#147#25#24#24#24#14#31''#229#232#224#4#252#186'$'#160#2'i'#166#220#247#170'&k FKind then begin + FKind:= AKind; + if FKind = bkCustom then exit; // if changed to custom, don't touch other settings + ModalResult:= BitBtnModalResults[AKind]; + ACaption:= GetButtonCaption(BitBtnImages[AKind]); + Shortcutpos:= DeleteAmpersands(ACaption); + Caption:= ACaption; + if Shortcutpos > 0 then begin + ShortcutVal:= ACaption[Shortcutpos]; + end; + BitBtnImage:= BitBtnImages[AKind]; + if BitBtnImage <> idButtonBase then begin + C := CreateBitmapFromLazarusResource(BitBtnResNames[BitBtnImage]); + try + Glyph.Assign(C); + finally + C.Free; + end; + end; + end; +end; + +procedure TCDButton.Click; +var + Form : TCustomForm; +begin + Form := GetParentForm(Self); + + { First we mimic the TBitBtn behavior + A TBitBtn with Kind = bkClose should + - Close the ParentForm if ModalResult = mrNone. + It should not set ParentForm.ModalResult in this case + - Close a non-modal ParentForm if ModalResult in [mrNone, mrClose] + - In all other cases it should behave like any other TBitBtn + } + if (FKind = bkClose) then + begin + if (Form <> nil) then + begin + if (FModalResult = mrNone) or + ((FModalResult = mrClose) and not (fsModal in Form.FormState)) then + begin + Form.Close; + Exit; + end; + end; + end; + if ModalResult <> mrNone + then begin + if Form <> nil then Form.ModalResult := ModalResult; + end; + inherited Click; +end; + function TCDButton.GetControlId: TCDControlID; begin Result := cidButton; diff --git a/lcl/interfaces/customdrawn/customdrawnobject_x11.inc b/lcl/interfaces/customdrawn/customdrawnobject_x11.inc index a515aa070a..8c8a576c07 100644 --- a/lcl/interfaces/customdrawn/customdrawnobject_x11.inc +++ b/lcl/interfaces/customdrawn/customdrawnobject_x11.inc @@ -455,7 +455,9 @@ begin end; X.MotionNotify: begin - TCDWSCustomForm.EvMouseMove(WindowEntry, CurWindowInfo, XEvent.xmotion); + repeat + until not XCheckTypedWindowEvent(FDisplay, XEvent.xmotion.window, X.MotionNotify, @XEvent); + TCDWSCustomForm.EvMouseMove(WindowEntry, CurWindowInfo, XEvent.xmotion); end; X.FocusIn: begin @@ -499,7 +501,9 @@ begin end; X.ConfigureNotify: begin - TCDWSCustomForm.EvConfigureNotify(WindowEntry, CurWindowInfo, XEvent.xconfigure); + repeat + until not XCheckTypedWindowEvent(FDisplay, XEvent.xconfigure.window, X.NotifyPointer, @XEvent); + TCDWSCustomForm.EvConfigureNotify(WindowEntry, CurWindowInfo, XEvent.xconfigure); end; X.ClientMessage: begin diff --git a/lcl/interfaces/customdrawn/customdrawnwsforms.pp b/lcl/interfaces/customdrawn/customdrawnwsforms.pp index 3307da928b..de145e23ed 100644 --- a/lcl/interfaces/customdrawn/customdrawnwsforms.pp +++ b/lcl/interfaces/customdrawn/customdrawnwsforms.pp @@ -34,7 +34,8 @@ uses SysUtils, Classes, types, ctypes, {$ifdef CD_Windows}Windows, customdrawn_WinProc,{$endif} {$ifdef CD_Cocoa}MacOSAll, CocoaAll, customdrawn_cocoaproc, CocoaUtils, CocoaGDIObjects,{$endif} - {$ifdef CD_X11}XShm, X, XLib, XUtil, XAtom, customdrawn_x11proc,{unitxft, Xft font support}{$endif} + {$ifdef CD_X11}XShm, X, XLib, XUtil, XAtom, customdrawn_x11proc, + {$ifdef CD_X11_UseATK}atk, {$endif} {unitxft, Xft font support}{$endif} {$ifdef CD_Android}customdrawn_androidproc,{$endif} // LazUtils lazutf8sysutils, diff --git a/lcl/lazdialogs.pas b/lcl/lazdialogs.pas index 3a308b6972..adfa8d14a7 100644 --- a/lcl/lazdialogs.pas +++ b/lcl/lazdialogs.pas @@ -1,15 +1,15 @@ unit lazdialogs; -{$mode delphi} +{$mode objfpc}{$H+} interface uses // RTL - Classes, SysUtils, + Classes, SysUtils, math, // LCL Forms, ShellCtrls, Buttons, StdCtrls, ExtCtrls, FileCtrl, ComCtrls, - Dialogs, ButtonPanel, lclstrconsts, FileUtil, Controls; + Dialogs, ButtonPanel, LCLStrConsts, FileUtil, Controls; type TLazFileDialogKind = ( @@ -71,8 +71,29 @@ type procedure DoInitialize; override; end; + { TLazMessageDialog } + TLazMessageDialog = class(TForm) + private + Image1: TImage; + Label1: TStaticText; + btnList: array [0..11] of TBitBtn; + NumButtons: Integer; + public + constructor CreateNew(TheOwner: TComponent; Num: Integer = 0); override; + end; + + function LazMessageDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType; + Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer; + function LazMessageDlg(const aMsg: string; DlgType: TMsgDlgType; + Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer; + + implementation +var + { Declared here for the time being to make it possibly work with LCLCustodrawn} + LazMessageDialog: TLazMessageDialog; + { TLazarusFileDialogForm } procedure TLazarusFileDialogForm.SetFilter(AFilter: string); @@ -107,8 +128,8 @@ begin ButtonPanel.Width := Width; ButtonPanel.Align := alBottom; ButtonPanel.ShowButtons := [pbOK, pbCancel]; - ButtonPanel.OKButton.OnClick := HandleOkClick; - ButtonPanel.CancelButton.OnClick := HandleCancelClick; + ButtonPanel.OKButton.OnClick := @HandleOkClick; + ButtonPanel.CancelButton.OnClick := @HandleCancelClick; if AKind in [ldkOpenDesktop, ldkSaveDesktop, ldkOpenPDA, ldkSavePDA] then begin @@ -131,7 +152,7 @@ begin ShellListView.Align := alClient; ShellListView.ShellTreeView := ShellTreeView; ShellListView.ScrollBars := ssVertical; - ShellListView.OnSelectItem := HandleSelectItem; + ShellListView.OnSelectItem := @HandleSelectItem; // TEdit for save dialog if AKind in [ldkSaveDesktop, ldkSavePDA] then @@ -144,7 +165,7 @@ begin SaveEdit.Width := Width; SaveEdit.Align := alBottom; SaveEdit.Text := SysUtils.ExtractFileName(FileName); - SaveEdit.OnChange := HandleEditChange; + SaveEdit.OnChange := @HandleEditChange; end; // TFilterComboBox @@ -175,13 +196,13 @@ begin ShellTreeView.Left := 0; ShellTreeView.Top := 0; ShellTreeView.Align := alClient; - ShellTreeView.OnSelectionChanged := HandleTreeViewSelectionChanged; + ShellTreeView.OnSelectionChanged := @HandleTreeViewSelectionChanged; ButtonPanel.OKButton.Enabled := False; end; // Form events - OnCloseQuery := HandleCloseQuery; + OnCloseQuery := @HandleCloseQuery; end; // The Ok button code should be only a simple mrOk, @@ -305,6 +326,186 @@ procedure TLazSelectDirectoryDialog.DoInitialize; begin FForm.Initialize(ldkSelectDirectory); end; +{ Dialog Functions } + +function LazMessageDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType; + Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer; +Var + I: Integer; + textWidth: Integer; + ButtonPos: Integer; + RequiredWidth: Integer; + +begin + {$ifdef LCLCustomdrawn} if not assigned(LazMessageDialog) then {$endif} + LazMessageDialog:= TLazMessageDialog.CreateNew(Application); + with LazMessageDialog do begin + Label1.Caption:= aMsg; + Label1.Parent:= LazMessageDialog; + {Select Image (and Caption) from DlgType} + case DlgType of + mtWarning: begin + Caption:= rsMtWarning; + image1.Picture.LoadFromLazarusResource('dialog_warning'); + end; + mtError: begin + Caption:= rsMtError; + image1.Picture.LoadFromLazarusResource('dialog_error'); + end; + mtConfirmation: begin + Caption:= rsMtConfirmation; + image1.Picture.LoadFromLazarusResource('dialog_confirmation'); + end; + mtInformation: begin + Caption:= rsMtInformation; + image1.Picture.LoadFromLazarusResource('dialog_information'); + end; + mtCustom: begin + Caption:= ApplicationName; + Image1.Width:= 8; + Image1.Hide; + end; + end; + Image1.Parent := LazMessageDialog; + + if aCaption <> '' then //A custom dialog caption has been required + Caption:= aCaption; + Label1.Left:= Image1.Left + Image1.Width + 8; + + {Select Buttons from Buttons} + if (Buttons = []) or (Buttons = [mbHelp]) then + Buttons:= Buttons + [mbOK]; // the dialog must provide a modal result + NumButtons:= 0; + { The order of Buttons is the same as in Qt - Totally different from GTK2} + if mbHelp in Buttons then begin + btnList[NumButtons] := TBitBtn.Create(LazMessageDialog); + btnList[NumButtons].Parent := LazMessageDialog; + btnList[NumButtons].Kind:= bkHelp; + inc(NumButtons); + end; + if mbYes in Buttons then begin + btnList[NumButtons] := TBitBtn.Create(LazMessageDialog); + btnList[NumButtons].Parent := LazMessageDialog; + btnList[NumButtons].Kind:= bkYes; + inc(NumButtons); + end; + if mbYesToAll in Buttons then begin + btnList[NumButtons] := TBitBtn.Create(LazMessageDialog); + btnList[NumButtons].Parent := LazMessageDialog; + btnList[NumButtons].Kind:= bkYesToAll; + inc(NumButtons); + end; + if mbNo in Buttons then begin + btnList[NumButtons] := TBitBtn.Create(LazMessageDialog); + btnList[NumButtons].Parent := LazMessageDialog; + btnList[NumButtons].Kind:= bkNo; + inc(NumButtons); + end; + if mbNoToAll in Buttons then begin + btnList[NumButtons] := TBitBtn.Create(LazMessageDialog); + btnList[NumButtons].Parent := LazMessageDialog; + btnList[NumButtons].Kind:= bkNoToAll; + inc(NumButtons); + end; + if mbAll in Buttons then begin + btnList[NumButtons] := TBitBtn.Create(LazMessageDialog); + btnList[NumButtons].Parent := LazMessageDialog; + btnList[NumButtons].Kind:= bkAll; + inc(NumButtons); + end; + if mbOK in Buttons then begin + btnList[NumButtons] := TBitBtn.Create(LazMessageDialog); + btnList[NumButtons].Parent := LazMessageDialog; + btnList[NumButtons].Kind:= bkOK; + inc(NumButtons); + end; + if mbRetry in Buttons then begin + btnList[NumButtons] := TBitBtn.Create(LazMessageDialog); + btnList[NumButtons].Parent := LazMessageDialog; + btnList[NumButtons].Kind:= bkRetry; + inc(NumButtons); + end; + if mbIgnore in Buttons then begin + btnList[NumButtons] := TBitBtn.Create(LazMessageDialog); + btnList[NumButtons].Parent := LazMessageDialog; + btnList[NumButtons].Kind:= bkIgnore; + inc(NumButtons); + end; + if mbCancel in Buttons then begin + btnList[NumButtons] := TBitBtn.Create(LazMessageDialog); + btnList[NumButtons].Parent := LazMessageDialog; + btnList[NumButtons].Kind:= bkCancel; + inc(NumButtons); + end; + if mbAbort in Buttons then begin + btnList[NumButtons] := TBitBtn.Create(LazMessageDialog); + btnList[NumButtons].Parent := LazMessageDialog; + btnList[NumButtons].Kind:= bkAbort; + inc(NumButtons); + end; + if mbClose in Buttons then begin + btnList[NumButtons] := TBitBtn.Create(LazMessageDialog); + btnList[NumButtons].Parent := LazMessageDialog; + btnList[NumButtons].Kind:= bkClose; + inc(NumButtons); + end; + + ButtonPos:= Image1.Left; + for I:= 0 to NumButtons -1 do begin + btnList[I].Constraints.MinHeight:= 25; + btnList[I].Constraints.MinWidth:= 75; + //btnList[I].DefaultCaption:= True; + //btnList[I].AutoSize:= True; + btnList[I].Left:= ButtonPos; + btnList[I].Top:= Image1.Top + Image1.Height + 10; + // next line is required until Autosize is implemented + {btnList[I].Width:= label1.Canvas.TextExtent(btnList[I].Caption).cx + + btnList[I].Glyph.Width + 16;} + btnList[I].AutoSize := True; + btnList[I].Visible:= True; + //Application.ProcessMessages; currently not required. It may become + //necessary if Autosize is set, and width computed automagically. Maybe + //outside the loop (run just once) + ButtonPos:= ButtonPos + btnList[I].Width + 8; + end; + //textWidth:= label1.Canvas.TextExtent(Label1.Caption).cx; + //Label1.Width:= textWidth; + label1.AutoSize := True; + textWidth:= label1.Left + label1.Width; + RequiredWidth:= Max(textWidth,ButtonPos); + Width := RequiredWidth + 10; + Height:= btnList[0].Top + btnList[0].Height + 10; + end; + result := LazMessageDialog.ShowModal; + {$ifndef LCLCustomdrawn}LazMessageDialog.Release;{$endif} +end; + +function LazMessageDlg(const aMsg: string; DlgType: TMsgDlgType; + Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer; +begin + result := LazMessageDlg('',aMsg,DlgType,Buttons,HelpCtx); +end; + +{ TLazMessageDialog } + +constructor TLazMessageDialog.CreateNew(TheOwner: TComponent; Num: Integer = 0); +begin + inherited CreateNew(TheOwner); + FormStyle:= fsStayOnTop; + Position:= poMainFormCenter; + Image1 := TImage.Create(Self); + Image1.Top:= 10; + Image1.Left:= 10; + Image1.Width:= 48; + Image1.Height:= 48; + Label1 := TStaticText.Create(Self); + Label1.Top:= Image1.Top; + Label1.Left:= Image1.Left + Image1.Width + 10; + Label1.Caption:= 'Label1'; + Width:= Image1.Width + Label1.Width + 20; + Height:= Image1.Height + 20; +end; + end.