]>
git.saurik.com Git - wxWidgets.git/blob - utils/ogl/samples/ogledit/palette.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: OGLEdit palette
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 // #pragma implementation
16 // For compilers that support precompilation, includes "wx.h".
17 #include <wx/wxprec.h>
27 #include <wx/toolbar.h>
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"
48 * Object editor tool palette
52 EditorToolPalette::EditorToolPalette(wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
54 TOOLPALETTECLASS(parent
, -1, pos
, size
, style
)
56 currentlySelected
= -1;
58 SetMaxRowsCols(1000, 1);
61 bool EditorToolPalette::OnLeftClick(int toolIndex
, bool toggled
)
63 // BEGIN mutual exclusivity code
64 if (toggled
&& (currentlySelected
!= -1) && (toolIndex
!= currentlySelected
))
65 ToggleTool(currentlySelected
, FALSE
);
68 currentlySelected
= toolIndex
;
69 else if (currentlySelected
== toolIndex
)
70 currentlySelected
= -1;
71 // END mutual exclusivity code
76 void EditorToolPalette::OnMouseEnter(int toolIndex
)
80 void EditorToolPalette::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
82 TOOLPALETTECLASS::SetSize(x
, y
, width
, height
, sizeFlags
);
85 EditorToolPalette
*MyApp::CreatePalette(wxFrame
*parent
)
87 // Load palette bitmaps
89 wxBitmap
PaletteTool1("TOOL1");
90 wxBitmap
PaletteTool2("TOOL2");
91 wxBitmap
PaletteTool3("TOOL3");
92 wxBitmap
PaletteTool4("TOOL4");
93 wxBitmap
PaletteArrow("ARROWTOOL");
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
);
102 EditorToolPalette
*palette
= new EditorToolPalette(parent
, wxPoint(0, 0), wxSize(-1, -1), wxTB_HORIZONTAL
);
104 palette
->SetMargins(2, 2);
107 if (palette
->IsKindOf(CLASSINFO(wxToolBar95
)))
108 ((wxToolBar95
*)palette
)->SetToolBitmapSize(wxSize(22, 22));
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");
119 palette
->ToggleTool(PALETTE_ARROW
, TRUE
);
120 palette
->currentlySelected
= PALETTE_ARROW
;