~ubuntu-branches/ubuntu/trusty/codeblocks/trusty-proposed

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmithContribItems/wxflatnotebook/wxFlatNotebook/src/wxFlatNotebook/renderer.cpp

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2013-05-06 00:20:02 UTC
  • mfrom: (6.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130506002002-ngc7bwkewnak8fja
Tags: 12.11-3
* Upload to unstable.
* Update watch file, thanks to Bart Martens.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
///////////////////////////////////////////////////////////////////////////////
2
 
// Name:                renderer.cpp 
3
 
// Purpose:     implementation of the different renderers used by wxFlatNotebook
4
 
// Author:      Eran Ifrah <eranif@bezeqint.net>
5
 
// Created:     30/12/2005
6
 
// Modified:    01/01/2006
7
 
// Copyright:   Eran Ifrah (c)
8
 
// Licence:     wxWindows license <http://www.wxwidgets.org/licence3.txt>
9
 
///////////////////////////////////////////////////////////////////////////////
10
 
#include <wx/wxFlatNotebook/renderer.h>
11
 
#include <wx/wxFlatNotebook/wxFlatNotebook.h> // for the styles
12
 
#include <wx/wxFlatNotebook/fnb_resources.h>
13
 
#include <wx/image.h>
14
 
 
15
 
#ifdef DEVELOPMENT
16
 
# define FNB_LOG_MSG( msg ) { wxString logmsg; logmsg << msg; wxLogMessage( logmsg ); }
17
 
#else
18
 
# define FNB_LOG_MSG( msg ) { wxString logmsg; logmsg << msg; }
19
 
#endif
20
 
 
21
 
//-----------------------------------------------------------------------------
22
 
// Util functions
23
 
//-----------------------------------------------------------------------------
24
 
 
25
 
static void DrawButton(wxDC& dc, 
26
 
                        const wxRect& rect, 
27
 
                        const bool &focus, 
28
 
                        const bool &upperTabs)
29
 
{
30
 
        // Define the middle points
31
 
        wxPoint leftPt, rightPt;
32
 
        if( focus ){
33
 
                if( upperTabs ){
34
 
                        leftPt = wxPoint(rect.x, rect.y + (rect.height / 10)*8 );
35
 
                        rightPt = wxPoint(rect.x + rect.width - 2, rect.y + (rect.height / 10)*8);
36
 
                } else {
37
 
                        leftPt = wxPoint(rect.x, rect.y + (rect.height / 10)*5 );
38
 
                        rightPt = wxPoint(rect.x + rect.width - 2, rect.y + (rect.height / 10)*5);
39
 
                }
40
 
        } else {
41
 
                leftPt = wxPoint(rect.x, rect.y + (rect.height / 2) );
42
 
                rightPt = wxPoint(rect.x + rect.width - 2, rect.y + (rect.height / 2));
43
 
        }
44
 
 
45
 
        // Define the top region
46
 
        wxRect top(rect.GetLeftTop(), rightPt);
47
 
        wxRect bottom(leftPt, rect.GetBottomRight());
48
 
 
49
 
        wxColour topStartColor(wxT("WHITE"));
50
 
 
51
 
        if( !focus ){
52
 
                topStartColor = wxFNBRenderer::LightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 50);
53
 
        }
54
 
 
55
 
        wxColour topEndColor( wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
56
 
        wxColour bottomStartColor(topEndColor);
57
 
        wxColour bottomEndColor(topEndColor);
58
 
 
59
 
        // Incase we use bottom tabs, switch the colors
60
 
        if( upperTabs ){
61
 
                if( focus ){
62
 
                        wxFNBRenderer::PaintStraightGradientBox(dc, top, topStartColor, topEndColor);
63
 
                        wxFNBRenderer::PaintStraightGradientBox(dc, bottom, bottomStartColor, bottomEndColor);
64
 
                } else {
65
 
                        wxFNBRenderer::PaintStraightGradientBox(dc, top, topEndColor , topStartColor);
66
 
                        wxFNBRenderer::PaintStraightGradientBox(dc, bottom, bottomStartColor, bottomEndColor);
67
 
                }
68
 
        } else {
69
 
                if( focus ){
70
 
                        wxFNBRenderer::PaintStraightGradientBox(dc, bottom, topEndColor, bottomEndColor);
71
 
                        wxFNBRenderer::PaintStraightGradientBox(dc, top,topStartColor,  topStartColor);
72
 
                } else {
73
 
                        wxFNBRenderer::PaintStraightGradientBox(dc, bottom, bottomStartColor, bottomEndColor);
74
 
                        wxFNBRenderer::PaintStraightGradientBox(dc, top, topEndColor, topStartColor);
75
 
                }
76
 
        }
77
 
        
78
 
        dc.SetBrush( *wxTRANSPARENT_BRUSH );
79
 
}
80
 
 
81
 
wxFNBRenderer::wxFNBRenderer()
82
 
: m_tabXBgBmp(16, 16)
83
 
, m_xBgBmp(16, 14)
84
 
, m_leftBgBmp(16, 14)
85
 
, m_rightBgBmp(16, 14)
86
 
{
87
 
}
88
 
 
89
 
wxFNBRenderer::~wxFNBRenderer()
90
 
{
91
 
}
92
 
 
93
 
int wxFNBRenderer::GetLeftButtonPos(wxWindow* pageContainer)
94
 
{
95
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
96
 
        long style = pc->GetParent()->GetWindowStyleFlag();
97
 
        wxRect rect = pc->GetClientRect();
98
 
        int clientWidth = rect.width;
99
 
        if(style & wxFNB_NO_X_BUTTON)
100
 
                return clientWidth - 38;
101
 
        else
102
 
                return clientWidth - 54;
103
 
}
104
 
 
105
 
int wxFNBRenderer::GetRightButtonPos(wxWindow* pageContainer)
106
 
{
107
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
108
 
        long style = pc->GetParent()->GetWindowStyleFlag();
109
 
        wxRect rect = pc->GetClientRect();
110
 
        int clientWidth = rect.width;
111
 
        if(style & wxFNB_NO_X_BUTTON)
112
 
                return clientWidth - 22;
113
 
        else
114
 
                return clientWidth - 38;
115
 
}
116
 
 
117
 
int wxFNBRenderer::GetDropArrowButtonPos(wxWindow *pageContainer)
118
 
{
119
 
        return GetRightButtonPos(pageContainer);
120
 
}
121
 
 
122
 
int wxFNBRenderer::GetXPos(wxWindow* pageContainer)
123
 
{
124
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
125
 
        long style = pc->GetParent()->GetWindowStyleFlag();
126
 
        wxRect rect = pc->GetClientRect();
127
 
        int clientWidth = rect.width;
128
 
        if(style & wxFNB_NO_X_BUTTON)
129
 
                return clientWidth;
130
 
        else
131
 
                return clientWidth - 22;
132
 
}
133
 
 
134
 
int wxFNBRenderer::GetButtonsAreaLength(wxWindow* pageContainer)
135
 
{
136
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
137
 
        long style = pc->GetParent()->GetWindowStyleFlag();
138
 
 
139
 
        // ''
140
 
        if(style & wxFNB_NO_NAV_BUTTONS && style & wxFNB_NO_X_BUTTON && !(style & wxFNB_DROPDOWN_TABS_LIST))
141
 
                return 0;
142
 
        
143
 
        // 'x'
144
 
        if((style & wxFNB_NO_NAV_BUTTONS) && !(style & wxFNB_NO_X_BUTTON) && !(style & wxFNB_DROPDOWN_TABS_LIST))
145
 
                return 22;
146
 
        
147
 
        // '<>'
148
 
        if(!(style & wxFNB_NO_NAV_BUTTONS) && (style & wxFNB_NO_X_BUTTON) && !(style & wxFNB_DROPDOWN_TABS_LIST))
149
 
                return 53 - 16;
150
 
        
151
 
        // 'vx'
152
 
        if((style & wxFNB_DROPDOWN_TABS_LIST) && !(style & wxFNB_NO_X_BUTTON))
153
 
                return 22 + 16;
154
 
 
155
 
        // 'v'
156
 
        if((style & wxFNB_DROPDOWN_TABS_LIST) && (style & wxFNB_NO_X_BUTTON))
157
 
                return 22;
158
 
 
159
 
        // '<>x'
160
 
        return 53;
161
 
}
162
 
 
163
 
void wxFNBRenderer::DrawLeftArrow(wxWindow* pageContainer, wxDC& dc)
164
 
{
165
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
166
 
        long style = pc->GetParent()->GetWindowStyleFlag();
167
 
        if(style & wxFNB_NO_NAV_BUTTONS)
168
 
                return;
169
 
 
170
 
        // Make sure that there are pages in the container
171
 
        if(pc->GetPageInfoVector().empty())
172
 
                return;
173
 
 
174
 
        // Set the bitmap according to the button status
175
 
        wxBitmap arrowBmp;
176
 
        switch(pc->m_nLeftButtonStatus)
177
 
        {
178
 
        case wxFNB_BTN_HOVER:
179
 
                arrowBmp = wxBitmap(left_arrow_hilite_xpm);
180
 
                break;
181
 
        case wxFNB_BTN_PRESSED:
182
 
                arrowBmp = wxBitmap(left_arrow_pressed_xpm);
183
 
                break;
184
 
        case wxFNB_BTN_NONE:
185
 
        default:
186
 
                arrowBmp = wxBitmap(left_arrow_xpm);
187
 
                break;
188
 
        }
189
 
 
190
 
        if(pc->m_nFrom == 0)
191
 
        {
192
 
                // Handle disabled arrow
193
 
                arrowBmp = wxBitmap(left_arrow_disabled_xpm);
194
 
        }
195
 
 
196
 
        arrowBmp.SetMask(new wxMask(arrowBmp, MASK_COLOR));
197
 
 
198
 
        // Erase old bitmap
199
 
        int posx = GetLeftButtonPos( pc );
200
 
        dc.DrawBitmap(m_leftBgBmp, posx, 6);
201
 
 
202
 
        // Draw the new bitmap
203
 
        dc.DrawBitmap(arrowBmp, posx, 6, true);
204
 
}
205
 
 
206
 
void wxFNBRenderer::DrawRightArrow(wxWindow* pageContainer, wxDC& dc)
207
 
{
208
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
209
 
        long style = pc->GetParent()->GetWindowStyleFlag();
210
 
        if(style & wxFNB_NO_NAV_BUTTONS)
211
 
                return;
212
 
 
213
 
        // Make sure that there are pages in the container
214
 
        if(pc->GetPageInfoVector().empty())
215
 
                return;
216
 
 
217
 
        // Set the bitmap according to the button status
218
 
        wxBitmap arrowBmp;
219
 
        switch(pc->m_nRightButtonStatus)
220
 
        {
221
 
        case wxFNB_BTN_HOVER:
222
 
                arrowBmp = wxBitmap(right_arrow_hilite_xpm);
223
 
                break;
224
 
        case wxFNB_BTN_PRESSED:
225
 
                arrowBmp = wxBitmap(right_arrow_pressed_xpm);
226
 
                break;
227
 
        case wxFNB_BTN_NONE:
228
 
        default:
229
 
                arrowBmp = wxBitmap(right_arrow_xpm);
230
 
                break;
231
 
        }
232
 
 
233
 
 
234
 
        // Check if the right most tab is visible, if it is
235
 
        // don't rotate right anymore
236
 
        if(pc->GetPageInfoVector()[pc->GetPageInfoVector().GetCount()-1].GetPosition() != wxPoint(-1, -1))
237
 
        {
238
 
                arrowBmp = wxBitmap(right_arrow_disabled_xpm);
239
 
        }
240
 
 
241
 
        arrowBmp.SetMask(new wxMask(arrowBmp, MASK_COLOR));
242
 
 
243
 
        // erase old bitmap
244
 
        int posx = GetRightButtonPos( pc ) ;
245
 
        dc.DrawBitmap(m_rightBgBmp, posx, 6);
246
 
 
247
 
        // Draw the new bitmap
248
 
        dc.DrawBitmap(arrowBmp, posx, 6, true);
249
 
}
250
 
 
251
 
void wxFNBRenderer::DrawDropDownArrow(wxWindow* pageContainer, wxDC& dc)
252
 
{
253
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
254
 
        // Check if this style is enabled
255
 
        long style = pc->GetParent()->GetWindowStyleFlag();
256
 
        if(! (style & wxFNB_DROPDOWN_TABS_LIST) )
257
 
                return;
258
 
 
259
 
        // Make sure that there are pages in the container
260
 
        if(pc->GetPageInfoVector().empty())
261
 
                return;
262
 
 
263
 
        // Set the bitmap according to the button status
264
 
        wxBitmap xbmp;
265
 
        
266
 
        switch(pc->m_nArrowDownButtonStatus)
267
 
        {
268
 
        case wxFNB_BTN_HOVER:
269
 
                xbmp = wxBitmap(down_arrow_hilite_xpm);
270
 
                break;
271
 
        case wxFNB_BTN_PRESSED:
272
 
                xbmp = wxBitmap(down_arrow_pressed_xpm);
273
 
                break;
274
 
        case wxFNB_BTN_NONE:
275
 
        default:
276
 
                xbmp = wxBitmap(down_arrow_xpm);
277
 
                break;
278
 
        }
279
 
 
280
 
        xbmp.SetMask(new wxMask(xbmp, MASK_COLOR));
281
 
        // erase old bitmap
282
 
        int posx = GetDropArrowButtonPos( pc );
283
 
        dc.DrawBitmap(m_rightBgBmp, posx, 6);
284
 
 
285
 
        // Draw the new bitmap
286
 
        dc.DrawBitmap(xbmp, posx, 6, true);
287
 
}
288
 
 
289
 
void wxFNBRenderer::DrawX(wxWindow* pageContainer, wxDC& dc)
290
 
{
291
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
292
 
        // Check if this style is enabled
293
 
        long style = pc->GetParent()->GetWindowStyleFlag();
294
 
        if(style & wxFNB_NO_X_BUTTON)
295
 
                return;
296
 
 
297
 
        // Make sure that there are pages in the container
298
 
        if(pc->GetPageInfoVector().empty())
299
 
                return;
300
 
 
301
 
        // Set the bitmap according to the button status
302
 
        wxBitmap xbmp;
303
 
        switch(pc->m_nXButtonStatus)
304
 
        {
305
 
        case wxFNB_BTN_HOVER:
306
 
                xbmp = wxBitmap(x_button_hilite_xpm);
307
 
                break;
308
 
        case wxFNB_BTN_PRESSED:
309
 
                xbmp = wxBitmap(x_button_pressed_xpm);
310
 
                break;
311
 
        case wxFNB_BTN_NONE:
312
 
        default:
313
 
                xbmp = wxBitmap(x_button_xpm);
314
 
                break;
315
 
        }
316
 
 
317
 
        xbmp.SetMask(new wxMask(xbmp, MASK_COLOR));
318
 
        // erase old bitmap
319
 
        int posx = GetXPos( pc );
320
 
        dc.DrawBitmap(m_xBgBmp, posx, 6);
321
 
 
322
 
        // Draw the new bitmap
323
 
        dc.DrawBitmap(xbmp, posx, 6, true);
324
 
}
325
 
 
326
 
void wxFNBRenderer::PaintStraightGradientBox(wxDC& dc, const wxRect& rect, const wxColour& startColor, const wxColour& endColor, bool  vertical)
327
 
{
328
 
        int rd, gd, bd, high = 0;
329
 
        rd = endColor.Red() - startColor.Red();
330
 
        gd = endColor.Green() - startColor.Green();
331
 
        bd = endColor.Blue() - startColor.Blue();
332
 
 
333
 
        /// Save the current pen and brush
334
 
        wxPen savedPen = dc.GetPen();
335
 
        wxBrush savedBrush = dc.GetBrush();
336
 
 
337
 
        if ( vertical )
338
 
                high = rect.GetHeight()-1;
339
 
        else
340
 
                high = rect.GetWidth()-1;
341
 
 
342
 
        if( high < 1 )
343
 
                return;
344
 
 
345
 
        for (int i = 0; i <= high; ++i)
346
 
        {
347
 
                int r = startColor.Red() +  ((i*rd*100)/high)/100;
348
 
                int g = startColor.Green() + ((i*gd*100)/high)/100;
349
 
                int b = startColor.Blue() + ((i*bd*100)/high)/100;
350
 
 
351
 
                wxPen p(wxColor(r, g, b));
352
 
                dc.SetPen(p);
353
 
 
354
 
                if ( vertical )
355
 
                        dc.DrawLine(rect.x, rect.y+i, rect.x+rect.width, rect.y+i);
356
 
                else
357
 
                        dc.DrawLine(rect.x+i, rect.y, rect.x+i, rect.y+rect.height);
358
 
        }
359
 
 
360
 
        /// Restore the pen and brush
361
 
        dc.SetPen( savedPen );
362
 
        dc.SetBrush( savedBrush );
363
 
}
364
 
 
365
 
void wxFNBRenderer::DrawTabX(wxWindow* pageContainer, wxDC& dc, const wxRect& rect, const int& tabIdx, const int btnStatus)
366
 
{
367
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
368
 
        if(!pc->HasFlag(wxFNB_X_ON_TAB))
369
 
                return;
370
 
 
371
 
        /// We draw the 'x' on the active tab only
372
 
        if(tabIdx != pc->GetSelection() || tabIdx < 0)
373
 
                return;
374
 
 
375
 
        // Set the bitmap according to the button status
376
 
        wxBitmap xBmp;
377
 
        switch(btnStatus)
378
 
        {
379
 
        case wxFNB_BTN_HOVER:
380
 
                xBmp = wxBitmap(x_button_xpm);
381
 
                break;
382
 
        case wxFNB_BTN_PRESSED:
383
 
                xBmp = wxBitmap(tab_x_button_pressed_xpm);
384
 
                break;
385
 
        case wxFNB_BTN_NONE:
386
 
        default:
387
 
                xBmp = wxBitmap(x_button_xpm);
388
 
                break;
389
 
        }
390
 
 
391
 
        /// Set the masking
392
 
        xBmp.SetMask(new wxMask(xBmp, MASK_COLOR));
393
 
 
394
 
        // erase old button
395
 
        dc.DrawBitmap(m_tabXBgBmp, rect.x, rect.y);
396
 
 
397
 
        // Draw the new bitmap
398
 
        dc.DrawBitmap(xBmp, rect.x, rect.y, true);
399
 
 
400
 
        // Update the vectpr
401
 
        wxRect rr(rect.x, rect.y, 14, 13);
402
 
        pc->GetPageInfoVector()[tabIdx].SetXRect( rr );
403
 
}
404
 
 
405
 
void wxFNBRenderer::GetBitmap(wxDC &dc, const wxRect &rect, wxBitmap &bmp)
406
 
{
407
 
        wxMemoryDC mem_dc;
408
 
        mem_dc.SelectObject(bmp);
409
 
        mem_dc.Blit(0, 0, rect.width, rect.height, &dc, rect.x, rect.y);
410
 
        mem_dc.SelectObject(wxNullBitmap);
411
 
}
412
 
 
413
 
wxColor wxFNBRenderer::RandomColor()
414
 
{
415
 
        int r, g, b;
416
 
        r = rand() % 256; // Random value betweem 0-255
417
 
        g = rand() % 256; // Random value betweem 0-255
418
 
        b = rand() % 256; // Random value betweem 0-255
419
 
        return wxColor(r, g, b);
420
 
}
421
 
 
422
 
wxColor wxFNBRenderer::LightColour(const wxColour& color, int percent)
423
 
{
424
 
        int rd, gd, bd, high = 0;
425
 
        wxColor end_color = wxT("WHITE");
426
 
        rd = end_color.Red() - color.Red();
427
 
        gd = end_color.Green() - color.Green();
428
 
        bd = end_color.Blue() - color.Blue();
429
 
        high = 100;
430
 
 
431
 
        // We take the percent way of the color from color --> white
432
 
        int i = percent;
433
 
        int r = color.Red() +  ((i*rd*100)/high)/100;
434
 
        int g = color.Green() + ((i*gd*100)/high)/100;
435
 
        int b = color.Blue() + ((i*bd*100)/high)/100;
436
 
        return wxColor(r, g, b);
437
 
}
438
 
 
439
 
void wxFNBRenderer::DrawTabsLine(wxWindow* pageContainer, wxDC& dc, wxCoord selTabX1, wxCoord selTabX2)
440
 
{
441
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
442
 
        wxRect clntRect = pc->GetClientRect();
443
 
        wxRect clientRect, clientRect2, clientRect3;
444
 
        clientRect3 = wxRect(0, 0, clntRect.width, clntRect.height);
445
 
 
446
 
        if( pc->HasFlag(wxFNB_FF2) ){
447
 
                wxColour fillColor;
448
 
                if( !pc->HasFlag(wxFNB_BOTTOM) ){
449
 
                        fillColor = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
450
 
                } else {
451
 
                        fillColor = wxColor(wxT("WHITE"));
452
 
                }
453
 
 
454
 
                dc.SetPen( wxPen(fillColor) );
455
 
                if(pc->HasFlag(wxFNB_BOTTOM)){
456
 
 
457
 
                        dc.DrawLine(1, 0, clntRect.width-1, 0);
458
 
                        dc.DrawLine(1, 1, clntRect.width-1, 1);
459
 
 
460
 
                        dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)));
461
 
                        dc.DrawLine(1, 2, clntRect.width-1, 2);
462
 
 
463
 
                        dc.SetPen(wxPen(fillColor));
464
 
                        dc.DrawLine(selTabX1 + 2, 2, selTabX2 - 1, 2);
465
 
                } else {
466
 
 
467
 
                
468
 
                        dc.DrawLine(1, clntRect.height, clntRect.width-1, clntRect.height);
469
 
                        dc.DrawLine(1, clntRect.height-1, clntRect.width-1, clntRect.height-1);
470
 
 
471
 
                        dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)));
