Discussion:
[Foxgui-users] FLAG_ENABLED on Windows
J GROSBOIS
2014-11-27 17:37:08 UTC
Permalink
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();
}
J GROSBOIS
2016-05-12 08:01:45 UTC
Permalink
Dear Jeroen,


*(1) issue description*
On Windows, layout managers are sensitized for mouse inputs (here a
vertical frame in the test program below) . One can expect that only
control-widgets are sensitized for mouse inputs.
On X11, implementation is correct: layout managers are not sensitized
for mouse inputs.

This is the test program to reproduce the issue:

#include <fx.h>

class FXTestFrame : public FXVerticalFrame
{
FXDECLARE(FXTestFrame)
public:
FXTestFrame(FXComposite* p, FXuint opts = FRAME_NORMAL, FXint x =
0, FXint y = 0, FXint w = 0, FXint h = 0);

long onLeftBtnPress(FXObject*, FXSelector, void*);
private:
FXTestFrame();
};

FXDEFMAP(FXTestFrame) FXTestViewMap[] =
{
FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, FXTestFrame::onLeftBtnPress),
};

FXIMPLEMENT(FXTestFrame, FXVerticalFrame, FXTestViewMap,
ARRAYNUMBER(FXTestViewMap))


FXTestFrame::FXTestFrame()
{
}

FXTestFrame::FXTestFrame(FXComposite* p, FXuint opts, FXint x, FXint y,
FXint w, FXint h) :
FXVerticalFrame(p, opts, x, y, w, h)
{
}


long FXTestFrame::onLeftBtnPress(FXObject*, FXSelector, void* ptr)
{
FXEvent* event = (FXEvent*)ptr;
FXMessageBox::error(this, MBOX_OK, "info", "Unexpected Left Btn
Press event");
return 1;
}

int main(int argc, char* argv[])
{
FXApp application("Test", "FoxTest");
application.init(argc, argv);
FXMainWindow *main = new FXMainWindow(&application, "test", NULL,
NULL, DECOR_ALL, 600, 200);
main->setHeight(200);
main->setWidth(200);
FXTestFrame* myFrame = new FXTestFrame(main, LAYOUT_FILL_X |
LAYOUT_FILL_Y);
myFrame->setBackColor(FXRGB(128, 64, 0));
application.create();
main->show(PLACEMENT_SCREEN);
return application.run();
}

*(2) correction*
You will find below the correction. On Windows, a newly created window
is enabled by default.

void FXWindow::create(){
// X11
...
// If enabled, turn on some more events
if(flags&FLAG_ENABLED) wattr.event_mask|=ENABLED_EVENT_MASK;
...

// Windows
...
// Create this window
xid=CreateWindowExA(
...
// correction: a newly created window is enabled, disable it if not
enabled
if( ! (flags&FLAG_ENABLED ))
EnableWindow((HWND)xid, FALSE);

if(flags&FLAG_SHOWN)
ShowWindow((HWND)xid,SW_SHOWNOACTIVATE);
else
ShowWindow((HWND)xid,SW_HIDE);


Could you confirm that the correction will be integrated in the next
release?

Regards,
/Jerome.
Post by J GROSBOIS
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)
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);
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,
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)
MyMainWindow(FXApp *app);
virtual void create();
virtual ~MyMainWindow();
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();
}
JVZ
2016-05-12 13:34:05 UTC
Permalink
On Thu, 12 May 2016 10:01:45 +0200
Post by J GROSBOIS
Dear Jeroen,
*(1) issue description*
On Windows, layout managers are sensitized for mouse inputs (here a
vertical frame in the test program below) . One can expect that only
control-widgets are sensitized for mouse inputs.
On X11, implementation is correct: layout managers are not sensitized
for mouse inputs.
#include <fx.h>
class FXTestFrame : public FXVerticalFrame
{
FXDECLARE(FXTestFrame)
FXTestFrame(FXComposite* p, FXuint opts = FRAME_NORMAL, FXint x =
0, FXint y = 0, FXint w = 0, FXint h = 0);
long onLeftBtnPress(FXObject*, FXSelector, void*);
FXTestFrame();
};
FXDEFMAP(FXTestFrame) FXTestViewMap[] =
{
FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, FXTestFrame::onLeftBtnPress),
};
FXIMPLEMENT(FXTestFrame, FXVerticalFrame, FXTestViewMap,
ARRAYNUMBER(FXTestViewMap))
FXTestFrame::FXTestFrame()
{
}
FXTestFrame::FXTestFrame(FXComposite* p, FXuint opts, FXint x, FXint y,
FXVerticalFrame(p, opts, x, y, w, h)
{
}
long FXTestFrame::onLeftBtnPress(FXObject*, FXSelector, void* ptr)
{
FXEvent* event = (FXEvent*)ptr;
FXMessageBox::error(this, MBOX_OK, "info", "Unexpected Left Btn
Press event");
return 1;
}
int main(int argc, char* argv[])
{
FXApp application("Test", "FoxTest");
application.init(argc, argv);
FXMainWindow *main = new FXMainWindow(&application, "test", NULL,
NULL, DECOR_ALL, 600, 200);
main->setHeight(200);
main->setWidth(200);
FXTestFrame* myFrame = new FXTestFrame(main, LAYOUT_FILL_X |
LAYOUT_FILL_Y);
myFrame->setBackColor(FXRGB(128, 64, 0));
application.create();
main->show(PLACEMENT_SCREEN);
return application.run();
}
*(2) correction*
You will find below the correction. On Windows, a newly created window
is enabled by default.
void FXWindow::create(){
// X11
...
// If enabled, turn on some more events
if(flags&FLAG_ENABLED) wattr.event_mask|=ENABLED_EVENT_MASK;
...
// Windows
...
// Create this window
xid=CreateWindowExA(
...
// correction: a newly created window is enabled, disable it if not
enabled
if( ! (flags&FLAG_ENABLED ))
EnableWindow((HWND)xid, FALSE);
if(flags&FLAG_SHOWN)
ShowWindow((HWND)xid,SW_SHOWNOACTIVATE);
else
ShowWindow((HWND)xid,SW_HIDE);
Could you confirm that the correction will be integrated in the next
release?
OK, applied your patch.

When a window is disabled, it could not be located with WindowFromPoint();
we're not using WindowFromPoint() anymore so its OK to disable windows now.

Thanks for the info!


Regards,

-- JVZ



+----------------------------------------------------------------------------+
| Copyright (C) 08:30 05/12/2016 Jeroen van der Zijp. All Rights Reserved. |
+----------------------------------------------------------------------------+
Continue reading on narkive:
Loading...