J GROSBOIS
2014-11-27 17:37:08 UTC
Dear Jeroen,
(1) layout frame on Windows
On X11 only control-widgets are sensitized for mouse inputs with flags
|= FLAG_ENABLED.
You can check with the sample below that frames are also sensitized for
mouse inputs on Windows platform without flags |= FLAG_ENABLED.
We should expect the same implementation on Windows and Linux.
(2) modal
Still with the same sample, I do not understand why the __FIX__macro is
necessary when running a modal window. If not, the parent of the dialog
box receive the event.
Maybe something is missing in the provided sample to avoid the disable()
and enable() calls in onLeftBtnRelease function.
/Jerome.
#include <fx.h>
#define __FIX__
//-------------------------------------------------
// MyView
//-------------------------------------------------
class MyView : public FXFrame
{
FXDECLARE(MyView)
public:
MyView(FXComposite* p, FXuint opts = FRAME_NORMAL, FXint x = 0,
FXint y = 0, FXint w = 0, FXint h = 0);
virtual ~MyView();
long onLeftBtnRelease(FXObject*, FXSelector, void* ptr);
protected:
MyView();
};
FXDEFMAP(MyView) MyViewMap[] =
{
FXMAPFUNC(SEL_LEFTBUTTONRELEASE, 0, MyView::onLeftBtnRelease),
};
FXIMPLEMENT(MyView, FXFrame, MyViewMap, ARRAYNUMBER(MyViewMap))
MyView::MyView(FXComposite* p, FXuint opts, FXint x, FXint y, FXint w,
FXint h) :
FXFrame(p, opts, x, y, w, h)
{
#ifdef _WIN32
FXASSERT(flags& FLAG_ENABLED != FLAG_ENABLED);
#else
flags |= FLAG_ENABLED ;
#endif
}
MyView::MyView()
{
}
MyView::~MyView()
{
}
long MyView::onLeftBtnRelease(FXObject*, FXSelector, void* ptr)
{
#ifdef __FIX__
this->disable();
#endif
FXColorDialog colordialog(this, tr("Color Dialog"));
colordialog.setRGBA(this->getBackColor());
colordialog.setOpaqueOnly(TRUE);
if ( colordialog.execute() )
{
this->setBackColor(colordialog.getRGBA());
}
#ifdef __FIX__
this->enable();
#endif
return 1;
}
//-------------------------------------------------
// MyMainWindow
//-------------------------------------------------
class MyMainWindow : public FXMainWindow
{
FXDECLARE(MyMainWindow)
public:
MyMainWindow(FXApp *app);
virtual void create();
virtual ~MyMainWindow();
private:
MyMainWindow(){}
MyMainWindow(const MyMainWindow&);
MyMainWindow& operator=(const MyMainWindow&);
MyView* _view;
};
FXIMPLEMENT(MyMainWindow, FXMainWindow, NULL, 0)
// Make some windows
MyMainWindow::MyMainWindow(FXApp *app) :FXMainWindow(app, "Test", NULL,
NULL, DECOR_ALL, 0, 0, 900, 820)
{
// Tooltip
new FXToolTip(getApp());
// inner frame
_view = new MyView(this, FRAME_NONE | LAYOUT_FILL_X |
LAYOUT_FILL_Y, 0, 0, 0, 0);
_view->setBackColor(FXRGB(255, 0, 0));
}
MyMainWindow::~MyMainWindow()
{
}
void MyMainWindow::create()
{
FXMainWindow::create();
this->show(PLACEMENT_SCREEN);
}
int main(int argc, char *argv[])
{
FXApp application("Frame event", "Frame event");
application.init(argc, argv);
MyMainWindow* mainWindow = new MyMainWindow(&application);
application.create();
return application.run();
}
(1) layout frame on Windows
On X11 only control-widgets are sensitized for mouse inputs with flags
|= FLAG_ENABLED.
You can check with the sample below that frames are also sensitized for
mouse inputs on Windows platform without flags |= FLAG_ENABLED.
We should expect the same implementation on Windows and Linux.
(2) modal
Still with the same sample, I do not understand why the __FIX__macro is
necessary when running a modal window. If not, the parent of the dialog
box receive the event.
Maybe something is missing in the provided sample to avoid the disable()
and enable() calls in onLeftBtnRelease function.
/Jerome.
#include <fx.h>
#define __FIX__
//-------------------------------------------------
// MyView
//-------------------------------------------------
class MyView : public FXFrame
{
FXDECLARE(MyView)
public:
MyView(FXComposite* p, FXuint opts = FRAME_NORMAL, FXint x = 0,
FXint y = 0, FXint w = 0, FXint h = 0);
virtual ~MyView();
long onLeftBtnRelease(FXObject*, FXSelector, void* ptr);
protected:
MyView();
};
FXDEFMAP(MyView) MyViewMap[] =
{
FXMAPFUNC(SEL_LEFTBUTTONRELEASE, 0, MyView::onLeftBtnRelease),
};
FXIMPLEMENT(MyView, FXFrame, MyViewMap, ARRAYNUMBER(MyViewMap))
MyView::MyView(FXComposite* p, FXuint opts, FXint x, FXint y, FXint w,
FXint h) :
FXFrame(p, opts, x, y, w, h)
{
#ifdef _WIN32
FXASSERT(flags& FLAG_ENABLED != FLAG_ENABLED);
#else
flags |= FLAG_ENABLED ;
#endif
}
MyView::MyView()
{
}
MyView::~MyView()
{
}
long MyView::onLeftBtnRelease(FXObject*, FXSelector, void* ptr)
{
#ifdef __FIX__
this->disable();
#endif
FXColorDialog colordialog(this, tr("Color Dialog"));
colordialog.setRGBA(this->getBackColor());
colordialog.setOpaqueOnly(TRUE);
if ( colordialog.execute() )
{
this->setBackColor(colordialog.getRGBA());
}
#ifdef __FIX__
this->enable();
#endif
return 1;
}
//-------------------------------------------------
// MyMainWindow
//-------------------------------------------------
class MyMainWindow : public FXMainWindow
{
FXDECLARE(MyMainWindow)
public:
MyMainWindow(FXApp *app);
virtual void create();
virtual ~MyMainWindow();
private:
MyMainWindow(){}
MyMainWindow(const MyMainWindow&);
MyMainWindow& operator=(const MyMainWindow&);
MyView* _view;
};
FXIMPLEMENT(MyMainWindow, FXMainWindow, NULL, 0)
// Make some windows
MyMainWindow::MyMainWindow(FXApp *app) :FXMainWindow(app, "Test", NULL,
NULL, DECOR_ALL, 0, 0, 900, 820)
{
// Tooltip
new FXToolTip(getApp());
// inner frame
_view = new MyView(this, FRAME_NONE | LAYOUT_FILL_X |
LAYOUT_FILL_Y, 0, 0, 0, 0);
_view->setBackColor(FXRGB(255, 0, 0));
}
MyMainWindow::~MyMainWindow()
{
}
void MyMainWindow::create()
{
FXMainWindow::create();
this->show(PLACEMENT_SCREEN);
}
int main(int argc, char *argv[])
{
FXApp application("Frame event", "Frame event");
application.init(argc, argv);
MyMainWindow* mainWindow = new MyMainWindow(&application);
application.create();
return application.run();
}