+BEGIN_EVENT_TABLE(MainFrame, wxFrame)
+ EVT_MENU(Show_Shaped, MainFrame::OnShowShaped)
+ EVT_MENU(Show_Transparent, MainFrame::OnShowTransparent)
+ EVT_MENU_RANGE(Show_Effect_First, Show_Effect_Last, MainFrame::OnShowEffect)
+END_EVENT_TABLE()
+
+MainFrame::MainFrame()
+ : wxFrame(NULL, wxID_ANY, "wxWidgets Shaped Sample",
+ wxDefaultPosition, wxSize(200, 100))
+{
+ SetIcon(wxICON(sample));
+
+ wxMenuBar * const mbar = new wxMenuBar;
+ wxMenu * const menuFrames = new wxMenu;
+ menuFrames->Append(Show_Shaped, "Show &shaped window\tCtrl-S");
+ menuFrames->Append(Show_Transparent, "Show &transparent window\tCtrl-T");
+ menuFrames->AppendSeparator();
+ menuFrames->Append(Show_Effect_Roll, "Show &rolled effect\tCtrl-R");
+ menuFrames->Append(Show_Effect_Slide, "Show s&lide effect\tCtrl-L");
+ menuFrames->Append(Show_Effect_Blend, "Show &fade effect\tCtrl-F");
+ menuFrames->Append(Show_Effect_Expand, "Show &expand effect\tCtrl-E");
+ menuFrames->AppendSeparator();
+ menuFrames->Append(wxID_EXIT, "E&xit");
+
+ mbar->Append(menuFrames, "&Show");
+ SetMenuBar(mbar);
+
+ Show();
+}
+
+void MainFrame::OnShowShaped(wxCommandEvent& WXUNUSED(event))
+{
+ ShapedFrame *shapedFrame = new ShapedFrame(this);
+ shapedFrame->Show(true);
+}
+
+void MainFrame::OnShowTransparent(wxCommandEvent& WXUNUSED(event))
+{
+ SeeThroughFrame *seeThroughFrame = new SeeThroughFrame();
+ seeThroughFrame->Show(true);
+}
+
+void MainFrame::OnShowEffect(wxCommandEvent& event)
+{
+ int effect = event.GetId();
+ static wxDirection direction = wxLEFT;
+ direction = (wxDirection)(((int)direction)<< 1);
+ if ( direction > wxDOWN )
+ direction = wxLEFT ;
+
+ wxShowEffect eff;
+ switch ( effect )
+ {
+ case Show_Effect_Roll:
+ switch ( direction )
+ {
+ case wxLEFT:
+ eff = wxSHOW_EFFECT_ROLL_TO_LEFT;
+ break;
+ case wxRIGHT:
+ eff = wxSHOW_EFFECT_ROLL_TO_RIGHT;
+ break;
+ case wxTOP:
+ eff = wxSHOW_EFFECT_ROLL_TO_TOP;
+ break;
+ case wxBOTTOM:
+ eff = wxSHOW_EFFECT_ROLL_TO_BOTTOM;
+ break;
+ default:
+ wxFAIL_MSG( "invalid direction" );
+ return;
+ }
+ break;
+ case Show_Effect_Slide:
+ switch ( direction )
+ {
+ case wxLEFT:
+ eff = wxSHOW_EFFECT_SLIDE_TO_LEFT;
+ break;
+ case wxRIGHT:
+ eff = wxSHOW_EFFECT_SLIDE_TO_RIGHT;
+ break;
+ case wxTOP:
+ eff = wxSHOW_EFFECT_SLIDE_TO_TOP;
+ break;
+ case wxBOTTOM:
+ eff = wxSHOW_EFFECT_SLIDE_TO_BOTTOM;
+ break;
+ default:
+ wxFAIL_MSG( "invalid direction" );
+ return;
+ }
+ break;
+
+ case Show_Effect_Blend:
+ eff = wxSHOW_EFFECT_BLEND;
+ break;
+
+ case Show_Effect_Expand:
+ eff = wxSHOW_EFFECT_EXPAND;
+ break;
+
+ default:
+ wxFAIL_MSG( "invalid effect" );
+ return;
+ }
+
+ new EffectFrame(this, eff, 1000);
+}
+
+// ----------------------------------------------------------------------------
+// shaped frame
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(ShapedFrame, wxFrame)
+ EVT_LEFT_DCLICK(ShapedFrame::OnDoubleClick)
+ EVT_LEFT_DOWN(ShapedFrame::OnLeftDown)
+ EVT_LEFT_UP(ShapedFrame::OnLeftUp)
+ EVT_MOTION(ShapedFrame::OnMouseMove)
+ EVT_RIGHT_UP(ShapedFrame::OnExit)
+ EVT_PAINT(ShapedFrame::OnPaint)
+END_EVENT_TABLE()
+
+