472
 
                        dc.DrawLine(1, clntRect.height-2, clntRect.width-1, clntRect.height-2);
473
 
 
474
 
                        dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)));
475
 
                        dc.DrawLine(selTabX1 + 2, clntRect.height-2, selTabX2-1, clntRect.height-2);
476
 
                }
477
 
        } else {
478
 
 
479
 
 
480
 
                if(pc->HasFlag(wxFNB_BOTTOM))
481
 
                {
482
 
                        clientRect = wxRect(0, 2, clntRect.width, clntRect.height - 2);
483
 
                        clientRect2 = wxRect(0, 1, clntRect.width, clntRect.height - 1);
484
 
                }
485
 
                else
486
 
                {
487
 
                        clientRect = wxRect(0, 0, clntRect.width, clntRect.height - 2);
488
 
                        clientRect2 = wxRect(0, 0, clntRect.width, clntRect.height - 1);
489
 
                }
490
 
 
491
 
                dc.SetBrush(*wxTRANSPARENT_BRUSH);
492
 
                dc.SetPen( wxPen(pc->GetSingleLineBorderColor()) );
493
 
                dc.DrawRectangle(clientRect2);
494
 
                dc.DrawRectangle(clientRect3);
495
 
 
496
 
        /// Patch ---- Ti-R ---- Enable to have the same color border has the selected tab
497
 
                if(pc->HasFlag(wxFNB_INVERSE_COLOR_LINE_VC8))
498
 
                        dc.SetPen(wxPen(pc->m_colorBorder));
499
 
                else
500
 
                        dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)));
501
 
 
502
 
                dc.DrawRectangle(clientRect);
503
 
 
504
 
                if( !pc->HasFlag(wxFNB_TABS_BORDER_SIMPLE) )
505
 
                {
506
 
                        dc.SetPen(wxPen( pc->HasFlag( wxFNB_VC71) ? wxColour(247, 243, 233) : pc->m_tabAreaColor));
507
 
                        dc.DrawLine(0, 0, 0, clientRect.height+1);
508
 
                        if(pc->HasFlag(wxFNB_BOTTOM))
509
 
                        {
510
 
                                dc.DrawLine(0, clientRect.height+1, clientRect.width, clientRect.height+1);
511
 
                        }
512
 
                        else
513
 
                                dc.DrawLine(0, 0, clientRect.width, 0);
514
 
                        dc.DrawLine(clientRect.width - 1, 0, clientRect.width - 1, clientRect.height+1);
515
 
                }
516
 
 
517
 
        /// Patch ---- Ti-R ---- Enable to have the same color border has the selected tab
518
 
                if(pc->HasFlag(wxFNB_BOTTOM_LINE_COLOR_CHANGE))
519
 
                {
520
 
                        dc.SetPen(wxPen(pc->m_colorBorder));
521
 
 
522
 
                        clientRect3 = wxRect(0, clntRect.height-2, 1, 2);
523
 
                        dc.DrawRectangle(clientRect3);
524
 
 
525
 
                        clientRect3 = wxRect(clntRect.width-1, clntRect.height-2, 1, 2);
526
 
                        dc.DrawRectangle(clientRect3);
527
 
                }
528
 
        }
529
 
}
530
 
 
531
 
int wxFNBRenderer::CalcTabWidth(wxWindow *pageContainer, int tabIdx, int tabHeight)
532
 
{
533
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
534
 
        int tabWidth, shapePoints(0), width, pom;
535
 
        wxMemoryDC dc;
536
 
 
537
 
        // bitmap must be set before it can be used for anything
538
 
        wxBitmap bmp(10, 10);
539
 
        dc.SelectObject(bmp);
540
 
        
541
 
        /// Patch (SetTextForeground) ---- Ti-R ---- Good Text Colour
542
 
                /// -- old code ---
543
 
//      wxFont normalFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
544
 
        wxFont normalFont = pc->m_font;
545
 
        wxFont boldFont(normalFont);
546
 
        boldFont.SetWeight(wxFONTWEIGHT_BOLD);
547
 
 
548
 
        if( pc->IsDefaultTabs() )
549
 
                shapePoints = (int)(tabHeight*tan((double)pc->GetPageInfoVector()[tabIdx].GetTabAngle()/180.0*M_PI));
550
 
 
551
 
        if(pc->GetSelection() == tabIdx)
552
 
                dc.SetFont(boldFont);
553
 
        else
554
 
                dc.SetFont(normalFont);
555
 
        dc.GetTextExtent(pc->GetPageText(tabIdx), &width, &pom);
556
 
 
557
 
        // Set a minimum size to a tab
558
 
        if(width < 20)
559
 
                width = 20;
560
 
 
561
 
        tabWidth = ((wxFlatNotebook *)pc->m_pParent)->GetPadding() * 2 + width;
562
 
        
563
 
        /// Style to add a small 'x' button on the top right
564
 
        /// of the tab
565
 
        if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())
566
 
        {
567
 
                int spacer = 9;
568
 
                if( pc->HasFlag(wxFNB_VC8) )
569
 
                        spacer = 4;
570
 
 
571
 
                tabWidth += ((wxFlatNotebook *)pc->m_pParent)->GetPadding() + spacer;
572
 
        }
573
 
 
574
 
        if( pc->IsDefaultTabs() )
575
 
                // Default style
576
 
                tabWidth += 2 * shapePoints;
577
 
 
578
 
        bool hasImage = (pc->m_ImageList != NULL && pc->GetPageInfoVector()[tabIdx].GetImageIndex() != -1);
579
 
 
580
 
        // For VC71 style, we only add the icon size (16 pixels)
581
 
        if(hasImage)
582
 
        {
583
 
                if( ! pc->IsDefaultTabs() )
584
 
                        tabWidth += (16 + ((wxFlatNotebook*)pc->m_pParent)->GetPadding());
585
 
                else
586
 
                        // Default style
587
 
                        tabWidth += (16 + ((wxFlatNotebook*)pc->m_pParent)->GetPadding()) + shapePoints / 2;
588
 
        }
589
 
        return tabWidth;
590
 
}
591
 
 
592
 
void wxFNBRenderer::NumberTabsCanFit(wxWindow *pageContainer, std::vector<wxRect> &vTabInfo, int from)
593
 
{
594
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
595
 
        int tabHeight, clientWidth;
596
 
        
597
 
        wxRect rect = pc->GetClientRect();
598
 
        clientWidth = rect.width;
599
 
 
600
 
        /// Empty results
601
 
        vTabInfo.clear();
602
 
 
603
 
        tabHeight = CalcTabHeight( pageContainer );
604
 
 
605
 
        // The drawing starts from posx
606
 
        int posx = ((wxFlatNotebook *)pc->m_pParent)->GetPadding();
607
 
        
608
 
        if( from < 0 )
609
 
                from = pc->m_nFrom;
610
 
 
611
 
        for(int i = from; i<(int)pc->GetPageInfoVector().GetCount(); i++)
612
 
        {
613
 
                int tabWidth = CalcTabWidth( pageContainer, i, tabHeight );
614
 
                if(posx + tabWidth + GetButtonsAreaLength( pc ) >= clientWidth)
615
 
                        break;
616
 
 
617
 
                /// Add a result to the returned vector
618
 
                wxRect tabRect(posx, VERTICAL_BORDER_PADDING, tabWidth , tabHeight);
619
 
                vTabInfo.push_back(tabRect);
620
 
 
621
 
                /// Advance posx
622
 
                posx += tabWidth;
623
 
        }
624
 
}
625
 
 
626
 
void wxFNBRenderer::DrawDragHint(wxWindow *pageContainer, int tabIdx)
627
 
{
628
 
        wxUnusedVar( pageContainer );
629
 
        wxUnusedVar( tabIdx );
630
 
}
631
 
 
632
 
int wxFNBRenderer::CalcTabHeight(wxWindow *pageContainer)
633
 
{
634
 
        int tabHeight;
635
 
        wxMemoryDC dc;
636
 
        wxUnusedVar( pageContainer );
637
 
 
638
 
        wxBitmap bmp(10, 10);
639
 
        dc.SelectObject(bmp);
640
 
 
641
 
        // For GTK it seems that we must do this steps in order
642
 
        // for the tabs will get the proper height on initialization
643
 
        // on MSW, preforming these steps yields wierd results
644
 
        wxFont normalFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
645
 
        wxFont boldFont = normalFont;
646
 
        boldFont.SetWeight(wxFONTWEIGHT_BOLD);
647
 
#ifdef __WXGTK__
648
 
        dc.SetFont( boldFont );
649
 
#endif
650
 
 
651
 
        static int height(-1);
652
 
        static int width(-1);
653
 
 
654
 
        if( height == -1 && width == -1 )
655
 
        {
656
 
                wxString stam = wxT("Tp");      // Temp data to get the text height;
657
 
                dc.GetTextExtent(stam, &width, &height);
658
 
        }
659
 
 
660
 
        tabHeight = height + wxFNB_HEIGHT_SPACER; // We use 8 pixels as padding
661
 
#ifdef __WXGTK__
662
 
        // On GTK the tabs are should be larger
663
 
        tabHeight += 6;
664
 
#endif
665
 
        return tabHeight;
666
 
}
667
 
 
668
 
void wxFNBRenderer::DrawTabs(wxWindow *pageContainer, wxDC &dc, wxEvent &event)
669
 
