]>
Commit | Line | Data |
---|---|---|
f449ef69 JS |
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 | ||
3dd4e4e0 | 27 | #include <wx/toolbar.h> |
f449ef69 JS |
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 | ||
3dd4e4e0 JS |
38 | // Include pixmaps |
39 | #if defined(__WXGTK__) || defined(__WXMOTIF__) | |
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 | ||
f449ef69 JS |
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 | SetMaxRowsCols(1000, 1); | |
59 | } | |
60 | ||
61 | bool EditorToolPalette::OnLeftClick(int toolIndex, bool toggled) | |
62 | { | |
63 | // BEGIN mutual exclusivity code | |
64 | if (toggled && (currentlySelected != -1) && (toolIndex != currentlySelected)) | |
65 | ToggleTool(currentlySelected, FALSE); | |
66 | ||
67 | if (toggled) | |
68 | currentlySelected = toolIndex; | |
69 | else if (currentlySelected == toolIndex) | |
70 | currentlySelected = -1; | |
71 | // END mutual exclusivity code | |
72 | ||
73 | return TRUE; | |
74 | } | |
75 | ||
76 | void EditorToolPalette::OnMouseEnter(int toolIndex) | |
77 | { | |
78 | } | |
79 | ||
80 | void EditorToolPalette::SetSize(int x, int y, int width, int height, int sizeFlags) | |
81 | { | |
82 | TOOLPALETTECLASS::SetSize(x, y, width, height, sizeFlags); | |
83 | } | |
84 | ||
85 | EditorToolPalette *MyApp::CreatePalette(wxFrame *parent) | |
86 | { | |
87 | // Load palette bitmaps | |
88 | #ifdef __WXMSW__ | |
89 | wxBitmap PaletteTool1("TOOL1"); | |
90 | wxBitmap PaletteTool2("TOOL2"); | |
91 | wxBitmap PaletteTool3("TOOL3"); | |
92 | wxBitmap PaletteTool4("TOOL4"); | |
93 | wxBitmap PaletteArrow("ARROWTOOL"); | |
3dd4e4e0 JS |
94 | #elif defined(__WXGTK__) || defined(__WXMOTIF__) |
95 | wxBitmap PaletteTool1(tool1_xpm); | |
96 | wxBitmap PaletteTool2(tool2_xpm); | |
97 | wxBitmap PaletteTool3(tool3_xpm); | |
98 | wxBitmap PaletteTool4(tool4_xpm); | |
99 | wxBitmap PaletteArrow(arrow_xpm); | |
f449ef69 JS |
100 | #endif |
101 | ||
102 | EditorToolPalette *palette = new EditorToolPalette(parent, wxPoint(0, 0), wxSize(-1, -1), wxTB_HORIZONTAL); | |
103 | ||
104 | palette->SetMargins(2, 2); | |
105 | ||
106 | #ifdef __WXMSW__ | |
107 | if (palette->IsKindOf(CLASSINFO(wxToolBar95))) | |
108 | ((wxToolBar95 *)palette)->SetToolBitmapSize(wxSize(22, 22)); | |
109 | #endif | |
110 | ||
111 | palette->AddTool(PALETTE_ARROW, PaletteArrow, wxNullBitmap, TRUE, 0, -1, NULL, "Pointer"); | |
112 | palette->AddTool(PALETTE_TOOL1, PaletteTool1, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 1"); | |
113 | palette->AddTool(PALETTE_TOOL2, PaletteTool2, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 2"); | |
114 | palette->AddTool(PALETTE_TOOL3, PaletteTool3, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 3"); | |
115 | palette->AddTool(PALETTE_TOOL4, PaletteTool4, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 4"); | |
116 | ||
117 | palette->Realize(); | |
118 | ||
119 | palette->ToggleTool(PALETTE_ARROW, TRUE); | |
120 | palette->currentlySelected = PALETTE_ARROW; | |
121 | return palette; | |
122 | } | |
123 |