📄 win32.cpp
字号:
const wxPoint& focusOffset
= wxPoint(FOCUS_RECT_OFFSET_X, FOCUS_RECT_OFFSET_Y));
// common part of DrawLabel() and DrawItem()
void DrawFocusRect(wxDC& dc, const wxRect& rect);
// DrawLabel() and DrawButtonLabel() helper
void DrawLabelShadow(wxDC& dc,
const wxString& label,
const wxRect& rect,
int alignment,
int indexAccel);
// DrawButtonBorder() helper
void DoDrawBackground(wxDC& dc,
const wxColour& col,
const wxRect& rect,
wxWindow *window = NULL );
// DrawBorder() helpers: all of them shift and clip the DC after drawing
// the border
// just draw a rectangle with the given pen
void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen);
// draw the lower left part of rectangle
void DrawHalfRect(wxDC& dc, wxRect *rect, const wxPen& pen);
// draw the rectange using the first brush for the left and top sides and
// the second one for the bottom and right ones
void DrawShadedRect(wxDC& dc, wxRect *rect,
const wxPen& pen1, const wxPen& pen2);
// draw the normal 3D border
void DrawRaisedBorder(wxDC& dc, wxRect *rect);
// draw the sunken 3D border
void DrawSunkenBorder(wxDC& dc, wxRect *rect);
// draw the border used for scrollbar arrows
void DrawArrowBorder(wxDC& dc, wxRect *rect, bool isPressed = false);
// public DrawArrow()s helper
void DrawArrow(wxDC& dc, const wxRect& rect,
wxArrowDirection arrowDir, wxArrowStyle arrowStyle);
// DrawArrowButton is used by DrawScrollbar and DrawComboButton
void DrawArrowButton(wxDC& dc, const wxRect& rect,
wxArrowDirection arrowDir,
wxArrowStyle arrowStyle);
// DrawCheckButton/DrawRadioButton helper
void DrawCheckOrRadioButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
const wxRect& rect,
int flags,
wxAlignment align,
int indexAccel,
wxCoord focusOffsetY);
// draw a normal or transposed line (useful for using the same code fo both
// horizontal and vertical widgets)
void DrawLine(wxDC& dc,
wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
bool transpose = false)
{
if ( transpose )
dc.DrawLine(y1, x1, y2, x2);
else
dc.DrawLine(x1, y1, x2, y2);
}
// get the standard check/radio button bitmap
wxBitmap GetIndicator(IndicatorType indType, int flags);
wxBitmap GetCheckBitmap(int flags)
{ return GetIndicator(IndicatorType_Check, flags); }
wxBitmap GetRadioBitmap(int flags)
{ return GetIndicator(IndicatorType_Radio, flags); }
private:
const wxColourScheme *m_scheme;
// the sizing parameters (TODO make them changeable)
wxSize m_sizeScrollbarArrow;
// GDI objects we use for drawing
wxColour m_colDarkGrey,
m_colHighlight;
wxPen m_penBlack,
m_penDarkGrey,
m_penLightGrey,
m_penHighlight;
wxFont m_titlebarFont;
// the checked and unchecked bitmaps for DrawCheckItem()
wxBitmap m_bmpCheckBitmaps[IndicatorStatus_Max];
// the bitmaps returned by GetIndicator()
wxBitmap m_bmpIndicators[IndicatorType_Max]
[IndicatorState_Max]
[IndicatorStatus_Max];
// titlebar icons:
wxBitmap m_bmpFrameButtons[FrameButton_Max];
// first row is for the normal state, second - for the disabled
wxBitmap m_bmpArrows[Arrow_StateMax][Arrow_Max];
};
// ----------------------------------------------------------------------------
// wxWin32InputHandler and derived classes: process the keyboard and mouse
// messages according to Windows standards
// ----------------------------------------------------------------------------
class wxWin32InputHandler : public wxInputHandler
{
public:
wxWin32InputHandler(wxWin32Renderer *renderer);
virtual bool HandleKey(wxInputConsumer *control,
const wxKeyEvent& event,
bool pressed);
virtual bool HandleMouse(wxInputConsumer *control,
const wxMouseEvent& event);
protected:
wxWin32Renderer *m_renderer;
};
#if wxUSE_SCROLLBAR
class wxWin32ScrollBarInputHandler : public wxStdScrollBarInputHandler
{
public:
wxWin32ScrollBarInputHandler(wxWin32Renderer *renderer,
wxInputHandler *handler);
virtual bool HandleMouse(wxInputConsumer *control, const wxMouseEvent& event);
virtual bool HandleMouseMove(wxInputConsumer *control, const wxMouseEvent& event);
virtual bool OnScrollTimer(wxScrollBar *scrollbar,
const wxControlAction& action);
protected:
virtual bool IsAllowedButton(int button) { return button == 1; }
virtual void Highlight(wxScrollBar * WXUNUSED(scrollbar),
bool WXUNUSED(doIt))
{
// we don't highlight anything
}
// the first and last event which caused the thumb to move
wxMouseEvent m_eventStartDrag,
m_eventLastDrag;
// have we paused the scrolling because the mouse moved?
bool m_scrollPaused;
// we remember the interval of the timer to be able to restart it
int m_interval;
};
#endif // wxUSE_SCROLLBAR
#if wxUSE_CHECKBOX
class wxWin32CheckboxInputHandler : public wxStdCheckboxInputHandler
{
public:
wxWin32CheckboxInputHandler(wxInputHandler *handler)
: wxStdCheckboxInputHandler(handler) { }
virtual bool HandleKey(wxInputConsumer *control,
const wxKeyEvent& event,
bool pressed);
};
#endif // wxUSE_CHECKBOX
#if wxUSE_TEXTCTRL
class wxWin32TextCtrlInputHandler : public wxStdTextCtrlInputHandler
{
public:
wxWin32TextCtrlInputHandler(wxInputHandler *handler)
: wxStdTextCtrlInputHandler(handler) { }
virtual bool HandleKey(wxInputConsumer *control,
const wxKeyEvent& event,
bool pressed);
};
#endif // wxUSE_TEXTCTRL
class wxWin32StatusBarInputHandler : public wxStdInputHandler
{
public:
wxWin32StatusBarInputHandler(wxInputHandler *handler);
virtual bool HandleMouse(wxInputConsumer *consumer,
const wxMouseEvent& event);
virtual bool HandleMouseMove(wxInputConsumer *consumer,
const wxMouseEvent& event);
protected:
// is the given point over the statusbar grip?
bool IsOnGrip(wxWindow *statbar, const wxPoint& pt) const;
private:
// the cursor we had replaced with the resize one
wxCursor m_cursorOld;
// was the mouse over the grip last time we checked?
bool m_isOnGrip;
};
class wxWin32SystemMenuEvtHandler;
class wxWin32FrameInputHandler : public wxStdFrameInputHandler
{
public:
wxWin32FrameInputHandler(wxInputHandler *handler);
~wxWin32FrameInputHandler();
virtual bool HandleMouse(wxInputConsumer *control,
const wxMouseEvent& event);
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
#if wxUSE_MENUS
void PopupSystemMenu(wxTopLevelWindow *window, const wxPoint& pos) const;
#endif // wxUSE_MENUS
private:
// was the mouse over the grip last time we checked?
wxWin32SystemMenuEvtHandler *m_menuHandler;
};
// ----------------------------------------------------------------------------
// wxWin32ColourScheme: uses (default) Win32 colours
// ----------------------------------------------------------------------------
class wxWin32ColourScheme : public wxColourScheme
{
public:
virtual wxColour Get(StdColour col) const;
virtual wxColour GetBackground(wxWindow *win) const;
};
// ----------------------------------------------------------------------------
// wxWin32ArtProvider
// ----------------------------------------------------------------------------
class wxWin32ArtProvider : public wxArtProvider
{
protected:
virtual wxBitmap CreateBitmap(const wxArtID& id,
const wxArtClient& client,
const wxSize& size);
};
// ----------------------------------------------------------------------------
// wxWin32Theme
// ----------------------------------------------------------------------------
WX_DEFINE_ARRAY_PTR(wxInputHandler *, wxArrayHandlers);
class wxWin32Theme : public wxTheme
{
public:
wxWin32Theme();
virtual ~wxWin32Theme();
virtual wxRenderer *GetRenderer();
virtual wxArtProvider *GetArtProvider();
virtual wxInputHandler *GetInputHandler(const wxString& control);
virtual wxColourScheme *GetColourScheme();
private:
// get the default input handler
wxInputHandler *GetDefaultInputHandler();
wxWin32Renderer *m_renderer;
wxWin32ArtProvider *m_artProvider;
// the names of the already created handlers and the handlers themselves
// (these arrays are synchronized)
wxSortedArrayString m_handlerNames;
wxArrayHandlers m_handlers;
wxWin32InputHandler *m_handlerDefault;
wxWin32ColourScheme *m_scheme;
WX_DECLARE_THEME(win32)
};
// ----------------------------------------------------------------------------
// standard bitmaps
// ----------------------------------------------------------------------------
// frame buttons bitmaps
static const char *frame_button_close_xpm[] = {
"12 10 2 1",
" c None",
". c black",
" ",
" .. .. ",
" .. .. ",
" .... ",
" .. ",
" .... ",
" .. .. ",
" .. .. ",
" ",
" "};
static const char *frame_button_help_xpm[] = {
"12 10 2 1",
" c None",
". c #000000",
" .... ",
" .. .. ",
" .. .. ",
" .. ",
" .. ",
" .. ",
" ",
" .. ",
" .. ",
" "};
static const char *frame_button_maximize_xpm[] = {
"12 10 2 1",
" c None",
". c #000000",
" ......... ",
" ......... ",
" . . ",
" . . ",
" . . ",
" . . ",
" . . ",
" . . ",
" ......... ",
" "};
static const char *frame_button_minimize_xpm[] = {
"12 10 2 1",
" c None",
". c #000000",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ...... ",
" ...... ",
" "};
static const char *frame_button_restore_xpm[] = {
"12 10 2 1",
" c None",
". c #000000",
" ...... ",
" ...... ",
" . . ",
" ...... . ",
" ...... . ",
" . ... ",
" . . ",
" . . ",
" ...... ",
" "};
// menu bitmaps
static const char *checked_menu_xpm[] = {
/* columns rows colors chars-per-pixel */
"9 9 2 1",
"w c None",
"b c black",
/* pixels */
"wwwwwwwww",
"wwwwwwwbw",
"wwwwwwbbw",
"wbwwwbbbw",
"wbbwbbbww",
"wbbbbbwww",
"wwbbbwwww",
"wwwbwwwww",
"wwwwwwwww"
};
static const char *selected_checked_menu_xpm[] = {
/* columns rows colors chars-per-pixel */
"9 9 2 1",
"w c None",
"b c white",
/* pixels */
"wwwwwwwww",
"wwwwwwwbw",
"wwwwwwbbw",
"wbwwwbbbw",
"wbbwbbbww",
"wbbbbbwww",
"wwbbbwwww",
"wwwbwwwww",
"wwwwwwwww"
};
static const char *disabled_checked_menu_xpm[] = {
/* columns rows colors chars-per-pixel */
"9 9 3 1",
"w c None",
"b c #7f7f7f",
"W c #e0e0e0",
/* pixels */
"wwwwwwwww",
"wwwwwwwbw",
"wwwwwwbbW",
"wbwwwbbbW",
"wbbwbbbWW",
"wbbbbbWWw",
"wwbbbWWww",
"wwwbWWwww",
"wwwwWwwww"
};
static const char *selected_disabled_checked_menu_xpm[] = {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -