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> 2016-06-12 Markus Gans <guru.mail@muenster.de>
* Add a title bar menu to close dialogs * Add a title bar menu to close dialogs

View File

@ -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*) void FDialog::cb_close (FWidget*, void*)
{ {
@ -530,16 +545,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
if ( mouse_x < 4 && mouse_y == 1 ) if ( mouse_x < 4 && mouse_y == 1 )
{ {
if ( dialog_menu->isVisible() ) if ( dialog_menu->isVisible() )
{ leaveMenu();
dialog_menu->unselectItem();
dialog_menu->hide();
activateWindow();
raiseWindow();
getFocusWidget()->setFocus();
redraw();
if ( statusBar() )
statusBar()->drawMessage();
}
else else
{ {
setOpenMenu(dialog_menu); setOpenMenu(dialog_menu);
@ -555,17 +561,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
{ {
// click on titlebar menu button // click on titlebar menu button
if ( mouse_x < 4 && mouse_y == 1 && dialog_menu->isVisible() ) if ( mouse_x < 4 && mouse_y == 1 && dialog_menu->isVisible() )
{ leaveMenu(); // close menu
// close menu
dialog_menu->unselectItem();
dialog_menu->hide();
activateWindow();
raiseWindow();
getFocusWidget()->setFocus();
redraw();
if ( statusBar() )
statusBar()->drawMessage();
}
} }
if ( ev->getButton() == fc::RightButton ) if ( ev->getButton() == fc::RightButton )

View File

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

View File

@ -2,6 +2,7 @@
// Provides: class FMenu // Provides: class FMenu
#include "fapp.h" #include "fapp.h"
#include "fdialog.h"
#include "fmenu.h" #include "fmenu.h"
#include "fstatusbar.h" #include "fstatusbar.h"
@ -252,6 +253,12 @@ void FMenu::adjustSize()
//move (adjust_X, ypos); //move (adjust_X, ypos);
} }
//----------------------------------------------------------------------
bool FMenu::isWindowsMenu (FWidget* w) const
{
return w->isDialog();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::isMenuBar (FWidget* w) const bool FMenu::isMenuBar (FWidget* w) const
{ {
@ -337,6 +344,11 @@ void FMenu::hideSuperMenus()
m->hide(); m->hide();
m->hideSuperMenus(); 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(); void adjustItems();
int adjustX(int); int adjustX(int);
void adjustSize(); void adjustSize();
bool isWindowsMenu (FWidget*) const;
bool isMenuBar (FWidget*) const; bool isMenuBar (FWidget*) const;
bool isMenu (FWidget*) const; bool isMenu (FWidget*) const;
bool isRadioMenuItem (FWidget*) const; bool isRadioMenuItem (FWidget*) const;