event.h
来自「A*算法 A*算法 A*算法 A*算法A*算法A*算法」· C头文件 代码 · 共 2,127 行 · 第 1/5 页
H
2,127 行
wxPoint GetLogicalPosition(const wxDC& dc) const;
// Get X position
wxCoord GetX() const { return m_x; }
// Get Y position
wxCoord GetY() const { return m_y; }
// Get wheel rotation, positive or negative indicates direction of
// rotation. Current devices all send an event when rotation is equal to
// +/-WheelDelta, but this allows for finer resolution devices to be
// created in the future. Because of this you shouldn't assume that one
// event is equal to 1 line or whatever, but you should be able to either
// do partial line scrolling or wait until +/-WheelDelta rotation values
// have been accumulated before scrolling.
int GetWheelRotation() const { return m_wheelRotation; }
// Get wheel delta, normally 120. This is the threshold for action to be
// taken, and one such action (for example, scrolling one increment)
// should occur for each delta.
int GetWheelDelta() const { return m_wheelDelta; }
// Returns the configured number of lines (or whatever) to be scrolled per
// wheel action. Defaults to one.
int GetLinesPerAction() const { return m_linesPerAction; }
// Is the system set to do page scrolling?
bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); }
virtual wxEvent *Clone() const { return new wxMouseEvent(*this); }
wxMouseEvent& operator=(const wxMouseEvent& event) { Assign(event); return *this; }
public:
wxCoord m_x, m_y;
bool m_leftDown;
bool m_middleDown;
bool m_rightDown;
bool m_controlDown;
bool m_shiftDown;
bool m_altDown;
bool m_metaDown;
int m_wheelRotation;
int m_wheelDelta;
int m_linesPerAction;
protected:
void Assign(const wxMouseEvent& evt);
private:
DECLARE_DYNAMIC_CLASS(wxMouseEvent)
};
// Cursor set event
/*
wxEVT_SET_CURSOR
*/
class WXDLLIMPEXP_CORE wxSetCursorEvent : public wxEvent
{
public:
wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0)
: wxEvent(0, wxEVT_SET_CURSOR),
m_x(x), m_y(y), m_cursor()
{ }
wxSetCursorEvent(const wxSetCursorEvent & event)
: wxEvent(event),
m_x(event.m_x),
m_y(event.m_y),
m_cursor(event.m_cursor)
{ }
wxCoord GetX() const { return m_x; }
wxCoord GetY() const { return m_y; }
void SetCursor(const wxCursor& cursor) { m_cursor = cursor; }
const wxCursor& GetCursor() const { return m_cursor; }
bool HasCursor() const { return m_cursor.Ok(); }
virtual wxEvent *Clone() const { return new wxSetCursorEvent(*this); }
private:
wxCoord m_x, m_y;
wxCursor m_cursor;
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSetCursorEvent)
};
// Keyboard input event class
/*
wxEVT_CHAR
wxEVT_CHAR_HOOK
wxEVT_KEY_DOWN
wxEVT_KEY_UP
wxEVT_HOTKEY
*/
class WXDLLIMPEXP_CORE wxKeyEvent : public wxEvent
{
public:
wxKeyEvent(wxEventType keyType = wxEVT_NULL);
wxKeyEvent(const wxKeyEvent& evt);
// Find state of shift/control keys
bool ControlDown() const { return m_controlDown; }
bool MetaDown() const { return m_metaDown; }
bool AltDown() const { return m_altDown; }
bool ShiftDown() const { return m_shiftDown; }
// "Cmd" is a pseudo key which is Control for PC and Unix platforms but
// Apple ("Command") key under Macs: it makes often sense to use it instead
// of, say, ControlDown() because Cmd key is used for the same thing under
// Mac as Ctrl elsewhere (but Ctrl still exists, just not used for this
// purpose under Mac)
bool CmdDown() const
{
#if defined(__WXMAC__) || defined(__WXCOCOA__)
return MetaDown();
#else
return ControlDown();
#endif
}
// exclude MetaDown() from HasModifiers() because NumLock under X is often
// configured as mod2 modifier, yet the key events even when it is pressed
// should be processed normally, not like Ctrl- or Alt-key
bool HasModifiers() const { return ControlDown() || AltDown(); }
// get the key code: an ASCII7 char or an element of wxKeyCode enum
int GetKeyCode() const { return (int)m_keyCode; }
#if wxUSE_UNICODE
// get the Unicode character corresponding to this key
wxChar GetUnicodeKey() const { return m_uniChar; }
#endif // wxUSE_UNICODE
// get the raw key code (platform-dependent)
wxUint32 GetRawKeyCode() const { return m_rawCode; }
// get the raw key flags (platform-dependent)
wxUint32 GetRawKeyFlags() const { return m_rawFlags; }
// Find the position of the event
void GetPosition(wxCoord *xpos, wxCoord *ypos) const
{
if (xpos) *xpos = m_x;
if (ypos) *ypos = m_y;
}
void GetPosition(long *xpos, long *ypos) const
{
if (xpos) *xpos = (long)m_x;
if (ypos) *ypos = (long)m_y;
}
wxPoint GetPosition() const
{ return wxPoint(m_x, m_y); }
// Get X position
wxCoord GetX() const { return m_x; }
// Get Y position
wxCoord GetY() const { return m_y; }
// deprecated, Use GetKeyCode instead.
wxDEPRECATED( long KeyCode() const );
virtual wxEvent *Clone() const { return new wxKeyEvent(*this); }
// we do need to copy wxKeyEvent sometimes (in wxTreeCtrl code, for
// example)
wxKeyEvent& operator=(const wxKeyEvent& evt)
{
m_x = evt.m_x;
m_y = evt.m_y;
m_keyCode = evt.m_keyCode;
m_controlDown = evt.m_controlDown;
m_shiftDown = evt.m_shiftDown;
m_altDown = evt.m_altDown;
m_metaDown = evt.m_metaDown;
m_scanCode = evt.m_scanCode;
m_rawCode = evt.m_rawCode;
m_rawFlags = evt.m_rawFlags;
#if wxUSE_UNICODE
m_uniChar = evt.m_uniChar;
#endif
return *this;
}
public:
wxCoord m_x, m_y;
long m_keyCode;
bool m_controlDown;
bool m_shiftDown;
bool m_altDown;
bool m_metaDown;
bool m_scanCode;
#if wxUSE_UNICODE
// This contains the full Unicode character
// in a character events in Unicode mode
wxChar m_uniChar;
#endif
// these fields contain the platform-specific information about
// key that was pressed
wxUint32 m_rawCode;
wxUint32 m_rawFlags;
private:
DECLARE_DYNAMIC_CLASS(wxKeyEvent)
};
// Size event class
/*
wxEVT_SIZE
*/
class WXDLLIMPEXP_CORE wxSizeEvent : public wxEvent
{
public:
wxSizeEvent() : wxEvent(0, wxEVT_SIZE)
{ }
wxSizeEvent(const wxSize& sz, int winid = 0)
: wxEvent(winid, wxEVT_SIZE),
m_size(sz)
{ }
wxSizeEvent(const wxSizeEvent & event)
: wxEvent(event),
m_size(event.m_size), m_rect(event.m_rect)
{ }
wxSizeEvent(const wxRect& rect, int id = 0)
: m_size(rect.GetSize()), m_rect(rect)
{ m_eventType = wxEVT_SIZING; m_id = id; }
wxSize GetSize() const { return m_size; }
wxRect GetRect() const { return m_rect; }
void SetRect(wxRect rect) { m_rect = rect; }
virtual wxEvent *Clone() const { return new wxSizeEvent(*this); }
public:
// For internal usage only. Will be converted to protected members.
wxSize m_size;
wxRect m_rect; // Used for wxEVT_SIZING
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSizeEvent)
};
// Move event class
/*
wxEVT_MOVE
*/
class WXDLLIMPEXP_CORE wxMoveEvent : public wxEvent
{
public:
wxMoveEvent()
: wxEvent(0, wxEVT_MOVE)
{ }
wxMoveEvent(const wxPoint& pos, int winid = 0)
: wxEvent(winid, wxEVT_MOVE),
m_pos(pos)
{ }
wxMoveEvent(const wxMoveEvent& event)
: wxEvent(event),
m_pos(event.m_pos)
{ }
wxMoveEvent(const wxRect& rect, int id = 0)
: m_pos(rect.GetPosition()), m_rect(rect)
{ m_eventType = wxEVT_MOVING; m_id = id; }
wxPoint GetPosition() const { return m_pos; }
void SetPosition(const wxPoint& pos) { m_pos = pos; }
wxRect GetRect() const { return m_rect; }
void SetRect(wxRect rect) { m_rect = rect; }
virtual wxEvent *Clone() const { return new wxMoveEvent(*this); }
#if WXWIN_COMPATIBILITY_2_4
public:
#else
protected:
#endif
wxPoint m_pos;
wxRect m_rect;
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMoveEvent)
};
// Paint event class
/*
wxEVT_PAINT
wxEVT_NC_PAINT
wxEVT_PAINT_ICON
*/
#if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__))
// see comments in src/msw|os2/dcclient.cpp where g_isPainting is defined
extern WXDLLIMPEXP_CORE int g_isPainting;
#endif // debug
class WXDLLIMPEXP_CORE wxPaintEvent : public wxEvent
{
public:
wxPaintEvent(int Id = 0)
: wxEvent(Id, wxEVT_PAINT)
{
#if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__))
// set the internal flag for the duration of processing of WM_PAINT
g_isPainting++;
#endif // debug
}
// default copy ctor and dtor are normally fine, we only need them to keep
// g_isPainting updated in debug build
#if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__))
wxPaintEvent(const wxPaintEvent& event)
: wxEvent(event)
{
g_isPainting++;
}
~wxPaintEvent()
{
g_isPainting--;
}
#endif // debug
virtual wxEvent *Clone() const { return new wxPaintEvent(*this); }
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaintEvent)
};
class WXDLLIMPEXP_CORE wxNcPaintEvent : public wxEvent
{
public:
wxNcPaintEvent(int winid = 0)
: wxEvent(winid, wxEVT_NC_PAINT)
{ }
virtual wxEvent *Clone() const { return new wxNcPaintEvent(*this); }
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNcPaintEvent)
};
// Erase background event class
/*
wxEVT_ERASE_BACKGROUND
*/
class WXDLLIMPEXP_CORE wxEraseEvent : public wxEvent
{
public:
wxEraseEvent(int Id = 0, wxDC *dc = (wxDC *) NULL)
: wxEvent(Id, wxEVT_ERASE_BACKGROUND),
m_dc(dc)
{ }
wxEraseEvent(const wxEraseEvent& event)
: wxEvent(event),
m_dc(event.m_dc)
{ }
wxDC *GetDC() const { return m_dc; }
virtual wxEvent *Clone() const { return new wxEraseEvent(*this); }
#if WXWIN_COMPATIBILITY_2_4
public:
#else
protected:
#endif
wxDC *m_dc;
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxEraseEvent)
};
// Focus event class
/*
wxEVT_SET_FOCUS
wxEVT_KILL_FOCUS
*/
class WXDLLIMPEXP_CORE wxFocusEvent : public wxEvent
{
public:
wxFocusEvent(wxEventType type = wxEVT_NULL, int winid = 0)
: wxEvent(winid, type)
{ m_win = NULL; }
wxFocusEvent(const wxFocusEvent& event)
: wxEvent(event)
{ m_win = event.m_win; }
// The window associated with this event is the window which had focus
// before for SET event and the window which will have focus for the KILL
// one. NB: it may be NULL in both cases!
wxWindow *GetWindow() const { return m_win; }
void SetWindow(wxWindow *win) { m_win = win; }
virtual wxEvent *Clone() const { return new wxFocusEvent(*this); }
private:
wxWindow *m_win;
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFocusEvent)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?