{
670
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
671
 
#ifndef __WXMAC__
672
 
        // Works well on MSW & GTK, however this lines should be skipped on MAC
673
 
        if(pc->GetPageInfoVector().empty() || pc->m_nFrom >= (int)pc->GetPageInfoVector().GetCount())
674
 
        {
675
 
                pc->Hide();
676
 
                event.Skip();
677
 
                return;
678
 
        }
679
 
#endif
680
 
 
681
 
        // Get the text hight
682
 
        int tabHeight = CalcTabHeight(pageContainer);
683
 
        long style = pc->GetParent()->GetWindowStyleFlag();
684
 
        
685
 
        // Calculate the number of rows required for drawing the tabs
686
 
        wxRect rect = pc->GetClientRect();
687
 
//      int clientWidth = rect.width;
688
 
 
689
 
        // Set the maximum client size
690
 
#ifdef __WXMAC__
691
 
        pc->SetSizeHints(wxSize(GetButtonsAreaLength( pc ), tabHeight));
692
 
#endif
693
 
        wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
694
 
 
695
 
        wxBrush backBrush;
696
 
        if(style & wxFNB_VC71)
697
 
                backBrush = wxBrush(wxColour(247, 243, 233));
698
 
        else
699
 
                backBrush = wxBrush(pc->m_tabAreaColor);
700
 
 
701
 
        wxBrush noselBrush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
702
 
        wxBrush selBrush = wxBrush(pc->m_activeTabColor);
703
 
 
704
 
        wxSize size = pc->GetSize();
705
 
 
706
 
        // Background
707
 
    dc.SetTextBackground((style & wxFNB_VC71 ? wxColour(247, 243, 233) : pc->GetBackgroundColour()));
708
 
        dc.SetTextForeground(pc->m_activeTextColor);
709
 
        dc.SetBrush(backBrush);
710
 
 
711
 
        // If border style is set, set the pen to be border pen
712
 
        if(pc->HasFlag(wxFNB_TABS_BORDER_SIMPLE))
713
 
                dc.SetPen(borderPen);
714
 
        else
715
 
        {
716
 
                wxColor colr = pc->HasFlag( wxFNB_VC71 ) ? wxColour(247, 243, 233) : pc->GetBackgroundColour();
717
 
                dc.SetPen( wxPen(colr) );
718
 
        }
719
 
 
720
 
        if( pc->HasFlag(wxFNB_FF2) ){
721
 
                int lightFactor = pc->HasFlag(wxFNB_BACKGROUND_GRADIENT) ? 70 : 0;
722
 
                PaintStraightGradientBox(dc, pc->GetClientRect(), pc->m_tabAreaColor, LightColour(pc->m_tabAreaColor, lightFactor));
723
 
                dc.SetBrush( *wxTRANSPARENT_BRUSH );
724
 
                dc.DrawRectangle(0, 0, size.x, size.y);
725
 
        } else {
726
 
                dc.DrawRectangle(0, 0, size.x, size.y);
727
 
        }
728
 
 
729
 
        // Take 3 bitmaps for the background for the buttons
730
 
        {
731
 
                wxMemoryDC mem_dc;
732
 
                wxRect rect;
733
 
 
734
 
                //---------------------------------------
735
 
                // X button
736
 
                //---------------------------------------
737
 
                rect = wxRect(GetXPos( pc ), 6, 16, 14);
738
 
                mem_dc.SelectObject(m_xBgBmp);
739
 
                mem_dc.Blit(0, 0, rect.width, rect.height, &dc, rect.x, rect.y);
740
 
                mem_dc.SelectObject(wxNullBitmap);
741
 
 
742
 
                //---------------------------------------
743
 
                // Right button
744
 
                //---------------------------------------
745
 
                rect = wxRect(GetRightButtonPos( pc ), 6, 16, 14);
746
 
                mem_dc.SelectObject(m_rightBgBmp);
747
 
                mem_dc.Blit(0, 0, rect.width, rect.height, &dc, rect.x, rect.y);
748
 
                mem_dc.SelectObject(wxNullBitmap);
749
 
 
750
 
                //---------------------------------------
751
 
                // Left button
752
 
                //---------------------------------------
753
 
                rect = wxRect(GetLeftButtonPos( pc ), 6, 16, 14);
754
 
                mem_dc.SelectObject(m_leftBgBmp);
755
 
                mem_dc.Blit(0, 0, rect.width, rect.height, &dc, rect.x, rect.y);
756
 
                mem_dc.SelectObject(wxNullBitmap);
757
 
        }
758
 
 
759
 
        // We always draw the bottom/upper line of the tabs
760
 
        // regradless the style
761
 
        dc.SetPen(borderPen);
762
 
 
763
 
        if( pc->HasFlag(wxFNB_FF2) == false ){
764
 
                DrawTabsLine(pc, dc);
765
 
        }
766
 
 
767
 
        // Restore the pen
768
 
        dc.SetPen(borderPen);
769
 
 
770
 
        if(pc->HasFlag( wxFNB_VC71 ))
771
 
        {
772
 
                int greyLineYVal  = pc->HasFlag( wxFNB_BOTTOM ) ? 0 : size.y - 2;
773
 
                int whiteLineYVal = pc->HasFlag( wxFNB_BOTTOM ) ? 3 : size.y - 3;
774
 
 
775
 
                wxPen pen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
776
 
                dc.SetPen(pen);
777
 
 
778
 
                // Draw thik grey line between the windows area and
779
 
                // the tab area
780
 
                int num = 0;
781
 
                for(; num<3; num++)
782
 
                        dc.DrawLine(0, greyLineYVal + num, size.x, greyLineYVal + num);
783
 
 
784
 
                wxPen wbPen = pc->HasFlag(wxFNB_BOTTOM) ? *wxBLACK_PEN : *wxWHITE_PEN;
785
 
                dc.SetPen( wbPen );
786
 
                dc.DrawLine(1, whiteLineYVal, size.x - 1, whiteLineYVal);
787
 
 
788
 
                // Restore the pen
789
 
                dc.SetPen(borderPen);
790
 
        }
791
 
 
792
 
#ifdef __WXMAC__
793
 
        // On MAC, Add these lines so the tab background gets painted
794
 
        if(pc->GetPageInfoVector().empty() || pc->m_nFrom >= (int)pc->GetPageInfoVector().GetCount())
795
 
        {
796
 
                pc->Hide();
797
 
                return;
798
 
        }
799
 
#endif
800
 
 
801
 
        // Draw labels
802
 
        /// Patch (SetTextForeground) ---- Ti-R ---- Good Text Colour
803
 
                /// -- old code ---
804
 
                //wxFont normalFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
805
 
        wxFont normalFont = pc->m_font;
806
 
        wxFont boldFont = normalFont;
807
 
        boldFont.SetWeight(wxFONTWEIGHT_BOLD);
808
 
        dc.SetFont(boldFont);
809
 
 
810
 
        int posx = ((wxFlatNotebook *)pc->m_pParent)->GetPadding();
811
 
        int i = 0;
812
 
 
813
 
        // Update all the tabs from 0 to 'pc->m_nFrom' to be non visible
814
 
        for(i=0; i<pc->m_nFrom; i++)
815
 
        {
816
 
                pc->GetPageInfoVector()[i].SetPosition(wxPoint(-1, -1));
817
 
                pc->GetPageInfoVector()[i].GetRegion().Clear();
818
 
        }
819
 
 
820
 
        //----------------------------------------------------------
821
 
        // Go over and draw the visible tabs
822
 
        //----------------------------------------------------------
823
 
        wxCoord x1(-1), x2(-1);
824
 
        std::vector<wxRect> vTabsInfo;
825
 
        NumberTabsCanFit(pc, vTabsInfo);
826
 
 
827
 
        for(i=pc->m_nFrom; i<pc->m_nFrom+(int)vTabsInfo.size(); i++)
828
 
        {
829
 
                dc.SetPen(borderPen);
830
 
                if( !pc->HasFlag(wxFNB_FF2) ){
831
 
                        dc.SetBrush((i==pc->GetSelection()) ? selBrush : noselBrush);
832
 
                }
833
 
 
834
 
                // Now set the font to the correct font
835
 
                dc.SetFont((i==pc->GetSelection()) ? boldFont : normalFont);
836
 
 
837
 
                // Add the padding to the tab width
838
 
                // Tab width:
839
 
                // +-----------------------------------------------------------+
840
 
                // | PADDING | IMG | IMG_PADDING | TEXT | PADDING | x |PADDING |
841
 
                // +-----------------------------------------------------------+
842
 
                int tabWidth = CalcTabWidth(pageContainer, i, tabHeight);
843
 
 
844
 
                // By default we clean the tab region
845
 
                pc->GetPageInfoVector()[i].GetRegion().Clear();
846
 
 
847
 
                // Clean the 'x' buttn on the tab.
848
 
                // A 'Clean' rectanlge, is a rectangle with width or height
849
 
                // with values lower than or equal to 0
850
 
                pc->GetPageInfoVector()[i].GetXRect().SetSize(wxSize(-1, -1));
851
 
 
852
 
                // Draw the tab (border, text, image & 'x' on tab)
853
 
                DrawTab(pc, dc, posx, i, tabWidth, tabHeight, pc->m_nTabXButtonStatus);
854
 
                
855
 
                if(pc->GetSelection() == i){
856
 
                        x1 = posx;
857
 
                        x2 = posx + tabWidth + 2;
858
 
                }
859
 
 
860
 
                // Restore the text forground
861
 
                dc.SetTextForeground(pc->m_activeTextColor);
862
 
 
863
 
                // Update the tab position & size
864
 
                int posy = pc->HasFlag(wxFNB_BOTTOM) ? 0 : VERTICAL_BORDER_PADDING;
865
 
 
866
 
                pc->GetPageInfoVector()[i].SetPosition(wxPoint(posx, posy));
867
 
                pc->GetPageInfoVector()[i].SetSize(wxSize(tabWidth, tabHeight));
868
 
                posx += tabWidth;
869
 
        }
870
 
 
871
 
        // Update all tabs that can not fit into the screen as non-visible
872
 
        for(; i<(int)pc->GetPageInfoVector().GetCount(); i++)
873
 
        {
874
 
                pc->GetPageInfoVector()[i].SetPosition(wxPoint(-1, -1));
875
 
                pc->GetPageInfoVector()[i].GetRegion().Clear();
876
 
        }
877
 
 
878
 
        // Draw the left/right/close buttons
879
 
        // Left arrow
880
 
        DrawLeftArrow(pc, dc);
881
 
        DrawRightArrow(pc, dc);
882
 
        DrawX(pc, dc);
883
 
        DrawDropDownArrow(pc, dc);
884
 
 
885
 
        if( pc->HasFlag(wxFNB_FF2) ){
886
 
                DrawTabsLine(pc, dc, x1, x2);
887
 
        }
888
 
}
889
 
 
890
 
//------------------------------------------
891
 
// Renderer manager
892
 
//------------------------------------------
893
 
wxFNBRendererMgr::wxFNBRendererMgr()
894
 
{
895
 
        // register renderers
896
 
        m_renderers[-1] = wxFNBRendererPtr(new wxFNBRendererDefault());
897
 
        m_renderers[wxFNB_VC71] = wxFNBRendererPtr(new wxFNBRendererVC71());
898
 
        m_renderers[wxFNB_FANCY_TABS] = wxFNBRendererPtr(new wxFNBRendererFancy());
899
 
        m_renderers[wxFNB_VC8] = wxFNBRendererPtr(new wxFNBRendererVC8());
900
 
        m_renderers[wxFNB_FF2] = wxFNBRendererPtr(new wxFNBRendererFirefox2());
901
 
}
902
 
 
903
 
wxFNBRendererMgr::~wxFNBRendererMgr()
904
 
{
905
 
}
906
 
 
907
 
wxFNBRendererPtr wxFNBRendererMgr::GetRenderer(long style)
908
 
{
909
 
        // Do the ugly switch/case
910
 
        if( style & wxFNB_VC71 )
911
 
                return m_renderers[wxFNB_VC71];
912
 
 
913
 
        if( style & wxFNB_FANCY_TABS )
914
 
                return m_renderers[wxFNB_FANCY_TABS];
915
 
 
916
 
        if( style & wxFNB_VC8 )
917
 
                return m_renderers[wxFNB_VC8];
918
 
 
919
 
        if( style & wxFNB_FF2 )
920
 
                return m_renderers[wxFNB_FF2];
921
 
 
922
 
        // the default is to return the default renderer
923
 
        return m_renderers[-1];
924
 
}
925
 
 
926
 
//------------------------------------------
927
 
// Default renderer 
928
 
//------------------------------------------
929
 
 
930
 
void wxFNBRendererDefault::DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus)
931
 
{
932
 
                // Default style
933
 
        wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
934
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
935
 
 
936
 
        wxPoint tabPoints[7];
937
 
        tabPoints[0].x = posx;
938
 
        tabPoints[0].y = pc->HasFlag(wxFNB_BOTTOM) ? 2 : tabHeight - 2;
939
 
 
940
 
        tabPoints[1].x = (int)(posx+(tabHeight-2)*tan((double)(pc->GetPageInfoVector())[tabIdx].GetTabAngle()/180.0*M_PI));
941
 
        tabPoints[1].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - (VERTICAL_BORDER_PADDING+2) : (VERTICAL_BORDER_PADDING+2);
942
 
 
943
 
        tabPoints[2].x = tabPoints[1].x+2;
944
 
        tabPoints[2].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;
945
 
 
946
 
        tabPoints[3].x = (int)(posx+tabWidth-(tabHeight-2)*tan((double)(pc->GetPageInfoVector())[tabIdx].GetTabAngle()/180.0*M_PI))-2;
947
 
        tabPoints[3].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;
948
 
 
949
 
        tabPoints[4].x = tabPoints[3].x+2;
950
 
        tabPoints[4].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - (VERTICAL_BORDER_PADDING+2) : (VERTICAL_BORDER_PADDING+2);
951
 
 
952
 
        tabPoints[5].x = (int)(tabPoints[4].x+(tabHeight-2)*tan((double)(pc->GetPageInfoVector())[tabIdx].GetTabAngle()/180.0*M_PI));
953
 
        tabPoints[5].y = pc->HasFlag(wxFNB_BOTTOM) ? 2 : tabHeight - 2;
954
 
 
955
 
        tabPoints[6].x = tabPoints[0].x;
956
 
        tabPoints[6].y = tabPoints[0].y;
957
 
 
958
 
        if(tabIdx == pc->GetSelection())
959
 
        {
960
 
                // Draw the tab as rounded rectangle
961
 
                dc.DrawPolygon(7, tabPoints);
962
 
        }
963
 
        else
964
 
        {
965
 
                if(tabIdx != pc->GetSelection() - 1)
966
 
                {
967
 
                        // Draw a vertical line to the right of the text
968
 
                        int pt1x, pt1y, pt2x, pt2y;
969
 
                        pt1x = tabPoints[5].x;
970
 
                        pt1y = pc->HasFlag(wxFNB_BOTTOM) ? 4 : tabHeight - 6;
971
 
                        pt2x = tabPoints[5].x;
972
 
                        pt2y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - 4 : 4 ;
973
 
                        dc.DrawLine(pt1x, pt1y, pt2x, pt2y);
974
 
                }
975
 
        }
976
 
 
977
 
        if(tabIdx == pc->GetSelection())
978
 
        {
979
 
                wxPen savePen = dc.GetPen();
980
 
                wxPen whitePen = wxPen(*wxWHITE);
981
 
                whitePen.SetWidth(1);
982
 
                dc.SetPen(whitePen);
983
 
 
984
 
                wxPoint secPt = wxPoint(tabPoints[5].x + 1, tabPoints[5].y);
985
 
                dc.DrawLine(tabPoints[0], secPt);
986
 
 
987
 
                // Restore the pen
988
 
                dc.SetPen(savePen);
989
 
        }
990
 
 
991
 
        // -----------------------------------
992
 
        // Text and image drawing
993
 
        // -----------------------------------
994
 
 
995
 
        // Text drawing offset from the left border of the
996
 
        // rectangle
997
 
        int textOffset;
998
 
 
999
 
        // The width of the images are 16 pixels
1000
 
        int padding = static_cast<wxFlatNotebook*>( pc->GetParent() )->GetPadding();
1001
 
        int shapePoints = (int)(tabHeight * tan((double)pc->GetPageInfoVector()[tabIdx].GetTabAngle()/180.0*M_PI));
1002
 
        bool hasImage = pc->GetPageInfoVector()[tabIdx].GetImageIndex() != -1;
1003
 
 
1004
 
#ifdef __WXMSW__
1005
 
        int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 8;
1006
 
#else 
1007
 
        int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 10;
1008
 
#endif
1009
 
 
1010
 
        hasImage ? textOffset = padding * 2 + 16 + shapePoints / 2 : textOffset = padding + shapePoints / 2 ;
1011
 
        textOffset += 2;
1012
 
 
1013
 
        if(tabIdx != pc->GetSelection())
1014
 
        {
1015
 
                // Set the text background to be like the vertical lines
1016
 
                dc.SetTextForeground( pc->GetNonoActiveTextColor() );
1017
 
        }
1018
 
 
1019
 
        if(hasImage)
1020
 
        {
1021
 
                int imageXOffset = textOffset - 16 - padding;
1022
 
                dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()],
1023
 
                        posx + imageXOffset, imageYCoord, true);
1024
 
        }
