event.h
来自「A*算法 A*算法 A*算法 A*算法A*算法A*算法」· C头文件 代码 · 共 2,127 行 · 第 1/5 页
H
2,127 行
DECLARE_ABSTRACT_CLASS(wxEvent)
};
/*
* Helper class to temporarily change an event not to propagate.
*/
class WXDLLIMPEXP_BASE wxPropagationDisabler
{
public:
wxPropagationDisabler(wxEvent& event) : m_event(event)
{
m_propagationLevelOld = m_event.StopPropagation();
}
~wxPropagationDisabler()
{
m_event.ResumePropagation(m_propagationLevelOld);
}
private:
wxEvent& m_event;
int m_propagationLevelOld;
DECLARE_NO_COPY_CLASS(wxPropagationDisabler)
};
/*
* Another one to temporarily lower propagation level.
*/
class WXDLLIMPEXP_BASE wxPropagateOnce
{
public:
wxPropagateOnce(wxEvent& event) : m_event(event)
{
wxASSERT_MSG( m_event.m_propagationLevel > 0,
_T("shouldn't be used unless ShouldPropagate()!") );
m_event.m_propagationLevel--;
}
~wxPropagateOnce()
{
m_event.m_propagationLevel++;
}
private:
wxEvent& m_event;
DECLARE_NO_COPY_CLASS(wxPropagateOnce)
};
#if wxUSE_GUI
// Item or menu event class
/*
wxEVT_COMMAND_BUTTON_CLICKED
wxEVT_COMMAND_CHECKBOX_CLICKED
wxEVT_COMMAND_CHOICE_SELECTED
wxEVT_COMMAND_LISTBOX_SELECTED
wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
wxEVT_COMMAND_TEXT_UPDATED
wxEVT_COMMAND_TEXT_ENTER
wxEVT_COMMAND_MENU_SELECTED
wxEVT_COMMAND_SLIDER_UPDATED
wxEVT_COMMAND_RADIOBOX_SELECTED
wxEVT_COMMAND_RADIOBUTTON_SELECTED
wxEVT_COMMAND_SCROLLBAR_UPDATED
wxEVT_COMMAND_VLBOX_SELECTED
wxEVT_COMMAND_COMBOBOX_SELECTED
wxEVT_COMMAND_TOGGLEBUTTON_CLICKED
*/
#if WXWIN_COMPATIBILITY_2_4
// Backwards compatibility for wxCommandEvent::m_commandString, will lead to compilation errors in some cases of usage
class WXDLLIMPEXP_CORE wxCommandEvent;
class WXDLLIMPEXP_CORE wxCommandEventStringHelper
{
public:
wxCommandEventStringHelper(wxCommandEvent * evt)
: m_evt(evt)
{ }
void operator=(const wxString &str);
operator wxString();
const wxChar* c_str() const;
private:
wxCommandEvent* m_evt;
};
#endif
#ifdef __VISUALC__
// 'this' : used in base member initializer list (for m_commandString)
#if _MSC_VER > 1100
#pragma warning(push)
#endif
#pragma warning(disable:4355)
#endif
class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent
{
public:
wxCommandEvent(wxEventType commandType = wxEVT_NULL, int winid = 0);
wxCommandEvent(const wxCommandEvent& event)
: wxEvent(event),
#if WXWIN_COMPATIBILITY_2_4
m_commandString(this),
#endif
m_cmdString(event.m_cmdString),
m_commandInt(event.m_commandInt),
m_extraLong(event.m_extraLong),
m_clientData(event.m_clientData),
m_clientObject(event.m_clientObject)
{ }
// Set/Get client data from controls
void SetClientData(void* clientData) { m_clientData = clientData; }
void *GetClientData() const { return m_clientData; }
// Set/Get client object from controls
void SetClientObject(wxClientData* clientObject) { m_clientObject = clientObject; }
wxClientData *GetClientObject() const { return m_clientObject; }
// Get listbox selection if single-choice
int GetSelection() const { return m_commandInt; }
// Set/Get listbox/choice selection string
void SetString(const wxString& s) { m_cmdString = s; }
wxString GetString() const;
// Get checkbox value
bool IsChecked() const { return m_commandInt != 0; }
// true if the listbox event was a selection.
bool IsSelection() const { return (m_extraLong != 0); }
void SetExtraLong(long extraLong) { m_extraLong = extraLong; }
long GetExtraLong() const { return m_extraLong; }
void SetInt(int i) { m_commandInt = i; }
long GetInt() const { return m_commandInt; }
virtual wxEvent *Clone() const { return new wxCommandEvent(*this); }
#if WXWIN_COMPATIBILITY_2_4
public:
wxCommandEventStringHelper m_commandString;
#else
protected:
#endif
wxString m_cmdString; // String event argument
int m_commandInt;
long m_extraLong; // Additional information (e.g. select/deselect)
void* m_clientData; // Arbitrary client data
wxClientData* m_clientObject; // Arbitrary client object
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent)
};
#if defined(__VISUALC__) && (_MSC_VER > 1100)
#pragma warning(pop)
#endif
#if WXWIN_COMPATIBILITY_2_4
inline void wxCommandEventStringHelper::operator=(const wxString &str)
{
m_evt->SetString(str);
}
inline wxCommandEventStringHelper::operator wxString()
{
return m_evt->GetString();
}
inline const wxChar* wxCommandEventStringHelper::c_str() const
{
return m_evt->GetString().c_str();
}
#endif
// this class adds a possibility to react (from the user) code to a control
// notification: allow or veto the operation being reported.
class WXDLLIMPEXP_CORE wxNotifyEvent : public wxCommandEvent
{
public:
wxNotifyEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
: wxCommandEvent(commandType, winid)
{ m_bAllow = true; }
wxNotifyEvent(const wxNotifyEvent& event)
: wxCommandEvent(event)
{ m_bAllow = event.m_bAllow; }
// veto the operation (usually it's allowed by default)
void Veto() { m_bAllow = false; }
// allow the operation if it was disabled by default
void Allow() { m_bAllow = true; }
// for implementation code only: is the operation allowed?
bool IsAllowed() const { return m_bAllow; }
virtual wxEvent *Clone() const { return new wxNotifyEvent(*this); }
private:
bool m_bAllow;
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNotifyEvent)
};
// Scroll event class, derived form wxCommandEvent. wxScrollEvents are
// sent by wxSlider and wxScrollBar.
/*
wxEVT_SCROLL_TOP
wxEVT_SCROLL_BOTTOM
wxEVT_SCROLL_LINEUP
wxEVT_SCROLL_LINEDOWN
wxEVT_SCROLL_PAGEUP
wxEVT_SCROLL_PAGEDOWN
wxEVT_SCROLL_THUMBTRACK
wxEVT_SCROLL_THUMBRELEASE
wxEVT_SCROLL_CHANGED
*/
class WXDLLIMPEXP_CORE wxScrollEvent : public wxCommandEvent
{
public:
wxScrollEvent(wxEventType commandType = wxEVT_NULL,
int winid = 0, int pos = 0, int orient = 0);
int GetOrientation() const { return (int) m_extraLong; }
int GetPosition() const { return m_commandInt; }
void SetOrientation(int orient) { m_extraLong = (long) orient; }
void SetPosition(int pos) { m_commandInt = pos; }
virtual wxEvent *Clone() const { return new wxScrollEvent(*this); }
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollEvent)
};
// ScrollWin event class, derived fom wxEvent. wxScrollWinEvents
// are sent by wxWindow.
/*
wxEVT_SCROLLWIN_TOP
wxEVT_SCROLLWIN_BOTTOM
wxEVT_SCROLLWIN_LINEUP
wxEVT_SCROLLWIN_LINEDOWN
wxEVT_SCROLLWIN_PAGEUP
wxEVT_SCROLLWIN_PAGEDOWN
wxEVT_SCROLLWIN_THUMBTRACK
wxEVT_SCROLLWIN_THUMBRELEASE
*/
class WXDLLIMPEXP_CORE wxScrollWinEvent : public wxEvent
{
public:
wxScrollWinEvent(wxEventType commandType = wxEVT_NULL,
int pos = 0, int orient = 0);
wxScrollWinEvent(const wxScrollWinEvent & event) : wxEvent(event)
{ m_commandInt = event.m_commandInt;
m_extraLong = event.m_extraLong; }
int GetOrientation() const { return (int) m_extraLong; }
int GetPosition() const { return m_commandInt; }
void SetOrientation(int orient) { m_extraLong = (long) orient; }
void SetPosition(int pos) { m_commandInt = pos; }
virtual wxEvent *Clone() const { return new wxScrollWinEvent(*this); }
#if WXWIN_COMPATIBILITY_2_4
public:
#else
protected:
#endif
int m_commandInt;
long m_extraLong;
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollWinEvent)
};
// Mouse event class
/*
wxEVT_LEFT_DOWN
wxEVT_LEFT_UP
wxEVT_MIDDLE_DOWN
wxEVT_MIDDLE_UP
wxEVT_RIGHT_DOWN
wxEVT_RIGHT_UP
wxEVT_MOTION
wxEVT_ENTER_WINDOW
wxEVT_LEAVE_WINDOW
wxEVT_LEFT_DCLICK
wxEVT_MIDDLE_DCLICK
wxEVT_RIGHT_DCLICK
wxEVT_NC_LEFT_DOWN
wxEVT_NC_LEFT_UP,
wxEVT_NC_MIDDLE_DOWN,
wxEVT_NC_MIDDLE_UP,
wxEVT_NC_RIGHT_DOWN,
wxEVT_NC_RIGHT_UP,
wxEVT_NC_MOTION,
wxEVT_NC_ENTER_WINDOW,
wxEVT_NC_LEAVE_WINDOW,
wxEVT_NC_LEFT_DCLICK,
wxEVT_NC_MIDDLE_DCLICK,
wxEVT_NC_RIGHT_DCLICK,
*/
// the symbolic names for the mouse buttons
enum
{
wxMOUSE_BTN_ANY = -1,
wxMOUSE_BTN_NONE = 0,
wxMOUSE_BTN_LEFT = 1,
wxMOUSE_BTN_MIDDLE = 2,
wxMOUSE_BTN_RIGHT = 3
};
class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent
{
public:
wxMouseEvent(wxEventType mouseType = wxEVT_NULL);
wxMouseEvent(const wxMouseEvent& event) : wxEvent(event)
{ Assign(event); }
// Was it a button event? (*doesn't* mean: is any button *down*?)
bool IsButton() const { return Button(wxMOUSE_BTN_ANY); }
// Was it a down event from this (or any) button?
bool ButtonDown(int but = wxMOUSE_BTN_ANY) const;
// Was it a dclick event from this (or any) button?
bool ButtonDClick(int but = wxMOUSE_BTN_ANY) const;
// Was it a up event from this (or any) button?
bool ButtonUp(int but = wxMOUSE_BTN_ANY) const;
// Was the given button?
bool Button(int but) const;
// Was the given button in Down state?
bool ButtonIsDown(int but) const;
// Get the button which is changing state (wxMOUSE_BTN_NONE if none)
int GetButton() const;
// 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; }
bool CmdDown() const
{
#if defined(__WXMAC__) || defined(__WXCOCOA__)
return MetaDown();
#else
return ControlDown();
#endif
}
// Find which event was just generated
bool LeftDown() const { return (m_eventType == wxEVT_LEFT_DOWN); }
bool MiddleDown() const { return (m_eventType == wxEVT_MIDDLE_DOWN); }
bool RightDown() const { return (m_eventType == wxEVT_RIGHT_DOWN); }
bool LeftUp() const { return (m_eventType == wxEVT_LEFT_UP); }
bool MiddleUp() const { return (m_eventType == wxEVT_MIDDLE_UP); }
bool RightUp() const { return (m_eventType == wxEVT_RIGHT_UP); }
bool LeftDClick() const { return (m_eventType == wxEVT_LEFT_DCLICK); }
bool MiddleDClick() const { return (m_eventType == wxEVT_MIDDLE_DCLICK); }
bool RightDClick() const { return (m_eventType == wxEVT_RIGHT_DCLICK); }
// Find the current state of the mouse buttons (regardless
// of current event type)
bool LeftIsDown() const { return m_leftDown; }
bool MiddleIsDown() const { return m_middleDown; }
bool RightIsDown() const { return m_rightDown; }
// True if a button is down and the mouse is moving
bool Dragging() const
{
return (m_eventType == wxEVT_MOTION) && ButtonIsDown(wxMOUSE_BTN_ANY);
}
// True if the mouse is moving, and no button is down
bool Moving() const
{
return (m_eventType == wxEVT_MOTION) && !ButtonIsDown(wxMOUSE_BTN_ANY);
}
// True if the mouse is just entering the window
bool Entering() const { return (m_eventType == wxEVT_ENTER_WINDOW); }
// True if the mouse is just leaving the window
bool Leaving() const { return (m_eventType == wxEVT_LEAVE_WINDOW); }
// 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;
}
// Find the position of the event
wxPoint GetPosition() const { return wxPoint(m_x, m_y); }
// Find the logical position of the event given the DC
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?