summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2010-05-07 11:10:31 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2010-05-07 11:10:31 +0200
commit0bbad919a198d3832a30e988518ca95f425c05ea (patch)
treeb50c723bcd770ce9db7bf4012d994b89bb2c9e6b /src
parent4930af8bbdc94132ed464717b75e39d6e9f856cb (diff)
parent99f194504f3306189d6658fc0ef10a757ea054e9 (diff)
downloadfpGUI-0bbad919a198d3832a30e988518ca95f425c05ea.tar.xz
Merge branch 'master' of ssh://fpgui.git.sourceforge.net/gitroot/fpgui/fpgui
Diffstat (limited to 'src')
-rw-r--r--src/corelib/fpg_base.pas1
-rw-r--r--src/corelib/fpg_stdimages.pas5
-rw-r--r--src/corelib/stdimages.inc54
-rw-r--r--src/gui/fpg_menu.pas46
4 files changed, 87 insertions, 19 deletions
diff --git a/src/corelib/fpg_base.pas b/src/corelib/fpg_base.pas
index 268c05dd..b0c4acee 100644
--- a/src/corelib/fpg_base.pas
+++ b/src/corelib/fpg_base.pas
@@ -2620,6 +2620,7 @@ begin
inherited Create(AOwner);
FHelpType := htKeyword;
FHelpContext := 0;
+ FTagPointer := nil;
end;
end.
diff --git a/src/corelib/fpg_stdimages.pas b/src/corelib/fpg_stdimages.pas
index 5c4790c1..2682ce3f 100644
--- a/src/corelib/fpg_stdimages.pas
+++ b/src/corelib/fpg_stdimages.pas
@@ -150,6 +150,11 @@ begin
sizeof(stdimg_menu_preferences_16), 0,0);
fpgImages.AddMaskedBMP(
+ 'stdimg.check',
+ @stdimg_menu_check_16,
+ sizeof(stdimg_menu_check_16), 0,0);
+
+ fpgImages.AddMaskedBMP(
'stdimg.document',
@stdimg_document,
sizeof(stdimg_document), 0,0);
diff --git a/src/corelib/stdimages.inc b/src/corelib/stdimages.inc
index ac3597a9..0c880278 100644
--- a/src/corelib/stdimages.inc
+++ b/src/corelib/stdimages.inc
@@ -2690,3 +2690,57 @@ Const
255,221,223,222,145,149,148,162,166,165,255,255,255,255,255,255,255,
255,255,255,255,255,185,187,186,148,152,150,255,255,255,255,255,255,
255,255,255,255,255,255);
+
+Const
+ stdimg_menu_check_16 : Array[0..821] of byte = (
+ 66, 77, 54, 3, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0,
+ 0, 16, 0, 0, 0, 16, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0,
+ 0, 3, 0, 0, 19, 11, 0, 0, 19, 11, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,
+ 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,
+ 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,
+ 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,
+ 255, 0,255,255, 0,255,255, 0,255, 0, 0, 0,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,
+ 255, 0,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255, 0, 0, 0, 0, 0, 0,
+ 255, 0,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255, 0, 0, 0,255, 0,255,255, 0,255,
+ 255, 0,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,
+ 255, 0,255, 0, 0, 0, 0, 0, 0,255, 0,255,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,
+ 255, 0,255, 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,
+ 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,
+ 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,
+ 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,
+ 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,
+ 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,
+ 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,
+ 255, 0,255,255, 0,255);
+
+
diff --git a/src/gui/fpg_menu.pas b/src/gui/fpg_menu.pas
index dbe92d50..3d972756 100644
--- a/src/gui/fpg_menu.pas
+++ b/src/gui/fpg_menu.pas
@@ -77,7 +77,7 @@ type
procedure Click;
function Selectable: boolean;
function GetAccelChar: string;
- procedure DrawText(ACanvas: TfpgCanvas; x, y: TfpgCoord);
+ procedure DrawText(ACanvas: TfpgCanvas; x, y: TfpgCoord; const AImgWidth: integer);
function GetCommand: ICommand;
procedure SetCommand(ACommand: ICommand);
property Checked: boolean read FChecked write SetChecked;
@@ -160,6 +160,7 @@ type
procedure PrepareToShow;
function VisibleCount: integer;
function VisibleItem(ind: integer): TfpgMenuItem;
+ procedure HandleShow; override;
procedure HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState); override;
procedure HandleLMouseDown(x, y: integer; shiftstate: TShiftState); override;
procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override;
@@ -186,10 +187,14 @@ function CreateMenuBar(AOwner: TfpgWidget): TfpgMenuBar; overload;
implementation
-
+
var
uFocusedPopupMenu: TfpgPopupMenu;
+const
+ cImgWidth: integer = 16;
+
+
function CreateMenuBar(AOwner: TfpgWidget; x, y, w, h: TfpgCoord): TfpgMenuBar;
begin
if AOwner = nil then
@@ -258,6 +263,7 @@ begin
FSeparator := False;
FVisible := True;
FEnabled := True;
+ FChecked := False;
FSubMenu := nil;
FOnClick := nil;
end;
@@ -286,11 +292,12 @@ begin
Result := '';
end;
-procedure TfpgMenuItem.DrawText(ACanvas: TfpgCanvas; x, y: TfpgCoord);
+procedure TfpgMenuItem.DrawText(ACanvas: TfpgCanvas; x, y: TfpgCoord; const AImgWidth: integer);
var
s: string;
p: integer;
achar: string;
+ img: TfpgImage;
begin
if not Enabled then
ACanvas.SetFont(fpgStyle.MenuDisabledFont)
@@ -300,19 +307,23 @@ begin
achar := '&';
s := Text;
+ if Checked then
+ begin
+ img := fpgImages.GetImage('stdimg.check'); // Do NOT localize
+ ACanvas.DrawImage(x-AImgWidth-2, y, img); // 2 = margin.
+ end;
+
repeat
p := UTF8Pos(achar, s);
if p > 0 then
begin
// first part of text before the & sign
-// ACanvas.DrawString(x, y, UTF8Copy(s, 1, p-1));
fpgStyle.DrawString(ACanvas, x, y, UTF8Copy(s, 1, p-1), Enabled);
inc(x, fpgStyle.MenuFont.TextWidth(UTF8Copy(s, 1, p-1)));
if UTF8Copy(s, p+1, 1) = achar then
begin
// Do we need to paint a actual & sign (create via && in item text)
-// ACanvas.DrawString(x, y, achar);
fpgStyle.DrawString(ACanvas, x, y, achar, Enabled);
inc(x, fpgStyle.MenuFont.TextWidth(achar));
end
@@ -321,7 +332,6 @@ begin
// Draw the HotKey text
if Enabled then
ACanvas.SetFont(fpgStyle.MenuAccelFont);
-// ACanvas.DrawString(x, y, UTF8Copy(s, p+1, 1));
fpgStyle.DrawString(ACanvas, x, y, UTF8Copy(s, p+1, 1), Enabled);
inc(x, ACanvas.Font.TextWidth(UTF8Copy(s, p+1, 1)));
if Enabled then
@@ -333,7 +343,6 @@ begin
// Draw the remaining text after the & sign
if UTF8Length(s) > 0 then
-// ACanvas.DrawString(x, y, s);
fpgStyle.DrawString(ACanvas, x, y, s, Enabled);
end;
@@ -391,6 +400,12 @@ begin
Result := TfpgMenuItem(FItems.Items[ind]);
end;
+procedure TfpgMenuBar.HandleShow;
+begin
+ PrepareToShow;
+ inherited HandleShow;
+end;
+
procedure TfpgMenuBar.HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState);
var
newf: integer;
@@ -497,7 +512,6 @@ var
n: integer;
r: TfpgRect;
begin
- PrepareToShow;
Canvas.BeginDraw;
inherited HandlePaint;
r.SetRect(0, 0, Width, Height);
@@ -590,7 +604,7 @@ begin
Canvas.FillRectangle(r);
// a possible future theme option
// Canvas.GradientFill(r, FLightColor, FDarkColor, gdVertical);
- mi.DrawText(Canvas, r.left+4, r.top+1);
+ mi.DrawText(Canvas, r.left+4, r.top+1, cImgWidth);
Canvas.EndDraw(r.Left, r.Top, r.Width, r.Height);
Exit; //==>
end; { if col=n }
@@ -829,7 +843,6 @@ procedure TfpgPopupMenu.HandleLMouseUp(x, y: integer; shiftstate: TShiftState);
var
newf: integer;
mi: TfpgMenuItem;
- r: TfpgRect;
begin
inherited HandleLMouseUp(x, y, shiftstate);
@@ -1025,25 +1038,20 @@ begin
else
begin
x := rect.Left + FSymbolWidth + FTextMargin;
-
- mi.DrawText(Canvas, x, rect.top);
+ mi.DrawText(Canvas, x+cImgWidth, rect.top, cImgWidth);
if mi.HotKeyDef <> '' then
begin
s := mi.HotKeyDef;
fpgStyle.DrawString(Canvas, rect.Right-FMenuFont.TextWidth(s)-FTextMargin, rect.Top, s, mi.Enabled);
-// Canvas.DrawString(rect.Right-FMenuFont.TextWidth(s)-FTextMargin, rect.Top, s);
end;
if mi.SubMenu <> nil then
begin
- canvas.SetColor(Canvas.TextColor);
+ Canvas.SetColor(Canvas.TextColor);
x := (rect.height div 2) - 3;
img := fpgImages.GetImage('sys.sb.right');
Canvas.DrawImage(rect.right-x-2, rect.Top + ((rect.Height-img.Height) div 2), img);
-// canvas.FillTriangle(rect.right-x-2, rect.top+2,
-// rect.right-2, rect.top+2+x,
-// rect.right-x-2, rect.top+2+2*x);
end;
end;
end;
@@ -1205,8 +1213,8 @@ begin
hkw := hkw + 10; // spacing between text and hotkey text
FHeight := FMargin*2 + h;
- FWidth := (FMargin+FTextMargin)*2 + FSymbolWidth + tw + hkw;
-
+ FWidth := (FMargin+FTextMargin)*2 + FSymbolWidth + tw + hkw + cImgWidth;
+
uFocusedPopupMenu := self;
end;