Kirix Support Forums

Why are floating panels defined with Dock set?

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

Why are floating panels defined with Dock set?

Postby NinjaNL on Tue Dec 04, 2007 3:00 am

When I define a floating pane (try this with the aui demo, there is then no need to change any code) I test for IsFloating on a pane and it always returns FALSE.

I see that in floatpane.cpp line 89

Code: Select all
    contained_pane.Dock().Center().Show().
                    CaptionVisible(false).
                    PaneBorder(false).
                    Layer(0).Row(0).Position(0);



The .Dock() here causes IsFloating to return False.

Could someone help me out with the reasoning behind this? Or is this an error/oversight?

This means IIUC that any floating pane is actually a docked pane, and I then need to do something like
Code: Select all
if(contained_pane->GetContainingWindow()->IsKindOf(CLASSINFO(wxAuiFloatingFrame)))
to actually detect whether it is a floating pane or not.

Thanks
Mal
NinjaNL
Registered User
 
Posts: 40
Joined: Thu Jun 14, 2007 6:53 am

Re: Why are floating panels defined with Dock set?

Postby Ben on Wed Dec 05, 2007 2:04 am

Hello,

Dock() is the opposite of Float(). Internally, there is only one flag used to indicate whether the pane is floating or not.

Are you calling IsFloating() before the wxAuiFrameManager::Update() command, or after? After Dock() is called, IsFloating() should return false. However, this may not be realized on screen until the frame manager is updated.

Please let me know.

Thanks,
Ben
Ben Williams
Kirix Support Team
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Re: Why are floating panels defined with Dock set?

Postby NinjaNL on Wed Dec 05, 2007 8:05 am

So the problem is one of my understanding. I assumed that a pane in a floating frame would be a floating pane.

So could you explain exactly when a floating pane is a floating pane? (IsFloating() = true)

Thanks
Mal
NinjaNL
Registered User
 
Posts: 40
Joined: Thu Jun 14, 2007 6:53 am

Re: Why are floating panels defined with Dock set?

Postby Ben on Thu Dec 06, 2007 9:14 am

The IsFloating() function is a way of determining if Float() has been called. When Float() is called, this indicates that upon the next Update() of the frame manager, the window will be removed from the docking scheme and floated (as a mini frame window)

So calling Float() doesn't actually immediately cause the pane to immediately become a mini frame -- this happens when Update() is called after setting Float() on a pane.

Best,
Ben
Ben Williams
Kirix Support Team
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Re: Why are floating panels defined with Dock set?

Postby NinjaNL on Thu Dec 06, 2007 1:39 pm

So, assuming my caffeine levels are at optimum,

Float() means "dock into a floating pane on next update"

IsFloating() means "see if we are waiting to be docked into a floating pane on next update"

