]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/ogl/ogledit/palette.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/ogl/ogledit/palette.cpp
3 // Purpose: OGLEdit palette
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/toolbar.h"
35 #include "bitmaps/arrow.xpm"
36 #include "bitmaps/tool1.xpm"
37 #include "bitmaps/tool2.xpm"
38 #include "bitmaps/tool3.xpm"
39 #include "bitmaps/tool4.xpm"
42 * Object editor tool palette
46 EditorToolPalette::EditorToolPalette(wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
48 TOOLPALETTECLASS(parent
, wxID_ANY
, pos
, size
, style
)
50 currentlySelected
= -1;
53 bool EditorToolPalette::OnLeftClick(int toolIndex
, bool toggled
)
55 // BEGIN mutual exclusivity code
56 if (toggled
&& (currentlySelected
!= -1) && (toolIndex
!= currentlySelected
))
57 ToggleTool(currentlySelected
, false);
60 currentlySelected
= toolIndex
;
61 else if (currentlySelected
== toolIndex
)
62 currentlySelected
= -1;
63 // END mutual exclusivity code
68 void EditorToolPalette::OnMouseEnter(int WXUNUSED(toolIndex
))
72 void EditorToolPalette::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
74 TOOLPALETTECLASS::SetSize(x
, y
, width
, height
, sizeFlags
);
77 EditorToolPalette
*MyApp::CreatePalette(wxFrame
*parent
)
79 // Load palette bitmaps.
80 wxBitmap
PaletteTool1(tool1_xpm
);
81 wxBitmap
PaletteTool2(tool2_xpm
);
82 wxBitmap
PaletteTool3(tool3_xpm
);
83 wxBitmap
PaletteTool4(tool4_xpm
);
84 wxBitmap
PaletteArrow(arrow_xpm
);
86 EditorToolPalette
*palette
= new EditorToolPalette(parent
, wxPoint(0, 0), wxDefaultSize
,
89 palette
->SetMargins(2, 2);
90 palette
->SetToolBitmapSize(wxSize(22, 22));
92 palette
->AddTool(PALETTE_ARROW
, PaletteArrow
, wxNullBitmap
, true, 0, wxDefaultCoord
, NULL
, _T("Pointer"));
93 palette
->AddTool(PALETTE_TOOL1
, PaletteTool1
, wxNullBitmap
, true, 0, wxDefaultCoord
, NULL
, _T("Tool 1"));
94 palette
->AddTool(PALETTE_TOOL2
, PaletteTool2
, wxNullBitmap
, true, 0, wxDefaultCoord
, NULL
, _T("Tool 2"));
95 palette
->AddTool(PALETTE_TOOL3
, PaletteTool3
, wxNullBitmap
, true, 0, wxDefaultCoord
, NULL
, _T("Tool 3"));
96 palette
->AddTool(PALETTE_TOOL4
, PaletteTool4
, wxNullBitmap
, true, 0, wxDefaultCoord
, NULL
, _T("Tool 4"));
100 palette
->ToggleTool(PALETTE_ARROW
, true);
101 palette
->currentlySelected
= PALETTE_ARROW
;