Thread: Some wx behavior questions

Some wx behavior questions

From
John McCawley
Date:
If you guys would rather I direct my wx related questions to the
wxWindows project let me know, but I would prefer to be active here
since my project's purpose is closely related to pgAdmin.

I like the default behavior of FLTK windows, and I would like to emulate
this in wxWindows.  I want the escape key to close the current window
(of course, prompting if the window is dirty) for all of my windows.
However, I have not figured out how to do a global event handler for a
Window.  i.e. if a textbox is currently active on the window, the parent
window will not receive the escape keypress event unless I explicitly
pass the event up from the textbox.  I would like some sort of way to
tell every one of my widgets "if you do not process this keyboard event,
pass it up to the parent window".

Is there a way to do this without explicitly creating an event handler
for every single widget I add to the window?

John


Re: Some wx behavior questions

From
Andreas Pflug
Date:
John McCawley wrote:

> If you guys would rather I direct my wx related questions to the
> wxWindows project let me know, but I would prefer to be active here
> since my project's purpose is closely related to pgAdmin.
>
> I like the default behavior of FLTK windows, and I would like to
> emulate this in wxWindows.  I want the escape key to close the current
> window (of course, prompting if the window is dirty) for all of my
> windows.

We should have this in pga also.

>   However, I have not figured out how to do a global event handler for
> a Window.  i.e. if a textbox is currently active on the window, the
> parent window will not receive the escape keypress event unless I
> explicitly pass the event up from the textbox.  I would like some sort
> of way to tell every one of my widgets "if you do not process this
> keyboard event, pass it up to the parent window".
>
> Is there a way to do this without explicitly creating an event handler
> for every single widget I add to the window?

You could try accelerator tables. But be careful: e.g. a combobox will
sometimes have to handle esc, you may not catch all escapes. I doubt
that you can handle this globally.

Regards,
Andreas



Re: Some wx behavior questions

From
"Dave Page"
Date:

> -----Original Message-----
> From: John McCawley [mailto:jmccawley@worleyco.com]
> Sent: 21 November 2003 15:37
> To: pgadmin-hackers@postgresql.org
> Subject: [pgadmin-hackers] Some wx behavior questions
>
> If you guys would rather I direct my wx related questions to
> the wxWindows project let me know, but I would prefer to be
> active here since my project's purpose is closely related to pgAdmin.

Hi John,

Please feel free to ask your questions here, I can't speak for everyone,
but certainly the main dev team will always help out where possible.
That said, the wx guys do know more about their code than we do, so you
may benefit more from asking them (though the one and only time I tried
this the silent response was deafening :-( ).

As for this particular problem, a few thoughts spring to mind (haven't
investigated the feasibility though):

- Set an access key on your Cancel button/Exit menu option

- wxCommandEvents are recursively applied to the parent windows event
handler. If you derive your own text control, can you catch the keypress
and raise your own wxCommandEvent?

- Derive your own controls and override the OnChar event handler (as
above) but this time call a public exit() method in the parent
frame/dialogue.

I would add that I would be hesitant to put code based on the second two
ideas in the pgAdmin tree as it would likely be a lot of extra classes
that implement a 'nicety' not in the rest of the code.

Regards, Dave.

Another wx behavior question

From
John McCawley
Date:
I have done a ton of work on pgDesigner, and I'm almost ready for a 1.0
release.  I decided to compile a Windows binary, but I am getting the
following compile error when compiling under MSVC 6 (Note: it compiles
and runs fine under Linux)

error C2440: 'type case' : cannot convert from 'void
(__thiscall_CDiagramWindow::*)(void)' to 'void (__thiscall
wxEvtHandler::*)(class wxCommandEvent &)'

I only get this on EVT_PAINT and EVT_MENU events, but not in all
classes, just two of them.  Is there something flakey regarding MSVC and
event handlers?  All of my handlers are pretty vanilla.  The only thing
I can see is that one of the classes that isn't working uses multiple
inheritance.  However, the other one doesn't, and it still isn't working.

Below is one of the ones that isn't working:

class CDiagramWindow : public wxScrolledWindow {
public:
/* stuff */
private:
        DECLARE_DYNAMIC_CLASS(CDiagramWindow)
        DECLARE_EVENT_TABLE()
};

IMPLEMENT_DYNAMIC_CLASS(CDiagramWindow, wxScrolledWindow)

BEGIN_EVENT_TABLE(CDiagramWindow, wxScrolledWindow)
        EVT_CHAR(CDiagramWindow::OnChar)
        EVT_RIGHT_UP(CDiagramWindow::OnRightClick)
        EVT_LEFT_DOWN(CDiagramWindow::OnLeftDown)
        EVT_MENU(ID_NEW_TABLE, CDiagramWindow::OnNewTable)
        EVT_MENU(ID_SELECT_COLOR, CDiagramWindow::OnSelectColor)
        EVT_MENU(ID_DELETE_KEY, CDiagramWindow::OnDeleteKey)
        EVT_PAINT(CDiagramWindow::OnPaint)
        EVT_MOTION(CDiagramWindow::OnMotion)
END_EVENT_TABLE()




Re: Another wx behavior question

From
Andreas Pflug
Date:
John McCawley wrote:

> I have done a ton of work on pgDesigner, and I'm almost ready for a
> 1.0 release.  I decided to compile a Windows binary, but I am getting
> the following compile error when compiling under MSVC 6 (Note: it
> compiles and runs fine under Linux)
>
> error C2440: 'type case' : cannot convert from 'void
> (__thiscall_CDiagramWindow::*)(void)' to 'void (__thiscall
> wxEvtHandler::*)(class wxCommandEvent &)'
>
> I only get this on EVT_PAINT and EVT_MENU events, but not in all
> classes, just two of them.  Is there something flakey regarding MSVC
> and event handlers?  All of my handlers are pretty vanilla.  The only
> thing I can see is that one of the classes that isn't working uses
> multiple inheritance.  However, the other one doesn't, and it still
> isn't working.
>
> Below is one of the ones that isn't working:
>
> class CDiagramWindow : public wxScrolledWindow {
> public:
> /* stuff */
> private:
>        DECLARE_DYNAMIC_CLASS(CDiagramWindow)
>        DECLARE_EVENT_TABLE()
> };
>
> IMPLEMENT_DYNAMIC_CLASS(CDiagramWindow, wxScrolledWindow)
>
> BEGIN_EVENT_TABLE(CDiagramWindow, wxScrolledWindow)
>        EVT_CHAR(CDiagramWindow::OnChar)
>        EVT_RIGHT_UP(CDiagramWindow::OnRightClick)
>        EVT_LEFT_DOWN(CDiagramWindow::OnLeftDown)
>        EVT_MENU(ID_NEW_TABLE, CDiagramWindow::OnNewTable)
>        EVT_MENU(ID_SELECT_COLOR, CDiagramWindow::OnSelectColor)
>        EVT_MENU(ID_DELETE_KEY, CDiagramWindow::OnDeleteKey)
>        EVT_PAINT(CDiagramWindow::OnPaint)
>        EVT_MOTION(CDiagramWindow::OnMotion)
> END_EVENT_TABLE()


John, you really should post stuff like this on the wx lists....

Still, I have some suggestions to you.
First: It appears to me that you're defining event handler methods that
don't have an event& argument. This will lead to a major desaster if you
use another compiler. This might already cover your problem as well.
Second: If registering event handlers outside the event table, you will
need some casting, sometimes even multiple casts.

Regards,
Andreas