1025
 
 
1026
 
        dc.DrawText(pc->GetPageText(tabIdx), posx + textOffset, imageYCoord);
1027
 
 
1028
 
        // draw 'x' on tab (if enabled)
1029
 
        if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())
1030
 
        {
1031
 
                int textWidth, textHeight;
1032
 
                dc.GetTextExtent(pc->GetPageText(tabIdx), &textWidth, &textHeight);
1033
 
                int tabCloseButtonXCoord = posx + textOffset + textWidth + 1;
1034
 
 
1035
 
                // take a bitmap from the position of the 'x' button (the x on tab button)
1036
 
                // this bitmap will be used later to delete old buttons
1037
 
                int tabCloseButtonYCoord = imageYCoord;
1038
 
                wxRect x_rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16);
1039
 
                GetBitmap(dc, x_rect, m_tabXBgBmp);
1040
 
 
1041
 
                // Draw the tab
1042
 
                DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);                    
1043
 
        }
1044
 
}
1045
 
 
1046
 
//------------------------------------------
1047
 
// Firefox2 renderer 
1048
 
//------------------------------------------
1049
 
void wxFNBRendererFirefox2::DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus)
1050
 
{
1051
 
                // Default style
1052
 
        wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
1053
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
1054
 
 
1055
 
        wxPoint tabPoints[7];
1056
 
        tabPoints[0].x = posx + 2;
1057
 
        tabPoints[0].y = pc->HasFlag(wxFNB_BOTTOM) ? 2 : tabHeight - 2;
1058
 
 
1059
 
        tabPoints[1].x = tabPoints[0].x;
1060
 
        tabPoints[1].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - (VERTICAL_BORDER_PADDING+2) : (VERTICAL_BORDER_PADDING+2);
1061
 
 
1062
 
        tabPoints[2].x = tabPoints[1].x+2;
1063
 
        tabPoints[2].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;
1064
 
 
1065
 
        tabPoints[3].x = posx +tabWidth - 2;
1066
 
        tabPoints[3].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;
1067
 
 
1068
 
        tabPoints[4].x = tabPoints[3].x+2;
1069
 
        tabPoints[4].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - (VERTICAL_BORDER_PADDING+2) : (VERTICAL_BORDER_PADDING+2);
1070
 
 
1071
 
        tabPoints[5].x = tabPoints[4].x;
1072
 
        tabPoints[5].y = pc->HasFlag(wxFNB_BOTTOM) ? 2 : tabHeight - 2;
1073
 
 
1074
 
        tabPoints[6].x = tabPoints[0].x;
1075
 
        tabPoints[6].y = tabPoints[0].y;
1076
 
 
1077
 
        //------------------------------------
1078
 
        // Paint the tab with gradient
1079
 
        //------------------------------------
1080
 
        wxRect rr(tabPoints[2], tabPoints[5]);
1081
 
 
1082
 
        DrawButton( dc, 
1083
 
                                rr, 
1084
 
                                (pc->GetSelection() == tabIdx) || (pc->HasFlag( wxFNB_PREVIEW_SELECT_TAB ) && pc->GetEnabled(tabIdx) && pc->m_nTabStatus == wxFNB_BTN_HOVER && pc->m_nTabPreviewId == tabIdx) , 
1085
 
                                !pc->HasFlag(wxFNB_BOTTOM));
1086
 
 
1087
 
        dc.SetBrush( *wxTRANSPARENT_BRUSH );
1088
 
        dc.SetPen( borderPen );
1089
 
 
1090
 
        // Draw the tab as rounded rectangle
1091
 
        dc.DrawPolygon(7, tabPoints);
1092
 
 
1093
 
        // -----------------------------------
1094
 
        // Text and image drawing
1095
 
        // -----------------------------------
1096
 
 
1097
 
        // Text drawing offset from the left border of the
1098
 
        // rectangle
1099
 
        int textOffset;
1100
 
 
1101
 
        // The width of the images are 16 pixels
1102
 
        int padding = static_cast<wxFlatNotebook*>( pc->GetParent() )->GetPadding();
1103
 
        int shapePoints = (int)(tabHeight * tan((double)pc->GetPageInfoVector()[tabIdx].GetTabAngle()/180.0*M_PI));
1104
 
        bool hasImage = pc->GetPageInfoVector()[tabIdx].GetImageIndex() != -1;
1105
 
 
1106
 
#ifdef __WXMSW__
1107
 
        int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 8;
1108
 
#else 
1109
 
        int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 10;
1110
 
#endif
1111
 
 
1112
 
        hasImage ? textOffset = padding * 2 + 16 + shapePoints / 2 : textOffset = padding + shapePoints / 2 ;
1113
 
        textOffset += 2;
1114
 
 
1115
 
        if(tabIdx != pc->GetSelection())
1116
 
        {
1117
 
                // Set the text background to be like the vertical lines
1118
 
                dc.SetTextForeground( pc->GetNonoActiveTextColor() );
1119
 
        }
1120
 
 
1121
 
        if(hasImage)
1122
 
        {
1123
 
                int imageXOffset = textOffset - 16 - padding;
1124
 
                dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()],
1125
 
                        posx + imageXOffset, imageYCoord, true);
1126
 
        }
1127
 
 
1128
 
        dc.DrawText(pc->GetPageText(tabIdx), posx + textOffset, imageYCoord);
1129
 
 
1130
 
        // draw 'x' on tab (if enabled)
1131
 
        if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())
1132
 
        {
1133
 
                int textWidth, textHeight;
1134
 
                dc.GetTextExtent(pc->GetPageText(tabIdx), &textWidth, &textHeight);
1135
 
                int tabCloseButtonXCoord = posx + textOffset + textWidth + 1;
1136
 
 
1137
 
                // take a bitmap from the position of the 'x' button (the x on tab button)
1138
 
                // this bitmap will be used later to delete old buttons
1139
 
                int tabCloseButtonYCoord = imageYCoord;
1140
 
                wxRect x_rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16);
1141
 
                GetBitmap(dc, x_rect, m_tabXBgBmp);
1142
 
 
1143
 
                // Draw the tab
1144
 
                DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);                    
1145
 
        }
1146
 
}
1147
 
//------------------------------------------------------------------
1148
 
// Visual studio 7.1 
1149
 
//------------------------------------------------------------------
1150
 
 
1151
 
void wxFNBRendererVC71::DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus)
1152
 
{
1153
 
                // Visual studio 7.1 style
1154
 
        wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
1155
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
1156
 
 
1157
 
        dc.SetPen((tabIdx == pc->GetSelection()) ? wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)) : borderPen);
1158
 
    dc.SetBrush(((tabIdx == pc->GetSelection()) ? wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)) : wxBrush(wxColour(247, 243, 233))));
1159
 
 
1160
 
        if(tabIdx == pc->GetSelection())
1161
 
        {
1162
 
                int posy = pc->HasFlag(wxFNB_BOTTOM) ? 0 : VERTICAL_BORDER_PADDING;
1163
 
                int tabH = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - 5 : tabHeight - 3;
1164
 
 
1165
 
                dc.DrawRectangle(posx, posy, tabWidth, tabH);
1166
 
 
1167
 
                // Draw a black line on the left side of the
1168
 
                // rectangle
1169
 
                wxPen pen = wxPen(*wxBLACK);
1170
 
                dc.SetPen(pen);
1171
 
 
1172
 
                int blackLineY1 = VERTICAL_BORDER_PADDING;
1173
 
                int blackLineY2 = tabH;
1174
 
                dc.DrawLine(posx + tabWidth, blackLineY1, posx + tabWidth, blackLineY2);
1175
 
 
1176
 
                // To give the tab more 3D look we do the following
1177
 
                // Incase the tab is on top,
1178
 
                // Draw a thik white line on topof the rectangle
1179
 
                // Otherwise, draw a thin (1 pixel) black line at the bottom
1180
 
 
1181
 
                pen = wxPen(pc->HasFlag(wxFNB_BOTTOM) ? *wxBLACK : *wxWHITE);
1182
 
                dc.SetPen(pen);
1183
 
                int whiteLinePosY = pc->HasFlag(wxFNB_BOTTOM) ? blackLineY2 : VERTICAL_BORDER_PADDING ;
1184
 
                dc.DrawLine(posx , whiteLinePosY, posx + tabWidth + 1, whiteLinePosY);
1185
 
 
1186
 
                // Draw a white vertical line to the left of the tab
1187
 
                dc.SetPen( *wxWHITE_PEN );
1188
 
                if( !pc->HasFlag(wxFNB_BOTTOM) ) blackLineY2 += 1;
1189
 
                dc.DrawLine(posx, blackLineY1, posx, blackLineY2);
1190
 
        }
1191
 
        else
1192
 
        {
1193
 
                // We dont draw a rectangle for non selected tabs, but only
1194
 
                // vertical line on the left
1195
 
 
1196
 
                int blackLineY1 = pc->HasFlag(wxFNB_BOTTOM) ? VERTICAL_BORDER_PADDING + 2 : VERTICAL_BORDER_PADDING + 1;
1197
 
                int blackLineY2 = pc->GetSize().y - 5 ;
1198
 
                dc.DrawLine(posx + tabWidth, blackLineY1, posx + tabWidth, blackLineY2);
1199
 
        }
1200
 
 
1201
 
        // -----------------------------------
1202
 
        // Text and image drawing
1203
 
        // -----------------------------------
1204
 
 
1205
 
        // Text drawing offset from the left border of the
1206
 
        // rectangle
1207
 
        int textOffset;
1208
 
 
1209
 
        // The width of the images are 16 pixels
1210
 
        int padding = static_cast<wxFlatNotebook*>( pc->GetParent() )->GetPadding();
1211
 
        bool hasImage = pc->GetPageInfoVector()[tabIdx].GetImageIndex() != -1;
1212
 
        int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 5 : 8;
1213
 
        
1214
 
        hasImage ? textOffset = padding * 2 + 16 : textOffset = padding;
1215
 
 
1216
 
        if(tabIdx != pc->GetSelection())
1217
 
        {
1218
 
                // Set the text background to be like the vertical lines
1219
 
                dc.SetTextForeground(pc->GetNonoActiveTextColor());
1220
 
        }
1221
 
 
1222
 
        if(hasImage)
1223
 
        {
1224
 
                int imageXOffset = textOffset - 16 - padding;
1225
 
                dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()],
1226
 
                        posx + imageXOffset, imageYCoord, true);
1227
 
        }
1228
 
 
1229
 
        dc.DrawText(pc->GetPageText(tabIdx), posx + textOffset, imageYCoord);
1230
 
        
1231
 
        // draw 'x' on tab (if enabled)
1232
 
        if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())
1233
 
        {
1234
 
                int textWidth, textHeight;
1235
 
                dc.GetTextExtent(pc->GetPageText(tabIdx), &textWidth, &textHeight);
1236
 
                int tabCloseButtonXCoord = posx + textOffset + textWidth + 1;
1237
 
 
1238
 
                // take a bitmap from the position of the 'x' button (the x on tab button)
1239
 
                // this bitmap will be used later to delete old buttons
1240
 
                int tabCloseButtonYCoord = imageYCoord;
1241
 
                wxRect x_rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16);
1242
 
                GetBitmap(dc, x_rect, m_tabXBgBmp);
1243
 
 
1244
 
                // Draw the tab
1245
 
                DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);                    
1246
 
        }
1247
 
}
1248
 
 
1249
 
//------------------------------------------------------------------
1250
 
// Fancy style
1251
 
//------------------------------------------------------------------
1252
 
 
1253
 
void wxFNBRendererFancy::DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus)
1254
 
