]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/canvas/simple/simple.cpp
1 /////////////////////////////////////////////////////////////////////////////
6 /////////////////////////////////////////////////////////////////////////////
9 #pragma implementation "simple.cpp"
12 // For compilers that support precompilation
13 #include "wx/wxprec.h"
19 // Include private headers
22 // Include icon header
23 #if defined(__WXGTK__) || defined(__WXMOTIF__)
24 #include "mondrian.xpm"
30 // WDR: class implementations
32 //------------------------------------------------------------------------------
34 //------------------------------------------------------------------------------
36 // WDR: event table for MyFrame
38 BEGIN_EVENT_TABLE(MyFrame
,wxFrame
)
39 EVT_MENU(ID_QUIT
, MyFrame::OnQuit
)
40 EVT_CLOSE(MyFrame::OnCloseWindow
)
43 MyFrame::MyFrame( wxWindow
*parent
, wxWindowID id
, const wxString
&title
,
44 const wxPoint
&position
, const wxSize
& size
, long style
) :
45 wxFrame( parent
, id
, title
, position
, size
, style
)
50 SetStatusText( "Welcome!" );
52 SetIcon(wxICON(mondrian
));
56 m_admin
= new wxCanvasAdmin
;
57 wxCanvas
*canvas
= new wxCanvas( m_admin
, this, -1 );
58 m_admin
->Append( canvas
);
59 m_admin
->SetActive( canvas
);
62 wxCanvasObjectGroup
*root
= new wxCanvasObjectGroup(0,0);
63 root
->DeleteContents( TRUE
);
67 rect
= new wxCanvasRect( 120,10,120,140 );
68 rect
->SetBrush( *wxRED_BRUSH
);
72 wxBitmap bitmap( smile_xpm );
73 wxImage image( bitmap );
75 m_smile1 = new wxCanvasImage( image, 0,70,32,32 );
76 root->Append( m_smile1 );
79 for (i = 10; i < 300; i+=10)
81 wxCanvasRect *r = new wxCanvasRect( i,50,3,140 );
82 r->SetBrush( *wxRED_BRUSH );
86 m_smile2 = new wxCanvasImage( image, 0,110,32,32 );
87 root->Append( m_smile2 );
89 for (i = 15; i < 300; i+=10)
91 wxCanvasRect *r = new wxCanvasRect( i,50,3,140 );
92 r->SetBrush( *wxRED_BRUSH );
97 canvas
->SetRoot( root
);
100 void MyFrame::CreateMyMenuBar()
102 wxMenu
*file_menu
= new wxMenu
;
103 file_menu
->Append( ID_QUIT
, "Quit...", "Quit program" );
105 wxMenuBar
*menu_bar
= new wxMenuBar();
106 menu_bar
->Append( file_menu
, "File" );
108 SetMenuBar( menu_bar
);
111 // WDR: handler implementations for MyFrame
113 void MyFrame::OnQuit( wxCommandEvent
&event
)
118 void MyFrame::OnCloseWindow( wxCloseEvent
&event
)
120 // if ! saved changes -> return
125 //------------------------------------------------------------------------------
127 //------------------------------------------------------------------------------
137 MyFrame
*frame
= new MyFrame( NULL
, -1, "SuperApp", wxPoint(20,20), wxSize(500,340) );