1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/themes/win32.cpp
3 // Purpose: wxUniversal theme implementing Win32-like LNF
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #include "wx/univ/theme.h"
35 #include "wx/window.h"
37 #include "wx/dcmemory.h"
39 #include "wx/button.h"
40 #include "wx/bmpbuttn.h"
41 #include "wx/listbox.h"
42 #include "wx/checklst.h"
43 #include "wx/combobox.h"
44 #include "wx/scrolbar.h"
45 #include "wx/slider.h"
46 #include "wx/textctrl.h"
47 #include "wx/toolbar.h"
48 #include "wx/statusbr.h"
51 // for COLOR_* constants
52 #include "wx/msw/private.h"
55 #include "wx/settings.h"
56 #include "wx/toplevel.h"
60 #include "wx/notebook.h"
61 #include "wx/spinbutt.h"
62 #include "wx/artprov.h"
63 #ifdef wxUSE_TOGGLEBTN
64 #include "wx/tglbtn.h"
65 #endif // wxUSE_TOGGLEBTN
67 #include "wx/univ/scrtimer.h"
68 #include "wx/univ/stdrend.h"
69 #include "wx/univ/inpcons.h"
70 #include "wx/univ/inphand.h"
71 #include "wx/univ/colschem.h"
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 static const int BORDER_THICKNESS
= 2;
79 static const size_t NUM_STATUSBAR_GRIP_BANDS
= 3;
80 static const size_t WIDTH_STATUSBAR_GRIP_BAND
= 4;
81 static const size_t STATUSBAR_GRIP_SIZE
=
82 WIDTH_STATUSBAR_GRIP_BAND
*NUM_STATUSBAR_GRIP_BANDS
;
84 static const wxCoord SLIDER_MARGIN
= 6; // margin around slider
85 static const wxCoord SLIDER_THUMB_LENGTH
= 18;
86 static const wxCoord SLIDER_TICK_LENGTH
= 6;
88 // wxWin32Renderer: draw the GUI elements in Win32 style
89 // ----------------------------------------------------------------------------
91 class wxWin32Renderer
: public wxStdRenderer
95 wxWin32Renderer(const wxColourScheme
*scheme
);
97 // reimplement the renderer methods which are different for this theme
98 virtual void DrawLabel(wxDC
& dc
,
99 const wxString
& label
,
102 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
104 wxRect
*rectBounds
= NULL
);
105 virtual void DrawButtonLabel(wxDC
& dc
,
106 const wxString
& label
,
107 const wxBitmap
& image
,
110 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
112 wxRect
*rectBounds
= NULL
);
113 virtual void DrawButtonBorder(wxDC
& dc
,
116 wxRect
*rectIn
= NULL
);
118 virtual void DrawArrow(wxDC
& dc
,
122 virtual void DrawScrollbarThumb(wxDC
& dc
,
123 wxOrientation orient
,
126 virtual void DrawScrollbarShaft(wxDC
& dc
,
127 wxOrientation orient
,
132 virtual void DrawToolBarButton(wxDC
& dc
,
133 const wxString
& label
,
134 const wxBitmap
& bitmap
,
139 #endif // wxUSE_TOOLBAR
142 virtual void DrawTab(wxDC
& dc
,
145 const wxString
& label
,
146 const wxBitmap
& bitmap
= wxNullBitmap
,
148 int indexAccel
= -1);
149 #endif // wxUSE_NOTEBOOK
152 virtual void DrawSliderShaft(wxDC
& dc
,
155 wxOrientation orient
,
158 wxRect
*rectShaft
= NULL
);
159 virtual void DrawSliderThumb(wxDC
& dc
,
161 wxOrientation orient
,
164 virtual void DrawSliderTicks(wxDC
& dc
,
167 wxOrientation orient
,
173 #endif // wxUSE_SLIDER
176 virtual void DrawMenuBarItem(wxDC
& dc
,
178 const wxString
& label
,
180 int indexAccel
= -1);
181 virtual void DrawMenuItem(wxDC
& dc
,
183 const wxMenuGeometryInfo
& geometryInfo
,
184 const wxString
& label
,
185 const wxString
& accel
,
186 const wxBitmap
& bitmap
= wxNullBitmap
,
188 int indexAccel
= -1);
189 virtual void DrawMenuSeparator(wxDC
& dc
,
191 const wxMenuGeometryInfo
& geomInfo
);
192 #endif // wxUSE_MENUS
195 virtual void DrawStatusField(wxDC
& dc
,
197 const wxString
& label
,
198 int flags
= 0, int style
= 0);
199 #endif // wxUSE_STATUSBAR
201 virtual void GetComboBitmaps(wxBitmap
*bmpNormal
,
203 wxBitmap
*bmpPressed
,
204 wxBitmap
*bmpDisabled
);
206 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
207 virtual bool AreScrollbarsInsideBorder() const;
209 virtual wxSize
GetScrollbarArrowSize() const
210 { return m_sizeScrollbarArrow
; }
212 virtual wxSize
GetCheckBitmapSize() const
213 { return wxSize(13, 13); }
214 virtual wxSize
GetRadioBitmapSize() const
215 { return wxSize(12, 12); }
216 virtual wxCoord
GetCheckItemMargin() const
220 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const
221 { if ( separator
) *separator
= 5; return wxSize(16, 15); }
222 virtual wxSize
GetToolBarMargin() const
223 { return wxSize(4, 4); }
224 #endif // wxUSE_TOOLBAR
227 virtual wxRect
GetTextTotalArea(const wxTextCtrl
*text
,
228 const wxRect
& rect
) const;
229 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
231 wxCoord
*extraSpaceBeyond
) const;
232 #endif // wxUSE_TEXTCTRL
235 virtual wxSize
GetTabIndent() const { return wxSize(2, 2); }
236 virtual wxSize
GetTabPadding() const { return wxSize(6, 5); }
237 #endif // wxUSE_NOTEBOOK
241 virtual wxCoord
GetSliderDim() const { return SLIDER_THUMB_LENGTH
+ 2*BORDER_THICKNESS
; }
242 virtual wxCoord
GetSliderTickLen() const { return SLIDER_TICK_LENGTH
; }
243 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
245 wxOrientation orient
,
246 long style
= 0) const;
247 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
249 wxOrientation orient
) const;
250 #endif // wxUSE_SLIDER
252 virtual wxSize
GetProgressBarStep() const { return wxSize(16, 32); }
255 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
256 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
257 const wxMenu
& menu
) const;
258 #endif // wxUSE_MENUS
261 // overridden wxStdRenderer methods
262 virtual void DrawFrameWithLabel(wxDC
& dc
,
263 const wxString
& label
,
264 const wxRect
& rectFrame
,
265 const wxRect
& rectText
,
270 virtual void DrawCheckItemBitmap(wxDC
& dc
,
271 const wxBitmap
& bitmap
,
276 // draw the border used for scrollbar arrows
277 void DrawArrowBorder(wxDC
& dc
, wxRect
*rect
, bool isPressed
= false);
279 // public DrawArrow()s helper
280 void DrawArrow(wxDC
& dc
, const wxRect
& rect
,
281 ArrowDirection arrowDir
, ArrowStyle arrowStyle
);
283 // DrawArrowButton is used by DrawScrollbar and DrawComboButton
284 void DrawArrowButton(wxDC
& dc
, const wxRect
& rect
,
285 ArrowDirection arrowDir
,
286 ArrowStyle arrowStyle
);
288 // draw a normal or transposed line (useful for using the same code fo both
289 // horizontal and vertical widgets)
290 void DrawLine(wxDC
& dc
,
291 wxCoord x1
, wxCoord y1
,
292 wxCoord x2
, wxCoord y2
,
293 bool transpose
= false)
296 dc
.DrawLine(y1
, x1
, y2
, x2
);
298 dc
.DrawLine(x1
, y1
, x2
, y2
);
301 // get the standard check/radio button bitmap
302 wxBitmap
GetIndicator(IndicatorType indType
, int flags
);
303 virtual wxBitmap
GetCheckBitmap(int flags
)
304 { return GetIndicator(IndicatorType_Check
, flags
); }
305 virtual wxBitmap
GetRadioBitmap(int flags
)
306 { return GetIndicator(IndicatorType_Radio
, flags
); }
308 virtual wxBitmap
GetFrameButtonBitmap(FrameButtonType type
);
311 // the sizing parameters (TODO make them changeable)
312 wxSize m_sizeScrollbarArrow
;
314 // the checked and unchecked bitmaps for DrawCheckItemBitmap()
315 wxBitmap m_bmpCheckBitmaps
[IndicatorStatus_Max
];
317 // the bitmaps returned by GetIndicator()
318 wxBitmap m_bmpIndicators
[IndicatorType_Max
]
319 [IndicatorState_MaxMenu
]
320 [IndicatorStatus_Max
];
323 wxBitmap m_bmpFrameButtons
[FrameButton_Max
];
325 // standard defaults for the above bitmaps
326 static const char **ms_xpmChecked
[IndicatorStatus_Max
];
327 static const char **ms_xpmIndicators
[IndicatorType_Max
]
328 [IndicatorState_MaxMenu
]
329 [IndicatorStatus_Max
];
330 static const char **ms_xpmFrameButtons
[FrameButton_Max
];
332 // first row is for the normal state, second - for the disabled
333 wxBitmap m_bmpArrows
[Arrow_StateMax
][Arrow_Max
];
336 // ----------------------------------------------------------------------------
337 // wxWin32InputHandler and derived classes: process the keyboard and mouse
338 // messages according to Windows standards
339 // ----------------------------------------------------------------------------
341 class wxWin32InputHandler
: public wxInputHandler
344 wxWin32InputHandler() { }
346 virtual bool HandleKey(wxInputConsumer
*control
,
347 const wxKeyEvent
& event
,
349 virtual bool HandleMouse(wxInputConsumer
*control
,
350 const wxMouseEvent
& event
);
354 class wxWin32ScrollBarInputHandler
: public wxStdScrollBarInputHandler
357 wxWin32ScrollBarInputHandler(wxRenderer
*renderer
,
358 wxInputHandler
*handler
);
360 virtual bool HandleMouse(wxInputConsumer
*control
,
361 const wxMouseEvent
& event
);
362 virtual bool HandleMouseMove(wxInputConsumer
*control
,
363 const wxMouseEvent
& event
);
365 virtual bool OnScrollTimer(wxScrollBar
*scrollbar
,
366 const wxControlAction
& action
);
369 virtual void Highlight(wxScrollBar
* WXUNUSED(scrollbar
),
372 // we don't highlight anything
375 // the first and last event which caused the thumb to move
376 wxMouseEvent m_eventStartDrag
,
379 // have we paused the scrolling because the mouse moved?
382 // we remember the interval of the timer to be able to restart it
385 #endif // wxUSE_SCROLLBAR
388 class wxWin32CheckboxInputHandler
: public wxStdInputHandler
391 wxWin32CheckboxInputHandler(wxInputHandler
*handler
)
392 : wxStdInputHandler(handler
) { }
394 virtual bool HandleKey(wxInputConsumer
*control
,
395 const wxKeyEvent
& event
,
398 #endif // wxUSE_CHECKBOX
401 class wxWin32TextCtrlInputHandler
: public wxStdInputHandler
404 wxWin32TextCtrlInputHandler(wxInputHandler
*handler
)
405 : wxStdInputHandler(handler
) { }
407 virtual bool HandleKey(wxInputConsumer
*control
,
408 const wxKeyEvent
& event
,
411 #endif // wxUSE_TEXTCTRL
413 class wxWin32StatusBarInputHandler
: public wxStdInputHandler
416 wxWin32StatusBarInputHandler(wxInputHandler
*handler
);
418 virtual bool HandleMouse(wxInputConsumer
*consumer
,
419 const wxMouseEvent
& event
);
421 virtual bool HandleMouseMove(wxInputConsumer
*consumer
,
422 const wxMouseEvent
& event
);
425 // is the given point over the statusbar grip?
426 bool IsOnGrip(wxWindow
*statbar
, const wxPoint
& pt
) const;
429 // the cursor we had replaced with the resize one
430 wxCursor m_cursorOld
;
432 // was the mouse over the grip last time we checked?
436 class wxWin32SystemMenuEvtHandler
;
438 class wxWin32FrameInputHandler
: public wxStdInputHandler
441 wxWin32FrameInputHandler(wxInputHandler
*handler
);
442 virtual ~wxWin32FrameInputHandler();
444 virtual bool HandleMouse(wxInputConsumer
*control
,
445 const wxMouseEvent
& event
);
447 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
450 void PopupSystemMenu(wxTopLevelWindow
*window
) const;
451 #endif // wxUSE_MENUS
454 // was the mouse over the grip last time we checked?
455 wxWin32SystemMenuEvtHandler
*m_menuHandler
;
458 // ----------------------------------------------------------------------------
459 // wxWin32ColourScheme: uses (default) Win32 colours
460 // ----------------------------------------------------------------------------
462 class wxWin32ColourScheme
: public wxColourScheme
465 virtual wxColour
Get(StdColour col
) const;
466 virtual wxColour
GetBackground(wxWindow
*win
) const;
469 // ----------------------------------------------------------------------------
470 // wxWin32ArtProvider
471 // ----------------------------------------------------------------------------
473 class wxWin32ArtProvider
: public wxArtProvider
476 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
477 const wxArtClient
& client
,
481 // ----------------------------------------------------------------------------
483 // ----------------------------------------------------------------------------
485 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
487 class wxWin32Theme
: public wxTheme
491 virtual ~wxWin32Theme();
493 virtual wxRenderer
*GetRenderer();
494 virtual wxArtProvider
*GetArtProvider();
495 virtual wxInputHandler
*GetInputHandler(const wxString
& control
,
496 wxInputConsumer
*consumer
);
497 virtual wxColourScheme
*GetColourScheme();
500 wxWin32Renderer
*m_renderer
;
502 wxWin32ArtProvider
*m_artProvider
;
504 // the names of the already created handlers and the handlers themselves
505 // (these arrays are synchronized)
506 wxSortedArrayString m_handlerNames
;
507 wxArrayHandlers m_handlers
;
509 wxWin32ColourScheme
*m_scheme
;
511 WX_DECLARE_THEME(win32
)
514 // ----------------------------------------------------------------------------
516 // ----------------------------------------------------------------------------
518 // frame buttons bitmaps
519 static const char *frame_button_close_xpm
[] = {
534 static const char *frame_button_help_xpm
[] = {
549 static const char *frame_button_maximize_xpm
[] = {
564 static const char *frame_button_minimize_xpm
[] = {
579 static const char *frame_button_restore_xpm
[] = {
594 const char **wxWin32Renderer::ms_xpmFrameButtons
[FrameButton_Max
] =
596 frame_button_close_xpm
,
597 frame_button_minimize_xpm
,
598 frame_button_maximize_xpm
,
599 frame_button_restore_xpm
,
600 frame_button_help_xpm
,
605 static const char *checked_menu_xpm
[] = {
606 /* columns rows colors chars-per-pixel */
622 static const char *selected_checked_menu_xpm
[] = {
623 /* columns rows colors chars-per-pixel */
639 static const char *disabled_checked_menu_xpm
[] = {
640 /* columns rows colors chars-per-pixel */
657 static const char *selected_disabled_checked_menu_xpm
[] = {
658 /* columns rows colors chars-per-pixel */
674 // checkbox and radiobox bitmaps below
676 static const char *checked_xpm
[] = {
677 /* columns rows colors chars-per-pixel */
700 static const char *pressed_checked_xpm
[] = {
701 /* columns rows colors chars-per-pixel */
723 static const char *pressed_disabled_checked_xpm
[] = {
724 /* columns rows colors chars-per-pixel */
746 static const char *checked_item_xpm
[] = {
747 /* columns rows colors chars-per-pixel */
768 static const char *unchecked_xpm
[] = {
769 /* columns rows colors chars-per-pixel */
792 static const char *pressed_unchecked_xpm
[] = {
793 /* columns rows colors chars-per-pixel */
815 static const char *unchecked_item_xpm
[] = {
816 /* columns rows colors chars-per-pixel */
836 static const char *undetermined_xpm
[] = {
837 /* columns rows colors chars-per-pixel */
860 static const char *pressed_undetermined_xpm
[] = {
861 /* columns rows colors chars-per-pixel */
884 static const char *checked_radio_xpm
[] = {
885 /* columns rows colors chars-per-pixel */
908 static const char *pressed_checked_radio_xpm
[] = {
909 /* columns rows colors chars-per-pixel */
932 static const char *pressed_disabled_checked_radio_xpm
[] = {
933 /* columns rows colors chars-per-pixel */
956 static const char *unchecked_radio_xpm
[] = {
957 /* columns rows colors chars-per-pixel */
980 static const char *pressed_unchecked_radio_xpm
[] = {
981 /* columns rows colors chars-per-pixel */
1004 const char **wxWin32Renderer::ms_xpmIndicators
[IndicatorType_Max
]
1005 [IndicatorState_MaxMenu
]
1006 [IndicatorStatus_Max
] =
1011 { checked_xpm
, unchecked_xpm
, undetermined_xpm
},
1014 { pressed_checked_xpm
, pressed_unchecked_xpm
, pressed_undetermined_xpm
},
1017 { pressed_disabled_checked_xpm
, pressed_unchecked_xpm
, pressed_disabled_checked_xpm
},
1023 { checked_radio_xpm
, unchecked_radio_xpm
, NULL
},
1026 { pressed_checked_radio_xpm
, pressed_unchecked_radio_xpm
, NULL
},
1029 { pressed_disabled_checked_radio_xpm
, pressed_unchecked_radio_xpm
, NULL
},
1035 { checked_menu_xpm
, NULL
, NULL
},
1038 { selected_checked_menu_xpm
, NULL
, NULL
},
1041 { disabled_checked_menu_xpm
, NULL
, NULL
},
1043 // disabled selected state
1044 { selected_disabled_checked_menu_xpm
, NULL
, NULL
},
1048 const char **wxWin32Renderer::ms_xpmChecked
[IndicatorStatus_Max
] =
1054 // ============================================================================
1056 // ============================================================================
1058 WX_IMPLEMENT_THEME(wxWin32Theme
, win32
, wxTRANSLATE("Win32 theme"));
1060 // ----------------------------------------------------------------------------
1062 // ----------------------------------------------------------------------------
1064 wxWin32Theme::wxWin32Theme()
1068 m_artProvider
= NULL
;
1071 wxWin32Theme::~wxWin32Theme()
1075 delete m_artProvider
;
1078 wxRenderer
*wxWin32Theme::GetRenderer()
1082 m_renderer
= new wxWin32Renderer(GetColourScheme());
1088 wxArtProvider
*wxWin32Theme::GetArtProvider()
1090 if ( !m_artProvider
)
1092 m_artProvider
= new wxWin32ArtProvider
;
1095 return m_artProvider
;
1099 wxWin32Theme::GetInputHandler(const wxString
& control
,
1100 wxInputConsumer
*consumer
)
1102 wxInputHandler
*handler
= NULL
;
1103 int n
= m_handlerNames
.Index(control
);
1104 if ( n
== wxNOT_FOUND
)
1106 static wxWin32InputHandler s_handlerDef
;
1108 wxInputHandler
* const
1109 handlerStd
= consumer
->DoGetStdInputHandler(&s_handlerDef
);
1111 // create a new handler
1112 if ( control
== wxINP_HANDLER_TOPLEVEL
)
1114 static wxWin32FrameInputHandler
s_handler(handlerStd
);
1116 handler
= &s_handler
;
1119 else if ( control
== wxINP_HANDLER_CHECKBOX
)
1121 static wxWin32CheckboxInputHandler
s_handler(handlerStd
);
1123 handler
= &s_handler
;
1125 #endif // wxUSE_CHECKBOX
1127 else if ( control
== wxINP_HANDLER_SCROLLBAR
)
1129 static wxWin32ScrollBarInputHandler
1130 s_handler(GetRenderer(), handlerStd
);
1132 handler
= &s_handler
;
1134 #endif // wxUSE_SCROLLBAR
1136 else if ( control
== wxINP_HANDLER_STATUSBAR
)
1138 static wxWin32StatusBarInputHandler
s_handler(handlerStd
);
1140 handler
= &s_handler
;
1142 #endif // wxUSE_STATUSBAR
1144 else if ( control
== wxINP_HANDLER_TEXTCTRL
)
1146 static wxWin32TextCtrlInputHandler
s_handler(handlerStd
);
1148 handler
= &s_handler
;
1150 #endif // wxUSE_TEXTCTRL
1151 else // no special handler for this control
1153 handler
= handlerStd
;
1156 n
= m_handlerNames
.Add(control
);
1157 m_handlers
.Insert(handler
, n
);
1159 else // we already have it
1161 handler
= m_handlers
[n
];
1167 wxColourScheme
*wxWin32Theme::GetColourScheme()
1171 m_scheme
= new wxWin32ColourScheme
;
1176 // ============================================================================
1177 // wxWin32ColourScheme
1178 // ============================================================================
1180 wxColour
wxWin32ColourScheme::GetBackground(wxWindow
*win
) const
1183 if ( win
->UseBgCol() )
1185 // use the user specified colour
1186 col
= win
->GetBackgroundColour();
1189 if ( !win
->ShouldInheritColours() )
1192 wxTextCtrl
*text
= wxDynamicCast(win
, wxTextCtrl
);
1193 #endif // wxUSE_TEXTCTRL
1195 wxListBox
* listBox
= wxDynamicCast(win
, wxListBox
);
1196 #endif // wxUSE_LISTBOX
1205 if ( !win
->IsEnabled() ) // not IsEditable()
1211 // doesn't depend on the state
1216 #endif // wxUSE_TEXTCTRL
1219 col
= Get(CONTROL
); // Most controls should be this colour, not WINDOW
1223 int flags
= win
->GetStateFlags();
1225 // the colour set by the user should be used for the normal state
1226 // and for the states for which we don't have any specific colours
1227 if ( !col
.Ok() || (flags
& wxCONTROL_PRESSED
) != 0 )
1230 if ( wxDynamicCast(win
, wxScrollBar
) )
1231 col
= Get(flags
& wxCONTROL_PRESSED
? SCROLLBAR_PRESSED
1234 #endif // wxUSE_SCROLLBAR
1242 wxColour
wxWin32ColourScheme::Get(wxWin32ColourScheme::StdColour col
) const
1246 // use the system colours under Windows
1247 #if defined(__WXMSW__)
1248 case WINDOW
: return wxColour(GetSysColor(COLOR_WINDOW
));
1250 case CONTROL_PRESSED
:
1251 case CONTROL_CURRENT
:
1252 case CONTROL
: return wxColour(GetSysColor(COLOR_BTNFACE
));
1254 case CONTROL_TEXT
: return wxColour(GetSysColor(COLOR_BTNTEXT
));
1256 #if defined(COLOR_3DLIGHT)
1257 case SCROLLBAR
: return wxColour(GetSysColor(COLOR_3DLIGHT
));
1259 case SCROLLBAR
: return wxColour(0xe0e0e0);
1261 case SCROLLBAR_PRESSED
: return wxColour(GetSysColor(COLOR_BTNTEXT
));
1263 case HIGHLIGHT
: return wxColour(GetSysColor(COLOR_HIGHLIGHT
));
1264 case HIGHLIGHT_TEXT
: return wxColour(GetSysColor(COLOR_HIGHLIGHTTEXT
));
1266 #if defined(COLOR_3DDKSHADOW)
1267 case SHADOW_DARK
: return wxColour(GetSysColor(COLOR_3DDKSHADOW
));
1269 case SHADOW_DARK
: return wxColour(GetSysColor(COLOR_3DHADOW
));
1272 case CONTROL_TEXT_DISABLED
:
1273 case SHADOW_HIGHLIGHT
: return wxColour(GetSysColor(COLOR_BTNHIGHLIGHT
));
1275 case SHADOW_IN
: return wxColour(GetSysColor(COLOR_BTNFACE
));
1277 case CONTROL_TEXT_DISABLED_SHADOW
:
1278 case SHADOW_OUT
: return wxColour(GetSysColor(COLOR_BTNSHADOW
));
1280 case TITLEBAR
: return wxColour(GetSysColor(COLOR_INACTIVECAPTION
));
1281 case TITLEBAR_ACTIVE
: return wxColour(GetSysColor(COLOR_ACTIVECAPTION
));
1282 case TITLEBAR_TEXT
: return wxColour(GetSysColor(COLOR_INACTIVECAPTIONTEXT
));
1283 case TITLEBAR_ACTIVE_TEXT
: return wxColour(GetSysColor(COLOR_CAPTIONTEXT
));
1285 case DESKTOP
: return wxColour(0x808000);
1287 // use the standard Windows colours elsewhere
1288 case WINDOW
: return *wxWHITE
;
1290 case CONTROL_PRESSED
:
1291 case CONTROL_CURRENT
:
1292 case CONTROL
: return wxColour(0xc0c0c0);
1294 case CONTROL_TEXT
: return *wxBLACK
;
1296 case SCROLLBAR
: return wxColour(0xe0e0e0);
1297 case SCROLLBAR_PRESSED
: return *wxBLACK
;
1299 case HIGHLIGHT
: return wxColour(0x800000);
1300 case HIGHLIGHT_TEXT
: return wxColour(0xffffff);
1302 case SHADOW_DARK
: return *wxBLACK
;
1304 case CONTROL_TEXT_DISABLED
:return wxColour(0xe0e0e0);
1305 case SHADOW_HIGHLIGHT
: return wxColour(0xffffff);
1307 case SHADOW_IN
: return wxColour(0xc0c0c0);
1309 case CONTROL_TEXT_DISABLED_SHADOW
:
1310 case SHADOW_OUT
: return wxColour(0x7f7f7f);
1312 case TITLEBAR
: return wxColour(0xaeaaae);
1313 case TITLEBAR_ACTIVE
: return wxColour(0x820300);
1314 case TITLEBAR_TEXT
: return wxColour(0xc0c0c0);
1315 case TITLEBAR_ACTIVE_TEXT
:return *wxWHITE
;
1317 case DESKTOP
: return wxColour(0x808000);
1320 case GAUGE
: return Get(HIGHLIGHT
);
1324 wxFAIL_MSG(_T("invalid standard colour"));
1329 // ============================================================================
1331 // ============================================================================
1333 // ----------------------------------------------------------------------------
1335 // ----------------------------------------------------------------------------
1337 wxWin32Renderer::wxWin32Renderer(const wxColourScheme
*scheme
)
1338 : wxStdRenderer(scheme
)
1341 m_sizeScrollbarArrow
= wxSize(16, 16);
1343 // init the arrow bitmaps
1344 static const size_t ARROW_WIDTH
= 7;
1345 static const size_t ARROW_LENGTH
= 4;
1348 wxMemoryDC dcNormal
,
1351 for ( size_t n
= 0; n
< Arrow_Max
; n
++ )
1353 bool isVertical
= n
> Arrow_Right
;
1366 // disabled arrow is larger because of the shadow
1367 m_bmpArrows
[Arrow_Normal
][n
].Create(w
, h
);
1368 m_bmpArrows
[Arrow_Disabled
][n
].Create(w
+ 1, h
+ 1);
1370 dcNormal
.SelectObject(m_bmpArrows
[Arrow_Normal
][n
]);
1371 dcDisabled
.SelectObject(m_bmpArrows
[Arrow_Disabled
][n
]);
1373 dcNormal
.SetBackground(*wxWHITE_BRUSH
);
1374 dcDisabled
.SetBackground(*wxWHITE_BRUSH
);
1378 dcNormal
.SetPen(m_penBlack
);
1379 dcDisabled
.SetPen(m_penDarkGrey
);
1381 // calculate the position of the point of the arrow
1385 x1
= (ARROW_WIDTH
- 1)/2;
1386 y1
= n
== Arrow_Up
? 0 : ARROW_LENGTH
- 1;
1390 x1
= n
== Arrow_Left
? 0 : ARROW_LENGTH
- 1;
1391 y1
= (ARROW_WIDTH
- 1)/2;
1402 for ( size_t i
= 0; i
< ARROW_LENGTH
; i
++ )
1404 dcNormal
.DrawLine(x1
, y1
, x2
, y2
);
1405 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1412 if ( n
== Arrow_Up
)
1423 else // left or right arrow
1428 if ( n
== Arrow_Left
)
1441 // draw the shadow for the disabled one
1442 dcDisabled
.SetPen(m_penHighlight
);
1447 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1451 x1
= ARROW_LENGTH
- 1;
1452 y1
= (ARROW_WIDTH
- 1)/2 + 1;
1455 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1456 dcDisabled
.DrawLine(++x1
, y1
, x2
, ++y2
);
1461 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1465 x1
= ARROW_WIDTH
- 1;
1467 x2
= (ARROW_WIDTH
- 1)/2;
1469 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1470 dcDisabled
.DrawLine(++x1
, y1
, x2
, ++y2
);
1475 // create the inverted bitmap but only for the right arrow as we only
1476 // use it for the menus
1477 if ( n
== Arrow_Right
)
1479 m_bmpArrows
[Arrow_Inverted
][n
].Create(w
, h
);
1480 dcInverse
.SelectObject(m_bmpArrows
[Arrow_Inverted
][n
]);
1482 dcInverse
.Blit(0, 0, w
, h
,
1485 dcInverse
.SelectObject(wxNullBitmap
);
1487 mask
= new wxMask(m_bmpArrows
[Arrow_Inverted
][n
], *wxBLACK
);
1488 m_bmpArrows
[Arrow_Inverted
][n
].SetMask(mask
);
1490 m_bmpArrows
[Arrow_InvertedDisabled
][n
].Create(w
, h
);
1491 dcInverse
.SelectObject(m_bmpArrows
[Arrow_InvertedDisabled
][n
]);
1493 dcInverse
.Blit(0, 0, w
, h
,
1496 dcInverse
.SelectObject(wxNullBitmap
);
1498 mask
= new wxMask(m_bmpArrows
[Arrow_InvertedDisabled
][n
], *wxBLACK
);
1499 m_bmpArrows
[Arrow_InvertedDisabled
][n
].SetMask(mask
);
1502 dcNormal
.SelectObject(wxNullBitmap
);
1503 dcDisabled
.SelectObject(wxNullBitmap
);
1505 mask
= new wxMask(m_bmpArrows
[Arrow_Normal
][n
], *wxWHITE
);
1506 m_bmpArrows
[Arrow_Normal
][n
].SetMask(mask
);
1507 mask
= new wxMask(m_bmpArrows
[Arrow_Disabled
][n
], *wxWHITE
);
1508 m_bmpArrows
[Arrow_Disabled
][n
].SetMask(mask
);
1510 m_bmpArrows
[Arrow_Pressed
][n
] = m_bmpArrows
[Arrow_Normal
][n
];
1514 bool wxWin32Renderer::AreScrollbarsInsideBorder() const
1519 // ----------------------------------------------------------------------------
1521 // ----------------------------------------------------------------------------
1523 void wxWin32Renderer::DrawLabel(wxDC
& dc
,
1524 const wxString
& label
,
1531 // the underscores are not drawn for focused controls in wxMSW
1532 if ( flags
& wxCONTROL_FOCUSED
)
1537 if ( flags
& wxCONTROL_DISABLED
)
1539 // the combination of wxCONTROL_SELECTED and wxCONTROL_DISABLED
1540 // currently only can happen for a menu item and it seems that Windows
1541 // doesn't draw the shadow in this case, so we don't do it neither
1542 if ( flags
& wxCONTROL_SELECTED
)
1544 // just make the label text greyed out
1545 dc
.SetTextForeground(m_penDarkGrey
.GetColour());
1547 flags
&= ~wxCONTROL_DISABLED
;
1551 wxStdRenderer::DrawLabel(dc
, label
, rect
, flags
, alignment
,
1552 indexAccel
, rectBounds
);
1555 void wxWin32Renderer::DrawFrameWithLabel(wxDC
& dc
,
1556 const wxString
& label
,
1557 const wxRect
& rectFrame
,
1558 const wxRect
& rectText
,
1564 label2
<< _T(' ') << label
<< _T(' ');
1565 if ( indexAccel
!= -1 )
1567 // adjust it as we prepended a space
1571 wxStdRenderer::DrawFrameWithLabel(dc
, label2
, rectFrame
, rectText
,
1572 flags
, alignment
, indexAccel
);
1575 void wxWin32Renderer::DrawButtonLabel(wxDC
& dc
,
1576 const wxString
& label
,
1577 const wxBitmap
& image
,
1584 // the underscores are not drawn for focused controls in wxMSW
1585 if ( flags
& wxCONTROL_PRESSED
)
1590 wxStdRenderer::DrawButtonLabel(dc
, label
, image
, rect
, flags
, alignment
,
1591 indexAccel
, rectBounds
);
1594 void wxWin32Renderer::DrawButtonBorder(wxDC
& dc
,
1595 const wxRect
& rectTotal
,
1599 wxRect rect
= rectTotal
;
1601 wxPen
penOut(*wxBLACK
);
1602 if ( flags
& wxCONTROL_PRESSED
)
1604 // button pressed: draw a double border around it
1605 DrawRect(dc
, &rect
, penOut
);
1606 DrawRect(dc
, &rect
, m_penDarkGrey
);
1608 else // button not pressed
1610 if ( flags
& (wxCONTROL_FOCUSED
| wxCONTROL_ISDEFAULT
) )
1612 // button either default or focused (or both): add an extra border
1614 DrawRect(dc
, &rect
, penOut
);
1617 // now draw a normal button border
1618 DrawRaisedBorder(dc
, &rect
);
1625 // ----------------------------------------------------------------------------
1626 // (check)listbox items
1627 // ----------------------------------------------------------------------------
1629 void wxWin32Renderer::DrawCheckItemBitmap(wxDC
& dc
,
1630 const wxBitmap
& bitmap
,
1639 else // use default bitmap
1641 IndicatorStatus i
= flags
& wxCONTROL_CHECKED
1642 ? IndicatorStatus_Checked
1643 : IndicatorStatus_Unchecked
;
1645 if ( !m_bmpCheckBitmaps
[i
].Ok() )
1647 m_bmpCheckBitmaps
[i
] = wxBitmap(ms_xpmChecked
[i
]);
1650 bmp
= m_bmpCheckBitmaps
[i
];
1653 dc
.DrawBitmap(bmp
, rect
.x
, rect
.y
+ (rect
.height
- bmp
.GetHeight()) / 2 - 1,
1654 true /* use mask */);
1657 // ----------------------------------------------------------------------------
1658 // check/radio buttons
1659 // ----------------------------------------------------------------------------
1661 wxBitmap
wxWin32Renderer::GetIndicator(IndicatorType indType
, int flags
)
1663 IndicatorState indState
;
1664 IndicatorStatus indStatus
;
1665 GetIndicatorsFromFlags(flags
, indState
, indStatus
);
1667 wxBitmap
& bmp
= m_bmpIndicators
[indType
][indState
][indStatus
];
1670 const char **xpm
= ms_xpmIndicators
[indType
][indState
][indStatus
];
1673 // create and cache it
1674 bmp
= wxBitmap(xpm
);
1681 // ----------------------------------------------------------------------------
1683 // ----------------------------------------------------------------------------
1686 void wxWin32Renderer::DrawToolBarButton(wxDC
& dc
,
1687 const wxString
& label
,
1688 const wxBitmap
& bitmap
,
1689 const wxRect
& rectOrig
,
1694 if (style
== wxTOOL_STYLE_BUTTON
)
1696 wxRect rect
= rectOrig
;
1697 rect
.Deflate(BORDER_THICKNESS
);
1699 if ( flags
& wxCONTROL_PRESSED
)
1701 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
);
1703 else if ( flags
& wxCONTROL_CURRENT
)
1705 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
);
1708 if(tbarStyle
& wxTB_TEXT
)
1710 if(tbarStyle
& wxTB_HORIZONTAL
)
1712 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1716 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
1721 int xpoint
= (rect
.GetLeft() + rect
.GetRight() + 1 - bitmap
.GetWidth()) / 2;
1722 int ypoint
= (rect
.GetTop() + rect
.GetBottom() + 1 - bitmap
.GetHeight()) / 2;
1723 dc
.DrawBitmap(bitmap
, xpoint
, ypoint
, bitmap
.GetMask() != NULL
);
1726 else if (style
== wxTOOL_STYLE_SEPARATOR
)
1728 // leave a small gap aroudn the line, also account for the toolbar
1730 if(rectOrig
.height
> rectOrig
.width
)
1733 DrawVerticalLine(dc
, rectOrig
.x
+ rectOrig
.width
/2,
1734 rectOrig
.y
+ 2*BORDER_THICKNESS
,
1735 rectOrig
.GetBottom() - BORDER_THICKNESS
);
1740 DrawHorizontalLine(dc
, rectOrig
.y
+ rectOrig
.height
/2,
1741 rectOrig
.x
+ 2*BORDER_THICKNESS
,
1742 rectOrig
.GetRight() - BORDER_THICKNESS
);
1745 // don't draw wxTOOL_STYLE_CONTROL
1747 #endif // wxUSE_TOOLBAR
1749 // ----------------------------------------------------------------------------
1751 // ----------------------------------------------------------------------------
1755 void wxWin32Renderer::DrawTab(wxDC
& dc
,
1756 const wxRect
& rectOrig
,
1758 const wxString
& label
,
1759 const wxBitmap
& bitmap
,
1763 #define SELECT_FOR_VERTICAL(X,Y) ( isVertical ? Y : X )
1764 #define REVERSE_FOR_VERTICAL(X,Y) \
1765 SELECT_FOR_VERTICAL(X,Y) \
1767 SELECT_FOR_VERTICAL(Y,X)
1769 wxRect rect
= rectOrig
;
1771 bool isVertical
= ( dir
== wxLEFT
) || ( dir
== wxRIGHT
);
1773 // the current tab is drawn indented (to the top for default case) and
1774 // bigger than the other ones
1775 const wxSize indent
= GetTabIndent();
1776 if ( flags
& wxCONTROL_SELECTED
)
1778 rect
.Inflate( SELECT_FOR_VERTICAL( indent
.x
, 0),
1779 SELECT_FOR_VERTICAL( 0, indent
.y
));
1783 wxFAIL_MSG(_T("invaild notebook tab orientation"));
1790 rect
.height
+= indent
.y
;
1797 rect
.width
+= indent
.x
;
1802 // draw the text, image and the focus around them (if necessary)
1803 wxRect
rectLabel( REVERSE_FOR_VERTICAL(rect
.x
,rect
.y
),
1804 REVERSE_FOR_VERTICAL(rect
.width
,rect
.height
)
1806 rectLabel
.Deflate(1, 1);
1809 // draw it horizontally into memory and rotate for screen
1811 wxBitmap bitmapRotated
,
1812 bitmapMem( rectLabel
.x
+ rectLabel
.width
,
1813 rectLabel
.y
+ rectLabel
.height
);
1814 dcMem
.SelectObject(bitmapMem
);
1815 dcMem
.SetBackground(dc
.GetBackground());
1816 dcMem
.SetFont(dc
.GetFont());
1817 dcMem
.SetTextForeground(dc
.GetTextForeground());
1821 wxBitmap( wxImage( bitmap
.ConvertToImage() ).Rotate90(dir
==wxLEFT
) )
1824 #endif // wxUSE_IMAGE
1826 DrawButtonLabel(dcMem
, label
, bitmapRotated
, rectLabel
,
1827 flags
, wxALIGN_CENTRE
, indexAccel
);
1828 dcMem
.SelectObject(wxNullBitmap
);
1829 bitmapMem
= bitmapMem
.GetSubBitmap(rectLabel
);
1831 bitmapMem
= wxBitmap(wxImage(bitmapMem
.ConvertToImage()).Rotate90(dir
==wxRIGHT
));
1832 #endif // wxUSE_IMAGE
1833 dc
.DrawBitmap(bitmapMem
, rectLabel
.y
, rectLabel
.x
, false);
1837 DrawButtonLabel(dc
, label
, bitmap
, rectLabel
,
1838 flags
, wxALIGN_CENTRE
, indexAccel
);
1841 // now draw the tab border itself (maybe use DrawRoundedRectangle()?)
1842 static const wxCoord CUTOFF
= 2; // radius of the rounded corner
1843 wxCoord x
= SELECT_FOR_VERTICAL(rect
.x
,rect
.y
),
1844 y
= SELECT_FOR_VERTICAL(rect
.y
,rect
.x
),
1845 x2
= SELECT_FOR_VERTICAL(rect
.GetRight(),rect
.GetBottom()),
1846 y2
= SELECT_FOR_VERTICAL(rect
.GetBottom(),rect
.GetRight());
1848 // FIXME: all this code will break if the tab indent or the border width,
1849 // it is tied to the fact that both of them are equal to 2
1855 // left orientation looks like top but IsVertical makes x and y reversed
1857 // top is not vertical so use coordinates in written order
1858 dc
.SetPen(m_penHighlight
);
1859 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
),
1860 REVERSE_FOR_VERTICAL(x
, y
+ CUTOFF
));
1861 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
+ CUTOFF
),
1862 REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y
));
1863 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y
),
1864 REVERSE_FOR_VERTICAL(x2
- CUTOFF
+ 1, y
));
1866 dc
.SetPen(m_penBlack
);
1867 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
),
1868 REVERSE_FOR_VERTICAL(x2
, y
+ CUTOFF
));
1869 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
+ CUTOFF
),
1870 REVERSE_FOR_VERTICAL(x2
- CUTOFF
, y
));
1872 dc
.SetPen(m_penDarkGrey
);
1873 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y2
),
1874 REVERSE_FOR_VERTICAL(x2
- 1, y
+ CUTOFF
- 1));
1876 if ( flags
& wxCONTROL_SELECTED
)
1878 dc
.SetPen(m_penLightGrey
);
1880 // overwrite the part of the border below this tab
1881 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1),
1882 REVERSE_FOR_VERTICAL(x2
- 1, y2
+ 1));
1884 // and the shadow of the tab to the left of us
1885 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
+ CUTOFF
+ 1),
1886 REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1));
1891 // right orientation looks like bottom but IsVertical makes x and y reversed
1893 // bottom is not vertical so use coordinates in written order
1894 dc
.SetPen(m_penHighlight
);
1895 // we need to continue one pixel further to overwrite the corner of
1896 // the border for the selected tab
1897 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
- (flags
& wxCONTROL_SELECTED
? 1 : 0)),
1898 REVERSE_FOR_VERTICAL(x
, y2
- CUTOFF
));
1899 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
- CUTOFF
),
1900 REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y2
));
1902 dc
.SetPen(m_penBlack
);
1903 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y2
),
1904 REVERSE_FOR_VERTICAL(x2
- CUTOFF
+ 1, y2
));
1905 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
),
1906 REVERSE_FOR_VERTICAL(x2
, y2
- CUTOFF
));
1907 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
- CUTOFF
),
1908 REVERSE_FOR_VERTICAL(x2
- CUTOFF
, y2
));
1910 dc
.SetPen(m_penDarkGrey
);
1911 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y2
- 1),
1912 REVERSE_FOR_VERTICAL(x2
- CUTOFF
+ 1, y2
- 1));
1913 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y
),
1914 REVERSE_FOR_VERTICAL(x2
- 1, y2
- CUTOFF
+ 1));
1916 if ( flags
& wxCONTROL_SELECTED
)
1918 dc
.SetPen(m_penLightGrey
);
1920 // overwrite the part of the (double!) border above this tab
1921 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 1),
1922 REVERSE_FOR_VERTICAL(x2
- 1, y
- 1));
1923 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 2),
1924 REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1926 // and the shadow of the tab to the left of us
1927 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
- CUTOFF
),
1928 REVERSE_FOR_VERTICAL(x
+ 1, y
- 1));
1933 #undef SELECT_FOR_VERTICAL
1934 #undef REVERSE_FOR_VERTICAL
1937 #endif // wxUSE_NOTEBOOK
1941 // ----------------------------------------------------------------------------
1943 // ----------------------------------------------------------------------------
1946 wxWin32Renderer::GetSliderThumbSize(const wxRect
& WXUNUSED(rect
),
1948 wxOrientation orient
) const
1951 wxCoord width
= wxMax (lenThumb
, SLIDER_THUMB_LENGTH
) / 2;
1952 wxCoord height
= wxMax (lenThumb
, SLIDER_THUMB_LENGTH
);
1954 if (orient
== wxHORIZONTAL
)
1968 wxRect
wxWin32Renderer::GetSliderShaftRect(const wxRect
& rectOrig
,
1970 wxOrientation orient
,
1973 bool transpose
= (orient
== wxVERTICAL
);
1974 bool left
= ((style
& wxSL_AUTOTICKS
) != 0) &
1975 (((style
& wxSL_TOP
) != 0) & !transpose
|
1976 ((style
& wxSL_LEFT
) != 0) & transpose
|
1977 ((style
& wxSL_BOTH
) != 0));
1978 bool right
= ((style
& wxSL_AUTOTICKS
) != 0) &
1979 (((style
& wxSL_BOTTOM
) != 0) & !transpose
|
1980 ((style
& wxSL_RIGHT
) != 0) & transpose
|
1981 ((style
& wxSL_BOTH
) != 0));
1983 wxRect rect
= rectOrig
;
1985 wxSize sizeThumb
= GetSliderThumbSize (rect
, lenThumb
, orient
);
1987 if (orient
== wxHORIZONTAL
) {
1988 rect
.x
+= SLIDER_MARGIN
;
1991 rect
.y
+= wxMax ((rect
.height
- 2*BORDER_THICKNESS
) / 2, sizeThumb
.y
/2);
1995 rect
.y
+= wxMax ((rect
.height
- 2*BORDER_THICKNESS
- sizeThumb
.y
/2), sizeThumb
.y
/2);
1999 rect
.y
+= sizeThumb
.y
/2;
2001 rect
.width
-= 2*SLIDER_MARGIN
;
2002 rect
.height
= 2*BORDER_THICKNESS
;
2006 rect
.y
+= SLIDER_MARGIN
;
2009 rect
.x
+= wxMax ((rect
.width
- 2*BORDER_THICKNESS
) / 2, sizeThumb
.x
/2);
2013 rect
.x
+= wxMax ((rect
.width
- 2*BORDER_THICKNESS
- sizeThumb
.x
/2), sizeThumb
.x
/2);
2017 rect
.x
+= sizeThumb
.x
/2;
2019 rect
.width
= 2*BORDER_THICKNESS
;
2020 rect
.height
-= 2*SLIDER_MARGIN
;
2026 void wxWin32Renderer::DrawSliderShaft(wxDC
& dc
,
2027 const wxRect
& rectOrig
,
2029 wxOrientation orient
,
2034 /* show shaft geometry
2052 if (flags
& wxCONTROL_FOCUSED
) {
2053 DrawFocusRect(dc
, rectOrig
);
2056 wxRect rect
= GetSliderShaftRect(rectOrig
, lenThumb
, orient
, style
);
2058 if (rectShaft
) *rectShaft
= rect
;
2060 DrawSunkenBorder(dc
, &rect
);
2063 void wxWin32Renderer::DrawSliderThumb(wxDC
& dc
,
2065 wxOrientation orient
,
2069 /* show thumb geometry
2078 H D B where H is highlight colour
2092 The interior of this shape is filled with the hatched brush if the thumb
2096 DrawBackground(dc
, wxNullColour
, rect
, flags
);
2098 bool transpose
= (orient
== wxVERTICAL
);
2099 bool left
= ((style
& wxSL_AUTOTICKS
) != 0) &
2100 (((style
& wxSL_TOP
) != 0) & !transpose
|
2101 ((style
& wxSL_LEFT
) != 0) & transpose
) &
2102 ((style
& wxSL_BOTH
) == 0);
2103 bool right
= ((style
& wxSL_AUTOTICKS
) != 0) &
2104 (((style
& wxSL_BOTTOM
) != 0) & !transpose
|
2105 ((style
& wxSL_RIGHT
) != 0) & transpose
) &
2106 ((style
& wxSL_BOTH
) == 0);
2108 wxCoord sizeArrow
= (transpose
? rect
.height
: rect
.width
) / 2;
2109 wxCoord c
= ((transpose
? rect
.height
: rect
.width
) - 2*sizeArrow
);
2111 wxCoord x1
, x2
, x3
, y1
, y2
, y3
, y4
;
2112 x1
= (transpose
? rect
.y
: rect
.x
);
2113 x2
= (transpose
? rect
.GetBottom() : rect
.GetRight());
2114 x3
= (x1
-1+c
) + sizeArrow
;
2115 y1
= (transpose
? rect
.x
: rect
.y
);
2116 y2
= (transpose
? rect
.GetRight() : rect
.GetBottom());
2117 y3
= (left
? (y1
-1+c
) + sizeArrow
: y1
);
2118 y4
= (right
? (y2
+1-c
) - sizeArrow
: y2
);
2120 dc
.SetPen(m_penBlack
);
2122 DrawLine(dc
, x3
+1-c
, y1
, x2
, y3
, transpose
);
2124 DrawLine(dc
, x2
, y3
, x2
, y4
, transpose
);
2127 DrawLine(dc
, x3
+1-c
, y2
, x2
, y4
, transpose
);
2131 DrawLine(dc
, x1
, y2
, x2
, y2
, transpose
);
2134 dc
.SetPen(m_penDarkGrey
);
2135 DrawLine(dc
, x2
-1, y3
+1, x2
-1, y4
-1, transpose
);
2137 DrawLine(dc
, x3
+1-c
, y2
-1, x2
-1, y4
, transpose
);
2141 DrawLine(dc
, x1
+1, y2
-1, x2
-1, y2
-1, transpose
);
2144 dc
.SetPen(m_penHighlight
);
2147 DrawLine(dc
, x1
, y3
, x3
, y1
, transpose
);
2148 DrawLine(dc
, x3
+1-c
, y1
+1, x2
-1, y3
, transpose
);
2152 DrawLine(dc
, x1
, y1
, x2
, y1
, transpose
);
2154 DrawLine(dc
, x1
, y3
, x1
, y4
, transpose
);
2157 DrawLine(dc
, x1
, y4
, x3
+c
, y2
+c
, transpose
);
2160 if (flags
& wxCONTROL_PRESSED
) {
2161 // TODO: MSW fills the entire area inside, not just the rect
2162 wxRect rectInt
= rect
;
2165 rectInt
.SetLeft(y3
);
2166 rectInt
.SetRight(y4
);
2171 rectInt
.SetBottom(y4
);
2175 #if !defined(__WXMGL__)
2176 static const char *stipple_xpm
[] = {
2177 /* columns rows colors chars-per-pixel */
2186 // VS: MGL can only do 8x8 stipple brushes
2187 static const char *stipple_xpm
[] = {
2188 /* columns rows colors chars-per-pixel */
2203 dc
.SetBrush(wxBrush(stipple_xpm
));
2205 dc
.SetTextForeground(wxSCHEME_COLOUR(m_scheme
, SHADOW_HIGHLIGHT
));
2206 dc
.SetTextBackground(wxSCHEME_COLOUR(m_scheme
, CONTROL
));
2207 dc
.SetPen(*wxTRANSPARENT_PEN
);
2208 dc
.DrawRectangle(rectInt
);
2212 void wxWin32Renderer::DrawSliderTicks(wxDC
& dc
,
2215 wxOrientation orient
,
2219 int WXUNUSED(flags
),
2222 /* show ticks geometry
2237 if (end
== start
) return;
2239 bool transpose
= (orient
== wxVERTICAL
);
2240 bool left
= ((style
& wxSL_AUTOTICKS
) != 0) &
2241 (((style
& wxSL_TOP
) != 0) & !transpose
|
2242 ((style
& wxSL_LEFT
) != 0) & transpose
|
2243 ((style
& wxSL_BOTH
) != 0));
2244 bool right
= ((style
& wxSL_AUTOTICKS
) != 0) &
2245 (((style
& wxSL_BOTTOM
) != 0) & !transpose
|
2246 ((style
& wxSL_RIGHT
) != 0) & transpose
|
2247 ((style
& wxSL_BOTH
) != 0));
2249 // default thumb size
2250 wxSize sizeThumb
= GetSliderThumbSize (rect
, 0, orient
);
2251 wxCoord defaultLen
= (transpose
? sizeThumb
.x
: sizeThumb
.y
);
2253 // normal thumb size
2254 sizeThumb
= GetSliderThumbSize (rect
, lenThumb
, orient
);
2255 wxCoord widthThumb
= (transpose
? sizeThumb
.y
: sizeThumb
.x
);
2257 wxRect rectShaft
= GetSliderShaftRect (rect
, lenThumb
, orient
, style
);
2259 wxCoord x1
, x2
, y1
, y2
, y3
, y4
, len
;
2260 x1
= (transpose
? rectShaft
.y
: rectShaft
.x
) + widthThumb
/2;
2261 x2
= (transpose
? rectShaft
.GetBottom() : rectShaft
.GetRight()) - widthThumb
/2;
2262 y1
= (transpose
? rectShaft
.x
: rectShaft
.y
) - defaultLen
/2;
2263 y2
= (transpose
? rectShaft
.GetRight() : rectShaft
.GetBottom()) + defaultLen
/2;
2264 y3
= (transpose
? rect
.x
: rect
.y
);
2265 y4
= (transpose
? rect
.GetRight() : rect
.GetBottom());
2268 dc
.SetPen(m_penBlack
);
2270 int range
= end
- start
;
2271 for ( int n
= 0; n
< range
; n
+= step
) {
2272 wxCoord x
= x1
+ (len
*n
) / range
;
2274 if (left
& (y1
> y3
)) {
2275 DrawLine(dc
, x
, y1
, x
, y3
, orient
== wxVERTICAL
);
2277 if (right
& (y4
> y2
)) {
2278 DrawLine(dc
, x
, y2
, x
, y4
, orient
== wxVERTICAL
);
2281 // always draw the line at the end position
2282 if (left
& (y1
> y3
)) {
2283 DrawLine(dc
, x2
, y1
, x2
, y3
, orient
== wxVERTICAL
);
2285 if (right
& (y4
> y2
)) {
2286 DrawLine(dc
, x2
, y2
, x2
, y4
, orient
== wxVERTICAL
);
2290 #endif // wxUSE_SLIDER
2294 // ----------------------------------------------------------------------------
2296 // ----------------------------------------------------------------------------
2298 // wxWin32MenuGeometryInfo: the wxMenuGeometryInfo used by wxWin32Renderer
2299 class WXDLLEXPORT wxWin32MenuGeometryInfo
: public wxMenuGeometryInfo
2302 virtual wxSize
GetSize() const { return m_size
; }
2304 wxCoord
GetLabelOffset() const { return m_ofsLabel
; }
2305 wxCoord
GetAccelOffset() const { return m_ofsAccel
; }
2307 wxCoord
GetItemHeight() const { return m_heightItem
; }
2310 // the total size of the menu
2313 // the offset of the start of the menu item label
2316 // the offset of the start of the accel label
2319 // the height of a normal (not separator) item
2320 wxCoord m_heightItem
;
2322 friend wxMenuGeometryInfo
*
2323 wxWin32Renderer::GetMenuGeometry(wxWindow
*, const wxMenu
&) const;
2326 // FIXME: all constants are hardcoded but shouldn't be
2327 static const wxCoord MENU_LEFT_MARGIN
= 9;
2328 static const wxCoord MENU_RIGHT_MARGIN
= 18;
2329 static const wxCoord MENU_VERT_MARGIN
= 3;
2331 // the margin around bitmap/check marks (on each side)
2332 static const wxCoord MENU_BMP_MARGIN
= 2;
2334 // the margin between the labels and accel strings
2335 static const wxCoord MENU_ACCEL_MARGIN
= 8;
2337 // the separator height in pixels: in fact, strangely enough, the real height
2338 // is 2 but Windows adds one extra pixel in the bottom margin, so take it into
2340 static const wxCoord MENU_SEPARATOR_HEIGHT
= 3;
2342 // the size of the standard checkmark bitmap
2343 static const wxCoord MENU_CHECK_SIZE
= 9;
2345 void wxWin32Renderer::DrawMenuBarItem(wxDC
& dc
,
2346 const wxRect
& rectOrig
,
2347 const wxString
& label
,
2351 wxRect rect
= rectOrig
;
2354 wxDCTextColourChanger
colChanger(dc
);
2356 if ( flags
& wxCONTROL_SELECTED
)
2358 colChanger
.Set(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT_TEXT
));
2360 const wxColour colBg
= wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT
);
2363 dc
.DrawRectangle(rect
);
2366 // don't draw the focus rect around menu bar items
2367 DrawLabel(dc
, label
, rect
, flags
& ~wxCONTROL_FOCUSED
,
2368 wxALIGN_CENTRE
, indexAccel
);
2371 void wxWin32Renderer::DrawMenuItem(wxDC
& dc
,
2373 const wxMenuGeometryInfo
& gi
,
2374 const wxString
& label
,
2375 const wxString
& accel
,
2376 const wxBitmap
& bitmap
,
2380 const wxWin32MenuGeometryInfo
& geometryInfo
=
2381 (const wxWin32MenuGeometryInfo
&)gi
;
2386 rect
.width
= geometryInfo
.GetSize().x
;
2387 rect
.height
= geometryInfo
.GetItemHeight();
2389 // draw the selected item specially
2390 wxDCTextColourChanger
colChanger(dc
);
2391 if ( flags
& wxCONTROL_SELECTED
)
2393 colChanger
.Set(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT_TEXT
));
2395 const wxColour colBg
= wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT
);
2398 dc
.DrawRectangle(rect
);
2401 // draw the bitmap: use the bitmap provided or the standard checkmark for
2402 // the checkable items
2403 wxBitmap bmp
= bitmap
;
2404 if ( !bmp
.Ok() && (flags
& wxCONTROL_CHECKED
) )
2406 bmp
= GetIndicator(IndicatorType_Menu
, flags
);
2411 rect
.SetRight(geometryInfo
.GetLabelOffset());
2412 wxControlRenderer::DrawBitmap(dc
, bmp
, rect
);
2416 rect
.x
= geometryInfo
.GetLabelOffset();
2417 rect
.SetRight(geometryInfo
.GetAccelOffset());
2419 DrawLabel(dc
, label
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
, indexAccel
);
2421 // draw the accel string
2422 rect
.x
= geometryInfo
.GetAccelOffset();
2423 rect
.SetRight(geometryInfo
.GetSize().x
);
2425 // NB: no accel index here
2426 DrawLabel(dc
, accel
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
);
2428 // draw the submenu indicator
2429 if ( flags
& wxCONTROL_ISSUBMENU
)
2431 rect
.x
= geometryInfo
.GetSize().x
- MENU_RIGHT_MARGIN
;
2432 rect
.width
= MENU_RIGHT_MARGIN
;
2434 ArrowStyle arrowStyle
;
2435 if ( flags
& wxCONTROL_DISABLED
)
2436 arrowStyle
= flags
& wxCONTROL_SELECTED
? Arrow_InvertedDisabled
2438 else if ( flags
& wxCONTROL_SELECTED
)
2439 arrowStyle
= Arrow_Inverted
;
2441 arrowStyle
= Arrow_Normal
;
2443 DrawArrow(dc
, rect
, Arrow_Right
, arrowStyle
);
2447 void wxWin32Renderer::DrawMenuSeparator(wxDC
& dc
,
2449 const wxMenuGeometryInfo
& geomInfo
)
2451 DrawHorizontalLine(dc
, y
+ MENU_VERT_MARGIN
, 0, geomInfo
.GetSize().x
);
2454 wxSize
wxWin32Renderer::GetMenuBarItemSize(const wxSize
& sizeText
) const
2456 wxSize size
= sizeText
;
2458 // FIXME: menubar height is configurable under Windows
2465 wxMenuGeometryInfo
*wxWin32Renderer::GetMenuGeometry(wxWindow
*win
,
2466 const wxMenu
& menu
) const
2468 // prepare the dc: for now we draw all the items with the system font
2470 dc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
2472 // the height of a normal item
2473 wxCoord heightText
= dc
.GetCharHeight();
2478 // the max length of label and accel strings: the menu width is the sum of
2479 // them, even if they're for different items (as the accels should be
2482 // the max length of the bitmap is never 0 as Windows always leaves enough
2483 // space for a check mark indicator
2484 wxCoord widthLabelMax
= 0,
2486 widthBmpMax
= MENU_LEFT_MARGIN
;
2488 for ( wxMenuItemList::compatibility_iterator node
= menu
.GetMenuItems().GetFirst();
2490 node
= node
->GetNext() )
2492 // height of this item
2495 wxMenuItem
*item
= node
->GetData();
2496 if ( item
->IsSeparator() )
2498 h
= MENU_SEPARATOR_HEIGHT
;
2500 else // not separator
2505 dc
.GetTextExtent(item
->GetLabel(), &widthLabel
, NULL
);
2506 if ( widthLabel
> widthLabelMax
)
2508 widthLabelMax
= widthLabel
;
2512 dc
.GetTextExtent(item
->GetAccelString(), &widthAccel
, NULL
);
2513 if ( widthAccel
> widthAccelMax
)
2515 widthAccelMax
= widthAccel
;
2518 const wxBitmap
& bmp
= item
->GetBitmap();
2521 wxCoord widthBmp
= bmp
.GetWidth();
2522 if ( widthBmp
> widthBmpMax
)
2523 widthBmpMax
= widthBmp
;
2525 //else if ( item->IsCheckable() ): no need to check for this as
2526 // MENU_LEFT_MARGIN is big enough to show the check mark
2529 h
+= 2*MENU_VERT_MARGIN
;
2531 // remember the item position and height
2532 item
->SetGeometry(height
, h
);
2537 // bundle the metrics into a struct and return it
2538 wxWin32MenuGeometryInfo
*gi
= new wxWin32MenuGeometryInfo
;
2540 gi
->m_ofsLabel
= widthBmpMax
+ 2*MENU_BMP_MARGIN
;
2541 gi
->m_ofsAccel
= gi
->m_ofsLabel
+ widthLabelMax
;
2542 if ( widthAccelMax
> 0 )
2544 // if we actually have any accesl, add a margin
2545 gi
->m_ofsAccel
+= MENU_ACCEL_MARGIN
;
2548 gi
->m_heightItem
= heightText
+ 2*MENU_VERT_MARGIN
;
2550 gi
->m_size
.x
= gi
->m_ofsAccel
+ widthAccelMax
+ MENU_RIGHT_MARGIN
;
2551 gi
->m_size
.y
= height
;
2556 #endif // wxUSE_MENUS
2560 // ----------------------------------------------------------------------------
2562 // ----------------------------------------------------------------------------
2564 void wxWin32Renderer::DrawStatusField(wxDC
& dc
,
2566 const wxString
& label
,
2572 if ( flags
& wxCONTROL_SIZEGRIP
)
2574 // draw the size grip: it is a normal rect except that in the lower
2575 // right corner we have several bands which may be used for dragging
2576 // the status bar corner
2578 // each band consists of 4 stripes: m_penHighlight, double
2579 // m_penDarkGrey and transparent one
2580 wxCoord x2
= rect
.GetRight(),
2581 y2
= rect
.GetBottom();
2583 // draw the upper left part of the rect normally
2584 if (style
!= wxSB_FLAT
)
2586 if (style
== wxSB_RAISED
)
2587 dc
.SetPen(m_penHighlight
);
2589 dc
.SetPen(m_penDarkGrey
);
2590 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(), rect
.GetLeft(), y2
);
2591 dc
.DrawLine(rect
.GetLeft() + 1, rect
.GetTop(), x2
, rect
.GetTop());
2594 // draw the grey stripes of the grip
2596 wxCoord ofs
= WIDTH_STATUSBAR_GRIP_BAND
- 1;
2597 for ( n
= 0; n
< NUM_STATUSBAR_GRIP_BANDS
; n
++, ofs
+= WIDTH_STATUSBAR_GRIP_BAND
)
2599 dc
.DrawLine(x2
- ofs
+ 1, y2
- 1, x2
, y2
- ofs
);
2600 dc
.DrawLine(x2
- ofs
, y2
- 1, x2
, y2
- ofs
- 1);
2603 // draw the white stripes
2604 dc
.SetPen(m_penHighlight
);
2605 ofs
= WIDTH_STATUSBAR_GRIP_BAND
+ 1;
2606 for ( n
= 0; n
< NUM_STATUSBAR_GRIP_BANDS
; n
++, ofs
+= WIDTH_STATUSBAR_GRIP_BAND
)
2608 dc
.DrawLine(x2
- ofs
+ 1, y2
- 1, x2
, y2
- ofs
);
2611 // draw the remaining rect boundaries
2612 if (style
!= wxSB_FLAT
)
2614 if (style
== wxSB_RAISED
)
2615 dc
.SetPen(m_penDarkGrey
);
2617 dc
.SetPen(m_penHighlight
);
2618 ofs
-= WIDTH_STATUSBAR_GRIP_BAND
;
2619 dc
.DrawLine(x2
, rect
.GetTop(), x2
, y2
- ofs
+ 1);
2620 dc
.DrawLine(rect
.GetLeft(), y2
, x2
- ofs
+ 1, y2
);
2626 rectIn
.width
-= STATUSBAR_GRIP_SIZE
;
2628 // this will prevent the standard version from drawing any borders
2632 wxStdRenderer::DrawStatusField(dc
, rect
, label
, flags
, style
);
2635 #endif // wxUSE_STATUSBAR
2637 // ----------------------------------------------------------------------------
2639 // ----------------------------------------------------------------------------
2641 void wxWin32Renderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
2642 wxBitmap
* WXUNUSED(bmpFocus
),
2643 wxBitmap
*bmpPressed
,
2644 wxBitmap
*bmpDisabled
)
2646 static const wxCoord widthCombo
= 16;
2647 static const wxCoord heightCombo
= 17;
2653 bmpNormal
->Create(widthCombo
, heightCombo
);
2654 dcMem
.SelectObject(*bmpNormal
);
2655 DrawArrowButton(dcMem
, wxRect(0, 0, widthCombo
, heightCombo
),
2656 Arrow_Down
, Arrow_Normal
);
2661 bmpPressed
->Create(widthCombo
, heightCombo
);
2662 dcMem
.SelectObject(*bmpPressed
);
2663 DrawArrowButton(dcMem
, wxRect(0, 0, widthCombo
, heightCombo
),
2664 Arrow_Down
, Arrow_Pressed
);
2669 bmpDisabled
->Create(widthCombo
, heightCombo
);
2670 dcMem
.SelectObject(*bmpDisabled
);
2671 DrawArrowButton(dcMem
, wxRect(0, 0, widthCombo
, heightCombo
),
2672 Arrow_Down
, Arrow_Disabled
);
2676 // ----------------------------------------------------------------------------
2678 // ----------------------------------------------------------------------------
2680 void wxWin32Renderer::DrawArrowBorder(wxDC
& dc
, wxRect
*rect
, bool isPressed
)
2684 DrawRect(dc
, rect
, m_penDarkGrey
);
2686 // the arrow is usually drawn inside border of width 2 and is offset by
2687 // another pixel in both directions when it's pressed - as the border
2688 // in this case is more narrow as well, we have to adjust rect like
2696 DrawAntiSunkenBorder(dc
, rect
);
2700 void wxWin32Renderer::DrawArrow(wxDC
& dc
,
2705 ArrowStyle arrowStyle
;
2706 if ( flags
& wxCONTROL_PRESSED
)
2708 // can't be pressed and disabled
2709 arrowStyle
= Arrow_Pressed
;
2713 arrowStyle
= flags
& wxCONTROL_DISABLED
? Arrow_Disabled
: Arrow_Normal
;
2716 DrawArrowButton(dc
, rect
, GetArrowDirection(dir
), arrowStyle
);
2719 void wxWin32Renderer::DrawArrow(wxDC
& dc
,
2721 ArrowDirection arrowDir
,
2722 ArrowStyle arrowStyle
)
2724 const wxBitmap
& bmp
= m_bmpArrows
[arrowStyle
][arrowDir
];
2726 // under Windows the arrows always have the same size so just centre it in
2727 // the provided rectangle
2728 wxCoord x
= rect
.x
+ (rect
.width
- bmp
.GetWidth()) / 2,
2729 y
= rect
.y
+ (rect
.height
- bmp
.GetHeight()) / 2;
2731 // Windows does it like this...
2732 if ( arrowDir
== Arrow_Left
)
2736 dc
.DrawBitmap(bmp
, x
, y
, true /* use mask */);
2739 void wxWin32Renderer::DrawArrowButton(wxDC
& dc
,
2740 const wxRect
& rectAll
,
2741 ArrowDirection arrowDir
,
2742 ArrowStyle arrowStyle
)
2744 wxRect rect
= rectAll
;
2745 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL
), rect
);
2746 DrawArrowBorder(dc
, &rect
, arrowStyle
== Arrow_Pressed
);
2747 DrawArrow(dc
, rect
, arrowDir
, arrowStyle
);
2750 void wxWin32Renderer::DrawScrollbarThumb(wxDC
& dc
,
2751 wxOrientation
WXUNUSED(orient
),
2753 int WXUNUSED(flags
))
2755 // we don't use the flags, the thumb never changes appearance
2756 wxRect rectThumb
= rect
;
2757 DrawArrowBorder(dc
, &rectThumb
);
2758 DrawBackground(dc
, wxNullColour
, rectThumb
);
2761 void wxWin32Renderer::DrawScrollbarShaft(wxDC
& dc
,
2762 wxOrientation
WXUNUSED(orient
),
2763 const wxRect
& rectBar
,
2766 wxColourScheme::StdColour col
= flags
& wxCONTROL_PRESSED
2767 ? wxColourScheme::SCROLLBAR_PRESSED
2768 : wxColourScheme::SCROLLBAR
;
2769 DrawBackground(dc
, m_scheme
->Get(col
), rectBar
);
2772 // ----------------------------------------------------------------------------
2774 // ----------------------------------------------------------------------------
2776 /* Copyright (c) Julian Smart */
2777 static char *error_xpm
[]={
2778 /* columns rows colors chars-per-pixel */
2855 " $oooooooooooo%& ",
2856 " *=-ooooooooooooo;: ",
2857 " *oooooooooooooooooo> ",
2858 " =ooooooooooooooooooo, ",
2859 " $-ooooooooooooooooooo<1 ",
2860 " .oooooo2334ooo533oooooo6 ",
2861 " +ooooooo789oo2883oooooo0q ",
2862 " oooooooo2w83o78eoooooooor ",
2863 " toooooooooy88u884oooooooori ",
2864 " Xooooooooooe888poooooooooas ",
2865 " ooooooooooo4889doooooooooof ",
2866 " ooooooooooo588w2oooooooooofi ",
2867 " oooooooooodw8887oooooooooofi ",
2868 " goooooooooh8w588jooooooookli ",
2869 " tooooooooz885op8wdooooooorix ",
2870 " oooooood98cood98cooooooori ",
2871 " @oooooop8w2ooo5885ooooovbi ",
2872 " n%ooooooooooooooooooooomiM ",
2873 " &;oooooooooooooooooooNBiV ",
2874 " :ooooooooooooooooooCZiA ",
2875 " nSooooooooooooooooCDiF ",
2876 " nG<oooooooooooooNZiiH ",
2877 " 160ooooooooovmBiFH ",
2878 " nqrraoookrrbiiA ",
2885 /* Copyright (c) Julian Smart */
2886 static char *info_xpm
[]={
2887 /* columns rows colors chars-per-pixel */
2909 " ..XXXXXXXXXXXXX.. ",
2910 " .XXXXXXXXXXXXXXXXX. ",
2911 " .XXXXXXXXoO+XXXXXXXX. ",
2912 " .XXXXXXXXX@#OXXXXXXXXX. ",
2913 " .XXXXXXXXXX$@oXXXXXXXXXX. ",
2914 " .XXXXXXXXXXXXXXXXXXXXXXX.% ",
2915 " .XXXXXXXXX&*=-XXXXXXXXXX.%% ",
2916 ".XXXXXXXXXX;:#>XXXXXXXXXXX.% ",
2917 ".XXXXXXXXXXX;#+XXXXXXXXXXX.% ",
2918 ".XXXXXXXXXXX;#+XXXXXXXXXXX.%% ",
2919 " .XXXXXXXXXX;#+XXXXXXXXXX.%%% ",
2920 " .XXXXXXXXXX;#+XXXXXXXXXX.%%% ",
2921 " .XXXXXXXXXX;#+XXXXXXXXXX.%% ",
2922 " .XXXXXXXX*-##+XXXXXXXX.%%% ",
2923 " .XXXXXXXXXXXXXXXXXXX.%%%% ",
2924 " .XXXXXXXXXXXXXXXXX.%%%% ",
2925 " ..XXXXXXXXXXXXX..%%%% ",
2926 " %...XXXXXXXX..%%%%% ",
2927 " %%%..XXXXXX.%%%%% ",
2941 /* Copyright (c) Julian Smart */
2942 static char *question_xpm
[]={
2943 /* columns rows colors chars-per-pixel */
2964 " ..XXXXXXXXXXXXX.. ",
2965 " .XXXXXXoO++@XXXXXX. ",
2966 " .XXXXXXO#$$$$#%XXXXX. ",
2967 " .XXXXXX@$$#&&#$#oXXXXX. ",
2968 " .XXXXXXX*$$%XX%$$=XXXXXX. ",
2969 " .XXXXXXX+-;XXXX$$-XXXXXX.: ",
2970 " .XXXXXXXXXXXXX+$$&XXXXXX.:: ",
2971 ".XXXXXXXXXXXXo;$$*oXXXXXXX.: ",
2972 ".XXXXXXXXXXXo*$$*oXXXXXXXX.: ",
2973 ".XXXXXXXXXXX+$$*oXXXXXXXXX.:: ",
2974 " .XXXXXXXXXX-$$oXXXXXXXXX.::: ",
2975 " .XXXXXXXXXXX--XXXXXXXXXX.::: ",
2976 " .XXXXXXXXXXXXXXXXXXXXXXX.:: ",
2977 " .XXXXXXXXX-$$XXXXXXXXX.::: ",
2978 " .XXXXXXXX-$$XXXXXXXX.:::: ",
2979 " .XXXXXXXO++XXXXXXX.:::: ",
2980 " ..XXXXXXXXXXXXX..:::: ",
2981 " :...XXXXXXXX..::::: ",
2982 " :::..XXXXXX.::::: ",
2996 /* Copyright (c) Julian Smart */
2997 static char *warning_xpm
[]={
2998 /* columns rows colors chars-per-pixel */
3024 " ..XXXXO@#XXX... ",
3025 " ...XXXXO@#XXXX.. ",
3026 " ..XXXXXO@#XXXX... ",
3027 " ...XXXXXo@OXXXXX.. ",
3028 " ...XXXXXXo@OXXXXXX.. ",
3029 " ..XXXXXXX$@OXXXXXX... ",
3030 " ...XXXXXXXX@XXXXXXXX.. ",
3031 " ...XXXXXXXXXXXXXXXXXX... ",
3032 " ..XXXXXXXXXXOXXXXXXXXX.. ",
3033 " ...XXXXXXXXXO@#XXXXXXXXX.. ",
3034 " ..XXXXXXXXXXX#XXXXXXXXXX... ",
3035 " ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
3036 " ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
3037 " .............................. ",
3038 " .............................. ",
3045 wxBitmap
wxWin32ArtProvider::CreateBitmap(const wxArtID
& id
,
3046 const wxArtClient
& WXUNUSED(client
),
3047 const wxSize
& WXUNUSED(size
))
3049 if ( id
== wxART_INFORMATION
)
3050 return wxBitmap(info_xpm
);
3051 if ( id
== wxART_ERROR
)
3052 return wxBitmap(error_xpm
);
3053 if ( id
== wxART_WARNING
)
3054 return wxBitmap(warning_xpm
);
3055 if ( id
== wxART_QUESTION
)
3056 return wxBitmap(question_xpm
);
3057 return wxNullBitmap
;
3063 // ----------------------------------------------------------------------------
3064 // text control geometry
3065 // ----------------------------------------------------------------------------
3068 wxWin32Renderer::GetTextTotalArea(const wxTextCtrl
*text
,
3069 const wxRect
& rect
) const
3071 wxRect rectTotal
= wxStdRenderer::GetTextTotalArea(text
, rect
);
3073 // this is strange but it's what Windows does
3080 wxWin32Renderer::GetTextClientArea(const wxTextCtrl
*text
,
3082 wxCoord
*extraSpaceBeyond
) const
3084 wxRect rectText
= rect
;
3086 // undo GetTextTotalArea()
3087 if ( rectText
.height
> 0 )
3090 return wxStdRenderer::GetTextClientArea(text
, rect
, extraSpaceBeyond
);
3093 #endif // wxUSE_TEXTCTRL
3095 // ----------------------------------------------------------------------------
3097 // ----------------------------------------------------------------------------
3099 void wxWin32Renderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
3102 if ( wxDynamicCast(window
, wxScrollBar
) )
3104 // we only set the width of vert scrollbars and height of the
3106 if ( window
->GetWindowStyle() & wxSB_HORIZONTAL
)
3107 size
->y
= m_sizeScrollbarArrow
.y
;
3109 size
->x
= m_sizeScrollbarArrow
.x
;
3111 // skip border width adjustments, they don't make sense for us
3114 #endif // wxUSE_SCROLLBAR
3117 if ( wxDynamicCast(window
, wxBitmapButton
) )
3121 #endif // wxUSE_BMPBUTTON
3122 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
3125 || wxDynamicCast(window
, wxButton
)
3126 # endif // wxUSE_BUTTON
3127 # if wxUSE_TOGGLEBTN
3128 || wxDynamicCast(window
, wxToggleButton
)
3129 # endif // wxUSE_TOGGLEBTN
3132 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
3134 // TODO: don't harcode all this
3135 size
->x
+= 3*window
->GetCharWidth();
3137 wxCoord heightBtn
= (11*(window
->GetCharHeight() + 8))/10;
3138 if ( size
->y
< heightBtn
- 8 )
3139 size
->y
= heightBtn
;
3144 // for compatibility with other ports, the buttons default size is never
3145 // less than the standard one, but not when display not PDAs.
3146 if (wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA
)
3148 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
3150 wxSize szDef
= wxButton::GetDefaultSize();
3151 if ( size
->x
< szDef
.x
)
3156 // no border width adjustments for buttons
3159 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
3161 wxStdRenderer::AdjustSize(size
, window
);
3164 wxBitmap
wxWin32Renderer::GetFrameButtonBitmap(FrameButtonType type
)
3166 wxBitmap
& bmp
= m_bmpFrameButtons
[type
];
3169 bmp
= wxBitmap(ms_xpmFrameButtons
[type
]);
3175 // ============================================================================
3177 // ============================================================================
3179 // ----------------------------------------------------------------------------
3180 // wxWin32InputHandler
3181 // ----------------------------------------------------------------------------
3183 bool wxWin32InputHandler::HandleKey(wxInputConsumer
* WXUNUSED(control
),
3184 const wxKeyEvent
& WXUNUSED(event
),
3185 bool WXUNUSED(pressed
))
3190 bool wxWin32InputHandler::HandleMouse(wxInputConsumer
*control
,
3191 const wxMouseEvent
& event
)
3193 // clicking on the control gives it focus
3194 if ( event
.ButtonDown() )
3196 wxWindow
*win
= control
->GetInputWindow();
3198 if ( (wxWindow::FindFocus() != control
->GetInputWindow()) &&
3199 win
->AcceptsFocus() )
3212 // ----------------------------------------------------------------------------
3213 // wxWin32ScrollBarInputHandler
3214 // ----------------------------------------------------------------------------
3216 wxWin32ScrollBarInputHandler::
3217 wxWin32ScrollBarInputHandler(wxRenderer
*renderer
, wxInputHandler
*handler
)
3218 : wxStdScrollBarInputHandler(renderer
, handler
)
3220 m_scrollPaused
= false;
3224 bool wxWin32ScrollBarInputHandler::OnScrollTimer(wxScrollBar
*scrollbar
,
3225 const wxControlAction
& action
)
3227 // stop if went beyond the position of the original click (this can only
3228 // happen when we scroll by pages)
3230 if ( action
== wxACTION_SCROLL_PAGE_DOWN
)
3232 stop
= m_renderer
->HitTestScrollbar(scrollbar
, m_ptStartScrolling
)
3233 != wxHT_SCROLLBAR_BAR_2
;
3235 else if ( action
== wxACTION_SCROLL_PAGE_UP
)
3237 stop
= m_renderer
->HitTestScrollbar(scrollbar
, m_ptStartScrolling
)
3238 != wxHT_SCROLLBAR_BAR_1
;
3243 StopScrolling(scrollbar
);
3245 scrollbar
->Refresh();
3250 return wxStdScrollBarInputHandler::OnScrollTimer(scrollbar
, action
);
3253 bool wxWin32ScrollBarInputHandler::HandleMouse(wxInputConsumer
*control
,
3254 const wxMouseEvent
& event
)
3256 // remember the current state
3257 bool wasDraggingThumb
= m_htLast
== wxHT_SCROLLBAR_THUMB
;
3259 // do process the message
3260 bool rc
= wxStdScrollBarInputHandler::HandleMouse(control
, event
);
3262 // analyse the changes
3263 if ( !wasDraggingThumb
&& (m_htLast
== wxHT_SCROLLBAR_THUMB
) )
3265 // we just started dragging the thumb, remember its initial position to
3266 // be able to restore it if the drag is cancelled later
3267 m_eventStartDrag
= event
;
3273 bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer
*control
,
3274 const wxMouseEvent
& event
)
3276 // we don't highlight scrollbar elements, so there is no need to process
3277 // mouse move events normally - only do it while mouse is captured (i.e.
3278 // when we're dragging the thumb or pressing on something)
3279 if ( !m_winCapture
)
3282 if ( event
.Entering() )
3284 // we're not interested in this at all
3288 wxScrollBar
*scrollbar
= wxStaticCast(control
->GetInputWindow(), wxScrollBar
);
3290 if ( m_scrollPaused
)
3292 // check if the mouse returned to its original location
3294 if ( event
.Leaving() )
3300 ht
= m_renderer
->HitTestScrollbar(scrollbar
, event
.GetPosition());
3301 if ( ht
== m_htLast
)
3303 // yes it did, resume scrolling
3304 m_scrollPaused
= false;
3305 if ( m_timerScroll
)
3307 // we were scrolling by line/page, restart timer
3308 m_timerScroll
->Start(m_interval
);
3310 Press(scrollbar
, true);
3312 else // we were dragging the thumb
3314 // restore its last location
3315 HandleThumbMove(scrollbar
, m_eventLastDrag
);
3321 else // normal case, scrolling hasn't been paused
3323 // if we're scrolling the scrollbar because the arrow or the shaft was
3324 // pressed, check that the mouse stays on the same scrollbar element
3327 // Always let thumb jump back if we leave the scrollbar
3328 if ( event
.Moving() )
3330 ht
= m_renderer
->HitTestScrollbar(scrollbar
, event
.GetPosition());
3332 else // event.Leaving()
3337 // Jump back only if we get far away from it
3338 wxPoint pos
= event
.GetPosition();
3339 if (scrollbar
->HasFlag( wxVERTICAL
))
3341 if (pos
.x
> -40 && pos
.x
< scrollbar
->GetSize().x
+40)
3346 if (pos
.y
> -40 && pos
.y
< scrollbar
->GetSize().y
+40)
3349 ht
= m_renderer
->HitTestScrollbar(scrollbar
, pos
);
3352 // if we're dragging the thumb and the mouse stays in the scrollbar, it
3353 // is still ok - we only want to catch the case when the mouse leaves
3354 // the scrollbar here
3355 if ( m_htLast
== wxHT_SCROLLBAR_THUMB
&& ht
!= wxHT_NOWHERE
)
3357 ht
= wxHT_SCROLLBAR_THUMB
;
3360 if ( ht
!= m_htLast
)
3362 // what were we doing? 2 possibilities: either an arrow/shaft was
3363 // pressed in which case we have a timer and so we just stop it or
3364 // we were dragging the thumb
3365 if ( m_timerScroll
)
3368 m_interval
= m_timerScroll
->GetInterval();
3369 m_timerScroll
->Stop();
3370 m_scrollPaused
= true;
3372 // unpress the arrow
3373 Press(scrollbar
, false);
3375 else // we were dragging the thumb
3377 // remember the current thumb position to be able to restore it
3378 // if the mouse returns to it later
3379 m_eventLastDrag
= event
;
3381 // and restore the original position (before dragging) of the
3383 HandleThumbMove(scrollbar
, m_eventStartDrag
);
3390 return wxStdInputHandler::HandleMouseMove(control
, event
);
3393 #endif // wxUSE_SCROLLBAR
3397 // ----------------------------------------------------------------------------
3398 // wxWin32CheckboxInputHandler
3399 // ----------------------------------------------------------------------------
3401 bool wxWin32CheckboxInputHandler::HandleKey(wxInputConsumer
*control
,
3402 const wxKeyEvent
& event
,
3407 wxControlAction action
;
3408 int keycode
= event
.GetKeyCode();
3412 action
= wxACTION_CHECKBOX_TOGGLE
;
3416 case WXK_NUMPAD_SUBTRACT
:
3417 action
= wxACTION_CHECKBOX_CHECK
;
3421 case WXK_NUMPAD_ADD
:
3422 case WXK_NUMPAD_EQUAL
:
3423 action
= wxACTION_CHECKBOX_CLEAR
;
3427 if ( !action
.IsEmpty() )
3429 control
->PerformAction(action
);
3438 #endif // wxUSE_CHECKBOX
3442 // ----------------------------------------------------------------------------
3443 // wxWin32TextCtrlInputHandler
3444 // ----------------------------------------------------------------------------
3446 bool wxWin32TextCtrlInputHandler::HandleKey(wxInputConsumer
*control
,
3447 const wxKeyEvent
& event
,
3450 // handle only MSW-specific text bindings here, the others are handled in
3454 int keycode
= event
.GetKeyCode();
3456 wxControlAction action
;
3457 if ( keycode
== WXK_DELETE
&& event
.ShiftDown() )
3459 action
= wxACTION_TEXT_CUT
;
3461 else if ( keycode
== WXK_INSERT
)
3463 if ( event
.ControlDown() )
3464 action
= wxACTION_TEXT_COPY
;
3465 else if ( event
.ShiftDown() )
3466 action
= wxACTION_TEXT_PASTE
;
3469 if ( action
!= wxACTION_NONE
)
3471 control
->PerformAction(action
);
3477 return wxStdInputHandler::HandleKey(control
, event
, pressed
);
3480 #endif // wxUSE_TEXTCTRL
3484 // ----------------------------------------------------------------------------
3485 // wxWin32StatusBarInputHandler
3486 // ----------------------------------------------------------------------------
3488 wxWin32StatusBarInputHandler::
3489 wxWin32StatusBarInputHandler(wxInputHandler
*handler
)
3490 : wxStdInputHandler(handler
)
3495 bool wxWin32StatusBarInputHandler::IsOnGrip(wxWindow
*statbar
,
3496 const wxPoint
& pt
) const
3498 if ( statbar
->HasFlag(wxST_SIZEGRIP
) &&
3499 statbar
->GetParent()->HasFlag(wxRESIZE_BORDER
) )
3502 parentTLW
= wxDynamicCast(statbar
->GetParent(), wxTopLevelWindow
);
3504 wxCHECK_MSG( parentTLW
, false,
3505 _T("the status bar should be a child of a TLW") );
3507 // a maximized window can't be resized anyhow
3508 if ( !parentTLW
->IsMaximized() )
3510 // VZ: I think that the standard Windows behaviour is to only
3511 // show the resizing cursor when the mouse is on top of the
3512 // grip itself but apparently different Windows versions behave
3513 // differently (?) and it seems a better UI to allow resizing
3514 // the status bar even when the mouse is above the grip
3515 wxSize sizeSbar
= statbar
->GetSize();
3517 int diff
= sizeSbar
.x
- pt
.x
;
3518 return diff
>= 0 && diff
< (wxCoord
)STATUSBAR_GRIP_SIZE
;
3525 bool wxWin32StatusBarInputHandler::HandleMouse(wxInputConsumer
*consumer
,
3526 const wxMouseEvent
& event
)
3528 if ( event
.Button(1) )
3530 if ( event
.ButtonDown(1) )
3532 wxWindow
*statbar
= consumer
->GetInputWindow();
3534 if ( IsOnGrip(statbar
, event
.GetPosition()) )
3536 wxTopLevelWindow
*tlw
= wxDynamicCast(statbar
->GetParent(),
3540 tlw
->PerformAction(wxACTION_TOPLEVEL_RESIZE
,
3541 wxHT_TOPLEVEL_BORDER_SE
);
3543 statbar
->SetCursor(m_cursorOld
);
3551 return wxStdInputHandler::HandleMouse(consumer
, event
);
3554 bool wxWin32StatusBarInputHandler::HandleMouseMove(wxInputConsumer
*consumer
,
3555 const wxMouseEvent
& event
)
3557 wxWindow
*statbar
= consumer
->GetInputWindow();
3559 bool isOnGrip
= IsOnGrip(statbar
, event
.GetPosition());
3560 if ( isOnGrip
!= m_isOnGrip
)
3562 m_isOnGrip
= isOnGrip
;
3565 m_cursorOld
= statbar
->GetCursor();
3566 statbar
->SetCursor(wxCURSOR_SIZENWSE
);
3570 statbar
->SetCursor(m_cursorOld
);
3574 return wxStdInputHandler::HandleMouseMove(consumer
, event
);
3577 #endif // wxUSE_STATUSBAR
3579 // ----------------------------------------------------------------------------
3580 // wxWin32FrameInputHandler
3581 // ----------------------------------------------------------------------------
3583 class wxWin32SystemMenuEvtHandler
: public wxEvtHandler
3586 wxWin32SystemMenuEvtHandler(wxWin32FrameInputHandler
*handler
);
3588 void Attach(wxInputConsumer
*consumer
);
3592 DECLARE_EVENT_TABLE()
3593 void OnSystemMenu(wxCommandEvent
&event
);
3594 void OnCloseFrame(wxCommandEvent
&event
);
3595 void OnClose(wxCloseEvent
&event
);
3597 wxWin32FrameInputHandler
*m_inputHnd
;
3598 wxTopLevelWindow
*m_wnd
;
3600 wxAcceleratorTable m_oldAccelTable
;
3604 wxWin32SystemMenuEvtHandler::
3605 wxWin32SystemMenuEvtHandler(wxWin32FrameInputHandler
*handler
)
3607 m_inputHnd
= handler
;
3611 void wxWin32SystemMenuEvtHandler::Attach(wxInputConsumer
*consumer
)
3613 wxASSERT_MSG( m_wnd
== NULL
, _T("can't attach the handler twice!") );
3615 m_wnd
= wxStaticCast(consumer
->GetInputWindow(), wxTopLevelWindow
);
3616 m_wnd
->PushEventHandler(this);
3619 // VS: This code relies on using generic implementation of
3620 // wxAcceleratorTable in wxUniv!
3621 wxAcceleratorTable table
= *m_wnd
->GetAcceleratorTable();
3622 m_oldAccelTable
= table
;
3623 table
.Add(wxAcceleratorEntry(wxACCEL_ALT
, WXK_SPACE
, wxID_SYSTEM_MENU
));
3624 table
.Add(wxAcceleratorEntry(wxACCEL_ALT
, WXK_F4
, wxID_CLOSE_FRAME
));
3625 m_wnd
->SetAcceleratorTable(table
);
3629 void wxWin32SystemMenuEvtHandler::Detach()
3634 m_wnd
->SetAcceleratorTable(m_oldAccelTable
);
3636 m_wnd
->RemoveEventHandler(this);
3641 BEGIN_EVENT_TABLE(wxWin32SystemMenuEvtHandler
, wxEvtHandler
)
3642 EVT_MENU(wxID_SYSTEM_MENU
, wxWin32SystemMenuEvtHandler::OnSystemMenu
)
3643 EVT_MENU(wxID_CLOSE_FRAME
, wxWin32SystemMenuEvtHandler::OnCloseFrame
)
3644 EVT_CLOSE(wxWin32SystemMenuEvtHandler::OnClose
)
3647 void wxWin32SystemMenuEvtHandler::OnSystemMenu(wxCommandEvent
&WXUNUSED(event
))
3650 wxAcceleratorTable table
= *m_wnd
->GetAcceleratorTable();
3651 m_wnd
->SetAcceleratorTable(wxNullAcceleratorTable
);
3655 m_inputHnd
->PopupSystemMenu(m_wnd
);
3656 #endif // wxUSE_MENUS
3659 m_wnd
->SetAcceleratorTable(table
);
3663 void wxWin32SystemMenuEvtHandler::OnCloseFrame(wxCommandEvent
&WXUNUSED(event
))
3665 m_wnd
->PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
,
3666 wxTOPLEVEL_BUTTON_CLOSE
);
3669 void wxWin32SystemMenuEvtHandler::OnClose(wxCloseEvent
&event
)
3676 wxWin32FrameInputHandler::wxWin32FrameInputHandler(wxInputHandler
*handler
)
3677 : wxStdInputHandler(handler
)
3679 m_menuHandler
= new wxWin32SystemMenuEvtHandler(this);
3682 wxWin32FrameInputHandler::~wxWin32FrameInputHandler()
3684 if ( m_menuHandler
)
3686 m_menuHandler
->Detach();
3687 delete m_menuHandler
;
3691 bool wxWin32FrameInputHandler::HandleMouse(wxInputConsumer
*consumer
,
3692 const wxMouseEvent
& event
)
3694 if ( event
.LeftDClick() || event
.LeftDown() || event
.RightDown() )
3696 wxTopLevelWindow
*tlw
=
3697 wxStaticCast(consumer
->GetInputWindow(), wxTopLevelWindow
);
3699 long hit
= tlw
->HitTest(event
.GetPosition());
3701 if ( event
.LeftDClick() && hit
== wxHT_TOPLEVEL_TITLEBAR
)
3703 tlw
->PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
,
3704 tlw
->IsMaximized() ? wxTOPLEVEL_BUTTON_RESTORE
3705 : wxTOPLEVEL_BUTTON_MAXIMIZE
);
3708 else if ( tlw
->GetWindowStyle() & wxSYSTEM_MENU
)
3710 if ( (event
.LeftDown() && hit
== wxHT_TOPLEVEL_ICON
) ||
3711 (event
.RightDown() &&
3712 (hit
== wxHT_TOPLEVEL_TITLEBAR
||
3713 hit
== wxHT_TOPLEVEL_ICON
)) )
3716 PopupSystemMenu(tlw
);
3717 #endif // wxUSE_MENUS
3723 return wxStdInputHandler::HandleMouse(consumer
, event
);
3728 void wxWin32FrameInputHandler::PopupSystemMenu(wxTopLevelWindow
*window
) const
3732 if ( window
->GetWindowStyle() & wxMAXIMIZE_BOX
)
3733 menu
.Append(wxID_RESTORE_FRAME
, _("&Restore"));
3734 menu
.Append(wxID_MOVE_FRAME
, _("&Move"));
3735 if ( window
->GetWindowStyle() & wxRESIZE_BORDER
)
3736 menu
.Append(wxID_RESIZE_FRAME
, _("&Size"));
3737 if ( wxSystemSettings::HasFeature(wxSYS_CAN_ICONIZE_FRAME
) )
3738 menu
.Append(wxID_ICONIZE_FRAME
, _("Mi&nimize"));
3739 if ( window
->GetWindowStyle() & wxMAXIMIZE_BOX
)
3740 menu
.Append(wxID_MAXIMIZE_FRAME
, _("Ma&ximize"));
3741 menu
.AppendSeparator();
3742 menu
.Append(wxID_CLOSE_FRAME
, _("Close\tAlt-F4"));
3744 if ( window
->GetWindowStyle() & wxMAXIMIZE_BOX
)
3746 if ( window
->IsMaximized() )
3748 menu
.Enable(wxID_MAXIMIZE_FRAME
, false);
3749 menu
.Enable(wxID_MOVE_FRAME
, false);
3750 if ( window
->GetWindowStyle() & wxRESIZE_BORDER
)
3751 menu
.Enable(wxID_RESIZE_FRAME
, false);
3754 menu
.Enable(wxID_RESTORE_FRAME
, false);
3757 window
->PopupMenu(&menu
, wxPoint(0, 0));
3760 #endif // wxUSE_MENUS
3762 bool wxWin32FrameInputHandler::HandleActivation(wxInputConsumer
*consumer
,
3765 if ( consumer
->GetInputWindow()->GetWindowStyle() & wxSYSTEM_MENU
)
3767 // always detach if active frame changed:
3768 m_menuHandler
->Detach();
3772 m_menuHandler
->Attach(consumer
);
3776 return wxStdInputHandler::HandleActivation(consumer
, activated
);
3779 #endif // wxUSE_THEME_WIN32