]> git.saurik.com Git - wxWidgets.git/blob - src/ribbon/control.cpp
let wxCheckListBox get the properties of wxCheckListBoxBase (was wxListBox) for wxGTK...
[wxWidgets.git] / src / ribbon / control.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/ribbon/control.cpp
3 // Purpose: Extension of wxControl with common ribbon methods
4 // Author: Peter Cawley
5 // Modified by:
6 // Created: 2009-06-05
7 // RCS-ID: $Id$
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #if wxUSE_RIBBON
19
20 #include "wx/ribbon/control.h"
21 #include "wx/ribbon/bar.h"
22
23 #ifndef WX_PRECOMP
24 #endif
25
26 #ifdef __WXMSW__
27 #include "wx/msw/private.h"
28 #endif
29
30 IMPLEMENT_CLASS(wxRibbonControl, wxControl)
31
32 bool wxRibbonControl::Create(wxWindow *parent, wxWindowID id,
33 const wxPoint& pos,
34 const wxSize& size, long style,
35 const wxValidator& validator,
36 const wxString& name)
37 {
38 if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
39 return false;
40
41 wxRibbonControl *ribbon_parent = wxDynamicCast(parent, wxRibbonControl);
42 if(ribbon_parent)
43 {
44 m_art = ribbon_parent->GetArtProvider();
45 }
46
47 return true;
48 }
49
50 void wxRibbonControl::SetArtProvider(wxRibbonArtProvider* art)
51 {
52 m_art = art;
53 }
54
55 wxSize wxRibbonControl::DoGetNextSmallerSize(wxOrientation direction,
56 wxSize size) const
57 {
58 // Dummy implementation for code which doesn't check for IsSizingContinuous() == true
59 wxSize minimum(GetMinSize());
60 if((direction & wxHORIZONTAL) && size.x > minimum.x)
61 {
62 size.x--;
63 }
64 if((direction & wxVERTICAL) && size.y > minimum.y)
65 {
66 size.y--;
67 }
68 return size;
69 }
70
71 wxSize wxRibbonControl::DoGetNextLargerSize(wxOrientation direction,
72 wxSize size) const
73 {
74 // Dummy implementation for code which doesn't check for IsSizingContinuous() == true
75 if(direction & wxHORIZONTAL)
76 {
77 size.x++;
78 }
79 if(direction & wxVERTICAL)
80 {
81 size.y++;
82 }
83 return size;
84 }
85
86 wxSize wxRibbonControl::GetNextSmallerSize(wxOrientation direction,
87 wxSize relative_to) const
88 {
89 return DoGetNextSmallerSize(direction, relative_to);
90 }
91
92 wxSize wxRibbonControl::GetNextLargerSize(wxOrientation direction,
93 wxSize relative_to) const
94 {
95 return DoGetNextLargerSize(direction, relative_to);
96 }
97
98 wxSize wxRibbonControl::GetNextSmallerSize(wxOrientation direction) const
99 {
100 return DoGetNextSmallerSize(direction, GetSize());
101 }
102
103 wxSize wxRibbonControl::GetNextLargerSize(wxOrientation direction) const
104 {
105 return DoGetNextLargerSize(direction, GetSize());
106 }
107
108 bool wxRibbonControl::Realize()
109 {
110 return true;
111 }
112
113 wxRibbonBar* wxRibbonControl::GetAncestorRibbonBar()const
114 {
115 for ( wxWindow* win = GetParent(); win; win = win->GetParent() )
116 {
117 wxRibbonBar* bar = wxDynamicCast(win, wxRibbonBar);
118 if ( bar )
119 return bar;
120 }
121
122 return NULL;
123 }
124
125 #endif // wxUSE_RIBBON