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