diff --git a/.gitattributes b/.gitattributes index d07e39eb37..08e0ba1f53 100644 --- a/.gitattributes +++ b/.gitattributes @@ -266,6 +266,7 @@ examples/comdialogs.pp svneol=native#text/pascal examples/dlgform.pp svneol=native#text/pascal examples/edittest.pp svneol=native#text/pascal examples/groupbox.pp svneol=native#text/pascal +examples/groupboxnested.pas svneol=native#text/pascal examples/gtkglarea/data/particle.bmp -text svneol=unset#image/bmp examples/gtkglarea/data/texture1.bmp -text svneol=unset#image/bmp examples/gtkglarea/data/texture2.bmp -text svneol=unset#image/bmp diff --git a/examples/Makefile b/examples/Makefile index aa767685b4..84800e4970 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -212,8 +212,8 @@ LCL_PLATFORM=gtk endif export LCL_PLATFORM endif -override TARGET_UNITS+=hello notebk comdialogs progressbar trackbar listboxtest bitbutton combobox checkbox scrollbar edittest memotest groupbox speedtest toolbar messagedialogs notebooktest listviewtest synedit1 testall -override CLEAN_FILES+=$(wildcard *$(OEXT)) $(wildcard *$(PPUEXT)) trackbar toolbar testall speedtest scrollbar progressbar notebooktest notebk messagedialogs memotest listviewtest listboxtest hello groupbox edittest comdialogs combobox checkbox bitbutton synedit1 +override TARGET_UNITS+=hello notebk comdialogs progressbar trackbar listboxtest bitbutton combobox checkbox scrollbar edittest memotest groupbox speedtest toolbar messagedialogs notebooktest listviewtest synedit1 groupboxnested testall +override CLEAN_FILES+=$(wildcard *$(OEXT)) $(wildcard *$(PPUEXT)) trackbar toolbar testall speedtest scrollbar progressbar notebooktest notebk messagedialogs memotest listviewtest listboxtest hello groupbox edittest comdialogs combobox checkbox bitbutton synedit1 groupboxnested override COMPILER_OPTIONS+=-gl override COMPILER_UNITDIR+=../lcl/units ../lcl/units/$(LCL_PLATFORM) ../components/units .. . ifdef REQUIRE_UNITSDIR diff --git a/examples/Makefile.fpc b/examples/Makefile.fpc index 6588e72b1b..5419699bed 100644 --- a/examples/Makefile.fpc +++ b/examples/Makefile.fpc @@ -10,7 +10,7 @@ version=0.9b units=hello notebk comdialogs progressbar trackbar listboxtest \ bitbutton combobox checkbox scrollbar edittest memotest \ groupbox speedtest toolbar messagedialogs notebooktest \ - listviewtest synedit1 testall + listviewtest synedit1 groupboxnested testall [require] packages=fcl regexpr @@ -19,7 +19,7 @@ packages=fcl regexpr files=$(wildcard *$(OEXT)) $(wildcard *$(PPUEXT)) \ trackbar toolbar testall speedtest scrollbar progressbar notebooktest \ notebk messagedialogs memotest listviewtest listboxtest hello groupbox \ - edittest comdialogs combobox checkbox bitbutton synedit1 + edittest comdialogs combobox checkbox bitbutton synedit1 groupboxnested [default] diff --git a/examples/groupbox.pp b/examples/groupbox.pp index c7a23cf0ab..a22558b18b 100644 --- a/examples/groupbox.pp +++ b/examples/groupbox.pp @@ -32,164 +32,161 @@ program GroupBox; {$mode objfpc}{$H+} uses - Interfaces, Classes, StdCtrls, Forms, Buttons, Menus, ComCtrls, - SysUtils; + Interfaces, Classes, StdCtrls, Forms, Buttons, Menus, ComCtrls, SysUtils; type - TForm1 = class(TFORM) - public + TForm1 = class(TFORM) + public + Button1: TButton; + Button2: TButton; + Button3: TButton; + Button4: TButton; + grpTst : TGroupBox; + mnuFile: TMainMenu; + itmFileQuit: TMenuItem; + CheckBox1: TCheckBox; + constructor Create(AOwner: TComponent); override; + procedure LoadMainMenu; + procedure mnuQuitClicked(Sender : TObject); + protected + procedure Button1CLick(Sender : TObject); + procedure Button2CLick(Sender : TObject); + procedure Button3CLick(Sender : TObject); + procedure Button4CLick(Sender : TObject); + end; - Button1: TButton; - Button2: TButton; - Button3: TButton; - Button4: TButton; - grpTst : TGroupBox; - mnuFile: TMainMenu; - itmFileQuit: TMenuItem; - CheckBox1 : TCheckBox; - constructor Create(AOwner: TComponent); override; - procedure LoadMainMenu; - procedure mnuQuitClicked(Sender : TObject); - protected - procedure Button1CLick(Sender : TObject); - procedure Button2CLick(Sender : TObject); - procedure Button3CLick(Sender : TObject); - procedure Button4CLick(Sender : TObject); - end; - -var -Form1 : TForm1; +var Form1 : TForm1; constructor TForm1.Create(AOwner: TComponent); begin - inherited Create(AOwner); - Caption := 'Groubox Demo v0.1'; - LoadMainMenu; + inherited Create(AOwner); + Caption := 'Groubox Demo v0.1'; + LoadMainMenu; end; procedure TForm1.Button1Click(Sender : TObject); Begin - if assigned (grpTst) then grpTst.Height := grpTst.Height + 10; + if assigned (grpTst) then grpTst.Height := grpTst.Height + 10; End; procedure TForm1.Button2Click(Sender : TObject); Begin - if assigned (grpTst) then begin - grpTst.Width := grpTst.Width + 10; - grpTst.Show; - end; + if assigned (grpTst) then begin + grpTst.Width := grpTst.Width + 10; + grpTst.Show; + end; End; procedure TForm1.Button3Click(Sender : TObject); Begin - if assigned (grpTst) then begin - grpTst.Show; - end; + if assigned (grpTst) then begin + grpTst.Show; + end; End; procedure TForm1.Button4Click(Sender : TObject); Begin - if assigned (grpTst) then begin - grpTst.Hide; - end; + if assigned (grpTst) then begin + grpTst.Hide; + end; End; {------------------------------------------------------------------------------} {------------------------------------------------------------------------------} procedure TForm1.LoadMainMenu; - begin -{ set the height and width } -Height := 350; -Width := 700; + { set the height and width } + Height := 350; + Width := 700; -{ Create a groupbox } -grpTst := TGroupBox.Create(Self); -grpTst.Parent := self; -grpTst.top := 70; -grpTst.left := 10; -grpTst.Height :=200; -grpTst.Width := 300; -grpTst.Show; -grpTst.Caption := 'Groupbox with 2 Buttons'; + { Create a groupbox } + grpTst := TGroupBox.Create(Self); + with grpTst do begin + Name:='grpTst'; + Parent := self; + top := 70; + left := 10; + Height :=200; + Width := 300; + Caption := 'Groupbox with 2 Buttons'; + end; -{ Create 2 buttons inside the groupbox } -if assigned (grpTst) then -begin - Button2 := TButton.Create(grpTst); - Button2.Parent := grpTst; -end -else begin - Button2 := TButton.Create(Self); - Button2.Parent := Self; -end; -Button2.Left := 200; -Button2.Top := 50; -Button2.Width := 80; -Button2.Height := 30; -Button2.Show; -Button2.Caption := 'Width ++'; -Button2.OnClick := @Button2Click; + { Create 2 buttons inside the groupbox } + if assigned (grpTst) then + begin + Button2 := TButton.Create(grpTst); + Button2.Parent := grpTst; + end + else begin + Button2 := TButton.Create(Self); + Button2.Parent := Self; + end; + Button2.Name:='Button2'; + Button2.Left := 200; + Button2.Top := 50; + Button2.Width := 80; + Button2.Height := 30; + Button2.Caption := 'Width ++'; + Button2.OnClick := @Button2Click; -if assigned (grpTst) then -begin - Button1 := TButton.Create(grpTst); - Button1.Parent := grpTst; -end -else begin - Button1 := TButton.Create(Self); - Button1.Parent := Self; -end; -Button1.Left := 50; -Button1.Top := 50; -Button1.Width := 80; -Button1.Height := 30; -Button1.Show; -Button1.Caption := 'Height++'; -Button1.OnClick := @Button1Click; + if assigned (grpTst) then + begin + Button1 := TButton.Create(grpTst); + Button1.Parent := grpTst; + end + else begin + Button1 := TButton.Create(Self); + Button1.Parent := Self; + end; + Button1.Name:='Button1'; + Button1.Left := 50; + Button1.Top := 50; + Button1.Width := 80; + Button1.Height := 30; + Button1.Caption := 'Height++'; + Button1.OnClick := @Button1Click; -{ Create 2 more buttons outside the groupbox } -Button3 := TButton.Create(Self); -Button3.Parent := Self; -Button3.Left := 50; -Button3.Top := 30; -Button3.Width := 80; -Button3.Height := 30; -Button3.Show; -Button3.Caption := 'Show'; -Button3.OnClick := @Button3Click; + { Create 2 more buttons outside the groupbox } + Button3 := TButton.Create(Self); + Button3.Name:='Button3'; + Button3.Parent := Self; + Button3.Left := 50; + Button3.Top := 30; + Button3.Width := 80; + Button3.Height := 30; + Button3.Caption := 'Show'; + Button3.OnClick := @Button3Click; -Button4 := TButton.Create(Self); -Button4.Parent := Self; -Button4.Left := 200; -Button4.Top := 30; -Button4.Width := 80; -Button4.Height := 30; -Button4.Show; -Button4.Caption := 'Hide'; -Button4.OnClick := @Button4Click; + Button4 := TButton.Create(Self); + Button4.Name:='Button4'; + Button4.Parent := Self; + Button4.Left := 200; + Button4.Top := 30; + Button4.Width := 80; + Button4.Height := 30; + Button4.Caption := 'Hide'; + Button4.OnClick := @Button4Click; -mnuFile := TMainMenu.Create(Self); - -itmFileQuit := TMenuItem.Create(Self); -itmFileQuit.Caption := 'Quit'; -itmFileQuit.OnClick := @mnuQuitClicked; -mnuFile.Items.Add(itmFileQuit); + mnuFile := TMainMenu.Create(Self); + itmFileQuit := TMenuItem.Create(Self); + itmFileQuit.Caption := 'Quit'; + itmFileQuit.OnClick := @mnuQuitClicked; + mnuFile.Items.Add(itmFileQuit); end; {------------------------------------------------------------------------------} procedure TForm1.mnuQuitClicked(Sender : TObject); begin - Close; + Close; end; {------------------------------------------------------------------------------} begin - Application.Initialize; { calls InitProcedure which starts up GTK } - Application.CreateForm(TForm1, Form1); - Application.Run; + Application.Initialize; { calls InitProcedure which starts up GTK } + Application.CreateForm(TForm1, Form1); + Application.Run; end. diff --git a/examples/groupboxnested.pas b/examples/groupboxnested.pas new file mode 100644 index 0000000000..78f9fa9e43 --- /dev/null +++ b/examples/groupboxnested.pas @@ -0,0 +1,76 @@ +{ $Id$ } +{ + *************************************************************************** + * * + * This source is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This code is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * General Public License for more details. * + * * + * A copy of the GNU General Public License is available on the World * + * Wide Web at . You can also * + * obtain it by writing to the Free Software Foundation, * + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * * + *************************************************************************** +} +program GroupBoxNested; + +{$mode objfpc}{$H+} + +uses + Interfaces, Classes, SysUtils, StdCtrls, Forms, Controls; + +type + TForm1 = class(TFORM) + GroupBox1: TGroupBox; + GroupBox2: TGroupBox; + GroupBox3: TGroupBox; + public + constructor Create(TheOwner: TComponent); override; + end; + +{ TForm1 } + +constructor TForm1.Create(TheOwner: TComponent); +begin + inherited Create(TheOwner); + Name:='Form1'; + Caption:='Nested Groupbox demo'; + SetBounds(100,50,300,250); + + GroupBox1:=TGroupBox.Create(Self); + with GroupBox1 do begin + Name:='GroupBox1'; + Parent:=Self; + Align:=alClient; + end; + + GroupBox2:=TGroupBox.Create(Self); + with GroupBox2 do begin + Name:='GroupBox2'; + Parent:=GroupBox1; + Align:=alClient; + end; + + GroupBox3:=TGroupBox.Create(Self); + with GroupBox3 do begin + Name:='GroupBox3'; + Parent:=GroupBox2; + Align:=alClient; + end; +end; + +var Form1 : TForm1; + +begin + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index 012fe2f0c7..fd56c9c2f9 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -639,9 +639,9 @@ end; -------------------------------------------------------------------------------} procedure TWinControl.InvalidateClientRectCache; begin - {$IFDEF VerboseClientRectBugFix} + { $IFDEF VerboseClientRectBugFix} writeln('[TWinControl.InvalidateClientRectCache] ',Name,':',ClassName); - {$ENDIF} + { $ENDIF} Include(FFlags,wcfClientRectNeedsUpdate); end; @@ -656,7 +656,7 @@ end; example just puts resize requests into a queue. The LCL resizes the childs just after this procedure due to the clientrect. On complex forms with lots of nested controls, this results in thousands of resizes. - Changing the clientrect in the LCL to the most probable size reduce + Changing the clientrect in the LCL to the most probable size reduces unneccessary resizes. -------------------------------------------------------------------------------} procedure TWinControl.DoSetBounds(ALeft, ATop, AWidth, AHeight : integer); @@ -2880,6 +2880,8 @@ var NewBounds: TRect; begin NewBounds:=Bounds(Left, Top, Width, Height); + writeln('TWinControl.DoSendBoundsToInterface A ',Name,':',ClassName,' Old=',FBoundsRealized.Left,',',FBoundsRealized.Top,',',FBoundsRealized.Right,',',FBoundsRealized.Bottom, + ' New=',NewBounds.Left,',',NewBounds.Top,',',NewBounds.Right,',',NewBounds.Bottom); FBoundsRealized:=NewBounds; CNSendMessage(LM_SetSize, Self, @NewBounds); end; @@ -2946,6 +2948,9 @@ end; { ============================================================================= $Log$ + Revision 1.158 2003/08/12 16:04:22 mattias + added groupboxnested example + Revision 1.157 2003/08/12 14:02:54 mattias fixed keypress/keyup, createcaret on synedit focus