diff --git a/ChangeLog b/ChangeLog index 426ffa77..89efd90d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016-07-14 Markus Gans + * Adding a dialog list with the entries in the chronological + order of the generation + 2016-07-13 Markus Gans * Bind accelerator key from the FMenuItem to the root widget diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 15a8758d..74d52bc0 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -52,6 +52,7 @@ FDialog::~FDialog() // destructor accelerator_list = 0; activatePrevWindow(); delWindow(this); + delDialog(this); fapp = static_cast(getRootWidget()); if ( ! fapp->quit_now ) @@ -102,6 +103,7 @@ void FDialog::init() ignore_padding = true; window_object = true; dialog_object = true; + addDialog(this); addWindow(this); setActiveWindow(this); @@ -324,6 +326,36 @@ void FDialog::cb_close (FWidget*, void*) close(); } +//---------------------------------------------------------------------- +void FDialog::addDialog (FWidget* obj) +{ + // add the dialog object obj to the dialog list + if ( dialog_list ) + dialog_list->push_back(obj); +} + +//---------------------------------------------------------------------- +void FDialog::delDialog (FWidget* obj) +{ + // delete the dialog object obj from the dialog list + if ( ! dialog_list || dialog_list->empty() ) + return; + + widgetList::iterator iter; + iter = dialog_list->begin(); + + while ( iter != dialog_list->end() ) + { + if ( (*iter) == obj ) + { + dialog_list->erase(iter); + return; + } + + ++iter; + } +} + // protected methods of FDialog //---------------------------------------------------------------------- diff --git a/src/fdialog.h b/src/fdialog.h index 8bb1dab6..f11c6637 100644 --- a/src/fdialog.h +++ b/src/fdialog.h @@ -50,23 +50,25 @@ class FDialog : public FWindow }; private: - FString tb_text; // title bar text - int result_code; - bool maximized; - FPoint TitleBarClickPos; - FRect oldGeometry; // required by move() - FWidget* focus_widget; - FMenu* dialog_menu; - FMenuItem* dgl_menuitem; + FString tb_text; // title bar text + int result_code; + bool maximized; + FPoint TitleBarClickPos; + FRect oldGeometry; // required by move() + FWidget* focus_widget; + FMenu* dialog_menu; + FMenuItem* dgl_menuitem; private: FDialog (const FDialog&); FDialog& operator = (const FDialog&); - void init(); - void drawBorder(); - void drawTitleBar(); - void leaveMenu(); - void cb_close (FWidget*, void*); + void init(); + void drawBorder(); + void drawTitleBar(); + void leaveMenu(); + void cb_close (FWidget*, void*); + static void addDialog (FWidget*); + static void delDialog (FWidget*); protected: virtual void done (int); diff --git a/src/fdialoglistmenu.cpp b/src/fdialoglistmenu.cpp index 39f9e1d8..3d709f0f 100644 --- a/src/fdialoglistmenu.cpp +++ b/src/fdialoglistmenu.cpp @@ -52,5 +52,5 @@ void FDialogListMenu::init() FMenuItem* menuitem = getItem(); if ( menuitem ) - menuitem->dialog_list = true; + menuitem->dialog_index = true; } diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 0a6027d2..66b3330f 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -23,7 +23,7 @@ FMenuItem::FMenuItem (FWidget* parent) , checkable(false) , checked(false) , radio_button(false) - , dialog_list(false) + , dialog_index(false) , text_length(0) , hotkey(0) , accel_key(0) @@ -42,7 +42,7 @@ FMenuItem::FMenuItem (FString& txt, FWidget* parent) , checkable(false) , checked(false) , radio_button(false) - , dialog_list(false) + , dialog_index(false) , text_length(0) , hotkey(0) , accel_key(0) @@ -61,7 +61,7 @@ FMenuItem::FMenuItem (const std::string& txt, FWidget* parent) , checkable(false) , checked(false) , radio_button(false) - , dialog_list(false) + , dialog_index(false) , text_length(0) , hotkey(0) , accel_key(0) @@ -80,7 +80,7 @@ FMenuItem::FMenuItem (const char* txt, FWidget* parent) , checkable(false) , checked(false) , radio_button(false) - , dialog_list(false) + , dialog_index(false) , text_length(0) , hotkey(0) , accel_key(0) @@ -99,7 +99,7 @@ FMenuItem::FMenuItem (int k, FString& txt, FWidget* parent) , checkable(false) , checked(false) , radio_button(false) - , dialog_list(false) + , dialog_index(false) , text_length(0) , hotkey(0) , accel_key(k) @@ -118,7 +118,7 @@ FMenuItem::FMenuItem (int k, const std::string& txt, FWidget* parent) , checkable(false) , checked(false) , radio_button(false) - , dialog_list(false) + , dialog_index(false) , text_length(0) , hotkey(0) , accel_key(k) @@ -137,7 +137,7 @@ FMenuItem::FMenuItem (int k, const char* txt, FWidget* parent) , checkable(false) , checked(false) , radio_button(false) - , dialog_list(false) + , dialog_index(false) , text_length(0) , hotkey(0) , accel_key(k) @@ -256,17 +256,14 @@ void FMenuItem::createDialogList (FMenu* winmenu) { winmenu->clear(); - if ( window_list && ! window_list->empty() ) + if ( dialog_list && ! dialog_list->empty() ) { - widgetList::const_iterator iter, begin; - iter = window_list->end(); - begin = window_list->begin(); + widgetList::const_iterator iter; + iter = dialog_list->begin(); - do + while ( iter != dialog_list->end() ) { - --iter; - - if ( (*iter)->isDialog() ) + if ( *iter && (*iter)->isDialog() ) { FDialog* win = dynamic_cast(*iter); @@ -283,8 +280,9 @@ void FMenuItem::createDialogList (FMenu* winmenu) ); } } + + ++iter; } - while ( iter != begin ); } winmenu->menu_dimension(); @@ -837,7 +835,7 @@ void FMenuItem::openMenu() open_menu->hideSubMenus(); } - if ( dialog_list ) + if ( dialog_index ) createDialogList (dd_menu); setOpenMenu(dd_menu); diff --git a/src/fmenuitem.h b/src/fmenuitem.h index 1004ae04..26b8e388 100644 --- a/src/fmenuitem.h +++ b/src/fmenuitem.h @@ -49,7 +49,7 @@ class FMenuItem : public FWidget bool checkable; bool checked; bool radio_button; - bool dialog_list; + bool dialog_index; uInt text_length; int hotkey; int accel_key; diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 9923de72..18db2cdf 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -18,6 +18,7 @@ FMenuBar* FWidget::menubar = 0; FWidget* FWidget::show_root_widget = 0; FWidget* FWidget::redraw_root_widget = 0; FWidget::widgetList* FWidget::window_list = 0; +FWidget::widgetList* FWidget::dialog_list = 0; FWidget::widgetList* FWidget::close_widget = 0; FWidget::widget_colors FWidget::wc; @@ -127,6 +128,7 @@ FWidget::~FWidget() // destructor void FWidget::init() { window_list = new widgetList(); + dialog_list = new widgetList(); close_widget = new widgetList(); getTermGeometry(); // <-----. @@ -178,6 +180,12 @@ void FWidget::finish() close_widget = 0; } + if ( dialog_list ) + { + delete dialog_list; + dialog_list = 0; + } + if ( window_list ) { delete window_list; diff --git a/src/fwidget.h b/src/fwidget.h index 1a93faa8..8bc7de58 100644 --- a/src/fwidget.h +++ b/src/fwidget.h @@ -92,6 +92,7 @@ class FWidget : public FObject, public FTerm public: typedef std::vector widgetList; static widgetList* window_list; + static widgetList* dialog_list; static widgetList* close_widget; typedef void (*FCallback)(FWidget*, void*); diff --git a/src/fwindow.cpp b/src/fwindow.cpp index ac1ba4c3..e1e3a493 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -143,21 +143,21 @@ void FWindow::addWindow (FWidget* obj) void FWindow::delWindow (FWidget* obj) { // delete the window object obj from the window list - if ( window_list && ! window_list->empty() ) + if ( ! window_list || window_list->empty() ) + return; + + widgetList::iterator iter; + iter = window_list->begin(); + + while ( iter != window_list->end() ) { - widgetList::iterator iter; - iter = window_list->begin(); - - while ( iter != window_list->end() ) + if ( (*iter) == obj ) { - if ( (*iter) == obj ) - { - window_list->erase(iter); - return; - } - - ++iter; + window_list->erase(iter); + return; } + + ++iter; } }