Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Helper.h
1 //
2 // vtui Helper.h
3 // Some useful standalone functions for use with wxWidgets.
4 //
5 // Copyright (c) 2002-2009 Virtual Terrain Project
6 // Free for all uses, see license.txt for details.
7 //
8 
9 #include "vtdata/vtString.h"
10 #include "vtdata/MathTypes.h"
11 
12 bool IsGUIApp();
13 
14 class vtDIB;
15 class wxBitmap;
16 class wxColour;
17 class wxStaticBitmap;
18 class wxBitmapButton;
19 class wxComboBox;
20 class wxChoice;
21 
23 
24 wxBitmap *MakeColorBitmap(int xsize, int ysize, wxColour color);
25 wxBitmap *DibToBitmap(vtDIB *dib);
26 
27 void FillWithColor(wxStaticBitmap *pStaticBitmap, const wxColour &color);
28 void FillWithColor(wxBitmapButton *pBitmapButton, const wxColour &color);
29 void FillWithColorSize(wxStaticBitmap *pStaticBitmap, int w, int h, const wxColour &color);
30 void FillWithColorSize(wxBitmapButton *pBitmapButton, int w, int h, const wxColour &color);
31 
32 void FillWithColor(wxStaticBitmap *pStaticBitmap, const RGBi &color);
33 void FillWithColor(wxBitmapButton *pBitmapButton, const RGBi &color);
34 void FillWithColorSize(wxStaticBitmap *pStaticBitmap, int w, int h, const RGBi &color);
35 void FillWithColorSize(wxBitmapButton *pBitmapButton, int w, int h, const RGBi &color);
36 
37 int AddFilenamesToComboBox(wxComboBox *box, const char *directory,
38  const char *wildcard, int omit_chars = 0);
39 int AddFilenamesToChoice(wxChoice *choice, const char *directory,
40  const char *wildcard, int omit_chars = 0);
41 int AddFilenamesToStringArray(vtStringArray &array, const char *directory,
42  const char *wildcard, int omit_chars = 0);
43 void AddType(wxString &str, const wxString &filter);
44 
46 
47 void IncreaseRect(wxRect &rect, int adjust);
48 void DrawRectangle(wxDC *pDC, const wxRect &rect, bool bCrossed = false);
49 
51 
52 #if WIN32 && (wxVERSION_NUMBER < 2900)
53 
57 class wxDC2 : public wxDC
58 {
59 public:
60  void StretchBlit(const wxBitmap &bmp, wxCoord x, wxCoord y,
61  wxCoord width, wxCoord height, wxCoord src_x, wxCoord src_y,
62  wxCoord src_width, wxCoord src_height);
63 };
64 #endif // WIN32
65 
66 bool LogWindowsVersion();
67 vtString FormatCoord(bool bGeo, double val, bool minsec = false);
68 enum wxLanguage GetLangFromName(const wxString &name);
69 
71 // Helper methods which provide a progress dialog.
72 
73 extern bool progress_callback(int amount);
74 void OpenProgressDialog(const wxString &title, bool bCancellable = false, wxWindow *pParent = NULL);
75 void SetProgressDialogParent(wxWindow *pParent);
76 void CloseProgressDialog();
77 bool UpdateProgressDialog(int amount, const wxString& newmsg = wxT(""));
78 void ResumeProgressDialog();
79 
81 // Helper methods which provide a 'double' progress dialog.
82 
83 extern bool progress_callback2(int amount1, int amount2);
84 extern bool progress_callback_major(int amount);
85 extern bool progress_callback_minor(int amount);
86 void OpenProgressDialog2(const wxString &title, bool bCancellable = false, wxWindow *pParent = NULL);
87 void SetProgressDialog2Width(int width);
88 void CloseProgressDialog2();
89 bool UpdateProgressDialog2(int amount1, int amount2, const wxString& newmsg = wxT(""));
90 void ResumeProgressDialog2();
91 
93 
94 int GuessZoneFromGeo(const DPoint2 &pos);
95 
97 
98 vtString MakeFilenameDB(const vtString &base, int col, int row,
99  int relative_lod);
100 
102 wxString StartOfFilenameWX(const wxString &strFullPath);
103 wxString ToBackslash(const wxString &path);
104 void RemoveFileExtensions(wxString &fname, bool bAll = true);
105 
107 
108 // Initialize GDAL/OGR. If there are problems, report them with a message box and VTLOG.
109 void CheckForGDALAndWarn();
110 
111 // Display a message to the user, and also send it to the log file.
112 void DisplayAndLog(const char *pFormat, ...);
113 void DisplayAndLog(const wchar_t *pFormat, ...);
114 void DisplayAndLog(const wxString &Format, ...);
115 
116 void LaunchAppDocumentation(const vtString &appname,
117  const vtString &local_lang_code);
118 
119 void ConvertArgcArgv(int wxArgc, wxChar** wxArgv, int* pArgc, char*** pArgv);