X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/92c01615ecb4afeb325e5148554b443fed830534..7862af84e5ceea5a1ddd4fcb55d53f707bc55d68:/samples/popup/popup.cpp diff --git a/samples/popup/popup.cpp b/samples/popup/popup.cpp index 8a3bcf268c..547a1bf1a0 100644 --- a/samples/popup/popup.cpp +++ b/samples/popup/popup.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: minimal.cpp +// Name: popup.cpp // Purpose: Popup wxWidgets sample // Author: Robert Roebling // Modified by: @@ -116,7 +116,7 @@ SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent ) m_panel = new wxScrolledWindow( this, wxID_ANY ); m_panel->SetBackgroundColour( *wxLIGHT_GREY ); - // Keep this code to verify if mouse events work, they're required if + // Keep this code to verify if mouse events work, they're required if // you're making a control like a combobox where the items are highlighted // under the cursor, the m_panel is set focus in the Popup() function m_panel->Connect(wxEVT_MOTION, @@ -124,8 +124,8 @@ SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent ) NULL, this); wxStaticText *text = new wxStaticText( m_panel, wxID_ANY, - wxT("wx.PopupTransientWindow is a\n") - wxT("wx.PopupWindow which disappears\n") + wxT("wxPopupTransientWindow is a\n") + wxT("wxPopupWindow which disappears\n") wxT("automatically when the user\n") wxT("clicks the mouse outside it or if it\n") wxT("(or its first child) loses focus in \n") @@ -133,7 +133,7 @@ SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent ) m_button = new wxButton(m_panel, Minimal_PopupButton, wxT("Press Me")); m_spinCtrl = new wxSpinCtrl(m_panel, Minimal_PopupSpinctrl, wxT("Hello")); - m_mouseText = new wxStaticText(m_panel, wxID_ANY, + m_mouseText = new wxStaticText(m_panel, wxID_ANY, wxT("<- Test Mouse ->")); wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); @@ -151,10 +151,10 @@ SimpleTransientPopup::~SimpleTransientPopup() { } -void SimpleTransientPopup::Popup(wxWindow *focus) +void SimpleTransientPopup::Popup(wxWindow* WXUNUSED(focus)) { wxLogMessage( wxT("0x%lx SimpleTransientPopup::Popup"), long(this) ); - wxPopupTransientWindow::Popup(focus ? focus : m_panel); + wxPopupTransientWindow::Popup(); } void SimpleTransientPopup::OnDismiss() @@ -200,9 +200,10 @@ void SimpleTransientPopup::OnMouse(wxMouseEvent &event) wxColour colour(*wxLIGHT_GREY); if (rect.Contains(event.GetPosition())) - { + { colour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); - wxLogMessage( wxT("0x%lx SimpleTransientPopup::OnMouse pos(%d, %d)"), long(event.GetEventObject()), event.GetX(), event.GetY()); + wxLogMessage( wxT("0x%lx SimpleTransientPopup::OnMouse pos(%d, %d)"), + long(event.GetEventObject()), event.GetX(), event.GetY()); } if (colour != m_mouseText->GetBackgroundColour()) @@ -228,7 +229,8 @@ void SimpleTransientPopup::OnButton(wxCommandEvent& event) void SimpleTransientPopup::OnSpinCtrl(wxSpinEvent& event) { - wxLogMessage( wxT("0x%lx SimpleTransientPopup::OnSpinCtrl ID %d Value %d"), long(this), event.GetId(), event.GetInt()); + wxLogMessage( wxT("0x%lx SimpleTransientPopup::OnSpinCtrl ID %d Value %d"), + long(this), event.GetId(), event.GetInt()); event.Skip(); } @@ -261,6 +263,7 @@ public: void OnTestDialog(wxCommandEvent& event); void OnStartSimplePopup(wxCommandEvent& event); void OnStartScrolledPopup(wxCommandEvent& event); + void OnActivate(wxActivateEvent& event); private: SimpleTransientPopup *m_simplePopup; @@ -312,12 +315,13 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(Minimal_Quit, MyFrame::OnQuit) EVT_MENU(Minimal_About, MyFrame::OnAbout) EVT_MENU(Minimal_TestDialog, MyFrame::OnTestDialog) + EVT_ACTIVATE(MyFrame::OnActivate) EVT_BUTTON(Minimal_StartSimplePopup, MyFrame::OnStartSimplePopup) EVT_BUTTON(Minimal_StartScrolledPopup, MyFrame::OnStartScrolledPopup) END_EVENT_TABLE() MyFrame::MyFrame(const wxString& title) - : wxFrame(NULL, wxID_ANY, title) +: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(500,300)) { m_simplePopup = m_scrolledPopup = NULL; @@ -376,6 +380,11 @@ MyFrame::~MyFrame() // event handlers +void MyFrame::OnActivate(wxActivateEvent& WXUNUSED(event)) +{ + wxLogMessage( wxT("In activate...") ); +} + void MyFrame::OnStartSimplePopup(wxCommandEvent& event) { wxLogMessage( wxT("================================================") );