Switch back to the own dialog when you closing a dialog menu

This commit is contained in:
Markus Gans 2016-08-20 22:27:23 +02:00
parent b08d064226
commit bbfbde465f
9 changed files with 50 additions and 31 deletions

View File

@ -1,3 +1,6 @@
2016-08-20 Markus Gans <guru.mail@muenster.de>
* Switch back to the own dialog when you closing a dialog menu
2016-08-14 Markus Gans <guru.mail@muenster.de> 2016-08-14 Markus Gans <guru.mail@muenster.de>
* Screen characters now have a transparent * Screen characters now have a transparent
and a transparent shadow option and a transparent shadow option

View File

@ -1391,13 +1391,21 @@ void FApplication::processMouseEvent()
if ( ! menu->containsMenuStructure(*mouse) ) if ( ! menu->containsMenuStructure(*mouse) )
{ {
bool is_window_menu;
FWidget* super = menu->getSuperMenu();
if ( super && menu->isWindowsMenu(super) )
is_window_menu = true;
else
is_window_menu = false;
menu->unselectItem(); menu->unselectItem();
menu->hide(); menu->hide();
menu->hideSubMenus(); menu->hideSubMenus();
menu->hideSuperMenus(); menu->hideSuperMenus();
// No widget was been clicked // No widget was been clicked and the menu is no dialog menu
if ( ! clicked_widget ) if ( ! (clicked_widget && is_window_menu) )
FWindow::switchToPrevWindow(); FWindow::switchToPrevWindow();
if ( statusBar() ) if ( statusBar() )

View File

@ -101,7 +101,6 @@ void FDialog::init()
createArea (vwin); createArea (vwin);
setGeometry (1, 1, 10, 10, false); // initialize geometry values setGeometry (1, 1, 10, 10, false); // initialize geometry values
ignore_padding = true; ignore_padding = true;
window_object = true;
dialog_object = true; dialog_object = true;
addDialog(this); addDialog(this);
addWindow(this); addWindow(this);
@ -125,6 +124,7 @@ void FDialog::init()
} }
accelerator_list = new Accelerators(); accelerator_list = new Accelerators();
// Add the dialog menu
dialog_menu = new FMenu ("-", this); dialog_menu = new FMenu ("-", this);
dialog_menu->move (xpos, ypos+1); dialog_menu->move (xpos, ypos+1);
dgl_menuitem = dialog_menu->getItem(); dgl_menuitem = dialog_menu->getItem();
@ -268,7 +268,7 @@ void FDialog::drawTitleBar()
if ( getMaxColor() < 16 ) if ( getMaxColor() < 16 )
setBold(); setBold();
if ( isActiveWindow() || dialog_menu->isVisible() ) if ( isActiveWindow() || (dialog_menu && dialog_menu->isVisible()) )
setColor (wc.titlebar_active_fg, wc.titlebar_active_bg); setColor (wc.titlebar_active_fg, wc.titlebar_active_bg);
else else
setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg); setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg);
@ -788,7 +788,7 @@ void FDialog::onWindowActive (FEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::onWindowInactive (FEvent*) void FDialog::onWindowInactive (FEvent*)
{ {
if ( ! dialog_menu->isVisible() ) if ( dialog_menu && ! dialog_menu->isVisible() )
FWindow::previous_widget = this; FWindow::previous_widget = this;
if ( isVisible() && isEnabled() ) if ( isVisible() && isEnabled() )

View File

@ -117,7 +117,6 @@ void FMenu::init(FWidget* parent)
createArea (vwin); createArea (vwin);
setGeometry (1, 1, 10, 2, false); // initialize geometry values setGeometry (1, 1, 10, 2, false); // initialize geometry values
setTransparentShadow(); setTransparentShadow();
window_object = true;
menu_object = true; menu_object = true;
addWindow(this); addWindow(this);
hide(); hide();
@ -1040,12 +1039,14 @@ void FMenu::onKeyPress (FKeyEvent* ev)
} }
else else
{ {
FWidget* super = getSuperMenu();
hideSuperMenus(); hideSuperMenus();
if ( statusBar() ) if ( statusBar() )
statusBar()->clearMessage(); statusBar()->clearMessage();
switchToPrevWindow(); if ( ! super || ! isWindowsMenu(super) )
switchToPrevWindow();
} }
if ( statusBar() ) if ( statusBar() )

View File

@ -46,7 +46,6 @@ void FMenuBar::init()
ypos = 1; ypos = 1;
createArea (vmenubar); createArea (vmenubar);
vmenubar->visible = true; vmenubar->visible = true;
window_object = true;
ignore_padding = true; ignore_padding = true;
// initialize geometry values // initialize geometry values
setGeometry (1, 1, getColumnNumber(), 1, false); setGeometry (1, 1, getColumnNumber(), 1, false);

View File

@ -190,7 +190,6 @@ void FStatusBar::init()
ypos = getLineNumber(); ypos = getLineNumber();
createArea (vstatusbar); createArea (vstatusbar);
vstatusbar->visible = true; vstatusbar->visible = true;
window_object = true;
ignore_padding = true; ignore_padding = true;
mouse_down = false; mouse_down = false;

View File

@ -768,7 +768,7 @@ bool FWidget::focusNextChild()
FObject::object_list children; FObject::object_list children;
FObject::object_list::iterator iter, end; FObject::object_list::iterator iter, end;
children = getParent()->getChildren(); children = parent->getChildren();
iter = children.begin(); iter = children.begin();
end = children.end(); end = children.end();
@ -838,7 +838,7 @@ bool FWidget::focusPrevChild()
FObject::object_list children; FObject::object_list children;
FObject::object_list::iterator iter, begin; FObject::object_list::iterator iter, begin;
children = getParent()->getChildren(); children = parent->getChildren();
iter = children.end(); iter = children.end();
begin = children.begin(); begin = children.begin();
@ -1428,13 +1428,12 @@ void FWidget::hide()
visible = false; visible = false;
shown = false; shown = false;
if ( FWidget::getFocusWidget() == this ) if ( ! isDialog()
&& FWidget::getFocusWidget() == this
&& ! focusPrevChild() )
{ {
if ( ! focusPrevChild() ) FWidget::getFocusWidget()->unsetFocus();
{ FWidget::setFocusWidget(getParentWidget());
FWidget::getFocusWidget()->unsetFocus();
FWidget::setFocusWidget(getParentWidget());
}
} }
FHideEvent hide_ev (fc::Hide_Event); FHideEvent hide_ev (fc::Hide_Event);

View File

@ -19,7 +19,9 @@ FWindow::FWindow(FWidget* parent)
: FWidget(parent) : FWidget(parent)
, window_active(false) , window_active(false)
, win_focus_widget(0) , win_focus_widget(0)
{ } {
window_object = true;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FWindow::~FWindow() // destructor FWindow::~FWindow() // destructor
@ -94,6 +96,9 @@ void FWindow::hide()
if ( area ) if ( area )
area->visible = false; area->visible = false;
if ( isDialog() )
switchToPrevWindow();
FWidget::hide(); FWidget::hide();
} }