{
1255
 
                // Fancy tabs - like with VC71 but with the following differences:
1256
 
        // - The Selected tab is colored with gradient color
1257
 
        wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
1258
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
1259
 
 
1260
 
        wxPen pen = (tabIdx == pc->GetSelection()) ? wxPen( pc->GetBorderColour() ) : wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
1261
 
 
1262
 
        if(tabIdx == pc->GetSelection())
1263
 
        {
1264
 
                int posy = pc->HasFlag(wxFNB_BOTTOM) ? 2 : VERTICAL_BORDER_PADDING;
1265
 
                int th = tabHeight - 5;
1266
 
 
1267
 
                wxRect rect(posx, posy, tabWidth, th);
1268
 
 
1269
 
                wxColour col2 = (pc->HasFlag( wxFNB_BOTTOM ) ) ? pc->GetGradientColourTo() : pc->GetGradientColourFrom();
1270
 
                wxColour col1 = (pc->HasFlag( wxFNB_BOTTOM ) ) ? pc->GetGradientColourFrom() : pc->GetGradientColourTo();
1271
 
 
1272
 
                PaintStraightGradientBox(dc, rect, col1, col2);
1273
 
                dc.SetBrush(*wxTRANSPARENT_BRUSH);
1274
 
                dc.SetPen(pen);
1275
 
                dc.DrawRectangle(rect);
1276
 
 
1277
 
                // erase the bottom/top line of the rectangle
1278
 
                dc.SetPen( wxPen( pc->GetGradientColourFrom() ) );
1279
 
                if(pc->HasFlag(wxFNB_BOTTOM))
1280
 
            dc.DrawLine(rect.x, 2, rect.x + rect.width, 2);
1281
 
                else
1282
 
                        dc.DrawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width, rect.y + rect.height - 1);
1283
 
        }
1284
 
        else
1285
 
        {
1286
 
                // We dont draw a rectangle for non selected tabs, but only
1287
 
                // vertical line on the left
1288
 
                dc.SetPen(borderPen);
1289
 
                dc.DrawLine(posx + tabWidth, VERTICAL_BORDER_PADDING + 3, posx + tabWidth, tabHeight - 4);
1290
 
        }
1291
 
 
1292
 
        // -----------------------------------
1293
 
        // Text and image drawing
1294
 
        // -----------------------------------
1295
 
 
1296
 
        // Text drawing offset from the left border of the
1297
 
        // rectangle
1298
 
        int textOffset;
1299
 
 
1300
 
        // The width of the images are 16 pixels
1301
 
        int padding = static_cast<wxFlatNotebook*>( pc->GetParent() )->GetPadding();
1302
 
        bool hasImage = pc->GetPageInfoVector()[tabIdx].GetImageIndex() != -1;
1303
 
#ifdef __WXMSW__
1304
 
        int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 8;
1305
 
#else 
1306
 
        int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 10;
1307
 
#endif
1308
 
 
1309
 
        hasImage ? textOffset = padding * 2 + 16 : textOffset = padding ;
1310
 
 
1311
 
        if(tabIdx != pc->GetSelection())
1312
 
        {
1313
 
                // Set the text background to be like the vertical lines
1314
 
                dc.SetTextForeground(pc->GetNonoActiveTextColor());
1315
 
        }
1316
 
 
1317
 
        if(hasImage)
1318
 
        {
1319
 
                int imageXOffset = textOffset - 16 - padding;
1320
 
                dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()],
1321
 
                        posx + imageXOffset, imageYCoord, true);
1322
 
        }
1323
 
 
1324
 
        dc.DrawText(pc->GetPageText(tabIdx), posx + textOffset, imageYCoord);
1325
 
        
1326
 
        // draw 'x' on tab (if enabled)
1327
 
        if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())
1328
 
        {
1329
 
                int textWidth, textHeight;
1330
 
                dc.GetTextExtent(pc->GetPageText(tabIdx), &textWidth, &textHeight);
1331
 
                int tabCloseButtonXCoord = posx + textOffset + textWidth + 1;
1332
 
 
1333
 
                // take a bitmap from the position of the 'x' button (the x on tab button)
1334
 
                // this bitmap will be used later to delete old buttons
1335
 
                int tabCloseButtonYCoord = imageYCoord;
1336
 
                wxRect x_rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16);
1337
 
                GetBitmap(dc, x_rect, m_tabXBgBmp);
1338
 
 
1339
 
                // Draw the tab
1340
 
                DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);                    
1341
 
        }
1342
 
}
1343
 
 
1344
 
//------------------------------------------------------------------
1345
 
// Visual studio 2005 (VS8)
1346
 
//------------------------------------------------------------------
1347
 
void wxFNBRendererVC8::DrawTabs(wxWindow *pageContainer, wxDC &dc, wxEvent &event)
1348
 
{
1349
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
1350
 
 
1351
 
#ifndef __WXMAC__ 
1352
 
        // Works well on MSW & GTK, however this lines should be skipped on MAC
1353
 
        if(pc->GetPageInfoVector().empty() || pc->m_nFrom >= (int)pc->GetPageInfoVector().GetCount())
1354
 
        {
1355
 
                pc->Hide();
1356
 
                event.Skip();
1357
 
                return;
1358
 
        }
1359
 
#endif
1360
 
 
1361
 
        // Get the text hight
1362
 
        int tabHeight = CalcTabHeight( pageContainer );
1363
 
 
1364
 
        // Set the font for measuring the tab height
1365
 
        /// Patch (SetTextForeground) ---- Ti-R ---- Good Text Colour
1366
 
                /// -- old code ---
1367
 
                //wxFont normalFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
1368
 
        wxFont normalFont = pc->m_font;
1369
 
        wxFont boldFont = normalFont;
1370
 
        boldFont.SetWeight(wxFONTWEIGHT_BOLD);
1371
 
 
1372
 
        // Calculate the number of rows required for drawing the tabs
1373
 
        wxRect rect = pc->GetClientRect();
1374
 
 
1375
 
        // Set the maximum client size
1376
 
#ifdef __WXMAC__
1377
 
        pc->SetSizeHints(wxSize(GetButtonsAreaLength( pc ), tabHeight));
1378
 
#endif 
1379
 
        wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
1380
 
 
1381
 
        /// Create brushes
1382
 
        wxBrush backBrush;
1383
 
        backBrush = wxBrush(pc->m_tabAreaColor);
1384
 
        wxBrush noselBrush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
1385
 
        wxBrush selBrush = wxBrush(pc->m_activeTabColor);
1386
 
        wxSize size = pc->GetSize();
1387
 
 
1388
 
        // Background
1389
 
        dc.SetTextBackground(pc->GetBackgroundColour());
1390
 
        dc.SetTextForeground(pc->m_activeTextColor);
1391
 
        
1392
 
        // If border style is set, set the pen to be border pen
1393
 
        if( pc->HasFlag(wxFNB_TABS_BORDER_SIMPLE) )
1394
 
                dc.SetPen(borderPen);
1395
 
        else
1396
 
                dc.SetPen(*wxTRANSPARENT_PEN);
1397
 
 
1398
 
        int lightFactor = pc->HasFlag(wxFNB_BACKGROUND_GRADIENT) ? 70 : 0;
1399
 
        /// For VC8 style, we color the tab area in gradient coloring
1400
 
        PaintStraightGradientBox(dc, pc->GetClientRect(), pc->m_tabAreaColor, LightColour(pc->m_tabAreaColor, lightFactor));
1401
 
 
1402
 
        dc.SetBrush(*wxTRANSPARENT_BRUSH);
1403
 
        dc.DrawRectangle(0, 0, size.x, size.y);
1404
 
 
1405
 
        // Take 3 bitmaps for the background for the buttons
1406
 
        {
1407
 
                wxMemoryDC mem_dc;
1408
 
                wxRect rect;
1409
 
                
1410
 
                //---------------------------------------
1411
 
                // X button
1412
 
                //---------------------------------------
1413
 
                rect = wxRect(GetXPos( pc ), 6, 16, 14);
1414
 
                mem_dc.SelectObject(m_xBgBmp);
1415
 
                mem_dc.Blit(0, 0, rect.width, rect.height, &dc, rect.x, rect.y);
1416
 
                mem_dc.SelectObject(wxNullBitmap);
1417
 
 
1418
 
                //---------------------------------------
1419
 
                // Right button
1420
 
                //---------------------------------------
1421
 
                rect = wxRect(GetRightButtonPos( pc ), 6, 16, 14);
1422
 
                mem_dc.SelectObject(m_rightBgBmp);
1423
 
                mem_dc.Blit(0, 0, rect.width, rect.height, &dc, rect.x, rect.y);
1424
 
                mem_dc.SelectObject(wxNullBitmap);
1425
 
 
1426
 
                //---------------------------------------
1427
 
                // Left button
1428
 
                //---------------------------------------
1429
 
                rect = wxRect(GetLeftButtonPos( pc ), 6, 16, 14);
1430
 
                mem_dc.SelectObject(m_leftBgBmp);
1431
 
                mem_dc.Blit(0, 0, rect.width, rect.height, &dc, rect.x, rect.y);
1432
 
                mem_dc.SelectObject(wxNullBitmap);
1433
 
        }
1434
 
 
1435
 
        // We always draw the bottom/upper line of the tabs
1436
 
        // regradless the style
1437
 
        dc.SetPen(borderPen);
1438
 
        DrawTabsLine(pc, dc);
1439
 
 
1440
 
        // Restore the pen
1441
 
        dc.SetPen(borderPen);
1442
 
 
1443
 
        // Draw labels
1444
 
        dc.SetFont(boldFont);
1445
 
        int posx;
1446
 
        int i = 0, cur = 0;
1447
 
 
1448
 
        // Update all the tabs from 0 to 'pc->m_nFrom' to be non visible
1449
 
        for(i=0; i<pc->m_nFrom; i++)
1450
 
        {
1451
 
                pc->GetPageInfoVector()[i].SetPosition(wxPoint(-1, -1));
1452
 
                pc->GetPageInfoVector()[i].GetRegion().Clear();
1453
 
        }
1454
 
 
1455
 
        // Draw the visible tabs, in VC8 style, we draw them from right to left
1456
 
        std::vector<wxRect> vTabsInfo;
1457
 
        NumberTabsCanFit(pc, vTabsInfo);
1458
 
        int activeTabPosx(0);
1459
 
        int activeTabWidth(0);
1460
 
        int     activeTabHeight(0);
1461
 
 
1462
 
        for(cur=(int)vTabsInfo.size() - 1; cur>=0; cur--) 
1463
 
        {
1464
 
                /// 'i' points to the index of the currently drawn tab
1465
 
                /// in pc->GetPageInfoVector() vector
1466
 
                i = pc->m_nFrom + cur;
1467
 
                dc.SetPen(borderPen);
1468
 
                dc.SetBrush((i==pc->GetSelection()) ? selBrush : noselBrush);
1469
 
 
1470
 
                // Now set the font to the correct font
1471
 
                dc.SetFont((i==pc->GetSelection()) ? boldFont : normalFont);
1472
 
 
1473
 
                // Add the padding to the tab width
1474
 
                // Tab width:
1475
 
                // +-----------------------------------------------------------+
1476
 
                // | PADDING | IMG | IMG_PADDING | TEXT | PADDING | x |PADDING |
1477
 
                // +-----------------------------------------------------------+
1478
 
 
1479
 
                int tabWidth = CalcTabWidth( pageContainer, i, tabHeight );
1480
 
                posx = vTabsInfo[cur].x;
1481
 
 
1482
 
                // By default we clean the tab region
1483
 
                // incase we use the VC8 style which requires
1484
 
                // the region, it will be filled by the function
1485
 
                // drawVc8Tab
1486
 
                pc->GetPageInfoVector()[i].GetRegion().Clear();
1487
 
                
1488
 
                // Clean the 'x' buttn on the tab 
1489
 
                // 'Clean' rectanlge is a rectangle with width or height
1490
 
                // with values lower than or equal to 0
1491
 
                pc->GetPageInfoVector()[i].GetXRect().SetSize(wxSize(-1, -1));
1492
 
 
1493
 
                // Draw the tab
1494
 
                // Incase we are drawing the active tab
1495
 
                // we need to redraw so it will appear on top
1496
 
                // of all other tabs
1497
 
 
1498
 
                // when using the vc8 style, we keep the position of the active tab so we will draw it again later
1499
 
                if( i == pc->GetSelection() && pc->HasFlag( wxFNB_VC8 ) )
1500
 
                {
1501
 
                        activeTabPosx = posx;
1502
 
                        activeTabWidth = tabWidth;
1503
 
                        activeTabHeight = tabHeight;
1504
 
                }
1505
 
                else
1506
 
                {
1507
 
                        DrawTab(pc, dc, posx, i, tabWidth, tabHeight, pc->m_nTabXButtonStatus);
1508
 
                }
1509
 
 
1510
 
                // Restore the text forground
1511
 
                dc.SetTextForeground(pc->m_activeTextColor);
1512
 
 
1513
 
                // Update the tab position & size
1514
 
                pc->GetPageInfoVector()[i].SetPosition(wxPoint(posx, VERTICAL_BORDER_PADDING));
1515
 
                pc->GetPageInfoVector()[i].SetSize(wxSize(tabWidth, tabHeight));
1516
 
        }
1517
 
 
1518
 
        // Incase we are in VC8 style, redraw the active tab (incase it is visible)
1519
 
        if(pc->GetSelection() >= pc->m_nFrom && pc->GetSelection()< pc->m_nFrom + (int)vTabsInfo.size() )
1520
 
        {
1521
 
                DrawTab(pc, dc, activeTabPosx, pc->GetSelection(), activeTabWidth, activeTabHeight, pc->m_nTabXButtonStatus);
1522
 
        }
1523
 
 
1524
 
        // Update all tabs that can not fit into the screen as non-visible
1525
 
        int xx;
1526
 
        for(xx = pc->m_nFrom + (int)vTabsInfo.size(); xx<(int)pc->GetPageInfoVector().size(); xx++)
1527
 
        {
1528
 
                pc->GetPageInfoVector()[xx].SetPosition(wxPoint(-1, -1));
1529
 
                pc->GetPageInfoVector()[xx].GetRegion().Clear();
1530
 
        }
1531
 
 
1532
 
        // Draw the left/right/close buttons 
1533
 
        // Left arrow
1534
 
        DrawLeftArrow(pc, dc);
1535
 
        DrawRightArrow(pc, dc);
1536
 
        DrawX(pc, dc);
1537
 
        DrawDropDownArrow(pc, dc);
1538
 
}
1539
 
 
1540
 
