Reorder functions to alphabetical. trunk
author"Roger Light <roger@atchoo.org>"
Mon Jun 29 19:42:54 2009 +0100 (2009-06-29)
branchtrunk
changeset 358ba4f3cbeb717
parent 357 9338a7c6af86
child 359 611e3a9df22f
Reorder functions to alphabetical.
process_editor/gpe_window.cpp
     1.1 --- a/process_editor/gpe_window.cpp	Mon Jun 29 19:36:35 2009 +0100
     1.2 +++ b/process_editor/gpe_window.cpp	Mon Jun 29 19:42:54 2009 +0100
     1.3 @@ -172,6 +172,121 @@
     1.4  	}
     1.5  }
     1.6  
     1.7 +void GPEWindow::OnCheckListBoxLayersClick( wxCommandEvent& event )
     1.8 +{
     1.9 +	if(m_layerIsDirty && m_selectedLayer >= 0 && m_selectedLayer < (int)m_checkListBoxLayers->GetCount()){
    1.10 +		wxMessageDialog *msgDialog = new wxMessageDialog(this, wxT("Layer modified. Apply changes?"), wxT("Warning"), wxYES_NO | wxCANCEL);
    1.11 +		switch(msgDialog->ShowModal()){
    1.12 +			case wxID_YES:
    1.13 +				SaveLayer(m_selectedLayer);
    1.14 +				break;
    1.15 +			case wxID_NO:
    1.16 +				break;
    1.17 +			case wxID_CANCEL:
    1.18 +				m_checkListBoxLayers->Select(m_selectedLayer);
    1.19 +				delete msgDialog;
    1.20 +				return;
    1.21 +				break;
    1.22 +		}
    1.23 +		delete msgDialog;
    1.24 +	}
    1.25 +	int selected = m_checkListBoxLayers->GetSelection();
    1.26 +	if(selected != wxNOT_FOUND){
    1.27 +		ProcessLayer *layer = m_process->GetLayer(selected);
    1.28 +		if(layer){
    1.29 +			m_textCtrlName->SetValue(wxString::FromAscii(layer->Name.c_str()));
    1.30 +			m_textCtrlLayer->SetValue(wxString::Format(wxT("%d"), layer->Layer));
    1.31 +			m_textCtrlDatatype->SetValue(wxString::Format(wxT("%d"), layer->Datatype));
    1.32 +			m_textCtrlHeight->SetValue(wxString::Format(wxT("%f"), layer->Height));
    1.33 +			m_textCtrlThickness->SetValue(wxString::Format(wxT("%f"), layer->Thickness));
    1.34 +			m_spinCtrlTransparency->SetValue(100 * layer->Filter);
    1.35 +			m_checkBoxMetal->SetValue(layer->Metal);
    1.36 +
    1.37 +			m_colourPickerLayer->SetColour(wxColour(255 * layer->Red, 255 * layer->Green, 255 * layer->Blue));
    1.38 +
    1.39 +			m_textCtrlName->Enable(true);
    1.40 +			m_textCtrlLayer->Enable(true);
    1.41 +			m_textCtrlDatatype->Enable(true);
    1.42 +			m_textCtrlHeight->Enable(true);
    1.43 +			m_textCtrlThickness->Enable(true);
    1.44 +			m_colourPickerLayer->Enable(true);
    1.45 +			m_spinCtrlTransparency->Enable(true);
    1.46 +			m_checkBoxMetal->Enable(true);
    1.47 +
    1.48 +			m_buttonRemove->Enable(true);
    1.49 +
    1.50 +			SetLayerDirtyState(false);
    1.51 +		}
    1.52 +	}
    1.53 +	m_selectedLayer = selected;
    1.54 +	if(selected > 0){
    1.55 +		m_buttonUp->Enable(true);
    1.56 +	}else{
    1.57 +		m_buttonUp->Enable(false);
    1.58 +	}
    1.59 +	if(selected < (int)m_checkListBoxLayers->GetCount() - 1){
    1.60 +		m_buttonDown->Enable(true);
    1.61 +	}else{
    1.62 +		m_buttonDown->Enable(false);
    1.63 +	}
    1.64 +}
    1.65 +
    1.66 +void GPEWindow::OnCheckListBoxLayersToggled( wxCommandEvent& event )
    1.67 +{
    1.68 +	int selected = event.GetSelection();
    1.69 +	if(selected != wxNOT_FOUND){
    1.70 +		ProcessLayer *layer = m_process->GetLayer(selected);
    1.71 +		if(layer){
    1.72 +			layer->Show = m_checkListBoxLayers->IsChecked(selected);
    1.73 +		}
    1.74 +	}
    1.75 +}
    1.76 +
    1.77 +void GPEWindow::OnCloseEvent( wxCloseEvent& event )
    1.78 +{
    1.79 +	bool veto;
    1.80 +	
    1.81 +	veto = TryFileSave();
    1.82 +
    1.83 +	if(!event.CanVeto()){
    1.84 +		/* Must destroy the window */
    1.85 +		Destroy();
    1.86 +	}else{
    1.87 +		if(veto){
    1.88 +			event.Veto(true);
    1.89 +		}else{
    1.90 +			Destroy();
    1.91 +		}
    1.92 +	}
    1.93 +}
    1.94 +
    1.95 +void GPEWindow::OnColourChangedLayer( wxColourPickerEvent& event )
    1.96 +{
    1.97 +	int selected = m_checkListBoxLayers->GetSelection();
    1.98 +	if(selected != wxNOT_FOUND){
    1.99 +		SetLayerDirtyState(true);
   1.100 +		/*
   1.101 +		ProcessLayer *layer = m_process->GetLayer(selected);
   1.102 +
   1.103 +		wxColour colour = m_colourPickerLayer->GetColour();
   1.104 +
   1.105 +		layer->Red = colour.Red() / 255.0;
   1.106 +		layer->Green = colour.Green() / 255.0;
   1.107 +		layer->Blue = colour.Blue() / 255.0;
   1.108 +		*/
   1.109 +	}
   1.110 +}
   1.111 +
   1.112 +void GPEWindow::OnLayerChange( wxCommandEvent& event )
   1.113 +{
   1.114 +	SetLayerDirtyState(true);
   1.115 +}
   1.116 +
   1.117 +void GPEWindow::OnLayerChangeSpin( wxSpinEvent& event )
   1.118 +{
   1.119 +	SetLayerDirtyState(true);
   1.120 +}
   1.121 +
   1.122  void GPEWindow::OnMenuFileExit( wxCommandEvent& event )
   1.123  {
   1.124  	Close();
   1.125 @@ -312,153 +427,6 @@
   1.126  	delete dialog;
   1.127  }
   1.128  
   1.129 -void GPEWindow::OnColourChangedLayer( wxColourPickerEvent& event )
   1.130 -{
   1.131 -	int selected = m_checkListBoxLayers->GetSelection();
   1.132 -	if(selected != wxNOT_FOUND){
   1.133 -		SetLayerDirtyState(true);
   1.134 -		/*
   1.135 -		ProcessLayer *layer = m_process->GetLayer(selected);
   1.136 -
   1.137 -		wxColour colour = m_colourPickerLayer->GetColour();
   1.138 -
   1.139 -		layer->Red = colour.Red() / 255.0;
   1.140 -		layer->Green = colour.Green() / 255.0;
   1.141 -		layer->Blue = colour.Blue() / 255.0;
   1.142 -		*/
   1.143 -	}
   1.144 -}
   1.145 -
   1.146 -void GPEWindow::OnCheckListBoxLayersClick( wxCommandEvent& event )
   1.147 -{
   1.148 -	if(m_layerIsDirty && m_selectedLayer >= 0 && m_selectedLayer < (int)m_checkListBoxLayers->GetCount()){
   1.149 -		wxMessageDialog *msgDialog = new wxMessageDialog(this, wxT("Layer modified. Apply changes?"), wxT("Warning"), wxYES_NO | wxCANCEL);
   1.150 -		switch(msgDialog->ShowModal()){
   1.151 -			case wxID_YES:
   1.152 -				SaveLayer(m_selectedLayer);
   1.153 -				break;
   1.154 -			case wxID_NO:
   1.155 -				break;
   1.156 -			case wxID_CANCEL:
   1.157 -				m_checkListBoxLayers->Select(m_selectedLayer);
   1.158 -				delete msgDialog;
   1.159 -				return;
   1.160 -				break;
   1.161 -		}
   1.162 -		delete msgDialog;
   1.163 -	}
   1.164 -	int selected = m_checkListBoxLayers->GetSelection();
   1.165 -	if(selected != wxNOT_FOUND){
   1.166 -		ProcessLayer *layer = m_process->GetLayer(selected);
   1.167 -		if(layer){
   1.168 -			m_textCtrlName->SetValue(wxString::FromAscii(layer->Name.c_str()));
   1.169 -			m_textCtrlLayer->SetValue(wxString::Format(wxT("%d"), layer->Layer));
   1.170 -			m_textCtrlDatatype->SetValue(wxString::Format(wxT("%d"), layer->Datatype));
   1.171 -			m_textCtrlHeight->SetValue(wxString::Format(wxT("%f"), layer->Height));
   1.172 -			m_textCtrlThickness->SetValue(wxString::Format(wxT("%f"), layer->Thickness));
   1.173 -			m_spinCtrlTransparency->SetValue(100 * layer->Filter);
   1.174 -			m_checkBoxMetal->SetValue(layer->Metal);
   1.175 -
   1.176 -			m_colourPickerLayer->SetColour(wxColour(255 * layer->Red, 255 * layer->Green, 255 * layer->Blue));
   1.177 -
   1.178 -			m_textCtrlName->Enable(true);
   1.179 -			m_textCtrlLayer->Enable(true);
   1.180 -			m_textCtrlDatatype->Enable(true);
   1.181 -			m_textCtrlHeight->Enable(true);
   1.182 -			m_textCtrlThickness->Enable(true);
   1.183 -			m_colourPickerLayer->Enable(true);
   1.184 -			m_spinCtrlTransparency->Enable(true);
   1.185 -			m_checkBoxMetal->Enable(true);
   1.186 -
   1.187 -			m_buttonRemove->Enable(true);
   1.188 -
   1.189 -			SetLayerDirtyState(false);
   1.190 -		}
   1.191 -	}
   1.192 -	m_selectedLayer = selected;
   1.193 -	if(selected > 0){
   1.194 -		m_buttonUp->Enable(true);
   1.195 -	}else{
   1.196 -		m_buttonUp->Enable(false);
   1.197 -	}
   1.198 -	if(selected < (int)m_checkListBoxLayers->GetCount() - 1){
   1.199 -		m_buttonDown->Enable(true);
   1.200 -	}else{
   1.201 -		m_buttonDown->Enable(false);
   1.202 -	}
   1.203 -}
   1.204 -
   1.205 -void GPEWindow::OnCheckListBoxLayersToggled( wxCommandEvent& event )
   1.206 -{
   1.207 -	int selected = event.GetSelection();
   1.208 -	if(selected != wxNOT_FOUND){
   1.209 -		ProcessLayer *layer = m_process->GetLayer(selected);
   1.210 -		if(layer){
   1.211 -			layer->Show = m_checkListBoxLayers->IsChecked(selected);
   1.212 -		}
   1.213 -	}
   1.214 -}
   1.215 -
   1.216 -void GPEWindow::OnCloseEvent( wxCloseEvent& event )
   1.217 -{
   1.218 -	bool veto;
   1.219 -	
   1.220 -	veto = TryFileSave();
   1.221 -
   1.222 -	if(!event.CanVeto()){
   1.223 -		/* Must destroy the window */
   1.224 -		Destroy();
   1.225 -	}else{
   1.226 -		if(veto){
   1.227 -			event.Veto(true);
   1.228 -		}else{
   1.229 -			Destroy();
   1.230 -		}
   1.231 -	}
   1.232 -}
   1.233 -
   1.234 -bool GPEWindow::TryFileSave(void)
   1.235 -{
   1.236 -	bool veto = false;
   1.237 -
   1.238 -	if(m_fileIsDirty){
   1.239 -		wxMessageDialog *msgDialog = new wxMessageDialog(this, wxT("File modified. Save changes?"), wxT("Warning"), wxYES_NO | wxCANCEL);
   1.240 -		switch(msgDialog->ShowModal()){
   1.241 -			case wxID_YES:
   1.242 -				if(!DoFileSave(false)){
   1.243 -					/* User cancelled file selection dialog */
   1.244 -					veto = true;
   1.245 -				}
   1.246 -			case wxID_NO:
   1.247 -				break;
   1.248 -			case wxID_CANCEL:
   1.249 -				veto = true;
   1.250 -				break;
   1.251 -		}
   1.252 -		delete msgDialog;
   1.253 -	}
   1.254 -
   1.255 -	return veto;
   1.256 -}
   1.257 -
   1.258 -void GPEWindow::SetLayerDirtyState(bool state)
   1.259 -{
   1.260 -	m_buttonApply->Enable(state);
   1.261 -	m_layerIsDirty = state;
   1.262 -
   1.263 -	m_fileIsDirty = true;
   1.264 -}
   1.265 -
   1.266 -void GPEWindow::OnLayerChange( wxCommandEvent& event )
   1.267 -{
   1.268 -	SetLayerDirtyState(true);
   1.269 -}
   1.270 -
   1.271 -void GPEWindow::OnLayerChangeSpin( wxSpinEvent& event )
   1.272 -{
   1.273 -	SetLayerDirtyState(true);
   1.274 -}
   1.275 -
   1.276  void GPEWindow::SaveLayer(int number)
   1.277  {
   1.278  	ProcessLayer *layer = m_process->GetLayer(number);
   1.279 @@ -505,3 +473,35 @@
   1.280  	}
   1.281  }
   1.282  
   1.283 +void GPEWindow::SetLayerDirtyState(bool state)
   1.284 +{
   1.285 +	m_buttonApply->Enable(state);
   1.286 +	m_layerIsDirty = state;
   1.287 +
   1.288 +	m_fileIsDirty = true;
   1.289 +}
   1.290 +
   1.291 +bool GPEWindow::TryFileSave(void)
   1.292 +{
   1.293 +	bool veto = false;
   1.294 +
   1.295 +	if(m_fileIsDirty){
   1.296 +		wxMessageDialog *msgDialog = new wxMessageDialog(this, wxT("File modified. Save changes?"), wxT("Warning"), wxYES_NO | wxCANCEL);
   1.297 +		switch(msgDialog->ShowModal()){
   1.298 +			case wxID_YES:
   1.299 +				if(!DoFileSave(false)){
   1.300 +					/* User cancelled file selection dialog */
   1.301 +					veto = true;
   1.302 +				}
   1.303 +			case wxID_NO:
   1.304 +				break;
   1.305 +			case wxID_CANCEL:
   1.306 +				veto = true;
   1.307 +				break;
   1.308 +		}
   1.309 +		delete msgDialog;
   1.310 +	}
   1.311 +
   1.312 +	return veto;
   1.313 +}
   1.314 +