00001
00028 #include "Defs.h"
00029 #include "mhDefs.h"
00030
00031 #if defined(WX) && (wxUSE_UNICODE || wxUSE_WCHAR_T)
00032 wxCSConv muCSConv(wxT("ISO-8859-1"));
00033
00034 #endif
00035
00036 wxString FileNameDialog(wxWindow * parent,
00037 int Command,
00038 wxString Filename)
00039 {
00040 #ifdef DEBUG
00041 std::cout << "FileNameDialog: " << Command << std::endl;
00042 #endif
00043
00044 static const wxString logic_sources(_("Mutabor tuning file (*.mut)|*.mut|Old Mutabor tuning file (*.mus)|*.mus|All files (*.*)|*.*"));
00045
00046 static const wxString route_sources(_("Mutabor routing file (*.mur)|*.mur|All files (*.*)|*.*"));
00047
00048 wxString title, filetypes,
00049 dir(wxEmptyString), name(wxEmptyString) , ext(wxEmptyString);
00050
00051 int flags;
00052
00053 switch (Command) {
00054
00055 case CM_FILEOPEN:
00056 title = _("Which Mutabor file shall be loaded?");
00057
00058 filetypes = logic_sources;
00059
00060 flags = wxFD_CHANGE_DIR | wxFD_FILE_MUST_EXIST | wxFD_OPEN;
00061
00062 break;
00063
00064 case CM_EXECUTE:
00065 title = _("Which Mutabor file shall be executed?");
00066
00067 filetypes = logic_sources;
00068
00069 flags = wxFD_CHANGE_DIR | wxFD_FILE_MUST_EXIST | wxFD_OPEN;
00070
00071 break;
00072
00073 case CM_FILESAVEAS:
00074 title = _("Enter the new Mutabor file name, please!");
00075
00076 filetypes = logic_sources;
00077
00078 flags = wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT | wxFD_SAVE;
00079
00080 break;
00081
00082 case CM_ROUTELOAD:
00083 title = _("Which Mutabor route file shall be loaded?");
00084
00085 filetypes = route_sources;
00086
00087 flags = wxFD_CHANGE_DIR | wxFD_FILE_MUST_EXIST | wxFD_OPEN;
00088
00089 break;
00090
00091 case CM_ROUTESAVE:
00092
00093 case CM_ROUTESAVEAS:
00094 title = _("Enter the new Mutabor route file name, please!");
00095
00096 filetypes = route_sources;
00097
00098 flags = wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT | wxFD_SAVE;
00099
00100 break;
00101
00102 default:
00103 wxLogError(_("Unexpected Command Id in FileNameDialog: %d"),Command);
00104
00105 return wxString(_T(""));
00106 }
00107
00108 if (!Filename.IsEmpty()) {
00109 wxFileName splitter(Filename);
00110 ext = splitter.GetExt();
00111 name = splitter.GetFullName();
00112 dir = splitter.GetPath();
00113 }
00114
00115 wxFileDialog * FileSelector = new wxFileDialog(parent, title, dir, name, filetypes,
00116
00117 #ifdef __WXCOCOA__
00118 0
00119 #else
00120 flags
00121 #endif
00122
00123 );
00124
00125 int cmd = FileSelector->ShowModal();
00126
00127 wxString retval;
00128 retval = (cmd == wxID_OK) ? (FileSelector->GetPath()) : wxString(wxEmptyString);
00129
00130 FileSelector->Destroy();
00131
00132 return retval;
00133 }
00134
00135 void PRINTWINDOW (wxWindow * window, const wxString & offset = _T (""))
00136 {
00137 if (!window) DEBUGLOG2 (other,_T("NULL window."));
00138
00139 }
00140
00141 #ifdef DEBUG
00142 void PRINTSIZER (wxSizer * sizer, const wxString & offset)
00143 {
00144 if (!sizer) DEBUGLOG2 (other,_T("NULL Pointer."));
00145 DEBUGLOGTYPE (other, *sizer, _T ("%sSizer: %p to Window %p"),
00146 offset.c_str (),
00147 sizer,sizer->GetContainingWindow ());
00148 wxSizerItemList &childs = sizer -> GetChildren ();
00149 for (wxSizerItemList::iterator i = childs.begin ();
00150 i!=childs.end (); i++) {
00151 wxSizerItem * item = *i;
00152 wxRect rect = item->GetRect ();
00153 if (item->IsSizer ()) {
00154 DEBUGLOGTYPE (other, *sizer,
00155 _T ("%s%s sizer from (%d,%d) to (%d,%d):"),
00156 offset.c_str (),
00157 (item -> IsShown ()?
00158 _T ("shown"):_T ("hidden")),
00159 rect.x,rect.y, rect.x+rect.width,
00160 rect.y+rect.height);
00161 PRINTSIZER (item->GetSizer (), offset + _T (" | "));
00162 } else if (item -> IsWindow ()) {
00163 wxWindow * window = item->GetWindow ();
00164 DEBUGLOGTYPE (other, *window,
00165 _T ("%sWindow: %p with parent window %p (%s) from (%d,%d) to (%d,%d)"),
00166 offset.c_str (),
00167 window,window->GetParent (),
00168 (item -> IsShown ()?
00169 _T ("shown"):_T ("hidden")),
00170 rect.x,rect.y, rect.x+rect.width,
00171 rect.y+rect.height);
00172 if (window -> GetSizer())
00173 PRINTSIZER(window -> GetSizer(), offset + _T(" [] "));
00174 } else if (item -> IsSpacer ()) {
00175 wxSize size = item->GetSpacer ();
00176 DEBUGLOGTYPE (other, size,
00177 _T ("%sSpacer: %d x %d (%s) from (%d,%d) to (%d,%d)"),
00178 offset.c_str (),
00179 size.x,size.y,
00180 (item -> IsShown ()?
00181 _T ("shown"):_T ("hidden")),
00182 rect.x,rect.y, rect.x+rect.width,
00183 rect.y+rect.height);
00184 }
00185 }
00186 }
00187 #endif
00188
00189