summaryrefslogtreecommitdiff
path: root/prototypes
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2011-05-04 00:07:10 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2011-05-04 00:07:10 +0200
commit67e5bdb85a805c6d5a67e843534f8f15826b959e (patch)
tree16ad219cd3df994b45216bdfcbe4c784e4b90d5e /prototypes
parent9492ed66c005af908a015a154ddba64677e792ec (diff)
downloadfpGUI-67e5bdb85a805c6d5a67e843534f8f15826b959e.tar.xz
more work on the prototype style test project.
These changes allows us to test the DrawControl(ecPushButtonLabel, ...) implementation. Either way, the fpg_style.pas unit is still crap anyway.
Diffstat (limited to 'prototypes')
-rw-r--r--prototypes/fpgui2/tests/themetest.lpi15
-rw-r--r--prototypes/fpgui2/tests/themetest.lpr65
2 files changed, 73 insertions, 7 deletions
diff --git a/prototypes/fpgui2/tests/themetest.lpi b/prototypes/fpgui2/tests/themetest.lpi
index 3af53c03..9bc2a87d 100644
--- a/prototypes/fpgui2/tests/themetest.lpi
+++ b/prototypes/fpgui2/tests/themetest.lpi
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
+ <Version Value="9"/>
<PathDelim Value="\"/>
- <Version Value="7"/>
<General>
<Flags>
<SaveOnlyProjectUnits Value="True"/>
@@ -10,11 +10,13 @@
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
- <TargetFileExt Value=""/>
</General>
<VersionInfo>
- <ProjectVersion Value=""/>
+ <StringTable ProductVersion=""/>
</VersionInfo>
+ <BuildModes Count="1">
+ <Item1 Name="default" Default="True"/>
+ </BuildModes>
<PublishOptions>
<Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
@@ -40,8 +42,13 @@
</Units>
</ProjectOptions>
<CompilerOptions>
- <Version Value="8"/>
+ <Version Value="9"/>
<PathDelim Value="\"/>
+ <Parsing>
+ <SyntaxOptions>
+ <UseAnsiStrings Value="False"/>
+ </SyntaxOptions>
+ </Parsing>
<Other>
<CustomOptions Value="-FUunits"/>
<CompilerPath Value="$(CompPath)"/>
diff --git a/prototypes/fpgui2/tests/themetest.lpr b/prototypes/fpgui2/tests/themetest.lpr
index 3a7a300b..1270f303 100644
--- a/prototypes/fpgui2/tests/themetest.lpr
+++ b/prototypes/fpgui2/tests/themetest.lpr
@@ -23,7 +23,7 @@ uses
type
{ Note:
I am only creating new classes to test my drawing routines in HandlePaint.
- The final themeing will be done inside the TfpgXXXX classes. }
+ The final themeing will be done inside the standard gui TfpgXXXX classes. }
{ Concept theme button }
TThemeButton = class(TfpgButton)
@@ -84,8 +84,7 @@ type
end;
- { TStyledButton }
-
+ { A button using the TfpgCommonStyle descendants }
TStyledButton = class(TfpgButton)
private
FStyle: TfpgBaseStyle;
@@ -128,12 +127,20 @@ type
procedure TStyledButton.HandlePaint;
var
buttonoptions: TfpgButtonStyleOption;
+ tx, ty, ix, iy: integer;
+ offset: integer;
+ img: TfpgImage;
+ r: TfpgRect;
+ lTextFlags: TFTextFlags;
begin
+ writeln('TStyledButton.HandlePaint');
Canvas.BeginDraw;
Canvas.Clear(clButtonFace);
Canvas.ClearClipRect;
+ lTextFlags := [];
+
// Setup all button options that we need
buttonoptions := TfpgButtonStyleOption.Create;
buttonoptions.Rect.SetRect(0, 0, Width, Height);
@@ -162,6 +169,58 @@ begin
FStyle.DrawControl(cePushButtonBevel, buttonoptions, Canvas, self);
FStyle.DrawPrimitive(peFocusRectangle, buttonoptions, Canvas, self);
+ if FDown then
+ offset := 1
+ else
+ offset := 0;
+ CalculatePositions(ix, iy, tx, ty);
+
+ if ShowImage and Assigned(FImage) then
+ begin
+ if Enabled then
+ Canvas.DrawImage(ix+offset, iy+offset, FImage)
+ else
+ begin
+ img := FImage.CreateDisabledImage;
+ Canvas.DrawImage(ix+offset, iy+offset, img);
+ img.Free;
+ end;
+ end;
+
+ { EXPERIMENTAL: multi-line button text
+ Only in this condition do we support multi-line text }
+ if AllowMultiLineText and (ImageLayout = ilImageLeft) then
+ begin
+ r := buttonoptions.Rect;
+ InflateRect(r, -3, -3); { same as focus rectangle }
+ if ShowImage and Assigned(FImage) then
+ begin
+ ix := ImageMargin + FImage.Width;
+ if ImageSpacing > 0 then
+ ix += ImageSpacing;
+ OffsetRect(r, ix, 0);
+ r.Width -= ix;
+ end;
+
+ if FDown then
+ OffsetRect(r, offset, offset);
+
+ lTextFlags := [txtHCenter, txtVCenter{, txtWrap}];
+ if not Enabled then
+ lTextFlags += [txtDisabled];
+
+// Canvas.DrawText(r, Text, lTextFlags);
+ buttonoptions.Rect := r;
+ end
+ else
+ begin
+ buttonoptions.Rect.Left := tx+offset;
+ buttonoptions.Rect.Top := ty+offset;
+// fpgStyle.DrawString(Canvas, tx+pofs, ty+pofs, Text, Enabled);
+ end;
+
+ FStyle.DrawControl(cePushButtonLabel, buttonoptions, Canvas, self);
+
buttonoptions.Free;
Canvas.EndDraw;
end;