test that static text and box get the click events
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15458 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -41,7 +41,6 @@
|
|||||||
#include "wx/statline.h"
|
#include "wx/statline.h"
|
||||||
|
|
||||||
#include "widgets.h"
|
#include "widgets.h"
|
||||||
#if 1
|
|
||||||
#include "icons/statbox.xpm"
|
#include "icons/statbox.xpm"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -73,25 +72,63 @@ enum
|
|||||||
StaticVAlign_Max
|
StaticVAlign_Max
|
||||||
};
|
};
|
||||||
|
|
||||||
class DerivedStaticText: public wxStaticText
|
// ----------------------------------------------------------------------------
|
||||||
|
// MyStaticText and MyStaticBox
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// these 2 classes simply show that the static controls can get the mouse
|
||||||
|
// clicks too -- this used to be broken under MSW but works now
|
||||||
|
|
||||||
|
class MyStaticText : public wxStaticText
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DerivedStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
|
MyStaticText(wxWindow* parent,
|
||||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
wxWindowID id,
|
||||||
long style = 0):
|
const wxString& label,
|
||||||
wxStaticText(parent, id, label, pos, size, style)
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = 0)
|
||||||
|
: wxStaticText(parent, id, label, pos, size, style)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
void OnMouseEvent(wxMouseEvent& event)
|
void OnMouseEvent(wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
if (event.LeftDown())
|
wxLogMessage(wxT("Clicked on static text"));
|
||||||
wxMessageBox(wxT("Clicked on static text"));
|
|
||||||
}
|
}
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(DerivedStaticText, wxStaticText)
|
class MyStaticBox : public wxStaticBox
|
||||||
EVT_MOUSE_EVENTS(DerivedStaticText::OnMouseEvent)
|
{
|
||||||
|
public:
|
||||||
|
MyStaticBox(wxWindow* parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = 0)
|
||||||
|
: wxStaticBox(parent, id, label, pos, size, style)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void OnMouseEvent(wxMouseEvent& event)
|
||||||
|
{
|
||||||
|
wxLogMessage(wxT("Clicked on static box"));
|
||||||
|
}
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(MyStaticText, wxStaticText)
|
||||||
|
EVT_LEFT_UP(MyStaticText::OnMouseEvent)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(MyStaticBox, wxStaticBox)
|
||||||
|
EVT_LEFT_UP(MyStaticBox::OnMouseEvent)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -339,13 +376,13 @@ void StaticWidgetsPage::CreateStatic()
|
|||||||
flagsText |= align;
|
flagsText |= align;
|
||||||
flagsBox |= align;
|
flagsBox |= align;
|
||||||
|
|
||||||
wxStaticBox *box = new wxStaticBox(this, -1, m_textBox->GetValue(),
|
wxStaticBox *box = new MyStaticBox(this, -1, m_textBox->GetValue(),
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
flagsBox);
|
flagsBox);
|
||||||
m_sizerStatBox = new wxStaticBoxSizer(box, isVert ? wxHORIZONTAL
|
m_sizerStatBox = new wxStaticBoxSizer(box, isVert ? wxHORIZONTAL
|
||||||
: wxVERTICAL);
|
: wxVERTICAL);
|
||||||
|
|
||||||
m_statText = new DerivedStaticText(this, -1, m_textLabel->GetValue(),
|
m_statText = new MyStaticText(this, -1, m_textLabel->GetValue(),
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
flagsText);
|
flagsText);
|
||||||
|
|
||||||
@@ -388,4 +425,3 @@ void StaticWidgetsPage::OnButtonLabelText(wxCommandEvent& event)
|
|||||||
m_statText->SetLabel(m_textLabel->GetValue());
|
m_statText->SetLabel(m_textLabel->GetValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
Reference in New Issue
Block a user