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>
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"
65 * Object editor tool palette
69 BEGIN_EVENT_TABLE(EditorToolPalette
, wxToolBarSimple
)
70 EVT_PAINT(EditorToolPalette::OnPaint
)
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
)
77 currentlySelected
= -1;
78 resourceManager
= manager
;
81 bool EditorToolPalette::OnLeftClick(int toolIndex
, bool toggled
)
83 // BEGIN mutual exclusivity code
84 if (toggled
&& (currentlySelected
!= -1) && (toolIndex
!= currentlySelected
))
85 ToggleTool(currentlySelected
, FALSE
);
88 currentlySelected
= toolIndex
;
89 else if (currentlySelected
== toolIndex
)
90 currentlySelected
= -1;
91 // END mutual exclusivity code
95 if (toggled && (toolIndex != PALETTE_ARROW))
96 MainFrame->canvas->SetCursor(crossCursor);
98 MainFrame->canvas->SetCursor(handCursor);
105 void EditorToolPalette::OnMouseEnter(int toolIndex
)
107 if (!resourceManager
) return;
108 wxFrame
*managerFrame
= resourceManager
->GetEditorFrame();
115 managerFrame
->SetStatusText("wxFrame");
117 case PALETTE_DIALOG_BOX
:
118 managerFrame
->SetStatusText("wxDialog");
121 managerFrame
->SetStatusText("wxPanel");
125 managerFrame
->SetStatusText("wxCanvas");
127 case PALETTE_TEXT_WINDOW
:
128 managerFrame
->SetStatusText("wxTextWindow");
132 managerFrame
->SetStatusText("wxButton");
134 case PALETTE_MESSAGE
:
135 managerFrame
->SetStatusText("wxStaticText");
138 managerFrame
->SetStatusText("wxTextCtrl (single-line)");
140 case PALETTE_MULTITEXT
:
141 managerFrame
->SetStatusText("wxTextCtrl (multi-line)");
144 managerFrame
->SetStatusText("wxChoice");
146 case PALETTE_CHECKBOX
:
147 managerFrame
->SetStatusText("wxCheckBox");
149 case PALETTE_RADIOBOX
:
150 managerFrame
->SetStatusText("wxRadioBox");
152 case PALETTE_LISTBOX
:
153 managerFrame
->SetStatusText("wxListBox");
156 managerFrame
->SetStatusText("wxSlider");
158 case PALETTE_GROUPBOX
:
159 managerFrame
->SetStatusText("wxStaticBox");
162 managerFrame
->SetStatusText("wxGauge");
164 case PALETTE_BITMAP_MESSAGE
:
165 managerFrame
->SetStatusText("wxStaticBitmap");
167 case PALETTE_BITMAP_BUTTON
:
168 managerFrame
->SetStatusText("wxBitmapButton");
170 case PALETTE_SCROLLBAR
:
171 managerFrame
->SetStatusText("wxScrollBar");
174 managerFrame
->SetStatusText("Pointer");
178 else managerFrame
->SetStatusText("");
181 void EditorToolPalette::OnPaint(wxPaintEvent
& event
)
183 TOOLPALETTECLASS::OnPaint(event
);
189 dc
.SetPen(wxBLACK_PEN
);
190 dc
.SetBrush(wxTRANSPARENT_BRUSH
);
191 dc
.DrawLine(0, h
-1, w
, h
-1);
194 EditorToolPalette
*wxResourceManager::OnCreatePalette(wxFrame
*parent
)
196 // Load palette bitmaps
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");
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
);
232 EditorToolPalette
*palette
= new EditorToolPalette(this, parent
, 0, 0, -1, -1, wxNO_BORDER
, // wxTB_3DBUTTONS,
235 palette
->SetMargins(2, 2);
238 if (palette->IsKindOf(CLASSINFO(wxToolBarMSW)))
239 ((wxToolBarMSW *)palette)->SetDefaultSize(22, 22);
243 palette
->AddTool(PALETTE_ARROW
, PaletteArrowBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "Pointer");
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");
246 palette
->AddTool(PALETTE_BUTTON
, PaletteButtonBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "Button");
247 palette
->AddTool(PALETTE_BITMAP_BUTTON
, PaletteBitmapButtonBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxBitmapButton");
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");
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)");
254 palette
->AddTool(PALETTE_SLIDER
, PaletteSliderBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxSlider");
255 palette
->AddTool(PALETTE_GROUPBOX
, PaletteGroupBitmap
, (wxBitmap
*)NULL
, TRUE
, 0, -1, NULL
, "wxStaticBox");
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");
260 palette
->CreateTools();
262 palette
->ToggleTool(PALETTE_ARROW
, TRUE
);
263 palette
->currentlySelected
= PALETTE_ARROW
;