//////////////////////////////////////////////////////////////////////////////
-// File: edit.cpp
+// File: contrib/samples/stc/edit.cpp
// Purpose: STC test module
// Maintainer: Wyo
// Created: 2003-09-01
// headers
//----------------------------------------------------------------------------
-// For compilers that support precompilation, includes <wx/wx.h>.
-#include <wx/wxprec.h>
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all 'standard' wxWidgets headers)
#ifndef WX_PRECOMP
- #include <wx/wx.h>
+ #include "wx/wx.h"
#endif
//! wxWidgets headers
-#include <wx/file.h> // raw file io support
-#include <wx/filename.h> // filename support
+#include "wx/file.h" // raw file io support
+#include "wx/filename.h" // filename support
//! application headers
#include "defsext.h" // additional definitions
long style)
: wxStyledTextCtrl (parent, id, pos, size, style) {
- m_filename = _T("");
+ m_filename = wxEmptyString;
m_LineNrID = 0;
m_DividerID = 1;
wxSTC_WRAP_WORD: wxSTC_WRAP_NONE);
wxFont font (10, wxMODERN, wxNORMAL, wxNORMAL);
StyleSetFont (wxSTC_STYLE_DEFAULT, font);
- StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColour (_T("BLACK")));
- StyleSetBackground (wxSTC_STYLE_DEFAULT, wxColour (_T("WHITE")));
+ StyleSetForeground (wxSTC_STYLE_DEFAULT, *wxBLACK);
+ StyleSetBackground (wxSTC_STYLE_DEFAULT, *wxWHITE);
StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (_T("DARK GREY")));
- StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour (_T("WHITE")));
+ StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE);
StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (_T("DARK GREY")));
InitializePrefs (DEFAULT_LANGUAGE);
}
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') {
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(".*"))) ||
// set margin for line numbers
SetMarginType (m_LineNrID, wxSTC_MARGIN_NUMBER);
StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (_T("DARK GREY")));
- StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour (_T("WHITE")));
+ StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE);
SetMarginWidth (m_LineNrID, 0); // start out not visible
// default fonts for all styles!
// folding
SetMarginType (m_FoldingID, wxSTC_MARGIN_SYMBOL);
SetMarginMask (m_FoldingID, wxSTC_MASK_FOLDERS);
- StyleSetBackground (m_FoldingID, wxColour (_T("WHITE")));
+ StyleSetBackground (m_FoldingID, *wxWHITE);
SetMarginWidth (m_FoldingID, 0);
SetMarginSensitive (m_FoldingID, false);
if (g_CommonPrefs.foldEnable) {
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, _T("Open file"), wxEmptyString, wxEmptyString,
+ _T("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;
+ if (!filename.empty()) m_filename = filename;
// wxFile file (m_filename);
// if (!file.IsOpened()) return false;
ClearAll ();
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, _T("Save file"), wxEmptyString, wxEmptyString, _T("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) {
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();
text = wxString::Format (_T("%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; }
ShowModal();
}
+#if wxUSE_PRINTING_ARCHITECTURE
+
//----------------------------------------------------------------------------
// EditPrint
//----------------------------------------------------------------------------
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<int> (top * ppiScr.y / 25.4);
bottom = static_cast<int> (bottom * ppiScr.y / 25.4);
left = static_cast<int> (left * ppiScr.x / 25.4);
right = static_cast<int> (right * ppiScr.x / 25.4);
+
m_printRect = wxRect (left,
top,
page.x - (left + right),
return true;
}
+#endif // wxUSE_PRINTING_ARCHITECTURE