Remove dialog list item callback from the associated dialog window
This commit is contained in:
parent
9b7918f2f6
commit
d5685aaafc
|
@ -1,5 +1,6 @@
|
||||||
2016-07-30 Markus Gans <guru.mail@muenster.de>
|
2016-07-30 Markus Gans <guru.mail@muenster.de>
|
||||||
* Delete all callbacks from a widget, when it will be destroyed
|
* Delete all callbacks from a widget with delCallbacks()
|
||||||
|
* Remove dialog list item callback from the associated window
|
||||||
|
|
||||||
2016-07-28 Markus Gans <guru.mail@muenster.de>
|
2016-07-28 Markus Gans <guru.mail@muenster.de>
|
||||||
* Improvements for the window focus
|
* Improvements for the window focus
|
||||||
|
|
|
@ -31,7 +31,8 @@ std::deque<FApplication::eventPair>* FApplication::event_queue = 0;
|
||||||
// constructors and destructor
|
// constructors and destructor
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FApplication::FApplication (int& _argc, char**& _argv)
|
FApplication::FApplication (int& _argc, char**& _argv)
|
||||||
: app_argc(_argc)
|
: FWidget(0)
|
||||||
|
, app_argc(_argc)
|
||||||
, app_argv(_argv)
|
, app_argv(_argv)
|
||||||
, skipped_terminal_update(0)
|
, skipped_terminal_update(0)
|
||||||
, key(0)
|
, key(0)
|
||||||
|
|
|
@ -29,6 +29,7 @@ FMenuItem::FMenuItem (FWidget* parent)
|
||||||
, accel_key(0)
|
, accel_key(0)
|
||||||
, menu(0)
|
, menu(0)
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
|
, associated_window(0)
|
||||||
{
|
{
|
||||||
init (parent);
|
init (parent);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +49,7 @@ FMenuItem::FMenuItem (FString& txt, FWidget* parent)
|
||||||
, accel_key(0)
|
, accel_key(0)
|
||||||
, menu(0)
|
, menu(0)
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
|
, associated_window(0)
|
||||||
{
|
{
|
||||||
init (parent);
|
init (parent);
|
||||||
}
|
}
|
||||||
|
@ -67,6 +69,7 @@ FMenuItem::FMenuItem (const std::string& txt, FWidget* parent)
|
||||||
, accel_key(0)
|
, accel_key(0)
|
||||||
, menu(0)
|
, menu(0)
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
|
, associated_window(0)
|
||||||
{
|
{
|
||||||
init (parent);
|
init (parent);
|
||||||
}
|
}
|
||||||
|
@ -86,6 +89,7 @@ FMenuItem::FMenuItem (const char* txt, FWidget* parent)
|
||||||
, accel_key(0)
|
, accel_key(0)
|
||||||
, menu(0)
|
, menu(0)
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
|
, associated_window(0)
|
||||||
{
|
{
|
||||||
init (parent);
|
init (parent);
|
||||||
}
|
}
|
||||||
|
@ -105,6 +109,7 @@ FMenuItem::FMenuItem (int k, FString& txt, FWidget* parent)
|
||||||
, accel_key(k)
|
, accel_key(k)
|
||||||
, menu(0)
|
, menu(0)
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
|
, associated_window(0)
|
||||||
{
|
{
|
||||||
init (parent);
|
init (parent);
|
||||||
}
|
}
|
||||||
|
@ -124,6 +129,7 @@ FMenuItem::FMenuItem (int k, const std::string& txt, FWidget* parent)
|
||||||
, accel_key(k)
|
, accel_key(k)
|
||||||
, menu(0)
|
, menu(0)
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
|
, associated_window(0)
|
||||||
{
|
{
|
||||||
init (parent);
|
init (parent);
|
||||||
}
|
}
|
||||||
|
@ -143,6 +149,7 @@ FMenuItem::FMenuItem (int k, const char* txt, FWidget* parent)
|
||||||
, accel_key(k)
|
, accel_key(k)
|
||||||
, menu(0)
|
, menu(0)
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
|
, associated_window(0)
|
||||||
{
|
{
|
||||||
init (parent);
|
init (parent);
|
||||||
}
|
}
|
||||||
|
@ -151,6 +158,10 @@ FMenuItem::FMenuItem (int k, const char* txt, FWidget* parent)
|
||||||
FMenuItem::~FMenuItem() // destructor
|
FMenuItem::~FMenuItem() // destructor
|
||||||
{
|
{
|
||||||
delAccelerator();
|
delAccelerator();
|
||||||
|
|
||||||
|
// remove dialog list item callback from the dialog
|
||||||
|
if ( associated_window )
|
||||||
|
associated_window->delCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -268,8 +279,10 @@ void FMenuItem::createDialogList (FMenu* winmenu)
|
||||||
if ( win )
|
if ( win )
|
||||||
{
|
{
|
||||||
int n = int(std::distance(begin, iter));
|
int n = int(std::distance(begin, iter));
|
||||||
FString win_title = win->getText();
|
// get the dialog title
|
||||||
FMenuItem* win_item = new FMenuItem (win_title, winmenu);
|
FString name = win->getText();
|
||||||
|
// create a new dialog list item
|
||||||
|
FMenuItem* win_item = new FMenuItem (name, winmenu);
|
||||||
|
|
||||||
if ( n < 9 )
|
if ( n < 9 )
|
||||||
win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9
|
win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9
|
||||||
|
@ -277,16 +290,17 @@ void FMenuItem::createDialogList (FMenu* winmenu)
|
||||||
win_item->addCallback
|
win_item->addCallback
|
||||||
(
|
(
|
||||||
"clicked",
|
"clicked",
|
||||||
_METHOD_CALLBACK (this, &FMenuItem::cb_switchToDialog),
|
_METHOD_CALLBACK (win_item, &FMenuItem::cb_switchToDialog),
|
||||||
dynamic_cast<FWidget::data_ptr>(win)
|
dynamic_cast<FWidget::data_ptr>(win)
|
||||||
);
|
);
|
||||||
|
|
||||||
win->addCallback
|
win->addCallback
|
||||||
(
|
(
|
||||||
"destroy",
|
"destroy",
|
||||||
_METHOD_CALLBACK (this, &FMenuItem::cb_destroyDialog),
|
_METHOD_CALLBACK (win_item, &FMenuItem::cb_destroyDialog)
|
||||||
static_cast<FWidget::data_ptr>(win_item)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
win_item->associated_window = win;
|
||||||
}
|
}
|
||||||
|
|
||||||
++iter;
|
++iter;
|
||||||
|
@ -310,16 +324,16 @@ void FMenuItem::cb_switchToDialog (FWidget*, void* data_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenuItem::cb_destroyDialog (FWidget* widget, void* data_ptr)
|
void FMenuItem::cb_destroyDialog (FWidget* widget, void*)
|
||||||
{
|
{
|
||||||
FDialog* win = static_cast<FDialog*>(widget);
|
FDialog* win = static_cast<FDialog*>(widget);
|
||||||
FMenuItem* win_item = static_cast<FMenuItem*>(data_ptr);
|
|
||||||
FApplication* fapp = static_cast<FApplication*>(getRootWidget());
|
FApplication* fapp = static_cast<FApplication*>(getRootWidget());
|
||||||
|
|
||||||
if ( win_item && win && fapp && ! fapp->isQuit() )
|
if ( win && fapp )
|
||||||
{
|
{
|
||||||
win_item->delAccelerator(win);
|
delAccelerator(win);
|
||||||
win_item->delCallback(this);
|
delCallback(win);
|
||||||
|
associated_window = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#include "fwidget.h"
|
#include "fwidget.h"
|
||||||
|
|
||||||
|
class FDialog;
|
||||||
class FMenu;
|
class FMenu;
|
||||||
class FMenuList;
|
class FMenuList;
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ class FMenuItem : public FWidget
|
||||||
int accel_key;
|
int accel_key;
|
||||||
FMenu* menu;
|
FMenu* menu;
|
||||||
FWidget* super_menu;
|
FWidget* super_menu;
|
||||||
|
FDialog* associated_window;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FMenuItem (const FMenuItem&);
|
FMenuItem (const FMenuItem&);
|
||||||
|
|
|
@ -103,7 +103,6 @@ FWidget::FWidget (FWidget* parent)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FWidget::~FWidget() // destructor
|
FWidget::~FWidget() // destructor
|
||||||
{
|
{
|
||||||
delCallbacks();
|
|
||||||
processDestroy();
|
processDestroy();
|
||||||
FApplication::removeQueuedEvent(this);
|
FApplication::removeQueuedEvent(this);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue