Minor decorations.
[wxWidgets.git] / samples / popup / popup.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: minimal.cpp
3 // Purpose: Popup wxWidgets sample
4 // Author: Robert Roebling
5 // Modified by:
6 // Created: 2005-02-04
7 // RCS-ID: $Id$
8 // Copyright: (c) 2005 Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx/wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 // for all others, include the necessary headers (this file is usually all you
28 // need because it includes almost all "standard" wxWidgets headers)
29 #ifndef WX_PRECOMP
30 #include "wx/wx.h"
31 #endif
32
33 #include "wx/popupwin.h"
34
35 // ----------------------------------------------------------------------------
36 // resources
37 // ----------------------------------------------------------------------------
38
39 // the application icon (under Windows and OS/2 it is in resources and even
40 // though we could still include the XPM here it would be unused)
41 #if !defined(__WXMSW__) && !defined(__WXPM__)
42 #include "../sample.xpm"
43 #endif
44
45 //----------------------------------------------------------------------------
46 // SimpleTransientPopup
47 //----------------------------------------------------------------------------
48 class SimpleTransientPopup: public wxPopupTransientWindow
49 {
50 public:
51 SimpleTransientPopup( wxWindow *parent );
52 virtual ~SimpleTransientPopup();
53
54 // wxPopupTransientWindow virtual methods are all overridden to log them
55 virtual void Popup(wxWindow *focus = NULL);
56 virtual void OnDismiss();
57 virtual bool ProcessLeftDown(wxMouseEvent& event);
58 virtual bool Show( bool show = true );
59
60 wxScrolledWindow* GetChild() { return m_panel; }
61
62 private:
63 wxScrolledWindow *m_panel;
64
65 private:
66 void OnMouse( wxMouseEvent &event );
67 void OnSize( wxSizeEvent &event );
68 void OnSetFocus( wxFocusEvent &event );
69 void OnKillFocus( wxFocusEvent &event );
70
71 private:
72 DECLARE_CLASS(SimpleTransientPopup)
73 DECLARE_EVENT_TABLE()
74 };
75
76 //----------------------------------------------------------------------------
77 // SimpleTransientPopup
78 //----------------------------------------------------------------------------
79 IMPLEMENT_CLASS(SimpleTransientPopup,wxPopupTransientWindow)
80
81 BEGIN_EVENT_TABLE(SimpleTransientPopup,wxPopupTransientWindow)
82 EVT_MOUSE_EVENTS( SimpleTransientPopup::OnMouse )
83 EVT_SIZE( SimpleTransientPopup::OnSize )
84 EVT_SET_FOCUS( SimpleTransientPopup::OnSetFocus )
85 EVT_KILL_FOCUS( SimpleTransientPopup::OnKillFocus )
86 END_EVENT_TABLE()
87
88 SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent ) :
89 wxPopupTransientWindow( parent )
90 {
91 m_panel = new wxScrolledWindow( this, wxID_ANY );
92 m_panel->SetBackgroundColour( *wxLIGHT_GREY );
93 wxStaticText *text = new wxStaticText( m_panel, wxID_ANY,
94 wxT("wx.PopupTransientWindow is a\n")
95 wxT("wx.PopupWindow which disappears\n")
96 wxT("automatically when the user\n")
97 wxT("clicks the mouse outside it or if it\n")
98 wxT("(or its first child) loses focus in \n")
99 wxT("any other way."), wxPoint( 10,10) );
100 wxSize size = text->GetBestSize();
101 m_panel->SetSize( size.x+20, size.y+20 );
102 SetClientSize( size.x+20, size.y+20 );
103 }
104
105 SimpleTransientPopup::~SimpleTransientPopup()
106 {
107 }
108
109 void SimpleTransientPopup::Popup(wxWindow *focus)
110 {
111 wxLogMessage( wxT("SimpleTransientPopup::Popup"));
112 wxPopupTransientWindow::Popup(focus);
113 }
114
115 void SimpleTransientPopup::OnDismiss()
116 {
117 wxLogMessage( wxT("SimpleTransientPopup::OnDismiss"));
118 wxPopupTransientWindow::OnDismiss();
119 }
120
121 bool SimpleTransientPopup::ProcessLeftDown(wxMouseEvent& event)
122 {
123 wxLogMessage( wxT("SimpleTransientPopup::ProcessLeftDown pos(%d, %d)"), event.GetX(), event.GetY());
124 return wxPopupTransientWindow::ProcessLeftDown(event);
125 }
126 bool SimpleTransientPopup::Show( bool show )
127 {
128 wxLogMessage( wxT("SimpleTransientPopup::Show %d"), int(show));
129 return wxPopupTransientWindow::Show(show);
130 }
131
132 void SimpleTransientPopup::OnSize(wxSizeEvent &event)
133 {
134 wxLogMessage( wxT("SimpleTransientPopup::OnSize"));
135 event.Skip();
136 }
137
138 void SimpleTransientPopup::OnSetFocus(wxFocusEvent &event)
139 {
140 wxLogMessage( wxT("SimpleTransientPopup::OnSetFocus"));
141 event.Skip();
142 }
143
144 void SimpleTransientPopup::OnKillFocus(wxFocusEvent &event)
145 {
146 wxLogMessage( wxT("SimpleTransientPopup::OnKillFocus"));
147 event.Skip();
148 }
149
150 void SimpleTransientPopup::OnMouse(wxMouseEvent &event)
151 {
152 wxLogMessage( wxT("SimpleTransientPopup::OnMouse pos(%d, %d)"), event.GetX(), event.GetY());
153 event.Skip();
154 }
155
156 // ----------------------------------------------------------------------------
157 // ComplexTransientPopup
158 // we push the event handler when the mouse isn't in the popup and
159 // and pop the event handler when it is so that the child gets the events.
160 // ----------------------------------------------------------------------------
161
162 // Use EVT_IDLE to push and pop the handler, else use a wxTimer
163 #define USE_TIMER_TO_PUSHPOP 0
164
165 class ComplexTransientPopup : public SimpleTransientPopup
166 {
167 public:
168 ComplexTransientPopup(wxWindow *parent) : SimpleTransientPopup(parent)
169 {
170 Init();
171 }
172 virtual ~ComplexTransientPopup();
173
174 virtual void Popup(wxWindow *focus = NULL);
175 virtual void Dismiss();
176 virtual bool ProcessLeftDown(wxMouseEvent& event);
177
178 protected:
179
180 // safely push and pop the event handler of the child
181 void PushPopupHandler(wxWindow* child);
182 void PopPopupHandler(wxWindow* child);
183
184 void OnMouse( wxMouseEvent& event );
185 void OnKeyDown( wxKeyEvent &event );
186
187 #if USE_TIMER_TO_PUSHPOP
188 // start/stop timer that pushes and pops handler when the mouse goes over
189 // the scrollbars (if any) of the child window
190 void StartTimer();
191 void StopTimer();
192 void OnTimer( wxTimerEvent& event );
193 wxTimer *m_timer; // timer for tracking mouse position
194 #else // !USE_TIMER_TO_PUSHPOP
195 void OnIdle( wxIdleEvent& event );
196 #endif // USE_TIMER_TO_PUSHPOP
197
198 wxPoint m_mouse; // last/current mouse position
199 bool m_popped_handler; // state of the event handler
200
201 private:
202 void Init();
203 DECLARE_EVENT_TABLE()
204 };
205
206 //----------------------------------------------------------------------------
207 // ComplexTransientPopup
208 //----------------------------------------------------------------------------
209 BEGIN_EVENT_TABLE(ComplexTransientPopup, SimpleTransientPopup)
210 EVT_KEY_DOWN(ComplexTransientPopup::OnKeyDown)
211 EVT_MOUSE_EVENTS(ComplexTransientPopup::OnMouse)
212 #if USE_TIMER_TO_PUSHPOP
213 EVT_TIMER( wxID_ANY, ComplexTransientPopup::OnTimer )
214 #endif // USE_TIMER_TO_PUSHPOP
215 END_EVENT_TABLE()
216
217 void ComplexTransientPopup::Init()
218 {
219 #if USE_TIMER_TO_PUSHPOP
220 m_timer = NULL;
221 #endif // USE_TIMER_TO_PUSHPOP
222 m_popped_handler = false;
223 }
224
225 ComplexTransientPopup::~ComplexTransientPopup()
226 {
227 #if USE_TIMER_TO_PUSHPOP
228 StopTimer();
229 #endif // USE_TIMER_TO_PUSHPOP
230 }
231
232 void ComplexTransientPopup::PushPopupHandler(wxWindow* child)
233 {
234 if (child && m_handlerPopup && m_popped_handler)
235 {
236 m_popped_handler = false;
237
238 if (child->GetEventHandler() != (wxEvtHandler*)m_handlerPopup)
239 child->PushEventHandler((wxEvtHandler*)m_handlerPopup);
240 if (!child->HasCapture())
241 child->CaptureMouse();
242
243 child->SetFocus();
244 }
245 }
246 void ComplexTransientPopup::PopPopupHandler(wxWindow* child)
247 {
248 if (child && m_handlerPopup && !m_popped_handler)
249 {
250 m_popped_handler = true;
251
252 if (child->GetEventHandler() == (wxEvtHandler*)m_handlerPopup)
253 child->PopEventHandler(false);
254 if (child->HasCapture())
255 child->ReleaseMouse();
256
257 child->SetFocus();
258 }
259 }
260
261 #if USE_TIMER_TO_PUSHPOP
262 void ComplexTransientPopup::OnTimer( wxTimerEvent &WXUNUSED(event) )
263 {
264 if (!IsShown()) return;
265
266 m_mouse = ScreenToClient(wxGetMousePosition());
267
268 wxWindow *child = GetChild();
269 if (!child) return; // nothing to do
270
271 wxRect clientRect(wxPoint(0,0), GetClientSize());
272 wxLogMessage(wxT("CTW::OnTimer mouse(%d, %d), popped %d, m_handlerPopup %d"), m_mouse.x, m_mouse.y, m_popped_handler, m_handlerPopup);
273 // pop the event handler if inside the child window or
274 // restore the event handler if not in the child window
275 if (clientRect.Inside(m_mouse))
276 PopPopupHandler(child);
277 else
278 PushPopupHandler(child);
279 }
280
281 void ComplexTransientPopup::StartTimer()
282 {
283 if (!m_timer)
284 m_timer = new wxTimer(this, wxID_ANY);
285
286 m_timer->Start(200, false);
287 }
288
289 void ComplexTransientPopup::StopTimer()
290 {
291 if (m_timer)
292 {
293 if (m_timer->IsRunning())
294 m_timer->Stop();
295 delete m_timer;
296 m_timer = NULL;
297 }
298 }
299
300 #else // USE_TIMER_TO_PUSHPOP
301 void ComplexTransientPopup::OnIdle( wxIdleEvent& event )
302 {
303 if (IsShown())
304 {
305 m_mouse = ScreenToClient(wxGetMousePosition());
306 wxLogMessage(wxT("CTW::OnIdle mouse(%d, %d), popped %d, m_handlerPopup %d"), m_mouse.x, m_mouse.y, m_popped_handler, m_handlerPopup);
307
308 wxWindow *child = GetChild();
309 if (!child) return; // nothing to do
310
311 wxRect clientRect(GetClientSize());
312 //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);
313 // pop the event handler if inside the child window or
314 // restore the event handler if not in the child window
315 if (clientRect.Inside(m_mouse))
316 PopPopupHandler(child);
317 else
318 PushPopupHandler(child);
319 }
320 event.Skip();
321 }
322 #endif // USE_TIMER_TO_PUSHPOP
323
324 void ComplexTransientPopup::OnMouse( wxMouseEvent& event )
325 {
326 m_mouse = event.GetPosition();
327 event.Skip();
328 }
329
330 void ComplexTransientPopup::OnKeyDown( wxKeyEvent &event )
331 {
332 if (GetChild() && GetChild()->ProcessEvent(event))
333 event.Skip(false);
334 else
335 event.Skip(true);
336 }
337
338 void ComplexTransientPopup::Popup(wxWindow *focus)
339 {
340 SimpleTransientPopup::Popup(focus);
341
342 #if USE_TIMER_TO_PUSHPOP
343 // start the timer to track the mouse position
344 // note: idle function not used in this case
345 StartTimer();
346 #else
347 // note: all timer related functions aren't used in this case
348 Connect(wxID_ANY, wxEVT_IDLE,
349 (wxObjectEventFunction)(wxEventFunction)(wxIdleEventFunction)
350 &ComplexTransientPopup::OnIdle, 0, this);
351 #endif // USE_TIMER_TO_PUSHPOP
352 }
353
354 void ComplexTransientPopup::Dismiss()
355 {
356 #if USE_TIMER_TO_PUSHPOP
357 StopTimer();
358 #else // USE_TIMER_TO_PUSHPOP
359 Disconnect(wxID_ANY, wxEVT_IDLE,
360 (wxObjectEventFunction)(wxEventFunction)(wxIdleEventFunction)
361 &ComplexTransientPopup::OnIdle, 0, this);
362 #endif // USE_TIMER_TO_PUSHPOP
363
364 // restore the event handler if necessary for the base class Dismiss
365 wxWindow *child = GetChild();
366 if (child) PushPopupHandler(child);
367
368 m_popped_handler = false;
369
370 SimpleTransientPopup::Dismiss();
371 }
372
373 bool ComplexTransientPopup::ProcessLeftDown( wxMouseEvent &event )
374 {
375 m_mouse = event.GetPosition();
376 //wxPrintf(wxT("DropDownPopup::ProcessLeftDown %d %d\n"), m_mouse.x, m_mouse.y); fflush(stdout);
377
378 if (m_popped_handler) return true; // shouldn't ever get here, but just in case
379
380 #if USE_TIMER_TO_PUSHPOP
381 StopTimer();
382 #endif // USE_TIMER_TO_PUSHPOP
383
384 // don't let the click on the dropdown button actually press it
385 // *** Here's where we stick code to ensure that if we click on a combobox
386 // dropdown box we don't try to reshow this dialog because they intend
387 // hide it.
388
389 if (wxRect(wxPoint(0,0), GetSize()).Inside(m_mouse))
390 return false;
391
392 Dismiss();
393 return true;
394 }
395
396 // ----------------------------------------------------------------------------
397 // private classes
398 // ----------------------------------------------------------------------------
399
400 class MyApp : public wxApp
401 {
402 public:
403 virtual bool OnInit();
404 };
405
406 class MyDialog : public wxDialog
407 {
408 public:
409 MyDialog(const wxString& title);
410
411 void OnStartSimplePopup(wxCommandEvent& event);
412 void OnStartScrolledPopup(wxCommandEvent& event);
413 void OnStartComplexPopup(wxCommandEvent& event);
414
415 private:
416 DECLARE_EVENT_TABLE()
417 };
418
419 class MyFrame : public wxFrame
420 {
421 public:
422 MyFrame(const wxString& title);
423 virtual ~MyFrame();
424
425 void CreatePanel(wxWindow* parent);
426
427 void OnQuit(wxCommandEvent& event);
428 void OnAbout(wxCommandEvent& event);
429 void OnTestDialog(wxCommandEvent& event);
430 void OnStartSimplePopup(wxCommandEvent& event);
431 void OnStartScrolledPopup(wxCommandEvent& event);
432 void OnStartComplexPopup(wxCommandEvent& event);
433
434 private:
435 wxLog *m_logOld;
436 DECLARE_EVENT_TABLE()
437 };
438
439 // ----------------------------------------------------------------------------
440 // constants
441 // ----------------------------------------------------------------------------
442
443 // IDs for the controls and the menu commands
444 enum
445 {
446 Minimal_Quit = wxID_EXIT,
447 Minimal_About = wxID_ABOUT,
448 Minimal_TestDialog,
449 Minimal_StartSimplePopup,
450 Minimal_StartScrolledPopup,
451 Minimal_StartComplexPopup,
452 Minimal_LogWindow
453 };
454
455 // ----------------------------------------------------------------------------
456 // event tables and other macros for wxWidgets
457 // ----------------------------------------------------------------------------
458
459
460 IMPLEMENT_APP(MyApp)
461
462 // 'Main program' equivalent: the program execution "starts" here
463 bool MyApp::OnInit()
464 {
465 // create the main application window
466 MyFrame *frame = new MyFrame(_T("Popup wxWidgets App"));
467
468 // and show it (the frames, unlike simple controls, are not shown when
469 // created initially)
470 frame->Show(true);
471
472 // success: wxApp::OnRun() will be called which will enter the main message
473 // loop and the application will run. If we returned false here, the
474 // application would exit immediately.
475 return true;
476 }
477
478 // ----------------------------------------------------------------------------
479 // main frame
480 // ----------------------------------------------------------------------------
481
482 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
483 EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
484 EVT_MENU(Minimal_About, MyFrame::OnAbout)
485 EVT_MENU(Minimal_TestDialog, MyFrame::OnTestDialog)
486 EVT_BUTTON(Minimal_StartSimplePopup, MyFrame::OnStartSimplePopup)
487 EVT_BUTTON(Minimal_StartScrolledPopup, MyFrame::OnStartScrolledPopup)
488 EVT_BUTTON(Minimal_StartComplexPopup, MyFrame::OnStartComplexPopup)
489 END_EVENT_TABLE()
490
491 MyFrame::MyFrame(const wxString& title)
492 : wxFrame(NULL, wxID_ANY, title)
493 {
494 SetIcon(wxICON(sample));
495
496 #if wxUSE_MENUS
497 wxMenu *menuFile = new wxMenu;
498
499 // the "About" item should be in the help menu
500 wxMenu *helpMenu = new wxMenu;
501 helpMenu->Append(Minimal_About, _T("&About...\tF1"), _T("Show about dialog"));
502
503 menuFile->Append(Minimal_TestDialog, _T("&Test dialog\tAlt-T"), _T("Test dialog"));
504 menuFile->Append(Minimal_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
505
506 // now append the freshly created menu to the menu bar...
507 wxMenuBar *menuBar = new wxMenuBar();
508 menuBar->Append(menuFile, _T("&File"));
509 menuBar->Append(helpMenu, _T("&Help"));
510
511 // ... and attach this menu bar to the frame
512 SetMenuBar(menuBar);
513 #endif // wxUSE_MENUS
514
515 wxButton *button1 = new wxButton( this, Minimal_StartSimplePopup, wxT("Show simple popup"), wxPoint(20,20) );
516 wxButton *button2 = new wxButton( this, Minimal_StartScrolledPopup, wxT("Show scrolled popup"), wxPoint(20,70) );
517 wxButton *button3 = new wxButton( this, Minimal_StartComplexPopup, wxT("Show complex popup"), wxPoint(20,120) );
518
519 wxTextCtrl* logWin = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition,
520 wxDefaultSize, wxTE_MULTILINE );
521 wxLogTextCtrl* logger = new wxLogTextCtrl( logWin );
522 m_logOld = logger->SetActiveTarget( logger );
523 logger->SetTimestamp( NULL );
524
525 wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
526 topSizer->Add( button1, 0 );
527 topSizer->Add( button2, 0 );
528 topSizer->Add( button3, 0 );
529 topSizer->Add( logWin, 1, wxEXPAND );
530
531 SetAutoLayout( true );
532 SetSizer( topSizer );
533
534 #if wxUSE_STATUSBAR
535 // create a status bar just for fun (by default with 1 pane only)
536 CreateStatusBar(2);
537 SetStatusText(_T("Welcome to wxWidgets!"));
538 #endif // wxUSE_STATUSBAR
539 }
540
541 MyFrame::~MyFrame()
542 {
543 delete wxLog::SetActiveTarget(m_logOld);
544 }
545
546
547 // event handlers
548
549 void MyFrame::OnStartSimplePopup(wxCommandEvent& event)
550 {
551 SimpleTransientPopup* popup = new SimpleTransientPopup( this );
552 wxWindow *btn = (wxWindow*) event.GetEventObject();
553 wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
554 wxSize sz = btn->GetSize();
555 popup->Position( pos, sz );
556 wxLogMessage( wxT("================================================") );
557 wxLogMessage( wxT("Simple Popup Shown pos(%d, %d) size(%d, %d)"), pos.x, pos.y, sz.x, sz.y );
558 popup->Popup();
559 }
560
561 void MyFrame::OnStartScrolledPopup(wxCommandEvent& event)
562 {
563 SimpleTransientPopup* popup = new SimpleTransientPopup( this );
564 popup->GetChild()->SetScrollbars(1, 1, 1000, 1000);
565 wxWindow *btn = (wxWindow*) event.GetEventObject();
566 wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
567 wxSize sz = btn->GetSize();
568 popup->Position( pos, sz );
569 wxLogMessage( wxT("================================================") );
570 wxLogMessage( wxT("Scrolled Popup Shown pos(%d, %d) size(%d, %d)"), pos.x, pos.y, sz.x, sz.y );
571 popup->Popup();
572 }
573
574 void MyFrame::OnStartComplexPopup(wxCommandEvent& event)
575 {
576 ComplexTransientPopup* popup = new ComplexTransientPopup( this );
577 popup->GetChild()->SetScrollbars(1, 1, 1000, 1000);
578 wxWindow *btn = (wxWindow*) event.GetEventObject();
579 wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
580 wxSize sz = btn->GetSize();
581 popup->Position( pos, sz );
582 wxLogMessage( wxT("================================================") );
583 wxLogMessage( wxT("Complex Popup Shown pos(%d, %d) size(%d, %d)"), pos.x, pos.y, sz.x, sz.y );
584 popup->Popup();
585 }
586
587 void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event))
588 {
589 MyDialog dialog( wxT("Test") );
590 dialog.ShowModal();
591 }
592
593 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
594 {
595 // true is to force the frame to close
596 Close(true);
597 }
598
599 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
600 {
601 wxString msg;
602 msg.Printf( _T("This is the About dialog of the popup sample.\n")
603 _T("Welcome to %s"), wxVERSION_STRING);
604
605 wxMessageBox(msg, _T("About Popup"), wxOK | wxICON_INFORMATION, this);
606 }
607
608 // ----------------------------------------------------------------------------
609 // test dialog
610 // ----------------------------------------------------------------------------
611
612 BEGIN_EVENT_TABLE(MyDialog, wxDialog)
613 EVT_BUTTON(Minimal_StartSimplePopup, MyDialog::OnStartSimplePopup)
614 EVT_BUTTON(Minimal_StartScrolledPopup, MyDialog::OnStartScrolledPopup)
615 EVT_BUTTON(Minimal_StartComplexPopup, MyDialog::OnStartComplexPopup)
616 END_EVENT_TABLE()
617
618 MyDialog::MyDialog(const wxString& title)
619 : wxDialog(NULL, wxID_ANY, title, wxPoint(50,50), wxSize(400,300))
620 {
621
622 new wxButton( this, Minimal_StartSimplePopup, wxT("Show simple popup"), wxPoint(20,20) );
623 new wxButton( this, Minimal_StartScrolledPopup, wxT("Show scrolled popup"), wxPoint(20,60) );
624 new wxButton( this, Minimal_StartComplexPopup, wxT("Show complex popup"), wxPoint(20,100) );
625
626 new wxButton( this, wxID_OK, wxT("OK"), wxPoint(20,200) );
627 }
628
629 void MyDialog::OnStartSimplePopup(wxCommandEvent& event)
630 {
631 SimpleTransientPopup* popup = new SimpleTransientPopup( this );
632 wxWindow *btn = (wxWindow*) event.GetEventObject();
633 wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
634 wxSize sz = btn->GetSize();
635 popup->Position( pos, sz );
636 wxLogMessage( wxT("================================================") );
637 wxLogMessage( wxT("Dialog Simple Popup Shown pos(%d, %d) size(%d, %d)"), pos.x, pos.y, sz.x, sz.y );
638 popup->Popup();
639 }
640
641 void MyDialog::OnStartScrolledPopup(wxCommandEvent& event)
642 {
643 SimpleTransientPopup* popup = new SimpleTransientPopup( this );
644 popup->GetChild()->SetScrollbars(1, 1, 1000, 1000);
645 wxWindow *btn = (wxWindow*) event.GetEventObject();
646 wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
647 wxSize sz = btn->GetSize();
648 popup->Position( pos, sz );
649 wxLogMessage( wxT("================================================") );
650 wxLogMessage( wxT("Dialog Scrolled Popup Shown pos(%d, %d) size(%d, %d)"), pos.x, pos.y, sz.x, sz.y );
651 popup->Popup();
652 }
653
654 void MyDialog::OnStartComplexPopup(wxCommandEvent& event)
655 {
656 ComplexTransientPopup* popup = new ComplexTransientPopup( this );
657 popup->GetChild()->SetScrollbars(1, 1, 1000, 1000);
658 wxWindow *btn = (wxWindow*) event.GetEventObject();
659 wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
660 wxSize sz = btn->GetSize();
661 popup->Position( pos, sz );
662 wxLogMessage( wxT("================================================") );
663 wxLogMessage( wxT("Dialog Complex Popup Shown pos(%d, %d) size(%d, %d)"), pos.x, pos.y, sz.x, sz.y );
664 popup->Popup();
665 }
666