X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/88a8b04e9c387b5e5295d42f2ed23afcf37e3c2e..a6f4dbbd86b54c720bdeab1aea1fad5eb3f030e6:/contrib/samples/stc/edit.cpp diff --git a/contrib/samples/stc/edit.cpp b/contrib/samples/stc/edit.cpp index 82ee73271a..44ce6f88c0 100644 --- a/contrib/samples/stc/edit.cpp +++ b/contrib/samples/stc/edit.cpp @@ -25,12 +25,12 @@ #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 #endif -//! wxWindows headers +//! wxWidgets headers #include // raw file io support #include // filename support @@ -100,8 +100,8 @@ 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) END_EVENT_TABLE() Edit::Edit (wxWindow *parent, wxWindowID id, @@ -132,11 +132,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, wxColour (_T("BLACK"))); + StyleSetBackground (wxSTC_STYLE_DEFAULT, wxColour (_T("WHITE"))); + StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (_T("DARK GREY"))); + StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour (_T("WHITE"))); + StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (_T("DARK GREY"))); InitializePrefs (DEFAULT_LANGUAGE); // set visibility @@ -145,21 +145,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, _T("BLACK"), _T("BLACK")); + MarkerDefine (wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, _T("BLACK"), _T("BLACK")); + MarkerDefine (wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY, _T("BLACK"), _T("BLACK")); + MarkerDefine (wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_DOTDOTDOT, _T("BLACK"), _T("WHITE")); + MarkerDefine (wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_ARROWDOWN, _T("BLACK"), _T("WHITE")); + MarkerDefine (wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY, _T("BLACK"), _T("BLACK")); + MarkerDefine (wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY, _T("BLACK"), _T("BLACK")); // miscelaneous m_LineNrMargin = TextWidth (wxSTC_STYLE_LINENUMBER, _T("_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); } @@ -233,11 +230,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 +339,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 +358,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; @@ -407,10 +404,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 (_T("DARK GREY"))); + StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour (_T("WHITE"))); + SetMarginWidth (m_LineNrID, 0); // start out not visible // default fonts for all styles! int Nr; @@ -420,8 +416,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 (_T("DARK GREY"))); + StyleSetForeground (wxSTC_STYLE_INDENTGUIDE, wxColour (_T("DARK GREY"))); // initialize settings if (g_CommonPrefs.syntaxEnable) { @@ -459,7 +455,7 @@ 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, wxColour (_T("WHITE"))); SetMarginWidth (m_FoldingID, 0); SetMarginSensitive (m_FoldingID, false); if (g_CommonPrefs.foldEnable) { @@ -536,9 +532,9 @@ bool Edit::LoadFile (const wxString &filename) { // InsertText (0, buf); // } // file.Close(); - + wxStyledTextCtrl::LoadFile(m_filename); - + EmptyUndoBuffer(); // determine lexer language @@ -584,7 +580,7 @@ bool Edit::SaveFile (const wxString &filename) { // return true; return wxStyledTextCtrl::SaveFile(filename); - + } bool Edit::Modified () { @@ -599,9 +595,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,24 +606,24 @@ 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), + textinfo->Add (new wxStaticText (this, wxID_ANY, text), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4); wxString EOLtype = _T(""); switch (edit->GetEOLMode()) { @@ -635,49 +631,49 @@ EditProperties::EditProperties (Edit *edit, case wxSTC_EOL_CRLF: {EOLtype = _T("CRLF (Windows)"); break; } case wxSTC_EOL_LF: {EOLtype = _T("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), + 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), + 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), + 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), + 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); @@ -786,7 +782,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()); }