Improved title bar menu integration

This commit is contained in:
Markus Gans 2016-06-13 22:44:15 +02:00
parent b576b8dcad
commit 28c4a61997
5 changed files with 40 additions and 24 deletions

View File

@ -1,3 +1,6 @@
2016-06-13 Markus Gans <guru.mail@muenster.de>
* Improved title bar menu integration
2016-06-12 Markus Gans <guru.mail@muenster.de>
* Add a title bar menu to close dialogs

View File

@ -133,7 +133,7 @@ void FDialog::init()
dialog_menu = new FMenu ("-", this);
dialog_menu->move (xpos, ypos+1);
dgl_menuitem = dialog_menu->getItem();
if ( dgl_menuitem )
{
@ -290,6 +290,21 @@ void FDialog::drawTitleBar()
}
//----------------------------------------------------------------------
void FDialog::leaveMenu()
{
dialog_menu->unselectItem();
dialog_menu->hide();
activateWindow();
raiseWindow();
getFocusWidget()->setFocus();
redraw();
if ( statusBar() )
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
//----------------------------------------------------------------------
void FDialog::cb_close (FWidget*, void*)
{
@ -530,16 +545,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
if ( mouse_x < 4 && mouse_y == 1 )
{
if ( dialog_menu->isVisible() )
{
dialog_menu->unselectItem();
dialog_menu->hide();
activateWindow();
raiseWindow();
getFocusWidget()->setFocus();
redraw();
if ( statusBar() )
statusBar()->drawMessage();
}
leaveMenu();
else
{
setOpenMenu(dialog_menu);
@ -555,17 +561,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
{
// click on titlebar menu button
if ( mouse_x < 4 && mouse_y == 1 && dialog_menu->isVisible() )
{
// close menu
dialog_menu->unselectItem();
dialog_menu->hide();
activateWindow();
raiseWindow();
getFocusWidget()->setFocus();
redraw();
if ( statusBar() )
statusBar()->drawMessage();
}
leaveMenu(); // close menu
}
if ( ev->getButton() == fc::RightButton )
@ -648,7 +644,7 @@ void FDialog::onMouseUp (FMouseEvent* ev)
&& dialog_menu->isVisible()
&& ! dialog_menu->hasSelectedItem() )
{
FMenuItem* first_item;
FMenuItem* first_item;
dialog_menu->selectFirstItem();
first_item = dialog_menu->getSelectedItem();
if ( first_item )
@ -679,7 +675,7 @@ void FDialog::onMouseMove (FMouseEvent* ev)
{
// Mouse event handover to the menu
const FRect& menu_geometry = dialog_menu->getGeometryGlobal();
if ( dialog_menu->count() > 0
&& menu_geometry.contains(ev->getGlobalPos()) )
{

View File

@ -65,6 +65,7 @@ class FDialog : public FWindow
void init();
void drawBorder();
void drawTitleBar();
void leaveMenu();
void cb_close (FWidget*, void*);
protected:
@ -130,6 +131,9 @@ class FDialog : public FWindow
bool hasShadow();
FString getText() const;
void setText (const FString&);
private:
friend class FMenu;
};
#pragma pack(pop)

View File

@ -2,6 +2,7 @@
// Provides: class FMenu
#include "fapp.h"
#include "fdialog.h"
#include "fmenu.h"
#include "fstatusbar.h"
@ -252,6 +253,12 @@ void FMenu::adjustSize()
//move (adjust_X, ypos);
}
//----------------------------------------------------------------------
bool FMenu::isWindowsMenu (FWidget* w) const
{
return w->isDialog();
}
//----------------------------------------------------------------------
bool FMenu::isMenuBar (FWidget* w) const
{
@ -337,6 +344,11 @@ void FMenu::hideSuperMenus()
m->hide();
m->hideSuperMenus();
}
else if ( isWindowsMenu(super) )
{
FDialog* dgl = reinterpret_cast<FDialog*>(super);
dgl->leaveMenu();
}
}
}

View File

@ -61,6 +61,7 @@ class FMenu : public FWindow, public FMenuList
void adjustItems();
int adjustX(int);
void adjustSize();
bool isWindowsMenu (FWidget*) const;
bool isMenuBar (FWidget*) const;
bool isMenu (FWidget*) const;
bool isRadioMenuItem (FWidget*) const;