diff options
author | Graeme Geldenhuys <graemeg@users.sourceforge.net> | 2007-05-01 18:20:12 +0000 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@users.sourceforge.net> | 2007-05-01 18:20:12 +0000 |
commit | ca38402b7cecfb29523181c100d429772bb25e00 (patch) | |
tree | ddc4ea959f60b3c59232e17ba9a7285afc8dc719 /gui | |
parent | 55825e0ebbe83c960478600f37858fdb8df2cf82 (diff) | |
download | fpGUI-ca38402b7cecfb29523181c100d429772bb25e00.tar.xz |
* GUI: Implemented a very basic ShowMessag() function.
This is still work in progress!
* GUI: Implemented TFBoxLayout.RemoveChild
* GFX/X11: Fixed a issue with the TextExtent where the
lower curl of the character g will get clipped
* GUI: Implemented a basic TDBLabel component
* GUI Demos: Implemented a basic DB Test example. This is
still work in progress and only tested under Linux.
* GFX: Minor AMD64 fix for the unitxft.pas unit
Diffstat (limited to 'gui')
-rw-r--r-- | gui/db/fpgui_db.pas | 82 | ||||
-rw-r--r-- | gui/fpgui.pas | 21 | ||||
-rw-r--r-- | gui/fpguidialogs.inc | 115 | ||||
-rw-r--r-- | gui/fpguiform.inc | 3 | ||||
-rw-r--r-- | gui/fpguilabel.inc | 22 | ||||
-rw-r--r-- | gui/fpguilayouts.inc | 17 | ||||
-rw-r--r-- | gui/fpguipackage.lpk | 9 | ||||
-rw-r--r-- | gui/fpguipackage.pas | 2 |
8 files changed, 170 insertions, 101 deletions
diff --git a/gui/db/fpgui_db.pas b/gui/db/fpgui_db.pas index 4be0aff2..c67bc3a2 100644 --- a/gui/db/fpgui_db.pas +++ b/gui/db/fpgui_db.pas @@ -3,7 +3,7 @@ Database support classes - Copyright (C) 2000 - 2006 See the file AUTHORS.txt, included in this + Copyright (C) 2000 - 2007 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -17,57 +17,67 @@ unit fpGUI_DB; {$IFDEF Debug} -{$ASSERTIONS On} + {$ASSERTIONS On} {$ENDIF} interface -uses Classes, fpGUI, DB; +uses + Classes + ,fpGUI + ,DB + ; type + TFieldDataLink = class(TDataLink) private - FWidget: TWidget; + FWidget: TFWidget; FField: TField; FFieldName: String; FOnDataChange: TNotifyEvent; - procedure SetFieldName(const AFieldName: String); - procedure UpdateField; + procedure SetFieldName(const AFieldName: String); + procedure UpdateField; protected - procedure ActiveChanged; override; - procedure RecordChanged(AField: TField); override; + procedure ActiveChanged; override; + procedure RecordChanged(AField: TField); override; public - constructor Create(AWidget: TWidget); - property Field: TField read FField; - property FieldName: String read FFieldName write SetFieldName; - property OnDataChange: TNotifyEvent read FOnDataChange write FOnDataChange; + constructor Create(AWidget: TFWidget); + property Field: TField read FField; + property FieldName: String read FFieldName write SetFieldName; + property OnDataChange: TNotifyEvent read FOnDataChange write FOnDataChange; end; + TDBText = class(TFCustomLabel) private FDataLink: TFieldDataLink; - function GetDataField: String; - procedure SetDataField(const ADataField: String); - function GetDataSource: TDataSource; - procedure SetDataSource(ADataSource: TDataSource); - procedure DataChange(Sender: TObject); + function GetDataField: String; + procedure SetDataField(const ADataField: String); + function GetDataSource: TDataSource; + procedure SetDataSource(ADataSource: TDataSource); + procedure DataChange(Sender: TObject); public constructor Create(AOwner: TComponent); override; - destructor Destroy; override; + destructor Destroy; override; published - property Text; - property DataField: String read GetDataField write SetDataField; - property DataSource: TDataSource read GetDataSource write SetDataSource; + property Alignment default taLeftJustify; + property CanExpandWidth; + property DataField: string read GetDataField write SetDataField; + property DataSource: TDataSource read GetDataSource write SetDataSource; + property Enabled; + property FontColor; + property Text; end; -// =================================================================== -// =================================================================== implementation -constructor TFieldDataLink.Create(AWidget: TWidget); +{ TFieldDataLink } + +constructor TFieldDataLink.Create(AWidget: TFWidget); begin inherited Create; FWidget := AWidget; @@ -95,13 +105,15 @@ end; procedure TFieldDataLink.UpdateField; begin -WriteLn('##############UpdateField. DataSet: ', DataSource.DataSet.ClassName); + {$IFDEF DEBUG} WriteLn('## UpdateField. DataSet: ', DataSource.DataSet.ClassName); {$ENDIF} FField := DataSource.DataSet.FindField(FieldName); if Assigned(OnDataChange) then OnDataChange(Self); end; +{ TDBText } + constructor TDBText.Create(AOwner: TComponent); begin inherited Create(AOwner); @@ -137,28 +149,18 @@ end; procedure TDBText.DataChange(Sender: TObject); begin -Write('TDBText.DataChange'); + {$IFDEF DEBUG} Write('TDBText.DataChange'); {$ENDIF} if Assigned(FDataLink.Field) then begin Text := FDataLink.Field.DisplayText; - WriteLn(' new text: "', Text, '"'); - end else + {$IFDEF DEBUG} WriteLn(' new text: "', Text, '"'); {$ENDIF} + end + else begin Text := ''; - WriteLn('DataLink has no data'); + {$IFDEF DEBUG} WriteLn('DataLink has no data'); {$ENDIF} end; end; - end. - -{ - $Log: fpgui_db.pp,v $ - Revision 1.2 2001/01/17 21:36:26 sg - * Updating fixes - - Revision 1.1 2000/12/23 23:20:16 sg - * First public CVS version... - -} diff --git a/gui/fpgui.pas b/gui/fpgui.pas index 111521b2..285c4c3b 100644 --- a/gui/fpgui.pas +++ b/gui/fpgui.pas @@ -147,11 +147,12 @@ type {$I fpguiprogressbar.inc} -function ClipMinMax(val, min, max: Integer): Integer; //inline; +function ClipMinMax(val, min, max: Integer): Integer; { This will change at a later date! } procedure LoadForm(AForm: TComponent); procedure SaveForm(AForm: TComponent); +procedure ShowMessage(const AMessage: string); implementation @@ -223,6 +224,24 @@ begin BinStream.Free; end; +// graeme: still work in progress (2007-05-01) +procedure ShowMessage(const AMessage: string); +var + frm: TFStandardDialog; +begin + frm := TFStandardDialog.Create(GFApplication); + try + frm.Text := 'ShowMessage'; + frm.Buttons := [mbOk]; +// frm.Buttons := [mbYes, mbNo, mbCancel, mbHelp]; + frm.Message := AMessage; + frm.ShowModal; + finally +// frm.Free; + end +end; + + {$IFDEF LAYOUTTRACES} procedure LAYOUTTRACE(const Position: String; const args: array of const); {$IFDEF TraceEvents} diff --git a/gui/fpguidialogs.inc b/gui/fpguidialogs.inc index b92bcc9b..413b11c3 100644 --- a/gui/fpguidialogs.inc +++ b/gui/fpguidialogs.inc @@ -3,7 +3,7 @@ Dialogs class declarations - Copyright (C) 2000 - 2006 See the file AUTHORS.txt, included in this + Copyright (C) 2000 - 2007 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -19,21 +19,27 @@ {$IFDEF read_interface} + { TFCustomStandardDialog } + TFCustomStandardDialog = class(TFCustomForm) private - procedure StdBtnClicked(Sender: TObject); + function GetMessage: string; + procedure SetMessage(const AValue: string); + procedure StdBtnClicked(Sender: TObject); protected FButtons: TMsgDlgButtons; MainLayout, BtnLayout: TFBoxLayout; Separator: TSeparator; - function ProcessEvent(Event: TEventObj): Boolean; override; - function DistributeEvent(Event: TEventObj): Boolean; override; - procedure CalcSizes; override; - procedure Resized; override; - procedure SeTFButtons(AButtons: TMsgDlgButtons); - property Buttons: TMsgDlgButtons read FButtons write SeTFButtons default [mbOk, mbCancel]; + FMessage: TFLabel; + function ProcessEvent(Event: TEventObj): Boolean; override; + function DistributeEvent(Event: TEventObj): Boolean; override; + procedure CalcSizes; override; + procedure Resized; override; + procedure SetButtons(AButtons: TMsgDlgButtons); + property Buttons: TMsgDlgButtons read FButtons write SetButtons default [mbOk, mbCancel]; public constructor Create(AOwner: TComponent); override; + property Message: string read GetMessage write SetMessage; end; @@ -43,6 +49,8 @@ property OnCreate; property Buttons; end; + + {$ENDIF read_interface} @@ -59,16 +67,6 @@ // public methods constructor TFCustomStandardDialog.Create(AOwner: TComponent); - - function AddBtn(const AText: String; ADefault: Boolean): TFButton; - begin - Result := TFButton.Create(Self); - Result.Text := AText; - // Result.Default := ADefault; - Result.OnClick := @StdBtnClicked; - Result.Parent := BtnLayout; - end; - begin inherited Create(AOwner); FButtons := [mbOk, mbCancel]; @@ -76,31 +74,23 @@ begin MainLayout := TFBoxLayout.Create(Self); MainLayout.Orientation := Vertical; - MainLayout.SetEmbeddedParent(Self); + Child := MainLayout; + FMessage := TFLabel.Create(self); + FMessage.CanExpandWidth := True; + MainLayout.InsertChild(FMessage); + Separator := TSeparator.Create(Self); - Separator.Parent := MainLayout; + MainLayout.InsertChild(Separator); BtnLayout := TFBoxLayout.Create(Self); BtnLayout.Orientation := Horizontal; BtnLayout.HorzAlign := horzRight; BtnLayout.VertAlign := vertCenter; BtnLayout.CanExpandHeight := False; - BtnLayout.Parent := MainLayout; - - if mbYes in FButtons then AddBtn(mbText_Yes, False); - if mbNo in FButtons then AddBtn(mbText_No, False); - if mbOk in FButtons then AddBtn(mbText_OK, True); - if mbCancel in FButtons then AddBtn(mbText_Cancel, False); - if mbApply in FButtons then AddBtn(mbText_Apply, False); - if mbAbort in FButtons then AddBtn(mbText_Abort, False); - if mbRetry in FButtons then AddBtn(mbText_Retry, False); - if mbIgnore in FButtons then AddBtn(mbText_Ignore, False); - if mbAll in FButtons then AddBtn(mbText_All, False); - if mbNoToAll in FButtons then AddBtn(mbText_NoToAll, False); - if mbYesToAll in FButtons then AddBtn(mbText_YesToAll, False); - if mbHelp in FButtons then AddBtn(mbText_Help, False); + MainLayout.InsertChild(BtnLayout); + SetButtons(FButtons); end; @@ -138,16 +128,65 @@ procedure TFCustomStandardDialog.Resized; begin if Assigned(Child) then Child.SetBounds(Point(BorderWidth, BorderWidth), - gfxBase.Size(Width - 2 * BorderWidth, - Height - MainLayout.DefSize.cy - 2 * BorderWidth)); + Size(Width - 2 * BorderWidth, + Height - MainLayout.DefSize.cy - 2 * BorderWidth)); MainLayout.SetBounds( Point(BorderWidth, Height - MainLayout.DefSize.cy - BorderWidth), - gfxBase.Size(Width - 2 * BorderWidth, MainLayout.DefSize.cy - BorderWidth)); + Size(Width - 2 * BorderWidth, MainLayout.DefSize.cy - BorderWidth)); end; -procedure TFCustomStandardDialog.SeTFButtons(AButtons: TMsgDlgButtons); +procedure TFCustomStandardDialog.SetButtons(AButtons: TMsgDlgButtons); + + function AddBtn(const AText: String; ADefault: Boolean): TFButton; + begin + Result := TFButton.Create(Self); + Result.Text := AText; + // Result.Default := ADefault; + Result.OnClick := @StdBtnClicked; + Result.Parent := BtnLayout; + end; + +var + i: integer; + b: TFButton; begin + // remove and free all previous buttons + for i := ComponentCount - 1 downto 0 do + begin + if Components[i] is TFButton then + begin + b := TFButton(Components[i]); + if BtnLayout.ContainsChild(b) then + BtnLayout.RemoveChild(b); + b.Free; + end; + end; + FButtons := AButtons; + + if mbYes in FButtons then AddBtn(mbText_Yes, False); + if mbNo in FButtons then AddBtn(mbText_No, False); + if mbOk in FButtons then AddBtn(mbText_OK, True); + if mbCancel in FButtons then AddBtn(mbText_Cancel, False); + if mbApply in FButtons then AddBtn(mbText_Apply, False); + if mbAbort in FButtons then AddBtn(mbText_Abort, False); + if mbRetry in FButtons then AddBtn(mbText_Retry, False); + if mbIgnore in FButtons then AddBtn(mbText_Ignore, False); + if mbAll in FButtons then AddBtn(mbText_All, False); + if mbNoToAll in FButtons then AddBtn(mbText_NoToAll, False); + if mbYesToAll in FButtons then AddBtn(mbText_YesToAll, False); + if mbHelp in FButtons then AddBtn(mbText_Help, False); +end; + +function TFCustomStandardDialog.GetMessage: string; +begin + Result := FMessage.Text; +end; + +procedure TFCustomStandardDialog.SetMessage(const AValue: string); +begin + if FMessage.Text <> AValue then + FMessage.Text := AValue; end; procedure TFCustomStandardDialog.StdBtnClicked(Sender: TObject); diff --git a/gui/fpguiform.inc b/gui/fpguiform.inc index 0db9b297..9bd737da 100644 --- a/gui/fpguiform.inc +++ b/gui/fpguiform.inc @@ -124,7 +124,6 @@ begin FCanExpandHeight := True; FCursor := crArrow; FWindowOptions := [woWindow]; - end; @@ -143,8 +142,6 @@ procedure TFCustomForm.Show; begin LAYOUTTRACE('TFCustomForm.Show for %s:%s', [Name, ClassName]); -// if Assigned(Wnd) then ; // this makes sure that wnd is created - FVisible := True; GFApplication.AddWindow(Wnd); Wnd.Show; diff --git a/gui/fpguilabel.inc b/gui/fpguilabel.inc index b7903f22..80ca2346 100644 --- a/gui/fpguilabel.inc +++ b/gui/fpguilabel.inc @@ -3,7 +3,7 @@ Label class declarations - Copyright (C) 2000 - 2006 See the file AUTHORS.txt, included in this + Copyright (C) 2000 - 2007 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -38,13 +38,12 @@ TFLabel = class(TFCustomLabel) - public published - property CanExpandWidth; - property Enabled; - property FontColor; - property Text; - property Alignment default taLeftJustify; + property Alignment default taLeftJustify; + property CanExpandWidth; + property Enabled; + property FontColor; + property Text; end; {$ENDIF read_interface} @@ -63,7 +62,6 @@ var x: Integer; begin Canvas.SetColor(Style.GetUIColor(FFontColor)); -// Canvas.SetColor(FFontColor); case Alignment of taLeftJustify: x := 0; taCenter: x := (BoundsSize.cx - Canvas.TextWidth(Text)) div 2; @@ -73,22 +71,19 @@ begin (BoundsSize.cy - Canvas.FontCellHeight) div 2), Text, WidgetState); end; - procedure TFCustomLabel.CalcSizes; begin with FindForm.Wnd.Canvas do - FMinSize := gfxbase.Size(TextWidth(Text), FontCellHeight); + FMinSize := Size(TextWidth(Text), FontCellHeight); end; - constructor TFCustomLabel.Create(const pText: string; pOwner: TComponent); begin Create(pOwner); - Text := pText; FFontColor := clWindowText; + Text := pText; end; - procedure TFCustomLabel.SetAlignment(AAlignment: TAlignment); begin if AAlignment <> Alignment then @@ -98,7 +93,6 @@ begin end; end; - procedure TFCustomLabel.SetFontColor(const AValue: TColor); begin if FFontColor = AValue then exit; diff --git a/gui/fpguilayouts.inc b/gui/fpguilayouts.inc index ad12545c..2c45cf84 100644 --- a/gui/fpguilayouts.inc +++ b/gui/fpguilayouts.inc @@ -665,9 +665,22 @@ end; procedure TFCustomBoxLayout.RemoveChild(AChild: TFWidget); +var + i: integer; + item: TFLayoutItem; begin + for i := FWidgets.Count - 1 downto 0 do + begin + item := TFLayoutItem(FWidgets.Items[i]); + if item.Widget = AChild then + begin + item := nil; + FWidgets.Delete(i); + exit; + end + end; {$Warning Not implemented yet.} - raise Exception.Create('TCustomBoxLayout.RemoveChild - Not implemented yet'); +// raise Exception.Create('TCustomBoxLayout.RemoveChild - Not implemented yet'); end; @@ -1016,7 +1029,7 @@ begin Inc(w, (item.Width - 1) * FColSpacing); Inc(h, (item.Height - 1) * FRowSpacing); item.Widget.SetBounds(Point(x + item.x * FColSpacing, - y + item.y * FRowSpacing), gfxbase.Size(w, h)); + y + item.y * FRowSpacing), Size(w, h)); end; FreeMem(ColInfos); diff --git a/gui/fpguipackage.lpk b/gui/fpguipackage.lpk index 1213b9a4..844c953b 100644 --- a/gui/fpguipackage.lpk +++ b/gui/fpguipackage.lpk @@ -6,6 +6,7 @@ <CompilerOptions> <Version Value="5"/> <SearchPaths> + <OtherUnitFiles Value="db/"/> <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> </SearchPaths> <Parsing> @@ -26,8 +27,8 @@ "/> <License Value="Modified LGPL "/> - <Version Minor="3"/> - <Files Count="5"> + <Version Minor="4"/> + <Files Count="6"> <Item1> <Filename Value="fpgui.pas"/> <UnitName Value="fpGUI"/> @@ -48,6 +49,10 @@ <Filename Value="opensoftstyle.pas"/> <UnitName Value="OpenSoftStyle"/> </Item5> + <Item6> + <Filename Value="db/fpgui_db.pas"/> + <UnitName Value="fpGUI_DB"/> + </Item6> </Files> <LazDoc Paths="../docs/xml/gui/"/> <RequiredPkgs Count="2"> diff --git a/gui/fpguipackage.pas b/gui/fpguipackage.pas index 2e601325..1052517f 100644 --- a/gui/fpguipackage.pas +++ b/gui/fpguipackage.pas @@ -7,7 +7,7 @@ unit fpguipackage; interface uses - fpGUI, StyleManager, WindowsStyle, MotifStyle, OpenSoftStyle; + fpGUI, StyleManager, WindowsStyle, MotifStyle, OpenSoftStyle, fpGUI_DB; implementation |