1 
2 ///////////////////////////////////////////////////////////
3 //                                                       //
4 //                         SAGA                          //
5 //                                                       //
6 //      System for Automated Geoscientific Analyses      //
7 //                                                       //
8 //                    User Interface                     //
9 //                                                       //
10 //                    Program: SAGA                      //
11 //                                                       //
12 //-------------------------------------------------------//
13 //                                                       //
14 //                   RES_Dialogs.cpp                     //
15 //                                                       //
16 //          Copyright (C) 2005 by Olaf Conrad            //
17 //                                                       //
18 //-------------------------------------------------------//
19 //                                                       //
20 // This file is part of 'SAGA - System for Automated     //
21 // Geoscientific Analyses'. SAGA is free software; you   //
22 // can redistribute it and/or modify it under the terms  //
23 // of the GNU General Public License as published by the //
24 // Free Software Foundation, either version 2 of the     //
25 // License, or (at your option) any later version.       //
26 //                                                       //
27 // SAGA is distributed in the hope that it will be       //
28 // useful, but WITHOUT ANY WARRANTY; without even the    //
29 // implied warranty of MERCHANTABILITY or FITNESS FOR A  //
30 // PARTICULAR PURPOSE. See the GNU General Public        //
31 // License for more details.                             //
32 //                                                       //
33 // You should have received a copy of the GNU General    //
34 // Public License along with this program; if not, see   //
35 // <http://www.gnu.org/licenses/>.                       //
36 //                                                       //
37 //-------------------------------------------------------//
38 //                                                       //
39 //    contact:    Olaf Conrad                            //
40 //                Institute of Geography                 //
41 //                University of Goettingen               //
42 //                Goldschmidtstr. 5                      //
43 //                37077 Goettingen                       //
44 //                Germany                                //
45 //                                                       //
46 //    e-mail:     oconrad@saga-gis.org                   //
47 //                                                       //
48 ///////////////////////////////////////////////////////////
49 
50 //---------------------------------------------------------
51 #include <wx/utils.h>
52 #include <wx/msgdlg.h>
53 #include <wx/dirdlg.h>
54 #include <wx/filedlg.h>
55 #include <wx/fontdlg.h>
56 #include <wx/textdlg.h>
57 #include <wx/colordlg.h>
58 #include <wx/choicdlg.h>
59 
60 #include <saga_api/saga_api.h>
61 
62 #include "saga_frame.h"
63 
64 #include "res_dialogs.h"
65 
66 #include "helper.h"
67 
68 #include "dlg_parameters.h"
69 #include "dlg_text.h"
70 #include "dlg_table.h"
71 #include "dlg_choices.h"
72 #include "dlg_list.h"
73 #include "dlg_colors.h"
74 
75 #include "wksp_map_manager.h"
76 #include "wksp_map.h"
77 
78 #include "wksp_data_manager.h"
79 
80 
81 ///////////////////////////////////////////////////////////
82 //														 //
83 //														 //
84 //														 //
85 ///////////////////////////////////////////////////////////
86 
87 //---------------------------------------------------------
88 #define CONFIG_GROUP_FILE_DLG	wxT("/FileDialogs")
89 
90 
91 ///////////////////////////////////////////////////////////
92 //														 //
93 //														 //
94 //														 //
95 ///////////////////////////////////////////////////////////
96 
97 //---------------------------------------------------------
DLG_Get_Text(int ID_DLG)98 wxString DLG_Get_Text(int ID_DLG)
99 {
100 	switch( ID_DLG )
101 	{
102 	case ID_DLG_ABOUT :	return( _TL("SAGA\nSystem for Automated Geoscientific Analyses\nVersion 2.0") );
103 	case ID_DLG_CLOSE :	return( _TL("Do you want to exit SAGA?") );
104 	case ID_DLG_DELETE:	return( _TL("Do you want to delete the selection?") );
105 	}
106 
107 	return( _TL("") );
108 }
109 
110 //---------------------------------------------------------
DLG_Get_Caption(int ID_DLG)111 wxString DLG_Get_Caption(int ID_DLG)
112 {
113 	switch( ID_DLG )
114 	{
115 	case ID_DLG_CLOSE :	return( _TL("Exit") );
116 	case ID_DLG_ABOUT :	return( _TL("About SAGA") );
117 	case ID_DLG_DELETE:	return( _TL("Delete") );
118 	}
119 
120 	return( _TL("") );
121 }
122 
123 
124 ///////////////////////////////////////////////////////////
125 //														 //
126 //														 //
127 //														 //
128 ///////////////////////////////////////////////////////////
129 
130 //---------------------------------------------------------
DLG_Get_FILE_Caption(int ID_DLG)131 wxString DLG_Get_FILE_Caption(int ID_DLG)
132 {
133 	switch( ID_DLG )
134 	{
135 	case ID_DLG_FILE_OPEN      :	return( _TL("Load") );
136 
137 	case ID_DLG_TOOL_OPEN      :	return( _TL("Load Tool Library") );
138 
139 	case ID_DLG_PROJECT_OPEN   :	return( _TL("Load Project") );
140 	case ID_DLG_PROJECT_SAVE   :	return( _TL("Save Project") );
141 
142 	case ID_DLG_GRID_OPEN      :	return( _TL("Load Grid") );
143 	case ID_DLG_GRID_SAVE      :	return( _TL("Save Grid") );
144 
145 	case ID_DLG_GRIDS_OPEN     :	return( _TL("Load Grid Collection") );
146 	case ID_DLG_GRIDS_SAVE     :	return( _TL("Save Grid Collection") );
147 
148 	case ID_DLG_SHAPES_OPEN    :	return( _TL("Load Shapes") );
149 	case ID_DLG_SHAPES_SAVE    :	return( _TL("Save Shapes") );
150 
151 	case ID_DLG_TABLE_OPEN     :	return( _TL("Load Table") );
152 	case ID_DLG_TABLE_SAVE     :	return( _TL("Save Table") );
153 
154 	case ID_DLG_TIN_OPEN       :	return( _TL("Load TIN") );
155 	case ID_DLG_TIN_SAVE       :	return( _TL("Save TIN") );
156 
157 	case ID_DLG_POINTCLOUD_OPEN:	return( _TL("Load Point Cloud") );
158 	case ID_DLG_POINTCLOUD_SAVE:	return( _TL("Save Point Cloud") );
159 
160 	case ID_DLG_TEXT_OPEN      :	return( _TL("Load Text") );
161 	case ID_DLG_TEXT_SAVE      :	return( _TL("Save Text") );
162 
163 	case ID_DLG_PARAMETERS_OPEN:	return( _TL("Load Settings") );
164 	case ID_DLG_PARAMETERS_SAVE:	return( _TL("Save Settings") );
165 
166 	case ID_DLG_COLORS_OPEN    :	return( _TL("Load Colors") );
167 	case ID_DLG_COLORS_SAVE    :	return( _TL("Save Colors") );
168 	}
169 
170 	return( _TL("Select File") );
171 }
172 
173 //---------------------------------------------------------
DLG_Get_FILE_Filter_GDAL_Read(int Type,wxString & Filter)174 bool DLG_Get_FILE_Filter_GDAL_Read(int Type, wxString &Filter)
175 {
176 	bool		bResult;
177 	CSG_Table	Formats;
178 
179 	SG_UI_ProgressAndMsg_Lock(true);
180 
181 	SG_RUN_TOOL(bResult, "io_gdal", 10,	// GDAL Formats
182 		SG_TOOL_PARAMETER_SET("FORMATS"   , &Formats)
183 	&&	SG_TOOL_PARAMETER_SET("TYPE"      , Type    )	// all (rasters and vectors)
184 	&&	SG_TOOL_PARAMETER_SET("ACCESS"    , 0       )	// read
185 	&&	SG_TOOL_PARAMETER_SET("RECOGNIZED", true    )	// add an entry for all recognized files
186 	);
187 
188 	SG_UI_ProgressAndMsg_Lock(false);
189 
190 	if( bResult && Formats.Get_Count() > 0 )
191 	{
192 		Filter	+= Formats[Formats.Get_Count() - 1].asString(2);
193 
194 		Filter.Replace("*.sdat;", "");	// we go for *.sgrd
195 		Filter.Replace("*.xml;" , "");	// too much noise
196 	}
197 
198 	#define ADD_FILTER(ext)	{ wxString s("*."); s += ext; if( Filter.Find(s) < 0 ) Filter += ";" + s; }
199 
200 	if( Type == 2 || Type == 0 )	// raster
201 	{
202 		ADD_FILTER("sg-grd"  );
203 		ADD_FILTER("sg-grd-z");
204 		ADD_FILTER("sg-gds"  );
205 		ADD_FILTER("sg-gds-z");
206 		ADD_FILTER("sgrd"    );
207 		ADD_FILTER("dgm"     );
208 		ADD_FILTER("grd"     );
209 		ADD_FILTER("bmp"     );
210 		ADD_FILTER("jpg"     );
211 		ADD_FILTER("png"     );
212 		ADD_FILTER("pcx"     );
213 	}
214 
215 	if( Type == 2 || Type == 1 )	// vector
216 	{
217 		ADD_FILTER("shp"     );
218 		ADD_FILTER("json"    );
219 		ADD_FILTER("geojson" );
220 	}
221 
222 	if( Type == 2 )					// all recognized
223 	{
224 		ADD_FILTER("sprj"    );
225 		ADD_FILTER("sg-pts"  );
226 		ADD_FILTER("sg-pts-z");
227 		ADD_FILTER("spc"     );
228 		ADD_FILTER("las"     );
229 		ADD_FILTER("txt"     );
230 		ADD_FILTER("csv"     );
231 		ADD_FILTER("dbf"     );
232 	}
233 
234 	return( bResult );
235 }
236 
237 //---------------------------------------------------------
DLG_Get_FILE_Filter(int ID_DLG)238 wxString DLG_Get_FILE_Filter(int ID_DLG)
239 {
240 	wxString	Recognized;
241 
242 	switch( ID_DLG )
243 	{
244 	//-----------------------------------------------------
245 	case ID_DLG_FILE_OPEN:
246 		DLG_Get_FILE_Filter_GDAL_Read(2, Recognized);
247 
248 		return( wxString::Format(
249 			"%s|%s|"
250 			"%s (*.dll, *.so, *.xml)|*.dll;*.so;*.xml;*.dylib|"
251 			"%s (*.sprj)|*.sprj|"
252 			"%s (*.sgrd, *.sg-grd-z)|*.sgrd;*.sg-grd;*.sg-grd-z;*.dgm;*.grd|"
253 			"%s (*.sg-gds, *.sg-gds-z)|*.sg-gds;*.sg-gds-z|"
254 			"%s (*.shp)|*.shp|"
255 			"%s (*.spc, *.sg-pts, *.sg-pts-z)|*.spc;*.sg-pts;*.sg-pts-z|"
256 			"%s (*.txt, *.csv, *.dbf)|*.txt;*.csv;*.dbf|"
257 			"%s|*.*",
258 			_TL("Recognized Files"), Recognized.c_str(),
259 			_TL("SAGA Tool Libraries"),
260 			_TL("SAGA Projects"),
261 			_TL("SAGA Grids"),
262 			_TL("SAGA Grid Collections"),
263 			_TL("ESRI Shape Files"),
264 			_TL("SAGA Point Clouds"),
265 			_TL("Tables"),
266 			_TL("All Files")
267 		));
268 
269 	//-----------------------------------------------------
270 	case ID_DLG_TOOL_OPEN:
271 		return( wxString::Format(
272 			"%s|*.dll;*.so;*.xml;*.dylib|"
273 			"%s (*.dll, *.so)|*.dll;*.so;*.xml;*.dylib|"
274 			"%s (*.xml)|*.xml|"
275 			"%s|*.*",
276 			_TL("Recognized Files"),
277 			_TL("SAGA Tool Libraries"),
278 			_TL("SAGA Tool Chains"),
279 			_TL("All Files")
280 		));
281 
282 	//-----------------------------------------------------
283 	case ID_DLG_PROJECT_OPEN:
284 	case ID_DLG_PROJECT_SAVE:
285 		return( wxString::Format(
286 			"%s (*.sprj)|*.sprj|"
287 			"%s|*.*",
288 			_TL("SAGA Projects"),
289 			_TL("All Files")
290 		));
291 
292 	//-----------------------------------------------------
293 	case ID_DLG_GRID_OPEN:
294 		DLG_Get_FILE_Filter_GDAL_Read(0, Recognized);
295 
296 		return( wxString::Format(
297 			"%s|%s|"
298 			"%s (*.sgrd, *.sg-grd-z))|*.sg-grd;*.sg-grd-z;*.sgrd;*.dgm;*.grd|"
299 			"%s|*.*",
300 			_TL("Recognized Files"), Recognized.c_str(),
301 			_TL("SAGA Grid Files"),
302 			_TL("All Files")
303 		));
304 
305 	case ID_DLG_GRID_SAVE:
306 		switch( SG_Grid_Get_File_Format_Default() )
307 		{
308 		default:	// SAGA Compressed Grid File (*.sg-grd-z)
309 			return( wxString::Format(
310 				"%s (*.sg-grd-z)|*.sg-grd-z|"
311 				"%s (*.sg-grd)|*.sg-grd|"
312 				"%s (*.sgrd)|*.sgrd|"
313 				"%s (*.tif)|*.tif;*.tiff|"
314 				"%s|*.*",
315 				_TL("SAGA Compressed Grid Files"),
316 				_TL("SAGA Grid Files"),
317 				_TL("SAGA Grid Files (old extension)"),
318 				_TL("GeoTIFF"),
319 				_TL("All Files")
320 			));
321 
322 		case GRID_FILE_FORMAT_Binary:	// SAGA Grid File (*.sg-grd)
323 			return( wxString::Format(
324 				"%s (*.sg-grd)|*.sg-grd|"
325 				"%s (*.sg-grd-z)|*.sg-grd-z|"
326 				"%s (*.sgrd)|*.sgrd|"
327 				"%s (*.tif)|*.tif;*.tiff|"
328 				"%s|*.*",
329 				_TL("SAGA Grid Files"),
330 				_TL("SAGA Compressed Grid Files"),
331 				_TL("SAGA Grid Files (old extension)"),
332 				_TL("GeoTIFF"),
333 				_TL("All Files")
334 			));
335 
336 		case GRID_FILE_FORMAT_Binary_old:	// SAGA Grid File (*.sgrd)
337 			return( wxString::Format(
338 				"%s (*.sgrd)|*.sgrd|"
339 				"%s (*.sg-grd-z)|*.sg-grd-z|"
340 				"%s (*.sg-grd)|*.sg-grd|"
341 				"%s (*.tif)|*.tif;*.tiff|"
342 				"%s|*.*",
343 				_TL("SAGA Grid Files (old extension)"),
344 				_TL("SAGA Compressed Grid Files"),
345 				_TL("SAGA Grid Files"),
346 				_TL("GeoTIFF"),
347 				_TL("All Files")
348 			));
349 
350 		case GRID_FILE_FORMAT_GeoTIFF:	// GeoTIFF
351 			return( wxString::Format(
352 				"%s (*.tif)|*.tif;*.tiff|"
353 				"%s (*.sgrd)|*.sgrd|"
354 				"%s (*.sg-grd-z)|*.sg-grd-z|"
355 				"%s (*.sg-grd)|*.sg-grd|"
356 				"%s|*.*",
357 				_TL("GeoTIFF"),
358 				_TL("SAGA Grid Files (old extension)"),
359 				_TL("SAGA Compressed Grid Files"),
360 				_TL("SAGA Grid Files"),
361 				_TL("All Files")
362 			));
363 		}
364 
365 	//-----------------------------------------------------
366 	case ID_DLG_GRIDS_OPEN:
367 		return( wxString::Format(
368 			"%s|*.sg-gds;*.sg-gds-z|"
369 			"%s (*.sg-gds-z)|*.sg-gds-z|"
370 			"%s (*.sg-gds)|*.sg-gds|"
371 			"%s|*.*",
372 			_TL("Recognized Files"),
373 			_TL("SAGA Compressed Grid Collections"),
374 			_TL("SAGA Uncompressed Grid Collections"),
375 			_TL("All Files")
376 		));
377 
378 	case ID_DLG_GRIDS_SAVE:
379 		return( wxString::Format(
380 			"%s (*.sg-gds-z)|*.sg-gds-z|"
381 			"%s (*.sg-gds)|*.sg-gds|"
382 			"%s (*.tif)|*.tif|"
383 			"%s|*.*",
384 			_TL("SAGA Compressed Grid Collections"),
385 			_TL("SAGA Uncompressed Grid Collections"),
386 			_TL("Multi-Band GeoTIFF"),
387 			_TL("All Files")
388 		));
389 
390 	//-----------------------------------------------------
391 	case ID_DLG_SHAPES_OPEN:
392 		DLG_Get_FILE_Filter_GDAL_Read(1, Recognized);
393 
394 		return( wxString::Format(
395 			"%s|%s|"
396 			"%s (*.shp)|*.shp|"
397 			"%s|*.*",
398 			_TL("Recognized Files"), Recognized.c_str(),
399 			_TL("ESRI Shape Files"),
400 			_TL("All Files")
401 		));
402 
403 	case ID_DLG_SHAPES_SAVE:
404 		switch( SG_Shapes_Get_File_Format_Default() )
405 		{
406 		default:	// ESRI Shape File (*.shp)
407 			return( wxString::Format(
408 				"%s (*.shp)|*.shp|"
409 				"%s (*.gpkg)|*.gpkg|"
410 				"%s (*.geojson)|*.geojson|"
411 				"%s|*.*",
412 				_TL("ESRI Shape Files"),
413 				_TL("GeoPackage Files"),
414 				_TL("GeoJSON Files"),
415 				_TL("All Files")
416 			));
417 
418 		case SHAPE_FILE_FORMAT_GeoPackage:	// GeoPackage (*.gpkg)
419 			return( wxString::Format(
420 				"%s (*.gpkg)|*.gpkg|"
421 				"%s (*.shp)|*.shp|"
422 				"%s (*.geojson)|*.geojson|"
423 				"%s|*.*",
424 				_TL("GeoPackage Files"),
425 				_TL("ESRI Shape Files"),
426 				_TL("GeoJSON Files"),
427 				_TL("All Files")
428 			));
429 
430 		case SHAPE_FILE_FORMAT_GeoJSON   :	// GeoJSON (*.geojson)
431 			return( wxString::Format(
432 				"%s (*.geojson)|*.geojson|"
433 				"%s (*.shp)|*.shp|"
434 				"%s (*.gpkg)|*.gpkg|"
435 				"%s|*.*",
436 				_TL("GeoJSON Files"),
437 				_TL("ESRI Shape Files"),
438 				_TL("GeoPackage Files"),
439 				_TL("All Files")
440 			));
441 		}
442 
443 	//-----------------------------------------------------
444 	case ID_DLG_TABLE_OPEN:
445 		return( wxString::Format(
446 			"%s (*.txt, *.csv, *.dbf)|*.txt;*.csv;*.dbf|"
447 			"%s|*.*",
448 			_TL("Tables"),
449 			_TL("All Files")
450 		));
451 
452 	case ID_DLG_TABLE_SAVE:
453 		return( wxString::Format(
454 			"%s (*.txt)|*.txt|"
455 			"%s (*.csv)|*.csv|"
456 			"%s (*.dbf)|*.dbf|"
457 			"%s|*.*",
458 			_TL("Text"),
459 			_TL("Comma Separated Values"),
460 			_TL("DBase"),
461 			_TL("All Files")
462 		));
463 
464 	//-----------------------------------------------------
465 	case ID_DLG_TIN_OPEN:
466 	case ID_DLG_TIN_SAVE:
467 		return( wxString::Format(
468 			"%s (*.shp)|*.shp|"
469 			"%s|*.*",
470 			_TL("ESRI Shape Files"),
471 			_TL("All Files")
472 		));
473 
474 	//-----------------------------------------------------
475 	case ID_DLG_POINTCLOUD_OPEN:
476 		return( wxString::Format(
477 			"%s (*.spc, *.sg-pts, *.sg-pts-z)|*.spc;*.sg-pts;*.sg-pts-z|"
478 			"%s|*.*",
479 			_TL("SAGA Point Clouds"),
480 			_TL("All Files")
481 		));
482 
483 	case ID_DLG_POINTCLOUD_SAVE:
484 		return( wxString::Format(
485 			"%s (*.sg-pts-z)|*.sg-pts-z|"
486 			"%s (*.sg-pts, *.spc)|*.sg-pts;*.spc|"
487 			"%s|*.*",
488 			_TL("SAGA Compressed Point Clouds"),
489 			_TL("SAGA Uncompressed Point Clouds"),
490 			_TL("All Files")
491 		));
492 
493 	//-----------------------------------------------------
494 	case ID_DLG_TEXT_OPEN:
495 	case ID_DLG_TEXT_SAVE:
496 		return( wxString::Format(
497 			"%s (*.txt)|*.txt|"
498 			"%s|*.*",
499 			_TL("Text Files"),
500 			_TL("All Files")
501 		));
502 
503 	//-----------------------------------------------------
504 	case ID_DLG_PARAMETERS_OPEN:
505 	case ID_DLG_PARAMETERS_SAVE:
506 		return( wxString::Format(
507 			"%s (*.sprm)|*.sprm|"
508 			"%s|*.*",
509 			_TL("SAGA Parameter Files"),
510 			_TL("All Files")
511 		));
512 
513 	//-----------------------------------------------------
514 	case ID_DLG_COLORS_OPEN:
515 	case ID_DLG_COLORS_SAVE:
516 		return( wxString::Format(
517 			"%s (*.pal)|*.pal|"
518 			"%s|*.*",
519 			_TL("SAGA Colors"),
520 			_TL("All Files")
521 		));
522 	}
523 
524 	//-----------------------------------------------------
525 	return( wxString::Format("%s|*.*", _TL("All Files")) );
526 }
527 
528 //---------------------------------------------------------
DLG_Get_FILE_Config(int ID_DLG)529 wxString DLG_Get_FILE_Config(int ID_DLG)
530 {
531 	switch( ID_DLG )
532 	{
533 	case ID_DLG_FILE_OPEN      :	return( "ALL_LOAD" );
534 
535 	case ID_DLG_TOOL_OPEN      :	return( "TLB_LOAD" );
536 
537 	case ID_DLG_PROJECT_OPEN   :	return( "PRJ_LOAD" );
538 	case ID_DLG_PROJECT_SAVE   :	return( "PRJ_SAVE" );
539 
540 	case ID_DLG_GRID_OPEN      :	return( "GRD_LOAD" );
541 	case ID_DLG_GRID_SAVE      :	return( "GRD_SAVE" );
542 
543 	case ID_DLG_GRIDS_OPEN     :	return( "GDS_LOAD" );
544 	case ID_DLG_GRIDS_SAVE     :	return( "GDS_SAVE" );
545 
546 	case ID_DLG_SHAPES_OPEN    :	return( "SHP_LOAD" );
547 	case ID_DLG_SHAPES_SAVE    :	return( "SHP_SAVE" );
548 
549 	case ID_DLG_TABLE_OPEN     :	return( "TAB_LOAD" );
550 	case ID_DLG_TABLE_SAVE     :	return( "TAB_SAVE" );
551 
552 	case ID_DLG_TIN_OPEN       :	return( "TIN_LOAD" );
553 	case ID_DLG_TIN_SAVE       :	return( "TIN_SAVE" );
554 
555 	case ID_DLG_POINTCLOUD_OPEN:	return( "PTS_LOAD" );
556 	case ID_DLG_POINTCLOUD_SAVE:	return( "PTS_SAVE" );
557 
558 	case ID_DLG_TEXT_OPEN      :	return( "TXT_LOAD" );
559 	case ID_DLG_TEXT_SAVE      :	return( "TXT_SAVE" );
560 
561 	case ID_DLG_PARAMETERS_OPEN:	return( "PRM_LOAD" );
562 	case ID_DLG_PARAMETERS_SAVE:	return( "PRM_SAVE" );
563 
564 	case ID_DLG_COLORS_OPEN    :	return( "COL_LOAD" );
565 	case ID_DLG_COLORS_SAVE    :	return( "COL_SAVE" );
566 	}
567 
568 	return( "FILE" );
569 }
570 
571 
572 ///////////////////////////////////////////////////////////
573 //														 //
574 //														 //
575 //														 //
576 ///////////////////////////////////////////////////////////
577 
578 //---------------------------------------------------------
DLG_Get_Def_Rect(void)579 wxRect		DLG_Get_Def_Rect(void)
580 {
581 //	wxRect	r(wxGetClientDisplayRect());
582 	wxRect	r(g_pSAGA_Frame->GetScreenRect());
583 
584 	r.Deflate((int)(0.15 * r.GetWidth()), (int)(0.15 * r.GetHeight()));
585 
586 	return( r );
587 }
588 
589 //---------------------------------------------------------
DLG_Get_Def_Position(void)590 wxPoint		DLG_Get_Def_Position(void)
591 {
592 	return( DLG_Get_Def_Rect().GetPosition() );
593 }
594 
595 //---------------------------------------------------------
DLG_Get_Def_Size(void)596 wxSize		DLG_Get_Def_Size(void)
597 {
598 	return( DLG_Get_Def_Rect().GetSize() );
599 }
600 
601 
602 ///////////////////////////////////////////////////////////
603 //														 //
604 //														 //
605 //														 //
606 ///////////////////////////////////////////////////////////
607 
608 //---------------------------------------------------------
DLG_Parameters(CSG_Parameters * pParameters,const wxString & Caption,const wxString & Description)609 bool		DLG_Parameters(CSG_Parameters *pParameters, const wxString &Caption, const wxString &Description)
610 {
611 	if( pParameters && pParameters->Get_Count() > 0 )
612 	{
613 		wxString	Name(pParameters->Get_Name().c_str());
614 
615 		CDLG_Parameters	dlg(pParameters, Caption.IsEmpty() ? Name : Caption, Description);
616 
617 		return( dlg.ShowModal() == wxID_OK );
618 	}
619 
620 	return( false );
621 }
622 
623 //---------------------------------------------------------
DLG_Text(const wxString & Caption,wxString & Text)624 bool		DLG_Text(const wxString &Caption, wxString &Text)
625 {
626 	CDLG_Text		dlg(&Text, Caption);
627 
628 	return( dlg.ShowModal() == wxID_OK );
629 }
630 
631 //---------------------------------------------------------
DLG_Login(wxString & Username,wxString & Password,const wxString & Caption)632 bool		DLG_Login(wxString &Username, wxString &Password, const wxString &Caption)
633 {
634 	CSG_Parameters	Login(_TL("Login"));
635 
636 	if( Caption.Length() > 0 )
637 	{
638 		Login.Set_Name(&Caption);
639 	}
640 
641 	Login.Add_String("", "USERNAME", _TL("Username"), _TL(""), &Username, false, false);
642 	Login.Add_String("", "PASSWORD", _TL("Password"), _TL(""), &Password, false, true );
643 
644 	if( DLG_Parameters(&Login) )
645 	{
646 		Username	= Login("USERNAME")->asString();
647 		Password	= Login("PASSWORD")->asString();
648 
649 		return( true );
650 	}
651 
652 	return( false );
653 }
654 
655 //---------------------------------------------------------
DLG_Table(const wxString & Caption,CSG_Table * pTable)656 bool		DLG_Table(const wxString &Caption, CSG_Table *pTable)
657 {
658 	CDLG_Table		dlg(pTable, Caption);
659 
660 	return( dlg.ShowModal() == wxID_OK );
661 }
662 
663 //---------------------------------------------------------
DLG_Table_Fields(const wxString & Caption,CSG_Parameter_Table_Fields * pFields)664 bool		DLG_Table_Fields(const wxString &Caption, CSG_Parameter_Table_Fields *pFields)
665 {
666 	CSG_Table	*pTable	= pFields->Get_Table();
667 
668 	if( pTable )
669 	{
670 		int				i;
671 		CSG_Parameters	P;
672 
673 		for(i=0; i<pTable->Get_Field_Count(); i++)
674 		{
675 			P.Add_Value(NULL, SG_Get_String(i), pTable->Get_Field_Name(i), _TL(""), PARAMETER_TYPE_Bool, false);
676 		}
677 
678 		for(i=0; i<pFields->Get_Count(); i++)
679 		{
680 			CSG_Parameter	*pParameter	= P(pFields->Get_Index(i));
681 
682 			if( pParameter )
683 			{
684 				pParameter->Set_Value(true);
685 			}
686 		}
687 
688 		if( DLG_Parameters(&P) )
689 		{
690 			CSG_String	s;
691 
692 			for(i=0; i<pTable->Get_Field_Count(); i++)
693 			{
694 				if( P(i)->asBool() )
695 				{
696 					s	+= CSG_String::Format(s.Length() ? SG_T(",%d") : SG_T("%d"), i);
697 				}
698 			}
699 
700 			pFields->Set_Value(s);
701 
702 			return( true );
703 		}
704 	}
705 
706 	return( false );
707 }
708 
709 //---------------------------------------------------------
DLG_Choices(const wxString & Caption,CSG_Parameter_Choices * pChoices)710 bool		DLG_Choices(const wxString &Caption, CSG_Parameter_Choices *pChoices)
711 {
712 	CDLG_Choices	dlg(pChoices, Caption);
713 
714 	return( dlg.ShowModal() == wxID_OK );
715 }
716 
717 //---------------------------------------------------------
DLG_List(const wxString & Caption,CSG_Parameter_List * pList)718 bool		DLG_List(const wxString &Caption, CSG_Parameter_List *pList)
719 {
720 	CDLG_List_Base	*pDialog;
721 
722 	switch( pList->Get_Type() )
723 	{
724 	case PARAMETER_TYPE_Grid_List      : pDialog = new CDLG_List_Grid      ((CSG_Parameter_Grid_List       *)pList, Caption); break;
725 	case PARAMETER_TYPE_Grids_List     : pDialog = new CDLG_List_Grids     ((CSG_Parameter_Grids_List      *)pList, Caption); break;
726 	case PARAMETER_TYPE_Table_List     : pDialog = new CDLG_List_Table     ((CSG_Parameter_Table_List      *)pList, Caption); break;
727 	case PARAMETER_TYPE_Shapes_List    : pDialog = new CDLG_List_Shapes    ((CSG_Parameter_Shapes_List     *)pList, Caption); break;
728 	case PARAMETER_TYPE_TIN_List       : pDialog = new CDLG_List_TIN       ((CSG_Parameter_TIN_List        *)pList, Caption); break;
729 	case PARAMETER_TYPE_PointCloud_List: pDialog = new CDLG_List_PointCloud((CSG_Parameter_PointCloud_List *)pList, Caption); break;
730 	default                            : pDialog = NULL;	break;
731 	}
732 
733 	if( pDialog )
734 	{
735 		bool	bResult	= pDialog->ShowModal() == wxID_OK;
736 
737 		delete(pDialog);
738 
739 		return( bResult );
740 	}
741 
742 	return( false );
743 }
744 
745 //---------------------------------------------------------
DLG_Colors(CSG_Colors * pColors)746 bool		DLG_Colors(CSG_Colors *pColors)
747 {
748 	CDLG_Colors		dlg(pColors);
749 
750 	return( dlg.ShowModal() == wxID_OK );
751 }
752 
753 
754 ///////////////////////////////////////////////////////////
755 //														 //
756 //														 //
757 //														 //
758 ///////////////////////////////////////////////////////////
759 
760 //---------------------------------------------------------
DLG_Colors(int & Palette)761 bool		DLG_Colors(int &Palette)
762 {
763 	wxString	Palettes[SG_COLORS_COUNT];
764 
765 	for(int i=0; i<SG_COLORS_COUNT; i++)
766 	{
767 		Palettes[i]	= SG_Colors_Get_Name(i).c_str();
768 	}
769 
770 	wxSingleChoiceDialog	dlg(MDI_Get_Top_Window(), "",
771 		_TL("Preset Selection"), SG_COLORS_COUNT, Palettes
772 	);
773 
774 	if( dlg.ShowModal() == wxID_OK )
775 	{
776 		Palette	= dlg.GetSelection();
777 
778 		return( true );
779 	}
780 
781 	return( false );
782 }
783 
784 //---------------------------------------------------------
DLG_Color(long & _Colour)785 bool		DLG_Color(long &_Colour)
786 {
787 	static wxColourData	Colours;
788 
789 	Colours.SetChooseFull(true);
790 
791 	wxColour		Colour(SG_GET_R(_Colour), SG_GET_G(_Colour), SG_GET_B(_Colour));
792 	wxColourDialog	dlg(MDI_Get_Top_Window(), &Colours);
793 
794 	dlg.GetColourData().SetColour(Colour);
795 
796 	if( dlg.ShowModal() == wxID_OK )
797 	{
798 		Colours	= dlg.GetColourData();
799 		Colour	= dlg.GetColourData().GetColour();
800 		_Colour	= Get_Color_asInt(Colour);
801 
802 		return( true );
803 	}
804 
805 	return( false );
806 }
807 
808 //---------------------------------------------------------
DLG_Color_From_Text(long & Colour)809 bool		DLG_Color_From_Text(long &Colour)
810 {
811 	wxString Text(wxString::Format("#%02X%02X%02X", SG_GET_R(Colour), SG_GET_G(Colour), SG_GET_B(Colour)));
812 
813 	if( DLG_Get_Text(Text, _TL("Enter Color Code"), wxString::Format("%s,\n%s\n(%s)",
814 		_TL("Enter comma separated red, green, blue values"),
815 		_TL("or use a leading '#' for their hexadecimal representation."),
816 		_TL("use right mouse button to open a color dialog"))) )
817 	{
818 		long oldColour = Colour;
819 
820 		if( Text[0] == '#' )
821 		{
822 			wxColour c; c.Set(Text);
823 
824 			Colour = Get_Color_asInt(c);
825 		}
826 		else
827 		{
828 			CSG_Strings	c = SG_String_Tokenize(&Text, ",;");
829 
830 			if( c.Get_Count() >= 3 )
831 			{
832 				Colour = SG_GET_RGB(c[0].asInt(), c[1].asInt(), c[2].asInt());
833 			}
834 		}
835 
836 		return( Colour != oldColour );
837 	}
838 
839 	return( false );
840 }
841 
842 //---------------------------------------------------------
DLG_Font(CSG_Parameter * pFont)843 bool		DLG_Font(CSG_Parameter *pFont)
844 {
845 	wxFont		Font;
846 	wxColour	Colour;
847 
848 	if( Set_Font(pFont, Font, Colour) )
849 	{
850 		wxFontDialog	dlg(MDI_Get_Top_Window());
851 
852 		dlg.GetFontData().SetInitialFont(Font);
853 		dlg.GetFontData().SetColour     (Colour);
854 
855 		if( dlg.ShowModal() == wxID_OK )
856 		{
857 			Font	= dlg.GetFontData().GetChosenFont();
858 			Colour	= dlg.GetFontData().GetColour();
859 
860 			return( Set_Font(Font, Colour, pFont) );
861 		}
862 	}
863 
864 	return( false );
865 }
866 
867 
868 ///////////////////////////////////////////////////////////
869 //														 //
870 //														 //
871 //														 //
872 ///////////////////////////////////////////////////////////
873 
874 //---------------------------------------------------------
DLG_Get_Text(wxString & Value,const wxString & Caption,const wxString & Text)875 bool		DLG_Get_Text(wxString &Value, const wxString &Caption, const wxString &Text)
876 {
877 	wxTextEntryDialog	dlg(MDI_Get_Top_Window(), Text, Caption, Value);
878 
879 	if( dlg.ShowModal() == wxID_OK )
880 	{
881 		Value	= dlg.GetValue();
882 
883 		return( true );
884 	}
885 
886 	return( false );
887 }
888 
DLG_Get_Text(wxString & Value)889 bool		DLG_Get_Text(wxString &Value)
890 {
891 	return( DLG_Get_Text(Value, _TL("Input"), _TL("Please enter a text:")) );
892 }
893 
894 //---------------------------------------------------------
DLG_Get_Number(double & Value,const wxString & Caption,const wxString & Text)895 bool		DLG_Get_Number(double &Value, const wxString &Caption, const wxString &Text)
896 {
897 	wxTextEntryDialog	dlg(MDI_Get_Top_Window(), Text, Caption, wxString::Format(wxT("%f"), Value));
898 
899 	return( dlg.ShowModal() == wxID_OK && dlg.GetValue().ToDouble(&Value) );
900 }
901 
DLG_Get_Number(double & Value)902 bool		DLG_Get_Number(double &Value)
903 {
904 	return( DLG_Get_Number(Value, _TL("Input"), _TL("Please enter a numeric value:")) );
905 }
906 
907 //---------------------------------------------------------
DLG_Get_Number(int & Value,const wxString & Caption,const wxString & Text)908 bool		DLG_Get_Number(int &Value, const wxString &Caption, const wxString &Text)
909 {
910 	long				lValue;
911 	wxTextEntryDialog	dlg(MDI_Get_Top_Window(), Text, Caption, wxString::Format(wxT("%d"), Value));
912 
913 	if( dlg.ShowModal() == wxID_OK && dlg.GetValue().ToLong(&lValue) )
914 	{
915 		Value	= lValue;
916 
917 		return( true );
918 	}
919 
920 	return( false );
921 }
922 
DLG_Get_Number(int & Value)923 bool		DLG_Get_Number(int &Value)
924 {
925 	return( DLG_Get_Number(Value, _TL("Input"), _TL("Please enter a numeric value:")) );
926 }
927 
928 
929 ///////////////////////////////////////////////////////////
930 //														 //
931 //														 //
932 //														 //
933 ///////////////////////////////////////////////////////////
934 
935 //---------------------------------------------------------
DLG_Directory(wxString & Directory,const wxString & Caption,const wxString & def_Dir)936 bool		DLG_Directory(wxString &Directory, const wxString &Caption, const wxString &def_Dir)
937 {
938 	wxDirDialog	dlg(MDI_Get_Top_Window(), Caption, def_Dir);
939 
940 	if( dlg.ShowModal() == wxID_OK )
941 	{
942 		Directory	= dlg.GetPath();
943 
944 		return( true );
945 	}
946 
947 	return( false );
948 }
949 
DLG_Directory(wxString & Directory,const wxString & Caption)950 bool		DLG_Directory(wxString &Directory, const wxString &Caption)
951 {
952 	return( DLG_Directory(Directory, Caption, SG_File_Get_Path(&Directory).w_str()) );
953 }
954 
955 //---------------------------------------------------------
DLG_Save(wxString & File_Path,const wxString & Caption,const wxString & def_Dir,const wxString & def_File,const wxString & Filter)956 bool		DLG_Save(wxString &File_Path, const wxString &Caption, const wxString &def_Dir, const wxString &def_File, const wxString &Filter)
957 {
958 	wxString	Dir(def_Dir);
959 
960 	if( !wxDirExists(def_Dir) )
961 	{
962 		CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(-1), Dir);
963 	}
964 
965 	wxFileDialog	dlg(MDI_Get_Top_Window(), Caption, Dir, def_File, Filter, wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
966 
967 	if( dlg.ShowModal() == wxID_OK )
968 	{
969 		File_Path	= dlg.GetPath();
970 
971 		if( !wxDirExists(def_Dir) )
972 		{
973 			CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(-1), SG_File_Get_Path(&File_Path).w_str());
974 		}
975 
976 		return( true );
977 	}
978 
979 	return( false );
980 }
981 
DLG_Save(wxString & File_Path,int ID_DLG)982 bool		DLG_Save(wxString &File_Path, int ID_DLG)
983 {
984 	wxString	def_Dir, def_Name;
985 
986 	def_Name	= SG_File_Get_Name(&File_Path, true).w_str();
987 	def_Dir		= SG_File_Get_Path(&File_Path).w_str();
988 
989 	if( !wxDirExists(def_Dir) )
990 	{
991 		CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), def_Dir);
992 	}
993 
994 	if( DLG_Save(File_Path, DLG_Get_FILE_Caption(ID_DLG), def_Dir, def_Name, DLG_Get_FILE_Filter(ID_DLG)) )
995 	{
996 		CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), SG_File_Get_Path(&File_Path).w_str());
997 
998 		return( true );
999 	}
1000 
1001 	return( false );
1002 }
1003 
DLG_Save(wxString & File_Path,const wxString & Caption,const wxString & Filter)1004 bool		DLG_Save(wxString &File_Path, const wxString &Caption, const wxString &Filter)
1005 {
1006 	return( DLG_Save(File_Path, Caption, SG_File_Get_Path(&File_Path).w_str(), SG_File_Get_Name(&File_Path, true).w_str(), Filter) );
1007 }
1008 
1009 //---------------------------------------------------------
DLG_Open(wxString & File_Path,const wxString & Caption,const wxString & def_Dir,const wxString & def_File,const wxString & Filter)1010 bool		DLG_Open(wxString &File_Path, const wxString &Caption, const wxString &def_Dir, const wxString &def_File, const wxString &Filter)
1011 {
1012 	wxString	Dir(def_Dir);
1013 
1014 	if( !wxDirExists(def_Dir) )
1015 	{
1016 		CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(-1), Dir);
1017 	}
1018 
1019 	wxFileDialog	dlg(MDI_Get_Top_Window(), Caption, Dir, def_File, Filter, wxFD_OPEN|wxFD_FILE_MUST_EXIST);
1020 
1021 	if( dlg.ShowModal() == wxID_OK )
1022 	{
1023 		File_Path	= dlg.GetPath();
1024 
1025 		if( !wxDirExists(def_Dir) )
1026 		{
1027 			CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(-1), SG_File_Get_Path(&File_Path).w_str());
1028 		}
1029 
1030 		return( true );
1031 	}
1032 
1033 	return( false );
1034 }
1035 
DLG_Open(wxString & File_Path,int ID_DLG)1036 bool		DLG_Open(wxString &File_Path, int ID_DLG)
1037 {
1038 	wxString	def_Dir;
1039 
1040 	CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), def_Dir);
1041 
1042 	if( DLG_Open(File_Path, DLG_Get_FILE_Caption(ID_DLG), def_Dir, wxT(""), DLG_Get_FILE_Filter(ID_DLG)) )
1043 	{
1044 		CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), SG_File_Get_Path(&File_Path).w_str());
1045 
1046 		return( true );
1047 	}
1048 
1049 	return( false );
1050 }
1051 
DLG_Open(wxString & File_Path,const wxString & Caption,const wxString & Filter)1052 bool		DLG_Open(wxString &File_Path, const wxString &Caption, const wxString &Filter)
1053 {
1054 	return( DLG_Open(File_Path, Caption, SG_File_Get_Path(&File_Path).w_str(), SG_File_Get_Name(&File_Path, true).w_str(), Filter) );
1055 }
1056 
1057 //---------------------------------------------------------
DLG_Open(wxArrayString & File_Paths,const wxString & Caption,const wxString & def_Dir,const wxString & Filter)1058 bool		DLG_Open(wxArrayString &File_Paths, const wxString &Caption, const wxString &def_Dir, const wxString &Filter)
1059 {
1060 	wxString	Dir(def_Dir);
1061 
1062 	if( !wxDirExists(def_Dir) )
1063 	{
1064 		CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(-1), Dir);
1065 	}
1066 
1067 	wxFileDialog	dlg(MDI_Get_Top_Window(), Caption, Dir, wxT(""), Filter, wxFD_OPEN|wxFD_FILE_MUST_EXIST|wxFD_MULTIPLE);
1068 
1069 	if( dlg.ShowModal() == wxID_OK )
1070 	{
1071 		dlg.GetPaths(File_Paths);
1072 
1073 		if( File_Paths.GetCount() > 0 )
1074 		{
1075 			if( !wxDirExists(def_Dir) )
1076 			{
1077 				CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(-1), SG_File_Get_Path(&File_Paths[0]).w_str());
1078 			}
1079 
1080 			return( true );
1081 		}
1082 	}
1083 
1084 	return( false );
1085 }
1086 
DLG_Open(wxArrayString & File_Paths,int ID_DLG)1087 bool		DLG_Open(wxArrayString &File_Paths, int ID_DLG)
1088 {
1089 	wxString	def_Dir;
1090 
1091 	CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), def_Dir);
1092 
1093 	if( DLG_Open(File_Paths, DLG_Get_FILE_Caption(ID_DLG), def_Dir, DLG_Get_FILE_Filter(ID_DLG)) )
1094 	{
1095 		CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), SG_File_Get_Path(&File_Paths[0]).w_str());
1096 
1097 		return( true );
1098 	}
1099 
1100 	return( false );
1101 }
1102 
DLG_Open(wxArrayString & File_Paths,const wxString & Caption,const wxString & Filter)1103 bool		DLG_Open(wxArrayString &File_Paths, const wxString &Caption, const wxString &Filter)
1104 {
1105 	return( DLG_Open(File_Paths, Caption, wxT(""), Filter) );
1106 }
1107 
1108 
1109 ///////////////////////////////////////////////////////////
1110 //														 //
1111 //														 //
1112 //														 //
1113 ///////////////////////////////////////////////////////////
1114 
1115 //---------------------------------------------------------
DLG_Image_Save(wxString & File_Path,int & Type,const wxString & def_Dir,const wxString & def_File)1116 bool		DLG_Image_Save(wxString &File_Path, int &Type, const wxString &def_Dir, const wxString &def_File)
1117 {
1118 	static	int	Filter_Index	= 3;
1119 
1120 	wxString	Dir(def_Dir);
1121 
1122 	if( !wxDirExists(def_Dir) )
1123 	{
1124 		CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(-1), Dir);
1125 	}
1126 
1127 	wxFileDialog	dlg(
1128 		MDI_Get_Top_Window(), _TL("Save As Image"), Dir, def_File, wxString::Format(
1129 			"%s (*.bmp)|*.bmp|"
1130 			"%s (*.jpg)|*.jpg;*.jif;*.jpeg|"
1131 			"%s (*.tif)|*.tif;*.tiff|"
1132 			"%s (*.png)|*.png|"
1133 			"%s (*.gif)|*.gif|"
1134 			"%s (*.pcx)|*.pcx",
1135 			_TL("Windows or OS/2 Bitmap"),
1136 			_TL("JPEG - JFIF Compliant"),
1137 			_TL("Tagged Image File Format"),
1138 			_TL("Portable Network Graphics"),
1139 			_TL("CompuServe Graphics Interchange"),
1140 			_TL("Zsoft Paintbrush")
1141 		), wxFD_SAVE|wxFD_OVERWRITE_PROMPT
1142 	);
1143 
1144 	dlg.SetFilterIndex(Filter_Index);
1145 
1146 	if( dlg.ShowModal() == wxID_OK )
1147 	{
1148 		File_Path		= dlg.GetPath();
1149 		Filter_Index	= dlg.GetFilterIndex();
1150 
1151 		switch( Filter_Index )
1152 		{
1153 		default: Type	= wxBITMAP_TYPE_BMP ;	break;
1154 		case  1: Type	= wxBITMAP_TYPE_JPEG;	break;
1155 		case  2: Type	= wxBITMAP_TYPE_TIF ;	break;
1156 		case  3: Type	= wxBITMAP_TYPE_PNG ;	break;
1157 		case  4: Type	= wxBITMAP_TYPE_GIF ;	break;
1158  		case  5: Type	= wxBITMAP_TYPE_PCX ;	break;
1159 		case  6: Type	= wxBITMAP_TYPE_PNM ;	break;
1160 		}
1161 
1162 		if( !wxDirExists(def_Dir) )
1163 		{
1164 			CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(-1), SG_File_Get_Path(&File_Path).w_str());
1165 		}
1166 
1167 		return( true );
1168 	}
1169 
1170 	return( false );
1171 }
1172 
1173 
1174 ///////////////////////////////////////////////////////////
1175 //														 //
1176 //														 //
1177 //														 //
1178 ///////////////////////////////////////////////////////////
1179 
1180 //---------------------------------------------------------
DLG_Message_Show(const wxString & Message,const wxString & Caption)1181 void		DLG_Message_Show(const wxString &Message, const wxString &Caption)
1182 {
1183 	wxMessageDialog	dlg(MDI_Get_Top_Window(), Message, Caption, wxOK);
1184 
1185 	dlg.ShowModal();
1186 }
1187 
DLG_Message_Show(int ID_DLG)1188 void		DLG_Message_Show(int ID_DLG)
1189 {
1190 	DLG_Message_Show(DLG_Get_Text(ID_DLG), DLG_Get_Caption(ID_DLG));
1191 }
1192 
DLG_Message_Show(const wxString & Message)1193 void		DLG_Message_Show(const wxString &Message)
1194 {
1195 	DLG_Message_Show(Message, DLG_Get_Caption(-1));
1196 }
1197 
1198 //---------------------------------------------------------
DLG_Message_Show_Error(const wxString & Message,const wxString & Caption)1199 int			DLG_Message_Show_Error(const wxString &Message, const wxString &Caption)
1200 {
1201 	wxMessageDialog	dlg(MDI_Get_Top_Window(), Message, Caption, wxOK|wxCANCEL|wxICON_ERROR);
1202 
1203 	switch( dlg.ShowModal() )
1204 	{
1205 		case wxID_OK: default:
1206 			return( 1 );
1207 
1208 		case wxID_CANCEL:
1209 			return( 0 );
1210 	}
1211 }
1212 
DLG_Message_Show_Error(int ID_DLG)1213 int			DLG_Message_Show_Error(int ID_DLG)
1214 {
1215 	return( DLG_Message_Show_Error(DLG_Get_Text(ID_DLG), DLG_Get_Caption(ID_DLG)) );
1216 }
1217 
1218 //---------------------------------------------------------
DLG_Message_Confirm(const wxString & Message,const wxString & Caption)1219 bool		DLG_Message_Confirm(const wxString &Message, const wxString &Caption)
1220 {
1221 	wxMessageDialog	dlg(MDI_Get_Top_Window(), Message, Caption, wxYES_NO|wxICON_EXCLAMATION);
1222 
1223 	return( dlg.ShowModal() == wxID_YES );
1224 }
1225 
DLG_Message_Confirm(int ID_DLG)1226 bool		DLG_Message_Confirm(int ID_DLG)
1227 {
1228 	return( DLG_Message_Confirm(DLG_Get_Text(ID_DLG), DLG_Get_Caption(ID_DLG)) );
1229 }
1230 
1231 //---------------------------------------------------------
DLG_Message_YesNoCancel(const wxString & Message,const wxString & Caption)1232 int			DLG_Message_YesNoCancel(const wxString &Message, const wxString &Caption)
1233 {
1234 	wxMessageDialog	dlg(MDI_Get_Top_Window(), Message, Caption, wxYES|wxNO|wxCANCEL|wxICON_QUESTION);
1235 
1236 	switch( dlg.ShowModal() )
1237 	{
1238 		case wxID_YES: default:
1239 			return( 0 );
1240 
1241 		case wxID_NO:
1242 			return( 1 );
1243 
1244 		case wxID_CANCEL:
1245 			return( 2 );
1246 	}
1247 }
1248 
DLG_Message_YesNoCancel(int ID_DLG)1249 int			DLG_Message_YesNoCancel(int ID_DLG)
1250 {
1251 	return( DLG_Message_YesNoCancel(DLG_Get_Text(ID_DLG), DLG_Get_Caption(ID_DLG)) );
1252 }
1253 
1254 
1255 ///////////////////////////////////////////////////////////
1256 //														 //
1257 //														 //
1258 //														 //
1259 ///////////////////////////////////////////////////////////
1260 
1261 //---------------------------------------------------------
DLG_Maps_Add(void)1262 int			DLG_Maps_Add(void)
1263 {
1264 	if( g_pMaps )
1265 	{
1266 		if( g_pMaps->Get_Count() <= 0 )
1267 		{
1268 			return( 0 );
1269 		}
1270 		else
1271 		{
1272 			wxString	*Maps	= new wxString[g_pMaps->Get_Count() + 1];
1273 
1274 			for(int i=0; i<g_pMaps->Get_Count(); i++)
1275 			{
1276 				Maps[i]	= g_pMaps->Get_Map(i)->Get_Name();
1277 			}
1278 
1279 			Maps[g_pMaps->Get_Count()]	= _TL("New");
1280 
1281 			wxSingleChoiceDialog	dlg(
1282 				MDI_Get_Top_Window(),
1283 				_TL("Map Selection"),
1284 				_TL("Add layer to selected map"),
1285 				g_pMaps->Get_Count() + 1,
1286 				Maps
1287 			);
1288 
1289 			dlg.SetSelection(g_pMaps->Get_Count());
1290 
1291 			bool	bOk	= dlg.ShowModal() == wxID_OK;
1292 
1293 			delete[](Maps);
1294 
1295 			if( bOk )
1296 			{
1297 				return( dlg.GetSelection() );
1298 			}
1299 		}
1300 	}
1301 
1302 	return( -1 );
1303 }
1304 
1305 
1306 ///////////////////////////////////////////////////////////
1307 //														 //
1308 //														 //
1309 //														 //
1310 ///////////////////////////////////////////////////////////
1311 
1312 //---------------------------------------------------------
1313