1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: OGLEdit palette
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 // #pragma implementation
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include <wx/laywin.h>
36 #include "cspalette.h"
39 #if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__)
40 #include "bitmaps/arrow.xpm"
41 #include "bitmaps/texttool.xpm"
45 * Object editor tool palette
49 csEditorToolPalette::csEditorToolPalette(wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
51 TOOLPALETTECLASS(parent
, id
, pos
, size
, style
)
53 m_currentlySelected
= -1;
55 SetMaxRowsCols(1, 1000);
58 bool csEditorToolPalette::OnLeftClick(int toolIndex
, bool toggled
)
60 // BEGIN mutual exclusivity code
61 if (toggled
&& (m_currentlySelected
!= -1) && (toolIndex
!= m_currentlySelected
))
62 ToggleTool(m_currentlySelected
, false);
65 m_currentlySelected
= toolIndex
;
66 else if (m_currentlySelected
== toolIndex
)
67 m_currentlySelected
= -1;
68 // END mutual exclusivity code
73 void csEditorToolPalette::OnMouseEnter(int toolIndex
)
76 wxString msg
= wxEmptyString
;
77 if (toolIndex
== PALETTE_ARROW
)
79 else if (toolIndex
!= -1)
81 csSymbol
* symbol
= wxGetApp().GetSymbolDatabase()->FindSymbol(toolIndex
);
83 msg
= symbol
->GetName();
85 ((wxFrame
*) wxGetApp().GetTopWindow())->SetStatusText(msg
);
87 wxUnusedVar(toolIndex
);
88 #endif // wxUSE_STATUSBAR
91 void csEditorToolPalette::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
93 TOOLPALETTECLASS::SetSize(x
, y
, width
, height
, sizeFlags
);
96 void csEditorToolPalette::SetSelection(int sel
)
98 if ((sel
!= m_currentlySelected
) && (m_currentlySelected
!= -1))
100 ToggleTool(m_currentlySelected
, false);
102 m_currentlySelected
= sel
;
103 ToggleTool(m_currentlySelected
, true);
106 bool csApp::CreatePalette(wxFrame
*parent
)
108 // First create a layout window
109 wxSashLayoutWindow
* win
= new wxSashLayoutWindow(parent
, ID_LAYOUT_WINDOW_PALETTE
, wxDefaultPosition
, wxSize(200, 30), wxNO_BORDER
|wxSW_3D
|wxCLIP_CHILDREN
);
110 win
->SetDefaultSize(wxSize(10000, 40));
111 win
->SetOrientation(wxLAYOUT_HORIZONTAL
);
112 win
->SetAlignment(wxLAYOUT_TOP
);
113 win
->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
));
114 win
->SetSashVisible(wxSASH_BOTTOM
, true);
116 m_diagramPaletteSashWindow
= win
;
118 m_diagramPaletteSashWindow
->Show(false);
120 // Load palette bitmaps
122 wxBitmap
PaletteArrow(_T("arrowtool"));
123 wxBitmap
TextTool(_T("texttool"));
124 wxSize
toolBitmapSize(32, 32);
125 #elif defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__)
126 wxBitmap
PaletteArrow(arrow_xpm
);
127 wxBitmap
TextTool(texttool_xpm
);
128 wxSize
toolBitmapSize(22, 22);
131 csEditorToolPalette
*palette
= new csEditorToolPalette(m_diagramPaletteSashWindow
, ID_DIAGRAM_PALETTE
, wxPoint(0, 0), wxDefaultSize
, wxTB_HORIZONTAL
|wxNO_BORDER
);
133 palette
->SetMargins(2, 2);
135 palette
->SetToolBitmapSize(toolBitmapSize
);
137 palette
->AddTool(PALETTE_ARROW
, PaletteArrow
, wxNullBitmap
, true, 0, wxDefaultCoord
, NULL
, _T("Pointer"));
138 palette
->AddTool(PALETTE_TEXT_TOOL
, TextTool
, wxNullBitmap
, true, 0, wxDefaultCoord
, NULL
, _T("Text"));
140 wxChar
** symbols
= new wxChar
*[20];
143 symbols
[noSymbols
] = _T("Wide Rectangle");
146 symbols
[noSymbols
] = _T("Thin Rectangle");
149 symbols
[noSymbols
] = _T("Triangle");
152 symbols
[noSymbols
] = _T("Octagon");
155 // For some reason, we're getting Gdk errors with
156 // some shapes, such as ones that use DrawEllipse.
158 symbols
[noSymbols
] = _T("Group");
161 symbols
[noSymbols
] = _T("Circle");
164 symbols
[noSymbols
] = _T("Circle shadow");
167 symbols
[noSymbols
] = _T("SemiCircle");
172 for (i
= 0; i
< noSymbols
; i
++)
174 csSymbol
* symbol
= GetSymbolDatabase()->FindSymbol(symbols
[i
]);
177 wxBitmap
* bitmap
= GetSymbolDatabase()->CreateToolBitmap(symbol
, toolBitmapSize
);
178 palette
->AddTool(symbol
->GetToolId(), *bitmap
, wxNullBitmap
, true, 0, wxDefaultCoord
, NULL
, symbol
->GetName());
186 wxNode
* node
= GetSymbolDatabase()->GetSymbols().First();
189 csSymbol
* symbol
= (csSymbol
*) node
->Data();
191 wxBitmap
* bitmap
= GetSymbolDatabase()->CreateToolBitmap(symbol
, toolBitmapSize
);
192 palette
->AddTool(symbol
->GetToolId(), *bitmap
, wxNullBitmap
, true, 0, wxDefaultCoord
, NULL
, symbol
->GetName());
202 palette
->SetSelection(PALETTE_ARROW
);
203 m_diagramPalette
= palette
;