16 #if defined(__WXGTK__) && (USE_GTK_NOTEBOOK) && !wxCHECK_VERSION(3, 0, 0) 17 #define GSocket GLibSocket 30 const int c_vertical_border_padding = 4;
45 #if wxCHECK_VERSION(3, 0, 0) 59 const wxAuiNotebookPage& page,
60 const wxRect& in_rect,
int close_button_state,
78 #if wxCHECK_VERSION(3, 0, 0) 81 wxCoord tab_height = m_tab_ctrl_height - 3;
86 int clip_width = tab_width;
87 if (tab_x + clip_width > in_rect.
x + in_rect.
width - 4)
88 clip_width = (in_rect.
x + in_rect.
width) - tab_x - 4;
89 dc.SetClippingRegion(tab_x, tab_y, clip_width + 1, tab_height - 3);
99 int tabH = tab_height - 2;
101 dc.DrawRectangle(tab_x, tab_y, tab_width, tabH);
103 int rightLineY1 = (
m_flags & wxAUI_NB_BOTTOM) ? c_vertical_border_padding - 2 : c_vertical_border_padding - 1;
104 int rightLineY2 = tabH + 3;
106 dc.DrawLine(tab_x + tab_width - 1, rightLineY1 + 1, tab_x + tab_width - 1, rightLineY2);
108 dc.DrawLine(tab_x + 1, rightLineY2 - 3 , tab_x + tab_width - 1, rightLineY2 - 3);
110 dc.DrawLine(tab_x + tab_width , rightLineY1 , tab_x + tab_width, rightLineY2);
112 dc.DrawLine(tab_x , rightLineY2 - 2 , tab_x + tab_width, rightLineY2 - 2);
119 int blackLineY1 = (
m_flags & wxAUI_NB_BOTTOM) ? c_vertical_border_padding + 2 : c_vertical_border_padding + 1;
120 int blackLineY2 = tab_height - 5;
121 dc.DrawLine(tab_x + tab_width, blackLineY1, tab_x + tab_width, blackLineY2);
127 border_points[0] =
wxPoint(tab_x, tab_y);
128 border_points[1] =
wxPoint(tab_x, tab_y + tab_height - 6);
132 border_points[0] =
wxPoint(tab_x, tab_y + tab_height - 4);
133 border_points[1] =
wxPoint(tab_x, tab_y + 2);
136 int drawn_tab_yoff = border_points[1].
y;
137 int drawn_tab_height = border_points[0].
y - border_points[1].
y;
139 int text_offset = tab_x + 8;
141 int bitmap_offset = 0;
142 if (page.bitmap.IsOk())
144 bitmap_offset = tab_x + 8;
147 dc.DrawBitmap(page.bitmap,
149 drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2),
152 text_offset = bitmap_offset + page.bitmap.GetWidth();
157 text_offset = tab_x + 8;
169 #if wxCHECK_VERSION(3, 0, 0) 172 dc.SetFont(m_selected_font);
175 #if wxCHECK_VERSION(3, 0, 0) 178 dc.SetFont(m_normal_font);
180 dc.GetTextExtent(caption, &textx, &texty);
183 dc.DrawText(page.caption, text_offset,
184 drawn_tab_yoff + drawn_tab_height / 2 - texty / 2 - 1);
189 #if wxCHECK_VERSION(3, 0, 0) 193 int close_button_width = m_active_close_bmp.
GetWidth();
194 wxBitmap bmp = m_disabled_close_bmp;
199 #if wxCHECK_VERSION(3, 0, 0) 202 bmp = m_active_close_bmp;
205 wxRect rect(tab_x + tab_width - close_button_width - 3,
206 drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.
GetHeight() / 2),
207 close_button_width, tab_height);
215 dc.DrawBitmap(bmp, rect.
x, rect.
y,
true);
216 *out_button_rect = rect;
219 *out_tab_rect =
wxRect(tab_x, tab_y, tab_width, tab_height);
220 dc.DestroyClippingRegion();
224 const wxAuiNotebookPageArray& WXUNUSED(pages),
225 const wxSize& WXUNUSED(required_bmp_size))
230 #if wxCHECK_VERSION(3, 0, 0) 233 dc.SetFont(m_measuring_font);
249 #if wxCHECK_VERSION(3, 0, 0) 263 const wxAuiNotebookPage& page,
264 const wxRect& in_rect,
int close_button_state,
273 page.active, close_button_state, x_extent);
275 #if wxCHECK_VERSION(3, 0, 0) 278 wxCoord tab_height = m_tab_ctrl_height - 2;
280 wxCoord tab_width = tab_size.x;
284 int clip_width = tab_width;
285 if (tab_x + clip_width > in_rect.
x + in_rect.
width - 4)
286 clip_width = (in_rect.
x + in_rect.
width) - tab_x - 4;
287 dc.SetClippingRegion(tab_x, tab_y, clip_width + 1, tab_height - 3);
296 tabPoints[0].
x = tab_x + 3;
297 tabPoints[0].
y = (
m_flags & wxAUI_NB_BOTTOM) ? 3 : tab_height - 2;
299 tabPoints[1].
x = tabPoints[0].
x;
300 tabPoints[1].
y = (
m_flags & wxAUI_NB_BOTTOM) ? tab_height - (c_vertical_border_padding + 2) - adjust : (c_vertical_border_padding + 2) + adjust;
302 tabPoints[2].
x = tabPoints[1].
x+2;
303 tabPoints[2].
y = (
m_flags & wxAUI_NB_BOTTOM) ? tab_height - c_vertical_border_padding - adjust: c_vertical_border_padding + adjust;
305 tabPoints[3].
x = tab_x +tab_width - 2;
306 tabPoints[3].
y = tabPoints[2].
y;
308 tabPoints[4].
x = tabPoints[3].
x + 2;
309 tabPoints[4].
y = tabPoints[1].
y;
311 tabPoints[5].
x = tabPoints[4].
x;
312 tabPoints[5].
y = tabPoints[0].
y;
314 tabPoints[6].
x = tabPoints[0].
x;
315 tabPoints[6].
y = tabPoints[0].
y;
322 dc.DrawPolygon(7, tabPoints);
327 dc.DrawLine(tabPoints[0].x + 1, tabPoints[0].y, tabPoints[5].x , tabPoints[0].y);
330 int drawn_tab_yoff = tabPoints[1].
y;
331 int drawn_tab_height = tabPoints[0].
y - tabPoints[2].
y;
333 int text_offset = tab_x + 8;
335 int bitmap_offset = 0;
336 if (page.bitmap.IsOk())
338 bitmap_offset = tab_x + 8;
341 dc.DrawBitmap(page.bitmap,
343 drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2),
346 text_offset = bitmap_offset + page.bitmap.GetWidth();
351 text_offset = tab_x + 8;
363 #if wxCHECK_VERSION(3, 0, 0) 366 dc.SetFont(m_selected_font);
369 #if wxCHECK_VERSION(3, 0, 0) 372 dc.SetFont(m_normal_font);
374 dc.GetTextExtent(caption, &textx, &texty);
377 dc.DrawText(page.caption, text_offset,
378 drawn_tab_yoff + drawn_tab_height / 2 - texty / 2 - 1);
383 #if wxCHECK_VERSION(3, 0, 0) 387 int close_button_width = m_active_close_bmp.
GetWidth();
388 wxBitmap bmp = m_disabled_close_bmp;
393 #if wxCHECK_VERSION(3, 0, 0) 396 bmp = m_active_close_bmp;
399 wxRect rect(tab_x + tab_width - close_button_width - 3,
400 drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.
GetHeight() / 2),
401 close_button_width, tab_height);
409 dc.DrawBitmap(bmp, rect.
x, rect.
y,
true);
410 *out_button_rect = rect;
413 *out_tab_rect =
wxRect(tab_x, tab_y, tab_width, tab_height);
414 dc.DestroyClippingRegion();
418 const wxAuiNotebookPageArray& WXUNUSED(pages),
419 const wxSize& WXUNUSED(required_bmp_size))
424 #if wxCHECK_VERSION(3, 0, 0) 427 dc.SetFont(m_measuring_font);
435 #if defined(__WXGTK__) && (USE_GTK_NOTEBOOK) && !wxCHECK_VERSION(3, 0, 0) 440 static GtkWidget *g_window =
nullptr;
441 static GtkWidget *g_container =
nullptr;
442 static GtkWidget *g_notebook =
nullptr;
443 static GtkWidget *g_button =
nullptr;
444 static int s_CloseIconSize = 16;
446 static void setup_widget_prototype(GtkWidget* widget)
450 g_window = gtk_window_new(GTK_WINDOW_POPUP);
451 gtk_widget_realize(g_window);
455 g_container = gtk_fixed_new();
456 gtk_container_add(GTK_CONTAINER(g_window), g_container);
459 gtk_container_add(GTK_CONTAINER(g_container), widget);
460 gtk_widget_realize(widget);
463 static GtkStyle * get_style_button()
467 g_button = gtk_button_new();
468 setup_widget_prototype(g_button);
470 return gtk_widget_get_style(g_button);
473 static GtkStyle * get_style_notebook()
477 g_notebook = gtk_notebook_new();
478 setup_widget_prototype(g_notebook);
480 return gtk_widget_get_style(g_notebook);
485 NbStyleGTK::NbStyleGTK():
496 NbStyleGTK* clone =
new NbStyleGTK();
498 #if wxCHECK_VERSION(3, 0, 0) 503 clone->SetNormalFont(m_normal_font);
504 clone->SetSelectedFont(m_normal_font);
505 clone->SetMeasuringFont(m_normal_font);
513 GtkStyle* style_notebook = get_style_notebook();
514 GtkNotebook* notebook = GTK_NOTEBOOK (g_notebook);
517 if(m_Xthickness != style_notebook->xthickness ||
518 m_Ythickness != style_notebook->ythickness ||
519 m_TabVBorder != notebook->tab_vborder ||
520 m_TabHBorder != notebook->tab_hborder)
522 m_Xthickness = style_notebook->xthickness;
523 m_Ythickness = style_notebook->ythickness;
524 m_TabVBorder = notebook->tab_vborder;
525 m_TabHBorder = notebook->tab_hborder;
532 #if wxCHECK_VERSION(3, 0, 0) 533 wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
534 GdkWindow* pWin = impldc->GetGDKWindow();
536 GdkWindow* pWin = dc.GetGDKWindow();
538 gtk_style_apply_default_background(style_notebook, pWin, 1, GTK_STATE_NORMAL,
nullptr,
542 void ButtonStateAndShadow(
int button_state, GtkStateType &state, GtkShadowType &shadow)
547 state = GTK_STATE_INSENSITIVE;
548 shadow = GTK_SHADOW_ETCHED_IN;
552 state = GTK_STATE_PRELIGHT;
553 shadow = GTK_SHADOW_OUT;
557 state = GTK_STATE_ACTIVE;
558 shadow = GTK_SHADOW_IN;
562 state = GTK_STATE_NORMAL;
563 shadow = GTK_SHADOW_OUT;
572 GdkRectangle* clipRect)
574 GtkStyle *style_button = get_style_button();
575 int xthickness = style_button->xthickness;
576 int ythickness = style_button->ythickness;
579 bmp.SetPixbuf(gtk_widget_render_icon(widget, GTK_STOCK_CLOSE, GTK_ICON_SIZE_SMALL_TOOLBAR,
"tab"));
584 img.
Rescale(s_CloseIconSize, s_CloseIconSize);
588 int button_size = s_CloseIconSize + 2 * xthickness;
592 if (orientation ==
wxLEFT)
593 out_rect.
x = in_rect.
x - ythickness;
595 out_rect.
x = in_rect.
x + in_rect.
width - button_size - ythickness;
597 out_rect.
y = in_rect.
y + (in_rect.
height - button_size) / 2;
598 out_rect.
width = button_size;
599 out_rect.
height = button_size;
601 #if wxCHECK_VERSION(3, 0, 0) 602 wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
603 GdkWindow* pWin = impldc->GetGDKWindow();
605 GdkWindow* pWin = dc.GetGDKWindow();
610 gtk_paint_box(style_button, pWin,
611 GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, clipRect, widget,
"button",
616 gtk_paint_box(style_button, pWin,
617 GTK_STATE_ACTIVE, GTK_SHADOW_IN, clipRect, widget,
"button",
622 dc.DrawBitmap(bmp, out_rect.
x + xthickness, out_rect.
y + ythickness,
true);
627 void NbStyleGTK::DrawTab(
wxDC& dc,
wxWindow* wnd,
const wxAuiNotebookPage& page,
628 const wxRect& in_rect,
int close_button_state,
wxRect* out_tab_rect,
629 wxRect* out_button_rect,
int* x_extent)
631 GtkWidget *widget = wnd->GetHandle();
632 GtkStyle *style_notebook = get_style_notebook();
634 wxRect const &window_rect = wnd->GetRect();
638 gtk_widget_style_get(g_notebook,
639 "focus-line-width", &focus_width,
644 tab_pos = wxAUI_NB_BOTTOM;
646 tab_pos = wxAUI_NB_TOP;
653 page.active, close_button_state, x_extent);
655 wxRect tab_rect = in_rect;
656 tab_rect.
width = tab_size.x;
657 tab_rect.
height = tab_size.y;
658 tab_rect.
y += 2 * m_TabHBorder;
661 tab_rect.
height += 2 * m_TabHBorder;
662 #if wxCHECK_VERSION(3, 0, 0) 664 if (! page.bitmap.IsOk())
668 int gap_rect_height = 6 * m_TabHBorder;
669 int gap_rect_x = 1, gap_start = 0, gap_width = 0;
670 int gap_rect_y = tab_rect.
y - gap_rect_height;
671 int gap_rect_width = window_rect.
width;
676 tab_rect.
y -= 2 * m_TabHBorder;
678 tab_rect.
y += 2 * m_TabHBorder;
679 gap_rect_y = tab_rect.
y + tab_rect.
height - m_TabHBorder / 2;
681 case wxAUI_NB_BOTTOM:
682 gap_start = tab_rect.
x - m_TabVBorder / 2;
683 gap_width = tab_rect.
width;
688 tab_rect.
y += m_TabHBorder / 2;
689 gap_rect_y += m_TabHBorder / 2;
691 int padding = focus_width + m_TabHBorder;
693 int clip_width = tab_rect.
width;
694 if (tab_rect.
x + tab_rect.
width > in_rect.
x + in_rect.
width)
695 clip_width = (in_rect.
x + in_rect.
width) - tab_rect.
x;
697 dc.SetClippingRegion(tab_rect.
x, tab_rect.
y - m_TabVBorder, clip_width, tab_rect.
height + m_TabVBorder);
700 area.x = tab_rect.
x - m_TabVBorder;
701 area.y = tab_rect.
y - 2 * m_TabHBorder;
702 area.width = clip_width + m_TabVBorder;
703 area.height = tab_rect.
height + 2 * m_TabHBorder;
705 #if wxCHECK_VERSION(3, 0, 0) 706 wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
707 GdkWindow* pWin = impldc->GetGDKWindow();
709 GdkWindow* pWin = dc.GetGDKWindow();
712 if (tab_pos == wxAUI_NB_BOTTOM)
716 gtk_paint_box_gap(style_notebook, pWin, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
717 NULL, widget,
"notebook",
718 gap_rect_x, gap_rect_y,
719 gap_rect_width, gap_rect_height,
720 GTK_POS_BOTTOM, gap_start , gap_width);
722 gtk_paint_extension(style_notebook, pWin,
723 page.active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_OUT,
724 &area, widget,
"tab",
725 tab_rect.
x, tab_rect.
y,
733 gtk_paint_box_gap(style_notebook, pWin, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
734 NULL, widget,
"notebook",
735 gap_rect_x, gap_rect_y,
736 gap_rect_width, gap_rect_height,
737 GTK_POS_TOP, gap_start , gap_width);
739 gtk_paint_extension(style_notebook, pWin,
740 page.active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_OUT,
741 &area, widget,
"tab",
742 tab_rect.
x, tab_rect.
y,
747 wxCoord textX = tab_rect.
x + padding + m_Xthickness;
749 int bitmap_offset = 0;
750 if (page.bitmap.IsOk())
752 bitmap_offset = textX;
755 int bitmapY = tab_rect.
y +(tab_rect.
height - page.bitmap.GetHeight()) / 2;
758 if (tab_pos == wxAUI_NB_TOP)
759 bitmapY += m_Ythickness / 2;
761 bitmapY -= m_Ythickness / 2;
763 dc.DrawBitmap(page.bitmap,
768 textX += page.bitmap.GetWidth() + padding;
773 #if wxCHECK_VERSION(3, 0, 0) 776 dc.SetFont(m_normal_font);
778 dc.GetTextExtent(page.caption, &textW, &textH);
779 textY = tab_rect.
y + (tab_rect.
height - textH) / 2;
782 if (tab_pos == wxAUI_NB_TOP)
783 textY += m_Ythickness / 2;
785 textY -= m_Ythickness / 2;
789 GdkColor text_colour = page.active ? style_notebook->fg[GTK_STATE_NORMAL] : style_notebook->fg[GTK_STATE_ACTIVE];
790 dc.SetTextForeground(wxColor(text_colour));
791 GdkRectangle focus_area;
793 int padding_focus = padding - focus_width;
794 focus_area.x = tab_rect.
x + padding_focus;
795 focus_area.y = textY - focus_width;
796 focus_area.width = tab_rect.
width - 2 * padding_focus;
797 focus_area.height = textH + 2 * focus_width;
799 if(page.active && (wnd->FindFocus() == wnd) && focus_area.x <= (area.x + area.width))
802 if((focus_area.x + focus_area.width) > (area.x + area.width))
803 focus_area.width = area.x + area.width - focus_area.x + focus_width - m_TabVBorder;
804 gtk_paint_focus (style_notebook, pWin,
805 GTK_STATE_ACTIVE,
NULL, widget,
"tab",
806 focus_area.x, focus_area.y, focus_area.width, focus_area.height);
809 dc.DrawText(page.caption, textX, textY);
817 if (tab_pos == wxAUI_NB_TOP)
818 rect.
y += m_Ythickness / 2;
820 rect.
y -= m_Ythickness / 2;
822 *out_button_rect = DrawCloseButton(dc, widget, close_button_state, rect,
wxRIGHT, &area);
825 tab_rect.
width = std::min(tab_rect.
width, clip_width);
826 *out_tab_rect = tab_rect;
828 dc.DestroyClippingRegion();
836 GtkArrowType arrow_type)
838 int scroll_arrow_hlength, scroll_arrow_vlength;
839 gtk_widget_style_get(widget,
840 "scroll-arrow-hlength", &scroll_arrow_hlength,
841 "scroll-arrow-vlength", &scroll_arrow_vlength,
845 GtkShadowType shadow;
846 ButtonStateAndShadow(button_state, state, shadow);
850 if (orientation ==
wxLEFT)
851 out_rect.
x = in_rect.
x;
853 out_rect.
x = in_rect.
x + in_rect.
width - scroll_arrow_hlength;
854 out_rect.
y = (in_rect.
y + in_rect.
height - 3 * get_style_notebook()->ythickness - scroll_arrow_vlength) / 2;
855 out_rect.
width = scroll_arrow_hlength;
856 out_rect.
height = scroll_arrow_vlength;
858 #if wxCHECK_VERSION(3, 0, 0) 859 wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
860 GdkWindow* pWin = impldc->GetGDKWindow();
862 GdkWindow* pWin = dc.GetGDKWindow();
864 gtk_paint_arrow (get_style_button(), pWin, state, shadow,
nullptr, widget,
"notebook",
865 arrow_type, TRUE, out_rect.
x, out_rect.
y, out_rect.
width, out_rect.
height);
877 GtkWidget *widget = wnd->GetHandle();
880 rect.
y += 2 * get_style_button()->ythickness;
885 rect.
y -= 2 * get_style_button()->ythickness;
886 rect = DrawCloseButton(dc, widget, button_state, rect, orientation,
NULL);
890 rect = DrawSimpleArrow(dc, widget, button_state, rect, orientation, GTK_ARROW_LEFT);
894 rect = DrawSimpleArrow(dc, widget, button_state, rect, orientation, GTK_ARROW_RIGHT);
899 rect.
height -= 4 * get_style_button()->ythickness;
904 wxRendererNative::Get().DrawComboBoxDropButton(wnd, dc, rect,
wxCONTROL_CURRENT);
906 wxRendererNative::Get().DrawComboBoxDropButton(wnd, dc, rect,
wxCONTROL_PRESSED);
908 wxRendererNative::Get().DrawDropArrow(wnd, dc, rect);
920 int NbStyleGTK::GetBestTabCtrlSize(
wxWindow* wnd,
921 const wxAuiNotebookPageArray& pages,
922 const wxSize& required_bmp_size)
924 #if wxCHECK_VERSION(3, 0, 0) 940 int close_button_state,
946 gtk_widget_style_get (wnd->GetHandle(),
947 "focus-line-width", &overlap,
949 *x_extent -= overlap;
953 #endif // #if defined(__WXGTK__) && (USE_GTK_NOTEBOOK) && !wxCHECK_VERSION(3, 0, 0)
wxBrush * wxTRANSPARENT_BRUSH
void SetSelectedFont(const wxFont &font)
int GetBestTabCtrlSize(wxWindow *wnd, const wxAuiNotebookPageArray &pages, const wxSize &requiredBmpSize)
int GetBestTabCtrlSize(wxWindow *wnd, const wxAuiNotebookPageArray &pages, const wxSize &required_bmp_size)
wxImage & Rescale(int width, int height, wxImageResizeQuality quality=wxIMAGE_QUALITY_NORMAL)
void SetNormalFont(const wxFont &font)
void DrawTab(wxDC &dc, wxWindow *wnd, const wxAuiNotebookPage &page, const wxRect &in_rect, int close_button_state, wxRect *out_tab_rect, wxRect *out_button_rect, int *x_extent)
virtual wxImage ConvertToImage() const
virtual void SetTabCtrlHeight(int height)
wxSize GetTabSize(wxDC &dc, wxWindow *wnd, const wxString &caption, const wxBitmap &bitmap, bool active, int closeButtonState, int *xExtent)
virtual int GetWidth() const
wxBitmap m_activeCloseBmp
static wxColour GetColour(wxSystemColour index)
int GetBestTabCtrlSize(wxWindow *wnd, const wxAuiNotebookPageArray &pages, const wxSize &required_bmp_size)
A notebook class This class is derived from wxAuiNotebook, to enhance its abilities.
virtual int GetHeight() const
void SetMeasuringFont(const wxFont &font)
void DrawTab(wxDC &dc, wxWindow *wnd, const wxAuiNotebookPage &page, const wxRect &in_rect, int close_button_state, wxRect *out_tab_rect, wxRect *out_button_rect, int *x_extent)
wxBitmap m_disabledCloseBmp