and the way to see if a pane is REALLY floating is to check for whether its parent frame is a wxAuiFloatingFrame
if(part->cont_sizer->GetContainingWindow()->IsKindOf(CLASSINFO(wxAuiFloatingFrame))) (http://www.kirix.com/forums/viewtopic.php?f=16&t=588 my solution for the bad gripper problem)
??

Or do I need more coffee?

Mal
NinjaNL
Registered User
 
Posts: 40
Joined: Thu Jun 14, 2007 6:53 am

Re: Why are floating panels defined with Dock set?

Postby Ben on Fri Dec 07, 2007 10:42 am

Hello,

Yes, the definitions you specify are right. Although, normally the time between calling Float() and Update() isn't so significant.

Instead of the more complicated RTTI code you specify (which will work), you can also just check the pane info's 'frame' member variable.

Code: Select all
if (pane_info.frame)
{
    // pane if floating
}
else
{
    // pane is not floating
}
Ben Williams
Kirix Support Team
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Re: Why are floating panels defined with Dock set?

Postby NinjaNL on Fri Dec 07, 2007 3:36 pm

I don't want to sound picky, but I couldn't get your code to work correctly, although I may have been looking at the wrong place. A little history:

I was investigating this http://sourceforge.net/tracker/index.php?func=detail&aid=1606167&group_id=9863&atid=109863 bug report, and having built a debug version of wxWidgets 2.8.7, I fired up the auidemo project. In any case I added the aui library as a part of the project, so that I could step through the code to see what was happening where.

The above mentioned bug was traced (I believe) to line 3833 of framemanager.cpp
Code: Select all
         else if (part->type == wxAuiDockUIPart::typeGripper)
        {
         cursor = wxCursor(wxCURSOR_SIZING);
        }

This simply checks to see if the mouse is over a gripper. The bug suggests that when the pane is floating (that is contained within a wxAuiFloatingFrame) then the mouse cursor should not change to the wxCURSOR_SIZING shaped cursor (since it has no function here - the frame alone should be used). It took me a while, but the result of my investigations was to change the code to
Code: Select all
         else if (part->type == wxAuiDockUIPart::typeGripper)
        {
            if(!part->cont_sizer->GetContainingWindow()->IsKindOf(CLASSINFO(wxAuiFloatingFrame)))
                cursor = wxCursor(wxCURSOR_SIZING);
        }

This has the result that when the gripper is contained within a wxAuiFloatingFrame the mouse cursor remains unchanged, however will indeed change when the gripper pane is docked within the main frame (checked with auidemo).

Now as to your code, I adapted it slightly so that the code looks like
Code: Select all
         else if (part->type == wxAuiDockUIPart::typeGripper)
        {
         bool showcursor = part->pane->frame;
         cursor = wxCursor(wxCURSOR_SIZING);
        }

This code will return false whether the pane is docked or not.

OR have I missed something obvious here? (and quite probably so painfully obvious to a beginner that I should just hang my head in shame and try to stop fixing someone else's bugs and take a beginners course in C++ programming)

Thanks
Mal
NinjaNL
Registered User
 
Posts: 40
Joined: Thu Jun 14, 2007 6:53 am

Re: Why are floating panels defined with Dock set?

Postby Ben on Sat Dec 08, 2007 5:03 pm

I know why that code is not working. It's something that I forgot about, but is still completely necessary.

Each top level window has it's own wxAuiManager instance. This allows us to do nifty things like placing pane elements such as captions and grippers in floating windows.

Do a little experiment: Place a break point in the original manager, and then in the location with the cursor setting. I think that you'll find that the two manager pointers are different.

The pane element you are accessing there is actually a copy of the original. See wxAuiFloatingFrame::SetPaneWindow to see how this is done. This is what is causing every discrepancy between what I have said and what you have noted (e.g. the frame being always null, or also why things appear to be docked when they are really floated -- they actually _are_ docked, from the floating window's perspective).

I see that there is no convenient way of discovering the pointer of the 'owner manager' in this case. This is regrettable, but not all too serious. At present, I see no other way to do it than the way you have suggested. Long term I might suggest that we add some mechanism to getting the owner manager.

I hope that clears things up. Any thoughts/comments/questions?

Best,
Ben
Ben Williams
Kirix Support Team
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Re: Why are floating panels defined with Dock set?

Postby NinjaNL on Sun Dec 09, 2007 6:00 am

Ben wrote:I know why that code is not working. It's something that I forgot about, but is still completely necessary.
So you're saying that there are things in wxAUI that aren't? :D

Ben wrote:<SNIP>This is what is causing every discrepancy between what I have said and what you have noted (e.g. the frame being always null, or also why things appear to be docked when they are really floated -- they actually _are_ docked, from the floating window's perspective).
Yeah, I thought that that would be the reasoning. That's why I ended up with that rather long piece of code. In effect it could/should be placed in it's own function bool IsInFloatingFrame(pane) or something like it, which would be a lot simpler to read (if (IsInFloatingFrame(pane) ...) .

Ben wrote:At present, I see no other way to do it than the way you have suggested.
That's a relief.

Ben wrote:Long term I might suggest that we add some mechanism to getting the owner manager.
Sounds good, especially if it would simplify the code (in any case as far as reading the code goes).

Ben wrote:I hope that clears things up.
Indeed

Ben wrote: Any thoughts/comments/questions?
Loads, but I think what you have said has cleared this thread up, and my understanding of the wxAUI mechanism is slightly better.

Thanks for the time and effort.

Mal
NinjaNL
Registered User
 
Posts: 40
Joined: Thu Jun 14, 2007 6:53 am

Return to wxAUI Questions, Thoughts & Feedback