1 
2 #include <manager.h>
3 #include <editormanager.h>
4 #include <configmanager.h>
5 #include <logmanager.h>
6 
7 #include "NassiEditorPanel.h"
8 #include "NassiFileContent.h"
9 
10 
11 BEGIN_EVENT_TABLE(NassiEditorPanel,cbEditorPanel)
12 
13 END_EVENT_TABLE()
14 
15 
16 NassiEditorPanel::EditorsSet NassiEditorPanel::m_AllEditors;
17 
NassiEditorPanel(const wxString & fileName,const wxString & title)18 NassiEditorPanel::NassiEditorPanel( const wxString &fileName, const wxString &title ):
19     cbEditorPanel( fileName, title, new NassiFileContent() ),
20     m_view(new NassiView((NassiFileContent *)m_filecontent )),
21     m_diagramwindow(0)
22 {
23     //m_view = new NassiView((NassiFileContent *)m_filecontent);
24     m_diagramwindow = m_view->CreateDiagramWindow(this);
25     m_view->Update();
26 
27     wxBoxSizer *BoxSizer = new wxBoxSizer(wxVERTICAL);
28     BoxSizer->Add((wxWindow *)m_diagramwindow,1, wxALL|wxEXPAND, 5);
29     SetSizer(BoxSizer);
30     BoxSizer->SetSizeHints(this);
31     ((wxWindow*)Manager::Get()->GetEditorManager()->GetNotebook())->Layout();
32 
33     m_AllEditors.insert( this );
34 
35     m_filecontent->AddObserver(this);
36 }
37 
~NassiEditorPanel()38 NassiEditorPanel::~NassiEditorPanel()
39 {
40     m_filecontent->RemoveObserver(this);
41     m_AllEditors.erase( this );
42 
43     if ( m_view ) delete m_view;
44     // diagram window will be deleted by its parent
45 }
46 
Update(wxObject *)47 void NassiEditorPanel::Update(wxObject* /*hint*/)
48 {
49     UpdateModified();
50 }
51 
IsNassiEditor(EditorBase * editor)52 bool NassiEditorPanel::IsNassiEditor( EditorBase* editor )
53 {
54     return m_AllEditors.find( editor ) != m_AllEditors.end();
55 }
56 
CloseAllNassiEditors()57 void NassiEditorPanel::CloseAllNassiEditors()
58 {
59     EditorsSet s = m_AllEditors;
60     for ( EditorsSet::iterator i = s.begin(); i != s.end(); ++i )
61     {
62         EditorManager::Get()->QueryClose( *i );
63         (*i)->Close();
64     }
65 
66     assert( m_AllEditors.empty() );
67 }
68 
IsDrawingSource()69 bool NassiEditorPanel::IsDrawingSource()
70 {
71     return m_view->IsDrawingSource();
72 }
73 
IsDrawingComment()74 bool NassiEditorPanel::IsDrawingComment()
75 {
76     return m_view->IsDrawingComment();
77 }
78 
EnableDrawSource(bool en)79 void NassiEditorPanel::EnableDrawSource(bool en)
80 {
81     m_view->EnableDrawSource(en);
82 }
83 
EnableDrawComment(bool en)84 void NassiEditorPanel::EnableDrawComment(bool en)
85 {
86     m_view->EnableDrawComment(en);
87 }
88 
ChangeToolTo(NassiView::NassiTools tool)89 void NassiEditorPanel::ChangeToolTo(NassiView::NassiTools tool)
90 {
91     m_view->ChangeToolTo(tool);
92 }
93 
ToolSelect()94 void NassiEditorPanel::ToolSelect()
95 {
96     m_view->ToolSelect();
97 }
98 
CanZoomIn()99 bool NassiEditorPanel::CanZoomIn()
100 {
101     return m_view->CanZoomIn();
102 }
103 
CanZoomOut()104 bool NassiEditorPanel::CanZoomOut()
105 {
106     return m_view->CanZoomOut();
107 }
108 
ZoomIn()109 void NassiEditorPanel::ZoomIn()
110 {
111     m_view->ZoomIn();
112 }
113 
ZoomOut()114 void NassiEditorPanel::ZoomOut()
115 {
116     m_view->ZoomOut();
117 }
118 
Cut()119 void NassiEditorPanel::Cut()
120 {
121     m_view->Cut();
122 }
123 
Copy()124 void NassiEditorPanel::Copy()
125 {
126     m_view->Copy();
127 }
128 
Paste()129 void NassiEditorPanel::Paste()
130 {
131     m_view->Paste();
132 }
133 
DeleteSelection()134 void NassiEditorPanel::DeleteSelection()
135 {
136     m_view->DeleteSelection();
137 }
138 
CanPaste() const139 bool NassiEditorPanel::CanPaste() const
140 {
141     return m_view->CanPaste();
142 }
143 
144 //bool NassiEditorPanel::CanCopy() const
145 //{
146 //    return m_view->CanCopy();
147 //}
148 
149 //bool NassiEditorPanel::CanCut() const
150 //{
151 //    return m_view->CanCut();
152 //}
153 
HasSelection() const154 bool NassiEditorPanel::HasSelection() const
155 {
156     return m_view->HasSelection();
157 }
158 
IsReadOnly() const159 bool NassiEditorPanel::IsReadOnly() const
160 {
161     return m_filecontent->IsReadOnly();
162 }
163 
CanSelectAll() const164 bool NassiEditorPanel::CanSelectAll() const
165 {
166     return m_view->CanSelectAll();
167 }
168 
SelectAll()169 void NassiEditorPanel::SelectAll()
170 {
171     m_view->SelectAll();
172 }
173 
CanExport()174 bool NassiEditorPanel::CanExport()
175 {
176     NassiFileContent *nfc = (NassiFileContent *)m_filecontent;
177     return m_view->HasSelectedBricks() || nfc->GetFirstBrick();
178 }
179 
ExportCSource()180 void NassiEditorPanel::ExportCSource()
181 {
182     m_view->ExportCSource();
183 }
184 
ExportVHDLSource()185 void NassiEditorPanel::ExportVHDLSource()
186 {
187     m_view->ExportVHDLSource();
188 }
189 
190 #if wxCHECK_VERSION(3, 0, 0)
ExportSVG()191 void NassiEditorPanel::ExportSVG()
192 {
193     m_view->ExportSVG();
194 }
195 #endif
196 
197 #if wxUSE_POSTSCRIPT
ExportPS()198 void NassiEditorPanel::ExportPS()
199 {
200     m_view->ExportPS();
201 }
202 #endif
203 
ExportStrukTeX()204 void NassiEditorPanel::ExportStrukTeX()
205 {
206     m_view->ExportStrukTeX();
207 }
208 
ExportBitmap()209 void NassiEditorPanel::ExportBitmap()
210 {
211     m_view->ExportBitmap();
212 }
213 
GetCSource(wxTextOutputStream & text_stream,wxUint32 n)214 bool NassiEditorPanel::GetCSource(wxTextOutputStream &text_stream, wxUint32 n)
215 {
216     return m_view->ExportCSource(text_stream,n);
217 }
218 
UpdateColors()219 void NassiEditorPanel::UpdateColors()
220 {
221     m_view->UpdateColors();
222 }
223