00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00030
00031
00032
00033
00034 #ifdef __GNUG__
00035 #pragma implementation "ImportDlg.h"
00036 #endif
00037
00038
00039 #include "mg/mgprec.h"
00040
00041 #ifndef mgPRECOMP
00042 #include <wx/wxprec.h>
00043 #include "mg/ImportDlg.h"
00044 #include "mg/GUIUtils.h"
00045 #endif
00046
00047
00048
00049
00050
00051 BEGIN_EVENT_TABLE(mgImportDlg, wxDialog)
00052
00053
00054 EVT_BUTTON( IDC_IMPORTDLG_IMPORT_BTN, mgImportDlg::OnImport )
00055
00056
00057
00058
00059 EVT_TEXT( IDC_IMPORTDLG_INLINEDEXPR_FIELD, mgImportDlg::OnInlinedExprChange )
00060
00061
00062
00063
00064
00065 END_EVENT_TABLE()
00066
00067
00068
00069
00070
00071
00072
00073
00074 mgImportDlg::mgImportDlg( wxWindow *parent, mgMathWnd *wnd, mgMathBox *box,
00075 wxWindowID id, const wxString &title,
00076 const wxPoint &position, const wxSize& size, long style ) :
00077
00078 wxDialog( parent, id, title, position, size, style),
00079 mgMathBoxWndUser(wnd, box)
00080 {
00081
00082
00083
00084
00085
00086
00087
00088
00089 BuildAll();
00090 }
00091
00092 mgImportDlg::~mgImportDlg()
00093 {
00094
00095 mcSAFE_DELETE(m_pFD);
00096 }
00097
00098
00099
00100 void mgImportDlg::BuildCtrls()
00101 {
00102 m_pFD = new wxFileDialog(this, wxT("Load an XHTML/XML file"), wxT(""), wxT(""),
00103 wxT("XHTML files (*.htm; *.html)|*.htm;*.html"), wxSAVE | wxCHANGE_DIR |
00104 wxOVERWRITE_PROMPT);
00105
00106 m_pExpr = new wxTextCtrl(this, IDC_IMPORTDLG_INLINEDEXPR_FIELD, wxT(""));
00107 }
00108
00109 void mgImportDlg::BuildAll()
00110 {
00111 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
00112
00113
00114 BuildCtrls();
00115
00117
00118 wxStaticText *hdr = new wxStaticText(this, -1,
00119 wxT("This dialog allows you to import MathML 2.0 ")
00120 wxT("documents and inlined expressions.\n")
00121 wxT("However, you cannot import both: the following radio")
00122 wxT("buttons allow you to choose which you want to import."));
00123 sizer->Add(
00124 hdr,
00125 0,
00126 wxALL | wxALIGN_LEFT,
00127 10);
00128
00129
00131
00132 wxBoxSizer *type = new wxBoxSizer(wxHORIZONTAL);
00133 type->Add(new wxRadioButton(
00134 this, IDC_IMPORTDLG_MATHML, wxT("MathML"), wxDefaultPosition,
00135 wxSize(-1,-1), wxRB_GROUP),
00136 0, wxALIGN_CENTER | wxRIGHT, 20);
00137 type->Add(new wxRadioButton(
00138 this, IDC_IMPORTDLG_INLINEDEXPR, wxT("Inlined expression")),
00139 0, wxALIGN_CENTER | wxLEFT, 10);
00140
00141
00143
00144 wxStaticBox *sb1 = new wxStaticBox(this, -1, wxT("MathML"));
00145 wxStaticBoxSizer *mathml = new wxStaticBoxSizer(sb1, wxVERTICAL);
00146 mathml->Add(new wxStaticText(this, -1,
00147 wxT("Sorry, MathML import system is not working yet")), 0, wxGROW | wxALL, 5);
00148
00149
00151
00152 wxStaticBox *sb2 = new wxStaticBox(this, -1, wxT("Inlined expressions"));
00153 wxStaticBoxSizer *ex = new wxStaticBoxSizer(sb2, wxVERTICAL);
00154 ex->Add(new wxStaticText(this, -1, wxT("Inlined expressions are the most ")
00155 wxT("commonly used form of math typing: using some simple rules\n")
00156 wxT("(like ^=introduce exponent, *=multiplication ...) complex ")
00157 wxT("expressions can be created\n(even if they become difficult to ")
00158 wxT("write and to understand).")), 0, wxGROW | wxALL, 5);
00159 ex->Add(new wxStaticText(this, -1, wxT("The textbox below allows you to ")
00160 wxT("paste an inlined expression and then to import it.")), 0, wxGROW | wxALL, 5);
00161 ex->Add(m_pExpr, 1, wxGROW | wxALL, 5);
00162
00163
00165
00166 wxBoxSizer *btn = new wxBoxSizer(wxHORIZONTAL);
00167 btn->Add(new wxButton(this, wxID_CANCEL, wxT("Cancel")), 3, wxGROW | wxTOP, 10);
00168 btn->Add(1, 1, 1, wxGROW);
00169
00170 wxButton *def = new wxButton(this, IDC_IMPORTDLG_IMPORT_BTN, wxT("Import"));
00171 btn->Add(def, 3, wxGROW | wxTOP, 10);
00172 def->SetDefault();
00173
00174
00175
00176 sizer->Add(type, 0, wxALIGN_CENTER | wxALL, 10);
00177 sizer->Add(mathml, 2, wxGROW | wxALL, 10);
00178 sizer->Add(ex, 2, wxGROW | wxALL, 10);
00179 sizer->Add(btn, 1, wxGROW | wxALL, 10);
00180
00181 SetSizer(sizer);
00182 sizer->SetSizeHints(this);
00183
00184
00185
00186
00187 this->CentreOnScreen();
00188 }
00189
00190 bool mgImportDlg::isImportingMathML()
00191 {
00192 wxRadioButton *btn = (wxRadioButton *)FindWindowById(IDC_IMPORTDLG_MATHML, this);
00193
00194
00195 return btn->GetValue();
00196 }
00197
00198
00199
00200
00201
00202 void mgImportDlg::OnImport(wxCommandEvent &ev)
00203 {
00204 mgLogDebug(wxT("mgImportDlg::OnImport() - importing %s..."),
00205 (isImportingMathML() ? wxT("a MathML file") : wxT("an inlined expression")));
00206
00207 if (isImportingMathML()) {
00208
00209 } else {
00210
00211
00212 if (m_pExpr->GetValue().IsEmpty()) {
00213
00214 wxMessageBox(wxT("Cannot import an empty string !"), wxT("Warning"),
00215 wxICON_EXCLAMATION | wxOK | wxCENTRE);
00216 return;
00217 }
00218
00219
00220 GetBox()->ImportInlinedExpr(m_pExpr->GetValue());
00221 }
00222
00223 EndModal(wxID_OK);
00224 }
00225
00226 void mgImportDlg::OnInlinedExprChange(wxCommandEvent &ev)
00227 {
00228 wxRadioButton *btn = (wxRadioButton *)FindWindowById(IDC_IMPORTDLG_INLINEDEXPR, this);
00229
00230
00231 btn->SetValue(TRUE);
00232 }
00233
00234
00235