View File

@ -220,8 +220,13 @@ void Window::onClose (FCloseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::cb_createWindows (FWidget*, void*) void Window::cb_createWindows (FWidget*, void*)
{ {
int w,h,dx,dy;
std::vector<win_data*>::const_iterator iter, begin; std::vector<win_data*>::const_iterator iter, begin;
iter = begin = windows.begin(); iter = begin = windows.begin();
w = getRootWidget()->getWidth();
h = getRootWidget()->getHeight();
dx = (w > 80) ? (w - 80) / 2 : 0;
dy = (h > 24) ? (h - 24) / 2 : 0;
while ( iter != windows.end() ) while ( iter != windows.end() )
{ {
@ -234,8 +239,8 @@ void Window::cb_createWindows (FWidget*, void*)
win_dat->is_open = true; win_dat->is_open = true;
win->setText(*(win_dat)->title); win->setText(*(win_dat)->title);
n = int(std::distance(begin, iter)); n = int(std::distance(begin, iter));
x = 5 + (n%3)*25 + int(n/3)*3; x = dx + 5 + (n%3)*25 + int(n/3)*3;
y = 11 + int(n/3)*3; y = dy + 11 + int(n/3)*3;
win->setGeometry (x, y, 20, 8); win->setGeometry (x, y, 20, 8);
win->setTransparentShadow(); win->setTransparentShadow();
win->show(); win->show();
@ -369,12 +374,14 @@ void Window::cb_destroyWindow (FWidget*, void* data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::adjustSize() void Window::adjustSize()
{ {
int w,h,X,Y; int w,h,X,Y,dx,dy;
std::vector<win_data*>::const_iterator iter, begin; std::vector<win_data*>::const_iterator iter, begin;
w = getRootWidget()->getWidth(); w = getRootWidget()->getWidth();
h = getRootWidget()->getHeight(); h = getRootWidget()->getHeight();
X = int(1 + (w - 40) / 2); X = int(1 + (w - 40) / 2);
Y = int(1 + (h - 22) / 2); Y = int(1 + (h - 22) / 2);
dx = (w > 80) ? (w - 80) / 2 : 0;
dy = (h > 24) ? (h - 24) / 2 : 0;
if ( Y < 2) if ( Y < 2)
Y = 2; Y = 2;
@ -386,12 +393,10 @@ void Window::adjustSize()
{ {
if ( (*iter)->is_open ) if ( (*iter)->is_open )
{ {
int x,y,dx,dy,n; int x,y,n;
n = int(std::distance(begin, iter)); n = int(std::distance(begin, iter));
dx = (w > 80) ? (w - 80) / 2 : 0; x = dx + 5 + (n%3)*25 + int(n/3)*3;
dy = (h > 24) ? (h - 24) / 2 : 0; y = dy + 11 + int(n/3)*3;
x = dx + 5 + (n%3)*25 + int(n/3)*3;
y = dy + 11 + int(n/3)*3;
(*iter)->dgl->setPos (x, y, false); (*iter)->dgl->setPos (x, y, false);
} }