X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/88a8b04e9c387b5e5295d42f2ed23afcf37e3c2e..4e15d1caa03346c126015019c1fdf093033ef40b:/samples/stc/edit.cpp diff --git a/samples/stc/edit.cpp b/samples/stc/edit.cpp index 82ee73271a..17e3737927 100644 --- a/samples/stc/edit.cpp +++ b/samples/stc/edit.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// File: edit.cpp +// File: contrib/samples/stc/edit.cpp // Purpose: STC test module // Maintainer: Wyo // Created: 2003-09-01 @@ -17,22 +17,22 @@ // headers //---------------------------------------------------------------------------- -// For compilers that support precompilation, includes . -#include +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif // for all others, include the necessary headers (this file is usually all you -// need because it includes almost all 'standard' wxWindows headers) +// need because it includes almost all 'standard' wxWidgets headers) #ifndef WX_PRECOMP - #include + #include "wx/wx.h" #endif -//! wxWindows headers -#include // raw file io support -#include // filename support +//! wxWidgets headers +#include "wx/file.h" // raw file io support +#include "wx/filename.h" // filename support //! application headers #include "defsext.h" // additional definitions @@ -100,8 +100,9 @@ BEGIN_EVENT_TABLE (Edit, wxStyledTextCtrl) EVT_MENU (myID_CONVERTCRLF, Edit::OnConvertEOL) EVT_MENU (myID_CONVERTLF, Edit::OnConvertEOL) // stc - EVT_STC_MARGINCLICK (-1, Edit::OnMarginClick) - EVT_STC_CHARADDED (-1, Edit::OnCharAdded) + EVT_STC_MARGINCLICK (wxID_ANY, Edit::OnMarginClick) + EVT_STC_CHARADDED (wxID_ANY, Edit::OnCharAdded) + EVT_STC_KEY( wxID_ANY , Edit::OnKey ) END_EVENT_TABLE() Edit::Edit (wxWindow *parent, wxWindowID id, @@ -110,7 +111,7 @@ Edit::Edit (wxWindow *parent, wxWindowID id, long style) : wxStyledTextCtrl (parent, id, pos, size, style) { - m_filename = _T(""); + m_filename = wxEmptyString; m_LineNrID = 0; m_DividerID = 1; @@ -119,6 +120,9 @@ Edit::Edit (wxWindow *parent, wxWindowID id, // initialize language m_language = NULL; + // Use all the bits in the style byte as styles, not indicators. + SetStyleBits(8); + // default font for all styles SetViewEOL (g_CommonPrefs.displayEOLEnable); SetIndentationGuides (g_CommonPrefs.indentGuideEnable); @@ -132,11 +136,11 @@ Edit::Edit (wxWindow *parent, wxWindowID id, wxSTC_WRAP_WORD: wxSTC_WRAP_NONE); wxFont font (10, wxMODERN, wxNORMAL, wxNORMAL); StyleSetFont (wxSTC_STYLE_DEFAULT, font); - StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColour ("BLACK")); - StyleSetBackground (wxSTC_STYLE_DEFAULT, wxColour ("WHITE")); - StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour ("DARK GREY")); - StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour ("WHITE")); - StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour ("DARK GREY")); + StyleSetForeground (wxSTC_STYLE_DEFAULT, *wxBLACK); + StyleSetBackground (wxSTC_STYLE_DEFAULT, *wxWHITE); + StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (wxT("DARK GREY"))); + StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE); + StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY"))); InitializePrefs (DEFAULT_LANGUAGE); // set visibility @@ -145,21 +149,18 @@ Edit::Edit (wxWindow *parent, wxWindowID id, SetYCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); // markers - MarkerDefine (wxSTC_MARKNUM_FOLDER, wxSTC_MARK_DOTDOTDOT, "BLACK", "BLACK"); - MarkerDefine (wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, "BLACK", "BLACK"); - MarkerDefine (wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY, "BLACK", "BLACK"); - MarkerDefine (wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_DOTDOTDOT, "BLACK", "WHITE"); - MarkerDefine (wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_ARROWDOWN, "BLACK", "WHITE"); - MarkerDefine (wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY, "BLACK", "BLACK"); - MarkerDefine (wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY, "BLACK", "BLACK"); + MarkerDefine (wxSTC_MARKNUM_FOLDER, wxSTC_MARK_DOTDOTDOT, wxT("BLACK"), wxT("BLACK")); + MarkerDefine (wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, wxT("BLACK"), wxT("BLACK")); + MarkerDefine (wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY, wxT("BLACK"), wxT("BLACK")); + MarkerDefine (wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_DOTDOTDOT, wxT("BLACK"), wxT("WHITE")); + MarkerDefine (wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_ARROWDOWN, wxT("BLACK"), wxT("WHITE")); + MarkerDefine (wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY, wxT("BLACK"), wxT("BLACK")); + MarkerDefine (wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY, wxT("BLACK"), wxT("BLACK")); // miscelaneous - m_LineNrMargin = TextWidth (wxSTC_STYLE_LINENUMBER, _T("_999999")); + m_LineNrMargin = TextWidth (wxSTC_STYLE_LINENUMBER, wxT("_999999")); m_FoldingMargin = 16; - SetMarginWidth (m_LineNrID, - g_CommonPrefs.lineNumberEnable? m_LineNrMargin: 0); CmdKeyClear (wxSTC_KEY_TAB, 0); // this is done by the menu accelerator key - UsePopUp (0); SetLayoutCache (wxSTC_CACHE_PAGE); } @@ -192,6 +193,11 @@ void Edit::OnEditClear (wxCommandEvent &WXUNUSED(event)) { Clear (); } +void Edit::OnKey (wxStyledTextEvent &WXUNUSED(event)) +{ + wxMessageBox("OnKey"); +} + void Edit::OnEditCut (wxCommandEvent &WXUNUSED(event)) { if (GetReadOnly() || (GetSelectionEnd()-GetSelectionStart() <= 0)) return; Cut (); @@ -233,11 +239,11 @@ void Edit::OnBraceMatch (wxCommandEvent &WXUNUSED(event)) { void Edit::OnGoto (wxCommandEvent &WXUNUSED(event)) { } -void Edit::OnEditIndentInc (wxCommandEvent &event) { +void Edit::OnEditIndentInc (wxCommandEvent &WXUNUSED(event)) { CmdKeyExecute (wxSTC_CMD_TAB); } -void Edit::OnEditIndentRed (wxCommandEvent &event) { +void Edit::OnEditIndentRed (wxCommandEvent &WXUNUSED(event)) { CmdKeyExecute (wxSTC_CMD_DELETEBACK); } @@ -342,7 +348,7 @@ void Edit::OnMarginClick (wxStyledTextEvent &event) { } void Edit::OnCharAdded (wxStyledTextEvent &event) { - char chr = event.GetKey(); + char chr = (char)event.GetKey(); int currentLine = GetCurrentLine(); // Change this if support for mac files with \r is needed if (chr == '\n') { @@ -361,7 +367,7 @@ void Edit::OnCharAdded (wxStyledTextEvent &event) { // private functions wxString Edit::DeterminePrefs (const wxString &filename) { - LanguageInfo const* curInfo = NULL; + LanguageInfo const* curInfo; // determine language from filepatterns int languageNr; @@ -369,11 +375,11 @@ wxString Edit::DeterminePrefs (const wxString &filename) { curInfo = &g_LanguagePrefs [languageNr]; wxString filepattern = curInfo->filepattern; filepattern.Lower(); - while (!filepattern.IsEmpty()) { + while (!filepattern.empty()) { wxString cur = filepattern.BeforeFirst (';'); if ((cur == filename) || - (cur == (filename.BeforeLast ('.') + _T(".*"))) || - (cur == (_T("*.") + filename.AfterLast ('.')))) { + (cur == (filename.BeforeLast ('.') + wxT(".*"))) || + (cur == (wxT("*.") + filename.AfterLast ('.')))) { return curInfo->name; } filepattern = filepattern.AfterFirst (';'); @@ -407,10 +413,9 @@ bool Edit::InitializePrefs (const wxString &name) { // set margin for line numbers SetMarginType (m_LineNrID, wxSTC_MARGIN_NUMBER); - StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour ("DARK GREY")); - StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour ("WHITE")); - SetMarginWidth (m_LineNrID, - g_CommonPrefs.lineNumberEnable? m_LineNrMargin: 0); + StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (wxT("DARK GREY"))); + StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE); + SetMarginWidth (m_LineNrID, 0); // start out not visible // default fonts for all styles! int Nr; @@ -420,8 +425,8 @@ bool Edit::InitializePrefs (const wxString &name) { } // set common styles - StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColour ("DARK GREY")); - StyleSetForeground (wxSTC_STYLE_INDENTGUIDE, wxColour ("DARK GREY")); + StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColour (wxT("DARK GREY"))); + StyleSetForeground (wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY"))); // initialize settings if (g_CommonPrefs.syntaxEnable) { @@ -443,7 +448,7 @@ bool Edit::InitializePrefs (const wxString &name) { StyleSetUnderline (Nr, (curType.fontstyle & mySTC_STYLE_UNDERL) > 0); StyleSetVisible (Nr, (curType.fontstyle & mySTC_STYLE_HIDDEN) == 0); StyleSetCase (Nr, curType.lettercase); - const wxChar *pwords = curInfo->styles[Nr].words; + const char *pwords = curInfo->styles[Nr].words; if (pwords) { SetKeyWords (keywordnr, pwords); keywordnr += 1; @@ -459,27 +464,27 @@ bool Edit::InitializePrefs (const wxString &name) { // folding SetMarginType (m_FoldingID, wxSTC_MARGIN_SYMBOL); SetMarginMask (m_FoldingID, wxSTC_MASK_FOLDERS); - StyleSetBackground (m_FoldingID, wxColour ("WHITE")); + StyleSetBackground (m_FoldingID, *wxWHITE); SetMarginWidth (m_FoldingID, 0); SetMarginSensitive (m_FoldingID, false); if (g_CommonPrefs.foldEnable) { SetMarginWidth (m_FoldingID, curInfo->folds != 0? m_FoldingMargin: 0); SetMarginSensitive (m_FoldingID, curInfo->folds != 0); - SetProperty (_T("fold"), curInfo->folds != 0? _T("1"): _T("0")); - SetProperty (_T("fold.comment"), - (curInfo->folds & mySTC_FOLD_COMMENT) > 0? _T("1"): _T("0")); - SetProperty (_T("fold.compact"), - (curInfo->folds & mySTC_FOLD_COMPACT) > 0? _T("1"): _T("0")); - SetProperty (_T("fold.preprocessor"), - (curInfo->folds & mySTC_FOLD_PREPROC) > 0? _T("1"): _T("0")); - SetProperty (_T("fold.html"), - (curInfo->folds & mySTC_FOLD_HTML) > 0? _T("1"): _T("0")); - SetProperty (_T("fold.html.preprocessor"), - (curInfo->folds & mySTC_FOLD_HTMLPREP) > 0? _T("1"): _T("0")); - SetProperty (_T("fold.comment.python"), - (curInfo->folds & mySTC_FOLD_COMMENTPY) > 0? _T("1"): _T("0")); - SetProperty (_T("fold.quotes.python"), - (curInfo->folds & mySTC_FOLD_QUOTESPY) > 0? _T("1"): _T("0")); + SetProperty (wxT("fold"), curInfo->folds != 0? wxT("1"): wxT("0")); + SetProperty (wxT("fold.comment"), + (curInfo->folds & mySTC_FOLD_COMMENT) > 0? wxT("1"): wxT("0")); + SetProperty (wxT("fold.compact"), + (curInfo->folds & mySTC_FOLD_COMPACT) > 0? wxT("1"): wxT("0")); + SetProperty (wxT("fold.preprocessor"), + (curInfo->folds & mySTC_FOLD_PREPROC) > 0? wxT("1"): wxT("0")); + SetProperty (wxT("fold.html"), + (curInfo->folds & mySTC_FOLD_HTML) > 0? wxT("1"): wxT("0")); + SetProperty (wxT("fold.html.preprocessor"), + (curInfo->folds & mySTC_FOLD_HTMLPREP) > 0? wxT("1"): wxT("0")); + SetProperty (wxT("fold.comment.python"), + (curInfo->folds & mySTC_FOLD_COMMENTPY) > 0? wxT("1"): wxT("0")); + SetProperty (wxT("fold.quotes.python"), + (curInfo->folds & mySTC_FOLD_QUOTESPY) > 0? wxT("1"): wxT("0")); } SetFoldFlags (wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED | wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED); @@ -506,39 +511,31 @@ bool Edit::InitializePrefs (const wxString &name) { return true; } -bool Edit::LoadFile () { - +bool Edit::LoadFile () +{ +#if wxUSE_FILEDLG // get filname if (!m_filename) { - wxFileDialog dlg (this, _T("Open file"), _T(""), _T(""), - _T("Any file (*)|*"), wxOPEN | wxFILE_MUST_EXIST | wxCHANGE_DIR); + wxFileDialog dlg (this, wxT("Open file"), wxEmptyString, wxEmptyString, + wxT("Any file (*)|*"), wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR); if (dlg.ShowModal() != wxID_OK) return false; m_filename = dlg.GetPath(); } // load file return LoadFile (m_filename); +#else + return false; +#endif // wxUSE_FILEDLG } bool Edit::LoadFile (const wxString &filename) { // load file in edit and clear undo - if (!filename.IsEmpty()) m_filename = filename; -// wxFile file (m_filename); -// if (!file.IsOpened()) return false; - ClearAll (); -// long lng = file.Length (); -// if (lng > 0) { -// wxString buf; -// wxChar *buff = buf.GetWriteBuf (lng); -// file.Read (buff, lng); -// buf.UngetWriteBuf (); -// InsertText (0, buf); -// } -// file.Close(); - + if (!filename.empty()) m_filename = filename; + wxStyledTextCtrl::LoadFile(m_filename); - + EmptyUndoBuffer(); // determine lexer language @@ -548,21 +545,25 @@ bool Edit::LoadFile (const wxString &filename) { return true; } -bool Edit::SaveFile () { - +bool Edit::SaveFile () +{ +#if wxUSE_FILEDLG // return if no change if (!Modified()) return true; // get filname if (!m_filename) { - wxFileDialog dlg (this, _T("Save file"), _T(""), _T(""), _T("Any file (*)|*"), - wxSAVE | wxOVERWRITE_PROMPT); + wxFileDialog dlg (this, wxT("Save file"), wxEmptyString, wxEmptyString, wxT("Any file (*)|*"), + wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (dlg.ShowModal() != wxID_OK) return false; m_filename = dlg.GetPath(); } // save file return SaveFile (m_filename); +#else + return false; +#endif // wxUSE_FILEDLG } bool Edit::SaveFile (const wxString &filename) { @@ -571,7 +572,7 @@ bool Edit::SaveFile (const wxString &filename) { if (!Modified()) return true; // // save edit in file and clear undo -// if (!filename.IsEmpty()) m_filename = filename; +// if (!filename.empty()) m_filename = filename; // wxFile file (m_filename, wxFile::write); // if (!file.IsOpened()) return false; // wxString buf = GetText(); @@ -584,7 +585,7 @@ bool Edit::SaveFile (const wxString &filename) { // return true; return wxStyledTextCtrl::SaveFile(filename); - + } bool Edit::Modified () { @@ -599,9 +600,9 @@ bool Edit::Modified () { EditProperties::EditProperties (Edit *edit, long style) - : wxDialog (edit, -1, wxEmptyString, + : wxDialog (edit, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { + style | wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { // sets the application title SetTitle (_("Properties")); @@ -610,74 +611,74 @@ EditProperties::EditProperties (Edit *edit, // fullname wxBoxSizer *fullname = new wxBoxSizer (wxHORIZONTAL); fullname->Add (10, 0); - fullname->Add (new wxStaticText (this, -1, _("Full filename"), - wxDefaultPosition, wxSize(80, -1)), + fullname->Add (new wxStaticText (this, wxID_ANY, _("Full filename"), + wxDefaultPosition, wxSize(80, wxDefaultCoord)), 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); - fullname->Add (new wxStaticText (this, -1, edit->GetFilename()), + fullname->Add (new wxStaticText (this, wxID_ANY, edit->GetFilename()), 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); // text info wxGridSizer *textinfo = new wxGridSizer (4, 0, 2); - textinfo->Add (new wxStaticText (this, -1, _("Language"), - wxDefaultPosition, wxSize(80, -1)), + textinfo->Add (new wxStaticText (this, wxID_ANY, _("Language"), + wxDefaultPosition, wxSize(80, wxDefaultCoord)), 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4); - textinfo->Add (new wxStaticText (this, -1, edit->m_language->name), + textinfo->Add (new wxStaticText (this, wxID_ANY, edit->m_language->name), 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4); - textinfo->Add (new wxStaticText (this, -1, _("Lexer-ID: "), - wxDefaultPosition, wxSize(80, -1)), + textinfo->Add (new wxStaticText (this, wxID_ANY, _("Lexer-ID: "), + wxDefaultPosition, wxSize(80, wxDefaultCoord)), 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4); - text = wxString::Format (_T("%d"), edit->GetLexer()); - textinfo->Add (new wxStaticText (this, -1, text), + text = wxString::Format (wxT("%d"), edit->GetLexer()); + textinfo->Add (new wxStaticText (this, wxID_ANY, text), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4); - wxString EOLtype = _T(""); + wxString EOLtype = wxEmptyString; switch (edit->GetEOLMode()) { - case wxSTC_EOL_CR: {EOLtype = _T("CR (Unix)"); break; } - case wxSTC_EOL_CRLF: {EOLtype = _T("CRLF (Windows)"); break; } - case wxSTC_EOL_LF: {EOLtype = _T("CR (Macintosh)"); break; } + case wxSTC_EOL_CR: {EOLtype = wxT("CR (Unix)"); break; } + case wxSTC_EOL_CRLF: {EOLtype = wxT("CRLF (Windows)"); break; } + case wxSTC_EOL_LF: {EOLtype = wxT("CR (Macintosh)"); break; } } - textinfo->Add (new wxStaticText (this, -1, _("Line endings"), - wxDefaultPosition, wxSize(80, -1)), + textinfo->Add (new wxStaticText (this, wxID_ANY, _("Line endings"), + wxDefaultPosition, wxSize(80, wxDefaultCoord)), 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4); - textinfo->Add (new wxStaticText (this, -1, EOLtype), + textinfo->Add (new wxStaticText (this, wxID_ANY, EOLtype), 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4); // text info box wxStaticBoxSizer *textinfos = new wxStaticBoxSizer ( - new wxStaticBox (this, -1, _("Informations")), + new wxStaticBox (this, wxID_ANY, _("Informations")), wxVERTICAL); textinfos->Add (textinfo, 0, wxEXPAND); textinfos->Add (0, 6); // statistic wxGridSizer *statistic = new wxGridSizer (4, 0, 2); - statistic->Add (new wxStaticText (this, -1, _("Total lines"), - wxDefaultPosition, wxSize(80, -1)), + statistic->Add (new wxStaticText (this, wxID_ANY, _("Total lines"), + wxDefaultPosition, wxSize(80, wxDefaultCoord)), 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4); - text = wxString::Format (_T("%d"), edit->GetLineCount()); - statistic->Add (new wxStaticText (this, -1, text), + text = wxString::Format (wxT("%d"), edit->GetLineCount()); + statistic->Add (new wxStaticText (this, wxID_ANY, text), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4); - statistic->Add (new wxStaticText (this, -1, _("Total chars"), - wxDefaultPosition, wxSize(80, -1)), + statistic->Add (new wxStaticText (this, wxID_ANY, _("Total chars"), + wxDefaultPosition, wxSize(80, wxDefaultCoord)), 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4); - text = wxString::Format (_T("%d"), edit->GetTextLength()); - statistic->Add (new wxStaticText (this, -1, text), + text = wxString::Format (wxT("%d"), edit->GetTextLength()); + statistic->Add (new wxStaticText (this, wxID_ANY, text), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4); - statistic->Add (new wxStaticText (this, -1, _("Current line"), - wxDefaultPosition, wxSize(80, -1)), + statistic->Add (new wxStaticText (this, wxID_ANY, _("Current line"), + wxDefaultPosition, wxSize(80, wxDefaultCoord)), 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4); - text = wxString::Format (_T("%d"), edit->GetCurrentLine()); - statistic->Add (new wxStaticText (this, -1, text), + text = wxString::Format (wxT("%d"), edit->GetCurrentLine()); + statistic->Add (new wxStaticText (this, wxID_ANY, text), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4); - statistic->Add (new wxStaticText (this, -1, _("Current pos"), - wxDefaultPosition, wxSize(80, -1)), + statistic->Add (new wxStaticText (this, wxID_ANY, _("Current pos"), + wxDefaultPosition, wxSize(80, wxDefaultCoord)), 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4); - text = wxString::Format (_T("%d"), edit->GetCurrentPos()); - statistic->Add (new wxStaticText (this, -1, text), + text = wxString::Format (wxT("%d"), edit->GetCurrentPos()); + statistic->Add (new wxStaticText (this, wxID_ANY, text), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4); // char/line statistics wxStaticBoxSizer *statistics = new wxStaticBoxSizer ( - new wxStaticBox (this, -1, _("Statistics")), + new wxStaticBox (this, wxID_ANY, _("Statistics")), wxVERTICAL); statistics->Add (statistic, 0, wxEXPAND); statistics->Add (0, 6); @@ -699,11 +700,13 @@ EditProperties::EditProperties (Edit *edit, ShowModal(); } +#if wxUSE_PRINTING_ARCHITECTURE + //---------------------------------------------------------------------------- // EditPrint //---------------------------------------------------------------------------- -EditPrint::EditPrint (Edit *edit, wxChar *title) +EditPrint::EditPrint (Edit *edit, const wxChar *title) : wxPrintout(title) { m_edit = edit; m_printed = 0; @@ -760,16 +763,18 @@ void EditPrint::GetPageInfo (int *minPage, int *maxPage, int *selPageFrom, int * page.y); // get margins informations and convert to printer pixels - int top = 25; // default 25 - int bottom = 25; // default 25 - int left = 20; // default 20 - int right = 20; // default 20 - wxPoint (top, left) = g_pageSetupData->GetMarginTopLeft(); - wxPoint (bottom, right) = g_pageSetupData->GetMarginBottomRight(); + wxPoint pt = g_pageSetupData->GetMarginTopLeft(); + int left = pt.x; + int top = pt.y; + pt = g_pageSetupData->GetMarginBottomRight(); + int right = pt.x; + int bottom = pt.y; + top = static_cast (top * ppiScr.y / 25.4); bottom = static_cast (bottom * ppiScr.y / 25.4); left = static_cast (left * ppiScr.x / 25.4); right = static_cast (right * ppiScr.x / 25.4); + m_printRect = wxRect (left, top, page.x - (left + right), @@ -786,7 +791,7 @@ void EditPrint::GetPageInfo (int *minPage, int *maxPage, int *selPageFrom, int * *selPageTo = *maxPage; } -bool EditPrint::HasPage (int page) { +bool EditPrint::HasPage (int WXUNUSED(page)) { return (m_printed < m_edit->GetLength()); } @@ -823,3 +828,4 @@ bool EditPrint::PrintScaling (wxDC *dc){ return true; } +#endif // wxUSE_PRINTING_ARCHITECTURE