1
///////////////////////////////////////////////////////////////////////////////
3
// Author: Eran Ifrah <eran.ifrah@gmail.com>
5
// Modified: 01/01/2006
6
// Copyright: Eran Ifrah (c)
7
// Licence: wxWindows license <http://www.wxwidgets.org/licence3.txt>
8
///////////////////////////////////////////////////////////////////////////////
13
#include <wx/wxFlatNotebook/wxFlatNotebookSDK.h>
15
#include <wx/string.h>
16
#include <wx/wxFlatNotebook/fnb_singleton.h>
17
#include <wx/wxFlatNotebook/fnb_smart_ptr.h>
22
class WXDLLIMPEXP_FNB wxFNBRenderer
25
// A bitmap that holds the background of the
26
// x button which is drawn on a tab
27
wxBitmap m_tabXBgBmp, m_xBgBmp, m_leftBgBmp, m_rightBgBmp;
28
wxBitmap m_arrowDown, m_arrowUp;
32
virtual ~wxFNBRenderer();
35
* Generic function that draws the tabs and updates values in the page container
36
* MAC requires that the event will be skipped, so we must pass it
37
* \param pageContainer window that contains the tabs drawing
38
* \param dc device context
40
virtual void DrawTabs(wxWindow* pageContainer, wxDC &dc, wxEvent &event);
43
* Draw a small 'x' button on top of the tab
44
* \param pageContainer parent window on which to draw
45
* \param dc device context to use
46
* \param rect button rectangle
47
* \param tabIdx tab index
48
* \param btnStatus button status, can be one of
52
* \param tabXBgBmp [output] background bitmap of the area of the button (just before it is painted)
54
virtual void DrawTabX(wxWindow* pageContainer, wxDC& dc, const wxRect& rect, const int& tabIdx, const int btnStatus);
58
* \param pageContainer parent window on which to draw
59
* \param dc device context to use
60
* \param posx tab x coordinate
61
* \param tabIdx tab index
62
* \param tabWidth tab width
63
* \param tabHeight tab height
64
* \param btnStatus btnStatus the little 'x' button (on top of the active tab) status, can be one of
69
virtual void DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus) = 0;
72
* Calculate tab width , based on its index (for image, x button on tab)
73
* \param pageContainer pageContainer parent window on which to draw
74
* \param tabIdx tab index
75
* \param tabHeight the tab height (used for tan() function calculations)
76
* \return tab bouding rectangle size
78
virtual int CalcTabWidth (wxWindow* pageContainer, int tabIdx, int tabHeight);
81
* Calculate tab height
82
* \param pageContainer pageContainer parent window on which to draw
83
* \return tab bouding rectangle size
85
virtual int CalcTabHeight(wxWindow* pageContainer);
88
* Get a bitmap from device context, with rect size
89
* \param dc device context
90
* \param rect bitmap rectangle
91
* \param bmp [output] bitmap
93
virtual void GetBitmap(wxDC& dc, const wxRect &rect, wxBitmap &bmp);
96
* Draw a bottom line for the tabs area
97
* \param pageContainer the owner of this tabs
98
* \param dc device context to use
99
* \param selTabX1 the selection tab X1 coord
100
* \param selTabX2 the selection tab X2 coord
102
void DrawTabsLine(wxWindow *pageContainer, wxDC& dc, wxCoord selTabX1 = -1, wxCoord selTabX2 = -1);
105
* Brighten a given colour with amount
106
* \param color starting colour
107
* \param percent percent, 0 - no change, 100 - white
108
* \return brighten colour
110
static wxColor LightColour(const wxColour& color, int percent);
113
* Paint rectangle with gradient colouring
114
* \param dc device context
115
* \param rect rectangle
116
* \param startColor gradient colour 1
117
* \param endColor gradient colour 2
118
* \param vertical use vertical gradient or horizontal
120
static void PaintStraightGradientBox(wxDC& dc, const wxRect& rect, const wxColour& startColor, const wxColour& endColor, bool vertical = true);
122
// Navigation buttons position
123
int GetLeftButtonPos(wxWindow *pageContainer);
124
int GetRightButtonPos(wxWindow *pageContainer);
125
int GetXPos(wxWindow *pageContainer);
126
int GetButtonsAreaLength(wxWindow *pageContainer);
127
int GetDropArrowButtonPos(wxWindow *pageContainer);
129
/// Draw right arrow button to the right area of the tabs
130
virtual void DrawRightArrow(wxWindow *pageContainer, wxDC &dc);
132
/// Draw left arrow button to the right area of the tabs
133
virtual void DrawLeftArrow (wxWindow *pageContainer, wxDC &dc);
135
/// Draw 'x' button to the right area of the tabs
136
virtual void DrawX (wxWindow *pageContainer, wxDC &dc);
139
* Draw tab drag hint, the default implementation is to do nothing ...
140
* u can override this function to provide a nice feedback to user
141
* \param pageContainer a pointer to the owner wxPageContainer
142
* \param tabIdx index of the tab that will be replaced with the dragged tab
144
virtual void DrawDragHint(wxWindow *pageContainer, int tabIdx);
147
* Draw drop down arrow on the right corner
148
* \param pageContainer window tabs container
149
* \param dc device context
151
void DrawDropDownArrow(wxWindow* pageContainer, wxDC& dc);
154
* Return an array of tabs info that can fit to screen starting from 'from'
155
* \param pageContainer
156
* \param [output] vTabInfo
159
virtual void NumberTabsCanFit(wxWindow *pageContainer, std::vector<wxRect> &vTabInfo, int from = -1);
163
* Generate random colour
164
* \return random colour
166
wxColour RandomColor();
171
typedef wxFNBSmartPtr<wxFNBRenderer> wxFNBRendererPtr;
173
class wxFNBRendererDefault : public wxFNBRenderer
176
wxFNBRendererDefault(){}
177
virtual ~wxFNBRendererDefault(){}
178
virtual void DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus);
181
class wxFNBRendererFirefox2 : public wxFNBRenderer
184
wxFNBRendererFirefox2(){}
185
virtual ~wxFNBRendererFirefox2(){}
186
virtual void DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus);
189
class wxFNBRendererVC71 : public wxFNBRenderer
192
wxFNBRendererVC71(){}
193
virtual ~wxFNBRendererVC71(){}
194
virtual void DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus);
197
class wxFNBRendererFancy : public wxFNBRenderer
200
wxFNBRendererFancy(){}
201
virtual ~wxFNBRendererFancy(){}
202
virtual void DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus);
205
class wxFNBRendererVC8 : public wxFNBRenderer
211
wxFNBRendererVC8() : m_factor(1), m_first(true) {}
212
virtual ~wxFNBRendererVC8(){}
213
virtual void DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus);
214
virtual void DrawTabs(wxWindow *pageContainer, wxDC &dc, wxEvent &event);
215
void NumberTabsCanFit(wxWindow *pageContainer, std::vector<wxRect> &vTabInfo, int from = -1);
218
void FillVC8GradientColor(wxWindow* pageContainer, wxDC &dc, const wxPoint tabPoints[], const bool bSelectedTab, const int tabIdx);
219
int GetEndX(const wxPoint tabPoints[], const int &y, long style);
220
int GetStartX(const wxPoint tabPoints[], const int &y, long style);
224
//-----------------------------------
225
// Renderer manager class
226
//-----------------------------------
228
class wxFNBRendererMgr
230
friend class wxFNBSingleton<wxFNBRendererMgr>;
231
std::map<int, wxFNBRendererPtr> m_renderers;
234
* Return the renderer according to the style flag, the returned pointer should not be
235
* deleted by caller, it is owned by this class
236
* \param style window style flag
237
* \return wxFNBRenderer
239
wxFNBRendererPtr GetRenderer(long style);
243
virtual ~wxFNBRendererMgr();
246
/// Patch (DLL) ---- Ti-R ---- Enable to get a real singleton share over dlls
248
//typedef wxFNBSingleton<wxFNBRendererMgr> wxFNBRendererMgrST;
250
class WXDLLIMPEXP_FNB wxFNBRendererMgrST:public wxFNBSingleton<wxFNBRendererMgr>