~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxContribItems/wxFlatNotebook/include/wx/wxFlatNotebook/renderer.h

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
///////////////////////////////////////////////////////////////////////////////
 
2
// Name:                renerder.h
 
3
// Author:      Eran Ifrah <eran.ifrah@gmail.com>
 
4
// Created:     30/12/2005
 
5
// Modified:    01/01/2006
 
6
// Copyright:   Eran Ifrah (c)
 
7
// Licence:     wxWindows license <http://www.wxwidgets.org/licence3.txt>
 
8
///////////////////////////////////////////////////////////////////////////////
 
9
 
 
10
#ifndef RENDERE_H
 
11
#define RENDERE_H
 
12
 
 
13
#include <wx/wxFlatNotebook/wxFlatNotebookSDK.h>
 
14
#include <wx/dc.h>
 
15
#include <wx/string.h>
 
16
#include <wx/wxFlatNotebook/fnb_singleton.h>
 
17
#include <wx/wxFlatNotebook/fnb_smart_ptr.h>
 
18
#include <map>
 
19
#include <vector>
 
20
#include <wx/event.h>
 
21
 
 
22
class WXDLLIMPEXP_FNB wxFNBRenderer
 
23
{
 
24
protected:
 
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;
 
29
 
 
30
public:
 
31
        wxFNBRenderer();
 
32
        virtual ~wxFNBRenderer();
 
33
 
 
34
        /**
 
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
 
39
         */
 
40
        virtual void DrawTabs(wxWindow* pageContainer, wxDC &dc, wxEvent &event);
 
41
 
 
42
        /**
 
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
 
49
         *   - wxFNB_BTN_PRESSED
 
50
         *   - wxFNB_BTN_HOVER
 
51
         *   - wxFNB_BTN_NONE
 
52
         * \param tabXBgBmp [output] background bitmap of the area of the button (just before it is painted)
 
53
         */
 
54
        virtual void DrawTabX(wxWindow* pageContainer, wxDC& dc, const wxRect& rect, const int& tabIdx, const int btnStatus);
 
55
 
 
56
        /**
 
57
         * Draw tab 
 
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
 
65
         *   - wxFNB_BTN_PRESSED
 
66
         *   - wxFNB_BTN_HOVER
 
67
         *   - wxFNB_BTN_NONE
 
68
         */
 
69
        virtual void DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus) = 0;
 
70
 
 
71
        /**
 
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
 
77
         */
 
78
        virtual int CalcTabWidth (wxWindow* pageContainer, int tabIdx, int tabHeight);
 
79
 
 
80
        /**
 
81
         * Calculate tab height
 
82
         * \param pageContainer pageContainer parent window on which to draw
 
83
         * \return tab bouding rectangle size
 
84
         */
 
85
        virtual int CalcTabHeight(wxWindow* pageContainer);
 
86
 
 
87
        /**
 
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
 
92
         */
 
93
        virtual void GetBitmap(wxDC& dc, const wxRect &rect, wxBitmap &bmp);
 
94
 
 
95
        /**
 
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
 
101
         */
 
102
        void DrawTabsLine(wxWindow *pageContainer, wxDC& dc, wxCoord selTabX1 = -1, wxCoord selTabX2 = -1);
 
103
 
 
104
        /**
 
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
 
109
         */
 
110
        static wxColor LightColour(const wxColour& color, int percent);
 
111
 
 
112
        /**
 
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
 
119
         */
 
120
        static void PaintStraightGradientBox(wxDC& dc, const wxRect& rect, const wxColour& startColor, const wxColour& endColor, bool  vertical = true);
 
121
 
 
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);
 
128
 
 
129
        /// Draw right arrow button to the right area of the tabs
 
130
        virtual void DrawRightArrow(wxWindow *pageContainer, wxDC &dc);
 
131
 
 
132
        /// Draw left arrow button to the right area of the tabs
 
133
        virtual void DrawLeftArrow (wxWindow *pageContainer, wxDC &dc);
 
134
 
 
135
        /// Draw 'x' button to the right area of the tabs
 
136
        virtual void DrawX         (wxWindow *pageContainer, wxDC &dc);
 
137
 
 
138
        /**
 
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
 
143
         */
 
144
        virtual void DrawDragHint(wxWindow *pageContainer, int tabIdx);
 
145
 
 
146
        /**
 
147
         * Draw drop down arrow on the right corner
 
148
         * \param pageContainer window tabs container
 
149
         * \param dc device context
 
150
         */
 
151
        void DrawDropDownArrow(wxWindow* pageContainer, wxDC& dc);
 
152
 
 
153
        /**
 
154
         * Return an array of tabs info that can fit to screen starting from 'from'
 
155
         * \param pageContainer 
 
156
         * \param [output] vTabInfo 
 
157
         * \param from 
 
158
         */
 
159
        virtual void NumberTabsCanFit(wxWindow *pageContainer, std::vector<wxRect> &vTabInfo, int from = -1);
 
160
 
 
161
protected:
 
162
        /**
 
163
         * Generate random colour
 
164
         * \return random colour
 
165
         */
 
166
        wxColour RandomColor();
 
167
 
 
168
 
 
169
};
 
170
 
 
171
typedef wxFNBSmartPtr<wxFNBRenderer> wxFNBRendererPtr;
 
172
 
 
173
class wxFNBRendererDefault : public wxFNBRenderer
 
174
{
 
175
public:
 
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);
 
179
};
 
180
 
 
181
class wxFNBRendererFirefox2 : public wxFNBRenderer
 
182
{
 
183
public:
 
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);
 
187
};
 
188
 
 
189
class wxFNBRendererVC71 : public wxFNBRenderer
 
190
{
 
191
public:
 
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);
 
195
};
 
196
 
 
197
class wxFNBRendererFancy : public wxFNBRenderer
 
198
{
 
199
public:
 
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);
 
203
};
 
204
 
 
205
class wxFNBRendererVC8 : public wxFNBRenderer
 
206
{
 
207
        int m_factor;
 
208
        bool m_first;
 
209
 
 
210
public:
 
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);
 
216
 
 
217
private:
 
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);
 
221
        
 
222
};
 
223
 
 
224
//-----------------------------------
 
225
// Renderer manager class
 
226
//-----------------------------------
 
227
 
 
228
class wxFNBRendererMgr
 
229
{
 
230
        friend class wxFNBSingleton<wxFNBRendererMgr>;
 
231
        std::map<int, wxFNBRendererPtr> m_renderers;
 
232
public:
 
233
        /**
 
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 
 
238
         */
 
239
        wxFNBRendererPtr GetRenderer(long style);
 
240
 
 
241
private:
 
242
        wxFNBRendererMgr();
 
243
        virtual ~wxFNBRendererMgr();
 
244
};
 
245
 
 
246
/// Patch (DLL) ---- Ti-R ----  Enable to get a real singleton share over dlls
 
247
        // --- old ---
 
248
        //typedef wxFNBSingleton<wxFNBRendererMgr> wxFNBRendererMgrST;
 
249
 
 
250
class WXDLLIMPEXP_FNB wxFNBRendererMgrST:public wxFNBSingleton<wxFNBRendererMgr>
 
251
{};
 
252
 
 
253
#endif // RENDERE_H