]> git.saurik.com Git - wxWidgets.git/blob - contrib/samples/ogl/ogledit/palette.cpp
Use 'wx/' for contrib samples and make wxTinderbox properly rebuilded after commits...
[wxWidgets.git] / contrib / samples / ogl / ogledit / palette.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/ogl/ogledit/palette.cpp
3 // Purpose: OGLEdit palette
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 12/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/wx.h"
21 #endif
22
23 #include "wx/toolbar.h"
24
25 #include <ctype.h>
26 #include <stdlib.h>
27 #include <math.h>
28
29 #include "doc.h"
30 #include "view.h"
31 #include "ogledit.h"
32 #include "palette.h"
33
34 // Include pixmaps
35 #include "bitmaps/arrow.xpm"
36 #include "bitmaps/tool1.xpm"
37 #include "bitmaps/tool2.xpm"
38 #include "bitmaps/tool3.xpm"
39 #include "bitmaps/tool4.xpm"
40
41 /*
42 * Object editor tool palette
43 *
44 */
45
46 EditorToolPalette::EditorToolPalette(wxWindow* parent, const wxPoint& pos, const wxSize& size,
47 long style):
48 TOOLPALETTECLASS(parent, wxID_ANY, pos, size, style)
49 {
50 currentlySelected = -1;
51 }
52
53 bool EditorToolPalette::OnLeftClick(int toolIndex, bool toggled)
54 {
55 // BEGIN mutual exclusivity code
56 if (toggled && (currentlySelected != -1) && (toolIndex != currentlySelected))
57 ToggleTool(currentlySelected, false);
58
59 if (toggled)
60 currentlySelected = toolIndex;
61 else if (currentlySelected == toolIndex)
62 currentlySelected = -1;
63 // END mutual exclusivity code
64
65 return true;
66 }
67
68 void EditorToolPalette::OnMouseEnter(int WXUNUSED(toolIndex))
69 {
70 }
71
72 void EditorToolPalette::SetSize(int x, int y, int width, int height, int sizeFlags)
73 {
74 TOOLPALETTECLASS::SetSize(x, y, width, height, sizeFlags);
75 }
76
77 EditorToolPalette *MyApp::CreatePalette(wxFrame *parent)
78 {
79 // Load palette bitmaps.
80 wxBitmap PaletteTool1(tool1_xpm);
81 wxBitmap PaletteTool2(tool2_xpm);
82 wxBitmap PaletteTool3(tool3_xpm);
83 wxBitmap PaletteTool4(tool4_xpm);
84 wxBitmap PaletteArrow(arrow_xpm);
85
86 EditorToolPalette *palette = new EditorToolPalette(parent, wxPoint(0, 0), wxDefaultSize,
87 wxTB_VERTICAL);
88
89 palette->SetMargins(2, 2);
90 palette->SetToolBitmapSize(wxSize(22, 22));
91
92 palette->AddTool(PALETTE_ARROW, PaletteArrow, wxNullBitmap, true, 0, wxDefaultCoord, NULL, _T("Pointer"));
93 palette->AddTool(PALETTE_TOOL1, PaletteTool1, wxNullBitmap, true, 0, wxDefaultCoord, NULL, _T("Tool 1"));
94 palette->AddTool(PALETTE_TOOL2, PaletteTool2, wxNullBitmap, true, 0, wxDefaultCoord, NULL, _T("Tool 2"));
95 palette->AddTool(PALETTE_TOOL3, PaletteTool3, wxNullBitmap, true, 0, wxDefaultCoord, NULL, _T("Tool 3"));
96 palette->AddTool(PALETTE_TOOL4, PaletteTool4, wxNullBitmap, true, 0, wxDefaultCoord, NULL, _T("Tool 4"));
97
98 palette->Realize();
99
100 palette->ToggleTool(PALETTE_ARROW, true);
101 palette->currentlySelected = PALETTE_ARROW;
102 return palette;
103 }