From 6300ada280f4d84ca6246d00d2d205f5dbd90e0e Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Sun, 15 Apr 2007 21:40:32 +0000 Subject: Fixed the rest of the GUI examples to work since we did a widget class renaming a while back. --- examples/gui/concepttest/OpenSoftStyle.pas | 254 ----------------- examples/gui/concepttest/compileroptform.frm | 42 +-- examples/gui/concepttest/frmCompilerOpt.pas | 44 +-- examples/gui/concepttest/hello.lpi | 401 +-------------------------- examples/gui/concepttest/hello.lpr | 218 ++++++++------- examples/gui/helloworld/helloworld.pas | 2 +- examples/gui/utfdemo/utfdemo.lpi | 14 +- examples/gui/widgetdemo/WidgetDemo.lpi | 56 ---- examples/gui/widgetdemo/WidgetDemo.lpr | 354 ----------------------- examples/gui/widgetdemo/widgetdemo.lpi | 56 ++++ examples/gui/widgetdemo/widgetdemo.lpr | 354 +++++++++++++++++++++++ 11 files changed, 588 insertions(+), 1207 deletions(-) delete mode 100644 examples/gui/concepttest/OpenSoftStyle.pas delete mode 100644 examples/gui/widgetdemo/WidgetDemo.lpi delete mode 100644 examples/gui/widgetdemo/WidgetDemo.lpr create mode 100644 examples/gui/widgetdemo/widgetdemo.lpi create mode 100644 examples/gui/widgetdemo/widgetdemo.lpr (limited to 'examples/gui') diff --git a/examples/gui/concepttest/OpenSoftStyle.pas b/examples/gui/concepttest/OpenSoftStyle.pas deleted file mode 100644 index 60a25f8d..00000000 --- a/examples/gui/concepttest/OpenSoftStyle.pas +++ /dev/null @@ -1,254 +0,0 @@ -unit OpenSoftStyle; - -{$mode objfpc}{$H+} - -interface - -uses - Classes, fpgui, gfxbase; - -type - - TGradientDirection = (gdTopToBottom, gdBottomToTop, gdLeftToRight, gdRightToLeft); - TCalcGradientEndX = function(Y, H: Integer): Integer; - - - TOpenSoftStyle = class(TDefaultStyle) - private - procedure PaintGradient(pCanvas: TGfxCanvas; const R: TRect; StartColor, EndColor: TColor; Direction: TGradientDirection; GradLines: Integer = -1); - public - // Colors - function GetGUIColor(Color: TColor): TGfxColor; override; - // Buttons (todo) - procedure DrawButtonFace(Canvas: TGfxCanvas; const ARect: TRect; Flags: TFButtonFlags); override; - // GroupBox - procedure DrawGroupBox(Canvas: TGfxCanvas; const ARect: TRect; const ALabel: String; WidgetState: TWidgetState); override; - end; - - -var - FOpenSoftStyle: TOpenSoftStyle; - -implementation - - -const - // Some predefined colors: - rgbaDkBlue: TGfxColor = (Red: $0000; Green: $0000; Blue: $8000; Alpha: $0000); - rgbaLtYellow: TGfxColor = (Red: $ffff; Green: $ffff; Blue: $e100; Alpha: $0000); - - rgbaWindowText: TGfxColor = (Red: $0000; Green: $0000; Blue: $0000; Alpha: $0000); - rgbaWindow: TGfxColor = (Red: $efef; Green: $efef; Blue: $efef; Alpha: $0000); - rgbaDkGrey: TGfxColor = (Red: $8686; Green: $8686; Blue: $8686; Alpha: $0000); - rgbaGbAALtGrey: TGfxColor = (Red: $baba; Green: $baba; Blue: $baba; Alpha: $0000); - rgbaGbAADkGrey: TGfxColor = (Red: $7878; Green: $7878; Blue: $7878; Alpha: $0000); - - -{ -procedure DrawGradient(Canvas: TCanvas; const R: TRect; StartColor, EndColor: TColor; - Direction: TGradientDirection; GradLines: Integer = -1; CalcEndX: TCalcGradientEndX = nil); -procedure DrawGradientEx(Canvas: TCanvas; const R: TRect; StartColor: TColor; - StartToMidHeight: Integer; MidColor, EndColor: TColor; - Direction: TGradientDirection; CalcEndX: TCalcGradientEndX = nil); - - -procedure ToRGB(c: TColor; out rgb: TRGB); -var - l: TColorRef; -begin - c := ColorFromColormap(c); - l := ColorToRGB(c); - rgb.r := TRGBValue(l).r; - rgb.g := TRGBValue(l).g; - rgb.b := TRGBValue(l).b; -end; -} - - -{ TOpenSoftStyle } - -procedure TOpenSoftStyle.PaintGradient(pCanvas: TGfxCanvas; const R: TRect; StartColor, EndColor: TColor; Direction: TGradientDirection; GradLines: Integer = -1); -var - X, i, w, h, Count: Integer; - EndCol, StartCol, AddCol, Tmp: TGfxColor; -begin - w := R.Right - R.Left - 1; - h := R.Bottom - R.Top - 1; - if (w <= 0) or (h <= 0) then - Exit; //==> - - StartCol := GetGUIColor(StartColor); - EndCol := GetGUIColor(EndColor); - - case Direction of - gdTopToBottom: - Count := h; - gdLeftToRight: - Count := w; - gdBottomToTop: - begin - Count := h; - Tmp := EndCol; - EndCol := StartCol; - StartCol := Tmp; - end; - gdRightToLeft: - begin - Count := w; - Tmp := EndCol; - EndCol := StartCol; - StartCol := Tmp; - end; - else - Exit; //==> - end; - if GradLines < 0 then - GradLines := Count; - - AddCol.r := (EndCol.r - StartCol.r) / GradLines; - AddCol.g := (EndCol.g - StartCol.g) / GradLines; - AddCol.b := (EndCol.b - StartCol.b) / GradLines; - -// Canvas.Pen.Style := psSolid; - pCanvas.SaveState; -// Canvas.Start; - try - StartColor := TColor(Round(StartCol.r), Round(StartCol.g), Round(StartCol.b)); -// Canvas.Pen.Color := StartColor; - pCanvas.SetColor(GetGUIColor(StartColor)); - for i := 0 to Count - 1 do - begin - if Direction in [gdTopToBottom, gdBottomToTop] then - begin - Canvas.MoveTo(R.Left, R.Top + i); - if Assigned(CalcEndX) then - X := CalcEndX(i, Count) - else - X := 0; - Canvas.LineTo(R.Right + X, R.Top + i); - end - else - begin - Canvas.MoveTo(R.Left + i, R.Top); - Canvas.LineTo(R.Left + i, R.Bottom); - end; - StartCol.r := StartCol.r + AddCol.r; - StartCol.g := StartCol.g + AddCol.g; - StartCol.b := StartCol.b + AddCol.b; - EndColor := RGB(Round(StartCol.r), Round(StartCol.g), Round(StartCol.b)); - if StartColor <> EndColor then - begin -// Canvas.Pen.Color := EndColor; - pCanvas.SetColor(GetGUIColor(EndColor)); - StartColor := EndColor; - end; - end; // for - finally -// Canvas.Stop; - pCanvas.RestoreState; - end; -end; - - -function TOpenSoftStyle.GetGUIColor(Color: TColor): TGfxColor; -begin - Result := inherited GetGUIColor(Color); - case Color of - // UI element colors - clScrollBar: Result := rgbaWindow; - clMenu: Result := rgbaWindow; -// clWindow: Result := GetUIColor(clWhite); -// clMenuText: Result := GetUIColor(clBlack); -// clWindowText: Result := GetUIColor(clBlack); -// clAppWorkSpace: Result := GetUIColor(clGray); -// clHighlight: Result := GetUIColor(clNavy); -// clHighlightText: Result := GetUIColor(clWhite); - cl3DFace: Result := rgbaWindow; -// cl3DShadow: Result := rgbaDkWhite; -// clGrayText: Result := GetUIColor(clGray); -// clBtnText: Result := GetUIColor(clBlack); -// cl3DHighlight: Result := GetUIColor(clWhite); - cl3DDkShadow: Result := GetUIColor(clMidnightBlue); -// cl3DLight: Result := GetUIColor(clDarkWhite); -// clInfoText: Result := GetUIColor(clBlack); -// clInfoBk: Result := GetUIColor(clLightYellow); -// -// else Result := GetUIColor(clWhite); - end; - -end; - - -procedure TOpenSoftStyle.DrawButtonFace(Canvas: TGfxCanvas; const ARect: TRect; - Flags: TFButtonFlags); -begin -// inherited DrawButtonFace(Canvas, ARect, Flags); - PaintGradient(Canvas, ARect, Flags); - Draw3DFrame(Canvas, ARect, cl3DHighlight, cl3DLight, cl3DDkShadow, cl3DShadow); -end; - - -procedure TOpenSoftStyle.DrawGroupBox(Canvas: TGfxCanvas; const ARect: TRect; - const ALabel: String; WidgetState: TWidgetState); -var - TitleWidth, TitleHeight, TopLine: Integer; -begin - TitleWidth := Canvas.TextWidth(ALabel); - TitleHeight := Canvas.FontCellHeight; - TopLine := ARect.Top + TitleHeight div 3; - - Canvas.SetColor(rgbaDkGrey); - // box outline - with ARect do - begin - // top - Canvas.DrawLine(Point(Left + 2, TopLine), Point(Left + 12, TopLine)); - Canvas.DrawLine(Point(Left + TitleWidth + 16, TopLine), Point(Right - 2, TopLine)); - // right - Canvas.DrawLine(Point(Right-1, TopLine + 2), Point(Right-1, Bottom - 2)); - // bottom - Canvas.DrawLine(Point(Right - 3, Bottom-1), Point(Left + 1, Bottom-1)); - // left - Canvas.DrawLine(Point(Left, Bottom - 3), Point(Left, TopLine + 1)); - end; - - // Text caption - SetUIColor(Canvas, clWindowText); - DrawText(Canvas, ARect.TopLeft + Point(14, 0), ALabel, WidgetState); - - { Anti-Aliasing - Top/Left } - Canvas.SetColor(rgbaGbAALtGrey); - Canvas.DrawPoint(ARect.TopLeft + Point(0, TopLine+1)); - Canvas.DrawPoint(ARect.TopLeft + Point(1, TopLine)); - Canvas.SetColor(rgbaGbAADkGrey); - Canvas.DrawPoint(ARect.TopLeft + Point(1, TopLine+1)); - { Anti-Aliasing - Top/Right } - Canvas.SetColor(rgbaGbAALtGrey); - Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-1, TopLine+1)); - Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, TopLine)); - Canvas.SetColor(rgbaGbAADkGrey); - Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, TopLine+1)); - { Anti-Aliasing - Bottom/Right } - Canvas.SetColor(rgbaGbAALtGrey); - Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-1, ARect.Bottom-2)); - Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, ARect.Bottom-1)); - Canvas.SetColor(rgbaGbAADkGrey); - Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, ARect.Bottom-2)); - { Anti-Aliasing - Bottom/Left } - Canvas.SetColor(rgbaGbAALtGrey); - Canvas.DrawPoint(ARect.TopLeft + Point(0, ARect.Bottom-2)); - Canvas.DrawPoint(ARect.TopLeft + Point(1, ARect.Bottom-1)); - Canvas.SetColor(rgbaGbAADkGrey); - Canvas.DrawPoint(ARect.TopLeft + Point(1, ARect.Bottom-2)); -end; - - -initialization - FOpenSoftStyle := TOpenSoftStyle.Create(Application.Display); - -finalization - if Assigned(FOpenSoftStyle) then - FOpenSoftStyle.Free; - -end. - diff --git a/examples/gui/concepttest/compileroptform.frm b/examples/gui/concepttest/compileroptform.frm index 054601db..708f2e09 100644 --- a/examples/gui/concepttest/compileroptform.frm +++ b/examples/gui/concepttest/compileroptform.frm @@ -8,43 +8,43 @@ object CompilerOptForm: TCompilerOptForm Orientation = Vertical Spacing = 4 object Box4: TFBoxLayout - object grpBox1: TGroupBox + object grpBox1: TFGroupBox Text = 'Unit Style:' object grpBox1VBox1: TFBoxLayout Orientation = Vertical - object cbSmartLink: TCheckbox + object cbSmartLink: TFCheckbox Checked = True Text = 'Smart Linkable (-CX)' end end end - object grpBox2: TGroupBox + object grpBox2: TFGroupBox Text = 'Checks:' object grpBox2VBox1: TFBoxLayout Orientation = Vertical - object rbIO: TRadioButton + object rbIO: TFRadioButton Checked = True Text = 'I/O (-Ci)' end - object rbOverflow: TRadioButton + object rbOverflow: TFRadioButton Checked = True Text = 'Overflow (-Co)' end - object rbRange: TRadioButton + object rbRange: TFRadioButton Checked = True Text = 'Range (-Cr)' end - object rbStack: TRadioButton + object rbStack: TFRadioButton Checked = True Text = 'Stack (-Ct)' end end end - object grpBox3: TGroupBox + object grpBox3: TFGroupBox Text = 'Heap Size (-Ch):' object grpBox3VBox1: TFBoxLayout Orientation = Vertical - object edHeapSize: TEdit + object edHeapSize: TFEdit Text = '0' CanExpandWidth = False end @@ -52,23 +52,23 @@ object CompilerOptForm: TCompilerOptForm end end object Box5: TFBoxLayout - object grpBox4: TGroupBox + object grpBox4: TFGroupBox Text = 'Generate:' object grpBox4VBox1: TFBoxLayout Orientation = Vertical - object rbNormal: TRadioButton + object rbNormal: TFRadioButton Text = 'Normal Code (none)' end - object rbFaster: TRadioButton + object rbFaster: TFRadioButton Checked = True Text = 'Faster Code (-OG)' end - object rbSmaller: TRadioButton + object rbSmaller: TFRadioButton Text = 'Smaller Code (-Og)' end end end - object grpBox5: TGroupBox + object grpBox5: TFGroupBox Text = 'Target Platform:' CanExpandHeight = True object grpBox5VBox1: TFBoxLayout @@ -87,28 +87,28 @@ object CompilerOptForm: TCompilerOptForm end end object Box6: TFBoxLayout - object grpBox6: TGroupBox + object grpBox6: TFGroupBox Text = 'Optimizations:' object grpBox6VBox1: TFBoxLayout Orientation = Vertical CanExpandWidth = True - object rbLevel0: TRadioButton + object rbLevel0: TFRadioButton Text = 'Level 0 (no extra Optimizations) (none)' end - object rbLevel1: TRadioButton + object rbLevel1: TFRadioButton Checked = True Text = 'Level 1 (Quick Optimizations) (-O1)' end - object rbLevel2: TRadioButton + object rbLevel2: TFRadioButton Text = 'Level 2 (Level 1 + Slower Optimizations) (-O2)' end - object rbLevel3: TRadioButton + object rbLevel3: TFRadioButton Text = 'Level 3 (Level 2 + Uncertain) (-O3)' end - object rbKeepVarReg: TCheckbox + object rbKeepVarReg: TFCheckbox Text = 'Keep certain variables in registers (-Or)' end - object rbUncOpt: TCheckbox + object rbUncOpt: TFCheckbox Text = 'Uncertain Optimizations (-Ou)' end end diff --git a/examples/gui/concepttest/frmCompilerOpt.pas b/examples/gui/concepttest/frmCompilerOpt.pas index b472e2ab..1a883c64 100644 --- a/examples/gui/concepttest/frmCompilerOpt.pas +++ b/examples/gui/concepttest/frmCompilerOpt.pas @@ -11,9 +11,9 @@ type { TCompilerOptForm } - TCompilerOptForm = Class(TForm) + TCompilerOptForm = Class(TFForm) private - FGroupBoxStyle: TStyle; + FGroupBoxStyle: TStyleAbs; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -28,34 +28,34 @@ type Box5: TFBoxLayout; Box6: TFBoxLayout; btnOK, btnCancel, btnShowOp, btnTest, btnLoadSave : TFButton; - grpBox1: TGroupBox; + grpBox1: TFGroupBox; grpBox1VBox1: TFBoxLayout; cbSmartLink: TFCheckbox; - grpBox2: TGroupBox; + grpBox2: TFGroupBox; grpBox2VBox1: TFBoxLayout; - rbIO: TRadioButton; - rbOverflow: TRadioButton; - rbRange: TRadioButton; - rbStack: TRadioButton; - grpBox3: TGroupBox; + rbIO: TFRadioButton; + rbOverflow: TFRadioButton; + rbRange: TFRadioButton; + rbStack: TFRadioButton; + grpBox3: TFGroupBox; grpBox3VBox1: TFBoxLayout; - edHeapSize: TEdit; - grpBox4: TGroupBox; + edHeapSize: TFEdit; + grpBox4: TFGroupBox; grpBox4VBox1: TFBoxLayout; - rbNormal: TRadioButton; - rbFaster: TRadioButton; - rbSmaller: TRadioButton; - grpBox5: TGroupBox; + rbNormal: TFRadioButton; + rbFaster: TFRadioButton; + rbSmaller: TFRadioButton; + grpBox5: TFGroupBox; grpBox5VBox1: TFBoxLayout; lblTarget1: TFLabel; lblTarget2: TFLabel; lblTarget3: TFLabel; - grpBox6: TGroupBox; + grpBox6: TFGroupBox; grpBox6VBox1: TFBoxLayout; - rbLevel0: TRadioButton; - rbLevel1: TRadioButton; - rbLevel2: TRadioButton; - rbLevel3: TRadioButton; + rbLevel0: TFRadioButton; + rbLevel1: TFRadioButton; + rbLevel2: TFRadioButton; + rbLevel3: TFRadioButton; rbKeepVarReg: TFCheckbox; rbUncOpt: TFCheckbox; end; @@ -64,8 +64,8 @@ var CompOpt: TCompilerOptForm; implementation -uses - OpenSoftStyle; +//uses +// OpenSoftStyle; { TCompilerOptForm } diff --git a/examples/gui/concepttest/hello.lpi b/examples/gui/concepttest/hello.lpi index 98611428..7d035197 100644 --- a/examples/gui/concepttest/hello.lpi +++ b/examples/gui/concepttest/hello.lpi @@ -4,14 +4,16 @@ + + + + - - @@ -26,407 +28,30 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + diff --git a/examples/gui/concepttest/hello.lpr b/examples/gui/concepttest/hello.lpr index 7e723696..8a2fbc31 100644 --- a/examples/gui/concepttest/hello.lpr +++ b/examples/gui/concepttest/hello.lpr @@ -7,13 +7,13 @@ uses cthreads, {$ENDIF}{$ENDIF} Classes, - fpgui, gfxbase, frmCompilerOpt, OpenSoftStyle, fpguipackage; + fpGUI, fpGFX, gfxbase, frmCompilerOpt, StyleManager; type { TMainForm } - TMainForm = class(TForm) + TMainForm = class(TFForm) procedure Button3Clicked(Sender: TObject); private procedure btnCloseClick(Sender: TObject); @@ -24,23 +24,23 @@ type public constructor Create(AOwner: TComponent); override; published - HBox: TBoxLayout; - VBox: TBoxLayout; - TextLabel: TLabel; - Button: TButton; - btnGridForm: TButton; - btnCompOpt: TButton; - Button1: TButton; - Button2: TButton; - Button3: TButton; + HBox: TFBoxLayout; + VBox: TFBoxLayout; + TextLabel: TFLabel; + Button: TFButton; + btnGridForm: TFButton; + btnCompOpt: TFButton; + Button1: TFButton; + Button2: TFButton; + Button3: TFButton; end; { TGridForm } - TGridForm = Class(TForm) - Layout : TGridLayout; - Button1,Button2,Button3,Button4,Button5 : TButton; + TGridForm = Class(TFForm) + Layout: TFGridLayout; + Button1,Button2,Button3,Button4,Button5: TFButton; public constructor Create(AOwner: TComponent); override; end; @@ -48,22 +48,22 @@ type { TFindDialog } - TFindDialog = class(TForm) + TFindDialog = class(TFForm) private procedure btnCloseClick(Sender: TObject); public constructor Create(AOwner: TComponent); override; published - lblFind: TLabel; - btnFindNext, btnClose: TButton; - edFind: TEdit; - GroupBox1: TGroupBox; - grpBox1Layout: TBoxLayout; - Radio1, Radio2: TRadioButton; - cbCase: TCheckBox; - leftLayout, rightLayout: TBoxLayout; - topLeftLayout: TBoxLayout; - mainLayout: TBoxLayout; + lblFind: TFLabel; + btnFindNext, btnClose: TFButton; + edFind: TFEdit; + GroupBox1: TFGroupBox; + grpBox1Layout: TFBoxLayout; + Radio1, Radio2: TFRadioButton; + cbCase: TFCheckBox; + leftLayout, rightLayout: TFBoxLayout; + topLeftLayout: TFBoxLayout; + mainLayout: TFBoxLayout; end; @@ -80,49 +80,54 @@ begin inherited Create(AOwner); Text := 'Find Dialog'; BorderWidth := 8; - WindowType := wtWindow; - topLeftLayout := TBoxLayout.Create(self); - lblFind := TLabel.Create(self); - lblFind.Text := 'Find what'; - edFind := TEdit.Create(self); + topLeftLayout := TFBoxLayout.Create(self); + topLeftLayout.CanExpandWidth := True; + lblFind := TFLabel.Create(self); + lblFind.Text := 'Find what:'; + edFind := TFEdit.Create(self); topLeftLayout.InsertChild(lblFind); topLeftLayout.InsertChild(edFind); - leftLayout := TBoxLayout.Create(self); + leftLayout := TFBoxLayout.Create(self); leftLayout.Orientation := Vertical; - leftLayout.CanExpandHeight := True; - GroupBox1 := TGroupBox.Create(self); + leftLayout.CanExpandWidth := True; + + GroupBox1 := TFGroupBox.Create(self); GroupBox1.Text := 'Direction'; - grpBox1Layout := TBoxLayout.Create(self); -// grpBox1Layout.Orientation := Vertical; + GroupBox1.CanExpandWidth := True; + grpBox1Layout := TFBoxLayout.Create(self); + Radio1 := TFRadioButton.Create(self); + Radio1.Text := 'Up'; + Radio1.CanExpandWidth := True; + Radio2 := TFRadioButton.Create(self); + Radio2.Text := 'Down'; + Radio2.CanExpandWidth := True; GroupBox1.InsertChild(grpBox1Layout); - Radio1 := TRadioButton.Create(self); - Radio1.Text := 'Up'; - Radio2 := TRadioButton.Create(self); - Radio2.Text := 'Down'; grpBox1Layout.InsertChild(Radio1); grpBox1Layout.InsertChild(Radio2); - cbCase := TCheckBox.Create(self); + cbCase := TFCheckBox.Create(self); cbCase.Text := 'Case sensitive'; + cbCase.CanExpandWidth := True; + leftLayout.InsertChild(topLeftLayout); leftLayout.InsertChild(GroupBox1); leftLayout.InsertChild(cbCase); - rightLayout := TBoxLayout.Create(self); + rightLayout := TFBoxLayout.Create(self); rightLayout.Orientation := Vertical; rightLayout.VertAlign := vertTop; - btnFindNext := TButton.Create(self); - btnFindNext.Text := 'Find Next'; - btnClose := TButton.Create(self); - btnClose.Text := 'Close'; - btnClose.CanExpandWidth := True; - btnClose.OnClick := @btnCloseClick; + btnFindNext := TFButton.Create(self); + btnFindNext.Text := 'Find Next'; + btnClose := TFButton.Create(self); + btnClose.Text := 'Close'; + btnClose.CanExpandWidth := True; + btnClose.OnClick := @btnCloseClick; rightLayout.InsertChild(btnFindNext); rightLayout.InsertChild(btnClose); - mainLayout := TBoxLayout.Create(self); + mainLayout := TFBoxLayout.Create(self); mainLayout.InsertChild(leftLayout); mainLayout.InsertChild(rightLayout); @@ -166,30 +171,30 @@ begin BorderWidth := 8; self.BorderWidth := 11; - Layout := TGridLayout.Create(Self); + Layout := TFGridLayout.Create(Self); Layout.Name := 'Layout'; Layout.RowCount := 3; Layout.ColCount := 3; - Button1 := TButton.Create(Self); + Button1 := TFButton.Create(Self); Button1.Name := 'TopLeft'; Button1.Text := 'Top Left'; Layout.AddWidget(Button1, 0, 0, 1, 1); - Button2 := TButton.Create(Self); + Button2 := TFButton.Create(Self); Button2.Name := 'TopRight'; Button2.Text := 'Top Right'; Layout.AddWidget(Button2, 2,0,1,1); - Button3 := TButton.Create(Self); + Button3 := TFButton.Create(Self); Button3.Name := 'CenterCenter'; Button3.Text := 'Center Center'; // Button3.CanExpandWidth := False; // Button3.CanExpandHeight := False; Layout.AddWidget(Button3, 1,1,1,1); - Button4 := TButton.Create(Self); + Button4 := TFButton.Create(Self); Button4.Name := 'BottomLeft'; Button4.Text := 'Bottom Left'; Layout.AddWidget(Button4,0,2,1,1); - Button5 := TButton.Create(Self); + Button5 := TFButton.Create(Self); Button5.Name := 'BottomRight'; Button5.Text := 'Bottom Right'; Layout.AddWidget(Button5, 2,2,1,1); @@ -226,7 +231,12 @@ end; procedure TMainForm.btnCompOptClick(Sender: TObject); begin if not Assigned(CompOpt) then - Application.CreateForm(TCompilerOptForm, CompOpt) + begin + CompOpt := TCompilerOptForm.Create(GFApplication); + LoadForm(CompOpt); + CompOpt.Style := gStyleManager.CreateInstance('OpenSoft'); + CompOpt.Show; + end else CompOpt.Show; end; @@ -255,59 +265,56 @@ begin inherited Create(AOwner); Name := 'frmMain'; BorderWidth := 8; - WindowType := wtWindow; OnActivate := @MainFormActivate; - HBox := TBoxLayout.Create(self); - HBox.Name := 'HBox'; - HBox.Parent := self; - HBox.Spacing := 3; - HBox.Orientation := Horizontal; - - TextLabel := TLabel.Create(self); - TextLabel.Name := 'TextLabel'; - TextLabel.Text := 'Hello'; - TextLabel.Parent := HBox; - - Button := TButton.Create(self); - Button.Parent := HBox; - Button.Text := 'Close'; - Button.OnClick := @btnCloseClick; - - btnGridForm := TButton.Create(self); - btnGridForm.Parent := HBox; - btnGridForm.Text := 'Grid Form'; - btnGridForm.OnClick := @btnGridFormClick; + HBox := TFBoxLayout.Create(self); + HBox.Name := 'HBox'; + HBox.Parent := self; + HBox.Spacing := 3; + HBox.Orientation := Horizontal; + + TextLabel := TFLabel.Create(self); + TextLabel.Name := 'TextLabel'; + TextLabel.Text := 'Hello'; + TextLabel.Parent := HBox; + + Button := TFButton.Create(self); + Button.Parent := HBox; + Button.Text := 'Close'; + Button.OnClick := @btnCloseClick; + + btnGridForm := TFButton.Create(self); + btnGridForm.Parent := HBox; + btnGridForm.Text := 'Grid Form'; + btnGridForm.OnClick := @btnGridFormClick; - btnCompOpt := TButton.Create(Self); - btnCompOpt.Parent := HBox; - btnCompOpt.Name := 'btnCompOpt'; - btnCompOpt.Text := 'Compiler Options'; - btnCompOpt.OnClick := @btnCompOptClick; -// btnCompOpt.FCanExpandWidth := True; // if not used, button is smaller than others - - VBox := TBoxLayout.Create(self); - VBox.Orientation := Vertical; - Button1 := TButton.Create(Self); - Button1.Name := 'Top'; - Button1.Text := 'Top'; - Button1.CanExpandWidth := True; // if not used, button is smaller than others - Button1.OnClick := @btnTopClick; + btnCompOpt := TFButton.Create(Self); + btnCompOpt.Parent := HBox; + btnCompOpt.Name := 'btnCompOpt'; + btnCompOpt.Text := 'Compiler Options'; + btnCompOpt.OnClick := @btnCompOptClick; + + VBox := TFBoxLayout.Create(self); + VBox.Orientation := Vertical; + Button1 := TFButton.Create(Self); + Button1.Name := 'Top'; + Button1.Text := 'Top'; + Button1.CanExpandWidth := True; // if not used, button is smaller than others + Button1.OnClick := @btnTopClick; VBox.InsertChild(Button1); - Button2 := TButton.Create(Self); - Button2.Name := 'Centre'; - Button2.Text := 'Centre'; - Button2.CanExpandWidth := True; + Button2 := TFButton.Create(Self); + Button2.Name := 'Centre'; + Button2.Text := 'Centre'; + Button2.CanExpandWidth := True; VBox.InsertChild(Button2); - Button3 := TButton.Create(Self); - Button3.Name := 'Bottom'; - Button3.Text := 'Bottom (SetBounds)'; - Button3.OnClick :=@Button3Clicked; + Button3 := TFButton.Create(Self); + Button3.Name := 'Bottom'; + Button3.Text := 'Bottom (SetBounds)'; + Button3.OnClick := @Button3Clicked; VBox.InsertChild(Button3); HBox.InsertChild(VBox); - Child := HBox; end; @@ -317,18 +324,19 @@ var begin MainForm := nil; - { set application wide style } - Application.SetStyle(FOpenSoftStyle); + { set application wide style } + GFApplication.Initialize; +// gStyleManager.CreateInstance('OpenSoft'); - MainForm := TMainForm.Create(Application); -// MainForm.SetBounds(Point(100, 300), Size(300,200)); + MainForm := TMainForm.Create(GFApplication); try + MainForm.Style := gStyleManager.CreateInstance('OpenSoft'); MainForm.Show; - Application.Run; + GFApplication.Run; finally MainForm.Free; end; - end. + diff --git a/examples/gui/helloworld/helloworld.pas b/examples/gui/helloworld/helloworld.pas index 16af32f5..bbcfd99b 100644 --- a/examples/gui/helloworld/helloworld.pas +++ b/examples/gui/helloworld/helloworld.pas @@ -9,7 +9,7 @@ uses ; type - TMainForm = class(TForm) + TMainForm = class(TFForm) private BoxLayout: TFBoxLayout; btnHello: TFButton; diff --git a/examples/gui/utfdemo/utfdemo.lpi b/examples/gui/utfdemo/utfdemo.lpi index 35240ae6..07c7660d 100644 --- a/examples/gui/utfdemo/utfdemo.lpi +++ b/examples/gui/utfdemo/utfdemo.lpi @@ -1,7 +1,7 @@ - + @@ -9,7 +9,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -39,11 +39,13 @@ - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/gui/widgetdemo/WidgetDemo.lpr b/examples/gui/widgetdemo/WidgetDemo.lpr deleted file mode 100644 index 0dc8d206..00000000 --- a/examples/gui/widgetdemo/WidgetDemo.lpr +++ /dev/null @@ -1,354 +0,0 @@ -{ - A proof of concept demo to see if we could duplicate one of Qt4's demos. -} - -program WidgetDemo; - -{$mode objfpc}{$H+} - -uses - {$IFDEF UNIX}{$IFDEF UseCThreads} - cthreads, - {$ENDIF}{$ENDIF} - Classes - ,SysUtils - ,fpGFX - ,fpGUI - ,StyleManager - ; - -type - - { TWidgetDemoForm } - - TWidgetDemoForm = class(TFForm) - topLayout: TFBoxLayout; - mainLayout: TFGridLayout; - MainMenu: TFMenuBar; - - topStyleComboLayout: TFBoxLayout; - lblStyle: TFLabel; - cbStyle: TFComboBox; - - topCheckboxLayout: TFBoxLayout; - chkStdPalette: TFCheckBox; - chkDisable: TFCheckBox; - - topLeftGroupBox: TFGroupBox; - topLeftGroupBoxLayout: TFBoxLayout; - Radio1: TFRadioButton; - Radio2: TFRadioButton; - Radio3: TFRadioButton; - - topRightGroupBox: TFGroupBox; - topRightGroupBoxLayout: TFBoxLayout; - Button1: TFButton; - Button2: TFButton; - - StringGrid: TFStringGrid; - - bottomRightGroupBox: TFGroupBox; - bottomRightGroupBoxLayout: TFBoxLayout; - Edit1: TFEdit; - Edit2: TFEdit; - - bottomButtonLayout: TFBoxLayout; - btnExit: TFButton; - btnHelp: TFButton; - - procedure btnExitClick(Sender: TObject); - procedure Radio1Click(Sender: TObject); - procedure Radio2Click(Sender: TObject); - procedure cbStyleChanged(Sender: TObject); - procedure TranslateToAfrikaans; - procedure TranslateToEnglish; - procedure chkDisableClick(Sender: TObject); - private - procedure CreateTopMenu; - procedure CreateStyleCombo; - procedure CreateTopCheckboxLine; - procedure CreateTopLeftGroupBox; - procedure CreateTopRightGroupBox; - procedure CreateBottomLeftStringGrid; - procedure CreateBottomRightGroupBox; - procedure CreateBottomButtonLayout; - public - constructor Create(AOwner: TComponent); override; - end; - - -{ TWidgetDemoForm } - -procedure TWidgetDemoForm.btnExitClick(Sender: TObject); -begin - Close; -end; - -procedure TWidgetDemoForm.Radio1Click(Sender: TObject); -begin - TranslateToEnglish; -end; - -procedure TWidgetDemoForm.Radio2Click(Sender: TObject); -begin - TranslateToAfrikaans; -end; - -procedure TWidgetDemoForm.cbStyleChanged(Sender: TObject); -begin - { I want to try something later with this } -// gStyleManager.SetStyle(cbStyle.Text); - if cbStyle.Text <> cDefaultStyle then - Style.Free; - Style := gStyleManager.CreateInstance(cbStyle.Text); - Redraw; -end; - -procedure TWidgetDemoForm.TranslateToAfrikaans; -begin - Text := 'Widget Demo - Afrikaans'; - lblStyle.Text := 'Venster Steil:'; - chkStdPalette.Text := 'Standaard kleur tablette'; - chkDisable.Text := 'Ge-deaktiveerde controles'; - topLeftGroupBox.Text := 'Groep Boks Een'; - Radio1.Text := 'Radio knoppie een'; - Radio2.Text := 'Radio knoppie twee'; - Radio3.Text := 'Radio knoppie drie'; - topLeftGroupBox.Text := 'Groep Boks Twee'; - Button1.Text := 'Normal Button'; - Button2.Text := 'Embedded Button'; - bottomRightGroupBox.Text := 'Group Boks Drie'; - Edit1.Text := 'Normale teks'; - Edit2.Text := 'Wagwoord teks'; - btnExit.Text := 'Verlaat Verlaat'; - btnHelp.Text := 'Hulp'; - Redraw; -end; - -procedure TWidgetDemoForm.TranslateToEnglish; -begin - Text := 'Widget Demo - English'; - lblStyle.Text := 'Style:'; - chkStdPalette.Text := 'Standard color palette'; - chkDisable.Text := 'Disable widgets'; - topLeftGroupBox.Text := 'Group Box 1'; - Radio1.Text := 'Radio button 1'; - Radio2.Text := 'Radio button 2'; - Radio3.Text := 'Radio button 3'; - topRightGroupBox.Text := 'Group Box 2'; - Button1.Text := 'Normal Button'; - Button2.Text := 'Embedded Button'; - bottomRightGroupBox.Text := 'Group Box 3'; - Edit1.Text := 'Normal Edit'; - Edit2.Text := 'Password Edit'; - btnExit.Text := 'Exit'; - btnHelp.Text := 'Help'; - Redraw; -end; - -procedure TWidgetDemoForm.chkDisableClick(Sender: TObject); -begin - lblStyle.Enabled := not chkDisable.Checked; - cbStyle.Enabled := not chkDisable.Checked; - chkStdPalette.Enabled := not chkDisable.Checked; - topLeftGroupBox.Enabled := not chkDisable.Checked; - topRightGroupBox.Enabled := not chkDisable.Checked; - StringGrid.Enabled := not chkDisable.Checked; - bottomRightGroupBox.Enabled := not chkDisable.Checked; -end; - -procedure TWidgetDemoForm.CreateTopMenu; -var - mi: TFMenuItem; -begin - MainMenu := TFMenuBar.Create(self); - mi := MainMenu.AddMenu('File'); - mi.SubMenu.AddMenu('Exit', '', @btnExitClick); - MainMenu.AddMenu('Edit'); - MainMenu.AddMenu('Options'); - MainMenu.AddMenu('Windows'); - MainMenu.AddMenu('Help'); -// MainMenu.CanExpandWidth := True; -end; - -procedure TWidgetDemoForm.CreateStyleCombo; -begin - topStyleComboLayout := TFBoxLayout.Create(self); - - lblStyle := TFLabel.Create('Style:', self); - - cbStyle := TFComboBox.Create(self); - cbStyle.CanExpandWidth := True; - gStyleManager.AssignStyleTypes(cbStyle.Items); - cbStyle.OnChange := @cbStyleChanged; - cbStyle.ItemIndex := 0; - - topStyleComboLayout.InsertChild(lblStyle); - topStyleComboLayout.InsertChild(cbStyle); -end; - -procedure TWidgetDemoForm.CreateTopCheckboxLine; -begin - topCheckboxLayout := TFBoxLayout.Create(self); - - chkStdPalette := TFCheckBox.Create('Standard color palette', self); - chkStdPalette.CanExpandWidth := True; - chkStdPalette.Checked := True; - - chkDisable := TFCheckBox.Create('Disable widgets', self); - chkDisable.OnClick := @chkDisableClick; - - topCheckboxLayout.InsertChild(chkStdPalette); - topCheckboxLayout.InsertChild(chkDisable); -end; - -procedure TWidgetDemoForm.CreateTopLeftGroupBox; -begin - topLeftGroupBox := TFGroupBox.Create('Group Box 1', self); - topLeftGroupBox.CanExpandWidth := True; - - topLeftGroupBoxLayout := TFBoxLayout.Create(self); - topLeftGroupBoxLayout.Orientation := Vertical; - - Radio1 := TFRadioButton.Create('Radio button 1', self); - Radio1.Checked := True; - Radio1.CanExpandWidth := True; - Radio1.OnClick := @Radio1Click; - - Radio2 := TFRadioButton.Create('Radio button 2', self); - Radio2.CanExpandWidth := True; - Radio2.OnClick := @Radio2Click; - - Radio3 := TFRadioButton.Create('Radio button 3', self); - Radio3.CanExpandWidth := True; - - topLeftGroupBox.InsertChild(topLeftGroupBoxLayout); - topLeftGroupBoxLayout.InsertChild(Radio1); - topLeftGroupBoxLayout.InsertChild(Radio2); - topLeftGroupBoxLayout.InsertChild(Radio3); -end; - -procedure TWidgetDemoForm.CreateTopRightGroupBox; -begin - topRightGroupBox := TFGroupBox.Create('Group Box 2', self); - topRightGroupBox.CanExpandWidth := True; - topRightGroupBox.CanExpandHeight := True; - - topRightGroupBoxLayout := TFBoxLayout.Create(self); - topRightGroupBoxLayout.Orientation := Vertical; - topRightGroupBoxLayout.VertAlign := vertCenter; - topRightGroupBoxLayout.Spacing := 8; - - Button1 := TFButton.Create('Normal Button', self); - Button1.CanExpandWidth := True; - - Button2 := TFButton.Create('Embedded Button', self); - Button2.CanExpandWidth := True; - Button2.Embedded := True; - - topRightGroupBox.InsertChild(topRightGroupBoxLayout); - topRightGroupBoxLayout.InsertChild(Button1); - topRightGroupBoxLayout.InsertChild(Button2); -end; - -procedure TWidgetDemoForm.CreateBottomLeftStringGrid; -var - x, y: integer; -begin - StringGrid := TFStringGrid.Create(self); - StringGrid.ColCount := 10; - StringGrid.RowCount := 15; - for y := 0 to StringGrid.RowCount - 1 do - for x := 0 to StringGrid.ColCount - 1 do - StringGrid.Cells[x, y] := Format('%d, %d', [x, y]); -end; - -procedure TWidgetDemoForm.CreateBottomRightGroupBox; -begin - bottomRightGroupBox := TFGroupBox.Create('Group Box 3', self); - bottomRightGroupBox.CanExpandHeight := True; - bottomRightGroupBox.CanExpandWidth := True; - - bottomRightGroupBoxLayout := TFBoxLayout.Create(self); - bottomRightGroupBoxLayout.Orientation := Vertical; - - Edit1 := TFEdit.Create('Normal Edit', self); - Edit2 := TFEdit.Create('Password Edit', self); - Edit2.PasswordChar := '*'; - - bottomRightGroupBox.InsertChild(bottomRightGroupBoxLayout); - bottomRightGroupBoxLayout.InsertChild(Edit1); - bottomRightGroupBoxLayout.InsertChild(Edit2); -end; - -procedure TWidgetDemoForm.CreateBottomButtonLayout; -begin - bottomButtonLayout := TFBoxLayout.Create(self); - bottomButtonLayout.HorzAlign := horzRight; - - btnHelp := TFButton.Create('Help', self); - - btnExit := TFButton.Create('Exit', self); - btnExit.OnClick := @btnExitClick; - - bottomButtonLayout.InsertChild(btnHelp); - bottomButtonLayout.InsertChild(btnExit); -end; - -constructor TWidgetDemoForm.Create(AOwner: TComponent); -begin - inherited Create(AOwner); - Text := 'Widget Demo'; - BorderWidth := 8; -// WindowType := wtWindow; - - topLayout := TFBoxLayout.Create(self); - topLayout.Orientation := Vertical; - mainLayout := TFGridLayout.Create(self); - mainLayout.RowCount := 2; - - CreateTopMenu; - topLayout.InsertChild(MainMenu); - - CreateStyleCombo; - topLayout.InsertChild(topStyleComboLayout); - - CreateTopCheckboxLine; - topLayout.InsertChild(topCheckboxLayout); - - CreateTopLeftGroupBox; - mainLayout.AddWidget(topLeftGroupBox, 0, 0, 1, 1); - - CreateTopRightGroupBox; - mainLayout.AddWidget(topRightGroupBox, 1, 0, 1, 1); - - CreateBottomLeftStringGrid; - mainLayout.AddWidget(StringGrid, 0, 1, 1, 1); - - CreateBottomRightGroupBox; - mainLayout.AddWidget(bottomRightGroupBox, 1, 1, 1, 1); - - topLayout.InsertChild(mainLayout); - - CreateBottomButtonLayout; - topLayout.InsertChild(bottomButtonLayout); - - Child := topLayout; -end; - - -var - WidgetDemoForm: TWidgetDemoForm; - -begin - GFApplication.Initialize; - - WidgetDemoForm := TWidgetDemoForm.Create(GFApplication); - try - WidgetDemoForm.Show; - GFApplication.Run; - finally - WidgetDemoForm.Free; - end; -end. - diff --git a/examples/gui/widgetdemo/widgetdemo.lpi b/examples/gui/widgetdemo/widgetdemo.lpi new file mode 100644 index 00000000..54798ccc --- /dev/null +++ b/examples/gui/widgetdemo/widgetdemo.lpi @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/gui/widgetdemo/widgetdemo.lpr b/examples/gui/widgetdemo/widgetdemo.lpr new file mode 100644 index 00000000..0dc8d206 --- /dev/null +++ b/examples/gui/widgetdemo/widgetdemo.lpr @@ -0,0 +1,354 @@ +{ + A proof of concept demo to see if we could duplicate one of Qt4's demos. +} + +program WidgetDemo; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes + ,SysUtils + ,fpGFX + ,fpGUI + ,StyleManager + ; + +type + + { TWidgetDemoForm } + + TWidgetDemoForm = class(TFForm) + topLayout: TFBoxLayout; + mainLayout: TFGridLayout; + MainMenu: TFMenuBar; + + topStyleComboLayout: TFBoxLayout; + lblStyle: TFLabel; + cbStyle: TFComboBox; + + topCheckboxLayout: TFBoxLayout; + chkStdPalette: TFCheckBox; + chkDisable: TFCheckBox; + + topLeftGroupBox: TFGroupBox; + topLeftGroupBoxLayout: TFBoxLayout; + Radio1: TFRadioButton; + Radio2: TFRadioButton; + Radio3: TFRadioButton; + + topRightGroupBox: TFGroupBox; + topRightGroupBoxLayout: TFBoxLayout; + Button1: TFButton; + Button2: TFButton; + + StringGrid: TFStringGrid; + + bottomRightGroupBox: TFGroupBox; + bottomRightGroupBoxLayout: TFBoxLayout; + Edit1: TFEdit; + Edit2: TFEdit; + + bottomButtonLayout: TFBoxLayout; + btnExit: TFButton; + btnHelp: TFButton; + + procedure btnExitClick(Sender: TObject); + procedure Radio1Click(Sender: TObject); + procedure Radio2Click(Sender: TObject); + procedure cbStyleChanged(Sender: TObject); + procedure TranslateToAfrikaans; + procedure TranslateToEnglish; + procedure chkDisableClick(Sender: TObject); + private + procedure CreateTopMenu; + procedure CreateStyleCombo; + procedure CreateTopCheckboxLine; + procedure CreateTopLeftGroupBox; + procedure CreateTopRightGroupBox; + procedure CreateBottomLeftStringGrid; + procedure CreateBottomRightGroupBox; + procedure CreateBottomButtonLayout; + public + constructor Create(AOwner: TComponent); override; + end; + + +{ TWidgetDemoForm } + +procedure TWidgetDemoForm.btnExitClick(Sender: TObject); +begin + Close; +end; + +procedure TWidgetDemoForm.Radio1Click(Sender: TObject); +begin + TranslateToEnglish; +end; + +procedure TWidgetDemoForm.Radio2Click(Sender: TObject); +begin + TranslateToAfrikaans; +end; + +procedure TWidgetDemoForm.cbStyleChanged(Sender: TObject); +begin + { I want to try something later with this } +// gStyleManager.SetStyle(cbStyle.Text); + if cbStyle.Text <> cDefaultStyle then + Style.Free; + Style := gStyleManager.CreateInstance(cbStyle.Text); + Redraw; +end; + +procedure TWidgetDemoForm.TranslateToAfrikaans; +begin + Text := 'Widget Demo - Afrikaans'; + lblStyle.Text := 'Venster Steil:'; + chkStdPalette.Text := 'Standaard kleur tablette'; + chkDisable.Text := 'Ge-deaktiveerde controles'; + topLeftGroupBox.Text := 'Groep Boks Een'; + Radio1.Text := 'Radio knoppie een'; + Radio2.Text := 'Radio knoppie twee'; + Radio3.Text := 'Radio knoppie drie'; + topLeftGroupBox.Text := 'Groep Boks Twee'; + Button1.Text := 'Normal Button'; + Button2.Text := 'Embedded Button'; + bottomRightGroupBox.Text := 'Group Boks Drie'; + Edit1.Text := 'Normale teks'; + Edit2.Text := 'Wagwoord teks'; + btnExit.Text := 'Verlaat Verlaat'; + btnHelp.Text := 'Hulp'; + Redraw; +end; + +procedure TWidgetDemoForm.TranslateToEnglish; +begin + Text := 'Widget Demo - English'; + lblStyle.Text := 'Style:'; + chkStdPalette.Text := 'Standard color palette'; + chkDisable.Text := 'Disable widgets'; + topLeftGroupBox.Text := 'Group Box 1'; + Radio1.Text := 'Radio button 1'; + Radio2.Text := 'Radio button 2'; + Radio3.Text := 'Radio button 3'; + topRightGroupBox.Text := 'Group Box 2'; + Button1.Text := 'Normal Button'; + Button2.Text := 'Embedded Button'; + bottomRightGroupBox.Text := 'Group Box 3'; + Edit1.Text := 'Normal Edit'; + Edit2.Text := 'Password Edit'; + btnExit.Text := 'Exit'; + btnHelp.Text := 'Help'; + Redraw; +end; + +procedure TWidgetDemoForm.chkDisableClick(Sender: TObject); +begin + lblStyle.Enabled := not chkDisable.Checked; + cbStyle.Enabled := not chkDisable.Checked; + chkStdPalette.Enabled := not chkDisable.Checked; + topLeftGroupBox.Enabled := not chkDisable.Checked; + topRightGroupBox.Enabled := not chkDisable.Checked; + StringGrid.Enabled := not chkDisable.Checked; + bottomRightGroupBox.Enabled := not chkDisable.Checked; +end; + +procedure TWidgetDemoForm.CreateTopMenu; +var + mi: TFMenuItem; +begin + MainMenu := TFMenuBar.Create(self); + mi := MainMenu.AddMenu('File'); + mi.SubMenu.AddMenu('Exit', '', @btnExitClick); + MainMenu.AddMenu('Edit'); + MainMenu.AddMenu('Options'); + MainMenu.AddMenu('Windows'); + MainMenu.AddMenu('Help'); +// MainMenu.CanExpandWidth := True; +end; + +procedure TWidgetDemoForm.CreateStyleCombo; +begin + topStyleComboLayout := TFBoxLayout.Create(self); + + lblStyle := TFLabel.Create('Style:', self); + + cbStyle := TFComboBox.Create(self); + cbStyle.CanExpandWidth := True; + gStyleManager.AssignStyleTypes(cbStyle.Items); + cbStyle.OnChange := @cbStyleChanged; + cbStyle.ItemIndex := 0; + + topStyleComboLayout.InsertChild(lblStyle); + topStyleComboLayout.InsertChild(cbStyle); +end; + +procedure TWidgetDemoForm.CreateTopCheckboxLine; +begin + topCheckboxLayout := TFBoxLayout.Create(self); + + chkStdPalette := TFCheckBox.Create('Standard color palette', self); + chkStdPalette.CanExpandWidth := True; + chkStdPalette.Checked := True; + + chkDisable := TFCheckBox.Create('Disable widgets', self); + chkDisable.OnClick := @chkDisableClick; + + topCheckboxLayout.InsertChild(chkStdPalette); + topCheckboxLayout.InsertChild(chkDisable); +end; + +procedure TWidgetDemoForm.CreateTopLeftGroupBox; +begin + topLeftGroupBox := TFGroupBox.Create('Group Box 1', self); + topLeftGroupBox.CanExpandWidth := True; + + topLeftGroupBoxLayout := TFBoxLayout.Create(self); + topLeftGroupBoxLayout.Orientation := Vertical; + + Radio1 := TFRadioButton.Create('Radio button 1', self); + Radio1.Checked := True; + Radio1.CanExpandWidth := True; + Radio1.OnClick := @Radio1Click; + + Radio2 := TFRadioButton.Create('Radio button 2', self); + Radio2.CanExpandWidth := True; + Radio2.OnClick := @Radio2Click; + + Radio3 := TFRadioButton.Create('Radio button 3', self); + Radio3.CanExpandWidth := True; + + topLeftGroupBox.InsertChild(topLeftGroupBoxLayout); + topLeftGroupBoxLayout.InsertChild(Radio1); + topLeftGroupBoxLayout.InsertChild(Radio2); + topLeftGroupBoxLayout.InsertChild(Radio3); +end; + +procedure TWidgetDemoForm.CreateTopRightGroupBox; +begin + topRightGroupBox := TFGroupBox.Create('Group Box 2', self); + topRightGroupBox.CanExpandWidth := True; + topRightGroupBox.CanExpandHeight := True; + + topRightGroupBoxLayout := TFBoxLayout.Create(self); + topRightGroupBoxLayout.Orientation := Vertical; + topRightGroupBoxLayout.VertAlign := vertCenter; + topRightGroupBoxLayout.Spacing := 8; + + Button1 := TFButton.Create('Normal Button', self); + Button1.CanExpandWidth := True; + + Button2 := TFButton.Create('Embedded Button', self); + Button2.CanExpandWidth := True; + Button2.Embedded := True; + + topRightGroupBox.InsertChild(topRightGroupBoxLayout); + topRightGroupBoxLayout.InsertChild(Button1); + topRightGroupBoxLayout.InsertChild(Button2); +end; + +procedure TWidgetDemoForm.CreateBottomLeftStringGrid; +var + x, y: integer; +begin + StringGrid := TFStringGrid.Create(self); + StringGrid.ColCount := 10; + StringGrid.RowCount := 15; + for y := 0 to StringGrid.RowCount - 1 do + for x := 0 to StringGrid.ColCount - 1 do + StringGrid.Cells[x, y] := Format('%d, %d', [x, y]); +end; + +procedure TWidgetDemoForm.CreateBottomRightGroupBox; +begin + bottomRightGroupBox := TFGroupBox.Create('Group Box 3', self); + bottomRightGroupBox.CanExpandHeight := True; + bottomRightGroupBox.CanExpandWidth := True; + + bottomRightGroupBoxLayout := TFBoxLayout.Create(self); + bottomRightGroupBoxLayout.Orientation := Vertical; + + Edit1 := TFEdit.Create('Normal Edit', self); + Edit2 := TFEdit.Create('Password Edit', self); + Edit2.PasswordChar := '*'; + + bottomRightGroupBox.InsertChild(bottomRightGroupBoxLayout); + bottomRightGroupBoxLayout.InsertChild(Edit1); + bottomRightGroupBoxLayout.InsertChild(Edit2); +end; + +procedure TWidgetDemoForm.CreateBottomButtonLayout; +begin + bottomButtonLayout := TFBoxLayout.Create(self); + bottomButtonLayout.HorzAlign := horzRight; + + btnHelp := TFButton.Create('Help', self); + + btnExit := TFButton.Create('Exit', self); + btnExit.OnClick := @btnExitClick; + + bottomButtonLayout.InsertChild(btnHelp); + bottomButtonLayout.InsertChild(btnExit); +end; + +constructor TWidgetDemoForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Text := 'Widget Demo'; + BorderWidth := 8; +// WindowType := wtWindow; + + topLayout := TFBoxLayout.Create(self); + topLayout.Orientation := Vertical; + mainLayout := TFGridLayout.Create(self); + mainLayout.RowCount := 2; + + CreateTopMenu; + topLayout.InsertChild(MainMenu); + + CreateStyleCombo; + topLayout.InsertChild(topStyleComboLayout); + + CreateTopCheckboxLine; + topLayout.InsertChild(topCheckboxLayout); + + CreateTopLeftGroupBox; + mainLayout.AddWidget(topLeftGroupBox, 0, 0, 1, 1); + + CreateTopRightGroupBox; + mainLayout.AddWidget(topRightGroupBox, 1, 0, 1, 1); + + CreateBottomLeftStringGrid; + mainLayout.AddWidget(StringGrid, 0, 1, 1, 1); + + CreateBottomRightGroupBox; + mainLayout.AddWidget(bottomRightGroupBox, 1, 1, 1, 1); + + topLayout.InsertChild(mainLayout); + + CreateBottomButtonLayout; + topLayout.InsertChild(bottomButtonLayout); + + Child := topLayout; +end; + + +var + WidgetDemoForm: TWidgetDemoForm; + +begin + GFApplication.Initialize; + + WidgetDemoForm := TWidgetDemoForm.Create(GFApplication); + try + WidgetDemoForm.Show; + GFApplication.Run; + finally + WidgetDemoForm.Free; + end; +end. + -- cgit v1.2.3-70-g09d2