summaryrefslogtreecommitdiff
path: root/examples/gui/customstyles
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2011-05-06 12:34:36 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2011-05-06 12:34:36 +0200
commitc3b41ed772ef91730a8dc89a2c287da0a86fba46 (patch)
treeb1b3bef927b71b01d6e59c906223013af38877dd /examples/gui/customstyles
parentfd4beb39fb820c34a51663f87376b78bb825c310 (diff)
downloadfpGUI-c3b41ed772ef91730a8dc89a2c287da0a86fba46.tar.xz
The style must be instantiated before we create forms.
The old behaviour caused problems with menus. A better solution must be found soon though - including getting rid of the fpgStyle variable. I also updated the instructions in the custom style unit for the demo.
Diffstat (limited to 'examples/gui/customstyles')
-rw-r--r--examples/gui/customstyles/customstyles.lpr12
-rw-r--r--examples/gui/customstyles/mystyle.pas22
2 files changed, 18 insertions, 16 deletions
diff --git a/examples/gui/customstyles/customstyles.lpr b/examples/gui/customstyles/customstyles.lpr
index 5da13e0f..419e6456 100644
--- a/examples/gui/customstyles/customstyles.lpr
+++ b/examples/gui/customstyles/customstyles.lpr
@@ -48,13 +48,15 @@ var
frm: TTestForm;
begin
fpgApplication.Initialize;
+
+ { Set our new style as the default (before we create any forms), unless
+ a the end-user specified a different style via the command line. }
+ if not gCommandLineParams.IsParam('style') then
+ if fpgStyleManager.SetStyle('Demo Style') then
+ fpgStyle := fpgStyleManager.Style;
+
frm := TTestForm.Create(nil);
try
- { Lets set a new default style if no style was specified in the command line }
- if not gCommandLineParams.IsParam('style') then
- if fpgStyleManager.SetStyle('Demo Style') then
- fpgStyle := fpgStyleManager.Style;
-
frm.Show;
fpgApplication.Run;
finally
diff --git a/examples/gui/customstyles/mystyle.pas b/examples/gui/customstyles/mystyle.pas
index 3e9c2992..8db9f2b4 100644
--- a/examples/gui/customstyles/mystyle.pas
+++ b/examples/gui/customstyles/mystyle.pas
@@ -2,9 +2,10 @@
A very quick and basic style implementation. It took all of 10 minutes.
To apply this style, follow these instructions:
- * free the old fpgStyle
- * instantiate the new style class
- * and assign this new instance to fpgStyle variable
+ 1) (optional) Check if a style was specified via a command line parameter
+ 2) If (1) was false, set the new default which will instantiate the new
+ style class and automatically free the old one.
+ 3) Assign our new style instance to the fpgStyle variable
Example:
@@ -14,14 +15,15 @@
frm: TMainForm;
begin
fpgApplication.Initialize;
+
+ { Set our new style as the default (before we create any forms), unless
+ a the end-user specified a different style via the command line. }
+ if not gCommandLineParams.IsParam('style') then
+ if fpgStyleManager.SetStyle('Demo Style') then
+ fpgStyle := fpgStyleManager.Style;
+
frm := TMainForm.Create(nil);
try
- // Free the old and set the new style
- if Assigned(fpgStyle) then
- fpgStyle.Free;
- fpgStyle := TMyStyle.Create;
-
- // now continue with the application
frm.Show;
fpgApplication.Run;
finally
@@ -41,8 +43,6 @@ uses
type
- { TMyStyle }
-
TMyStyle = class(TfpgStyle)
public
constructor Create; override;