summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-01-14 14:28:18 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-01-14 14:28:18 +0000
commitecfb462fd56c4508b1e66a4c7fde09097e80f8d8 (patch)
tree5d2833ee8bc5df1c3bc3964d5d8a0db3590a1f36 /src/gui
parent590d07beadb3632a8944c6b97f6b6a7d914f9caa (diff)
downloadfpGUI-ecfb462fd56c4508b1e66a4c7fde09097e80f8d8.tar.xz
* ShowMessage can now Centre of Left Align the text.
* Long text with paragraphs are now handled and painted correctly in the MessageBox and Message Dialog.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui_dialogs.pas31
-rw-r--r--src/gui/gui_grid.pas13
-rw-r--r--src/gui/messagedialog.inc5
3 files changed, 35 insertions, 14 deletions
diff --git a/src/gui/gui_dialogs.pas b/src/gui/gui_dialogs.pas
index e3439ae4..e830809e 100644
--- a/src/gui/gui_dialogs.pas
+++ b/src/gui/gui_dialogs.pas
@@ -77,13 +77,16 @@ type
FLineHeight: integer;
FMaxLineWidth: integer;
FButton: TfpgButton;
+ FCentreText: Boolean;
protected
procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override;
procedure HandlePaint; override;
+ procedure HandleShow; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SetMessage(AMessage: string);
+ property CentreText: Boolean read FCentreText write FCentreText default False;
end;
@@ -184,8 +187,8 @@ type
-procedure ShowMessage(AMessage, ATitle: string); overload;
-procedure ShowMessage(AMessage: string); overload;
+procedure ShowMessage(AMessage, ATitle: string; ACentreText: Boolean = False); overload;
+procedure ShowMessage(AMessage: string; ACentreText: Boolean = False); overload;
function SelectFontDialog(var FontDesc: string): boolean;
@@ -268,7 +271,10 @@ begin
c := AText[n];
if (c = #13) or (c = #10) then
begin
- AddLine(false);
+ // True indicates that if the text is split over multiple lines the last
+ // line must also be pocessed before continuing. If False then double CR
+ // can get ignored.
+ AddLine(true);
if (c = #13) and (n < Length(AText)) and (AText[n+1] = #10) then
Inc(n);
end
@@ -283,13 +289,14 @@ begin
AWidth := maxw;
end;
-procedure ShowMessage(AMessage, ATitle: string);
+procedure ShowMessage(AMessage, ATitle: string; ACentreText: Boolean);
var
frm: TfpgMessageBox;
begin
frm := TfpgMessageBox.Create(nil);
try
frm.WindowTitle := ATitle;
+ frm.CentreText := ACentreText;
frm.SetMessage(AMessage);
frm.ShowModal;
finally
@@ -297,9 +304,9 @@ begin
end;
end;
-procedure ShowMessage(AMessage: string);
+procedure ShowMessage(AMessage: string; ACentreText: Boolean);
begin
- ShowMessage(AMessage, 'Message');
+ ShowMessage(AMessage, 'Message', ACentreText);
end;
function SelectFontDialog(var FontDesc: string): boolean;
@@ -341,12 +348,21 @@ begin
for n := 0 to FLines.Count-1 do
begin
tw := FFont.TextWidth(FLines[n]);
- Canvas.DrawString(Width div 2 - tw div 2, y, FLines[n]);
+ if CentreText then
+ Canvas.DrawString(Width div 2 - tw div 2, y, FLines[n])
+ else
+ Canvas.DrawString(10, y, FLines[n]);
Inc(y, FLineHeight);
end;
Canvas.EndDraw;
end;
+procedure TfpgMessageBox.HandleShow;
+begin
+ inherited HandleShow;
+ FButton.SetFocus;
+end;
+
constructor TfpgMessageBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
@@ -359,6 +375,7 @@ begin
FLineHeight := FFont.Height + 4;
MinWidth := 200;
FMaxLineWidth := 500;
+ FCentreText := False;
FButton := TfpgButton.Create(self);
FButton.Text := cMsgDlgBtnText[mbOK]; // We must localize this
diff --git a/src/gui/gui_grid.pas b/src/gui/gui_grid.pas
index a293a98b..4ae2a08d 100644
--- a/src/gui/gui_grid.pas
+++ b/src/gui/gui_grid.pas
@@ -1,7 +1,7 @@
{
fpGUI - Free Pascal GUI Library
- Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this
+ Copyright (C) 2006 - 2008 See the file AUTHORS.txt, included in this
distribution, for details of the copyright.
See the file COPYING.modifiedLGPL, included in this distribution,
@@ -21,9 +21,11 @@ unit gui_grid;
{
TODO:
- * TCustomStringGrid: Objects property needs to be implemented.
- * TCustomStringGrid: Col[] and Row[] properties need to be implemented.
- The return TStrings with all text inserted.gui_grid
+ * TCustomStringGrid: Col[] and Row[] properties need to be implemented,
+ returning a TStrings with all related text inserted.
+ * File Grid: Introduce support for images based on file types. User must
+ be able to override the default images with their own.
+ * Remove the usage of libc unit. libc is linux/x86 specific.
}
interface
@@ -307,7 +309,7 @@ begin
result := p^.gr_name;
end;
{$ELSE}
-// Still need to find a alternative as we can't use the libc unit.
+// Still need to find an alternative for FreeBSD as we can't use the libc unit.
function GetGroupName(gid: integer): string;
begin
result := IntToStr(gid);
@@ -326,6 +328,7 @@ begin
result := '';
end;
{$ELSE}
+// Still need to find an alternative for FreeBSD as we can't use the libc unit.
function GetUserName(uid: integer): string;
begin
result := IntToStr(uid);
diff --git a/src/gui/messagedialog.inc b/src/gui/messagedialog.inc
index 23497a0f..7953e03d 100644
--- a/src/gui/messagedialog.inc
+++ b/src/gui/messagedialog.inc
@@ -1354,7 +1354,8 @@ begin
// tw := FFont.TextWidth(FInformativeText[i]);
// Canvas.DrawString(Width div 2 - tw div 2, y, FInformativeText[i]);
// left align text
- Canvas.DrawString(70, y, FInformativeText[i]);
+ if FInformativeText[i] <> '' then
+ Canvas.DrawString(70, y, FInformativeText[i]);
Inc(y, FLineHeight);
end;
end;
@@ -1517,7 +1518,7 @@ procedure TfpgMessageDialog.AfterCreate;
begin
{@VFD_BODY_BEGIN: fpgMessageDialog}
Name := 'fpgMessageDialog';
- WindowTitle := 'Form1';
+ WindowTitle := 'Message...';
Sizeable := False;
Width := 500;
Height := 400;