Minor decorations.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31864 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -56,12 +56,12 @@ public:
|
|||||||
virtual void OnDismiss();
|
virtual void OnDismiss();
|
||||||
virtual bool ProcessLeftDown(wxMouseEvent& event);
|
virtual bool ProcessLeftDown(wxMouseEvent& event);
|
||||||
virtual bool Show( bool show = true );
|
virtual bool Show( bool show = true );
|
||||||
|
|
||||||
wxScrolledWindow* GetChild() { return m_panel; }
|
wxScrolledWindow* GetChild() { return m_panel; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxScrolledWindow *m_panel;
|
wxScrolledWindow *m_panel;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnMouse( wxMouseEvent &event );
|
void OnMouse( wxMouseEvent &event );
|
||||||
void OnSize( wxSizeEvent &event );
|
void OnSize( wxSizeEvent &event );
|
||||||
@@ -88,9 +88,9 @@ END_EVENT_TABLE()
|
|||||||
SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent ) :
|
SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent ) :
|
||||||
wxPopupTransientWindow( parent )
|
wxPopupTransientWindow( parent )
|
||||||
{
|
{
|
||||||
m_panel = new wxScrolledWindow( this, -1 );
|
m_panel = new wxScrolledWindow( this, wxID_ANY );
|
||||||
m_panel->SetBackgroundColour( *wxLIGHT_GREY );
|
m_panel->SetBackgroundColour( *wxLIGHT_GREY );
|
||||||
wxStaticText *text = new wxStaticText( m_panel, -1,
|
wxStaticText *text = new wxStaticText( m_panel, wxID_ANY,
|
||||||
wxT("wx.PopupTransientWindow is a\n")
|
wxT("wx.PopupTransientWindow is a\n")
|
||||||
wxT("wx.PopupWindow which disappears\n")
|
wxT("wx.PopupWindow which disappears\n")
|
||||||
wxT("automatically when the user\n")
|
wxT("automatically when the user\n")
|
||||||
@@ -164,18 +164,18 @@ void SimpleTransientPopup::OnMouse(wxMouseEvent &event)
|
|||||||
|
|
||||||
class ComplexTransientPopup : public SimpleTransientPopup
|
class ComplexTransientPopup : public SimpleTransientPopup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ComplexTransientPopup(wxWindow *parent) : SimpleTransientPopup(parent)
|
ComplexTransientPopup(wxWindow *parent) : SimpleTransientPopup(parent)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
virtual ~ComplexTransientPopup();
|
virtual ~ComplexTransientPopup();
|
||||||
|
|
||||||
virtual void Popup(wxWindow *focus = NULL);
|
virtual void Popup(wxWindow *focus = NULL);
|
||||||
virtual void Dismiss();
|
virtual void Dismiss();
|
||||||
virtual bool ProcessLeftDown(wxMouseEvent& event);
|
virtual bool ProcessLeftDown(wxMouseEvent& event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// safely push and pop the event handler of the child
|
// safely push and pop the event handler of the child
|
||||||
void PushPopupHandler(wxWindow* child);
|
void PushPopupHandler(wxWindow* child);
|
||||||
@@ -183,7 +183,7 @@ protected:
|
|||||||
|
|
||||||
void OnMouse( wxMouseEvent& event );
|
void OnMouse( wxMouseEvent& event );
|
||||||
void OnKeyDown( wxKeyEvent &event );
|
void OnKeyDown( wxKeyEvent &event );
|
||||||
|
|
||||||
#if USE_TIMER_TO_PUSHPOP
|
#if USE_TIMER_TO_PUSHPOP
|
||||||
// start/stop timer that pushes and pops handler when the mouse goes over
|
// start/stop timer that pushes and pops handler when the mouse goes over
|
||||||
// the scrollbars (if any) of the child window
|
// the scrollbars (if any) of the child window
|
||||||
@@ -194,7 +194,7 @@ protected:
|
|||||||
#else // !USE_TIMER_TO_PUSHPOP
|
#else // !USE_TIMER_TO_PUSHPOP
|
||||||
void OnIdle( wxIdleEvent& event );
|
void OnIdle( wxIdleEvent& event );
|
||||||
#endif // USE_TIMER_TO_PUSHPOP
|
#endif // USE_TIMER_TO_PUSHPOP
|
||||||
|
|
||||||
wxPoint m_mouse; // last/current mouse position
|
wxPoint m_mouse; // last/current mouse position
|
||||||
bool m_popped_handler; // state of the event handler
|
bool m_popped_handler; // state of the event handler
|
||||||
|
|
||||||
@@ -234,47 +234,47 @@ void ComplexTransientPopup::PushPopupHandler(wxWindow* child)
|
|||||||
if (child && m_handlerPopup && m_popped_handler)
|
if (child && m_handlerPopup && m_popped_handler)
|
||||||
{
|
{
|
||||||
m_popped_handler = false;
|
m_popped_handler = false;
|
||||||
|
|
||||||
if (child->GetEventHandler() != (wxEvtHandler*)m_handlerPopup)
|
if (child->GetEventHandler() != (wxEvtHandler*)m_handlerPopup)
|
||||||
child->PushEventHandler((wxEvtHandler*)m_handlerPopup);
|
child->PushEventHandler((wxEvtHandler*)m_handlerPopup);
|
||||||
if (!child->HasCapture())
|
if (!child->HasCapture())
|
||||||
child->CaptureMouse();
|
child->CaptureMouse();
|
||||||
|
|
||||||
child->SetFocus();
|
child->SetFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ComplexTransientPopup::PopPopupHandler(wxWindow* child)
|
void ComplexTransientPopup::PopPopupHandler(wxWindow* child)
|
||||||
{
|
{
|
||||||
if (child && m_handlerPopup && !m_popped_handler)
|
if (child && m_handlerPopup && !m_popped_handler)
|
||||||
{
|
{
|
||||||
m_popped_handler = true;
|
m_popped_handler = true;
|
||||||
|
|
||||||
if (child->GetEventHandler() == (wxEvtHandler*)m_handlerPopup)
|
if (child->GetEventHandler() == (wxEvtHandler*)m_handlerPopup)
|
||||||
child->PopEventHandler(false);
|
child->PopEventHandler(false);
|
||||||
if (child->HasCapture())
|
if (child->HasCapture())
|
||||||
child->ReleaseMouse();
|
child->ReleaseMouse();
|
||||||
|
|
||||||
child->SetFocus();
|
child->SetFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_TIMER_TO_PUSHPOP
|
#if USE_TIMER_TO_PUSHPOP
|
||||||
void ComplexTransientPopup::OnTimer( wxTimerEvent &WXUNUSED(event) )
|
void ComplexTransientPopup::OnTimer( wxTimerEvent &WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
if (!IsShown()) return;
|
if (!IsShown()) return;
|
||||||
|
|
||||||
m_mouse = ScreenToClient(wxGetMousePosition());
|
m_mouse = ScreenToClient(wxGetMousePosition());
|
||||||
|
|
||||||
wxWindow *child = GetChild();
|
wxWindow *child = GetChild();
|
||||||
if (!child) return; // nothing to do
|
if (!child) return; // nothing to do
|
||||||
|
|
||||||
wxRect clientRect(wxPoint(0,0), GetClientSize());
|
wxRect clientRect(wxPoint(0,0), GetClientSize());
|
||||||
wxLogMessage(wxT("CTW::OnTimer mouse(%d, %d), popped %d, m_handlerPopup %d"), m_mouse.x, m_mouse.y, m_popped_handler, m_handlerPopup);
|
wxLogMessage(wxT("CTW::OnTimer mouse(%d, %d), popped %d, m_handlerPopup %d"), m_mouse.x, m_mouse.y, m_popped_handler, m_handlerPopup);
|
||||||
// pop the event handler if inside the child window or
|
// pop the event handler if inside the child window or
|
||||||
// restore the event handler if not in the child window
|
// restore the event handler if not in the child window
|
||||||
if (clientRect.Inside(m_mouse))
|
if (clientRect.Inside(m_mouse))
|
||||||
PopPopupHandler(child);
|
PopPopupHandler(child);
|
||||||
else
|
else
|
||||||
PushPopupHandler(child);
|
PushPopupHandler(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,19 +282,19 @@ void ComplexTransientPopup::StartTimer()
|
|||||||
{
|
{
|
||||||
if (!m_timer)
|
if (!m_timer)
|
||||||
m_timer = new wxTimer(this, wxID_ANY);
|
m_timer = new wxTimer(this, wxID_ANY);
|
||||||
|
|
||||||
m_timer->Start(200, false);
|
m_timer->Start(200, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComplexTransientPopup::StopTimer()
|
void ComplexTransientPopup::StopTimer()
|
||||||
{
|
{
|
||||||
if (m_timer)
|
if (m_timer)
|
||||||
{
|
{
|
||||||
if (m_timer->IsRunning())
|
if (m_timer->IsRunning())
|
||||||
m_timer->Stop();
|
m_timer->Stop();
|
||||||
delete m_timer;
|
delete m_timer;
|
||||||
m_timer = NULL;
|
m_timer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // USE_TIMER_TO_PUSHPOP
|
#else // USE_TIMER_TO_PUSHPOP
|
||||||
@@ -304,17 +304,17 @@ void ComplexTransientPopup::OnIdle( wxIdleEvent& event )
|
|||||||
{
|
{
|
||||||
m_mouse = ScreenToClient(wxGetMousePosition());
|
m_mouse = ScreenToClient(wxGetMousePosition());
|
||||||
wxLogMessage(wxT("CTW::OnIdle mouse(%d, %d), popped %d, m_handlerPopup %d"), m_mouse.x, m_mouse.y, m_popped_handler, m_handlerPopup);
|
wxLogMessage(wxT("CTW::OnIdle mouse(%d, %d), popped %d, m_handlerPopup %d"), m_mouse.x, m_mouse.y, m_popped_handler, m_handlerPopup);
|
||||||
|
|
||||||
wxWindow *child = GetChild();
|
wxWindow *child = GetChild();
|
||||||
if (!child) return; // nothing to do
|
if (!child) return; // nothing to do
|
||||||
|
|
||||||
wxRect clientRect(wxPoint(0,0), GetClientSize());
|
wxRect clientRect(GetClientSize());
|
||||||
//wxPrintf(wxT("**DropDownPopup::OnIdle mouse %d %d -- %d %d %d\n"), m_mouse.x, m_mouse.y, m_popped_handler, m_child, m_handlerPopup); fflush(stdout);
|
//wxPrintf(wxT("**DropDownPopup::OnIdle mouse %d %d -- %d %d %d\n"), m_mouse.x, m_mouse.y, m_popped_handler, m_child, m_handlerPopup); fflush(stdout);
|
||||||
// pop the event handler if inside the child window or
|
// pop the event handler if inside the child window or
|
||||||
// restore the event handler if not in the child window
|
// restore the event handler if not in the child window
|
||||||
if (clientRect.Inside(m_mouse))
|
if (clientRect.Inside(m_mouse))
|
||||||
PopPopupHandler(child);
|
PopPopupHandler(child);
|
||||||
else
|
else
|
||||||
PushPopupHandler(child);
|
PushPopupHandler(child);
|
||||||
}
|
}
|
||||||
event.Skip();
|
event.Skip();
|
||||||
@@ -328,7 +328,7 @@ void ComplexTransientPopup::OnMouse( wxMouseEvent& event )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ComplexTransientPopup::OnKeyDown( wxKeyEvent &event )
|
void ComplexTransientPopup::OnKeyDown( wxKeyEvent &event )
|
||||||
{
|
{
|
||||||
if (GetChild() && GetChild()->ProcessEvent(event))
|
if (GetChild() && GetChild()->ProcessEvent(event))
|
||||||
event.Skip(false);
|
event.Skip(false);
|
||||||
else
|
else
|
||||||
@@ -338,12 +338,12 @@ void ComplexTransientPopup::OnKeyDown( wxKeyEvent &event )
|
|||||||
void ComplexTransientPopup::Popup(wxWindow *focus)
|
void ComplexTransientPopup::Popup(wxWindow *focus)
|
||||||
{
|
{
|
||||||
SimpleTransientPopup::Popup(focus);
|
SimpleTransientPopup::Popup(focus);
|
||||||
|
|
||||||
#if USE_TIMER_TO_PUSHPOP
|
#if USE_TIMER_TO_PUSHPOP
|
||||||
// start the timer to track the mouse position
|
// start the timer to track the mouse position
|
||||||
// note: idle function not used in this case
|
// note: idle function not used in this case
|
||||||
StartTimer();
|
StartTimer();
|
||||||
#else
|
#else
|
||||||
// note: all timer related functions aren't used in this case
|
// note: all timer related functions aren't used in this case
|
||||||
Connect(wxID_ANY, wxEVT_IDLE,
|
Connect(wxID_ANY, wxEVT_IDLE,
|
||||||
(wxObjectEventFunction)(wxEventFunction)(wxIdleEventFunction)
|
(wxObjectEventFunction)(wxEventFunction)(wxIdleEventFunction)
|
||||||
@@ -354,13 +354,13 @@ void ComplexTransientPopup::Popup(wxWindow *focus)
|
|||||||
void ComplexTransientPopup::Dismiss()
|
void ComplexTransientPopup::Dismiss()
|
||||||
{
|
{
|
||||||
#if USE_TIMER_TO_PUSHPOP
|
#if USE_TIMER_TO_PUSHPOP
|
||||||
StopTimer();
|
StopTimer();
|
||||||
#else // USE_TIMER_TO_PUSHPOP
|
#else // USE_TIMER_TO_PUSHPOP
|
||||||
Disconnect(wxID_ANY, wxEVT_IDLE,
|
Disconnect(wxID_ANY, wxEVT_IDLE,
|
||||||
(wxObjectEventFunction)(wxEventFunction)(wxIdleEventFunction)
|
(wxObjectEventFunction)(wxEventFunction)(wxIdleEventFunction)
|
||||||
&ComplexTransientPopup::OnIdle, 0, this);
|
&ComplexTransientPopup::OnIdle, 0, this);
|
||||||
#endif // USE_TIMER_TO_PUSHPOP
|
#endif // USE_TIMER_TO_PUSHPOP
|
||||||
|
|
||||||
// restore the event handler if necessary for the base class Dismiss
|
// restore the event handler if necessary for the base class Dismiss
|
||||||
wxWindow *child = GetChild();
|
wxWindow *child = GetChild();
|
||||||
if (child) PushPopupHandler(child);
|
if (child) PushPopupHandler(child);
|
||||||
@@ -374,18 +374,18 @@ bool ComplexTransientPopup::ProcessLeftDown( wxMouseEvent &event )
|
|||||||
{
|
{
|
||||||
m_mouse = event.GetPosition();
|
m_mouse = event.GetPosition();
|
||||||
//wxPrintf(wxT("DropDownPopup::ProcessLeftDown %d %d\n"), m_mouse.x, m_mouse.y); fflush(stdout);
|
//wxPrintf(wxT("DropDownPopup::ProcessLeftDown %d %d\n"), m_mouse.x, m_mouse.y); fflush(stdout);
|
||||||
|
|
||||||
if (m_popped_handler) return true; // shouldn't ever get here, but just in case
|
if (m_popped_handler) return true; // shouldn't ever get here, but just in case
|
||||||
|
|
||||||
#if USE_TIMER_TO_PUSHPOP
|
#if USE_TIMER_TO_PUSHPOP
|
||||||
StopTimer();
|
StopTimer();
|
||||||
#endif // USE_TIMER_TO_PUSHPOP
|
#endif // USE_TIMER_TO_PUSHPOP
|
||||||
|
|
||||||
// don't let the click on the dropdown button actually press it
|
// don't let the click on the dropdown button actually press it
|
||||||
// *** Here's where we stick code to ensure that if we click on a combobox
|
// *** Here's where we stick code to ensure that if we click on a combobox
|
||||||
// dropdown box we don't try to reshow this dialog because they intend
|
// dropdown box we don't try to reshow this dialog because they intend
|
||||||
// hide it.
|
// hide it.
|
||||||
|
|
||||||
if (wxRect(wxPoint(0,0), GetSize()).Inside(m_mouse))
|
if (wxRect(wxPoint(0,0), GetSize()).Inside(m_mouse))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -516,12 +516,12 @@ MyFrame::MyFrame(const wxString& title)
|
|||||||
wxButton *button2 = new wxButton( this, Minimal_StartScrolledPopup, wxT("Show scrolled popup"), wxPoint(20,70) );
|
wxButton *button2 = new wxButton( this, Minimal_StartScrolledPopup, wxT("Show scrolled popup"), wxPoint(20,70) );
|
||||||
wxButton *button3 = new wxButton( this, Minimal_StartComplexPopup, wxT("Show complex popup"), wxPoint(20,120) );
|
wxButton *button3 = new wxButton( this, Minimal_StartComplexPopup, wxT("Show complex popup"), wxPoint(20,120) );
|
||||||
|
|
||||||
wxTextCtrl* logWin = new wxTextCtrl( this, -1, wxEmptyString, wxDefaultPosition,
|
wxTextCtrl* logWin = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition,
|
||||||
wxDefaultSize, wxTE_MULTILINE );
|
wxDefaultSize, wxTE_MULTILINE );
|
||||||
wxLogTextCtrl* logger = new wxLogTextCtrl( logWin );
|
wxLogTextCtrl* logger = new wxLogTextCtrl( logWin );
|
||||||
m_logOld = logger->SetActiveTarget( logger );
|
m_logOld = logger->SetActiveTarget( logger );
|
||||||
logger->SetTimestamp( NULL );
|
logger->SetTimestamp( NULL );
|
||||||
|
|
||||||
wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
|
wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
topSizer->Add( button1, 0 );
|
topSizer->Add( button1, 0 );
|
||||||
topSizer->Add( button2, 0 );
|
topSizer->Add( button2, 0 );
|
||||||
@@ -538,10 +538,10 @@ MyFrame::MyFrame(const wxString& title)
|
|||||||
#endif // wxUSE_STATUSBAR
|
#endif // wxUSE_STATUSBAR
|
||||||
}
|
}
|
||||||
|
|
||||||
MyFrame::~MyFrame()
|
MyFrame::~MyFrame()
|
||||||
{
|
{
|
||||||
delete wxLog::SetActiveTarget(m_logOld);
|
delete wxLog::SetActiveTarget(m_logOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// event handlers
|
// event handlers
|
||||||
|
Reference in New Issue
Block a user