]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dragimag/dragimag.cpp
Use wxBookCtrl wrapper rather than wxNotebook in common code for native book (Smartph...
[wxWidgets.git] / samples / dragimag / dragimag.cpp
index dba64848960a49a99196b0b935e572ee2b0e83ef..187c696f8ae4f12d8c74f26d2d2b8df101b2ad06 100644 (file)
@@ -91,7 +91,7 @@ void MyCanvas::OnEraseBackground(wxEraseEvent& event)
     {
         wxSize sz = GetClientSize();
         wxRect rect(0, 0, sz.x, sz.y);
-        
+
         if (event.GetDC())
         {
             wxGetApp().TileBitmap(rect, *(event.GetDC()), wxGetApp().GetBackgroundBitmap());
@@ -188,15 +188,7 @@ void MyCanvas::OnMouseEvent(wxMouseEvent& event)
                 }
                 case SHAPE_DRAG_ICON:
                 {
-                    // Can anyone explain why this test is necessary,
-                    // to prevent a gcc error?
-#if defined(__WXMOTIF__) || defined(__WXX11__)
-                    wxIcon icon(dragicon_xpm);
-#else
-                    wxIcon icon(wxICON(dragicon));
-#endif
-                    
-                    m_dragImage = new wxDragImage(icon, wxCursor(wxCURSOR_HAND));
+                    m_dragImage = new wxDragImage(wxICON(dragicon), wxCursor(wxCURSOR_HAND));
                     break;
                 }
             }
@@ -205,19 +197,19 @@ void MyCanvas::OnMouseEvent(wxMouseEvent& event)
 
             // The offset between the top-left of the shape image and the current shape position
             wxPoint beginDragHotSpot = m_dragStartPos - m_draggedShape->GetPosition();
-            
+
             // Now we do this inside the implementation: always assume
             // coordinates relative to the capture window (client coordinates)
 
             //if (fullScreen)
             //    beginDragHotSpot -= ClientToScreen(wxPoint(0, 0));
-            
+
             if (!m_dragImage->BeginDrag(beginDragHotSpot, this, fullScreen))
             {
                 delete m_dragImage;
                 m_dragImage = (wxDragImage*) NULL;
                 m_dragMode = TEST_DRAG_NONE;
-                
+
             } else
             {
                 m_dragImage->Move(event.GetPosition());
@@ -287,7 +279,7 @@ void MyCanvas::EraseShape(DragShape* shape, wxDC& dc)
 
     wxRect rect2(shape->GetRect());
     dc.SetClippingRegion(rect2.x, rect2.y, rect2.width, rect2.height);
-        
+
     wxGetApp().TileBitmap(rect, dc, wxGetApp().GetBackgroundBitmap());
 
     dc.DestroyClippingRegion();
@@ -332,19 +324,21 @@ MyFrame::MyFrame()
 {
     wxMenu *file_menu = new wxMenu();
     file_menu->Append( wxID_ABOUT, _T("&About..."));
-    file_menu->Append( TEST_USE_SCREEN, _T("&Use whole screen for dragging"), _T("Use whole screen"), true);
+    file_menu->AppendCheckItem( TEST_USE_SCREEN, _T("&Use whole screen for dragging"), _T("Use whole screen"));
     file_menu->Append( wxID_EXIT, _T("E&xit"));
-    
+
     wxMenuBar *menu_bar = new wxMenuBar();
     menu_bar->Append(file_menu, _T("&File"));
 
     SetIcon(wxICON(mondrian));
     SetMenuBar( menu_bar );
-    
+
+#if wxUSE_STATUSBAR
     CreateStatusBar(2);
     int widths[] = { -1, 100 };
     SetStatusWidths( 2, widths );
-    
+#endif // wxUSE_STATUSBAR
+
     m_canvas = new MyCanvas( this, wxID_ANY, wxPoint(0,0), wxSize(10,10) );
 }
 
@@ -357,7 +351,7 @@ void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
 {
     (void)wxMessageBox( _T("wxDragImage demo\n")
         _T("Julian Smart (c) 2000"),
-        _T("About wxDragImage Demo"), 
+        _T("About wxDragImage Demo"),
         wxICON_INFORMATION | wxOK );
 }
 
@@ -445,7 +439,7 @@ bool MyApp::TileBitmap(const wxRect& rect, wxDC& dc, wxBitmap& bitmap)
 {
     int w = bitmap.GetWidth();
     int h = bitmap.GetHeight();
-    
+
     int i, j;
     for (i = rect.x; i < rect.x + rect.width; i += w)
     {
@@ -471,14 +465,10 @@ DragShape::DragShape(const wxBitmap& bitmap)
     m_show = true;
 }
 
-DragShape::~DragShape()
-{
-}
-
 bool DragShape::HitTest(const wxPoint& pt) const
 {
     wxRect rect(GetRect());
-    return rect.Inside(pt.x, pt.y);
+    return rect.Contains(pt.x, pt.y);
 }
 
 bool DragShape::Draw(wxDC& dc, int op)
@@ -487,7 +477,7 @@ bool DragShape::Draw(wxDC& dc, int op)
     {
         wxMemoryDC memDC;
         memDC.SelectObject(m_bitmap);
-    
+
         dc.Blit(m_pos.x, m_pos.y, m_bitmap.GetWidth(), m_bitmap.GetHeight(),
             & memDC, 0, 0, op, true);