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>
* Screen characters now have a transparent
and a transparent shadow option

View File

@ -1391,13 +1391,21 @@ void FApplication::processMouseEvent()
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->hide();
menu->hideSubMenus();
menu->hideSuperMenus();
// No widget was been clicked
if ( ! clicked_widget )
// No widget was been clicked and the menu is no dialog menu
if ( ! (clicked_widget && is_window_menu) )
FWindow::switchToPrevWindow();
if ( statusBar() )

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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