]> git.saurik.com Git - wxWidgets.git/blob - utils/ogl/samples/studio/cspalette.cpp
added Makefile[.in] for build using wxGTK method. Note that wxGTK's createall
[wxWidgets.git] / utils / ogl / samples / studio / cspalette.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cspalette.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/laywin.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 "studio.h"
36 #include "cspalette.h"
37 #include "symbols.h"
38
39 #if defined(__WXGTK__) || defined(__WXMOTIF__)
40 #include "bitmaps/arrow.xpm"
41 #include "bitmaps/texttool.xpm"
42 #endif
43
44 /*
45 * Object editor tool palette
46 *
47 */
48
49 csEditorToolPalette::csEditorToolPalette(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
50 long style):
51 TOOLPALETTECLASS(parent, id, pos, size, style)
52 {
53 m_currentlySelected = -1;
54
55 SetMaxRowsCols(1, 1000);
56 }
57
58 bool csEditorToolPalette::OnLeftClick(int toolIndex, bool toggled)
59 {
60 // BEGIN mutual exclusivity code
61 if (toggled && (m_currentlySelected != -1) && (toolIndex != m_currentlySelected))
62 ToggleTool(m_currentlySelected, FALSE);
63
64 if (toggled)
65 m_currentlySelected = toolIndex;
66 else if (m_currentlySelected == toolIndex)
67 m_currentlySelected = -1;
68 // END mutual exclusivity code
69
70 return TRUE;
71 }
72
73 void csEditorToolPalette::OnMouseEnter(int toolIndex)
74 {
75 wxString msg("");
76 if (toolIndex == PALETTE_ARROW)
77 msg = "Pointer";
78 else if (toolIndex != -1)
79 {
80 csSymbol* symbol = wxGetApp().GetSymbolDatabase()->FindSymbol(toolIndex);
81 if (symbol)
82 msg = symbol->GetName();
83 }
84 ((wxFrame*) wxGetApp().GetTopWindow())->SetStatusText(msg);
85 }
86
87 void csEditorToolPalette::SetSize(int x, int y, int width, int height, int sizeFlags)
88 {
89 TOOLPALETTECLASS::SetSize(x, y, width, height, sizeFlags);
90 }
91
92 void csEditorToolPalette::SetSelection(int sel)
93 {
94 if ((sel != m_currentlySelected) && (m_currentlySelected != -1))
95 {
96 ToggleTool(m_currentlySelected, FALSE);
97 }
98 m_currentlySelected = sel;
99 ToggleTool(m_currentlySelected, TRUE);
100 }
101
102 bool csApp::CreatePalette(wxFrame *parent)
103 {
104 // First create a layout window
105 wxSashLayoutWindow* win = new wxSashLayoutWindow(parent, ID_LAYOUT_WINDOW_PALETTE, wxDefaultPosition, wxSize(200, 30), wxNO_BORDER|wxSW_3D|wxCLIP_CHILDREN);
106 win->SetDefaultSize(wxSize(10000, 40));
107 win->SetOrientation(wxLAYOUT_HORIZONTAL);
108 win->SetAlignment(wxLAYOUT_TOP);
109 win->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
110 win->SetSashVisible(wxSASH_BOTTOM, TRUE);
111
112 m_diagramPaletteSashWindow = win;
113
114 m_diagramPaletteSashWindow->Show(FALSE);
115
116 // Load palette bitmaps
117 #ifdef __WXMSW__
118 wxBitmap PaletteArrow("arrowtool");
119 wxBitmap TextTool("texttool");
120 #elif defined(__WXGTK__) || defined(__WXMOTIF__)
121 wxBitmap PaletteArrow(arrow_xpm);
122 wxBitmap TextTool(texttool_xpm);
123 #endif
124
125 csEditorToolPalette *palette = new csEditorToolPalette(m_diagramPaletteSashWindow, ID_DIAGRAM_PALETTE, wxPoint(0, 0), wxSize(-1, -1), wxTB_HORIZONTAL|wxNO_BORDER);
126
127 palette->SetMargins(2, 2);
128
129 palette->SetToolBitmapSize(wxSize(32, 32));
130
131 palette->AddTool(PALETTE_ARROW, PaletteArrow, wxNullBitmap, TRUE, 0, -1, NULL, "Pointer");
132 palette->AddTool(PALETTE_TEXT_TOOL, TextTool, wxNullBitmap, TRUE, 0, -1, NULL, "Text");
133
134 wxNode* node = GetSymbolDatabase()->GetSymbols().First();
135 while (node)
136 {
137 csSymbol* symbol = (csSymbol*) node->Data();
138 wxBitmap* bitmap = GetSymbolDatabase()->CreateToolBitmap(symbol);
139 palette->AddTool(symbol->GetToolId(), *bitmap, wxNullBitmap, TRUE, 0, -1, NULL, symbol->GetName());
140
141 delete bitmap;
142
143 node = node->Next();
144 }
145
146 palette->Realize();
147
148 palette->SetSelection(PALETTE_ARROW);
149 m_diagramPalette = palette;
150
151 return TRUE;
152 }
153