]> git.saurik.com Git - wxWidgets.git/blame - contrib/samples/ogl/ogledit/palette.cpp
Removal of second part of dsw files (as requested by Jamie Gadd).
[wxWidgets.git] / contrib / samples / ogl / ogledit / palette.cpp
CommitLineData
1fc25a89 1/////////////////////////////////////////////////////////////////////////////
f4ec6bd2 2// Name: samples/ogl/ogledit/palette.cpp
1fc25a89
JS
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
2ba06d5a 9// Licence: wxWindows licence
1fc25a89
JS
10/////////////////////////////////////////////////////////////////////////////
11
1fc25a89 12// For compilers that support precompilation, includes "wx.h".
92a19c2e 13#include "wx/wxprec.h"
1fc25a89
JS
14
15#ifdef __BORLANDC__
16#pragma hdrstop
17#endif
18
19#ifndef WX_PRECOMP
f4ec6bd2 20#include "wx/wx.h"
1fc25a89
JS
21#endif
22
f4ec6bd2 23#include "wx/toolbar.h"
1fc25a89
JS
24
25#include <ctype.h>
26#include <stdlib.h>
27#include <math.h>
28
29#include "doc.h"
30#include "view.h"
31#include "ogledit.h"
32#include "palette.h"
33
34// Include pixmaps
1fc25a89
JS
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"
1fc25a89
JS
40
41/*
42 * Object editor tool palette
43 *
44 */
45
46EditorToolPalette::EditorToolPalette(wxWindow* parent, const wxPoint& pos, const wxSize& size,
47 long style):
2ba06d5a 48 TOOLPALETTECLASS(parent, wxID_ANY, pos, size, style)
1fc25a89 49{
8e74bcb2 50 currentlySelected = -1;
1fc25a89
JS
51}
52
53bool EditorToolPalette::OnLeftClick(int toolIndex, bool toggled)
54{
55 // BEGIN mutual exclusivity code
56 if (toggled && (currentlySelected != -1) && (toolIndex != currentlySelected))
2ba06d5a 57 ToggleTool(currentlySelected, false);
1fc25a89
JS
58
59 if (toggled)
60 currentlySelected = toolIndex;
61 else if (currentlySelected == toolIndex)
62 currentlySelected = -1;
63 // END mutual exclusivity code
64
2ba06d5a 65 return true;
1fc25a89
JS
66}
67
1484b5cc 68void EditorToolPalette::OnMouseEnter(int WXUNUSED(toolIndex))
1fc25a89
JS
69{
70}
71
72void EditorToolPalette::SetSize(int x, int y, int width, int height, int sizeFlags)
73{
74 TOOLPALETTECLASS::SetSize(x, y, width, height, sizeFlags);
75}
76
77EditorToolPalette *MyApp::CreatePalette(wxFrame *parent)
78{
4e833069 79 // Load palette bitmaps.
1fc25a89
JS
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);
1fc25a89 85
2ba06d5a 86 EditorToolPalette *palette = new EditorToolPalette(parent, wxPoint(0, 0), wxDefaultSize,
8e74bcb2 87 wxTB_VERTICAL);
1fc25a89
JS
88
89 palette->SetMargins(2, 2);
90 palette->SetToolBitmapSize(wxSize(22, 22));
91
422d0ff0
WS
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"));
1fc25a89
JS
97
98 palette->Realize();
99
2ba06d5a 100 palette->ToggleTool(PALETTE_ARROW, true);
1fc25a89
JS
101 palette->currentlySelected = PALETTE_ARROW;
102 return palette;
103}