1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Editor tool palette
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "editrpal.h"
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
32 #if defined(__WINDOWS__) && !defined(__GNUWIN32__)
35 #include <strstream.h>
41 // Bitmaps for palette
42 wxBitmap
*PaletteFrameBitmap
= NULL
;
43 wxBitmap
*PaletteDialogBoxBitmap
= NULL
;
44 wxBitmap
*PalettePanelBitmap
= NULL
;
45 wxBitmap
*PaletteCanvasBitmap
= NULL
;
46 wxBitmap
*PaletteTextWindowBitmap
= NULL
;
47 wxBitmap
*PaletteMessageBitmap
= NULL
;
48 wxBitmap
*PaletteButtonBitmap
= NULL
;
49 wxBitmap
*PaletteCheckBoxBitmap
= NULL
;
50 wxBitmap
*PaletteListBoxBitmap
= NULL
;
51 wxBitmap
*PaletteRadioBoxBitmap
= NULL
;
52 wxBitmap
*PaletteChoiceBitmap
= NULL
;
53 wxBitmap
*PaletteTextBitmap
= NULL
;
54 wxBitmap
*PaletteMultiTextBitmap
= NULL
;
55 wxBitmap
*PaletteSliderBitmap
= NULL
;
56 wxBitmap
*PaletteArrowBitmap
= NULL
;
57 wxBitmap
*PaletteGroupBitmap
= NULL
;
58 wxBitmap
*PaletteGaugeBitmap
= NULL
;
59 wxBitmap
*PalettePictureBitmap
= NULL
;
60 wxBitmap
*PaletteBitmapButtonBitmap
= NULL
;
61 wxBitmap
*PaletteScrollbarBitmap
= NULL
;
64 #include "bitmaps/frame.xbm"
65 #include "bitmaps/dialog.xbm"
66 #include "bitmaps/panel.xbm"
67 #include "bitmaps/canvas.xbm"
68 #include "bitmaps/textsw.xbm"
69 #include "bitmaps/message.xbm"
70 #include "bitmaps/button.xbm"
71 #include "bitmaps/check.xbm"
72 #include "bitmaps/listbox.xbm"
73 #include "bitmaps/radio.xbm"
74 #include "bitmaps/choice.xbm"
75 #include "bitmaps/text.xbm"
76 #include "bitmaps/mtext.xbm"
77 #include "bitmaps/slider.xbm"
78 #include "bitmaps/arrow.xbm"
79 #include "bitmaps/group.xbm"
80 #include "bitmaps/gauge.xbm"
81 #include "bitmaps/scroll.xbm"
82 #include "bitmaps/picture.xbm"
83 #include "bitmaps/bmpbuttn.xbm"
87 * Object editor tool palette
91 BEGIN_EVENT_TABLE(EditorToolPalette
, wxToolBarSimple
)
92 EVT_PAINT(EditorToolPalette::OnPaint
)
95 EditorToolPalette::EditorToolPalette(wxResourceManager
*manager
, wxFrame
*frame
, int x
, int y
, int w
, int h
,
96 long style
, int direction
, int RowsOrColumns
):
97 TOOLPALETTECLASS(frame
, -1, wxPoint(x
, y
), wxSize(w
, h
), style
, direction
, RowsOrColumns
)
99 currentlySelected
= -1;
100 resourceManager
= manager
;
103 bool EditorToolPalette::OnLeftClick(int toolIndex
, bool toggled
)
105 // BEGIN mutual exclusivity code
106 if (toggled
&& (currentlySelected
!= -1) && (toolIndex
!= currentlySelected
))
107 ToggleTool(currentlySelected
, FALSE
);
110 currentlySelected
= toolIndex
;
111 else if (currentlySelected
== toolIndex
)
112 currentlySelected
= -1;
113 // END mutual exclusivity code
117 if (toggled && (toolIndex != PALETTE_ARROW))
118 MainFrame->canvas->SetCursor(crossCursor);
120 MainFrame->canvas->SetCursor(handCursor);
127 void EditorToolPalette::OnMouseEnter(int toolIndex
)
129 if (!resourceManager
) return;
130 wxFrame
*managerFrame
= resourceManager
->GetEditorFrame();
137 managerFrame
->SetStatusText("wxFrame");
139 case PALETTE_DIALOG_BOX
:
140 managerFrame
->SetStatusText("wxDialog");
143 managerFrame
->SetStatusText("wxPanel");
146 managerFrame
->SetStatusText("wxCanvas");
148 case PALETTE_TEXT_WINDOW
:
149 managerFrame
->SetStatusText("wxTextWindow");
152 managerFrame
->SetStatusText("wxButton");
154 case PALETTE_MESSAGE
:
155 managerFrame
->SetStatusText("wxMessage");
158 managerFrame
->SetStatusText("wxText");
160 case PALETTE_MULTITEXT
:
161 managerFrame
->SetStatusText("wxMultiText");
164 managerFrame
->SetStatusText("wxChoice");
166 case PALETTE_CHECKBOX
:
167 managerFrame
->SetStatusText("wxCheckBox");
169 case PALETTE_RADIOBOX
:
170 managerFrame
->SetStatusText("wxRadioBox");
172 case PALETTE_LISTBOX
:
173 managerFrame
->SetStatusText("wxListBox");
176 managerFrame
->SetStatusText("wxSlider");
178 case PALETTE_GROUPBOX
:
179 managerFrame
->SetStatusText("wxGroupBox");
182 managerFrame
->SetStatusText("wxGauge");
184 case PALETTE_BITMAP_MESSAGE
:
185 managerFrame
->SetStatusText("Bitmap wxMessage");
187 case PALETTE_BITMAP_BUTTON
:
188 managerFrame
->SetStatusText("Bitmap wxButton");
190 case PALETTE_SCROLLBAR
:
191 managerFrame
->SetStatusText("wxScrollBar");
194 managerFrame
->SetStatusText("Pointer");
198 else managerFrame
->SetStatusText("");
201 void EditorToolPalette::OnPaint(wxPaintEvent
& event
)
203 TOOLPALETTECLASS::OnPaint(event
);
209 dc
.SetPen(wxBLACK_PEN
);
210 dc
.SetBrush(wxTRANSPARENT_BRUSH
);
211 dc
.DrawLine(0, h
-1, w
, h
-1);
214 bool wxResourceManager::InitializeTools(void)
216 // Load palette bitmaps
218 PaletteFrameBitmap
= new wxBitmap("FRAMETOOL");
219 PaletteDialogBoxBitmap
= new wxBitmap("DIALOGBOXTOOL");
220 PalettePanelBitmap
= new wxBitmap("PANELTOOL");
221 PaletteCanvasBitmap
= new wxBitmap("CANVASTOOL");
222 PaletteTextWindowBitmap
= new wxBitmap("TEXTWINDOWTOOL");
223 PaletteMessageBitmap
= new wxBitmap("MESSAGETOOL");
224 PaletteButtonBitmap
= new wxBitmap("BUTTONTOOL");
225 PaletteCheckBoxBitmap
= new wxBitmap("CHECKBOXTOOL");
226 PaletteListBoxBitmap
= new wxBitmap("LISTBOXTOOL");
227 PaletteRadioBoxBitmap
= new wxBitmap("RADIOBOXTOOL");
228 PaletteChoiceBitmap
= new wxBitmap("CHOICETOOL");
229 PaletteTextBitmap
= new wxBitmap("TEXTTOOL");
230 PaletteMultiTextBitmap
= new wxBitmap("MULTITEXTTOOL");
231 PaletteSliderBitmap
= new wxBitmap("SLIDERTOOL");
232 PaletteArrowBitmap
= new wxBitmap("ARROWTOOL");
233 PaletteGroupBitmap
= new wxBitmap("GROUPTOOL");
234 PaletteGaugeBitmap
= new wxBitmap("GAUGETOOL");
235 PalettePictureBitmap
= new wxBitmap("PICTURETOOL");
236 PaletteBitmapButtonBitmap
= new wxBitmap("BMPBUTTONTOOL");
237 PaletteScrollbarBitmap
= new wxBitmap("SCROLLBARTOOL");
240 PaletteFrameBitmap
= new wxBitmap(frame_bits
, frame_width
, frame_height
);
241 PaletteDialogBoxBitmap
= new wxBitmap(dialog_bits
, dialog_width
, dialog_height
);
242 PalettePanelBitmap
= new wxBitmap(panel_bits
, panel_width
, panel_height
);
243 PaletteCanvasBitmap
= new wxBitmap(canvas_bits
, canvas_width
, canvas_height
);
244 PaletteTextWindowBitmap
= new wxBitmap(textsw_bits
, textsw_width
, textsw_height
);
245 PaletteMessageBitmap
= new wxBitmap(message_bits
, message_width
, message_height
);
246 PaletteButtonBitmap
= new wxBitmap(button_bits
, button_width
, button_height
);
247 PaletteCheckBoxBitmap
= new wxBitmap(check_bits
, check_width
, check_height
);
248 PaletteListBoxBitmap
= new wxBitmap(listbox_bits
, listbox_width
, listbox_height
);
249 PaletteRadioBoxBitmap
= new wxBitmap(radio_bits
, radio_width
, radio_height
);
250 PaletteChoiceBitmap
= new wxBitmap(choice_bits
, choice_width
, choice_height
);
251 PaletteTextBitmap
= new wxBitmap(text_bits
, text_width
, text_height
);
252 PaletteMultiTextBitmap
= new wxBitmap(mtext_bits
, mtext_width
, mtext_height
);
253 PaletteSliderBitmap
= new wxBitmap(slider_bits
, slider_width
, slider_height
);
254 PaletteArrowBitmap
= new wxBitmap(arrow_bits
, arrow_width
, arrow_height
);
255 PaletteGroupBitmap
= new wxBitmap(group_bits
, group_width
, group_height
);
256 PaletteGaugeBitmap
= new wxBitmap(gauge_bits
, gauge_width
, gauge_height
);
257 PalettePictureBitmap
= new wxBitmap(picture_bits
, picture_width
, picture_height
);
258 PaletteBitmapButtonBitmap
= new wxBitmap(bmpbuttn_bits
, bmpbuttn_width
, bmpbuttn_height
);
259 PaletteScrollbarBitmap
= new wxBitmap(scroll_bits
, scroll_width
, scroll_height
);
264 EditorToolPalette
*wxResourceManager::OnCreatePalette(wxFrame
*parent
)
266 EditorToolPalette
*palette
= new EditorToolPalette(this, parent
, 0, 0, -1, -1, wxNO_BORDER
, // wxTB_3DBUTTONS,
269 palette
->SetMargins(2, 2);
272 if (palette->IsKindOf(CLASSINFO(wxToolBarMSW)))
273 ((wxToolBarMSW *)palette)->SetDefaultSize(22, 22);
277 // palette->GetDC()->SetBackground(wxLIGHT_GREY_BRUSH);
278 palette
->AddTool(PALETTE_ARROW
, PaletteArrowBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "Pointer");
280 palette->AddTool(PALETTE_FRAME, PaletteFrameBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxFrame");
281 palette->AddTool(PALETTE_DIALOG_BOX, PaletteDialogBoxBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxDialog");
282 palette->AddTool(PALETTE_PANEL, PalettePanelBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxPanel");
283 palette->AddTool(PALETTE_CANVAS, PaletteCanvasBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxCanvas");
284 palette->AddTool(PALETTE_TEXT_WINDOW, PaletteTextWindowBitmap, (wxBitmap *)NULL, TRUE, 0, -1, NULL, "wxTextWindow");
287 palette
->AddTool(PALETTE_MESSAGE
, PaletteMessageBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxMessage");
288 palette
->AddTool(PALETTE_BITMAP_MESSAGE
, PalettePictureBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "Picture wxMessage");
289 palette
->AddTool(PALETTE_BUTTON
, PaletteButtonBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "Button");
290 palette
->AddTool(PALETTE_BITMAP_BUTTON
, PaletteBitmapButtonBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "Picture wxButton");
291 palette
->AddTool(PALETTE_CHECKBOX
, PaletteCheckBoxBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxCheckBox");
292 palette
->AddTool(PALETTE_RADIOBOX
, PaletteRadioBoxBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxRadioBox");
293 palette
->AddTool(PALETTE_LISTBOX
, PaletteListBoxBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxListBox");
294 palette
->AddTool(PALETTE_CHOICE
, PaletteChoiceBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxChoice");
295 palette
->AddTool(PALETTE_TEXT
, PaletteTextBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxText");
296 palette
->AddTool(PALETTE_MULTITEXT
, PaletteMultiTextBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxMultiText");
297 palette
->AddTool(PALETTE_SLIDER
, PaletteSliderBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxSlider");
298 palette
->AddTool(PALETTE_GROUPBOX
, PaletteGroupBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxGroupBox");
299 palette
->AddTool(PALETTE_GAUGE
, PaletteGaugeBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxGauge");
300 palette
->AddTool(PALETTE_SCROLLBAR
, PaletteScrollbarBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxScrollBar");
303 palette
->CreateTools();
305 palette
->ToggleTool(PALETTE_ARROW
, TRUE
);
306 palette
->currentlySelected
= PALETTE_ARROW
;