diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2010-05-07 11:10:31 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2010-05-07 11:10:31 +0200 |
commit | 0bbad919a198d3832a30e988518ca95f425c05ea (patch) | |
tree | b50c723bcd770ce9db7bf4012d994b89bb2c9e6b | |
parent | 4930af8bbdc94132ed464717b75e39d6e9f856cb (diff) | |
parent | 99f194504f3306189d6658fc0ef10a757ea054e9 (diff) | |
download | fpGUI-0bbad919a198d3832a30e988518ca95f425c05ea.tar.xz |
Merge branch 'master' of ssh://fpgui.git.sourceforge.net/gitroot/fpgui/fpgui
-rw-r--r-- | examples/gui/menutest/menutest.lpi | 10 | ||||
-rw-r--r-- | examples/gui/menutest/menutest.lpr | 267 | ||||
-rw-r--r-- | images/menu_check_16.bmp | bin | 0 -> 822 bytes | |||
-rw-r--r-- | src/corelib/fpg_base.pas | 1 | ||||
-rw-r--r-- | src/corelib/fpg_stdimages.pas | 5 | ||||
-rw-r--r-- | src/corelib/stdimages.inc | 54 | ||||
-rw-r--r-- | src/gui/fpg_menu.pas | 46 |
7 files changed, 328 insertions, 55 deletions
diff --git a/examples/gui/menutest/menutest.lpi b/examples/gui/menutest/menutest.lpi index f3d307af..96e0dc63 100644 --- a/examples/gui/menutest/menutest.lpi +++ b/examples/gui/menutest/menutest.lpi @@ -1,15 +1,14 @@ <?xml version="1.0"?> <CONFIG> <ProjectOptions> - <PathDelim Value="/"/> - <Version Value="6"/> + <Version Value="7"/> <General> <Flags> <SaveOnlyProjectUnits Value="True"/> + <LRSInOutputDirectory Value="False"/> </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> - <IconPath Value="./"/> <TargetFileExt Value=""/> </General> <VersionInfo> @@ -45,6 +44,11 @@ <Debugging> <GenerateDebugInfo Value="True"/> </Debugging> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> </Linking> <Other> <CustomOptions Value="-FUunits diff --git a/examples/gui/menutest/menutest.lpr b/examples/gui/menutest/menutest.lpr index 1db064fb..e4d40cf0 100644 --- a/examples/gui/menutest/menutest.lpr +++ b/examples/gui/menutest/menutest.lpr @@ -7,24 +7,44 @@ uses cthreads, {$ENDIF}{$ENDIF} Classes, + fpg_base, fpg_main, fpg_form, fpg_menu, - fpg_edit; + fpg_edit, + fpg_panel, + fpg_button, + fpg_dialogs, + fpg_memo; type TMainForm = class(TfpgForm) private + {@VFD_HEAD_BEGIN: MainForm} FMenuBar: TfpgMenuBar; + StatusBar: TfpgPanel; + Toolbar: TfpgBevel; + btnQuit: TfpgButton; + btnSave: TfpgButton; + btnOpen: TfpgButton; + btnAbout: TfpgButton; + edit1: TfpgEdit; + Memo1: TfpgMemo; FFileSubMenu: TfpgPopupMenu; FEditSubMenu: TfpgPopupMenu; FEditSelectSubMenu: TfpgPopupMenu; + FViewSubMenu: TfpgPopupMenu; FHelpSubMenu: TfpgPopupMenu; - edit1: TfpgEdit; + {@VFD_HEAD_END: MainForm} procedure miExitClicked(Sender: TObject); procedure miMenuItemSelected(Sender: TObject); + procedure miMenuItemChecked(Sender: TObject); + procedure miToolBarChecked(Sender: TObject); + procedure miStatusBarChecked(Sender: TObject); + procedure btnAboutClicked(Sender: TObject); + procedure Log(const AText: TfpgString); public - constructor Create(AOwner: TComponent); override; + procedure AfterCreate; override; end; @@ -38,52 +58,233 @@ end; procedure TMainForm.miMenuItemSelected(Sender: TObject); begin if Sender is TfpgMenuItem then - writeln('Menu clicked: ', TfpgMenuItem(Sender).Text); + Log('Menu clicked: ' + TfpgMenuItem(Sender).Text); +end; + +procedure TMainForm.miMenuItemChecked(Sender: TObject); +begin + TfpgMenuItem(Sender).Checked := not TfpgMenuItem(Sender).Checked; + Log('Check Menu item toggled'); +end; + +procedure TMainForm.miToolBarChecked(Sender: TObject); +begin + TfpgMenuItem(Sender).Checked := not TfpgMenuItem(Sender).Checked; + ToolBar.Visible := not ToolBar.Visible; + Log('Check Menu for Toolbar toggled'); +end; + +procedure TMainForm.miStatusBarChecked(Sender: TObject); +begin + TfpgMenuItem(Sender).Checked := not TfpgMenuItem(Sender).Checked; + StatusBar.Visible := not StatusBar.Visible; + Log('Check Menu for Statusbar toggled'); +end; + +procedure TMainForm.btnAboutClicked(Sender: TObject); +begin + TfpgMessageDialog.AboutFPGui; +end; + +procedure TMainForm.Log(const AText: TfpgString); +begin + Memo1.Lines.Add(AText); end; -constructor TMainForm.Create(AOwner: TComponent); +procedure TMainForm.AfterCreate; begin - inherited Create(AOwner); + {%region 'Auto-generated GUI code' -fold} + {@VFD_BODY_BEGIN: MainForm} + Name := 'MainForm'; + SetPosition(316, 169, 400, 200); WindowTitle := 'Menu Test'; - WindowPosition := wpUser; - SetPosition(100, 100, 400, 200); - - // Create top level sub-menus + Hint := ''; + WindowPosition := wpOneThirdDown; + + FMenuBar := TfpgMenuBar.Create(self); + with FMenuBar do + begin + Name := 'FMenuBar'; + SetPosition(0, 0, 400, 24); + Anchors := [anLeft,anRight,anTop]; + end; + + StatusBar := TfpgPanel.Create(self); + with StatusBar do + begin + Name := 'StatusBar'; + SetPosition(0, 176, 400, 24); + Anchors := [anLeft,anRight,anBottom]; + Alignment := taLeftJustify; + FontDesc := '#Label1'; + Hint := ''; + Style := bsLowered; + Text := 'This is the status bar...'; + end; + + Toolbar := TfpgBevel.Create(self); + with Toolbar do + begin + Name := 'Toolbar'; + SetPosition(0, 24, 400, 29); + Anchors := [anLeft,anRight,anTop]; + Hint := ''; + Shape := bsBottomLine; + end; + + btnQuit := TfpgButton.Create(Toolbar); + with btnQuit do + begin + Name := 'btnQuit'; + SetPosition(4, 2, 24, 24); + Text := ''; + Embedded := True; + FontDesc := '#Label1'; + Hint := ''; + ImageMargin := -1; + ImageName := 'stdimg.quit'; + ImageSpacing := 0; + TabOrder := 1; + OnClick := @miExitClicked; + end; + + btnSave := TfpgButton.Create(Toolbar); + with btnSave do + begin + Name := 'btnSave'; + SetPosition(56, 2, 24, 24); + Text := ''; + Embedded := True; + FontDesc := '#Label1'; + Hint := ''; + ImageMargin := -1; + ImageName := 'stdimg.save'; + ImageSpacing := 0; + TabOrder := 2; + end; + + btnOpen := TfpgButton.Create(Toolbar); + with btnOpen do + begin + Name := 'btnOpen'; + SetPosition(32, 2, 24, 24); + Text := ''; + Embedded := True; + FontDesc := '#Label1'; + Hint := ''; + ImageMargin := -1; + ImageName := 'stdimg.open'; + ImageSpacing := 0; + TabOrder := 3; + end; + + btnAbout := TfpgButton.Create(Toolbar); + with btnAbout do + begin + Name := 'btnAbout'; + SetPosition(84, 2, 24, 24); + Text := ''; + Embedded := True; + FontDesc := '#Label1'; + Hint := ''; + ImageMargin := -1; + ImageName := 'stdimg.help'; + ImageSpacing := 0; + TabOrder := 4; + OnClick := @btnAboutClicked; + end; + + edit1 := TfpgEdit.Create(self); + with edit1 do + begin + Name := 'edit1'; + SetPosition(8, 62, 100, 24); + ExtraHint := ''; + Hint := ''; + TabOrder := 6; + Text := ''; + FontDesc := '#Edit1'; + end; + + Memo1 := TfpgMemo.Create(self); + with Memo1 do + begin + Name := 'Memo1'; + SetPosition(124, 60, 268, 108); + Anchors := [anLeft,anRight,anTop,anBottom]; + Hint := ''; + Lines.Add('<= Text Edit has a popup menu too.'); + FontDesc := '#Edit1'; + TabOrder := 10; + end; + FFileSubMenu := TfpgPopupMenu.Create(self); - FFileSubMenu.AddMenuItem('&Open', 'Ctrl-O', @miMenuItemSelected); - FFileSubMenu.AddMenuItem('&Save', 'Ctrl-S', @miMenuItemSelected); - FFileSubMenu.AddMenuItem('S&ave As', 'Ctrl+Shift+S', @miMenuItemSelected); - FFileSubMenu.AddMenuItem('-', '', nil); - FFileSubMenu.AddMenuItem('Save && Reload', '', @miMenuItemSelected); - FFileSubMenu.AddMenuItem('-', '', nil); - FFileSubMenu.AddMenuItem('&Quit', 'Ctrl-Q', @miExitClicked); + with FFileSubMenu do + begin + Name := 'FFileSubMenu'; + SetPosition(264, 60, 120, 20); + AddMenuItem('&Open', 'Ctrl-O', @miMenuItemSelected); + AddMenuItem('&Save', 'Ctrl-S', @miMenuItemSelected); + AddMenuItem('S&ave As', 'Ctrl+Shift+S', @miMenuItemSelected); + AddMenuItem('-', '', nil); + AddMenuItem('Save && Reload', '', @miMenuItemSelected); + AddMenuItem('-', '', nil); + AddMenuItem('&Quit', 'Ctrl-Q', @miExitClicked); + end; FEditSubMenu := TfpgPopupMenu.Create(self); - FEditSubMenu.AddMenuItem('&Cut', 'Ctrl-X', @miMenuItemSelected); - FEditSubMenu.AddMenuItem('C&opy', 'Ctrl-C', @miMenuItemSelected); - FEditSubMenu.AddMenuItem('&Paste', 'Ctrl-V', @miMenuItemSelected); - FEditSubMenu.AddMenuItem('-', '', nil); - FEditSubMenu.AddMenuItem('&Spell check', 'F4', @miMenuItemSelected).Enabled := False; + with FEditSubMenu do + begin + Name := 'FEditSubMenu'; + SetPosition(264, 80, 120, 20); + AddMenuItem('&Cut', 'Ctrl-X', @miMenuItemSelected); + AddMenuItem('C&opy', 'Ctrl-C', @miMenuItemSelected); + AddMenuItem('&Paste', 'Ctrl-V', @miMenuItemSelected); + AddMenuItem('-', '', nil); + AddMenuItem('&Spell check', 'F4', @miMenuItemSelected).Enabled := False; + end; + FEditSelectSubMenu := TfpgPopupMenu.Create(self); - FEditSubMenu.AddMenuItem('Selec&t', '', nil).SubMenu := FEditSelectSubMenu; - FEditSelectSubMenu.AddMenuItem('Select All', '', @miMenuItemSelected); - FEditSelectSubMenu.AddMenuItem('Select Word', '', @miMenuItemSelected); - FEditSelectSubMenu.AddMenuItem('Select Line', '', @miMenuItemSelected); + with FEditSelectSubMenu do + begin + Name := 'FEditSelectSubMenu'; + SetPosition(264, 100, 120, 20); + AddMenuItem('Select All', '', @miMenuItemSelected); + AddMenuItem('Select Word', '', @miMenuItemSelected); + AddMenuItem('Select Line', '', @miMenuItemSelected); + FEditSubMenu.AddMenuItem('Selec&t', '', nil).SubMenu := FEditSelectSubMenu; + end; + + FViewSubMenu := TfpgPopupMenu.Create(self); + with FViewSubMenu do + begin + Name := 'FViewSubMenu'; + SetPosition(264, 120, 120, 20); + AddMenuItem('Full Screen', '', @miMenuItemChecked); + AddMenuItem('Tool Bar', '', @miToolBarChecked).Checked := True; + AddMenuItem('Status Bar', '', @miStatusBarChecked).Checked := True; + AddMenuItem('Line Numbers', '', @miMenuItemChecked); + end; FHelpSubMenu := TfpgPopupMenu.Create(self); - FHelpSubMenu.AddMenuItem('&About', 'F12', @miMenuItemSelected); - FHelpSubMenu.AddMenuItem('Test Russian text -> Òåñò', '', @miMenuItemSelected); + with FHelpSubMenu do + begin + Name := 'FHelpSubMenu'; + SetPosition(264, 140, 120, 20); + AddMenuItem('&About', 'F12', @btnAboutClicked); + AddMenuItem('Test Russian text -> Òåñò', '', @miMenuItemSelected); + end; + + {@VFD_BODY_END: MainForm} + {%endregion} - // Create main menu bar - FMenuBar := CreateMenuBar(self); + // Attach sub menus to main menu bar FMenuBar.AddMenuItem('&File', nil).SubMenu := FFileSubMenu; FMenuBar.AddMenuItem('&Edit', nil).SubMenu := FEditSubMenu; + FMenuBar.AddMenuItem('&View', nil).SubMenu := FViewSubMenu; FMenuBar.AddMenuItem('&Windows', nil); FMenuBar.AddMenuItem('&Disabled', nil).Enabled := False; FMenuBar.AddMenuItem('&Help', nil).SubMenu := FHelpSubMenu; - - edit1 := TfpgEdit.Create(self); - edit1.SetPosition(10, 70, 100, 24); end; diff --git a/images/menu_check_16.bmp b/images/menu_check_16.bmp Binary files differnew file mode 100644 index 00000000..7fec8e3c --- /dev/null +++ b/images/menu_check_16.bmp 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; |