]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/ogl/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 #include "bitmaps/arrow.xpm"
40 #include "bitmaps/tool1.xpm"
41 #include "bitmaps/tool2.xpm"
42 #include "bitmaps/tool3.xpm"
43 #include "bitmaps/tool4.xpm"
46 * Object editor tool palette
50 EditorToolPalette::EditorToolPalette(wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
52 TOOLPALETTECLASS(parent
, wxID_ANY
, pos
, size
, style
)
54 currentlySelected
= -1;
57 bool EditorToolPalette::OnLeftClick(int toolIndex
, bool toggled
)
59 // BEGIN mutual exclusivity code
60 if (toggled
&& (currentlySelected
!= -1) && (toolIndex
!= currentlySelected
))
61 ToggleTool(currentlySelected
, false);
64 currentlySelected
= toolIndex
;
65 else if (currentlySelected
== toolIndex
)
66 currentlySelected
= -1;
67 // END mutual exclusivity code
72 void EditorToolPalette::OnMouseEnter(int WXUNUSED(toolIndex
))
76 void EditorToolPalette::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
78 TOOLPALETTECLASS::SetSize(x
, y
, width
, height
, sizeFlags
);
81 EditorToolPalette
*MyApp::CreatePalette(wxFrame
*parent
)
83 // Load palette bitmaps. MSW-specific bitmaps no
86 wxBitmap
PaletteTool1(_T("TOOL1"));
87 wxBitmap
PaletteTool2(_T("TOOL2"));
88 wxBitmap
PaletteTool3(_T("TOOL3"));
89 wxBitmap
PaletteTool4(_T("TOOL4"));
90 wxBitmap
PaletteArrow(_T("ARROWTOOL"));
92 wxBitmap
PaletteTool1(tool1_xpm
);
93 wxBitmap
PaletteTool2(tool2_xpm
);
94 wxBitmap
PaletteTool3(tool3_xpm
);
95 wxBitmap
PaletteTool4(tool4_xpm
);
96 wxBitmap
PaletteArrow(arrow_xpm
);
99 EditorToolPalette
*palette
= new EditorToolPalette(parent
, wxPoint(0, 0), wxDefaultSize
,
102 palette
->SetMargins(2, 2);
103 palette
->SetToolBitmapSize(wxSize(22, 22));
105 palette
->AddTool(PALETTE_ARROW
, PaletteArrow
, wxNullBitmap
, true, 0, wxDefaultPosition
.y
, NULL
, _T("Pointer"));
106 palette
->AddTool(PALETTE_TOOL1
, PaletteTool1
, wxNullBitmap
, true, 0, wxDefaultPosition
.y
, NULL
, _T("Tool 1"));
107 palette
->AddTool(PALETTE_TOOL2
, PaletteTool2
, wxNullBitmap
, true, 0, wxDefaultPosition
.y
, NULL
, _T("Tool 2"));
108 palette
->AddTool(PALETTE_TOOL3
, PaletteTool3
, wxNullBitmap
, true, 0, wxDefaultPosition
.y
, NULL
, _T("Tool 3"));
109 palette
->AddTool(PALETTE_TOOL4
, PaletteTool4
, wxNullBitmap
, true, 0, wxDefaultPosition
.y
, NULL
, _T("Tool 4"));
113 palette
->ToggleTool(PALETTE_ARROW
, true);
114 palette
->currentlySelected
= PALETTE_ARROW
;