]> git.saurik.com Git - wxWidgets.git/blob - contrib/samples/ogl/ogledit/palette.cpp
regenerated with DESTDIR fixes
[wxWidgets.git] / contrib / samples / ogl / ogledit / palette.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #ifdef __GNUG__
13 // #pragma implementation
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include <wx/wx.h>
25 #endif
26
27 #include <wx/toolbar.h>
28
29 #include <ctype.h>
30 #include <stdlib.h>
31 #include <math.h>
32
33 #include "doc.h"
34 #include "view.h"
35 #include "ogledit.h"
36 #include "palette.h"
37
38 // Include pixmaps
39 #if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__)
40 #include "bitmaps/arrow.xpm"
41 #include "bitmaps/tool1.xpm"
42 #include "bitmaps/tool2.xpm"
43 #include "bitmaps/tool3.xpm"
44 #include "bitmaps/tool4.xpm"
45 #endif
46
47 /*
48 * Object editor tool palette
49 *
50 */
51
52 EditorToolPalette::EditorToolPalette(wxWindow* parent, const wxPoint& pos, const wxSize& size,
53 long style):
54 TOOLPALETTECLASS(parent, -1, pos, size, style)
55 {
56 currentlySelected = -1;
57
58 #if 1 // ndef __WXGTK__
59 SetMaxRowsCols(1000, 1);
60 #endif
61 }
62
63 bool EditorToolPalette::OnLeftClick(int toolIndex, bool toggled)
64 {
65 // BEGIN mutual exclusivity code
66 if (toggled && (currentlySelected != -1) && (toolIndex != currentlySelected))
67 ToggleTool(currentlySelected, FALSE);
68
69 if (toggled)
70 currentlySelected = toolIndex;
71 else if (currentlySelected == toolIndex)
72 currentlySelected = -1;
73 // END mutual exclusivity code
74
75 return TRUE;
76 }
77
78 void EditorToolPalette::OnMouseEnter(int WXUNUSED(toolIndex))
79 {
80 }
81
82 void EditorToolPalette::SetSize(int x, int y, int width, int height, int sizeFlags)
83 {
84 TOOLPALETTECLASS::SetSize(x, y, width, height, sizeFlags);
85 }
86
87 EditorToolPalette *MyApp::CreatePalette(wxFrame *parent)
88 {
89 // Load palette bitmaps
90 #ifdef __WXMSW__
91 wxBitmap PaletteTool1(_T("TOOL1"));
92 wxBitmap PaletteTool2(_T("TOOL2"));
93 wxBitmap PaletteTool3(_T("TOOL3"));
94 wxBitmap PaletteTool4(_T("TOOL4"));
95 wxBitmap PaletteArrow(_T("ARROWTOOL"));
96 #elif defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__)
97 wxBitmap PaletteTool1(tool1_xpm);
98 wxBitmap PaletteTool2(tool2_xpm);
99 wxBitmap PaletteTool3(tool3_xpm);
100 wxBitmap PaletteTool4(tool4_xpm);
101 wxBitmap PaletteArrow(arrow_xpm);
102 #endif
103
104 EditorToolPalette *palette = new EditorToolPalette(parent, wxPoint(0, 0), wxSize(-1, -1), wxTB_HORIZONTAL);
105
106 palette->SetMargins(2, 2);
107 palette->SetToolBitmapSize(wxSize(22, 22));
108
109 palette->AddTool(PALETTE_ARROW, PaletteArrow, wxNullBitmap, TRUE, 0, -1, NULL, _T("Pointer"));
110 palette->AddTool(PALETTE_TOOL1, PaletteTool1, wxNullBitmap, TRUE, 0, -1, NULL, _T("Tool 1"));
111 palette->AddTool(PALETTE_TOOL2, PaletteTool2, wxNullBitmap, TRUE, 0, -1, NULL, _T("Tool 2"));
112 palette->AddTool(PALETTE_TOOL3, PaletteTool3, wxNullBitmap, TRUE, 0, -1, NULL, _T("Tool 3"));
113 palette->AddTool(PALETTE_TOOL4, PaletteTool4, wxNullBitmap, TRUE, 0, -1, NULL, _T("Tool 4"));
114
115 palette->Realize();
116
117 palette->ToggleTool(PALETTE_ARROW, TRUE);
118 palette->currentlySelected = PALETTE_ARROW;
119 return palette;
120 }
121