diff options
author | sekelsenmat <sekelsenmat@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-12 21:36:57 +0000 |
---|---|---|
committer | sekelsenmat <sekelsenmat@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-12 21:36:57 +0000 |
commit | 472fef946bd1a41845ee2e471cb42e895ead77b6 (patch) | |
tree | e5031b566ec5f6becdfbca6061347c5660240e2e /prototypes | |
parent | 4f9b7999b021cf25e1e85751505df7f2a0daaa6c (diff) | |
download | fpGUI-472fef946bd1a41845ee2e471cb42e895ead77b6.tar.xz |
Added TFEdit to newmultihandle
Diffstat (limited to 'prototypes')
-rw-r--r-- | prototypes/newmultihandle/examples/helloworld.lpi | 7 | ||||
-rw-r--r-- | prototypes/newmultihandle/examples/helloworld.lpr | 13 | ||||
-rw-r--r-- | prototypes/newmultihandle/fpgui.pas | 2 | ||||
-rw-r--r-- | prototypes/newmultihandle/fpguipackage.lpk | 11 | ||||
-rw-r--r-- | prototypes/newmultihandle/gui_button.inc | 41 | ||||
-rw-r--r-- | prototypes/newmultihandle/gui_edit.inc | 90 | ||||
-rw-r--r-- | prototypes/newmultihandle/gui_style.inc | 13 |
7 files changed, 151 insertions, 26 deletions
diff --git a/prototypes/newmultihandle/examples/helloworld.lpi b/prototypes/newmultihandle/examples/helloworld.lpi index 6cc38a28..779ed512 100644 --- a/prototypes/newmultihandle/examples/helloworld.lpi +++ b/prototypes/newmultihandle/examples/helloworld.lpi @@ -1,12 +1,12 @@ <?xml version="1.0"?> <CONFIG> <ProjectOptions> - <PathDelim Value="/"/> + <PathDelim Value="\"/> <Version Value="5"/> <General> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> - <IconPath Value="./"/> + <IconPath Value=".\"/> <TargetFileExt Value=".exe"/> </General> <VersionInfo> @@ -20,7 +20,7 @@ <RunParams> <local> <FormatVersion Value="1"/> - <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> + <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/> </local> </RunParams> <RequiredPackages Count="2"> @@ -41,6 +41,7 @@ </ProjectOptions> <CompilerOptions> <Version Value="5"/> + <PathDelim Value="\"/> <CodeGeneration> <Generate Value="Faster"/> </CodeGeneration> diff --git a/prototypes/newmultihandle/examples/helloworld.lpr b/prototypes/newmultihandle/examples/helloworld.lpr index 398ea421..ab364d59 100644 --- a/prototypes/newmultihandle/examples/helloworld.lpr +++ b/prototypes/newmultihandle/examples/helloworld.lpr @@ -12,6 +12,7 @@ type TMainForm = class(TFWidget) private btnHello: TFButton; + txtEdit: TFEdit; procedure FormPaint(Sender: TObject); public constructor Create(AParent: TFCustomWindow); override; @@ -63,8 +64,8 @@ var lSize: TSize; lPoint: TPoint; begin - inherited AfterConstruction; + // BorderWidth := 8; // Text := 'fpGUI Application'; @@ -78,6 +79,16 @@ begin btnHello.SetPosition(lPoint); btnHello.Show; + { create the edit } + txtEdit := TFEdit.Create(self); + lSize.cx := 100; + lSize.cy := 25; + txtEdit.SetClientSize(lSize); + lPoint.x := 25; + lPoint.y := 100; + txtEdit.SetPosition(lPoint); + txtEdit.Show; + { set a min and max size } lSize.cx := 200; lSize.cy := 300; diff --git a/prototypes/newmultihandle/fpgui.pas b/prototypes/newmultihandle/fpgui.pas index f94904dc..9649e21e 100644 --- a/prototypes/newmultihandle/fpgui.pas +++ b/prototypes/newmultihandle/fpgui.pas @@ -15,6 +15,7 @@ uses { Primary widgets includes } {$include gui_button.inc} +{$include gui_edit.inc} var { Default Styles } @@ -32,6 +33,7 @@ implementation { Primary widgets includes } {$include gui_button.inc} +{$include gui_edit.inc} initialization { Default Styles } diff --git a/prototypes/newmultihandle/fpguipackage.lpk b/prototypes/newmultihandle/fpguipackage.lpk index b7c0eb0b..19788333 100644 --- a/prototypes/newmultihandle/fpguipackage.lpk +++ b/prototypes/newmultihandle/fpguipackage.lpk @@ -1,11 +1,13 @@ <?xml version="1.0"?> <CONFIG> <Package Version="2"> + <PathDelim Value="\"/> <Name Value="fpguipackage"/> <CompilerOptions> <Version Value="5"/> + <PathDelim Value="\"/> <SearchPaths> - <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> </SearchPaths> <CodeGeneration> <Generate Value="Faster"/> @@ -14,7 +16,7 @@ <CompilerPath Value="$(CompPath)"/> </Other> </CompilerOptions> - <Files Count="4"> + <Files Count="5"> <Item1> <Filename Value="fpgui.pas"/> <UnitName Value="fpgui"/> @@ -31,6 +33,10 @@ <Filename Value="gui_style.inc"/> <Type Value="Include"/> </Item4> + <Item5> + <Filename Value="gui_edit.inc"/> + <Type Value="Include"/> + </Item5> </Files> <Type Value="RunAndDesignTime"/> <RequiredPkgs Count="2"> @@ -47,6 +53,7 @@ </UsageOptions> <PublishOptions> <Version Value="2"/> + <DestinationDirectory Value="$(TestDir)\publishedpackage\"/> <IgnoreBinaries Value="False"/> </PublishOptions> </Package> diff --git a/prototypes/newmultihandle/gui_button.inc b/prototypes/newmultihandle/gui_button.inc index b70c5795..2c619b9b 100644 --- a/prototypes/newmultihandle/gui_button.inc +++ b/prototypes/newmultihandle/gui_button.inc @@ -9,10 +9,9 @@ type TFButton = class(TFWidget) private FIsPressed: Boolean; - public - Text: string; - constructor Create(AParent: TFCustomWindow); override; - constructor Create(ACaption: string; AParent: TFCustomWindow); + FText: string; + procedure SetText(const AValue: string); + protected procedure EvFocusIn; override; procedure EvFocusOut; override; procedure EvKeyPressed(AKey: Word); override; @@ -22,6 +21,12 @@ type procedure EvMousePressed(AButton: TMouseButton; const AMousePos: TPoint); override; procedure EvMouseReleased(AButton: TMouseButton; const AMousePos: TPoint); override; procedure EvPaint; override; + public + { Constructors and Destructors } + constructor Create(AParent: TFCustomWindow); override; + constructor Create(ACaption: string; AParent: TFCustomWindow); + { Properties } + property Text: string read FText write SetText; end; @@ -31,6 +36,8 @@ constructor TFButton.Create(AParent: TFCustomWindow); begin inherited Create(AParent); + FDrawBackground := False; + SetClientSize(Size(100, 50)); end; @@ -38,11 +45,16 @@ constructor TFButton.Create(ACaption: string; AParent: TFCustomWindow); begin Create(AParent); - FDrawBackground := False; - Text := ACaption; end; +procedure TFButton.SetText(const AValue: string); +begin + FText := AValue; + + Invalidate; +end; + procedure TFButton.EvFocusIn; begin inherited EvFocusIn; @@ -103,16 +115,8 @@ end; procedure TFButton.EvPaint; var - rt: TRect; Flags: TFButtonFlags; begin - WriteLn('Paint event'); - - rt.Left := 0; - rt.Top := 0; - rt.Right := Width; - rt.Bottom := Height; - { Prepare the flags } Flags := []; @@ -120,15 +124,12 @@ begin if FIsPressed then Include(Flags, fbfIsPressed); -{ if FFocused and (not FEmbedded) then - Include(lBtnFlags, btnHasFocus); - - if FEmbedded then - Include(lBtnFlags, btnIsEmbedded); } +{ if FFocused then + Include(lBtnFlags, btnHasFocus); } { Draw the button } - GFDefaultStyle.DrawButtonFace(Canvas, rt, Flags); + GFDefaultStyle.DrawButtonFace(Canvas, Bounds(0, 0, Width, Height), Flags); inherited EvPaint(); end; diff --git a/prototypes/newmultihandle/gui_edit.inc b/prototypes/newmultihandle/gui_edit.inc new file mode 100644 index 00000000..ab23f13d --- /dev/null +++ b/prototypes/newmultihandle/gui_edit.inc @@ -0,0 +1,90 @@ +{%mainunit fpgui.pas}
+
+{$ifndef READ_IMPLEMENTATION}
+
+type
+
+ { TFEdit }
+
+ TFEdit = class(TFWidget)
+ private
+ FText: String;
+ procedure SetText(const AValue: String);
+ protected
+ procedure EvFocusIn; override;
+ procedure EvFocusOut; override;
+ procedure EvKeyPressed(AKey: Word); override;
+ procedure EvKeyReleased(AKey: Word); override;
+ procedure EvMousePressed(AButton: TMouseButton; const AMousePos: TPoint); override;
+ procedure EvMouseReleased(AButton: TMouseButton; const AMousePos: TPoint); override;
+ procedure EvPaint; override;
+ public
+ { Constructors and Destructors }
+ constructor Create(AParent: TFCustomWindow); override;
+ { Properties }
+ property Text: String read FText write SetText;
+ end;
+
+
+{$else}
+
+constructor TFEdit.Create(AParent: TFCustomWindow);
+begin
+ inherited Create(AParent);
+
+ FDrawBackground := False;
+
+ SetClientSize(Size(100, 50));
+end;
+
+procedure TFEdit.SetText(const AValue: String);
+begin
+ if FText = AValue then exit;
+
+ FText := AValue;
+
+ Invalidate;
+end;
+
+procedure TFEdit.EvFocusIn;
+begin
+ inherited EvFocusIn;
+end;
+
+procedure TFEdit.EvFocusOut;
+begin
+ inherited EvFocusOut;
+end;
+
+procedure TFEdit.EvKeyPressed(AKey: Word);
+begin
+ inherited EvKeyPressed(AKey);
+end;
+
+procedure TFEdit.EvKeyReleased(AKey: Word);
+begin
+ inherited EvKeyReleased(AKey);
+end;
+
+procedure TFEdit.EvMousePressed(AButton: TMouseButton; const AMousePos: TPoint);
+begin
+ inherited EvMousePressed(AButton, AMousePos);
+end;
+
+procedure TFEdit.EvMouseReleased(AButton: TMouseButton;
+ const AMousePos: TPoint);
+begin
+ inherited EvMouseReleased(AButton, AMousePos);
+end;
+
+procedure TFEdit.EvPaint;
+begin
+ { Draw the edit }
+
+ GFDefaultStyle.DrawEdit(Canvas, Bounds(0, 0, Width, Height));
+
+ inherited EvPaint();
+end;
+
+{$endif}
+
diff --git a/prototypes/newmultihandle/gui_style.inc b/prototypes/newmultihandle/gui_style.inc index 84d3224e..f6aa7de1 100644 --- a/prototypes/newmultihandle/gui_style.inc +++ b/prototypes/newmultihandle/gui_style.inc @@ -15,6 +15,7 @@ type procedure DrawButtonFace(ACanvas: TFCustomCanvas; ARect: TRect; AFlags: TFButtonFlags); virtual;
procedure DrawControlFrame(ACanvas: TFCustomCanvas; ARect: TRect); virtual;
procedure DrawDirectionArrow(ACanvas: TFCustomCanvas; ARect: TRect; direction: Integer); virtual;
+ procedure DrawEdit(ACanvas: TFCustomCanvas; ARect: TRect); virtual;
end;
const
@@ -22,6 +23,7 @@ const colShadow2: TGfxColor = (Red: $40; Green: $40; Blue: $40; Alpha: $00);
colHilite1: TGfxColor = (Red: $E0; Green: $E0; Blue: $E0; Alpha: $00);
colHilite2: TGfxColor = (Red: $FF; Green: $FF; Blue: $FF; Alpha: $00);
+ colGrayBlue: TGfxColor = (Red: $7F; Green: $9D; Blue: $B9; Alpha: $00);
{$else}
@@ -86,5 +88,16 @@ procedure TFStyle.DrawDirectionArrow(ACanvas: TFCustomCanvas; ARect: TRect; dire begin
end;
+procedure TFStyle.DrawEdit(ACanvas: TFCustomCanvas; ARect: TRect);
+begin
+ { Inner area }
+ ACanvas.SetColor(colWhite);
+ ACanvas.FillRect(ARect);
+
+ { Outer border }
+ ACanvas.SetColor(colGrayBlue);
+ ACanvas.DrawRect(ARect);
+end;
+
{$endif}
|