lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Switching between wxNotebook and wxListbook


From: Greg Chicares
Subject: Re: [lmi] Switching between wxNotebook and wxListbook
Date: Thu, 20 Jul 2006 23:21:41 +0000
User-agent: Thunderbird 1.5.0.4 (Windows/20060516)

On 2006-7-20 2:22 UTC, Vadim Zeitlin wrote:
> On Thu, 20 Jul 2006 00:24:25 +0000 Greg Chicares <address@hidden> wrote:
> 
> GC> 1. Two simple text replacements:
> GC>   s/wxNotebook/wxBookCtrlBase/g
> GC>   s/#include <wx/notebook.h>/#include <wx/bookctrl.h>/
> GC> across all my '*.?pp' files were nearly sufficient. The only problem
> GC> I encountered was that there is no
> GC>   typedef wxWindow wxBookCtrlBasePage;
> GC> corresponding to wxNotebookPage.
> 
>  You can just use wxWindow instead of wxNotebookPage. I initially thought
> that there could be some restrictions on the notebook pages (e.g. that only
> wxPanel could be used) but this turned out to not be the case so this
> typedef is not very useful.

In case someone finds this message in a web search and would like
an automated way to apply the changes we're discussing, here's
what I used:

for z in *; do <$z >../some/other/directory/$z sed \
-e 's|wxNotebookPage|wxWindow|g' \
-e 's|wxNotebook|wxBookCtrlBase|g' \
-e 's|wxBookCtrl\([^B]\)|wxBookCtrlBase\1|g' \
-e 's|#include <wx/notebook.h>|#include <wx/bookctrl.h>|' \
; done

[Oops...and 's|NOTEBOOK|BOOKCTRL|g' is also necessary, for the
event macros.]

The tricky bit with the backreference is needed only if you've
already made your code more portable across platforms by using
class wxBookCtrl. If you've already used, say, wxListbook, then
that's simple to add to the script. Of course, layout might need
some manual adjustments.

And any '.xrc' files need to be protected from that script.
wxBookCtrlBase isn't a leaf class, so wxxrc can't possibly
handle it--there's no way to know which type of book to create.

> GC> 4. The wxListCtrl doesn't seem to size itself automatically to make
> GC> its contents fit, even if I widen the dialog. I'll email you a tiny
> GC> '.png' that shows this. I thought this might be a wxSplitterWindow
> GC> but couldn't find a "sash" to drag. Shouldn't wxxrc resize this?
> 
>  The list control currently doesn't resize after creation. I did think
> about using a splitter here but didn't do it for several reasons, the most
> important one being that it should work just fine without it anyhow, as the
> control should have correct size initially. But clearly this is not the
> case here...

Perhaps that's because I'm using wxxrc? I'm guessing that maybe
wxxrc involves an extra step, like
  (1) construct
  (2) call Create()...and initialize list control's size
  (3) call wxXmlResource::LoadDialog()...after setting size

> Could you please let me know how can I reproduce the bug? I
> don't see it in the notebook sample.

I observe the same problem with wxTreeBook, too.

I've committed the changes described above. You could just build
the 'skeleton' trunk (and manually change
  s|class="wxNotebook"|class="wxListbook"|
  s|class="notebookpage"|class="listbookpage"|
), but if that's a problem then we can try to figure out how to
reproduce it in the wx xrc sample.

BTW, here's a new problem that our automated GUI tests discovered:
Veto() doesn't seem to work with wxListbook or wxTreeBook. Here's
the handler:

  void MvcController::UponPageChanging(wxBookCtrlBaseEvent& event)
  {
    event.Skip();

    UpdateWindowUI();

    if(!Validate())
        {
        event.Skip(false);
        event.Veto();
        RefocusLastFocusedWindow();
        }
  }

and here's how it's connected (dynamically only--no static table):

    ::Connect
        (this
        ,wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING
        ,&MvcController::UponPageChanging
        ,XRCID(view_.BookControlName())
        );

I have a possible explanation for this. I call Validate() in two
different handlers, for these events:
  wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING
  wxEVT_CHILD_FOCUS
Perhaps notebook tabs are special in some way that the other book
controls' page-change controls aren't. Certainly I can change the
wxNotebook page from the keyboard without focusing the tab control.
The automated GUI tests don't ever simulate keyboard events--they
just call AdvanceSelection() directly--but maybe that call focuses
the tree or list control as a side effect? And maybe that means the
wxEVT_CHILD_FOCUS handler is called before the handler for
wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING? I don't know--this is just
speculation, and it doesn't seem very convincing.

Yet another concern with book controls other than wxNotebook is
that I can't see how to get back to the book page with the keyboard
after I've navigated to the page-selection control. Perhaps that is
related to this report, though:

  <http://savannah.nongnu.org/bugs/?func=detailitem&item_id=16847>

which, as you mentioned there, seems invalid. I think I'd better
resolve that problem separately first.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]