]>
git.saurik.com Git - wxWidgets.git/blob - samples/minifram/test.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMiniFrame sample
4 // Author: Robert Roebling
8 // Copyright: (c) Julian Smart and Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/toolbar.h"
26 #if defined(__WXGTK__) || defined(__WXMOTIF__)
27 #include "mondrian.xpm"
28 #include "bitmaps/new.xpm"
29 #include "bitmaps/open.xpm"
30 #include "bitmaps/save.xpm"
31 #include "bitmaps/copy.xpm"
32 #include "bitmaps/cut.xpm"
33 // #include "bitmaps/paste.xpm"
34 #include "bitmaps/print.xpm"
35 #include "bitmaps/preview.xpm"
36 #include "bitmaps/help.xpm"
42 // The `main program' equivalent, creating the windows and returning the
44 bool MyApp::OnInit(void)
46 // Create the main frame window
47 MyFrame
* frame
= new MyFrame((wxFrame
*) NULL
, -1, (const wxString
) "wxMiniFrame sample",
48 wxPoint(100, 100), wxSize(205, 45));
51 frame
->SetIcon(wxIcon("mondrian"));
53 frame
->SetIcon( wxIcon(mondrian_xpm
) );
57 frame
->CreateToolBar(wxNO_BORDER
|wxHORIZONTAL
|wxTB_FLAT
, ID_TOOLBAR
);
59 InitToolbar(frame
->GetToolBar());
67 bool MyApp::InitToolbar(wxToolBar
* toolBar
)
69 toolBar
->SetMargins(5, 5);
72 wxBitmap
* toolBarBitmaps
[8];
75 toolBarBitmaps
[0] = new wxBitmap("icon1");
76 toolBarBitmaps
[1] = new wxBitmap("icon2");
77 toolBarBitmaps
[2] = new wxBitmap("icon3");
78 toolBarBitmaps
[3] = new wxBitmap("icon4");
79 toolBarBitmaps
[4] = new wxBitmap("icon5");
80 toolBarBitmaps
[5] = new wxBitmap("icon6");
81 toolBarBitmaps
[6] = new wxBitmap("icon7");
82 toolBarBitmaps
[7] = new wxBitmap("icon8");
84 toolBarBitmaps
[0] = new wxBitmap( new_xpm
);
85 toolBarBitmaps
[1] = new wxBitmap( open_xpm
);
86 toolBarBitmaps
[2] = new wxBitmap( save_xpm
);
87 toolBarBitmaps
[3] = new wxBitmap( copy_xpm
);
88 toolBarBitmaps
[4] = new wxBitmap( cut_xpm
);
89 // toolBarBitmaps[5] = new wxBitmap( paste_xpm );
90 toolBarBitmaps
[5] = new wxBitmap( preview_xpm
);
91 toolBarBitmaps
[6] = new wxBitmap( print_xpm
);
92 toolBarBitmaps
[7] = new wxBitmap( help_xpm
);
102 toolBar
->AddTool(wxID_NEW
, *(toolBarBitmaps
[0]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, "New file");
103 currentX
+= width
+ 5;
104 toolBar
->AddTool(wxID_OPEN
, *(toolBarBitmaps
[1]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, "Open file");
105 currentX
+= width
+ 5;
106 toolBar
->AddTool(wxID_SAVE
, *(toolBarBitmaps
[2]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, "Save file");
107 currentX
+= width
+ 5;
108 toolBar
->AddSeparator();
109 toolBar
->AddTool(wxID_COPY
, *(toolBarBitmaps
[3]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, "Copy");
110 currentX
+= width
+ 5;
111 toolBar
->AddTool(wxID_CUT
, *(toolBarBitmaps
[4]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, "Cut");
112 currentX
+= width
+ 5;
113 toolBar
->AddTool(wxID_PASTE
, *(toolBarBitmaps
[5]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, "Paste");
114 currentX
+= width
+ 5;
115 toolBar
->AddSeparator();
116 toolBar
->AddTool(wxID_PRINT
, *(toolBarBitmaps
[6]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, "Print");
117 currentX
+= width
+ 5;
118 toolBar
->AddSeparator();
119 toolBar
->AddTool(wxID_HELP
, *(toolBarBitmaps
[7]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, "Help");
123 // Can delete the bitmaps since they're reference counted
125 for (i
= 0; i
< 8; i
++)
126 delete toolBarBitmaps
[i
];
131 BEGIN_EVENT_TABLE(MyFrame
, wxMiniFrame
)
132 EVT_CLOSE(MyFrame::OnCloseWindow
)
135 // Define my frame constructor
136 MyFrame::MyFrame(wxFrame
* parent
, wxWindowID id
, const wxString
& title
, const wxPoint
& pos
,
137 const wxSize
& size
) :
138 wxMiniFrame(parent
, id
, title
, pos
, size
)
142 // - must delete all frames except for the main one.
143 void MyFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))