void wxFNBRendererVC8::DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus)
1541
 
{
1542
 
        // Fancy tabs - like with VC71 but with the following differences:
1543
 
        // - The Selected tab is colored with gradient color
1544
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
1545
 
        wxPen borderPen = wxPen( pc->GetBorderColour() );
1546
 
        wxPoint tabPoints[8];
1547
 
 
1548
 
        // If we draw the first tab or the active tab, 
1549
 
        // we draw a full tab, else we draw a truncated tab
1550
 
        //
1551
 
        //             X(2)                  X(3)
1552
 
        //        X(1)                            X(4)
1553
 
        //                                          
1554
 
        //                                           X(5)
1555
 
        //                                           
1556
 
        // X(0),(7)                                  X(6)
1557
 
        //
1558
 
        //
1559
 
 
1560
 
        tabPoints[0].x = pc->HasFlag( wxFNB_BOTTOM ) ? posx : posx + m_factor;
1561
 
        tabPoints[0].y = pc->HasFlag( wxFNB_BOTTOM ) ? 2 : tabHeight - 3;
1562
 
 
1563
 
        tabPoints[1].x = tabPoints[0].x + tabHeight - VERTICAL_BORDER_PADDING - 3 - m_factor;
1564
 
        tabPoints[1].y = pc->HasFlag( wxFNB_BOTTOM ) ? tabHeight  - (VERTICAL_BORDER_PADDING+2) : (VERTICAL_BORDER_PADDING+2);
1565
 
 
1566
 
        tabPoints[2].x = tabPoints[1].x + 4;
1567
 
        tabPoints[2].y = pc->HasFlag( wxFNB_BOTTOM ) ? tabHeight  - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;
1568
 
 
1569
 
        tabPoints[3].x = tabPoints[2].x + tabWidth - 2;
1570
 
        tabPoints[3].y = pc->HasFlag( wxFNB_BOTTOM ) ? tabHeight  - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;
1571
 
 
1572
 
        tabPoints[4].x = tabPoints[3].x + 1;
1573
 
        tabPoints[4].y = pc->HasFlag( wxFNB_BOTTOM ) ? tabPoints[3].y - 1 : tabPoints[3].y + 1;
1574
 
 
1575
 
        tabPoints[5].x = tabPoints[4].x + 1;
1576
 
        tabPoints[5].y = pc->HasFlag( wxFNB_BOTTOM ) ? (tabPoints[4].y - 1 ): tabPoints[4].y + 1;
1577
 
 
1578
 
        tabPoints[6].x = tabPoints[2].x + tabWidth;
1579
 
        tabPoints[6].y = tabPoints[0].y;
1580
 
 
1581
 
        tabPoints[7].x = tabPoints[0].x;
1582
 
        tabPoints[7].y = tabPoints[0].y;
1583
 
 
1584
 
        pc->GetPageInfoVector()[tabIdx].SetRegion(8, tabPoints);
1585
 
 
1586
 
        // Draw the polygon
1587
 
        wxBrush br = dc.GetBrush();
1588
 
        dc.SetBrush(wxBrush(tabIdx == pc->GetSelection() ? pc->GetActiveTabColour() : pc->GetGradientColourTo() ));
1589
 
        
1590
 
/// Patch ---- Ti-R ---- Enable to have the same line color as the selected tab
1591
 
        if(pc->HasFlag( wxFNB_INVERSE_COLOR_LINE_VC8 ))
1592
 
                dc.SetPen(wxPen(tabIdx == pc->GetSelection() ? pc->GetBorderColour() : wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)));
1593
 
        else
1594
 
                dc.SetPen(wxPen(tabIdx == pc->GetSelection() ? wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW) : pc->GetBorderColour()));
1595
 
        dc.DrawPolygon(8, tabPoints);
1596
 
 
1597
 
        // Restore the brush
1598
 
        dc.SetBrush(br);
1599
 
 
1600
 
        wxRect rect = pc->GetClientRect();
1601
 
 
1602
 
        if(tabIdx != pc->GetSelection() && !pc->HasFlag( wxFNB_BOTTOM ))
1603
 
        {
1604
 
 
1605
 
        /// Patch ---- Ti-R ---- Enable to have the same line color as the selected tab
1606
 
                if(pc->HasFlag( wxFNB_INVERSE_COLOR_LINE_VC8 ))
1607
 
                {
1608
 
                        // Top default tabs
1609
 
                        dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)));
1610
 
                }
1611
 
                else
1612
 
                {
1613
 
                        // Top default tabs
1614
 
                        dc.SetPen(wxPen( pc->GetBorderColour() ));
1615
 
                }
1616
 
 
1617
 
                int lineY = rect.height;
1618
 
                wxPen curPen = dc.GetPen();
1619
 
                curPen.SetWidth(1);
1620
 
                dc.SetPen(curPen);
1621
 
                dc.DrawLine(posx, lineY, posx+rect.width, lineY);
1622
 
        }
1623
 
 
1624
 
        // Incase we are drawing the selected tab, we draw the border of it as well
1625
 
        // but without the bottom (upper line incase of wxBOTTOM)
1626
 
        if(tabIdx == pc->GetSelection())
1627
 
        {
1628
 
                wxPen borderPen ;
1629
 
 
1630
 
        /// Patch ---- Ti-R ---- Enable to have the same line color as the selected tab
1631
 
                if(pc->HasFlag( wxFNB_INVERSE_COLOR_LINE_VC8 ))
1632
 
                        borderPen = pc->GetBorderColour();
1633
 
                else
1634
 
                        borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
1635
 
 
1636
 
                wxBrush brush(*wxTRANSPARENT_BRUSH);
1637
 
                dc.SetPen(borderPen);
1638
 
                dc.SetBrush(brush);
1639
 
                dc.DrawPolygon(8, tabPoints);
1640
 
 
1641
 
                // Delete the bottom line (or the upper one, incase we use wxBOTTOM) 
1642
 
                dc.SetPen(wxPen(wxT("WHITE")));
1643
 
                dc.DrawLine(tabPoints[0], tabPoints[6]);
1644
 
        }
1645
 
 
1646
 
 
1647
 
        FillVC8GradientColor(pc, dc, tabPoints, tabIdx == pc->GetSelection(), tabIdx);
1648
 
 
1649
 
        // Draw a thin line to the right of the non-selected tab
1650
 
        if(tabIdx != pc->GetSelection())
1651
 
        {
1652
 
                dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)));
1653
 
                dc.DrawLine(tabPoints[4].x-1, tabPoints[4].y, tabPoints[5].x-1, tabPoints[5].y);
1654
 
                dc.DrawLine(tabPoints[5].x-1, tabPoints[5].y, tabPoints[6].x-1, tabPoints[6].y);
1655
 
        }
1656
 
 
1657
 
        // Text drawing offset from the left border of the 
1658
 
        // rectangle
1659
 
        int textOffset;
1660
 
 
1661
 
        // The width of the images are 16 pixels
1662
 
        int vc8ShapeLen = tabHeight - VERTICAL_BORDER_PADDING - 2;
1663
 
        if( pc->TabHasImage( tabIdx ) )
1664
 
                textOffset = ((wxFlatNotebook *)pc->m_pParent)->GetPadding() * 2 + 16 + vc8ShapeLen; 
1665
 
        else
1666
 
                textOffset = ((wxFlatNotebook *)pc->m_pParent)->GetPadding() + vc8ShapeLen;
1667
 
 
1668
 
        // Draw the image for the tab if any
1669
 
#ifdef __WXMSW__
1670
 
        int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 8;
1671
 
#else 
1672
 
        int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 10;
1673
 
#endif
1674
 
 
1675
 
        if( pc->TabHasImage( tabIdx ) )
1676
 
        {
1677
 
                int imageXOffset = textOffset - 16 - ((wxFlatNotebook *)pc->m_pParent)->GetPadding();
1678
 
                dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()], 
1679
 
                        posx + imageXOffset, imageYCoord, true);
1680
 
        }
1681
 
 
1682
 
        /// Patch (SetTextForeground) ---- Ti-R ---- Good Text Colour
1683
 
                /// -- old code ---
1684
 
                //wxFont boldFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
1685
 
        wxFont boldFont = pc->m_font;
1686
 
 
1687
 
        /// Patch (Test GetEnabled) ---- Ti-R ---- change color is disable
1688
 
        if(!pc->GetEnabled(tabIdx))
1689
 
        {
1690
 
                dc.SetTextForeground(pc->m_disableTextColor);
1691
 
        }
1692
 
        else
1693
 
        {
1694
 
                // if selected tab, draw text in bold
1695
 
                if( tabIdx == pc->GetSelection() )
1696
 
                {
1697
 
                /// Patch (SetTextForeground) ---- Ti-R ---- Good Text Colour
1698
 
                        dc.SetTextForeground(pc->m_activeTextColor);
1699
 
                        boldFont.SetWeight(wxFONTWEIGHT_BOLD);
1700
 
                }
1701
 
                else
1702
 
                {
1703
 
                /// Patch (SetTextForeground) ---- Ti-R ---- Good Text Colour
1704
 
                        dc.SetTextForeground(pc->m_nonActiveTextColor);
1705
 
                }
1706
 
        }
1707
 
 
1708
 
        dc.SetFont( boldFont );
1709
 
        dc.DrawText(pc->GetPageText(tabIdx), posx + textOffset, imageYCoord);
1710
 
        
1711
 
        // draw 'x' on tab (if enabled)
1712
 
        if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())
1713
 
        {
1714
 
                int textWidth, textHeight;
1715
 
                dc.GetTextExtent(pc->GetPageText(tabIdx), &textWidth, &textHeight);
1716
 
                int tabCloseButtonXCoord = posx + textOffset + textWidth + 1;
1717
 
 
1718
 
                // take a bitmap from the position of the 'x' button (the x on tab button)
1719
 
                // this bitmap will be used later to delete old buttons
1720
 
                int tabCloseButtonYCoord = imageYCoord;
1721
 
                wxRect x_rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16);
1722
 
                GetBitmap(dc, x_rect, m_tabXBgBmp);
1723
 
                wxBitmap bmp( 16, 16 );
1724
 
 
1725
 
                // Draw the tab
1726
 
                DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);                    
1727
 
        }
1728
 
}
1729
 
 
1730
 
void wxFNBRendererVC8::FillVC8GradientColor(wxWindow* pageContainer, wxDC &dc, const wxPoint tabPoints[], const bool bSelectedTab, const int tabIdx)
1731
 
