summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-02-01 08:41:01 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-02-01 08:41:01 +0000
commit352a0d6eb4320cf3c6cabffb27f93f285a8bfeb9 (patch)
tree8bd877e2426ba6979e9709949a33f66d1a493239
parent606d4914596a3455d1757aa4e8c408c218316639 (diff)
downloadfpGUI-352a0d6eb4320cf3c6cabffb27f93f285a8bfeb9.tar.xz
* Applied patch from Jean-Marc which fixes a minor issue in the TfpgMemo and TfpgMenu components. It also adds a new BackgroundColor property to TfpgButton.
* Minor fixes to Jean-Marc's patch with button painting. * The threedee example now uses the new Button.BackgroundColor property.
-rw-r--r--prototypes/fpgui2/tests/frm_threedee.pas3
-rw-r--r--src/corelib/x11/fpgfx_package.pas6
-rw-r--r--src/gui/gui_button.pas34
-rw-r--r--src/gui/gui_memo.pas4
-rw-r--r--src/gui/gui_menu.pas13
5 files changed, 48 insertions, 12 deletions
diff --git a/prototypes/fpgui2/tests/frm_threedee.pas b/prototypes/fpgui2/tests/frm_threedee.pas
index a31a829e..dd3bc46d 100644
--- a/prototypes/fpgui2/tests/frm_threedee.pas
+++ b/prototypes/fpgui2/tests/frm_threedee.pas
@@ -214,6 +214,7 @@ begin
tb.BackgroundColor := clWindowBackground;
lblName1.BackgroundColor := clWindowBackground;
lblName2.BackgroundColor := clWindowBackground;
+ btnQuit.BackgroundColor := clButtonFace;
end
else
begin
@@ -223,6 +224,7 @@ begin
tb.BackgroundColor := clM2DarkBlue;
lblName1.BackgroundColor := clM2DarkBlue;
lblName2.BackgroundColor := clM2DarkBlue;
+ btnQuit.BackgroundColor := clM2DarkBlue;
end;
end;
@@ -250,6 +252,7 @@ begin
Text := 'Quit';
FontDesc := '#Label1';
ImageName := 'stdimg.quit';
+ BackgroundColor := clM2DarkBlue;
OnClick := @btnQuitClicked;
end;
diff --git a/src/corelib/x11/fpgfx_package.pas b/src/corelib/x11/fpgfx_package.pas
index 03d1c316..aa0d1848 100644
--- a/src/corelib/x11/fpgfx_package.pas
+++ b/src/corelib/x11/fpgfx_package.pas
@@ -9,9 +9,9 @@ interface
uses
x11_xft, x11_keyconv, gfxbase, gfx_x11, fpgfx, gfx_stdimages, gfx_imgfmt_bmp,
gfx_widget, gfx_UTF8utils, gfx_extinterpolation, gfx_cmdlineparams,
- gfx_clipboard, gfx_utils, gfx_popupwindow, gfx_impl,
- gfx_command_intf, gfx_wuline;
+ gfx_clipboard, gfx_utils, gfx_popupwindow, gfx_impl, gfx_command_intf,
+ gfx_wuline;
implementation
-end. \ No newline at end of file
+end.
diff --git a/src/gui/gui_button.pas b/src/gui/gui_button.pas
index b8c6354c..85de9f8e 100644
--- a/src/gui/gui_button.pas
+++ b/src/gui/gui_button.pas
@@ -36,6 +36,7 @@ type
TfpgButton = class(TfpgWidget, ICommandHolder)
private
FTextColor: TfpgColor;
+ FBackgroundColor: TfpgColor;
FCommand: ICommand;
FImageName: string;
FClicked: Boolean;
@@ -46,6 +47,7 @@ type
FModalResult: integer;
function GetFontDesc: string;
procedure SetTextColor(const AValue: TfpgColor);
+ procedure SetBackgroundColor(const AValue: TfpgColor);
procedure SetDefault(const AValue: boolean);
procedure SetEmbedded(const AValue: Boolean);
procedure SetFontDesc(const AValue: string);
@@ -87,6 +89,7 @@ type
property AllowDown: Boolean read GetAllowDown write SetAllowDown;
published
property AllowAllUp: boolean read FAllowAllUp write SetAllowAllUp default False;
+ property BackgroundColor: TfpgColor read FBackgroundColor write SetBackgroundColor default clButtonFace;
property Default: boolean read FDefault write SetDefault default False;
property Embedded: Boolean read FEmbedded write SetEmbedded default False;
property FontDesc: string read GetFontDesc write SetFontDesc;
@@ -173,6 +176,15 @@ begin
end;
end;
+procedure TfpgButton.SetBackgroundColor(const AValue: TfpgColor);
+begin
+ if FBackgroundColor <> AValue then
+ begin
+ FBackgroundColor := AValue;
+ Repaint;
+ end;
+end;
+
procedure TfpgButton.SetDefault(const AValue: boolean);
var
i: integer;
@@ -181,7 +193,7 @@ begin
if FDefault = AValue then
Exit; //==>
FDefault := AValue;
-
+
// Clear other buttons Default state
if FDefault and (Parent <> nil) then
begin
@@ -221,6 +233,7 @@ begin
FWidth := 75;
FFocusable := True;
FTextColor := clText1;
+ FBackgroundColor := clButtonFace;
OnClick := nil;
FDown := False;
FClicked := False;
@@ -231,7 +244,7 @@ begin
FImageName := '';
FShowImage := True;
FImageMargin := 3; // image is 3 pixels from edge of button. -1 will centre image.
- FImageSpacing := -1; // text is centered in remainind space
+ FImageSpacing := -1; // text is centered in remaining space
FModalResult := 0;
FEmbedded := False;
FDefault := False;
@@ -253,10 +266,11 @@ var
r: TfpgRect;
pofs: integer;
lBtnFlags: TFButtonFlags;
+ clr: TfpgColor;
begin
Canvas.BeginDraw;
// inherited HandlePaint;
- Canvas.Clear(clButtonFace);
+// Canvas.Clear(FBackgroundColor); // Do we need this?
Canvas.ClearClipRect;
r.SetRect(0, 0, Width, Height);
@@ -270,18 +284,26 @@ begin
if FEmbedded then
Include(lBtnFlags, btnIsEmbedded);
-
+
if FDefault then
Include(lBtnFlags, btnIsDefault);
- Canvas.DrawButtonFace(r, lBtnFlags);
+ if FBackgroundColor <> clButtonFace then
+ begin
+ clr := fpgColorToRGB(clButtonFace);
+ fpgSetNamedColor(clButtonface, FBackgroundColor);
+ Canvas.DrawButtonFace(r, lBtnFlags);
+ fpgSetNamedColor(clButtonface, clr);
+ end
+ else
+ Canvas.DrawButtonFace(r, lBtnFlags);
if FFocused and (not FEmbedded) then
begin
InflateRect(r, -3, -3);
Canvas.DrawFocusRect(r);
end;
-
+
Canvas.SetTextColor(FTextColor);
Canvas.SetColor(clText1);
diff --git a/src/gui/gui_memo.pas b/src/gui/gui_memo.pas
index 599d3fd0..a925f2f2 100644
--- a/src/gui/gui_memo.pas
+++ b/src/gui/gui_memo.pas
@@ -565,8 +565,8 @@ end;
function TfpgMemo.GetLineText(linenum: integer): string;
begin
- if LineCount < 1 then
- FLines.Add('');
+{ if LineCount < 1 then
+ FLines.Add(''); }
if (linenum >= 1) and (linenum <= LineCount) then
Result := FLines.Strings[linenum - 1]
else
diff --git a/src/gui/gui_menu.pas b/src/gui/gui_menu.pas
index 62aa5b62..3284bcef 100644
--- a/src/gui/gui_menu.pas
+++ b/src/gui/gui_menu.pas
@@ -171,12 +171,24 @@ type
property BeforeShow: TNotifyEvent read FBeforeShow write FBeforeShow;
end;
+function CreateMenuBar(AOwner: TComponent; x, y, w, h: TfpgCoord): TfpgMenuBar;
+
implementation
var
uFocusedPopupMenu: TfpgPopupMenu;
+function CreateMenuBar(AOwner: TComponent; x, y, w, h: TfpgCoord): TfpgMenuBar;
+begin
+ Result := TfpgMenuBar.Create(AOwner);
+ Result.Left := x;
+ Result.Top := y;
+ Result.Width := w;
+ if h > 0 then
+ Result.Height := h;
+end;
+
{ TfpgMenuItem }
@@ -667,7 +679,6 @@ end;
procedure TfpgPopupMenu.SetBackgroundColor(const AValue: TfpgColor);
begin
if FBackgroundColor = AValue then Exit; //==>
- Exit;
FBackgroundColor := AValue;
end;