18 #pragma implementation
24 #include "wx/canvas/canorderdlg.h"
26 const int ORDER_LIST_SELECT = wxID_HIGHEST + 5108 ;
35 int n, const wxString choices[],
long style )
36 : wxListBox ( parent,
id, pos, size, n, choices, style )
41 void a2dDragListBox::OnMouseLeftDown(
class wxMouseEvent& event )
43 wxPoint point = wxPoint( event.m_x, event.m_y );
44 m_selection = HitTest( point );
49 void a2dDragListBox::OnMouseLeftUp(
class wxMouseEvent& event )
51 int pasteLoc = GetSelection();
52 if ( m_selection != -1 && m_selection != pasteLoc )
54 if ( m_selection < pasteLoc )
57 for ( row = m_selection; row < pasteLoc; row++ )
59 wxString selectLocStr = GetString( row );
60 wxString copyLocStr = GetString( row + 1 );
62 SetString( row, copyLocStr );
63 SetString( row + 1, selectLocStr );
70 for ( row = m_selection; row > pasteLoc; row-- )
72 wxString selectLocStr = GetString( row );
73 wxString copyLocStr = GetString( row - 1 );
75 SetString( row, copyLocStr );
76 SetString( row - 1, selectLocStr );
84 void a2dDragListBox::CmListBox( wxCommandEvent& selevent )
86 m_selection = GetSelection();
91 const int ORDER_BUTTON_OK = wxID_HIGHEST + 5101 ;
92 const int ORDER_BUTTON_CANCEL = wxID_HIGHEST + 5102 ;
94 const int ORDER_BUTTON_UP = wxID_HIGHEST + 5103 ;
96 const int ORDER_BUTTON_DOWN = wxID_HIGHEST + 5104 ;
98 const int ORDER_BUTTON_SHOW = wxID_HIGHEST + 5106 ;
100 const int ORDER_UPDATE_DIALOG = wxID_HIGHEST + 5107 ;
123 wxDialog( parent, ORDER_UPDATE_DIALOG, title, wxPoint( 0, 0 ), wxSize( 200, 500 ), style, name )
125 m_habitat = m_habitat;
132 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer( wxHORIZONTAL );
133 itemDialog1->SetSizer( itemBoxSizer2 );
135 wxString* m_listboxStrings = NULL;
136 m_listbox =
new a2dDragListBox( itemDialog1, ORDER_LIST_SELECT, wxDefaultPosition, wxSize( 100, 500 ), 0, m_listboxStrings, wxLB_SINGLE | wxLB_NEEDED_SB );
137 m_listbox->SetHelpText( _(
"Select a layer and press up or down button" ) );
138 m_listbox->SetToolTip( _(
"Select a layer and press up or down button" ) );
139 itemBoxSizer2->Add( m_listbox, 1, wxGROW | wxALL, 0 );
141 wxBoxSizer* itemBoxSizer4 =
new wxBoxSizer( wxVERTICAL );
142 itemBoxSizer2->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0 );
144 m_buttonOK =
new wxButton( itemDialog1, ORDER_BUTTON_OK, _(
"Hide" ), wxDefaultPosition, wxSize( 55, 22 ), 0 );
145 itemBoxSizer4->Add( m_buttonOK, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0 );
147 m_buttonCANCEL =
new wxButton( itemDialog1, ORDER_BUTTON_CANCEL, _(
"Cancel" ), wxDefaultPosition, wxSize( 55, 22 ), 0 );
148 itemBoxSizer4->Add( m_buttonCANCEL, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0 );
150 itemBoxSizer4->Add( 5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
152 m_buttonUP =
new wxButton( itemDialog1, ORDER_BUTTON_UP, _(
"Up" ), wxDefaultPosition, wxSize( 55, 22 ), 0 );
153 itemBoxSizer4->Add( m_buttonUP, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0 );
155 m_buttonDOWN =
new wxButton( itemDialog1, ORDER_BUTTON_DOWN, _(
"Down" ), wxDefaultPosition, wxSize( 55, 22 ), 0 );
156 itemBoxSizer4->Add( m_buttonDOWN, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0 );
158 m_buttonSHOW =
new wxButton( itemDialog1, ORDER_BUTTON_SHOW, _(
"Apply" ), wxDefaultPosition, wxSize( 55, 22 ), 0 );
159 itemBoxSizer4->Add( m_buttonSHOW, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0 );
161 GetSizer()->Fit(
this );
162 GetSizer()->SetSizeHints(
this );
180 m_layersetup = layersetup;
185 for ( j = 0; j < wxMAXLAYER; j++ )
188 if ( layerinfo != wxNullLayerInfo )
192 wxSnprintf( _buf,
sizeof( _buf ), wxT(
"%04d %s" ), j, layerinfo->
GetName().c_str() );
193 m_listbox->Append( _buf );
199 wxSnprintf( _buf,
sizeof( _buf ), wxT(
"%04d ND %s" ), j, layerinfo->
GetName().c_str() );
200 m_listbox->Append( _buf );
209 for (
int i = 0; i < wxMAXLAYER; i++ )
211 layernr = m_listbox->GetString( i ).Left( 4 );
213 if ( layerinfo != wxNullLayerInfo )
220 SetEvtHandlerEnabled(
false );
222 ProcessEvent( changedlayers );
223 SetEvtHandlerEnabled(
true );
228 int selection = m_listbox->GetSelection();
229 m_listbox->SetSelection( selection, FALSE );
237 int selection = m_listbox->GetSelection();
238 m_listbox->SetSelection( selection, FALSE );
245 wxCommandEvent a = wxCommandEvent();
261 int selection = m_listbox->GetSelection();
262 if ( selection == -1 )
263 ( void )wxMessageBox( _T(
"You must select a layer first" ), _T(
"a2dLayerOrderDlg" ), wxICON_INFORMATION | wxOK );
266 if ( selection != 0 )
268 if ( selection == wxMAXLAYER - 1 ) m_buttonDOWN->Enable( TRUE );
270 wxString selected = m_listbox->GetString( m_listbox->GetSelection() - 1 );
272 m_listbox->SetString( selection - 1, m_listbox->GetString( selection ) );
273 m_listbox->SetString( selection, selected );
274 m_listbox->Show( TRUE );
277 m_listbox->SetSelection( selection, FALSE );
278 m_listbox->SetSelection( selection - 1, TRUE );
279 if ( selection == 1 )
280 m_buttonUP->Enable( FALSE );
284 ( void )wxMessageBox( _T(
"layer is allready at the highest possible order" ), _T(
"a2dLayerOrderDlg" ), wxICON_INFORMATION | wxOK );
291 int selection = m_listbox->GetSelection();
293 if ( selection == -1 )
294 ( void )wxMessageBox( _T(
"You must select a layer first" ), _T(
"a2dLayerOrderDlg" ), wxICON_INFORMATION | wxOK );
297 if ( selection != wxMAXLAYER - 1 )
299 if ( selection == 0 ) m_buttonUP->Enable( TRUE );
301 wxString selected = m_listbox->GetString( m_listbox->GetSelection() + 1 );
303 m_listbox->SetString( selection + 1, m_listbox->GetString( selection ) );
304 m_listbox->SetString( selection, selected );
305 m_listbox->Show( TRUE );
308 m_listbox->SetSelection( selection, FALSE );
309 m_listbox->SetSelection( selection + 1, TRUE );
311 if ( selection == wxMAXLAYER - 2 ) m_buttonDOWN->Enable( FALSE );
315 ( void )wxMessageBox( _T(
"layer is allready at the lowest possible order" ), _T(
"a2dLayerOrderDlg" ), wxICON_INFORMATION | wxOK );
322 int selection = m_listbox->GetSelection();
323 m_buttonUP->Enable( selection != 0 );
324 m_buttonDOWN->Enable( selection != wxMAXLAYER - 1 );
326 m_habitat->
SetLayer( selection,
true );
329 void a2dLayerOrderDlg::OnComEvent(
a2dComEvent& event )
331 if ( GetEvtHandlerEnabled() )
336 if ( doc && doc == m_layersetup->
GetRoot() )
342 if ( doc && doc == m_layersetup->
GetRoot() )
349 Init( m_layersetup );
361 EVT_BUTTON ( ORDER_BUTTON_CANCEL,
a2dLayerDlg::CmCancel )
362 EVT_LISTBOX ( ORDER_LIST_SELECT,
a2dLayerDlg::CmListBox )
368 wxDialog( parent, ORDER_UPDATE_DIALOG, title, wxPoint( 0, 0 ), wxSize( 200, 500 ), wxDEFAULT_DIALOG_STYLE, name )
370 m_habitat = m_habitat;
373 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer( wxHORIZONTAL );
374 itemDialog1->SetSizer( itemBoxSizer2 );
376 wxString* m_listboxStrings = NULL;
377 m_listbox =
new wxListBox( itemDialog1, ORDER_LIST_SELECT, wxDefaultPosition, wxSize( 100, 500 ), 0, m_listboxStrings, wxLB_SINGLE | wxLB_NEEDED_SB );
378 m_listbox->SetHelpText( _(
"Select a layer and press up or down button" ) );
379 m_listbox->SetToolTip( _(
"Select a layer and press up or down button" ) );
380 itemBoxSizer2->Add( m_listbox, 1, wxGROW | wxALL, 0 );
382 wxBoxSizer* itemBoxSizer4 =
new wxBoxSizer( wxVERTICAL );
383 itemBoxSizer2->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0 );
387 m_buttonOK =
new wxButton( itemDialog1, ORDER_BUTTON_OK, _(
"Oke" ), wxDefaultPosition, wxSize( 55, 22 ), 0 );
389 m_buttonOK =
new wxButton( itemDialog1, ORDER_BUTTON_OK, _(
"Hide" ), wxDefaultPosition, wxSize( 55, 22 ), 0 );
390 itemBoxSizer4->Add( m_buttonOK, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0 );
392 m_buttonCANCEL =
new wxButton( itemDialog1, ORDER_BUTTON_CANCEL, _(
"Cancel" ), wxDefaultPosition, wxSize( 55, 22 ), 0 );
393 itemBoxSizer4->Add( m_buttonCANCEL, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0 );
395 itemBoxSizer4->Add( 5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
397 GetSizer()->Fit(
this );
398 GetSizer()->SetSizeHints(
this );
415 m_layersetup = layersetup;
420 for ( j = 0; j < wxMAXLAYER; j++ )
428 if ( layerinfo != wxNullLayerInfo )
432 wxSnprintf( _buf,
sizeof( _buf ), wxT(
"%04d %s" ), j, layerinfo->
GetName().c_str() );
433 m_listbox->Append( _buf );
444 SetReturnCode( wxID_OK );
452 EndModal( wxID_CANCEL );
455 SetReturnCode( wxID_CANCEL );
463 EndModal( wxID_CANCEL );
466 SetReturnCode( wxID_CANCEL );
482 if ( GetEvtHandlerEnabled() )
492 if ( doc && doc == m_layersetup->
GetRoot() )
498 if ( doc && doc == m_layersetup->
GetRoot() )
505 Init( m_layersetup );
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
void CmShow(wxCommandEvent &)
Show new layerorder if the SHOW-button is pressed.
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
void SetLayer(wxUint16 layer, bool setStyleOfLayer=false)
void CmCancel(wxCommandEvent &)
Close window if CANCEL-button is pressed.
a2dCanvasObject * GetRootObject() const
get the root object, which holds the objects in the document
a2dDrawing * GetRoot() const
get a2dCanvasDocument of the object.
void ConnectEvent(wxEventType type, wxEvtHandler *eventSink)
bool m_onOrder
drawing order in listbox instead of layer id
void OnCloseWindow(wxCloseEvent &event)
Close window if EXIT-button is pressed.
a2dCanvasObject is the base class for Canvas Objects.
std::vector< a2dLayerInfoPtr > & GetLayerIndex()
return array index on Layer
void CmListBox(wxCommandEvent &)
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
void CmCancel(wxCommandEvent &)
Close window if CANCEL-button is pressed.
static const a2dSignal sig_layersetupChanged
layer info changed id sent around when m_layersetup is changed.
~a2dLayerOrderDlg()
destructor.
a2dDrawingPart * GetActiveDrawingPart()
return the currently/last active drawing part.
void CmListBox(wxCommandEvent &)
void CmOk(wxCommandEvent &)
Close window if OK-button is pressed.
virtual wxString GetName() const
Get name for layer.
static const a2dSignal sig_changedActiveDrawing
when active drawing is set, this signal is send to the drawing.
void CmDown(wxCommandEvent &)
Move selected layer to a lower layersetting if the DOWN-button is pressed.
layer settings for a a2dCanvasDocument Holds layers settings classes
GUI listbox with copy feature.
void SetPending(bool pending)
next to base sets m_indexed false
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
static const a2dSignal sig_changedLayerInfo
when one layer its a2dLayerInfo has changed ( e.g. visible or order of rendering ) ...
contains the layer properties for one layer,
void OnCloseWindow(wxCloseEvent &event)
Close window if EXIT-button is pressed.
void Init(a2dLayers *layersetup)
initialize with this layer setup
defines common settinsg for a habitat for a set of a2dCameleons.
~a2dLayerDlg()
destructor.
static const a2dSignal sig_changedLayers
when more layers changed ( rerendering view is needed).
void CmOk(wxCommandEvent &)
Close window if OK-button is pressed.
void SetOrder(wxUint16 order)
set drawing order for layer
wxUint16 m_layerselected
set or end selected layer
std::vector< a2dLayerInfoPtr > & GetOrderIndex()
return array index on Order
void CmUp(wxCommandEvent &)
Move selected layer to a heigher layersetting if UP-button is pressed.
a2dDrawing * GetDrawing() const
get drawing via top object
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
all headers of the canvas module
void StoreOrder()
store current order to layer setup
bool DisconnectEvent(wxEventType type, wxEvtHandler *eventSink)
void Init(a2dLayers *layersetup)
initialize with this layer setup
Contain one drawing as hierarchical tree of a2dCanvasObject's.