]> git.saurik.com Git - wxWidgets.git/blame - utils/ogl/samples/ogledit/palette.cpp
const added to GetBitmap it was my fault.
[wxWidgets.git] / utils / ogl / samples / ogledit / palette.cpp
CommitLineData
f449ef69
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: palette.cpp
3// Purpose: OGLEdit palette
4// Author: Julian Smart
5// Modified by:
6// Created: 12/07/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13// #pragma implementation
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include <wx/wxprec.h>
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24#include <wx/wx.h>
25#endif
26
27#include <wx/tbar95.h>
28
29#include <ctype.h>
30#include <stdlib.h>
31#include <math.h>
32
33#include "doc.h"
34#include "view.h"
35#include "ogledit.h"
36#include "palette.h"
37
38/*
39 * Object editor tool palette
40 *
41 */
42
43EditorToolPalette::EditorToolPalette(wxWindow* parent, const wxPoint& pos, const wxSize& size,
44 long style):
45 TOOLPALETTECLASS(parent, -1, pos, size, style)
46{
47 currentlySelected = -1;
48
49 SetMaxRowsCols(1000, 1);
50}
51
52bool EditorToolPalette::OnLeftClick(int toolIndex, bool toggled)
53{
54 // BEGIN mutual exclusivity code
55 if (toggled && (currentlySelected != -1) && (toolIndex != currentlySelected))
56 ToggleTool(currentlySelected, FALSE);
57
58 if (toggled)
59 currentlySelected = toolIndex;
60 else if (currentlySelected == toolIndex)
61 currentlySelected = -1;
62 // END mutual exclusivity code
63
64 return TRUE;
65}
66
67void EditorToolPalette::OnMouseEnter(int toolIndex)
68{
69}
70
71void EditorToolPalette::SetSize(int x, int y, int width, int height, int sizeFlags)
72{
73 TOOLPALETTECLASS::SetSize(x, y, width, height, sizeFlags);
74}
75
76EditorToolPalette *MyApp::CreatePalette(wxFrame *parent)
77{
78 // Load palette bitmaps
79#ifdef __WXMSW__
80 wxBitmap PaletteTool1("TOOL1");
81 wxBitmap PaletteTool2("TOOL2");
82 wxBitmap PaletteTool3("TOOL3");
83 wxBitmap PaletteTool4("TOOL4");
84 wxBitmap PaletteArrow("ARROWTOOL");
85#endif
86#ifdef __X__
87 wxBitmap PaletteTool1(tool1_bits, tool1_width, tool1_height);
88 wxBitmap PaletteTool2(tool2_bits, tool2_width, tool2_height);
89 wxBitmap PaletteTool3(tool3_bits, tool3_width, tool3_height);
90 wxBitmap PaletteTool4(tool4_bits, tool4_width, tool4_height);
91 wxBitmap PaletteArrow(arrow_bits, arrow_width, arrow_height);
92#endif
93
94 EditorToolPalette *palette = new EditorToolPalette(parent, wxPoint(0, 0), wxSize(-1, -1), wxTB_HORIZONTAL);
95
96 palette->SetMargins(2, 2);
97
98#ifdef __WXMSW__
99 if (palette->IsKindOf(CLASSINFO(wxToolBar95)))
100 ((wxToolBar95 *)palette)->SetToolBitmapSize(wxSize(22, 22));
101#endif
102
103 palette->AddTool(PALETTE_ARROW, PaletteArrow, wxNullBitmap, TRUE, 0, -1, NULL, "Pointer");
104 palette->AddTool(PALETTE_TOOL1, PaletteTool1, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 1");
105 palette->AddTool(PALETTE_TOOL2, PaletteTool2, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 2");
106 palette->AddTool(PALETTE_TOOL3, PaletteTool3, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 3");
107 palette->AddTool(PALETTE_TOOL4, PaletteTool4, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 4");
108
109 palette->Realize();
110
111 palette->ToggleTool(PALETTE_ARROW, TRUE);
112 palette->currentlySelected = PALETTE_ARROW;
113 return palette;
114}
115