]> git.saurik.com Git - wxWidgets.git/blame - src/ribbon/control.cpp
No changes, just don't initialize the variable twice.
[wxWidgets.git] / src / ribbon / control.cpp
CommitLineData
3c3ead1d
PC
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///////////////////////////////////////////////////////////////////////////////
4cf018e1 11
3c3ead1d
PC
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
3c3ead1d
PC
18#if wxUSE_RIBBON
19
4cf018e1 20#include "wx/ribbon/control.h"
07c72264 21#include "wx/ribbon/bar.h"
4cf018e1 22
3c3ead1d
PC
23#ifndef WX_PRECOMP
24#endif
25
26#ifdef __WXMSW__
27#include "wx/msw/private.h"
28#endif
29
30IMPLEMENT_CLASS(wxRibbonControl, wxControl)
31
fd6e1597 32bool wxRibbonControl::Create(wxWindow *parent, wxWindowID id,
3c3ead1d
PC
33 const wxPoint& pos,
34 const wxSize& size, long style,
35 const wxValidator& validator,
36 const wxString& name)
3c3ead1d 37{
fd6e1597
VZ
38 if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
39 return false;
3c3ead1d
PC
40
41 wxRibbonControl *ribbon_parent = wxDynamicCast(parent, wxRibbonControl);
42 if(ribbon_parent)
43 {
44 m_art = ribbon_parent->GetArtProvider();
45 }
fd6e1597
VZ
46
47 return true;
3c3ead1d
PC
48}
49
50void wxRibbonControl::SetArtProvider(wxRibbonArtProvider* art)
51{
52 m_art = art;
53}
54
55wxSize 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
71wxSize 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
86wxSize wxRibbonControl::GetNextSmallerSize(wxOrientation direction,
87 wxSize relative_to) const
88{
89 return DoGetNextSmallerSize(direction, relative_to);
90}
91
92wxSize wxRibbonControl::GetNextLargerSize(wxOrientation direction,
93 wxSize relative_to) const
94{
95 return DoGetNextLargerSize(direction, relative_to);
96}
97
98wxSize wxRibbonControl::GetNextSmallerSize(wxOrientation direction) const
99{
100 return DoGetNextSmallerSize(direction, GetSize());
101}
102
103wxSize wxRibbonControl::GetNextLargerSize(wxOrientation direction) const
104{
105 return DoGetNextLargerSize(direction, GetSize());
106}
107
108bool wxRibbonControl::Realize()
109{
110 return true;
111}
112
07c72264
VZ
113wxRibbonBar* 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
3c3ead1d 125#endif // wxUSE_RIBBON