{
1732
 
wxColour p_colorFrom;
1733
 
wxColour p_colorTo;
1734
 
 
1735
 
        // calculate gradient coefficients
1736
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
1737
 
 
1738
 
        /// Patch (comment) ---- Ti-R ---- No need anymore, see below
1739
 
/*      if( m_first )
1740
 
        {
1741
 
                m_first = false;
1742
 
                pc->m_colorTo   = LightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 0); 
1743
 
                pc->m_colorFrom = LightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 60);
1744
 
        }*/
1745
 
 
1746
 
        /// (BEGIN) Patch (m_nTabStatus) ---- Ti-R ---- Set the preview color
1747
 
        if( pc->HasFlag( wxFNB_PREVIEW_SELECT_TAB ) && pc->GetEnabled(tabIdx) && pc->m_nTabStatus == wxFNB_BTN_HOVER && pc->m_nTabPreviewId == tabIdx)
1748
 
        {
1749
 
                p_colorTo   = pc->m_colorPreview; 
1750
 
                p_colorFrom = pc->m_colorPreview;
1751
 
        }
1752
 
        else
1753
 
        {
1754
 
                p_colorTo   = pc->GetGradientColourTo(); //LightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 0); 
1755
 
                p_colorFrom = pc->GetGradientColourFrom(); //LightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 60);
1756
 
        }
1757
 
        /// (END) Patch (m_nTabStatus) ---- Ti-R ---- 
1758
 
 
1759
 
        wxColour col2 = pc->HasFlag( wxFNB_BOTTOM ) ? p_colorTo : p_colorFrom;
1760
 
        wxColour col1 = pc->HasFlag( wxFNB_BOTTOM ) ? p_colorFrom : p_colorTo;
1761
 
 
1762
 
        // If colorful tabs style is set, override the tab color
1763
 
        if(pc->HasFlag(wxFNB_COLORFUL_TABS))
1764
 
        {
1765
 
                if( !pc->GetPageInfoVector()[tabIdx].GetColor().Ok() )
1766
 
                {
1767
 
                        // First time, generate color, and keep it in the vector
1768
 
                        wxColor tabColor(RandomColor());
1769
 
                        pc->GetPageInfoVector()[tabIdx].SetColor(tabColor);
1770
 
                }
1771
 
 
1772
 
                if( pc->HasFlag(wxFNB_BOTTOM) )
1773
 
                {
1774
 
                        col2 = LightColour( pc->GetPageInfoVector()[tabIdx].GetColor() , 50 );
1775
 
                        col1 = LightColour( pc->GetPageInfoVector()[tabIdx].GetColor() , 80 );
1776
 
                }
1777
 
                else
1778
 
                {
1779
 
                        col1 = LightColour( pc->GetPageInfoVector()[tabIdx].GetColor() , 50 );
1780
 
                        col2 = LightColour( pc->GetPageInfoVector()[tabIdx].GetColor() , 80 );
1781
 
                }
1782
 
        }
1783
 
 
1784
 
        int size = abs(tabPoints[2].y - tabPoints[0].y) - 1;
1785
 
 
1786
 
        double rstep = double((col2.Red() -   col1.Red())) / double(size), rf = 0,
1787
 
                gstep = double((col2.Green() - col1.Green())) / double(size), gf = 0,
1788
 
                bstep = double((col2.Blue() -  col1.Blue())) / double(size), bf = 0;
1789
 
 
1790
 
        wxColour currCol;
1791
 
        int y = tabPoints[0].y; 
1792
 
 
1793
 
        // If we are drawing the selected tab, we need also to draw a line 
1794
 
        // from 0->tabPoints[0].x and tabPoints[6].x -> end, we achieve this
1795
 
        // by drawing the rectangle with transparent brush
1796
 
        // the line under the selected tab will be deleted by the drwaing loop
1797
 
        if( bSelectedTab )
1798
 
                DrawTabsLine(pc, dc);
1799
 
 
1800
 
        while( true )
1801
 
        {
1802
 
                if(pc->HasFlag( wxFNB_BOTTOM ))
1803
 
                {
1804
 
                        if(y > tabPoints[0].y + size)
1805
 
                                break;
1806
 
                }
1807
 
                else
1808
 
                {
1809
 
                        if(y < tabPoints[0].y - size)
1810
 
                                break;
1811
 
                }
1812
 
 
1813
 
                currCol.Set(
1814
 
                        (unsigned char)(col1.Red() + rf),
1815
 
                        (unsigned char)(col1.Green() + gf),
1816
 
                        (unsigned char)(col1.Blue() + bf)
1817
 
                        );
1818
 
 
1819
 
                dc.SetPen(bSelectedTab ? wxPen(pc->m_activeTabColor) : wxPen(currCol));
1820
 
                int startX = GetStartX(tabPoints, y, pc->GetParent()->GetWindowStyleFlag()) ;
1821
 
                int endX   = GetEndX(tabPoints, y, pc->GetParent()->GetWindowStyleFlag());
1822
 
                dc.DrawLine(startX, y, endX, y);
1823
 
 
1824
 
                // Draw the border using the 'edge' point
1825
 
                /// Patch ---- Ti-R ---- Enable to have the same line color as the selected tab
1826
 
                if(pc->HasFlag( wxFNB_INVERSE_COLOR_LINE_VC8 ))
1827
 
                        dc.SetPen(wxPen(bSelectedTab ? pc->m_colorBorder : wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)));
1828
 
                else
1829
 
                        dc.SetPen(wxPen(bSelectedTab ? wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW) : pc->m_colorBorder));
1830
 
                
1831
 
                dc.DrawPoint(startX, y);
1832
 
                dc.DrawPoint(endX, y);
1833
 
                
1834
 
                // Progress the color 
1835
 
                rf += rstep; gf += gstep; bf += bstep;
1836
 
 
1837
 
                pc->HasFlag( wxFNB_BOTTOM ) ? y++ : y--;
1838
 
        }
1839
 
}
1840
 
 
1841
 
int wxFNBRendererVC8::GetStartX(const wxPoint tabPoints[], const int &y, long style)
1842
 
{
1843
 
        double x1 = 0, x2 = 0, y1 = 0, y2 = 0;
1844
 
 
1845
 
        // We check the 3 points to the left
1846
 
        bool bBottomStyle = style & wxFNB_BOTTOM ? true : false;
1847
 
        bool match = false;
1848
 
 
1849
 
        if(bBottomStyle)
1850
 
        {
1851
 
                for(int i=0; i<3; i++)
1852
 
                {       
1853
 
                        if(y >= tabPoints[i].y && y < tabPoints[i+1].y)
1854
 
                        {
1855
 
                                x1 = tabPoints[i].x;
1856
 
                                x2 = tabPoints[i+1].x;
1857
 
                                y1 = tabPoints[i].y;
1858
 
                                y2 = tabPoints[i+1].y;
1859
 
                                match = true;
1860
 
                                break;
1861
 
                        }
1862
 
                }
1863
 
        }
1864
 
        else
1865
 
        {
1866
 
                for(int i=0; i<3; i++)
1867
 
                {       
1868
 
                        if(y <= tabPoints[i].y && y > tabPoints[i+1].y)
1869
 
                        {
1870
 
                                x1 = tabPoints[i].x;
1871
 
                                x2 = tabPoints[i+1].x;
1872
 
                                y1 = tabPoints[i].y;
1873
 
                                y2 = tabPoints[i+1].y;
1874
 
                                match = true;
1875
 
                                break;
1876
 
                        }
1877
 
                }
1878
 
        }
1879
 
 
1880
 
        if(!match)
1881
 
                return tabPoints[2].x;
1882
 
 
1883
 
        // According to the equation y = ax + b => x = (y-b)/a
1884
 
        // We know the first 2 points
1885
 
 
1886
 
        double a;
1887
 
        if(x2 == x1) 
1888
 
                return static_cast<int>( x2 );
1889
 
        else
1890
 
                a = (y2 - y1) / (x2 - x1);
1891
 
 
1892
 
        double b = y1 - ((y2 - y1) / (x2 - x1)) * x1;
1893
 
 
1894
 
        if(a == 0) 
1895
 
                return static_cast<int>( x1 );
1896
 
 
1897
 
        double x = (y - b) / a;
1898
 
        return static_cast<int>( x );
1899
 
}
1900
 
 
1901
 
int wxFNBRendererVC8::GetEndX(const wxPoint tabPoints[], const int &y, long style)
1902
 
{
1903
 
        double x1 = 0, x2 = 0, y1 = 0, y2 = 0;
1904
 
 
1905
 
        // We check the 3 points to the left
1906
 
        bool bBottomStyle = style & wxFNB_BOTTOM ? true : false;
1907
 
        bool match = false;
1908
 
 
1909
 
        if(bBottomStyle)
1910
 
        {
1911
 
                for(int i=7; i>3; i--)
1912
 
                {       
1913
 
                        if(y >= tabPoints[i].y && y < tabPoints[i-1].y)
1914
 
                        {
1915
 
                                x1 = tabPoints[i].x;
1916
 
                                x2 = tabPoints[i-1].x;
1917
 
                                y1 = tabPoints[i].y;
1918
 
                                y2 = tabPoints[i-1].y;
1919
 
                                match = true;
1920
 
                                break;
1921
 
                        }
1922
 
                }
1923
 
        }
1924
 
        else
1925
 
        {
1926
 
                for(int i=7; i>3; i--)
1927
 
                {       
1928
 
                        if(y <= tabPoints[i].y && y > tabPoints[i-1].y)
1929
 
                        {
1930
 
                                x1 = tabPoints[i].x;
1931
 
                                x2 = tabPoints[i-1].x;
1932
 
                                y1 = tabPoints[i].y;
1933
 
                                y2 = tabPoints[i-1].y;
1934
 
                                match = true;
1935
 
                                break;
1936
 
                        }
1937
 
                }
1938
 
        }
1939
 
 
1940
 
        if(!match)
1941
 
                return tabPoints[3].x;
1942
 
 
1943
 
        // According to the equation y = ax + b => x = (y-b)/a
1944
 
        // We know the first 2 points
1945
 
        double a = (y2 - y1) / (x2 - x1);
1946
 
 
1947
 
        // Vertical line
1948
 
        if(x1 == x2)
1949
 
                return (int)x1;
1950
 
 
1951
 
        double b = y1 - ((y2 - y1) / (x2 - x1)) * x1;
1952
 
 
1953
 
        if(a == 0) 
1954
 
                return (int)x1;
1955
 
 
1956
 
        double x = (y - b) / a;
1957
 
        return (int)x;
1958
 
}
1959
 
 
1960
 
void wxFNBRendererVC8::NumberTabsCanFit(wxWindow *pageContainer, std::vector<wxRect> &vTabInfo, int from)
1961
 
{
1962
 
        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
1963
 
        int tabHeight, clientWidth;
1964
 
        
1965
 
        wxRect rect = pc->GetClientRect();
1966
 
        clientWidth = rect.width;
1967
 
 
1968
 
        /// Empty results
1969
 
        vTabInfo.clear();
1970
 
 
1971
 
        tabHeight = CalcTabHeight( pageContainer );
1972
 
 
1973
 
        // The drawing starts from posx
1974
 
        int posx = ((wxFlatNotebook *)pc->m_pParent)->GetPadding();
1975
 
        
1976
 
        if( from < 0 )
1977
 
                from = pc->m_nFrom;
1978
 
 
1979
 
        for(int i = from; i<(int)pc->GetPageInfoVector().GetCount(); i++)
1980
 
        {
1981
 
                int vc8glitch = tabHeight + wxFNB_HEIGHT_SPACER;
1982
 
                int tabWidth = CalcTabWidth( pageContainer, i, tabHeight );
1983
 
                if(posx + tabWidth + vc8glitch + GetButtonsAreaLength( pc ) >= clientWidth)
1984
 
                        break;
1985
 
 
1986
 
                /// Add a result to the returned vector
1987
 
                wxRect tabRect(posx, VERTICAL_BORDER_PADDING, tabWidth , tabHeight);
1988
 
                vTabInfo.push_back(tabRect);
1989
 
 
1990
 
                /// Advance posx
1991
 
                posx += tabWidth + wxFNB_HEIGHT_SPACER;
1992
 
        }
1993
 
}