]> git.saurik.com Git - wxWidgets.git/blame - utils/ogl/samples/ogledit/palette.cpp
#included log.h
[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
3dd4e4e0 27#include <wx/toolbar.h>
f449ef69
JS
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
3dd4e4e0
JS
38// Include pixmaps
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"
45#endif
46
f449ef69
JS
47/*
48 * Object editor tool palette
49 *
50 */
51
52EditorToolPalette::EditorToolPalette(wxWindow* parent, const wxPoint& pos, const wxSize& size,
53 long style):
54 TOOLPALETTECLASS(parent, -1, pos, size, style)
55{
56 currentlySelected = -1;
57
20e85460 58#if 1 // ndef __WXGTK__
f449ef69 59 SetMaxRowsCols(1000, 1);
bec3e860 60#endif
f449ef69
JS
61}
62
63bool EditorToolPalette::OnLeftClick(int toolIndex, bool toggled)
64{
65 // BEGIN mutual exclusivity code
66 if (toggled && (currentlySelected != -1) && (toolIndex != currentlySelected))
67 ToggleTool(currentlySelected, FALSE);
68
69 if (toggled)
70 currentlySelected = toolIndex;
71 else if (currentlySelected == toolIndex)
72 currentlySelected = -1;
73 // END mutual exclusivity code
74
75 return TRUE;
76}
77
78void EditorToolPalette::OnMouseEnter(int toolIndex)
79{
80}
81
82void EditorToolPalette::SetSize(int x, int y, int width, int height, int sizeFlags)
83{
84 TOOLPALETTECLASS::SetSize(x, y, width, height, sizeFlags);
85}
86
87EditorToolPalette *MyApp::CreatePalette(wxFrame *parent)
88{
89 // Load palette bitmaps
90#ifdef __WXMSW__
91 wxBitmap PaletteTool1("TOOL1");
92 wxBitmap PaletteTool2("TOOL2");
93 wxBitmap PaletteTool3("TOOL3");
94 wxBitmap PaletteTool4("TOOL4");
95 wxBitmap PaletteArrow("ARROWTOOL");
3dd4e4e0
JS
96#elif defined(__WXGTK__) || defined(__WXMOTIF__)
97 wxBitmap PaletteTool1(tool1_xpm);
98 wxBitmap PaletteTool2(tool2_xpm);
99 wxBitmap PaletteTool3(tool3_xpm);
100 wxBitmap PaletteTool4(tool4_xpm);
101 wxBitmap PaletteArrow(arrow_xpm);
f449ef69
JS
102#endif
103
104 EditorToolPalette *palette = new EditorToolPalette(parent, wxPoint(0, 0), wxSize(-1, -1), wxTB_HORIZONTAL);
105
106 palette->SetMargins(2, 2);
107
108#ifdef __WXMSW__
109 if (palette->IsKindOf(CLASSINFO(wxToolBar95)))
110 ((wxToolBar95 *)palette)->SetToolBitmapSize(wxSize(22, 22));
111#endif
112
113 palette->AddTool(PALETTE_ARROW, PaletteArrow, wxNullBitmap, TRUE, 0, -1, NULL, "Pointer");
114 palette->AddTool(PALETTE_TOOL1, PaletteTool1, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 1");
115 palette->AddTool(PALETTE_TOOL2, PaletteTool2, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 2");
116 palette->AddTool(PALETTE_TOOL3, PaletteTool3, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 3");
117 palette->AddTool(PALETTE_TOOL4, PaletteTool4, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 4");
118
119 palette->Realize();
120
121 palette->ToggleTool(PALETTE_ARROW, TRUE);
122 palette->currentlySelected = PALETTE_ARROW;
123 return palette;
124}
125