114
114
self._tab_ctrl_height = 0
115
115
self._buttonRect = wx.Rect()
117
base_colour = GetBaseColour()
119
self._base_colour = base_colour
120
border_colour = StepColour(base_colour, 75)
122
self._border_pen = wx.Pen(border_colour)
123
self._base_colour_pen = wx.Pen(self._base_colour)
124
self._base_colour_brush = wx.Brush(self._base_colour)
117
self.SetDefaultColours()
126
119
if wx.Platform == "__WXMAC__":
127
120
bmp_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DDKSHADOW)
158
151
self._focusPen = wx.Pen(wx.BLACK, 1, wx.USER_DASH)
159
152
self._focusPen.SetDashes([1, 1])
160
153
self._focusPen.SetCap(wx.CAP_BUTT)
156
def SetBaseColour(self, base_colour):
158
Sets a new base colour.
160
:param `base_colour`: an instance of `wx.Colour`.
163
self._base_colour = base_colour
164
self._base_colour_pen = wx.Pen(self._base_colour)
165
self._base_colour_brush = wx.Brush(self._base_colour)
168
def SetDefaultColours(self, base_colour=None):
170
Sets the default colours, which are calculated from the given base colour.
172
:param `base_colour`: an instance of `wx.Colour`. If defaulted to ``None``, a colour
173
is generated accordingly to the platform and theme.
176
if base_colour is None:
177
base_colour = GetBaseColour()
179
self.SetBaseColour( base_colour )
180
self._border_colour = StepColour(base_colour, 75)
181
self._border_pen = wx.Pen(self._border_colour)
183
self._background_top_colour = StepColour(self._base_colour, 90)
184
self._background_bottom_colour = StepColour(self._base_colour, 170)
186
self._tab_top_colour = self._base_colour
187
self._tab_bottom_colour = wx.WHITE
188
self._tab_gradient_highlight_colour = wx.WHITE
190
self._tab_inactive_top_colour = self._base_colour
191
self._tab_inactive_bottom_colour = StepColour(self._tab_inactive_top_colour, 160)
193
self._tab_text_colour = lambda page: page.text_colour
194
self._tab_disabled_text_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)
164
198
""" Clones the art object. """
166
art = AuiDefaultTabArt()
167
201
art.SetNormalFont(self.GetNormalFont())
168
202
art.SetSelectedFont(self.GetSelectedFont())
169
203
art.SetMeasuringFont(self.GetMeasuringFont())
184
218
``AUI_NB_TOP`` With this style, tabs are drawn along the top of the notebook
185
219
``AUI_NB_LEFT`` With this style, tabs are drawn along the left of the notebook. Not implemented yet.
186
220
``AUI_NB_RIGHT`` With this style, tabs are drawn along the right of the notebook. Not implemented yet.
187
``AUI_NB_BOTTOM`` With this style, tabs are drawn along the bottom of the notebook.
221
``AUI_NB_BOTTOM`` With this style, tabs are drawn along the bottom of the notebook
188
222
``AUI_NB_TAB_SPLIT`` Allows the tab control to be split by dragging a tab
189
223
``AUI_NB_TAB_MOVE`` Allows a tab to be moved horizontally by dragging
190
224
``AUI_NB_TAB_EXTERNAL_MOVE`` Allows a tab to be moved to another tab control
194
228
``AUI_NB_CLOSE_BUTTON`` With this style, a close button is available on the tab bar
195
229
``AUI_NB_CLOSE_ON_ACTIVE_TAB`` With this style, a close button is available on the active tab
196
230
``AUI_NB_CLOSE_ON_ALL_TABS`` With this style, a close button is available on all tabs
197
``AUI_NB_MIDDLE_CLICK_CLOSE`` Allows to close AuiNotebook tabs by mouse middle button click
198
``AUI_NB_SUB_NOTEBOOK`` This style is used by AuiManager to create automatic AuiNotebooks
231
``AUI_NB_MIDDLE_CLICK_CLOSE`` Allows to close L{AuiNotebook} tabs by mouse middle button click
232
``AUI_NB_SUB_NOTEBOOK`` This style is used by L{AuiManager} to create automatic AuiNotebooks
199
233
``AUI_NB_HIDE_ON_SINGLE_TAB`` Hides the tab window if only one tab is present
200
``AUI_NB_SMART_TABS`` Use Smart Tabbing, like ``Alt``+``Tab`` on Windows
234
``AUI_NB_SMART_TABS`` Use Smart Tabbing, like ``Alt`` + ``Tab`` on Windows
201
235
``AUI_NB_USE_IMAGES_DROPDOWN`` Uses images on dropdown window list menu instead of check items
202
236
``AUI_NB_CLOSE_ON_TAB_LEFT`` Draws the tab close button on the left instead of on the right (a la Camino browser)
203
237
``AUI_NB_TAB_FLOAT`` Allows the floating of single tabs. Known limitation: when the notebook is more or less full screen, tabs cannot be dragged far enough outside of the notebook to become floating pages
204
238
``AUI_NB_DRAW_DND_TAB`` Draws an image representation of a tab while dragging (on by default)
239
``AUI_NB_ORDER_BY_ACCESS`` Tab navigation order by last access time for the tabs
240
``AUI_NB_NO_TAB_FOCUS`` Don't draw tab focus rectangle
205
241
==================================== ==================================
226
262
:param `tab_ctrl_size`: the size of the tab control area;
227
263
:param `tab_count`: the number of tabs;
228
:param `minMaxTabWidth`: the minimum and maximum tab widths to be used
229
when the ``AUI_NB_TAB_FIXED_WIDTH`` style is active.
264
:param `minMaxTabWidth`: a tuple containing the minimum and maximum tab widths
265
to be used when the ``AUI_NB_TAB_FIXED_WIDTH`` style is active.
232
268
self._fixed_tab_width = 100
281
317
else: #for AUI_NB_TOP
282
318
r = wx.Rect(rect.x, rect.y, rect.width+2, rect.height-3)
284
top_colour = StepColour(self._base_colour, 90)
285
bottom_colour = StepColour(self._base_colour, 170)
287
dc.GradientFillLinear(r, top_colour, bottom_colour, wx.SOUTH)
320
dc.GradientFillLinear(r, self._background_top_colour, self._background_bottom_colour, wx.SOUTH)
289
322
# draw base lines
293
326
w = rect.GetWidth()
295
328
if agwFlags & AUI_NB_BOTTOM:
296
dc.SetBrush(wx.Brush(bottom_colour))
329
dc.SetBrush(wx.Brush(self._background_bottom_colour))
297
330
dc.DrawRectangle(-1, 0, w+2, 4)
299
332
# TODO: else if (agwFlags & AUI_NB_LEFT)
353
386
textx, texty = normal_textx, normal_texty
355
388
if not page.enabled:
356
dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT))
389
dc.SetTextForeground(self._tab_disabled_text_colour)
357
390
pagebitmap = page.dis_bitmap
359
dc.SetTextForeground(page.text_colour)
392
dc.SetTextForeground(self._tab_text_colour(page))
360
393
pagebitmap = page.bitmap
362
395
# create points that will make the tab outline
407
440
dc.DrawRectangle(r.x+1, r.y+1, r.width-1, r.height-4)
409
442
# this white helps fill out the gradient at the top of the tab
410
dc.SetPen(wx.WHITE_PEN)
411
dc.SetBrush(wx.WHITE_BRUSH)
443
dc.SetPen( wx.Pen(self._tab_gradient_highlight_colour) )
444
dc.SetBrush( wx.Brush(self._tab_gradient_highlight_colour) )
412
445
dc.DrawRectangle(r.x+2, r.y+1, r.width-3, r.height-4)
414
447
# these two points help the rounded corners appear more antialiased
426
459
# draw gradient background
427
top_colour = wx.WHITE
428
bottom_colour = self._base_colour
460
top_colour = self._tab_bottom_colour
461
bottom_colour = self._tab_top_colour
429
462
dc.GradientFillLinear(r, bottom_colour, top_colour, wx.NORTH)
446
479
# -- draw top gradient fill for glossy look
447
top_colour = self._base_colour
448
bottom_colour = StepColour(top_colour, 160)
480
top_colour = self._tab_inactive_top_colour
481
bottom_colour = self._tab_inactive_bottom_colour
449
482
dc.GradientFillLinear(r, bottom_colour, top_colour, wx.NORTH)
454
487
# -- draw bottom fill for glossy look
455
top_colour = self._base_colour
456
bottom_colour = self._base_colour
488
top_colour = self._tab_inactive_bottom_colour
489
bottom_colour = self._tab_inactive_bottom_colour
457
490
dc.GradientFillLinear(r, top_colour, bottom_colour, wx.SOUTH)
459
492
# draw tab outline
468
501
if agwFlags & AUI_NB_BOTTOM:
469
dc.SetPen(wx.Pen(StepColour(self._base_colour, 170)))
502
dc.SetPen(wx.Pen(self._background_bottom_colour))
471
504
# TODO: else if (agwFlags & AUI_NB_LEFT)
472
505
# TODO: else if (agwFlags & AUI_NB_RIGHT)
534
567
dc.DrawLabel(draw_text, wx.Rect(text_offset, ypos, rectx, recty))
536
569
# draw focus rectangle
537
self.DrawFocusRectangle(dc, page, wnd, draw_text, offset_focus, bitmap_offset, drawn_tab_yoff, drawn_tab_height, textx, texty)
570
if (agwFlags & AUI_NB_NO_TAB_FOCUS) == 0:
571
self.DrawFocusRectangle(dc, page, wnd, draw_text, offset_focus, bitmap_offset, drawn_tab_yoff, drawn_tab_height, rectx, recty)
539
573
out_button_rect = wx.Rect()
757
791
:param `texty`: the y text extent.
794
if self.GetAGWFlags() & AUI_NB_NO_TAB_FOCUS:
760
797
if page.active and wx.Window.FindFocus() == wnd:
762
799
focusRectText = wx.Rect(text_offset, (drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2)),
1010
1047
``AUI_NB_TOP`` With this style, tabs are drawn along the top of the notebook
1011
1048
``AUI_NB_LEFT`` With this style, tabs are drawn along the left of the notebook. Not implemented yet.
1012
1049
``AUI_NB_RIGHT`` With this style, tabs are drawn along the right of the notebook. Not implemented yet.
1013
``AUI_NB_BOTTOM`` With this style, tabs are drawn along the bottom of the notebook.
1050
``AUI_NB_BOTTOM`` With this style, tabs are drawn along the bottom of the notebook
1014
1051
``AUI_NB_TAB_SPLIT`` Allows the tab control to be split by dragging a tab
1015
1052
``AUI_NB_TAB_MOVE`` Allows a tab to be moved horizontally by dragging
1016
1053
``AUI_NB_TAB_EXTERNAL_MOVE`` Allows a tab to be moved to another tab control
1020
1057
``AUI_NB_CLOSE_BUTTON`` With this style, a close button is available on the tab bar
1021
1058
``AUI_NB_CLOSE_ON_ACTIVE_TAB`` With this style, a close button is available on the active tab
1022
1059
``AUI_NB_CLOSE_ON_ALL_TABS`` With this style, a close button is available on all tabs
1023
``AUI_NB_MIDDLE_CLICK_CLOSE`` Allows to close AuiNotebook tabs by mouse middle button click
1024
``AUI_NB_SUB_NOTEBOOK`` This style is used by AuiManager to create automatic AuiNotebooks
1060
``AUI_NB_MIDDLE_CLICK_CLOSE`` Allows to close L{AuiNotebook} tabs by mouse middle button click
1061
``AUI_NB_SUB_NOTEBOOK`` This style is used by L{AuiManager} to create automatic AuiNotebooks
1025
1062
``AUI_NB_HIDE_ON_SINGLE_TAB`` Hides the tab window if only one tab is present
1026
``AUI_NB_SMART_TABS`` Use Smart Tabbing, like ``Alt``+``Tab`` on Windows
1063
``AUI_NB_SMART_TABS`` Use Smart Tabbing, like ``Alt`` + ``Tab`` on Windows
1027
1064
``AUI_NB_USE_IMAGES_DROPDOWN`` Uses images on dropdown window list menu instead of check items
1028
1065
``AUI_NB_CLOSE_ON_TAB_LEFT`` Draws the tab close button on the left instead of on the right (a la Camino browser)
1029
1066
``AUI_NB_TAB_FLOAT`` Allows the floating of single tabs. Known limitation: when the notebook is more or less full screen, tabs cannot be dragged far enough outside of the notebook to become floating pages
1030
1067
``AUI_NB_DRAW_DND_TAB`` Draws an image representation of a tab while dragging (on by default)
1068
``AUI_NB_ORDER_BY_ACCESS`` Tab navigation order by last access time for the tabs
1069
``AUI_NB_NO_TAB_FOCUS`` Don't draw tab focus rectangle
1031
1070
==================================== ==================================
1052
1091
:param `tab_ctrl_size`: the size of the tab control area;
1053
1092
:param `tab_count`: the number of tabs;
1054
:param `minMaxTabWidth`: the minimum and maximum tab widths to be used
1055
when the ``AUI_NB_TAB_FIXED_WIDTH`` style is active.
1093
:param `minMaxTabWidth`: a tuple containing the minimum and maximum tab widths
1094
to be used when the ``AUI_NB_TAB_FIXED_WIDTH`` style is active.
1058
1097
self._fixed_tab_width = 100
1245
1283
dc.DrawLabel(draw_text, wx.Rect(text_offset, ypos, rectx, recty))
1247
1285
# draw focus rectangle
1248
if page.active and wx.Window.FindFocus() == wnd:
1286
if page.active and wx.Window.FindFocus() == wnd and (agwFlags & AUI_NB_NO_TAB_FOCUS) == 0:
1250
1288
focusRect = wx.Rect(text_offset, ((tab_y + tab_height)/2 - (texty/2) + 1),
1251
1289
selected_textx, selected_texty)
1777
1815
out_button_rect = wx.Rect()
1779
1817
# draw focus rectangle
1780
self.DrawFocusRectangle(dc, page, wnd, draw_text, offset_focus, bitmap_offset, drawn_tab_yoff+shift,
1781
drawn_tab_height+shift, textx, texty)
1818
if (agwFlags & AUI_NB_NO_TAB_FOCUS) == 0:
1819
self.DrawFocusRectangle(dc, page, wnd, draw_text, offset_focus, bitmap_offset, drawn_tab_yoff+shift,
1820
drawn_tab_height+shift, rectx, recty)
1783
1822
# draw 'x' on tab (if enabled)
1784
1823
if close_button_state != AUI_BUTTON_STATE_HIDDEN:
2012
2051
dc.DrawLabel(draw_text, wx.Rect(text_offset, ypos, rectx, recty))
2014
2053
# draw focus rectangle
2015
self.DrawFocusRectangle(dc, page, wnd, draw_text, offset_focus, bitmap_offset, drawn_tab_yoff+shift,
2016
drawn_tab_height, textx, texty)
2054
if (agwFlags & AUI_NB_NO_TAB_FOCUS) == 0:
2055
self.DrawFocusRectangle(dc, page, wnd, draw_text, offset_focus, bitmap_offset, drawn_tab_yoff+shift,
2056
drawn_tab_height, rectx, recty)
2018
2058
out_button_rect = wx.Rect()
2019
2059
# draw 'x' on tab (if enabled)
2134
2174
:param `tab_ctrl_size`: the size of the tab control area;
2135
2175
:param `tab_count`: the number of tabs;
2136
:param `minMaxTabWidth`: the minimum and maximum tab widths to be used
2137
when the ``AUI_NB_TAB_FIXED_WIDTH`` style is active.
2176
:param `minMaxTabWidth`: a tuple containing the minimum and maximum tab widths
2177
to be used when the ``AUI_NB_TAB_FIXED_WIDTH`` style is active.
2140
2180
AuiDefaultTabArt.SetSizingInfo(self, tab_ctrl_size, tab_count, minMaxTabWidth)
2342
2382
dc.DrawLabel(draw_text, wx.Rect(text_offset, ypos, rectx, recty))
2344
2384
# draw focus rectangle
2345
self.DrawFocusRectangle(dc, page, wnd, draw_text, offset_focus, bitmap_offset, drawn_tab_yoff+shift,
2346
drawn_tab_height+shift, textx, texty)
2385
if (agwFlags & AUI_NB_NO_TAB_FOCUS) == 0:
2386
self.DrawFocusRectangle(dc, page, wnd, draw_text, offset_focus, bitmap_offset, drawn_tab_yoff+shift,
2387
drawn_tab_height+shift, rectx, recty)
2348
2389
out_button_rect = wx.Rect()
2349
2390
# draw 'x' on tab (if enabled)
2451
2492
``AUI_NB_TOP`` With this style, tabs are drawn along the top of the notebook
2452
2493
``AUI_NB_LEFT`` With this style, tabs are drawn along the left of the notebook. Not implemented yet.
2453
2494
``AUI_NB_RIGHT`` With this style, tabs are drawn along the right of the notebook. Not implemented yet.
2454
``AUI_NB_BOTTOM`` With this style, tabs are drawn along the bottom of the notebook.
2495
``AUI_NB_BOTTOM`` With this style, tabs are drawn along the bottom of the notebook
2455
2496
``AUI_NB_TAB_SPLIT`` Allows the tab control to be split by dragging a tab
2456
2497
``AUI_NB_TAB_MOVE`` Allows a tab to be moved horizontally by dragging
2457
2498
``AUI_NB_TAB_EXTERNAL_MOVE`` Allows a tab to be moved to another tab control
2461
2502
``AUI_NB_CLOSE_BUTTON`` With this style, a close button is available on the tab bar
2462
2503
``AUI_NB_CLOSE_ON_ACTIVE_TAB`` With this style, a close button is available on the active tab
2463
2504
``AUI_NB_CLOSE_ON_ALL_TABS`` With this style, a close button is available on all tabs
2464
``AUI_NB_MIDDLE_CLICK_CLOSE`` Allows to close AuiNotebook tabs by mouse middle button click
2465
``AUI_NB_SUB_NOTEBOOK`` This style is used by AuiManager to create automatic AuiNotebooks
2505
``AUI_NB_MIDDLE_CLICK_CLOSE`` Allows to close L{AuiNotebook} tabs by mouse middle button click
2506
``AUI_NB_SUB_NOTEBOOK`` This style is used by L{AuiManager} to create automatic AuiNotebooks
2466
2507
``AUI_NB_HIDE_ON_SINGLE_TAB`` Hides the tab window if only one tab is present
2467
``AUI_NB_SMART_TABS`` Use Smart Tabbing, like ``Alt``+``Tab`` on Windows
2508
``AUI_NB_SMART_TABS`` Use Smart Tabbing, like ``Alt`` + ``Tab`` on Windows
2468
2509
``AUI_NB_USE_IMAGES_DROPDOWN`` Uses images on dropdown window list menu instead of check items
2469
2510
``AUI_NB_CLOSE_ON_TAB_LEFT`` Draws the tab close button on the left instead of on the right (a la Camino browser)
2470
2511
``AUI_NB_TAB_FLOAT`` Allows the floating of single tabs. Known limitation: when the notebook is more or less full screen, tabs cannot be dragged far enough outside of the notebook to become floating pages
2471
2512
``AUI_NB_DRAW_DND_TAB`` Draws an image representation of a tab while dragging (on by default)
2513
``AUI_NB_ORDER_BY_ACCESS`` Tab navigation order by last access time for the tabs
2514
``AUI_NB_NO_TAB_FOCUS`` Don't draw tab focus rectangle
2472
2515
==================================== ==================================
2474
2517
:note: Overridden from L{AuiDefaultTabArt}.
2526
2569
:param `tab_ctrl_size`: the size of the tab control area;
2527
2570
:param `tab_count`: the number of tabs;
2528
:param `minMaxTabWidth`: the minimum and maximum tab widths to be used
2529
when the ``AUI_NB_TAB_FIXED_WIDTH`` style is active.
2571
:param `minMaxTabWidth`: a tuple containing the minimum and maximum tab widths
2572
to be used when the ``AUI_NB_TAB_FIXED_WIDTH`` style is active.
2532
2575
AuiDefaultTabArt.SetSizingInfo(self, tab_ctrl_size, tab_count, minMaxTabWidth)