summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2015-02-18 18:25:31 +0000
committerGraeme Geldenhuys <graemeg@gmail.com>2015-02-19 09:02:20 +0000
commit19984743b90f4de05381d5e26f08e0333c6420eb (patch)
treefc886754075a7b9682a9ff8fc5a5501d7253db1a /src
parent2e5c0cebb5a96a01dd853e0a253ccef000fa0f1c (diff)
downloadfpGUI-19984743b90f4de05381d5e26f08e0333c6420eb.tar.xz
menu: Replace font reference variable with direct fpgStyle calls
If the fpgStyle changed at runtime, those font reference variables are out of scope and causes a runtime error.
Diffstat (limited to 'src')
-rw-r--r--src/gui/fpg_menu.pas19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/gui/fpg_menu.pas b/src/gui/fpg_menu.pas
index 7b93be06..4779fe40 100644
--- a/src/gui/fpg_menu.pas
+++ b/src/gui/fpg_menu.pas
@@ -108,9 +108,6 @@ type
function MenuFocused: boolean;
function SearchItemByAccel(s: string): integer;
protected
- FMenuFont: TfpgFont;
- FMenuAccelFont: TfpgFont;
- FMenuDisabledFont: TfpgFont;
FSymbolWidth: integer;
FItems: TList;
FFocusItem: integer;
@@ -1100,7 +1097,7 @@ begin
if mi.HotKeyDef <> '' then
begin
s := mi.HotKeyDef;
- fpgStyle.DrawString(Canvas, rect.Right-FMenuFont.TextWidth(s)-FTextMargin, rect.Top, s, mi.Enabled);
+ fpgStyle.DrawString(Canvas, rect.Right-fpgStyle.MenuFont.TextWidth(s)-FTextMargin, rect.Top, s, mi.Enabled);
end;
// process menu item submenu arrow image
@@ -1182,7 +1179,7 @@ begin
if mi.Separator then
Result := 5
else
- Result := FMenuFont.Height + 2;
+ Result := fpgStyle.MenuFont.Height + 2;
end;
function TfpgPopupMenu.MenuFocused: boolean;
@@ -1263,14 +1260,14 @@ begin
mi := VisibleItem(n);
x := ItemHeight(mi);
inc(h, x);
- x := FMenuFont.TextWidth(mi.Text);
+ x := fpgStyle.MenuFont.TextWidth(mi.Text);
if tw < x then
tw := x;
if mi.SubMenu <> nil then
- x := FMenuFont.Height
+ x := fpgStyle.MenuFont.Height
else
- x := FMenuFont.TextWidth(mi.HotKeyDef);
+ x := fpgStyle.MenuFont.TextWidth(mi.HotKeyDef);
if hkw < x then
hkw := x;
end;
@@ -1348,11 +1345,7 @@ begin
FTextMargin := 3;
FItems := TList.Create;
- // fonts
- FMenuFont := fpgStyle.MenuFont;
- FMenuAccelFont := fpgStyle.MenuAccelFont;
- FMenuDisabledFont := fpgStyle.MenuDisabledFont;
- FSymbolWidth := FMenuFont.Height+2;
+ FSymbolWidth := fpgStyle.MenuFont.Height+2;
FBeforeShow := nil;
FFocusItem := -1;