1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/ribbon/page.cpp
3 // Purpose: Container for ribbon-bar-style interface panels
4 // Author: Peter Cawley
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
17 #include "wx/ribbon/page.h"
21 #include "wx/ribbon/art.h"
22 #include "wx/ribbon/bar.h"
23 #include "wx/dcbuffer.h"
29 #include "wx/msw/private.h"
32 static int GetSizeInOrientation(wxSize size
, wxOrientation orientation
);
34 // As scroll buttons need to be rendered on top of a page's child windows, the
35 // buttons themselves have to be proper child windows (rather than just painted
36 // onto the page). In order to get proper clipping of a page's children (with
37 // regard to the scroll button), the scroll buttons are created as children of
38 // the ribbon bar rather than children of the page. This could not have been
39 // achieved by creating buttons as children of the page and then doing some Z-order
40 // manipulation, as this causes problems on win32 due to ribbon panels having the
41 // transparent flag set.
42 class wxRibbonPageScrollButton
: public wxRibbonControl
45 wxRibbonPageScrollButton(wxRibbonPage
* sibling
,
46 wxWindowID id
= wxID_ANY
,
47 const wxPoint
& pos
= wxDefaultPosition
,
48 const wxSize
& size
= wxDefaultSize
,
51 virtual ~wxRibbonPageScrollButton();
54 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
56 void OnEraseBackground(wxEraseEvent
& evt
);
57 void OnPaint(wxPaintEvent
& evt
);
58 void OnMouseEnter(wxMouseEvent
& evt
);
59 void OnMouseLeave(wxMouseEvent
& evt
);
60 void OnMouseDown(wxMouseEvent
& evt
);
61 void OnMouseUp(wxMouseEvent
& evt
);
63 wxRibbonPage
* m_sibling
;
66 DECLARE_CLASS(wxRibbonPageScrollButton
)
70 IMPLEMENT_CLASS(wxRibbonPageScrollButton
, wxRibbonControl
)
72 BEGIN_EVENT_TABLE(wxRibbonPageScrollButton
, wxRibbonControl
)
73 EVT_ENTER_WINDOW(wxRibbonPageScrollButton::OnMouseEnter
)
74 EVT_ERASE_BACKGROUND(wxRibbonPageScrollButton::OnEraseBackground
)
75 EVT_LEAVE_WINDOW(wxRibbonPageScrollButton::OnMouseLeave
)
76 EVT_LEFT_DOWN(wxRibbonPageScrollButton::OnMouseDown
)
77 EVT_LEFT_UP(wxRibbonPageScrollButton::OnMouseUp
)
78 EVT_PAINT(wxRibbonPageScrollButton::OnPaint
)
81 wxRibbonPageScrollButton::wxRibbonPageScrollButton(wxRibbonPage
* sibling
,
85 long style
) : wxRibbonControl(sibling
->GetParent(), id
, pos
, size
, wxBORDER_NONE
)
87 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
89 m_flags
= (style
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
) | wxRIBBON_SCROLL_BTN_FOR_PAGE
;
92 wxRibbonPageScrollButton::~wxRibbonPageScrollButton()
96 void wxRibbonPageScrollButton::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
))
98 // Do nothing - all painting done in main paint handler
101 void wxRibbonPageScrollButton::OnPaint(wxPaintEvent
& WXUNUSED(evt
))
103 wxAutoBufferedPaintDC
dc(this);
106 m_art
->DrawScrollButton(dc
, this, GetSize(), m_flags
);
110 void wxRibbonPageScrollButton::OnMouseEnter(wxMouseEvent
& WXUNUSED(evt
))
112 m_flags
|= wxRIBBON_SCROLL_BTN_HOVERED
;
116 void wxRibbonPageScrollButton::OnMouseLeave(wxMouseEvent
& WXUNUSED(evt
))
118 m_flags
&= ~wxRIBBON_SCROLL_BTN_HOVERED
;
119 m_flags
&= ~wxRIBBON_SCROLL_BTN_ACTIVE
;
123 void wxRibbonPageScrollButton::OnMouseDown(wxMouseEvent
& WXUNUSED(evt
))
125 m_flags
|= wxRIBBON_SCROLL_BTN_ACTIVE
;
129 void wxRibbonPageScrollButton::OnMouseUp(wxMouseEvent
& WXUNUSED(evt
))
131 if(m_flags
& wxRIBBON_SCROLL_BTN_ACTIVE
)
133 m_flags
&= ~wxRIBBON_SCROLL_BTN_ACTIVE
;
135 switch(m_flags
& wxRIBBON_SCROLL_BTN_DIRECTION_MASK
)
137 case wxRIBBON_SCROLL_BTN_DOWN
:
138 case wxRIBBON_SCROLL_BTN_RIGHT
:
139 m_sibling
->ScrollLines(1);
141 case wxRIBBON_SCROLL_BTN_UP
:
142 case wxRIBBON_SCROLL_BTN_LEFT
:
143 m_sibling
->ScrollLines(-1);
151 IMPLEMENT_CLASS(wxRibbonPage
, wxRibbonControl
)
153 BEGIN_EVENT_TABLE(wxRibbonPage
, wxRibbonControl
)
154 EVT_ERASE_BACKGROUND(wxRibbonPage::OnEraseBackground
)
155 EVT_PAINT(wxRibbonPage::OnPaint
)
156 EVT_SIZE(wxRibbonPage::OnSize
)
159 wxRibbonPage::wxRibbonPage()
161 m_scroll_left_btn
= NULL
;
162 m_scroll_right_btn
= NULL
;
164 m_scroll_buttons_visible
= false;
167 wxRibbonPage::wxRibbonPage(wxRibbonBar
* parent
,
169 const wxString
& label
,
170 const wxBitmap
& icon
,
171 long WXUNUSED(style
))
172 : wxRibbonControl(parent
, id
, wxDefaultPosition
, wxDefaultSize
, wxBORDER_NONE
)
174 CommonInit(label
, icon
);
177 wxRibbonPage::~wxRibbonPage()
181 bool wxRibbonPage::Create(wxRibbonBar
* parent
,
183 const wxString
& label
,
184 const wxBitmap
& icon
,
185 long WXUNUSED(style
))
187 if(!wxRibbonControl::Create(parent
, id
, wxDefaultPosition
, wxDefaultSize
, wxBORDER_NONE
))
190 CommonInit(label
, icon
);
195 void wxRibbonPage::CommonInit(const wxString
& label
, const wxBitmap
& icon
)
200 m_old_size
= wxSize(0, 0);
202 m_scroll_left_btn
= NULL
;
203 m_scroll_right_btn
= NULL
;
205 m_scroll_buttons_visible
= false;
207 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
209 wxDynamicCast(GetParent(), wxRibbonBar
)->AddPage(this);
212 void wxRibbonPage::SetArtProvider(wxRibbonArtProvider
* art
)
215 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
217 node
= node
->GetNext() )
219 wxWindow
* child
= node
->GetData();
220 wxRibbonControl
* ribbon_child
= wxDynamicCast(child
, wxRibbonControl
);
223 ribbon_child
->SetArtProvider(art
);
228 void wxRibbonPage::AdjustRectToIncludeScrollButtons(wxRect
* rect
) const
230 if(m_scroll_buttons_visible
)
232 if(GetMajorAxis() == wxVERTICAL
)
234 if(m_scroll_left_btn
)
236 rect
->SetY(rect
->GetY() -
237 m_scroll_left_btn
->GetSize().GetHeight());
238 rect
->SetHeight(rect
->GetHeight() +
239 m_scroll_left_btn
->GetSize().GetHeight());
241 if(m_scroll_right_btn
)
243 rect
->SetHeight(rect
->GetHeight() +
244 m_scroll_right_btn
->GetSize().GetHeight());
249 if(m_scroll_left_btn
)
251 rect
->SetX(rect
->GetX() -
252 m_scroll_left_btn
->GetSize().GetWidth());
253 rect
->SetWidth(rect
->GetWidth() +
254 m_scroll_left_btn
->GetSize().GetWidth());
256 if(m_scroll_right_btn
)
258 rect
->SetWidth(rect
->GetWidth() +
259 m_scroll_right_btn
->GetSize().GetWidth());
265 void wxRibbonPage::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
))
267 // All painting done in main paint handler to minimise flicker
270 void wxRibbonPage::OnPaint(wxPaintEvent
& WXUNUSED(evt
))
272 // No foreground painting done by the page itself, but a paint DC
273 // must be created anyway.
274 wxAutoBufferedPaintDC
dc(this);
275 wxRect
rect(GetSize());
276 AdjustRectToIncludeScrollButtons(&rect
);
277 m_art
->DrawPageBackground(dc
, this, rect
);
280 wxOrientation
wxRibbonPage::GetMajorAxis() const
282 if(m_art
&& (m_art
->GetFlags() & wxRIBBON_BAR_FLOW_VERTICAL
))
292 bool wxRibbonPage::ScrollLines(int lines
)
294 return ScrollPixels(lines
* 8);
297 bool wxRibbonPage::ScrollPixels(int pixels
)
301 if(m_scroll_amount
== 0)
303 if(m_scroll_amount
< -pixels
)
304 pixels
= -m_scroll_amount
;
308 if(m_scroll_amount
== m_scroll_amount_limit
)
310 if(m_scroll_amount
+ pixels
> m_scroll_amount_limit
)
311 pixels
= m_scroll_amount_limit
- m_scroll_amount
;
316 m_scroll_amount
+= pixels
;
318 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
320 node
= node
->GetNext() )
322 wxWindow
* child
= node
->GetData();
324 child
->GetPosition(&x
, &y
);
325 if(GetMajorAxis() == wxHORIZONTAL
)
329 child
->SetPosition(wxPoint(x
, y
));
337 void wxRibbonPage::SetSizeWithScrollButtonAdjustment(int x
, int y
, int width
, int height
)
339 if(m_scroll_buttons_visible
)
341 if(GetMajorAxis() == wxHORIZONTAL
)
343 if(m_scroll_left_btn
)
345 int w
= m_scroll_left_btn
->GetSize().GetWidth();
346 m_scroll_left_btn
->SetPosition(wxPoint(x
, y
));
350 if(m_scroll_right_btn
)
352 int w
= m_scroll_right_btn
->GetSize().GetWidth();
354 m_scroll_right_btn
->SetPosition(wxPoint(x
+ width
, y
));
359 if(m_scroll_left_btn
)
361 int h
= m_scroll_left_btn
->GetSize().GetHeight();
362 m_scroll_left_btn
->SetPosition(wxPoint(x
, y
));
366 if(m_scroll_right_btn
)
368 int h
= m_scroll_right_btn
->GetSize().GetHeight();
370 m_scroll_right_btn
->SetPosition(wxPoint(x
, y
+ height
));
374 SetSize(x
, y
, width
, height
);
377 void wxRibbonPage::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
379 // When a resize triggers the scroll buttons to become visible, the page is resized.
380 // This resize from within a resize event can cause (MSW) wxWidgets some confusion,
381 // and report the 1st size to the 2nd size event. Hence the most recent size is
382 // remembered internally and used in Layout() where appropiate.
384 if(GetMajorAxis() == wxHORIZONTAL
)
385 m_size_in_major_axis_for_children
= width
;
387 m_size_in_major_axis_for_children
= height
;
389 wxRibbonControl::DoSetSize(x
, y
, width
, height
, sizeFlags
);
392 void wxRibbonPage::OnSize(wxSizeEvent
& evt
)
394 wxSize new_size
= evt
.GetSize();
397 wxRect invalid_rect
= m_art
->GetPageBackgroundRedrawArea(temp_dc
, this, m_old_size
, new_size
);
398 Refresh(true, &invalid_rect
);
400 m_old_size
= new_size
;
402 if(new_size
.GetX() > 0 && new_size
.GetY() > 0)
408 // Simplify other calculations by pretending new size is zero in both
411 // When size == 0, no point in doing any layout
417 void wxRibbonPage::RemoveChild(wxWindowBase
*child
)
419 // Remove all references to the child from the collapse stack
420 size_t count
= m_collapse_stack
.GetCount();
422 for(src
= 0, dst
= 0; src
< count
; ++src
, ++dst
)
424 wxRibbonControl
*item
= m_collapse_stack
.Item(src
);
435 m_collapse_stack
.Item(dst
) = item
;
440 m_collapse_stack
.RemoveAt(dst
, src
- dst
);
443 // ... and then proceed as normal
444 wxRibbonControl::RemoveChild(child
);
447 bool wxRibbonPage::Realize()
451 m_collapse_stack
.Clear();
452 for (wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
454 node
= node
->GetNext())
456 wxRibbonControl
* child
= wxDynamicCast(node
->GetData(), wxRibbonControl
);
461 if(!child
->Realize())
465 child
->SetSize(child
->GetMinSize());
468 if(GetSize().GetX() > 0 && GetSize().GetY() > 0)
470 status
= Layout() && status
;
476 bool wxRibbonPage::Layout()
478 if(GetChildren().GetCount() == 0)
483 wxPoint
origin_(m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
), m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
));
484 wxOrientation major_axis
= GetMajorAxis();
485 if(m_scroll_buttons_visible
)
487 if(major_axis
== wxHORIZONTAL
)
489 origin_
.x
-= m_scroll_amount
;
490 if(m_scroll_left_btn
)
491 origin_
.x
-= m_scroll_left_btn
->GetSize().GetWidth();
495 origin_
.y
-= m_scroll_amount
;
496 if(m_scroll_left_btn
)
497 origin_
.y
-= m_scroll_left_btn
->GetSize().GetHeight();
500 wxPoint
origin(origin_
);
503 if(major_axis
== wxHORIZONTAL
)
505 gap
= m_art
->GetMetric(wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
);
506 minor_axis_size
= GetSize().GetHeight() - origin
.y
- m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
);
510 gap
= m_art
->GetMetric(wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
);
511 minor_axis_size
= GetSize().GetWidth() - origin
.x
- m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
);
514 for(int iteration
= 1; iteration
<= 2; ++iteration
)
516 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
518 node
= node
->GetNext() )
520 wxWindow
* child
= node
->GetData();
522 child
->GetSize(&w
, &h
);
523 if(major_axis
== wxHORIZONTAL
)
525 child
->SetSize(origin
.x
, origin
.y
, w
, minor_axis_size
);
530 child
->SetSize(origin
.x
, origin
.y
, minor_axis_size
, h
);
537 if(major_axis
== wxHORIZONTAL
)
538 available_space
= m_size_in_major_axis_for_children
- m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
) - origin
.x
+ gap
;
540 available_space
= m_size_in_major_axis_for_children
- m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
) - origin
.y
+ gap
;
541 if(m_scroll_buttons_visible
)
543 available_space
-= m_scroll_amount
;
544 if(m_scroll_right_btn
!= NULL
)
545 available_space
+= GetSizeInOrientation(m_scroll_right_btn
->GetSize(), major_axis
);
547 if(available_space
> 0)
549 if(m_scroll_buttons_visible
)
555 if(!ExpandPanels(major_axis
, available_space
))
558 else if(available_space
< 0)
560 if(m_scroll_buttons_visible
)
562 // Scroll buttons already visible - not going to be able to downsize any more
563 m_scroll_amount_limit
= -available_space
;
564 if(m_scroll_amount
> m_scroll_amount_limit
)
566 ScrollPixels(m_scroll_amount_limit
- m_scroll_amount
);
571 if(!CollapsePanels(major_axis
, -available_space
))
574 m_scroll_amount_limit
= -available_space
;
584 origin
= origin_
; // Reset the origin
591 bool wxRibbonPage::Show(bool show
)
593 if(m_scroll_left_btn
)
594 m_scroll_left_btn
->Show(show
);
595 if(m_scroll_right_btn
)
596 m_scroll_right_btn
->Show(show
);
597 return wxRibbonControl::Show(show
);
600 void wxRibbonPage::HideScrollButtons()
603 m_scroll_amount_limit
= 0;
607 void wxRibbonPage::ShowScrollButtons()
609 bool show_left
= true;
610 bool show_right
= true;
611 bool reposition
= false;
612 if(m_scroll_amount
== 0)
616 if(m_scroll_amount
>= m_scroll_amount_limit
)
619 m_scroll_amount
= m_scroll_amount_limit
;
621 m_scroll_buttons_visible
= show_left
|| show_right
;
625 if(m_scroll_left_btn
== NULL
)
630 if(GetMajorAxis() == wxHORIZONTAL
)
632 direction
= wxRIBBON_SCROLL_BTN_LEFT
;
633 size
= m_art
->GetScrollButtonMinimumSize(temp_dc
, GetParent(), direction
);
634 size
.SetHeight(GetSize().GetHeight());
638 direction
= wxRIBBON_SCROLL_BTN_UP
;
639 size
= m_art
->GetScrollButtonMinimumSize(temp_dc
, GetParent(), direction
);
640 size
.SetWidth(GetSize().GetWidth());
642 m_scroll_left_btn
= new wxRibbonPageScrollButton(this, wxID_ANY
, GetPosition(), size
, direction
);
645 m_scroll_left_btn
->Hide();
652 if(m_scroll_left_btn
!= NULL
)
654 m_scroll_left_btn
->Destroy();
655 m_scroll_left_btn
= NULL
;
662 if(m_scroll_right_btn
== NULL
)
667 if(GetMajorAxis() == wxHORIZONTAL
)
669 direction
= wxRIBBON_SCROLL_BTN_RIGHT
;
670 size
= m_art
->GetScrollButtonMinimumSize(temp_dc
, GetParent(), direction
);
671 size
.SetHeight(GetSize().GetHeight());
675 direction
= wxRIBBON_SCROLL_BTN_DOWN
;
676 size
= m_art
->GetScrollButtonMinimumSize(temp_dc
, GetParent(), direction
);
677 size
.SetWidth(GetSize().GetWidth());
679 wxPoint initial_pos
= GetPosition() + GetSize() - size
;
680 m_scroll_right_btn
= new wxRibbonPageScrollButton(this, wxID_ANY
, initial_pos
, size
, direction
);
683 m_scroll_right_btn
->Hide();
690 if(m_scroll_right_btn
!= NULL
)
692 m_scroll_right_btn
->Destroy();
693 m_scroll_right_btn
= NULL
;
700 wxDynamicCast(GetParent(), wxRibbonBar
)->RepositionPage(this);
704 static int GetSizeInOrientation(wxSize size
, wxOrientation orientation
)
708 case wxHORIZONTAL
: return size
.GetWidth();
709 case wxVERTICAL
: return size
.GetHeight();
710 case wxBOTH
: return size
.GetWidth() * size
.GetHeight();
715 bool wxRibbonPage::ExpandPanels(wxOrientation direction
, int maximum_amount
)
717 bool expanded_something
= false;
718 while(maximum_amount
> 0)
720 int smallest_size
= INT_MAX
;
721 wxRibbonPanel
* smallest_panel
= NULL
;
722 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
724 node
= node
->GetNext() )
726 wxRibbonPanel
* panel
= wxDynamicCast(node
->GetData(), wxRibbonPanel
);
731 if(panel
->IsSizingContinuous())
733 int size
= GetSizeInOrientation(panel
->GetSize(), direction
);
734 if(size
< smallest_size
)
736 smallest_size
= size
;
737 smallest_panel
= panel
;
742 wxSize current
= panel
->GetSize();
743 int size
= GetSizeInOrientation(current
, direction
);
744 if(size
< smallest_size
)
746 wxSize larger
= panel
->GetNextLargerSize(direction
);
747 if(larger
!= current
&& GetSizeInOrientation(larger
, direction
) > size
)
749 smallest_size
= size
;
750 smallest_panel
= panel
;
755 if(smallest_panel
!= NULL
)
757 if(smallest_panel
->IsSizingContinuous())
759 wxSize size
= smallest_panel
->GetSize();
760 int amount
= maximum_amount
;
763 // For "large" growth, grow this panel a bit, and then re-allocate
764 // the remainder (which may come to this panel again anyway)
767 if(direction
& wxHORIZONTAL
)
771 if(direction
& wxVERTICAL
)
775 smallest_panel
->SetSize(size
);
776 maximum_amount
-= amount
;
777 m_collapse_stack
.Add(smallest_panel
);
778 expanded_something
= true;
782 wxSize current
= smallest_panel
->GetSize();
783 wxSize larger
= smallest_panel
->GetNextLargerSize(direction
);
784 wxSize delta
= larger
- current
;
785 if(GetSizeInOrientation(delta
, direction
) <= maximum_amount
)
787 smallest_panel
->SetSize(larger
);
788 maximum_amount
-= GetSizeInOrientation(delta
, direction
);
789 m_collapse_stack
.Add(smallest_panel
);
790 expanded_something
= true;
803 if(expanded_something
)
814 bool wxRibbonPage::CollapsePanels(wxOrientation direction
, int minimum_amount
)
816 bool collapsed_something
= false;
817 while(minimum_amount
> 0)
819 int largest_size
= 0;
820 wxRibbonPanel
* largest_panel
= NULL
;
821 if(!m_collapse_stack
.IsEmpty())
823 // For a more consistent panel layout, try to collapse panels which
824 // were recently expanded.
825 largest_panel
= wxDynamicCast(m_collapse_stack
.Last(), wxRibbonPanel
);
826 m_collapse_stack
.RemoveAt(m_collapse_stack
.GetCount() - 1);
830 for(wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
832 node
= node
->GetNext() )
834 wxRibbonPanel
* panel
= wxDynamicCast(node
->GetData(), wxRibbonPanel
);
839 if(panel
->IsSizingContinuous())
841 int size
= GetSizeInOrientation(panel
->GetSize(), direction
);
842 if(size
> largest_size
)
845 largest_panel
= panel
;
850 wxSize current
= panel
->GetSize();
851 int size
= GetSizeInOrientation(current
, direction
);
852 if(size
> largest_size
)
854 wxSize smaller
= panel
->GetNextSmallerSize(direction
);
855 if(smaller
!= current
&&
856 GetSizeInOrientation(smaller
, direction
) < size
)
859 largest_panel
= panel
;
865 if(largest_panel
!= NULL
)
867 if(largest_panel
->IsSizingContinuous())
869 wxSize size
= largest_panel
->GetSize();
870 int amount
= minimum_amount
;
873 // For "large" contraction, reduce this panel a bit, and
874 // then re-allocate the remainder of the quota (which may
875 // come to this panel again anyway)
878 if(direction
& wxHORIZONTAL
)
882 if(direction
& wxVERTICAL
)
886 largest_panel
->SetSize(size
);
887 minimum_amount
-= amount
;
888 collapsed_something
= true;
892 wxSize current
= largest_panel
->GetSize();
893 wxSize smaller
= largest_panel
->GetNextSmallerSize(direction
);
894 wxSize delta
= current
- smaller
;
895 largest_panel
->SetSize(smaller
);
896 minimum_amount
-= GetSizeInOrientation(delta
, direction
);
897 collapsed_something
= true;
905 if(collapsed_something
)
916 bool wxRibbonPage::DismissExpandedPanel()
918 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
920 node
= node
->GetNext() )
922 wxRibbonPanel
* panel
= wxDynamicCast(node
->GetData(), wxRibbonPanel
);
927 if(panel
->GetExpandedPanel() != NULL
)
929 return panel
->HideExpanded();
935 wxSize
wxRibbonPage::GetMinSize() const
937 wxSize
min(wxDefaultCoord
, wxDefaultCoord
);
939 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
941 node
= node
->GetNext() )
943 wxWindow
* child
= node
->GetData();
944 wxSize
child_min(child
->GetMinSize());
946 min
.x
= wxMax(min
.x
, child_min
.x
);
947 min
.y
= wxMax(min
.y
, child_min
.y
);
950 if(GetMajorAxis() == wxHORIZONTAL
)
952 min
.x
= wxDefaultCoord
;
953 if(min
.y
!= wxDefaultCoord
)
955 min
.y
+= m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
) + m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
);
960 if(min
.x
!= wxDefaultCoord
)
962 min
.x
+= m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
) + m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
);
964 min
.y
= wxDefaultCoord
;
970 wxSize
wxRibbonPage::DoGetBestSize() const
975 if(GetMajorAxis() == wxHORIZONTAL
)
977 best
.y
= wxDefaultCoord
;
979 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
981 node
= node
->GetNext() )
983 wxWindow
* child
= node
->GetData();
984 wxSize
child_best(child
->GetBestSize());
986 if(child_best
.x
!= wxDefaultCoord
)
988 best
.IncBy(child_best
.x
, 0);
990 best
.y
= wxMax(best
.y
, child_best
.y
);
997 best
.IncBy((count
- 1) * m_art
->GetMetric(wxRIBBON_ART_PANEL_X_SEPARATION_SIZE
), 0);
1002 best
.x
= wxDefaultCoord
;
1004 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1006 node
= node
->GetNext() )
1008 wxWindow
* child
= node
->GetData();
1009 wxSize
child_best(child
->GetBestSize());
1011 best
.x
= wxMax(best
.x
, child_best
.x
);
1012 if(child_best
.y
!= wxDefaultCoord
)
1014 best
.IncBy(0, child_best
.y
);
1022 best
.IncBy(0, (count
- 1) * m_art
->GetMetric(wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE
));
1026 if(best
.x
!= wxDefaultCoord
)
1028 best
.x
+= m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE
) + m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE
);
1030 if(best
.y
!= wxDefaultCoord
)
1032 best
.y
+= m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_TOP_SIZE
) + m_art
->GetMetric(wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE
);
1037 #endif // wxUSE_RIBBON