Generalize mouse event passing in FMenuItem
This commit is contained in:
parent
8bc40459e0
commit
1435d9d362
|
@ -1,3 +1,6 @@
|
|||
2017-02-22 Markus Gans <guru.mail@muenster.de>
|
||||
* Generalize mouse event passing in FMenuItem
|
||||
|
||||
2017-02-19 Markus Gans <guru.mail@muenster.de>
|
||||
* Refactoring FTerm::init_termcaps
|
||||
* Refactoring FTerm::init_encoding
|
||||
|
|
|
@ -9,4 +9,4 @@ ACLOCAL_AMFLAGS = -I m4
|
|||
SUBDIRS = src fonts doc examples
|
||||
|
||||
docdir = ${datadir}/doc/${PACKAGE}
|
||||
doc_DATA = AUTHORS COPYING ChangeLog
|
||||
doc_DATA = AUTHORS COPYING COPYING.LESSER ChangeLog
|
||||
|
|
|
@ -85,8 +85,9 @@ host_triplet = @host@
|
|||
subdir = .
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(top_srcdir)/configure $(am__configure_deps) \
|
||||
$(srcdir)/config.h.in AUTHORS COPYING ChangeLog compile \
|
||||
config.guess config.sub depcomp install-sh missing ltmain.sh
|
||||
$(srcdir)/config.h.in AUTHORS COPYING COPYING.LESSER ChangeLog \
|
||||
compile config.guess config.sub depcomp install-sh missing \
|
||||
ltmain.sh
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prefix_config_h.m4 \
|
||||
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
|
||||
|
@ -354,7 +355,7 @@ top_srcdir = @top_srcdir@
|
|||
AUTOMAKE_OPTIONS = foreign
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
SUBDIRS = src fonts doc examples
|
||||
doc_DATA = AUTHORS COPYING ChangeLog
|
||||
doc_DATA = AUTHORS COPYING COPYING.LESSER ChangeLog
|
||||
all: config.h
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2017 Markus Gans *
|
||||
* Copyright 2015-2018 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
|
@ -169,6 +169,8 @@ class FMenuItem : public FWidget
|
|||
void processActivate();
|
||||
void processDeactivate();
|
||||
void createDialogList (FMenu*);
|
||||
template<class T>
|
||||
void passMouseEvent (T, FMouseEvent*, fc::events);
|
||||
|
||||
// Callback methods
|
||||
void cb_switchToDialog (FWidget*, data_ptr);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2017 Markus Gans *
|
||||
* Copyright 2015-2018 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
|
@ -341,72 +341,22 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
|
|||
if ( ! super_menu )
|
||||
return;
|
||||
|
||||
const FPoint& t = ev->getTermPos();
|
||||
int b = ev->getButton();
|
||||
|
||||
if ( isMenu(super_menu) )
|
||||
{
|
||||
FMenu* smenu = static_cast<FMenu*>(super_menu);
|
||||
const FPoint& p2 = smenu->termToWidgetPos(t);
|
||||
|
||||
try
|
||||
{
|
||||
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
|
||||
, p2, t, b );
|
||||
smenu->onMouseDoubleClick(_ev);
|
||||
delete _ev;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << "not enough memory to alloc "
|
||||
<< ex.what() << std::endl;
|
||||
}
|
||||
passMouseEvent (smenu, ev, fc::MouseDoubleClick_Event);
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
|
||||
|
||||
if ( mbar )
|
||||
{
|
||||
const FPoint& p2 = mbar->termToWidgetPos(t);
|
||||
|
||||
try
|
||||
{
|
||||
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
|
||||
, p2, t, b );
|
||||
mbar->onMouseDoubleClick(_ev);
|
||||
delete _ev;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << "not enough memory to alloc "
|
||||
<< ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
passMouseEvent (mbar, ev, fc::MouseDoubleClick_Event);
|
||||
}
|
||||
|
||||
if ( isWindowsMenu(super_menu) )
|
||||
{
|
||||
FDialog* dgl = static_cast<FDialog*>(super_menu);
|
||||
|
||||
if ( dgl )
|
||||
{
|
||||
const FPoint& p2 = dgl->termToWidgetPos(t);
|
||||
|
||||
try
|
||||
{
|
||||
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
|
||||
, p2, t, b );
|
||||
dgl->onMouseDoubleClick(_ev);
|
||||
delete _ev;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << "not enough memory to alloc "
|
||||
<< ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
passMouseEvent (dgl, ev, fc::MouseDoubleClick_Event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,72 +366,22 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
|
|||
if ( ! super_menu )
|
||||
return;
|
||||
|
||||
const FPoint& t = ev->getTermPos();
|
||||
int b = ev->getButton();
|
||||
|
||||
if ( isMenu(super_menu) )
|
||||
{
|
||||
FMenu* smenu = static_cast<FMenu*>(super_menu);
|
||||
const FPoint& p2 = smenu->termToWidgetPos(t);
|
||||
|
||||
try
|
||||
{
|
||||
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
|
||||
, p2, t, b );
|
||||
smenu->onMouseDown(_ev);
|
||||
delete _ev;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << "not enough memory to alloc "
|
||||
<< ex.what() << std::endl;
|
||||
}
|
||||
passMouseEvent (smenu, ev, fc::MouseDown_Event);
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
|
||||
|
||||
if ( mbar )
|
||||
{
|
||||
const FPoint& p2 = mbar->termToWidgetPos(t);
|
||||
|
||||
try
|
||||
{
|
||||
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
|
||||
, p2, t, b );
|
||||
mbar->onMouseDown(_ev);
|
||||
delete _ev;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << "not enough memory to alloc "
|
||||
<< ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
passMouseEvent (mbar, ev, fc::MouseDown_Event);
|
||||
}
|
||||
|
||||
if ( isWindowsMenu(super_menu) )
|
||||
{
|
||||
FDialog* dgl = static_cast<FDialog*>(super_menu);
|
||||
|
||||
if ( dgl )
|
||||
{
|
||||
const FPoint& p2 = dgl->termToWidgetPos(t);
|
||||
|
||||
try
|
||||
{
|
||||
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
|
||||
, p2, t, b );
|
||||
dgl->onMouseDown(_ev);
|
||||
delete _ev;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << "not enough memory to alloc "
|
||||
<< ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
passMouseEvent (dgl, ev, fc::MouseDown_Event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -491,34 +391,22 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
|
|||
if ( ! super_menu )
|
||||
return;
|
||||
|
||||
const FPoint& t = ev->getTermPos();
|
||||
int b = ev->getButton();
|
||||
|
||||
if ( isMenu(super_menu) )
|
||||
{
|
||||
FMenu* smenu = static_cast<FMenu*>(super_menu);
|
||||
const FPoint& p2 = smenu->termToWidgetPos(t);
|
||||
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
|
||||
smenu->onMouseUp(_ev);
|
||||
delete _ev;
|
||||
passMouseEvent (smenu, ev, fc::MouseUp_Event);
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
|
||||
const FPoint& p2 = mbar->termToWidgetPos(t);
|
||||
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
|
||||
mbar->onMouseUp(_ev);
|
||||
delete _ev;
|
||||
passMouseEvent (mbar, ev, fc::MouseUp_Event);
|
||||
}
|
||||
|
||||
if ( isWindowsMenu(super_menu) )
|
||||
{
|
||||
FDialog* dgl = static_cast<FDialog*>(super_menu);
|
||||
const FPoint& p2 = dgl->termToWidgetPos(t);
|
||||
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
|
||||
dgl->onMouseUp(_ev);
|
||||
delete _ev;
|
||||
passMouseEvent (dgl, ev, fc::MouseUp_Event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -528,34 +416,22 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
|
|||
if ( ! super_menu )
|
||||
return;
|
||||
|
||||
const FPoint& t = ev->getTermPos();
|
||||
int b = ev->getButton();
|
||||
|
||||
if ( isMenu(super_menu) )
|
||||
{
|
||||
FMenu* smenu = static_cast<FMenu*>(super_menu);
|
||||
const FPoint& p2 = smenu->termToWidgetPos(t);
|
||||
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
|
||||
smenu->onMouseMove(_ev);
|
||||
delete _ev;
|
||||
passMouseEvent (smenu, ev, fc::MouseMove_Event);
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
|
||||
const FPoint& p2 = mbar->termToWidgetPos(t);
|
||||
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
|
||||
mbar->onMouseMove(_ev);
|
||||
delete _ev;
|
||||
passMouseEvent (mbar, ev, fc::MouseMove_Event);
|
||||
}
|
||||
|
||||
if ( isWindowsMenu(super_menu) )
|
||||
{
|
||||
FDialog* dgl = static_cast<FDialog*>(super_menu);
|
||||
const FPoint& p2 = dgl->termToWidgetPos(t);
|
||||
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
|
||||
dgl->onMouseMove(_ev);
|
||||
delete _ev;
|
||||
passMouseEvent (dgl, ev, fc::MouseMove_Event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -817,6 +693,52 @@ void FMenuItem::createDialogList (FMenu* winmenu)
|
|||
winmenu->calculateDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
template<class T>
|
||||
void FMenuItem::passMouseEvent ( T widget, FMouseEvent* ev
|
||||
, fc::events ev_type )
|
||||
{
|
||||
if ( ! widget )
|
||||
return;
|
||||
|
||||
FMouseEvent* _ev;
|
||||
const FPoint& t = ev->getTermPos();
|
||||
const FPoint& p2 = widget->termToWidgetPos(t);
|
||||
int b = ev->getButton();
|
||||
|
||||
try
|
||||
{
|
||||
_ev = new FMouseEvent (ev_type, p2, t, b);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << "not enough memory to alloc "
|
||||
<< ex.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( int(ev_type) )
|
||||
{
|
||||
case fc::MouseDoubleClick_Event:
|
||||
widget->onMouseDoubleClick(_ev);
|
||||
break;
|
||||
|
||||
case fc::MouseDown_Event:
|
||||
widget->onMouseDown(_ev);
|
||||
break;
|
||||
|
||||
case fc::MouseUp_Event:
|
||||
widget->onMouseUp(_ev);
|
||||
break;
|
||||
|
||||
case fc::MouseMove_Event:
|
||||
widget->onMouseMove(_ev);
|
||||
break;
|
||||
}
|
||||
|
||||
delete _ev;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::cb_switchToDialog (FWidget*, data_ptr data)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue