]>
Commit | Line | Data |
---|---|---|
457814b5 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: editrpal.cpp | |
3 | // Purpose: Editor tool palette | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "editrpal.h" | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx/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 <ctype.h> | |
28 | #include <stdlib.h> | |
29 | #include <math.h> | |
30 | #include <string.h> | |
31 | ||
32 | #if defined(__WINDOWS__) && !defined(__GNUWIN32__) | |
33 | #include <strstrea.h> | |
34 | #else | |
35 | #include <strstream.h> | |
36 | #endif | |
37 | ||
38 | #include "reseditr.h" | |
39 | #include "editrpal.h" | |
40 | ||
457814b5 JS |
41 | #ifdef __X__ |
42 | #include "bitmaps/frame.xbm" | |
43 | #include "bitmaps/dialog.xbm" | |
44 | #include "bitmaps/panel.xbm" | |
45 | #include "bitmaps/canvas.xbm" | |
46 | #include "bitmaps/textsw.xbm" | |
47 | #include "bitmaps/message.xbm" | |
48 | #include "bitmaps/button.xbm" | |
49 | #include "bitmaps/check.xbm" | |
50 | #include "bitmaps/listbox.xbm" | |
51 | #include "bitmaps/radio.xbm" | |
52 | #include "bitmaps/choice.xbm" | |
53 | #include "bitmaps/text.xbm" | |
54 | #include "bitmaps/mtext.xbm" | |
55 | #include "bitmaps/slider.xbm" | |
56 | #include "bitmaps/arrow.xbm" | |
57 | #include "bitmaps/group.xbm" | |
58 | #include "bitmaps/gauge.xbm" | |
59 | #include "bitmaps/scroll.xbm" | |
60 | #include "bitmaps/picture.xbm" | |
61 | #include "bitmaps/bmpbuttn.xbm" | |
62 | #endif | |
63 | ||
64 | /* | |
65 | * Object editor tool palette | |
66 | * | |
67 | */ | |
68 | ||
69 | BEGIN_EVENT_TABLE(EditorToolPalette, wxToolBarSimple) | |
70 | EVT_PAINT(EditorToolPalette::OnPaint) | |
71 | END_EVENT_TABLE() | |
72 | ||
73 | EditorToolPalette::EditorToolPalette(wxResourceManager *manager, wxFrame *frame, int x, int y, int w, int h, | |
74 | long style, int direction, int RowsOrColumns): | |
75 | TOOLPALETTECLASS(frame, -1, wxPoint(x, y), wxSize(w, h), style, direction, RowsOrColumns) | |
76 | { | |
77 | currentlySelected = -1; | |
78 | resourceManager = manager; | |
79 | } | |
80 | ||
81 | bool EditorToolPalette::OnLeftClick(int toolIndex, bool toggled) | |
82 | { | |
83 | // BEGIN mutual exclusivity code | |
84 | if (toggled && (currentlySelected != -1) && (toolIndex != currentlySelected)) | |
85 | ToggleTool(currentlySelected, FALSE); | |
86 | ||
87 | if (toggled) | |
88 | currentlySelected = toolIndex; | |
89 | else if (currentlySelected == toolIndex) | |
90 | currentlySelected = -1; | |
91 | // END mutual exclusivity code | |
92 | /* | |
93 | if (MainFrame) | |
94 | { | |
95 | if (toggled && (toolIndex != PALETTE_ARROW)) | |
96 | MainFrame->canvas->SetCursor(crossCursor); | |
97 | else | |
98 | MainFrame->canvas->SetCursor(handCursor); | |
99 | } | |
100 | */ | |
101 | ||
102 | return TRUE; | |
103 | } | |
104 | ||
105 | void EditorToolPalette::OnMouseEnter(int toolIndex) | |
106 | { | |
107 | if (!resourceManager) return; | |
108 | wxFrame *managerFrame = resourceManager->GetEditorFrame(); | |
109 | ||
110 | if (toolIndex > -1) | |
111 | { | |
112 | switch (toolIndex) | |
113 | { | |
114 | case PALETTE_FRAME: | |
115 | managerFrame->SetStatusText("wxFrame"); | |
116 | break; | |
117 | case PALETTE_DIALOG_BOX: | |
118 | managerFrame->SetStatusText("wxDialog"); | |
119 | break; | |
120 | case PALETTE_PANEL: | |
121 | managerFrame->SetStatusText("wxPanel"); | |
122 | break; | |
ae8351fc | 123 | #if 0 |
457814b5 JS |
124 | case PALETTE_CANVAS: |
125 | managerFrame->SetStatusText("wxCanvas"); | |
126 | break; | |
127 | case PALETTE_TEXT_WINDOW: | |
128 | managerFrame->SetStatusText("wxTextWindow"); | |
129 | break; | |
ae8351fc | 130 | #endif |
457814b5 JS |
131 | case PALETTE_BUTTON: |
132 | managerFrame->SetStatusText("wxButton"); | |
133 | break; | |
134 | case PALETTE_MESSAGE: | |
ae8351fc | 135 | managerFrame->SetStatusText("wxStaticText"); |
457814b5 JS |
136 | break; |
137 | case PALETTE_TEXT: | |
ae8351fc | 138 | managerFrame->SetStatusText("wxTextCtrl (single-line)"); |
457814b5 JS |
139 | break; |
140 | case PALETTE_MULTITEXT: | |
ae8351fc | 141 | managerFrame->SetStatusText("wxTextCtrl (multi-line)"); |
457814b5 JS |
142 | break; |
143 | case PALETTE_CHOICE: | |
144 | managerFrame->SetStatusText("wxChoice"); | |
145 | break; | |
146 | case PALETTE_CHECKBOX: | |
147 | managerFrame->SetStatusText("wxCheckBox"); | |
148 | break; | |
149 | case PALETTE_RADIOBOX: | |
150 | managerFrame->SetStatusText("wxRadioBox"); | |
151 | break; | |
152 | case PALETTE_LISTBOX: | |
153 | managerFrame->SetStatusText("wxListBox"); | |
154 | break; | |
155 | case PALETTE_SLIDER: | |
156 | managerFrame->SetStatusText("wxSlider"); | |
157 | break; | |
158 | case PALETTE_GROUPBOX: | |
ae8351fc | 159 | managerFrame->SetStatusText("wxStaticBox"); |
457814b5 JS |
160 | break; |
161 | case PALETTE_GAUGE: | |
162 | managerFrame->SetStatusText("wxGauge"); | |
163 | break; | |
164 | case PALETTE_BITMAP_MESSAGE: | |
ae8351fc | 165 | managerFrame->SetStatusText("wxStaticBitmap"); |
457814b5 JS |
166 | break; |
167 | case PALETTE_BITMAP_BUTTON: | |
ae8351fc | 168 | managerFrame->SetStatusText("wxBitmapButton"); |
457814b5 JS |
169 | break; |
170 | case PALETTE_SCROLLBAR: | |
171 | managerFrame->SetStatusText("wxScrollBar"); | |
172 | break; | |
173 | case PALETTE_ARROW: | |
174 | managerFrame->SetStatusText("Pointer"); | |
175 | break; | |
176 | } | |
177 | } | |
178 | else managerFrame->SetStatusText(""); | |
179 | } | |
180 | ||
181 | void EditorToolPalette::OnPaint(wxPaintEvent& event) | |
182 | { | |
183 | TOOLPALETTECLASS::OnPaint(event); | |
184 | ||
185 | wxPaintDC dc(this); | |
186 | ||
187 | int w, h; | |
188 | GetSize(&w, &h); | |
189 | dc.SetPen(wxBLACK_PEN); | |
190 | dc.SetBrush(wxTRANSPARENT_BRUSH); | |
191 | dc.DrawLine(0, h-1, w, h-1); | |
192 | } | |
193 | ||
ae8351fc | 194 | EditorToolPalette *wxResourceManager::OnCreatePalette(wxFrame *parent) |
457814b5 JS |
195 | { |
196 | // Load palette bitmaps | |
197 | #ifdef __WINDOWS__ | |
ae8351fc JS |
198 | wxBitmap PaletteMessageBitmap("MESSAGETOOL"); |
199 | wxBitmap PaletteButtonBitmap("BUTTONTOOL"); | |
200 | wxBitmap PaletteCheckBoxBitmap("CHECKBOXTOOL"); | |
201 | wxBitmap PaletteListBoxBitmap("LISTBOXTOOL"); | |
202 | wxBitmap PaletteRadioBoxBitmap("RADIOBOXTOOL"); | |
203 | wxBitmap PaletteChoiceBitmap("CHOICETOOL"); | |
204 | wxBitmap PaletteTextBitmap("TEXTTOOL"); | |
205 | wxBitmap PaletteMultiTextBitmap("MULTITEXTTOOL"); | |
206 | wxBitmap PaletteSliderBitmap("SLIDERTOOL"); | |
207 | wxBitmap PaletteArrowBitmap("ARROWTOOL"); | |
208 | wxBitmap PaletteGroupBitmap("GROUPTOOL"); | |
209 | wxBitmap PaletteGaugeBitmap("GAUGETOOL"); | |
210 | wxBitmap PalettePictureBitmap("PICTURETOOL"); | |
211 | wxBitmap PaletteBitmapButtonBitmap("BMPBUTTONTOOL"); | |
212 | wxBitmap PaletteScrollbarBitmap("SCROLLBARTOOL"); | |
457814b5 JS |
213 | #endif |
214 | #ifdef __X__ | |
ae8351fc JS |
215 | wxBitmap PaletteMessageBitmap(message_bits, message_width, message_height); |
216 | wxBitmap PaletteButtonBitmap(button_bits, button_width, button_height); | |
217 | wxBitmap PaletteCheckBoxBitmap(check_bits, check_width, check_height); | |
218 | wxBitmap PaletteListBoxBitmap(listbox_bits, listbox_width, listbox_height); | |
219 | wxBitmap PaletteRadioBoxBitmap(radio_bits, radio_width, radio_height); | |
220 | wxBitmap PaletteChoiceBitmap(choice_bits, choice_width, choice_height); | |
221 | wxBitmap PaletteTextBitmap(text_bits, text_width, text_height); | |
222 | wxBitmap PaletteMultiTextBitmap(mtext_bits, mtext_width, mtext_height); | |
223 | wxBitmap PaletteSliderBitmap(slider_bits, slider_width, slider_height); | |
224 | wxBitmap PaletteArrowBitmap(arrow_bits, arrow_width, arrow_height); | |
225 | wxBitmap PaletteGroupBitmap(group_bits, group_width, group_height); | |
226 | wxBitmap PaletteGaugeBitmap(gauge_bits, gauge_width, gauge_height); | |
227 | wxBitmap PalettePictureBitmap(picture_bits, picture_width, picture_height); | |
228 | wxBitmap PaletteBitmapButtonBitmap(bmpbuttn_bits, bmpbuttn_width, bmpbuttn_height); | |
229 | wxBitmap PaletteScrollbarBitmap(scroll_bits, scroll_width, scroll_height); | |
457814b5 | 230 | #endif |
457814b5 | 231 | |
457814b5 JS |
232 | EditorToolPalette *palette = new EditorToolPalette(this, parent, 0, 0, -1, -1, wxNO_BORDER, // wxTB_3DBUTTONS, |
233 | wxVERTICAL, 1); | |
234 | ||
235 | palette->SetMargins(2, 2); | |
236 | /* | |
237 | #ifdef __WINDOWS__ | |
238 | if (palette->IsKindOf(CLASSINFO(wxToolBarMSW))) | |
239 | ((wxToolBarMSW *)palette)->SetDefaultSize(22, 22); | |
240 | #endif | |
241 | */ | |
242 | ||
457814b5 | 243 | palette->AddTool(PALETTE_ARROW, PaletteArrowBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "Pointer"); |
ae8351fc JS |
244 | palette->AddTool(PALETTE_MESSAGE, PaletteMessageBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxStaticText"); |
245 | palette->AddTool(PALETTE_BITMAP_MESSAGE, PalettePictureBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxStaticBitmap"); | |
457814b5 | 246 | palette->AddTool(PALETTE_BUTTON, PaletteButtonBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "Button"); |
ae8351fc | 247 | palette->AddTool(PALETTE_BITMAP_BUTTON, PaletteBitmapButtonBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxBitmapButton"); |
457814b5 JS |
248 | palette->AddTool(PALETTE_CHECKBOX, PaletteCheckBoxBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxCheckBox"); |
249 | palette->AddTool(PALETTE_RADIOBOX, PaletteRadioBoxBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxRadioBox"); | |
250 | palette->AddTool(PALETTE_LISTBOX, PaletteListBoxBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxListBox"); | |
251 | palette->AddTool(PALETTE_CHOICE, PaletteChoiceBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxChoice"); | |
ae8351fc JS |
252 | palette->AddTool(PALETTE_TEXT, PaletteTextBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxTextCtrl (single-line)"); |
253 | palette->AddTool(PALETTE_MULTITEXT, PaletteMultiTextBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxTextCtrl (multi-line)"); | |
457814b5 | 254 | palette->AddTool(PALETTE_SLIDER, PaletteSliderBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxSlider"); |
ae8351fc | 255 | palette->AddTool(PALETTE_GROUPBOX, PaletteGroupBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxStaticBox"); |
457814b5 JS |
256 | palette->AddTool(PALETTE_GAUGE, PaletteGaugeBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxGauge"); |
257 | palette->AddTool(PALETTE_SCROLLBAR, PaletteScrollbarBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxScrollBar"); | |
258 | ||
259 | palette->Layout(); | |
260 | palette->CreateTools(); | |
261 | ||
262 | palette->ToggleTool(PALETTE_ARROW, TRUE); | |
263 | palette->currentlySelected = PALETTE_ARROW; | |
264 | return palette; | |
265 | } | |
266 |