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

@ -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 )

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;