1
///////////////////////////////////////////////////////////////////////////////
3
// Purpose: implementation of the different renderers used by wxFlatNotebook
4
// Author: Eran Ifrah <eranif@bezeqint.net>
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>
16
# define FNB_LOG_MSG( msg ) { wxString logmsg; logmsg << msg; wxLogMessage( logmsg ); }
18
# define FNB_LOG_MSG( msg ) { wxString logmsg; logmsg << msg; }
21
//-----------------------------------------------------------------------------
23
//-----------------------------------------------------------------------------
25
static void DrawButton(wxDC& dc,
28
const bool &upperTabs)
30
// Define the middle points
31
wxPoint leftPt, rightPt;
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);
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);
41
leftPt = wxPoint(rect.x, rect.y + (rect.height / 2) );
42
rightPt = wxPoint(rect.x + rect.width - 2, rect.y + (rect.height / 2));
45
// Define the top region
46
wxRect top(rect.GetLeftTop(), rightPt);
47
wxRect bottom(leftPt, rect.GetBottomRight());
49
wxColour topStartColor(wxT("WHITE"));
52
topStartColor = wxFNBRenderer::LightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 50);
55
wxColour topEndColor( wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
56
wxColour bottomStartColor(topEndColor);
57
wxColour bottomEndColor(topEndColor);
59
// Incase we use bottom tabs, switch the colors
62
wxFNBRenderer::PaintStraightGradientBox(dc, top, topStartColor, topEndColor);
63
wxFNBRenderer::PaintStraightGradientBox(dc, bottom, bottomStartColor, bottomEndColor);
65
wxFNBRenderer::PaintStraightGradientBox(dc, top, topEndColor , topStartColor);
66
wxFNBRenderer::PaintStraightGradientBox(dc, bottom, bottomStartColor, bottomEndColor);
70
wxFNBRenderer::PaintStraightGradientBox(dc, bottom, topEndColor, bottomEndColor);
71
wxFNBRenderer::PaintStraightGradientBox(dc, top,topStartColor, topStartColor);
73
wxFNBRenderer::PaintStraightGradientBox(dc, bottom, bottomStartColor, bottomEndColor);
74
wxFNBRenderer::PaintStraightGradientBox(dc, top, topEndColor, topStartColor);
78
dc.SetBrush( *wxTRANSPARENT_BRUSH );
81
wxFNBRenderer::wxFNBRenderer()
85
, m_rightBgBmp(16, 14)
89
wxFNBRenderer::~wxFNBRenderer()
93
int wxFNBRenderer::GetLeftButtonPos(wxWindow* pageContainer)
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;
102
return clientWidth - 54;
105
int wxFNBRenderer::GetRightButtonPos(wxWindow* pageContainer)
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;
114
return clientWidth - 38;
117
int wxFNBRenderer::GetDropArrowButtonPos(wxWindow *pageContainer)
119
return GetRightButtonPos(pageContainer);
122
int wxFNBRenderer::GetXPos(wxWindow* pageContainer)
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)
131
return clientWidth - 22;
134
int wxFNBRenderer::GetButtonsAreaLength(wxWindow* pageContainer)
136
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
137
long style = pc->GetParent()->GetWindowStyleFlag();
140
if(style & wxFNB_NO_NAV_BUTTONS && style & wxFNB_NO_X_BUTTON && !(style & wxFNB_DROPDOWN_TABS_LIST))
144
if((style & wxFNB_NO_NAV_BUTTONS) && !(style & wxFNB_NO_X_BUTTON) && !(style & wxFNB_DROPDOWN_TABS_LIST))
148
if(!(style & wxFNB_NO_NAV_BUTTONS) && (style & wxFNB_NO_X_BUTTON) && !(style & wxFNB_DROPDOWN_TABS_LIST))
152
if((style & wxFNB_DROPDOWN_TABS_LIST) && !(style & wxFNB_NO_X_BUTTON))
156
if((style & wxFNB_DROPDOWN_TABS_LIST) && (style & wxFNB_NO_X_BUTTON))
163
void wxFNBRenderer::DrawLeftArrow(wxWindow* pageContainer, wxDC& dc)
165
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
166
long style = pc->GetParent()->GetWindowStyleFlag();
167
if(style & wxFNB_NO_NAV_BUTTONS)
170
// Make sure that there are pages in the container
171
if(pc->GetPageInfoVector().empty())
174
// Set the bitmap according to the button status
176
switch(pc->m_nLeftButtonStatus)
178
case wxFNB_BTN_HOVER:
179
arrowBmp = wxBitmap(left_arrow_hilite_xpm);
181
case wxFNB_BTN_PRESSED:
182
arrowBmp = wxBitmap(left_arrow_pressed_xpm);
186
arrowBmp = wxBitmap(left_arrow_xpm);
192
// Handle disabled arrow
193
arrowBmp = wxBitmap(left_arrow_disabled_xpm);
196
arrowBmp.SetMask(new wxMask(arrowBmp, MASK_COLOR));
199
int posx = GetLeftButtonPos( pc );
200
dc.DrawBitmap(m_leftBgBmp, posx, 6);
202
// Draw the new bitmap
203
dc.DrawBitmap(arrowBmp, posx, 6, true);
206
void wxFNBRenderer::DrawRightArrow(wxWindow* pageContainer, wxDC& dc)
208
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
209
long style = pc->GetParent()->GetWindowStyleFlag();
210
if(style & wxFNB_NO_NAV_BUTTONS)
213
// Make sure that there are pages in the container
214
if(pc->GetPageInfoVector().empty())
217
// Set the bitmap according to the button status
219
switch(pc->m_nRightButtonStatus)
221
case wxFNB_BTN_HOVER:
222
arrowBmp = wxBitmap(right_arrow_hilite_xpm);
224
case wxFNB_BTN_PRESSED:
225
arrowBmp = wxBitmap(right_arrow_pressed_xpm);
229
arrowBmp = wxBitmap(right_arrow_xpm);
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))
238
arrowBmp = wxBitmap(right_arrow_disabled_xpm);
241
arrowBmp.SetMask(new wxMask(arrowBmp, MASK_COLOR));
244
int posx = GetRightButtonPos( pc ) ;
245
dc.DrawBitmap(m_rightBgBmp, posx, 6);
247
// Draw the new bitmap
248
dc.DrawBitmap(arrowBmp, posx, 6, true);
251
void wxFNBRenderer::DrawDropDownArrow(wxWindow* pageContainer, wxDC& dc)
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) )
259
// Make sure that there are pages in the container
260
if(pc->GetPageInfoVector().empty())
263
// Set the bitmap according to the button status
266
switch(pc->m_nArrowDownButtonStatus)
268
case wxFNB_BTN_HOVER:
269
xbmp = wxBitmap(down_arrow_hilite_xpm);
271
case wxFNB_BTN_PRESSED:
272
xbmp = wxBitmap(down_arrow_pressed_xpm);
276
xbmp = wxBitmap(down_arrow_xpm);
280
xbmp.SetMask(new wxMask(xbmp, MASK_COLOR));
282
int posx = GetDropArrowButtonPos( pc );
283
dc.DrawBitmap(m_rightBgBmp, posx, 6);
285
// Draw the new bitmap
286
dc.DrawBitmap(xbmp, posx, 6, true);
289
void wxFNBRenderer::DrawX(wxWindow* pageContainer, wxDC& dc)
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)
297
// Make sure that there are pages in the container
298
if(pc->GetPageInfoVector().empty())
301
// Set the bitmap according to the button status
303
switch(pc->m_nXButtonStatus)
305
case wxFNB_BTN_HOVER:
306
xbmp = wxBitmap(x_button_hilite_xpm);
308
case wxFNB_BTN_PRESSED:
309
xbmp = wxBitmap(x_button_pressed_xpm);
313
xbmp = wxBitmap(x_button_xpm);
317
xbmp.SetMask(new wxMask(xbmp, MASK_COLOR));
319
int posx = GetXPos( pc );
320
dc.DrawBitmap(m_xBgBmp, posx, 6);
322
// Draw the new bitmap
323
dc.DrawBitmap(xbmp, posx, 6, true);
326
void wxFNBRenderer::PaintStraightGradientBox(wxDC& dc, const wxRect& rect, const wxColour& startColor, const wxColour& endColor, bool vertical)
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();
333
/// Save the current pen and brush
334
wxPen savedPen = dc.GetPen();
335
wxBrush savedBrush = dc.GetBrush();
338
high = rect.GetHeight()-1;
340
high = rect.GetWidth()-1;
345
for (int i = 0; i <= high; ++i)
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;
351
wxPen p(wxColor(r, g, b));
355
dc.DrawLine(rect.x, rect.y+i, rect.x+rect.width, rect.y+i);
357
dc.DrawLine(rect.x+i, rect.y, rect.x+i, rect.y+rect.height);
360
/// Restore the pen and brush
361
dc.SetPen( savedPen );
362
dc.SetBrush( savedBrush );
365
void wxFNBRenderer::DrawTabX(wxWindow* pageContainer, wxDC& dc, const wxRect& rect, const int& tabIdx, const int btnStatus)
367
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
368
if(!pc->HasFlag(wxFNB_X_ON_TAB))
371
/// We draw the 'x' on the active tab only
372
if(tabIdx != pc->GetSelection() || tabIdx < 0)
375
// Set the bitmap according to the button status
379
case wxFNB_BTN_HOVER:
380
xBmp = wxBitmap(x_button_xpm);
382
case wxFNB_BTN_PRESSED:
383
xBmp = wxBitmap(tab_x_button_pressed_xpm);
387
xBmp = wxBitmap(x_button_xpm);
392
xBmp.SetMask(new wxMask(xBmp, MASK_COLOR));
395
dc.DrawBitmap(m_tabXBgBmp, rect.x, rect.y);
397
// Draw the new bitmap
398
dc.DrawBitmap(xBmp, rect.x, rect.y, true);
401
wxRect rr(rect.x, rect.y, 14, 13);
402
pc->GetPageInfoVector()[tabIdx].SetXRect( rr );
405
void wxFNBRenderer::GetBitmap(wxDC &dc, const wxRect &rect, wxBitmap &bmp)
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);
413
wxColor wxFNBRenderer::RandomColor()
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);
422
wxColor wxFNBRenderer::LightColour(const wxColour& color, int percent)
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();
431
// We take the percent way of the color from color --> white
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);
439
void wxFNBRenderer::DrawTabsLine(wxWindow* pageContainer, wxDC& dc, wxCoord selTabX1, wxCoord selTabX2)
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);
446
if( pc->HasFlag(wxFNB_FF2) ){
448
if( !pc->HasFlag(wxFNB_BOTTOM) ){
449
fillColor = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
451
fillColor = wxColor(wxT("WHITE"));
454
dc.SetPen( wxPen(fillColor) );
455
if(pc->HasFlag(wxFNB_BOTTOM)){
457
dc.DrawLine(1, 0, clntRect.width-1, 0);
458
dc.DrawLine(1, 1, clntRect.width-1, 1);
460
dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)));
461
dc.DrawLine(1, 2, clntRect.width-1, 2);
463
dc.SetPen(wxPen(fillColor));
464
dc.DrawLine(selTabX1 + 2, 2, selTabX2 - 1, 2);
468
dc.DrawLine(1, clntRect.height, clntRect.width-1, clntRect.height);
469
dc.DrawLine(1, clntRect.height-1, clntRect.width-1, clntRect.height-1);
471
dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)));
472
dc.DrawLine(1, clntRect.height-2, clntRect.width-1, clntRect.height-2);
474
dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)));
475
dc.DrawLine(selTabX1 + 2, clntRect.height-2, selTabX2-1, clntRect.height-2);
480
if(pc->HasFlag(wxFNB_BOTTOM))
482
clientRect = wxRect(0, 2, clntRect.width, clntRect.height - 2);
483
clientRect2 = wxRect(0, 1, clntRect.width, clntRect.height - 1);
487
clientRect = wxRect(0, 0, clntRect.width, clntRect.height - 2);
488
clientRect2 = wxRect(0, 0, clntRect.width, clntRect.height - 1);
491
dc.SetBrush(*wxTRANSPARENT_BRUSH);
492
dc.SetPen( wxPen(pc->GetSingleLineBorderColor()) );
493
dc.DrawRectangle(clientRect2);
494
dc.DrawRectangle(clientRect3);
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));
500
dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)));
502
dc.DrawRectangle(clientRect);
504
if( !pc->HasFlag(wxFNB_TABS_BORDER_SIMPLE) )
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))
510
dc.DrawLine(0, clientRect.height+1, clientRect.width, clientRect.height+1);
513
dc.DrawLine(0, 0, clientRect.width, 0);
514
dc.DrawLine(clientRect.width - 1, 0, clientRect.width - 1, clientRect.height+1);
517
/// Patch ---- Ti-R ---- Enable to have the same color border has the selected tab
518
if(pc->HasFlag(wxFNB_BOTTOM_LINE_COLOR_CHANGE))
520
dc.SetPen(wxPen(pc->m_colorBorder));
522
clientRect3 = wxRect(0, clntRect.height-2, 1, 2);
523
dc.DrawRectangle(clientRect3);
525
clientRect3 = wxRect(clntRect.width-1, clntRect.height-2, 1, 2);
526
dc.DrawRectangle(clientRect3);
531
int wxFNBRenderer::CalcTabWidth(wxWindow *pageContainer, int tabIdx, int tabHeight)
533
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
534
int tabWidth, shapePoints(0), width, pom;
537
// bitmap must be set before it can be used for anything
538
wxBitmap bmp(10, 10);
539
dc.SelectObject(bmp);
541
/// Patch (SetTextForeground) ---- Ti-R ---- Good Text Colour
543
// wxFont normalFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
544
wxFont normalFont = pc->m_font;
545
wxFont boldFont(normalFont);
546
boldFont.SetWeight(wxFONTWEIGHT_BOLD);
548
if( pc->IsDefaultTabs() )
549
shapePoints = (int)(tabHeight*tan((double)pc->GetPageInfoVector()[tabIdx].GetTabAngle()/180.0*M_PI));
551
if(pc->GetSelection() == tabIdx)
552
dc.SetFont(boldFont);
554
dc.SetFont(normalFont);
555
dc.GetTextExtent(pc->GetPageText(tabIdx), &width, &pom);
557
// Set a minimum size to a tab
561
tabWidth = ((wxFlatNotebook *)pc->m_pParent)->GetPadding() * 2 + width;
563
/// Style to add a small 'x' button on the top right
565
if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())
568
if( pc->HasFlag(wxFNB_VC8) )
571
tabWidth += ((wxFlatNotebook *)pc->m_pParent)->GetPadding() + spacer;
574
if( pc->IsDefaultTabs() )
576
tabWidth += 2 * shapePoints;
578
bool hasImage = (pc->m_ImageList != NULL && pc->GetPageInfoVector()[tabIdx].GetImageIndex() != -1);
580
// For VC71 style, we only add the icon size (16 pixels)
583
if( ! pc->IsDefaultTabs() )
584
tabWidth += (16 + ((wxFlatNotebook*)pc->m_pParent)->GetPadding());
587
tabWidth += (16 + ((wxFlatNotebook*)pc->m_pParent)->GetPadding()) + shapePoints / 2;
592
void wxFNBRenderer::NumberTabsCanFit(wxWindow *pageContainer, std::vector<wxRect> &vTabInfo, int from)
594
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
595
int tabHeight, clientWidth;
597
wxRect rect = pc->GetClientRect();
598
clientWidth = rect.width;
603
tabHeight = CalcTabHeight( pageContainer );
605
// The drawing starts from posx
606
int posx = ((wxFlatNotebook *)pc->m_pParent)->GetPadding();
611
for(int i = from; i<(int)pc->GetPageInfoVector().GetCount(); i++)
613
int tabWidth = CalcTabWidth( pageContainer, i, tabHeight );
614
if(posx + tabWidth + GetButtonsAreaLength( pc ) >= clientWidth)
617
/// Add a result to the returned vector
618
wxRect tabRect(posx, VERTICAL_BORDER_PADDING, tabWidth , tabHeight);
619
vTabInfo.push_back(tabRect);
626
void wxFNBRenderer::DrawDragHint(wxWindow *pageContainer, int tabIdx)
628
wxUnusedVar( pageContainer );
629
wxUnusedVar( tabIdx );
632
int wxFNBRenderer::CalcTabHeight(wxWindow *pageContainer)
636
wxUnusedVar( pageContainer );
638
wxBitmap bmp(10, 10);
639
dc.SelectObject(bmp);
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);
648
dc.SetFont( boldFont );
651
static int height(-1);
652
static int width(-1);
654
if( height == -1 && width == -1 )
656
wxString stam = wxT("Tp"); // Temp data to get the text height;
657
dc.GetTextExtent(stam, &width, &height);
660
tabHeight = height + wxFNB_HEIGHT_SPACER; // We use 8 pixels as padding
662
// On GTK the tabs are should be larger
668
void wxFNBRenderer::DrawTabs(wxWindow *pageContainer, wxDC &dc, wxEvent &event)
670
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
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())
681
// Get the text hight
682
int tabHeight = CalcTabHeight(pageContainer);
683
long style = pc->GetParent()->GetWindowStyleFlag();
685
// Calculate the number of rows required for drawing the tabs
686
wxRect rect = pc->GetClientRect();
687
// int clientWidth = rect.width;
689
// Set the maximum client size
691
pc->SetSizeHints(wxSize(GetButtonsAreaLength( pc ), tabHeight));
693
wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
696
if(style & wxFNB_VC71)
697
backBrush = wxBrush(wxColour(247, 243, 233));
699
backBrush = wxBrush(pc->m_tabAreaColor);
701
wxBrush noselBrush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
702
wxBrush selBrush = wxBrush(pc->m_activeTabColor);
704
wxSize size = pc->GetSize();
707
dc.SetTextBackground((style & wxFNB_VC71 ? wxColour(247, 243, 233) : pc->GetBackgroundColour()));
708
dc.SetTextForeground(pc->m_activeTextColor);
709
dc.SetBrush(backBrush);
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);
716
wxColor colr = pc->HasFlag( wxFNB_VC71 ) ? wxColour(247, 243, 233) : pc->GetBackgroundColour();
717
dc.SetPen( wxPen(colr) );
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);
726
dc.DrawRectangle(0, 0, size.x, size.y);
729
// Take 3 bitmaps for the background for the buttons
734
//---------------------------------------
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);
742
//---------------------------------------
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);
750
//---------------------------------------
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);
759
// We always draw the bottom/upper line of the tabs
760
// regradless the style
761
dc.SetPen(borderPen);
763
if( pc->HasFlag(wxFNB_FF2) == false ){
764
DrawTabsLine(pc, dc);
768
dc.SetPen(borderPen);
770
if(pc->HasFlag( wxFNB_VC71 ))
772
int greyLineYVal = pc->HasFlag( wxFNB_BOTTOM ) ? 0 : size.y - 2;
773
int whiteLineYVal = pc->HasFlag( wxFNB_BOTTOM ) ? 3 : size.y - 3;
775
wxPen pen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
778
// Draw thik grey line between the windows area and
782
dc.DrawLine(0, greyLineYVal + num, size.x, greyLineYVal + num);
784
wxPen wbPen = pc->HasFlag(wxFNB_BOTTOM) ? *wxBLACK_PEN : *wxWHITE_PEN;
786
dc.DrawLine(1, whiteLineYVal, size.x - 1, whiteLineYVal);
789
dc.SetPen(borderPen);
793
// On MAC, Add these lines so the tab background gets painted
794
if(pc->GetPageInfoVector().empty() || pc->m_nFrom >= (int)pc->GetPageInfoVector().GetCount())
802
/// Patch (SetTextForeground) ---- Ti-R ---- Good Text Colour
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);
810
int posx = ((wxFlatNotebook *)pc->m_pParent)->GetPadding();
813
// Update all the tabs from 0 to 'pc->m_nFrom' to be non visible
814
for(i=0; i<pc->m_nFrom; i++)
816
pc->GetPageInfoVector()[i].SetPosition(wxPoint(-1, -1));
817
pc->GetPageInfoVector()[i].GetRegion().Clear();
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);
827
for(i=pc->m_nFrom; i<pc->m_nFrom+(int)vTabsInfo.size(); i++)
829
dc.SetPen(borderPen);
830
if( !pc->HasFlag(wxFNB_FF2) ){
831
dc.SetBrush((i==pc->GetSelection()) ? selBrush : noselBrush);
834
// Now set the font to the correct font
835
dc.SetFont((i==pc->GetSelection()) ? boldFont : normalFont);
837
// Add the padding to the tab width
839
// +-----------------------------------------------------------+
840
// | PADDING | IMG | IMG_PADDING | TEXT | PADDING | x |PADDING |
841
// +-----------------------------------------------------------+
842
int tabWidth = CalcTabWidth(pageContainer, i, tabHeight);
844
// By default we clean the tab region
845
pc->GetPageInfoVector()[i].GetRegion().Clear();
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));
852
// Draw the tab (border, text, image & 'x' on tab)
853
DrawTab(pc, dc, posx, i, tabWidth, tabHeight, pc->m_nTabXButtonStatus);
855
if(pc->GetSelection() == i){
857
x2 = posx + tabWidth + 2;
860
// Restore the text forground
861
dc.SetTextForeground(pc->m_activeTextColor);
863
// Update the tab position & size
864
int posy = pc->HasFlag(wxFNB_BOTTOM) ? 0 : VERTICAL_BORDER_PADDING;
866
pc->GetPageInfoVector()[i].SetPosition(wxPoint(posx, posy));
867
pc->GetPageInfoVector()[i].SetSize(wxSize(tabWidth, tabHeight));
871
// Update all tabs that can not fit into the screen as non-visible
872
for(; i<(int)pc->GetPageInfoVector().GetCount(); i++)
874
pc->GetPageInfoVector()[i].SetPosition(wxPoint(-1, -1));
875
pc->GetPageInfoVector()[i].GetRegion().Clear();
878
// Draw the left/right/close buttons
880
DrawLeftArrow(pc, dc);
881
DrawRightArrow(pc, dc);
883
DrawDropDownArrow(pc, dc);
885
if( pc->HasFlag(wxFNB_FF2) ){
886
DrawTabsLine(pc, dc, x1, x2);
890
//------------------------------------------
892
//------------------------------------------
893
wxFNBRendererMgr::wxFNBRendererMgr()
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());
903
wxFNBRendererMgr::~wxFNBRendererMgr()
907
wxFNBRendererPtr wxFNBRendererMgr::GetRenderer(long style)
909
// Do the ugly switch/case
910
if( style & wxFNB_VC71 )
911
return m_renderers[wxFNB_VC71];
913
if( style & wxFNB_FANCY_TABS )
914
return m_renderers[wxFNB_FANCY_TABS];
916
if( style & wxFNB_VC8 )
917
return m_renderers[wxFNB_VC8];
919
if( style & wxFNB_FF2 )
920
return m_renderers[wxFNB_FF2];
922
// the default is to return the default renderer
923
return m_renderers[-1];
926
//------------------------------------------
928
//------------------------------------------
930
void wxFNBRendererDefault::DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus)
933
wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
934
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
936
wxPoint tabPoints[7];
937
tabPoints[0].x = posx;
938
tabPoints[0].y = pc->HasFlag(wxFNB_BOTTOM) ? 2 : tabHeight - 2;
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);
943
tabPoints[2].x = tabPoints[1].x+2;
944
tabPoints[2].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;
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;
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);
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;
955
tabPoints[6].x = tabPoints[0].x;
956
tabPoints[6].y = tabPoints[0].y;
958
if(tabIdx == pc->GetSelection())
960
// Draw the tab as rounded rectangle
961
dc.DrawPolygon(7, tabPoints);
965
if(tabIdx != pc->GetSelection() - 1)
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);
977
if(tabIdx == pc->GetSelection())
979
wxPen savePen = dc.GetPen();
980
wxPen whitePen = wxPen(*wxWHITE);
981
whitePen.SetWidth(1);
984
wxPoint secPt = wxPoint(tabPoints[5].x + 1, tabPoints[5].y);
985
dc.DrawLine(tabPoints[0], secPt);
991
// -----------------------------------
992
// Text and image drawing
993
// -----------------------------------
995
// Text drawing offset from the left border of the
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;
1005
int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 8;
1007
int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 10;
1010
hasImage ? textOffset = padding * 2 + 16 + shapePoints / 2 : textOffset = padding + shapePoints / 2 ;
1013
if(tabIdx != pc->GetSelection())
1015
// Set the text background to be like the vertical lines
1016
dc.SetTextForeground( pc->GetNonoActiveTextColor() );
1021
int imageXOffset = textOffset - 16 - padding;
1022
dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()],
1023
posx + imageXOffset, imageYCoord, true);
1026
dc.DrawText(pc->GetPageText(tabIdx), posx + textOffset, imageYCoord);
1028
// draw 'x' on tab (if enabled)
1029
if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())
1031
int textWidth, textHeight;
1032
dc.GetTextExtent(pc->GetPageText(tabIdx), &textWidth, &textHeight);
1033
int tabCloseButtonXCoord = posx + textOffset + textWidth + 1;
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);
1042
DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);
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)
1052
wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
1053
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
1055
wxPoint tabPoints[7];
1056
tabPoints[0].x = posx + 2;
1057
tabPoints[0].y = pc->HasFlag(wxFNB_BOTTOM) ? 2 : tabHeight - 2;
1059
tabPoints[1].x = tabPoints[0].x;
1060
tabPoints[1].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - (VERTICAL_BORDER_PADDING+2) : (VERTICAL_BORDER_PADDING+2);
1062
tabPoints[2].x = tabPoints[1].x+2;
1063
tabPoints[2].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;
1065
tabPoints[3].x = posx +tabWidth - 2;
1066
tabPoints[3].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;
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);
1071
tabPoints[5].x = tabPoints[4].x;
1072
tabPoints[5].y = pc->HasFlag(wxFNB_BOTTOM) ? 2 : tabHeight - 2;
1074
tabPoints[6].x = tabPoints[0].x;
1075
tabPoints[6].y = tabPoints[0].y;
1077
//------------------------------------
1078
// Paint the tab with gradient
1079
//------------------------------------
1080
wxRect rr(tabPoints[2], tabPoints[5]);
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));
1087
dc.SetBrush( *wxTRANSPARENT_BRUSH );
1088
dc.SetPen( borderPen );
1090
// Draw the tab as rounded rectangle
1091
dc.DrawPolygon(7, tabPoints);
1093
// -----------------------------------
1094
// Text and image drawing
1095
// -----------------------------------
1097
// Text drawing offset from the left border of the
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;
1107
int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 8;
1109
int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 10;
1112
hasImage ? textOffset = padding * 2 + 16 + shapePoints / 2 : textOffset = padding + shapePoints / 2 ;
1115
if(tabIdx != pc->GetSelection())
1117
// Set the text background to be like the vertical lines
1118
dc.SetTextForeground( pc->GetNonoActiveTextColor() );
1123
int imageXOffset = textOffset - 16 - padding;
1124
dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()],
1125
posx + imageXOffset, imageYCoord, true);
1128
dc.DrawText(pc->GetPageText(tabIdx), posx + textOffset, imageYCoord);
1130
// draw 'x' on tab (if enabled)
1131
if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())
1133
int textWidth, textHeight;
1134
dc.GetTextExtent(pc->GetPageText(tabIdx), &textWidth, &textHeight);
1135
int tabCloseButtonXCoord = posx + textOffset + textWidth + 1;
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);
1144
DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);
1147
//------------------------------------------------------------------
1148
// Visual studio 7.1
1149
//------------------------------------------------------------------
1151
void wxFNBRendererVC71::DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus)
1153
// Visual studio 7.1 style
1154
wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
1155
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
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))));
1160
if(tabIdx == pc->GetSelection())
1162
int posy = pc->HasFlag(wxFNB_BOTTOM) ? 0 : VERTICAL_BORDER_PADDING;
1163
int tabH = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - 5 : tabHeight - 3;
1165
dc.DrawRectangle(posx, posy, tabWidth, tabH);
1167
// Draw a black line on the left side of the
1169
wxPen pen = wxPen(*wxBLACK);
1172
int blackLineY1 = VERTICAL_BORDER_PADDING;
1173
int blackLineY2 = tabH;
1174
dc.DrawLine(posx + tabWidth, blackLineY1, posx + tabWidth, blackLineY2);
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
1181
pen = wxPen(pc->HasFlag(wxFNB_BOTTOM) ? *wxBLACK : *wxWHITE);
1183
int whiteLinePosY = pc->HasFlag(wxFNB_BOTTOM) ? blackLineY2 : VERTICAL_BORDER_PADDING ;
1184
dc.DrawLine(posx , whiteLinePosY, posx + tabWidth + 1, whiteLinePosY);
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);
1193
// We dont draw a rectangle for non selected tabs, but only
1194
// vertical line on the left
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);
1201
// -----------------------------------
1202
// Text and image drawing
1203
// -----------------------------------
1205
// Text drawing offset from the left border of the
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;
1214
hasImage ? textOffset = padding * 2 + 16 : textOffset = padding;
1216
if(tabIdx != pc->GetSelection())
1218
// Set the text background to be like the vertical lines
1219
dc.SetTextForeground(pc->GetNonoActiveTextColor());
1224
int imageXOffset = textOffset - 16 - padding;
1225
dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()],
1226
posx + imageXOffset, imageYCoord, true);
1229
dc.DrawText(pc->GetPageText(tabIdx), posx + textOffset, imageYCoord);
1231
// draw 'x' on tab (if enabled)
1232
if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())
1234
int textWidth, textHeight;
1235
dc.GetTextExtent(pc->GetPageText(tabIdx), &textWidth, &textHeight);
1236
int tabCloseButtonXCoord = posx + textOffset + textWidth + 1;
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);
1245
DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);
1249
//------------------------------------------------------------------
1251
//------------------------------------------------------------------
1253
void wxFNBRendererFancy::DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus)
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 );
1260
wxPen pen = (tabIdx == pc->GetSelection()) ? wxPen( pc->GetBorderColour() ) : wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
1262
if(tabIdx == pc->GetSelection())
1264
int posy = pc->HasFlag(wxFNB_BOTTOM) ? 2 : VERTICAL_BORDER_PADDING;
1265
int th = tabHeight - 5;
1267
wxRect rect(posx, posy, tabWidth, th);
1269
wxColour col2 = (pc->HasFlag( wxFNB_BOTTOM ) ) ? pc->GetGradientColourTo() : pc->GetGradientColourFrom();
1270
wxColour col1 = (pc->HasFlag( wxFNB_BOTTOM ) ) ? pc->GetGradientColourFrom() : pc->GetGradientColourTo();
1272
PaintStraightGradientBox(dc, rect, col1, col2);
1273
dc.SetBrush(*wxTRANSPARENT_BRUSH);
1275
dc.DrawRectangle(rect);
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);
1282
dc.DrawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width, rect.y + rect.height - 1);
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);
1292
// -----------------------------------
1293
// Text and image drawing
1294
// -----------------------------------
1296
// Text drawing offset from the left border of the
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;
1304
int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 8;
1306
int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 10;
1309
hasImage ? textOffset = padding * 2 + 16 : textOffset = padding ;
1311
if(tabIdx != pc->GetSelection())
1313
// Set the text background to be like the vertical lines
1314
dc.SetTextForeground(pc->GetNonoActiveTextColor());
1319
int imageXOffset = textOffset - 16 - padding;
1320
dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()],
1321
posx + imageXOffset, imageYCoord, true);
1324
dc.DrawText(pc->GetPageText(tabIdx), posx + textOffset, imageYCoord);
1326
// draw 'x' on tab (if enabled)
1327
if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())
1329
int textWidth, textHeight;
1330
dc.GetTextExtent(pc->GetPageText(tabIdx), &textWidth, &textHeight);
1331
int tabCloseButtonXCoord = posx + textOffset + textWidth + 1;
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);
1340
DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);
1344
//------------------------------------------------------------------
1345
// Visual studio 2005 (VS8)
1346
//------------------------------------------------------------------
1347
void wxFNBRendererVC8::DrawTabs(wxWindow *pageContainer, wxDC &dc, wxEvent &event)
1349
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
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())
1361
// Get the text hight
1362
int tabHeight = CalcTabHeight( pageContainer );
1364
// Set the font for measuring the tab height
1365
/// Patch (SetTextForeground) ---- Ti-R ---- Good Text Colour
1367
//wxFont normalFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
1368
wxFont normalFont = pc->m_font;
1369
wxFont boldFont = normalFont;
1370
boldFont.SetWeight(wxFONTWEIGHT_BOLD);
1372
// Calculate the number of rows required for drawing the tabs
1373
wxRect rect = pc->GetClientRect();
1375
// Set the maximum client size
1377
pc->SetSizeHints(wxSize(GetButtonsAreaLength( pc ), tabHeight));
1379
wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
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();
1389
dc.SetTextBackground(pc->GetBackgroundColour());
1390
dc.SetTextForeground(pc->m_activeTextColor);
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);
1396
dc.SetPen(*wxTRANSPARENT_PEN);
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));
1402
dc.SetBrush(*wxTRANSPARENT_BRUSH);
1403
dc.DrawRectangle(0, 0, size.x, size.y);
1405
// Take 3 bitmaps for the background for the buttons
1410
//---------------------------------------
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);
1418
//---------------------------------------
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);
1426
//---------------------------------------
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);
1435
// We always draw the bottom/upper line of the tabs
1436
// regradless the style
1437
dc.SetPen(borderPen);
1438
DrawTabsLine(pc, dc);
1441
dc.SetPen(borderPen);
1444
dc.SetFont(boldFont);
1448
// Update all the tabs from 0 to 'pc->m_nFrom' to be non visible
1449
for(i=0; i<pc->m_nFrom; i++)
1451
pc->GetPageInfoVector()[i].SetPosition(wxPoint(-1, -1));
1452
pc->GetPageInfoVector()[i].GetRegion().Clear();
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);
1462
for(cur=(int)vTabsInfo.size() - 1; cur>=0; cur--)
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);
1470
// Now set the font to the correct font
1471
dc.SetFont((i==pc->GetSelection()) ? boldFont : normalFont);
1473
// Add the padding to the tab width
1475
// +-----------------------------------------------------------+
1476
// | PADDING | IMG | IMG_PADDING | TEXT | PADDING | x |PADDING |
1477
// +-----------------------------------------------------------+
1479
int tabWidth = CalcTabWidth( pageContainer, i, tabHeight );
1480
posx = vTabsInfo[cur].x;
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
1486
pc->GetPageInfoVector()[i].GetRegion().Clear();
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));
1494
// Incase we are drawing the active tab
1495
// we need to redraw so it will appear on top
1496
// of all other tabs
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 ) )
1501
activeTabPosx = posx;
1502
activeTabWidth = tabWidth;
1503
activeTabHeight = tabHeight;
1507
DrawTab(pc, dc, posx, i, tabWidth, tabHeight, pc->m_nTabXButtonStatus);
1510
// Restore the text forground
1511
dc.SetTextForeground(pc->m_activeTextColor);
1513
// Update the tab position & size
1514
pc->GetPageInfoVector()[i].SetPosition(wxPoint(posx, VERTICAL_BORDER_PADDING));
1515
pc->GetPageInfoVector()[i].SetSize(wxSize(tabWidth, tabHeight));
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() )
1521
DrawTab(pc, dc, activeTabPosx, pc->GetSelection(), activeTabWidth, activeTabHeight, pc->m_nTabXButtonStatus);
1524
// Update all tabs that can not fit into the screen as non-visible
1526
for(xx = pc->m_nFrom + (int)vTabsInfo.size(); xx<(int)pc->GetPageInfoVector().size(); xx++)
1528
pc->GetPageInfoVector()[xx].SetPosition(wxPoint(-1, -1));
1529
pc->GetPageInfoVector()[xx].GetRegion().Clear();
1532
// Draw the left/right/close buttons
1534
DrawLeftArrow(pc, dc);
1535
DrawRightArrow(pc, dc);
1537
DrawDropDownArrow(pc, dc);
1540
void wxFNBRendererVC8::DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus)
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];
1548
// If we draw the first tab or the active tab,
1549
// we draw a full tab, else we draw a truncated tab
1560
tabPoints[0].x = pc->HasFlag( wxFNB_BOTTOM ) ? posx : posx + m_factor;
1561
tabPoints[0].y = pc->HasFlag( wxFNB_BOTTOM ) ? 2 : tabHeight - 3;
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);
1566
tabPoints[2].x = tabPoints[1].x + 4;
1567
tabPoints[2].y = pc->HasFlag( wxFNB_BOTTOM ) ? tabHeight - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;
1569
tabPoints[3].x = tabPoints[2].x + tabWidth - 2;
1570
tabPoints[3].y = pc->HasFlag( wxFNB_BOTTOM ) ? tabHeight - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;
1572
tabPoints[4].x = tabPoints[3].x + 1;
1573
tabPoints[4].y = pc->HasFlag( wxFNB_BOTTOM ) ? tabPoints[3].y - 1 : tabPoints[3].y + 1;
1575
tabPoints[5].x = tabPoints[4].x + 1;
1576
tabPoints[5].y = pc->HasFlag( wxFNB_BOTTOM ) ? (tabPoints[4].y - 1 ): tabPoints[4].y + 1;
1578
tabPoints[6].x = tabPoints[2].x + tabWidth;
1579
tabPoints[6].y = tabPoints[0].y;
1581
tabPoints[7].x = tabPoints[0].x;
1582
tabPoints[7].y = tabPoints[0].y;
1584
pc->GetPageInfoVector()[tabIdx].SetRegion(8, tabPoints);
1587
wxBrush br = dc.GetBrush();
1588
dc.SetBrush(wxBrush(tabIdx == pc->GetSelection() ? pc->GetActiveTabColour() : pc->GetGradientColourTo() ));
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)));
1594
dc.SetPen(wxPen(tabIdx == pc->GetSelection() ? wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW) : pc->GetBorderColour()));
1595
dc.DrawPolygon(8, tabPoints);
1597
// Restore the brush
1600
wxRect rect = pc->GetClientRect();
1602
if(tabIdx != pc->GetSelection() && !pc->HasFlag( wxFNB_BOTTOM ))
1605
/// Patch ---- Ti-R ---- Enable to have the same line color as the selected tab
1606
if(pc->HasFlag( wxFNB_INVERSE_COLOR_LINE_VC8 ))
1609
dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)));
1614
dc.SetPen(wxPen( pc->GetBorderColour() ));
1617
int lineY = rect.height;
1618
wxPen curPen = dc.GetPen();
1621
dc.DrawLine(posx, lineY, posx+rect.width, lineY);
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())
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();
1634
borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
1636
wxBrush brush(*wxTRANSPARENT_BRUSH);
1637
dc.SetPen(borderPen);
1639
dc.DrawPolygon(8, tabPoints);
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]);
1647
FillVC8GradientColor(pc, dc, tabPoints, tabIdx == pc->GetSelection(), tabIdx);
1649
// Draw a thin line to the right of the non-selected tab
1650
if(tabIdx != pc->GetSelection())
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);
1657
// Text drawing offset from the left border of the
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;
1666
textOffset = ((wxFlatNotebook *)pc->m_pParent)->GetPadding() + vc8ShapeLen;
1668
// Draw the image for the tab if any
1670
int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 8;
1672
int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 10;
1675
if( pc->TabHasImage( tabIdx ) )
1677
int imageXOffset = textOffset - 16 - ((wxFlatNotebook *)pc->m_pParent)->GetPadding();
1678
dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()],
1679
posx + imageXOffset, imageYCoord, true);
1682
/// Patch (SetTextForeground) ---- Ti-R ---- Good Text Colour
1684
//wxFont boldFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
1685
wxFont boldFont = pc->m_font;
1687
/// Patch (Test GetEnabled) ---- Ti-R ---- change color is disable
1688
if(!pc->GetEnabled(tabIdx))
1690
dc.SetTextForeground(pc->m_disableTextColor);
1694
// if selected tab, draw text in bold
1695
if( tabIdx == pc->GetSelection() )
1697
/// Patch (SetTextForeground) ---- Ti-R ---- Good Text Colour
1698
dc.SetTextForeground(pc->m_activeTextColor);
1699
boldFont.SetWeight(wxFONTWEIGHT_BOLD);
1703
/// Patch (SetTextForeground) ---- Ti-R ---- Good Text Colour
1704
dc.SetTextForeground(pc->m_nonActiveTextColor);
1708
dc.SetFont( boldFont );
1709
dc.DrawText(pc->GetPageText(tabIdx), posx + textOffset, imageYCoord);
1711
// draw 'x' on tab (if enabled)
1712
if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())
1714
int textWidth, textHeight;
1715
dc.GetTextExtent(pc->GetPageText(tabIdx), &textWidth, &textHeight);
1716
int tabCloseButtonXCoord = posx + textOffset + textWidth + 1;
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 );
1726
DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);
1730
void wxFNBRendererVC8::FillVC8GradientColor(wxWindow* pageContainer, wxDC &dc, const wxPoint tabPoints[], const bool bSelectedTab, const int tabIdx)
1732
wxColour p_colorFrom;
1735
// calculate gradient coefficients
1736
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
1738
/// Patch (comment) ---- Ti-R ---- No need anymore, see below
1742
pc->m_colorTo = LightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 0);
1743
pc->m_colorFrom = LightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 60);
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)
1749
p_colorTo = pc->m_colorPreview;
1750
p_colorFrom = pc->m_colorPreview;
1754
p_colorTo = pc->GetGradientColourTo(); //LightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 0);
1755
p_colorFrom = pc->GetGradientColourFrom(); //LightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 60);
1757
/// (END) Patch (m_nTabStatus) ---- Ti-R ----
1759
wxColour col2 = pc->HasFlag( wxFNB_BOTTOM ) ? p_colorTo : p_colorFrom;
1760
wxColour col1 = pc->HasFlag( wxFNB_BOTTOM ) ? p_colorFrom : p_colorTo;
1762
// If colorful tabs style is set, override the tab color
1763
if(pc->HasFlag(wxFNB_COLORFUL_TABS))
1765
if( !pc->GetPageInfoVector()[tabIdx].GetColor().Ok() )
1767
// First time, generate color, and keep it in the vector
1768
wxColor tabColor(RandomColor());
1769
pc->GetPageInfoVector()[tabIdx].SetColor(tabColor);
1772
if( pc->HasFlag(wxFNB_BOTTOM) )
1774
col2 = LightColour( pc->GetPageInfoVector()[tabIdx].GetColor() , 50 );
1775
col1 = LightColour( pc->GetPageInfoVector()[tabIdx].GetColor() , 80 );
1779
col1 = LightColour( pc->GetPageInfoVector()[tabIdx].GetColor() , 50 );
1780
col2 = LightColour( pc->GetPageInfoVector()[tabIdx].GetColor() , 80 );
1784
int size = abs(tabPoints[2].y - tabPoints[0].y) - 1;
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;
1791
int y = tabPoints[0].y;
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
1798
DrawTabsLine(pc, dc);
1802
if(pc->HasFlag( wxFNB_BOTTOM ))
1804
if(y > tabPoints[0].y + size)
1809
if(y < tabPoints[0].y - size)
1814
(unsigned char)(col1.Red() + rf),
1815
(unsigned char)(col1.Green() + gf),
1816
(unsigned char)(col1.Blue() + bf)
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);
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)));
1829
dc.SetPen(wxPen(bSelectedTab ? wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW) : pc->m_colorBorder));
1831
dc.DrawPoint(startX, y);
1832
dc.DrawPoint(endX, y);
1834
// Progress the color
1835
rf += rstep; gf += gstep; bf += bstep;
1837
pc->HasFlag( wxFNB_BOTTOM ) ? y++ : y--;
1841
int wxFNBRendererVC8::GetStartX(const wxPoint tabPoints[], const int &y, long style)
1843
double x1 = 0, x2 = 0, y1 = 0, y2 = 0;
1845
// We check the 3 points to the left
1846
bool bBottomStyle = style & wxFNB_BOTTOM ? true : false;
1851
for(int i=0; i<3; i++)
1853
if(y >= tabPoints[i].y && y < tabPoints[i+1].y)
1855
x1 = tabPoints[i].x;
1856
x2 = tabPoints[i+1].x;
1857
y1 = tabPoints[i].y;
1858
y2 = tabPoints[i+1].y;
1866
for(int i=0; i<3; i++)
1868
if(y <= tabPoints[i].y && y > tabPoints[i+1].y)
1870
x1 = tabPoints[i].x;
1871
x2 = tabPoints[i+1].x;
1872
y1 = tabPoints[i].y;
1873
y2 = tabPoints[i+1].y;
1881
return tabPoints[2].x;
1883
// According to the equation y = ax + b => x = (y-b)/a
1884
// We know the first 2 points
1888
return static_cast<int>( x2 );
1890
a = (y2 - y1) / (x2 - x1);
1892
double b = y1 - ((y2 - y1) / (x2 - x1)) * x1;
1895
return static_cast<int>( x1 );
1897
double x = (y - b) / a;
1898
return static_cast<int>( x );
1901
int wxFNBRendererVC8::GetEndX(const wxPoint tabPoints[], const int &y, long style)
1903
double x1 = 0, x2 = 0, y1 = 0, y2 = 0;
1905
// We check the 3 points to the left
1906
bool bBottomStyle = style & wxFNB_BOTTOM ? true : false;
1911
for(int i=7; i>3; i--)
1913
if(y >= tabPoints[i].y && y < tabPoints[i-1].y)
1915
x1 = tabPoints[i].x;
1916
x2 = tabPoints[i-1].x;
1917
y1 = tabPoints[i].y;
1918
y2 = tabPoints[i-1].y;
1926
for(int i=7; i>3; i--)
1928
if(y <= tabPoints[i].y && y > tabPoints[i-1].y)
1930
x1 = tabPoints[i].x;
1931
x2 = tabPoints[i-1].x;
1932
y1 = tabPoints[i].y;
1933
y2 = tabPoints[i-1].y;
1941
return tabPoints[3].x;
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);
1951
double b = y1 - ((y2 - y1) / (x2 - x1)) * x1;
1956
double x = (y - b) / a;
1960
void wxFNBRendererVC8::NumberTabsCanFit(wxWindow *pageContainer, std::vector<wxRect> &vTabInfo, int from)
1962
wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );
1963
int tabHeight, clientWidth;
1965
wxRect rect = pc->GetClientRect();
1966
clientWidth = rect.width;
1971
tabHeight = CalcTabHeight( pageContainer );
1973
// The drawing starts from posx
1974
int posx = ((wxFlatNotebook *)pc->m_pParent)->GetPadding();
1979
for(int i = from; i<(int)pc->GetPageInfoVector().GetCount(); i++)
1981
int vc8glitch = tabHeight + wxFNB_HEIGHT_SPACER;
1982
int tabWidth = CalcTabWidth( pageContainer, i, tabHeight );
1983
if(posx + tabWidth + vc8glitch + GetButtonsAreaLength( pc ) >= clientWidth)
1986
/// Add a result to the returned vector
1987
wxRect tabRect(posx, VERTICAL_BORDER_PADDING, tabWidth , tabHeight);
1988
vTabInfo.push_back(tabRect);
1991
posx += tabWidth + wxFNB_HEIGHT_SPACER;