]> git.saurik.com Git - wxWidgets.git/blame - contrib/samples/ogl/ogledit/palette.cpp
remove unfinished sample for release
[wxWidgets.git] / contrib / samples / ogl / ogledit / palette.cpp
CommitLineData
1fc25a89
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
2ba06d5a 9// Licence: wxWindows licence
1fc25a89
JS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13// #pragma implementation
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
92a19c2e 17#include "wx/wxprec.h"
1fc25a89
JS
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/toolbar.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// Include pixmaps
1fc25a89
JS
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"
1fc25a89
JS
44
45/*
46 * Object editor tool palette
47 *
48 */
49
50EditorToolPalette::EditorToolPalette(wxWindow* parent, const wxPoint& pos, const wxSize& size,
51 long style):
2ba06d5a 52 TOOLPALETTECLASS(parent, wxID_ANY, pos, size, style)
1fc25a89 53{
8e74bcb2 54 currentlySelected = -1;
1fc25a89
JS
55}
56
57bool EditorToolPalette::OnLeftClick(int toolIndex, bool toggled)
58{
59 // BEGIN mutual exclusivity code
60 if (toggled && (currentlySelected != -1) && (toolIndex != currentlySelected))
2ba06d5a 61 ToggleTool(currentlySelected, false);
1fc25a89
JS
62
63 if (toggled)
64 currentlySelected = toolIndex;
65 else if (currentlySelected == toolIndex)
66 currentlySelected = -1;
67 // END mutual exclusivity code
68
2ba06d5a 69 return true;
1fc25a89
JS
70}
71
1484b5cc 72void EditorToolPalette::OnMouseEnter(int WXUNUSED(toolIndex))
1fc25a89
JS
73{
74}
75
76void EditorToolPalette::SetSize(int x, int y, int width, int height, int sizeFlags)
77{
78 TOOLPALETTECLASS::SetSize(x, y, width, height, sizeFlags);
79}
80
81EditorToolPalette *MyApp::CreatePalette(wxFrame *parent)
82{
8e74bcb2
JS
83 // Load palette bitmaps. MSW-specific bitmaps no
84 // longer needed.
85#if 0
1484b5cc
VS
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"));
8e74bcb2 91#else
1fc25a89
JS
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);
97#endif
98
2ba06d5a 99 EditorToolPalette *palette = new EditorToolPalette(parent, wxPoint(0, 0), wxDefaultSize,
8e74bcb2 100 wxTB_VERTICAL);
1fc25a89
JS
101
102 palette->SetMargins(2, 2);
103 palette->SetToolBitmapSize(wxSize(22, 22));
104
422d0ff0
WS
105 palette->AddTool(PALETTE_ARROW, PaletteArrow, wxNullBitmap, true, 0, wxDefaultCoord, NULL, _T("Pointer"));
106 palette->AddTool(PALETTE_TOOL1, PaletteTool1, wxNullBitmap, true, 0, wxDefaultCoord, NULL, _T("Tool 1"));
107 palette->AddTool(PALETTE_TOOL2, PaletteTool2, wxNullBitmap, true, 0, wxDefaultCoord, NULL, _T("Tool 2"));
108 palette->AddTool(PALETTE_TOOL3, PaletteTool3, wxNullBitmap, true, 0, wxDefaultCoord, NULL, _T("Tool 3"));
109 palette->AddTool(PALETTE_TOOL4, PaletteTool4, wxNullBitmap, true, 0, wxDefaultCoord, NULL, _T("Tool 4"));
1fc25a89
JS
110
111 palette->Realize();
112
2ba06d5a 113 palette->ToggleTool(PALETTE_ARROW, true);
1fc25a89
JS
114 palette->currentlySelected = PALETTE_ARROW;
115 return palette;
116}
117