Adding a dialog list with the entries in the chronological order of the generation

This commit is contained in:
Markus Gans 2016-07-14 23:55:22 +02:00
parent 9ef3bd3243
commit ef201a1a33
9 changed files with 89 additions and 44 deletions

View File

@ -1,3 +1,7 @@
2016-07-14 Markus Gans <guru.mail@muenster.de>
* Adding a dialog list with the entries in the chronological
order of the generation
2016-07-13 Markus Gans <guru.mail@muenster.de>
* Bind accelerator key from the FMenuItem to the root widget

View File

@ -52,6 +52,7 @@ FDialog::~FDialog() // destructor
accelerator_list = 0;
activatePrevWindow();
delWindow(this);
delDialog(this);
fapp = static_cast<FApplication*>(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
//----------------------------------------------------------------------

View File

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

View File

@ -52,5 +52,5 @@ void FDialogListMenu::init()
FMenuItem* menuitem = getItem();
if ( menuitem )
menuitem->dialog_list = true;
menuitem->dialog_index = true;
}

View File

@ -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<FDialog*>(*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);

View File

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

View File

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

View File

@ -92,6 +92,7 @@ class FWidget : public FObject, public FTerm
public:
typedef std::vector<FWidget*> widgetList;
static widgetList* window_list;
static widgetList* dialog_list;
static widgetList* close_widget;
typedef void (*FCallback)(FWidget*, void*);

View File

@ -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;
}
}