2003-09-18 01:05:52 -04:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2006-02-10 06:59:52 -05:00
|
|
|
// File: contrib/samples/stc/stctest.cpp
|
2003-09-18 01:05:52 -04:00
|
|
|
// Purpose: STC test application
|
|
|
|
// Maintainer: Otto Wyss
|
|
|
|
// Created: 2003-09-01
|
|
|
|
// Copyright: (c) wxGuide
|
2000-03-09 14:42:06 -05:00
|
|
|
// Licence: wxWindows licence
|
2003-09-18 01:05:52 -04:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
//----------------------------------------------------------------------------
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2006-02-10 06:59:52 -05:00
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
2005-09-16 14:25:44 -04:00
|
|
|
#include "wx/wxprec.h"
|
2000-03-09 14:42:06 -05:00
|
|
|
|
|
|
|
|
|
|
|
// for all others, include the necessary headers (this file is usually all you
|
2004-05-25 07:20:37 -04:00
|
|
|
// need because it includes almost all 'standard' wxWidgets headers)
|
2000-03-09 14:42:06 -05:00
|
|
|
#ifndef WX_PRECOMP
|
2005-08-23 12:02:51 -04:00
|
|
|
#include "wx/wx.h"
|
2000-03-09 14:42:06 -05:00
|
|
|
#endif
|
|
|
|
|
2004-05-25 07:20:37 -04:00
|
|
|
//! wxWidgets headers
|
2005-08-23 12:02:51 -04:00
|
|
|
#include "wx/config.h" // configuration support
|
|
|
|
#include "wx/filedlg.h" // file dialog support
|
|
|
|
#include "wx/filename.h" // filename support
|
|
|
|
#include "wx/notebook.h" // notebook support
|
|
|
|
#include "wx/settings.h" // system settings
|
|
|
|
#include "wx/string.h" // strings support
|
|
|
|
#include "wx/image.h" // images support
|
2017-05-25 17:14:47 -04:00
|
|
|
#if wxUSE_PRINTING_ARCHITECTURE
|
|
|
|
#include "wx/paper.h"
|
|
|
|
#endif // wxUSE_PRINTING_ARCHITECTURE
|
2003-09-18 01:05:52 -04:00
|
|
|
|
|
|
|
//! application headers
|
|
|
|
#include "defsext.h" // Additional definitions
|
|
|
|
#include "edit.h" // Edit module
|
|
|
|
#include "prefs.h" // Prefs
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// resources
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2015-11-28 17:54:31 -05:00
|
|
|
// the application icon (under Windows it is in resources)
|
2012-03-03 19:28:58 -05:00
|
|
|
#ifndef wxHAS_IMAGES_IN_RESOURCES
|
2010-06-20 13:42:33 -04:00
|
|
|
#include "../sample.xpm"
|
2003-09-18 01:05:52 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
// declarations
|
|
|
|
//============================================================================
|
|
|
|
|
2018-09-28 21:45:15 -04:00
|
|
|
#define APP_NAME "STC-Test"
|
|
|
|
#define APP_DESCR "See http://wxguide.sourceforge.net/"
|
2003-09-18 01:05:52 -04:00
|
|
|
|
2018-09-28 21:45:15 -04:00
|
|
|
#define APP_MAINT "Otto Wyss"
|
|
|
|
#define APP_VENDOR "wxWidgets"
|
|
|
|
#define APP_COPYRIGTH "(C) 2003 Otto Wyss"
|
|
|
|
#define APP_LICENCE "wxWidgets"
|
2003-09-18 01:05:52 -04:00
|
|
|
|
2018-09-28 21:45:15 -04:00
|
|
|
#define APP_VERSION "0.1.alpha"
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
class AppBook;
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//! global application name
|
|
|
|
wxString *g_appname = NULL;
|
|
|
|
|
2005-08-23 12:02:51 -04:00
|
|
|
#if wxUSE_PRINTING_ARCHITECTURE
|
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
//! global print data, to remember settings during the session
|
|
|
|
wxPrintData *g_printData = (wxPrintData*) NULL;
|
2012-02-20 16:55:55 -05:00
|
|
|
wxPageSetupDialogData *g_pageSetupData = (wxPageSetupDialogData*) NULL;
|
2003-09-18 01:05:52 -04:00
|
|
|
|
2005-08-23 12:02:51 -04:00
|
|
|
#endif // wxUSE_PRINTING_ARCHITECTURE
|
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
|
2006-04-26 12:27:16 -04:00
|
|
|
class AppFrame;
|
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//! application APP_VENDOR-APP_NAME.
|
|
|
|
class App: public wxApp {
|
|
|
|
friend class AppFrame;
|
2000-03-09 14:42:06 -05:00
|
|
|
|
|
|
|
public:
|
2015-05-21 04:45:48 -04:00
|
|
|
//! the main function called during application start
|
2018-03-06 17:12:19 -05:00
|
|
|
virtual bool OnInit () wxOVERRIDE;
|
2003-09-18 01:05:52 -04:00
|
|
|
|
|
|
|
//! application exit function
|
2018-03-06 17:12:19 -05:00
|
|
|
virtual int OnExit () wxOVERRIDE;
|
2003-09-18 01:05:52 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
//! frame window
|
|
|
|
AppFrame* m_frame;
|
|
|
|
|
2009-09-24 09:08:48 -04:00
|
|
|
wxFrame* MinimalEditor();
|
|
|
|
protected:
|
|
|
|
void OnMinimalEditor(wxCommandEvent&);
|
2014-03-30 03:07:55 -04:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2000-03-09 14:42:06 -05:00
|
|
|
};
|
|
|
|
|
2004-05-25 07:20:37 -04:00
|
|
|
// created dynamically by wxWidgets
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_APP(App);
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//! frame of the application APP_VENDOR-APP_NAME.
|
|
|
|
class AppFrame: public wxFrame {
|
|
|
|
friend class App;
|
|
|
|
friend class AppBook;
|
|
|
|
friend class AppAbout;
|
2003-04-19 16:00:02 -04:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
public:
|
|
|
|
//! constructor
|
|
|
|
AppFrame (const wxString &title);
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
~AppFrame ();
|
|
|
|
|
|
|
|
//! event handlers
|
|
|
|
//! common
|
|
|
|
void OnClose (wxCloseEvent &event);
|
|
|
|
void OnAbout (wxCommandEvent &event);
|
|
|
|
void OnExit (wxCommandEvent &event);
|
|
|
|
//! file
|
|
|
|
void OnFileOpen (wxCommandEvent &event);
|
|
|
|
void OnFileSave (wxCommandEvent &event);
|
|
|
|
void OnFileSaveAs (wxCommandEvent &event);
|
|
|
|
void OnFileClose (wxCommandEvent &event);
|
|
|
|
//! properties
|
|
|
|
void OnProperties (wxCommandEvent &event);
|
|
|
|
//! print
|
|
|
|
void OnPrintSetup (wxCommandEvent &event);
|
|
|
|
void OnPrintPreview (wxCommandEvent &event);
|
|
|
|
void OnPrint (wxCommandEvent &event);
|
|
|
|
//! edit events
|
|
|
|
void OnEdit (wxCommandEvent &event);
|
2017-03-16 18:31:17 -04:00
|
|
|
void OnContextMenu(wxContextMenuEvent& evt);
|
2003-04-19 16:00:02 -04:00
|
|
|
|
|
|
|
private:
|
2003-09-18 01:05:52 -04:00
|
|
|
// edit object
|
|
|
|
Edit *m_edit;
|
|
|
|
void FileOpen (wxString fname);
|
|
|
|
|
|
|
|
//! creates the application menu bar
|
|
|
|
wxMenuBar *m_menuBar;
|
|
|
|
void CreateMenu ();
|
|
|
|
|
|
|
|
// print preview position and size
|
|
|
|
wxRect DeterminePrintSize ();
|
|
|
|
|
2014-03-30 03:07:55 -04:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2003-04-19 16:00:02 -04:00
|
|
|
};
|
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//! about box of the application APP_VENDOR-APP_NAME
|
|
|
|
class AppAbout: public wxDialog {
|
2003-04-19 16:00:02 -04:00
|
|
|
|
2000-03-09 14:42:06 -05:00
|
|
|
public:
|
2003-09-18 01:05:52 -04:00
|
|
|
//! constructor
|
|
|
|
AppAbout (wxWindow *parent,
|
|
|
|
int milliseconds = 0,
|
|
|
|
long style = 0);
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
~AppAbout ();
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
// event handlers
|
|
|
|
void OnTimerEvent (wxTimerEvent &event);
|
2000-03-09 14:42:06 -05:00
|
|
|
|
|
|
|
private:
|
2003-09-18 01:05:52 -04:00
|
|
|
// timer
|
|
|
|
wxTimer *m_timer;
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2014-03-30 03:07:55 -04:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2000-03-09 14:42:06 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
//============================================================================
|
|
|
|
// implementation
|
|
|
|
//============================================================================
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxIMPLEMENT_APP(App);
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2009-09-24 09:08:48 -04:00
|
|
|
|
2014-03-30 03:07:55 -04:00
|
|
|
wxBEGIN_EVENT_TABLE(App, wxApp)
|
2009-09-24 09:08:48 -04:00
|
|
|
EVT_MENU(myID_WINDOW_MINIMAL, App::OnMinimalEditor)
|
2014-03-30 03:07:55 -04:00
|
|
|
wxEND_EVENT_TABLE()
|
2009-09-24 09:08:48 -04:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// App
|
|
|
|
//----------------------------------------------------------------------------
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
bool App::OnInit () {
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
wxInitAllImageHandlers();
|
2003-10-10 21:20:24 -04:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
// set application and vendor name
|
|
|
|
SetAppName (APP_NAME);
|
|
|
|
SetVendorName (APP_VENDOR);
|
|
|
|
g_appname = new wxString ();
|
|
|
|
g_appname->Append (APP_VENDOR);
|
2018-09-28 21:45:15 -04:00
|
|
|
g_appname->Append ("-");
|
2003-09-18 01:05:52 -04:00
|
|
|
g_appname->Append (APP_NAME);
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2005-08-23 12:02:51 -04:00
|
|
|
#if wxUSE_PRINTING_ARCHITECTURE
|
2003-09-18 01:05:52 -04:00
|
|
|
// initialize print data and setup
|
|
|
|
g_printData = new wxPrintData;
|
2017-05-25 17:14:47 -04:00
|
|
|
wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4);
|
|
|
|
g_printData->SetPaperId(paper->GetId());
|
|
|
|
g_printData->SetPaperSize(paper->GetSize());
|
|
|
|
g_printData->SetOrientation(wxPORTRAIT);
|
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
g_pageSetupData = new wxPageSetupDialogData;
|
2017-05-25 17:14:47 -04:00
|
|
|
// copy over initial paper size from print record
|
|
|
|
(*g_pageSetupData) = *g_printData;
|
2005-08-23 12:02:51 -04:00
|
|
|
#endif // wxUSE_PRINTING_ARCHITECTURE
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
// create application frame
|
|
|
|
m_frame = new AppFrame (*g_appname);
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
// open application frame
|
|
|
|
m_frame->Layout ();
|
|
|
|
m_frame->Show (true);
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
return true;
|
|
|
|
}
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
int App::OnExit () {
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
// delete global appname
|
|
|
|
delete g_appname;
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2005-08-23 12:02:51 -04:00
|
|
|
#if wxUSE_PRINTING_ARCHITECTURE
|
2003-09-18 01:05:52 -04:00
|
|
|
// delete global print data and setup
|
|
|
|
if (g_printData) delete g_printData;
|
|
|
|
if (g_pageSetupData) delete g_pageSetupData;
|
2005-08-23 12:02:51 -04:00
|
|
|
#endif // wxUSE_PRINTING_ARCHITECTURE
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
return 0;
|
|
|
|
}
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// AppFrame
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2014-03-30 03:07:55 -04:00
|
|
|
wxBEGIN_EVENT_TABLE (AppFrame, wxFrame)
|
2003-09-18 01:05:52 -04:00
|
|
|
// common
|
|
|
|
EVT_CLOSE ( AppFrame::OnClose)
|
|
|
|
// file
|
|
|
|
EVT_MENU (wxID_OPEN, AppFrame::OnFileOpen)
|
|
|
|
EVT_MENU (wxID_SAVE, AppFrame::OnFileSave)
|
|
|
|
EVT_MENU (wxID_SAVEAS, AppFrame::OnFileSaveAs)
|
|
|
|
EVT_MENU (wxID_CLOSE, AppFrame::OnFileClose)
|
|
|
|
// properties
|
|
|
|
EVT_MENU (myID_PROPERTIES, AppFrame::OnProperties)
|
|
|
|
// print and exit
|
|
|
|
EVT_MENU (wxID_PRINT_SETUP, AppFrame::OnPrintSetup)
|
|
|
|
EVT_MENU (wxID_PREVIEW, AppFrame::OnPrintPreview)
|
|
|
|
EVT_MENU (wxID_PRINT, AppFrame::OnPrint)
|
|
|
|
EVT_MENU (wxID_EXIT, AppFrame::OnExit)
|
2013-02-05 15:46:13 -05:00
|
|
|
// Menu items with standard IDs forwarded to the editor.
|
2003-09-18 01:05:52 -04:00
|
|
|
EVT_MENU (wxID_CLEAR, AppFrame::OnEdit)
|
|
|
|
EVT_MENU (wxID_CUT, AppFrame::OnEdit)
|
|
|
|
EVT_MENU (wxID_COPY, AppFrame::OnEdit)
|
|
|
|
EVT_MENU (wxID_PASTE, AppFrame::OnEdit)
|
|
|
|
EVT_MENU (wxID_SELECTALL, AppFrame::OnEdit)
|
|
|
|
EVT_MENU (wxID_REDO, AppFrame::OnEdit)
|
|
|
|
EVT_MENU (wxID_UNDO, AppFrame::OnEdit)
|
|
|
|
EVT_MENU (wxID_FIND, AppFrame::OnEdit)
|
2013-02-05 15:46:13 -05:00
|
|
|
// And all our edit-related menu commands.
|
|
|
|
EVT_MENU_RANGE (myID_EDIT_FIRST, myID_EDIT_LAST,
|
2003-09-18 01:05:52 -04:00
|
|
|
AppFrame::OnEdit)
|
|
|
|
// help
|
|
|
|
EVT_MENU (wxID_ABOUT, AppFrame::OnAbout)
|
2017-03-16 18:31:17 -04:00
|
|
|
EVT_CONTEXT_MENU( AppFrame::OnContextMenu)
|
2014-03-30 03:07:55 -04:00
|
|
|
wxEND_EVENT_TABLE ()
|
2003-09-18 01:05:52 -04:00
|
|
|
|
|
|
|
AppFrame::AppFrame (const wxString &title)
|
2019-10-10 16:29:12 -04:00
|
|
|
: wxFrame ((wxFrame *)NULL, wxID_ANY, title, wxDefaultPosition, wxSize(750,550))
|
2009-02-07 20:01:00 -05:00
|
|
|
{
|
|
|
|
SetIcon(wxICON(sample));
|
2003-09-18 01:05:52 -04:00
|
|
|
|
2010-06-20 13:42:33 -04:00
|
|
|
// initialize important variables
|
2003-09-18 01:05:52 -04:00
|
|
|
m_edit = NULL;
|
|
|
|
|
|
|
|
// set icon and background
|
|
|
|
SetTitle (*g_appname);
|
2018-09-28 21:45:15 -04:00
|
|
|
SetBackgroundColour ("WHITE");
|
2003-09-18 01:05:52 -04:00
|
|
|
|
|
|
|
// create menu
|
|
|
|
m_menuBar = new wxMenuBar;
|
|
|
|
CreateMenu ();
|
|
|
|
|
|
|
|
// open first page
|
2004-09-28 11:13:27 -04:00
|
|
|
m_edit = new Edit (this, wxID_ANY);
|
2003-09-18 01:05:52 -04:00
|
|
|
m_edit->SetFocus();
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2018-09-28 21:45:15 -04:00
|
|
|
FileOpen ("stctest.cpp");
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
AppFrame::~AppFrame () {
|
|
|
|
}
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
// common event handlers
|
|
|
|
void AppFrame::OnClose (wxCloseEvent &event) {
|
|
|
|
wxCommandEvent evt;
|
|
|
|
OnFileClose (evt);
|
|
|
|
if (m_edit && m_edit->Modified()) {
|
|
|
|
if (event.CanVeto()) event.Veto (true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Destroy();
|
2003-04-19 16:00:02 -04:00
|
|
|
}
|
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
void AppFrame::OnAbout (wxCommandEvent &WXUNUSED(event)) {
|
2004-12-08 12:12:53 -05:00
|
|
|
AppAbout dlg(this);
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
2003-04-19 16:00:02 -04:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
void AppFrame::OnExit (wxCommandEvent &WXUNUSED(event)) {
|
|
|
|
Close (true);
|
|
|
|
}
|
2003-04-19 16:00:02 -04:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
// file event handlers
|
|
|
|
void AppFrame::OnFileOpen (wxCommandEvent &WXUNUSED(event)) {
|
|
|
|
if (!m_edit) return;
|
2005-08-23 12:02:51 -04:00
|
|
|
#if wxUSE_FILEDLG
|
2003-09-18 01:05:52 -04:00
|
|
|
wxString fname;
|
2018-09-28 21:45:15 -04:00
|
|
|
wxFileDialog dlg (this, "Open file", wxEmptyString, wxEmptyString, "Any file (*)|*",
|
2006-05-28 19:32:12 -04:00
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR);
|
2003-09-18 01:05:52 -04:00
|
|
|
if (dlg.ShowModal() != wxID_OK) return;
|
|
|
|
fname = dlg.GetPath ();
|
|
|
|
FileOpen (fname);
|
2005-08-23 12:02:51 -04:00
|
|
|
#endif // wxUSE_FILEDLG
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppFrame::OnFileSave (wxCommandEvent &WXUNUSED(event)) {
|
|
|
|
if (!m_edit) return;
|
|
|
|
if (!m_edit->Modified()) {
|
|
|
|
wxMessageBox (_("There is nothing to save!"), _("Save file"),
|
|
|
|
wxOK | wxICON_EXCLAMATION);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_edit->SaveFile ();
|
|
|
|
}
|
2000-03-09 14:42:06 -05:00
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
void AppFrame::OnFileSaveAs (wxCommandEvent &WXUNUSED(event)) {
|
|
|
|
if (!m_edit) return;
|
2005-08-23 12:02:51 -04:00
|
|
|
#if wxUSE_FILEDLG
|
2019-02-25 13:49:04 -05:00
|
|
|
wxString filename;
|
2018-09-28 21:45:15 -04:00
|
|
|
wxFileDialog dlg (this, "Save file", wxEmptyString, wxEmptyString, "Any file (*)|*", wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
|
2003-09-18 01:05:52 -04:00
|
|
|
if (dlg.ShowModal() != wxID_OK) return;
|
|
|
|
filename = dlg.GetPath();
|
|
|
|
m_edit->SaveFile (filename);
|
2005-08-23 12:02:51 -04:00
|
|
|
#endif // wxUSE_FILEDLG
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppFrame::OnFileClose (wxCommandEvent &WXUNUSED(event)) {
|
|
|
|
if (!m_edit) return;
|
|
|
|
if (m_edit->Modified()) {
|
|
|
|
if (wxMessageBox (_("Text is not saved, save before closing?"), _("Close"),
|
|
|
|
wxYES_NO | wxICON_QUESTION) == wxYES) {
|
|
|
|
m_edit->SaveFile();
|
|
|
|
if (m_edit->Modified()) {
|
|
|
|
wxMessageBox (_("Text could not be saved!"), _("Close abort"),
|
|
|
|
wxOK | wxICON_EXCLAMATION);
|
|
|
|
return;
|
|
|
|
}
|
2003-04-19 16:00:02 -04:00
|
|
|
}
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
2003-10-10 21:20:24 -04:00
|
|
|
m_edit->SetFilename (wxEmptyString);
|
|
|
|
m_edit->ClearAll();
|
|
|
|
m_edit->SetSavePoint();
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// properties event handlers
|
|
|
|
void AppFrame::OnProperties (wxCommandEvent &WXUNUSED(event)) {
|
|
|
|
if (!m_edit) return;
|
2004-12-08 12:12:53 -05:00
|
|
|
EditProperties dlg(m_edit, 0);
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// print event handlers
|
|
|
|
void AppFrame::OnPrintSetup (wxCommandEvent &WXUNUSED(event)) {
|
2005-08-23 12:02:51 -04:00
|
|
|
#if wxUSE_PRINTING_ARCHITECTURE
|
2003-09-18 01:05:52 -04:00
|
|
|
(*g_pageSetupData) = * g_printData;
|
|
|
|
wxPageSetupDialog pageSetupDialog(this, g_pageSetupData);
|
|
|
|
pageSetupDialog.ShowModal();
|
|
|
|
(*g_printData) = pageSetupDialog.GetPageSetupData().GetPrintData();
|
|
|
|
(*g_pageSetupData) = pageSetupDialog.GetPageSetupData();
|
2005-08-23 12:02:51 -04:00
|
|
|
#endif // wxUSE_PRINTING_ARCHITECTURE
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppFrame::OnPrintPreview (wxCommandEvent &WXUNUSED(event)) {
|
2005-08-23 12:02:51 -04:00
|
|
|
#if wxUSE_PRINTING_ARCHITECTURE
|
2003-09-18 01:05:52 -04:00
|
|
|
wxPrintDialogData printDialogData( *g_printData);
|
|
|
|
wxPrintPreview *preview =
|
|
|
|
new wxPrintPreview (new EditPrint (m_edit),
|
|
|
|
new EditPrint (m_edit),
|
|
|
|
&printDialogData);
|
2011-05-03 12:29:04 -04:00
|
|
|
if (!preview->IsOk()) {
|
2003-09-18 01:05:52 -04:00
|
|
|
delete preview;
|
|
|
|
wxMessageBox (_("There was a problem with previewing.\n\
|
|
|
|
Perhaps your current printer is not correctly?"),
|
|
|
|
_("Previewing"), wxOK);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
wxRect rect = DeterminePrintSize();
|
|
|
|
wxPreviewFrame *frame = new wxPreviewFrame (preview, this, _("Print Preview"));
|
|
|
|
frame->SetSize (rect);
|
|
|
|
frame->Centre(wxBOTH);
|
|
|
|
frame->Initialize();
|
|
|
|
frame->Show(true);
|
2005-08-23 12:02:51 -04:00
|
|
|
#endif // wxUSE_PRINTING_ARCHITECTURE
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppFrame::OnPrint (wxCommandEvent &WXUNUSED(event)) {
|
2005-08-23 12:02:51 -04:00
|
|
|
#if wxUSE_PRINTING_ARCHITECTURE
|
2003-09-18 01:05:52 -04:00
|
|
|
wxPrintDialogData printDialogData( *g_printData);
|
|
|
|
wxPrinter printer (&printDialogData);
|
|
|
|
EditPrint printout (m_edit);
|
|
|
|
if (!printer.Print (this, &printout, true)) {
|
|
|
|
if (wxPrinter::GetLastError() == wxPRINTER_ERROR) {
|
|
|
|
wxMessageBox (_("There was a problem with printing.\n\
|
|
|
|
Perhaps your current printer is not correctly?"),
|
|
|
|
_("Previewing"), wxOK);
|
|
|
|
return;
|
2003-04-19 16:00:02 -04:00
|
|
|
}
|
|
|
|
}
|
2003-09-18 01:05:52 -04:00
|
|
|
(*g_printData) = printer.GetPrintDialogData().GetPrintData();
|
2005-08-23 12:02:51 -04:00
|
|
|
#endif // wxUSE_PRINTING_ARCHITECTURE
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// edit events
|
|
|
|
void AppFrame::OnEdit (wxCommandEvent &event) {
|
2009-01-25 06:58:39 -05:00
|
|
|
if (m_edit) m_edit->GetEventHandler()->ProcessEvent (event);
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
|
|
|
|
2017-03-16 18:31:17 -04:00
|
|
|
void AppFrame::OnContextMenu(wxContextMenuEvent& evt)
|
|
|
|
{
|
|
|
|
wxPoint point = evt.GetPosition();
|
|
|
|
// If from keyboard
|
|
|
|
if ( point.x == -1 && point.y == -1 )
|
|
|
|
{
|
|
|
|
wxSize size = GetSize();
|
|
|
|
point.x = size.x / 2;
|
|
|
|
point.y = size.y / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
point = ScreenToClient(point);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxMenu menu;
|
2018-09-28 21:45:15 -04:00
|
|
|
menu.Append(wxID_ABOUT, "&About");
|
|
|
|
menu.Append(wxID_EXIT, "E&xit");
|
2017-03-16 18:31:17 -04:00
|
|
|
PopupMenu(&menu, point);
|
|
|
|
}
|
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
// private functions
|
2005-08-23 12:02:51 -04:00
|
|
|
void AppFrame::CreateMenu ()
|
|
|
|
{
|
2003-09-18 01:05:52 -04:00
|
|
|
// File menu
|
|
|
|
wxMenu *menuFile = new wxMenu;
|
|
|
|
menuFile->Append (wxID_OPEN, _("&Open ..\tCtrl+O"));
|
|
|
|
menuFile->Append (wxID_SAVE, _("&Save\tCtrl+S"));
|
|
|
|
menuFile->Append (wxID_SAVEAS, _("Save &as ..\tCtrl+Shift+S"));
|
|
|
|
menuFile->Append (wxID_CLOSE, _("&Close\tCtrl+W"));
|
|
|
|
menuFile->AppendSeparator();
|
|
|
|
menuFile->Append (myID_PROPERTIES, _("Proper&ties ..\tCtrl+I"));
|
|
|
|
menuFile->AppendSeparator();
|
|
|
|
menuFile->Append (wxID_PRINT_SETUP, _("Print Set&up .."));
|
|
|
|
menuFile->Append (wxID_PREVIEW, _("Print Pre&view\tCtrl+Shift+P"));
|
|
|
|
menuFile->Append (wxID_PRINT, _("&Print ..\tCtrl+P"));
|
|
|
|
menuFile->AppendSeparator();
|
|
|
|
menuFile->Append (wxID_EXIT, _("&Quit\tCtrl+Q"));
|
|
|
|
|
|
|
|
// Edit menu
|
|
|
|
wxMenu *menuEdit = new wxMenu;
|
|
|
|
menuEdit->Append (wxID_UNDO, _("&Undo\tCtrl+Z"));
|
|
|
|
menuEdit->Append (wxID_REDO, _("&Redo\tCtrl+Shift+Z"));
|
|
|
|
menuEdit->AppendSeparator();
|
|
|
|
menuEdit->Append (wxID_CUT, _("Cu&t\tCtrl+X"));
|
|
|
|
menuEdit->Append (wxID_COPY, _("&Copy\tCtrl+C"));
|
|
|
|
menuEdit->Append (wxID_PASTE, _("&Paste\tCtrl+V"));
|
|
|
|
menuEdit->Append (wxID_CLEAR, _("&Delete\tDel"));
|
|
|
|
menuEdit->AppendSeparator();
|
|
|
|
menuEdit->Append (wxID_FIND, _("&Find\tCtrl+F"));
|
|
|
|
menuEdit->Enable (wxID_FIND, false);
|
|
|
|
menuEdit->Append (myID_FINDNEXT, _("Find &next\tF3"));
|
|
|
|
menuEdit->Enable (myID_FINDNEXT, false);
|
|
|
|
menuEdit->Append (myID_REPLACE, _("&Replace\tCtrl+H"));
|
|
|
|
menuEdit->Enable (myID_REPLACE, false);
|
|
|
|
menuEdit->Append (myID_REPLACENEXT, _("Replace &again\tShift+F4"));
|
|
|
|
menuEdit->Enable (myID_REPLACENEXT, false);
|
|
|
|
menuEdit->AppendSeparator();
|
|
|
|
menuEdit->Append (myID_BRACEMATCH, _("&Match brace\tCtrl+M"));
|
|
|
|
menuEdit->Append (myID_GOTO, _("&Goto\tCtrl+G"));
|
|
|
|
menuEdit->Enable (myID_GOTO, false);
|
|
|
|
menuEdit->AppendSeparator();
|
|
|
|
menuEdit->Append (myID_INDENTINC, _("&Indent increase\tTab"));
|
2008-12-27 09:21:35 -05:00
|
|
|
menuEdit->Append (myID_INDENTRED, _("I&ndent reduce\tShift+Tab"));
|
2003-09-18 01:05:52 -04:00
|
|
|
menuEdit->AppendSeparator();
|
|
|
|
menuEdit->Append (wxID_SELECTALL, _("&Select all\tCtrl+A"));
|
|
|
|
menuEdit->Append (myID_SELECTLINE, _("Select &line\tCtrl+L"));
|
|
|
|
|
2015-05-21 04:45:48 -04:00
|
|
|
// highlight submenu
|
2015-06-05 07:56:52 -04:00
|
|
|
wxMenu *menuHighlight = new wxMenu;
|
2003-09-18 01:05:52 -04:00
|
|
|
int Nr;
|
|
|
|
for (Nr = 0; Nr < g_LanguagePrefsSize; Nr++) {
|
2015-06-05 07:56:52 -04:00
|
|
|
menuHighlight->Append (myID_HIGHLIGHTFIRST + Nr,
|
2003-09-18 01:05:52 -04:00
|
|
|
g_LanguagePrefs [Nr].name);
|
|
|
|
}
|
|
|
|
|
|
|
|
// charset submenu
|
|
|
|
wxMenu *menuCharset = new wxMenu;
|
|
|
|
menuCharset->Append (myID_CHARSETANSI, _("&ANSI (Windows)"));
|
|
|
|
menuCharset->Append (myID_CHARSETMAC, _("&MAC (Macintosh)"));
|
|
|
|
|
|
|
|
// View menu
|
|
|
|
wxMenu *menuView = new wxMenu;
|
2015-06-05 07:56:52 -04:00
|
|
|
menuView->Append (myID_HIGHLIGHTLANG, _("&Highlight language .."), menuHighlight);
|
2003-09-18 01:05:52 -04:00
|
|
|
menuView->AppendSeparator();
|
|
|
|
menuView->AppendCheckItem (myID_FOLDTOGGLE, _("&Toggle current fold\tCtrl+T"));
|
|
|
|
menuView->AppendCheckItem (myID_OVERTYPE, _("&Overwrite mode\tIns"));
|
|
|
|
menuView->AppendCheckItem (myID_WRAPMODEON, _("&Wrap mode\tCtrl+U"));
|
|
|
|
menuView->AppendSeparator();
|
|
|
|
menuView->AppendCheckItem (myID_DISPLAYEOL, _("Show line &endings"));
|
|
|
|
menuView->AppendCheckItem (myID_INDENTGUIDE, _("Show &indent guides"));
|
|
|
|
menuView->AppendCheckItem (myID_LINENUMBER, _("Show line &numbers"));
|
|
|
|
menuView->AppendCheckItem (myID_LONGLINEON, _("Show &long line marker"));
|
|
|
|
menuView->AppendCheckItem (myID_WHITESPACE, _("Show white&space"));
|
|
|
|
menuView->AppendSeparator();
|
|
|
|
menuView->Append (myID_USECHARSET, _("Use &code page of .."), menuCharset);
|
|
|
|
|
2013-02-05 15:46:16 -05:00
|
|
|
// Annotations menu
|
|
|
|
wxMenu* menuAnnotations = new wxMenu;
|
|
|
|
menuAnnotations->Append(myID_ANNOTATION_ADD, _("&Add or edit an annotation..."),
|
|
|
|
_("Add an annotation for the current line"));
|
|
|
|
menuAnnotations->Append(myID_ANNOTATION_REMOVE, _("&Remove annotation"),
|
|
|
|
_("Remove the annotation for the current line"));
|
|
|
|
menuAnnotations->Append(myID_ANNOTATION_CLEAR, _("&Clear all annotations"));
|
|
|
|
|
|
|
|
wxMenu* menuAnnotationsStyle = new wxMenu;
|
|
|
|
menuAnnotationsStyle->AppendRadioItem(myID_ANNOTATION_STYLE_HIDDEN, _("&Hidden"));
|
|
|
|
menuAnnotationsStyle->AppendRadioItem(myID_ANNOTATION_STYLE_STANDARD, _("&Standard"));
|
|
|
|
menuAnnotationsStyle->AppendRadioItem(myID_ANNOTATION_STYLE_BOXED, _("&Boxed"));
|
|
|
|
menuAnnotations->AppendSubMenu(menuAnnotationsStyle, "&Style");
|
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
// change case submenu
|
|
|
|
wxMenu *menuChangeCase = new wxMenu;
|
|
|
|
menuChangeCase->Append (myID_CHANGEUPPER, _("&Upper case"));
|
|
|
|
menuChangeCase->Append (myID_CHANGELOWER, _("&Lower case"));
|
|
|
|
|
|
|
|
// convert EOL submenu
|
|
|
|
wxMenu *menuConvertEOL = new wxMenu;
|
|
|
|
menuConvertEOL->Append (myID_CONVERTCR, _("CR (&Linux)"));
|
|
|
|
menuConvertEOL->Append (myID_CONVERTCRLF, _("CR+LF (&Windows)"));
|
|
|
|
menuConvertEOL->Append (myID_CONVERTLF, _("LF (&Macintosh)"));
|
|
|
|
|
|
|
|
// Extra menu
|
|
|
|
wxMenu *menuExtra = new wxMenu;
|
|
|
|
menuExtra->AppendCheckItem (myID_READONLY, _("&Readonly mode"));
|
|
|
|
menuExtra->AppendSeparator();
|
|
|
|
menuExtra->Append (myID_CHANGECASE, _("Change &case to .."), menuChangeCase);
|
|
|
|
menuExtra->AppendSeparator();
|
|
|
|
menuExtra->Append (myID_CONVERTEOL, _("Convert line &endings to .."), menuConvertEOL);
|
2014-05-05 10:42:29 -04:00
|
|
|
menuExtra->AppendCheckItem(myID_MULTIPLE_SELECTIONS, _("Toggle &multiple selections"));
|
|
|
|
menuExtra->AppendCheckItem(myID_MULTI_PASTE, _("Toggle multi-&paste"));
|
|
|
|
menuExtra->AppendCheckItem(myID_MULTIPLE_SELECTIONS_TYPING, _("Toggle t&yping on multiple selections"));
|
2017-03-16 18:31:17 -04:00
|
|
|
menuExtra->AppendSeparator();
|
2020-05-31 17:42:33 -04:00
|
|
|
#if defined(__WXMSW__) && wxUSE_GRAPHICS_DIRECT2D
|
|
|
|
wxMenu* menuTechnology = new wxMenu;
|
|
|
|
menuTechnology->AppendRadioItem(myID_TECHNOLOGY_DEFAULT, _("&Default"));
|
|
|
|
menuTechnology->AppendRadioItem(myID_TECHNOLOGY_DIRECTWRITE, _("Direct&Write"));
|
|
|
|
menuExtra->AppendSubMenu(menuTechnology, _("&Technology"));
|
|
|
|
menuExtra->AppendSeparator();
|
|
|
|
#endif
|
|
|
|
menuExtra->AppendCheckItem (myID_CUSTOM_POPUP, _("C&ustom context menu"));
|
2003-09-18 01:05:52 -04:00
|
|
|
|
|
|
|
// Window menu
|
|
|
|
wxMenu *menuWindow = new wxMenu;
|
2009-09-24 09:08:48 -04:00
|
|
|
menuWindow->Append(myID_WINDOW_MINIMAL, _("&Minimal editor"));
|
2003-09-18 01:05:52 -04:00
|
|
|
|
|
|
|
// Help menu
|
|
|
|
wxMenu *menuHelp = new wxMenu;
|
2013-08-23 12:37:09 -04:00
|
|
|
menuHelp->Append (wxID_ABOUT, _("&About ..\tCtrl+D"));
|
2003-09-18 01:05:52 -04:00
|
|
|
|
|
|
|
// construct menu
|
|
|
|
m_menuBar->Append (menuFile, _("&File"));
|
|
|
|
m_menuBar->Append (menuEdit, _("&Edit"));
|
|
|
|
m_menuBar->Append (menuView, _("&View"));
|
2013-02-05 15:46:16 -05:00
|
|
|
m_menuBar->Append (menuAnnotations, _("&Annotations"));
|
2003-09-18 01:05:52 -04:00
|
|
|
m_menuBar->Append (menuExtra, _("E&xtra"));
|
|
|
|
m_menuBar->Append (menuWindow, _("&Window"));
|
|
|
|
m_menuBar->Append (menuHelp, _("&Help"));
|
|
|
|
SetMenuBar (m_menuBar);
|
2013-02-05 15:46:16 -05:00
|
|
|
|
|
|
|
m_menuBar->Check(myID_ANNOTATION_STYLE_BOXED, true);
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
|
|
|
|
2005-08-23 12:02:51 -04:00
|
|
|
void AppFrame::FileOpen (wxString fname)
|
|
|
|
{
|
2021-07-11 09:48:57 -04:00
|
|
|
m_edit->LoadFile (wxFileName(fname).GetAbsolutePath());
|
2012-09-30 18:26:36 -04:00
|
|
|
m_edit->SelectNone();
|
2000-03-09 14:42:06 -05:00
|
|
|
}
|
2003-09-18 01:05:52 -04:00
|
|
|
|
|
|
|
wxRect AppFrame::DeterminePrintSize () {
|
|
|
|
|
|
|
|
wxSize scr = wxGetDisplaySize();
|
|
|
|
|
|
|
|
// determine position and size (shifting 16 left and down)
|
|
|
|
wxRect rect = GetRect();
|
|
|
|
rect.x += 16;
|
|
|
|
rect.y += 16;
|
|
|
|
rect.width = wxMin (rect.width, (scr.x - rect.x));
|
|
|
|
rect.height = wxMin (rect.height, (scr.x - rect.y));
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// AppAbout
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2014-03-30 03:07:55 -04:00
|
|
|
wxBEGIN_EVENT_TABLE (AppAbout, wxDialog)
|
2003-09-18 01:05:52 -04:00
|
|
|
EVT_TIMER (myID_ABOUTTIMER, AppAbout::OnTimerEvent)
|
2014-03-30 03:07:55 -04:00
|
|
|
wxEND_EVENT_TABLE ()
|
2003-09-18 01:05:52 -04:00
|
|
|
|
|
|
|
AppAbout::AppAbout (wxWindow *parent,
|
|
|
|
int milliseconds,
|
|
|
|
long style)
|
2004-09-28 11:13:27 -04:00
|
|
|
: wxDialog (parent, wxID_ANY, wxEmptyString,
|
2003-09-18 01:05:52 -04:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2003-09-18 13:35:31 -04:00
|
|
|
style | wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {
|
2003-09-18 01:05:52 -04:00
|
|
|
|
|
|
|
// set timer if any
|
|
|
|
m_timer = NULL;
|
|
|
|
if (milliseconds > 0) {
|
|
|
|
m_timer = new wxTimer (this, myID_ABOUTTIMER);
|
|
|
|
m_timer->Start (milliseconds, wxTIMER_ONE_SHOT);
|
|
|
|
}
|
|
|
|
|
2017-02-09 16:27:47 -05:00
|
|
|
// Get version of Scintilla
|
|
|
|
wxVersionInfo vi = wxStyledTextCtrl::GetLibraryVersionInfo();
|
|
|
|
|
2003-09-18 01:05:52 -04:00
|
|
|
// sets the application title
|
|
|
|
SetTitle (_("About .."));
|
|
|
|
|
|
|
|
// about info
|
|
|
|
wxGridSizer *aboutinfo = new wxGridSizer (2, 0, 2);
|
2004-09-28 11:13:27 -04:00
|
|
|
aboutinfo->Add (new wxStaticText(this, wxID_ANY, _("Written by: ")),
|
2003-09-18 01:05:52 -04:00
|
|
|
0, wxALIGN_LEFT);
|
2004-09-28 11:13:27 -04:00
|
|
|
aboutinfo->Add (new wxStaticText(this, wxID_ANY, APP_MAINT),
|
2003-09-18 01:05:52 -04:00
|
|
|
1, wxEXPAND | wxALIGN_LEFT);
|
2004-09-28 11:13:27 -04:00
|
|
|
aboutinfo->Add (new wxStaticText(this, wxID_ANY, _("Version: ")),
|
2003-09-18 01:05:52 -04:00
|
|
|
0, wxALIGN_LEFT);
|
2017-02-09 16:27:47 -05:00
|
|
|
aboutinfo->Add (new wxStaticText(this, wxID_ANY, wxString::Format("%s (%s)", APP_VERSION, vi.GetVersionString())),
|
2003-09-18 01:05:52 -04:00
|
|
|
1, wxEXPAND | wxALIGN_LEFT);
|
2004-09-28 11:13:27 -04:00
|
|
|
aboutinfo->Add (new wxStaticText(this, wxID_ANY, _("Licence type: ")),
|
2003-09-18 01:05:52 -04:00
|
|
|
0, wxALIGN_LEFT);
|
2004-09-28 11:13:27 -04:00
|
|
|
aboutinfo->Add (new wxStaticText(this, wxID_ANY, APP_LICENCE),
|
2003-09-18 01:05:52 -04:00
|
|
|
1, wxEXPAND | wxALIGN_LEFT);
|
2004-09-28 11:13:27 -04:00
|
|
|
aboutinfo->Add (new wxStaticText(this, wxID_ANY, _("Copyright: ")),
|
2003-09-18 01:05:52 -04:00
|
|
|
0, wxALIGN_LEFT);
|
2004-09-28 11:13:27 -04:00
|
|
|
aboutinfo->Add (new wxStaticText(this, wxID_ANY, APP_COPYRIGTH),
|
2003-09-18 01:05:52 -04:00
|
|
|
1, wxEXPAND | wxALIGN_LEFT);
|
|
|
|
|
|
|
|
// about icontitle//info
|
|
|
|
wxBoxSizer *aboutpane = new wxBoxSizer (wxHORIZONTAL);
|
2010-06-20 13:42:33 -04:00
|
|
|
wxBitmap bitmap = wxBitmap(wxICON (sample));
|
2004-09-28 11:13:27 -04:00
|
|
|
aboutpane->Add (new wxStaticBitmap (this, wxID_ANY, bitmap),
|
2003-09-18 01:05:52 -04:00
|
|
|
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 20);
|
|
|
|
aboutpane->Add (aboutinfo, 1, wxEXPAND);
|
|
|
|
aboutpane->Add (60, 0);
|
|
|
|
|
|
|
|
// about complete
|
|
|
|
wxBoxSizer *totalpane = new wxBoxSizer (wxVERTICAL);
|
|
|
|
totalpane->Add (0, 20);
|
2004-09-28 11:13:27 -04:00
|
|
|
wxStaticText *appname = new wxStaticText(this, wxID_ANY, *g_appname);
|
2014-01-11 09:25:30 -05:00
|
|
|
appname->SetFont (wxFontInfo(24).Bold());
|
2003-09-18 01:05:52 -04:00
|
|
|
totalpane->Add (appname, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 40);
|
|
|
|
totalpane->Add (0, 10);
|
|
|
|
totalpane->Add (aboutpane, 0, wxEXPAND | wxALL, 4);
|
2004-09-28 11:13:27 -04:00
|
|
|
totalpane->Add (new wxStaticText(this, wxID_ANY, APP_DESCR),
|
2003-09-18 01:05:52 -04:00
|
|
|
0, wxALIGN_CENTER | wxALL, 10);
|
|
|
|
wxButton *okButton = new wxButton (this, wxID_OK, _("OK"));
|
|
|
|
okButton->SetDefault();
|
|
|
|
totalpane->Add (okButton, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT | wxBOTTOM, 10);
|
|
|
|
|
|
|
|
SetSizerAndFit (totalpane);
|
|
|
|
|
2003-10-10 21:20:24 -04:00
|
|
|
CenterOnScreen();
|
2003-09-18 01:05:52 -04:00
|
|
|
ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
AppAbout::~AppAbout () {
|
2010-06-20 14:18:23 -04:00
|
|
|
wxDELETE(m_timer);
|
2003-09-18 01:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// event handlers
|
2003-09-18 13:35:31 -04:00
|
|
|
void AppAbout::OnTimerEvent (wxTimerEvent &WXUNUSED(event)) {
|
2010-06-20 14:18:23 -04:00
|
|
|
wxDELETE(m_timer);
|
2003-09-18 01:05:52 -04:00
|
|
|
EndModal (wxID_OK);
|
|
|
|
}
|
2009-09-24 09:08:48 -04:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Minimal editor added by Troels K 2008-04-08
|
|
|
|
// Thanks to geralds for SetLexerXml() - http://wxforum.shadonet.com/viewtopic.php?t=7155
|
|
|
|
|
|
|
|
class MinimalEditor : public wxStyledTextCtrl
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
margin_id_lineno,
|
|
|
|
margin_id_fold,
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
MinimalEditor(wxWindow* parent, wxWindowID id = wxID_ANY) : wxStyledTextCtrl(parent, id)
|
|
|
|
{
|
|
|
|
SetLexerXml();
|
|
|
|
|
2018-09-28 21:45:15 -04:00
|
|
|
SetProperty("fold", "1");
|
|
|
|
SetProperty("fold.comment", "1");
|
|
|
|
SetProperty("fold.compact", "1");
|
|
|
|
SetProperty("fold.preprocessor", "1");
|
|
|
|
SetProperty("fold.html", "1");
|
|
|
|
SetProperty("fold.html.preprocessor", "1");
|
2009-09-24 09:08:48 -04:00
|
|
|
|
|
|
|
SetMarginType(margin_id_lineno, wxSTC_MARGIN_NUMBER);
|
|
|
|
SetMarginWidth(margin_id_lineno, 32);
|
|
|
|
|
2018-09-28 21:45:15 -04:00
|
|
|
MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, "WHITE", "BLACK");
|
|
|
|
MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, "WHITE", "BLACK");
|
|
|
|
MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, "WHITE", "BLACK");
|
|
|
|
MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, "WHITE", "BLACK");
|
|
|
|
MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, "WHITE", "BLACK");
|
|
|
|
MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, "WHITE", "BLACK");
|
|
|
|
MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, "WHITE", "BLACK");
|
2009-09-24 09:08:48 -04:00
|
|
|
|
|
|
|
SetMarginMask(margin_id_fold, wxSTC_MASK_FOLDERS);
|
|
|
|
SetMarginWidth(margin_id_fold, 32);
|
|
|
|
SetMarginSensitive(margin_id_fold, true);
|
|
|
|
|
|
|
|
SetFoldFlags(wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED | wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED);
|
|
|
|
|
|
|
|
SetTabWidth(4);
|
|
|
|
SetUseTabs(false);
|
|
|
|
SetWrapMode(wxSTC_WRAP_WORD);
|
|
|
|
SetWrapVisualFlags(wxSTC_WRAPVISUALFLAG_END);
|
|
|
|
}
|
2018-03-06 17:12:19 -05:00
|
|
|
virtual bool SetFont(const wxFont& font) wxOVERRIDE
|
2009-09-24 09:08:48 -04:00
|
|
|
{
|
2020-05-31 17:44:52 -04:00
|
|
|
StyleSetFont(wxSTC_STYLE_DEFAULT, font);
|
2009-09-24 09:08:48 -04:00
|
|
|
return wxStyledTextCtrl::SetFont(font);
|
|
|
|
}
|
|
|
|
void SetLexerXml()
|
|
|
|
{
|
|
|
|
SetLexer(wxSTC_LEX_XML);
|
|
|
|
StyleSetForeground(wxSTC_H_DEFAULT, *wxBLACK);
|
|
|
|
StyleSetForeground(wxSTC_H_TAG, *wxBLUE);
|
|
|
|
StyleSetForeground(wxSTC_H_TAGUNKNOWN, *wxBLUE);
|
|
|
|
StyleSetForeground(wxSTC_H_ATTRIBUTE, *wxRED);
|
|
|
|
StyleSetForeground(wxSTC_H_ATTRIBUTEUNKNOWN, *wxRED);
|
|
|
|
StyleSetBold(wxSTC_H_ATTRIBUTEUNKNOWN, true);
|
|
|
|
StyleSetForeground(wxSTC_H_NUMBER, *wxBLACK);
|
|
|
|
StyleSetForeground(wxSTC_H_DOUBLESTRING, *wxBLACK);
|
|
|
|
StyleSetForeground(wxSTC_H_SINGLESTRING, *wxBLACK);
|
|
|
|
StyleSetForeground(wxSTC_H_OTHER, *wxBLUE);
|
2019-05-22 12:50:34 -04:00
|
|
|
StyleSetForeground(wxSTC_H_COMMENT, wxColour("GREY"));
|
2009-09-24 09:08:48 -04:00
|
|
|
StyleSetForeground(wxSTC_H_ENTITY, *wxRED);
|
|
|
|
StyleSetBold(wxSTC_H_ENTITY, true);
|
|
|
|
StyleSetForeground(wxSTC_H_TAGEND, *wxBLUE);
|
|
|
|
StyleSetForeground(wxSTC_H_XMLSTART, *wxBLUE);
|
|
|
|
StyleSetForeground(wxSTC_H_XMLEND, *wxBLUE);
|
|
|
|
StyleSetForeground(wxSTC_H_CDATA, *wxRED);
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
void OnMarginClick(wxStyledTextEvent&);
|
|
|
|
void OnText(wxStyledTextEvent&);
|
2014-03-30 03:07:55 -04:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2009-09-24 09:08:48 -04:00
|
|
|
};
|
|
|
|
|
2014-03-30 03:07:55 -04:00
|
|
|
wxBEGIN_EVENT_TABLE(MinimalEditor, wxStyledTextCtrl)
|
2009-09-24 09:08:48 -04:00
|
|
|
EVT_STC_MARGINCLICK(wxID_ANY, MinimalEditor::OnMarginClick)
|
|
|
|
EVT_STC_CHANGE(wxID_ANY, MinimalEditor::OnText)
|
2014-03-30 03:07:55 -04:00
|
|
|
wxEND_EVENT_TABLE()
|
2009-09-24 09:08:48 -04:00
|
|
|
|
|
|
|
void MinimalEditor::OnMarginClick(wxStyledTextEvent &event)
|
|
|
|
{
|
|
|
|
if (event.GetMargin() == margin_id_fold)
|
|
|
|
{
|
|
|
|
int lineClick = LineFromPosition(event.GetPosition());
|
|
|
|
int levelClick = GetFoldLevel(lineClick);
|
|
|
|
if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0)
|
|
|
|
{
|
|
|
|
ToggleFold(lineClick);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MinimalEditor::OnText(wxStyledTextEvent& event)
|
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
wxLogDebug("Modified");
|
2009-09-24 09:08:48 -04:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
class MinimalEditorFrame : public wxFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MinimalEditorFrame() : wxFrame(NULL, wxID_ANY, _("Minimal Editor"))
|
|
|
|
{
|
|
|
|
MinimalEditor* editor = new MinimalEditor(this);
|
2020-05-31 17:44:52 -04:00
|
|
|
editor->SetFont(wxFontInfo().Family(wxFONTFAMILY_TELETYPE));
|
2009-09-24 09:08:48 -04:00
|
|
|
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
sizer->Add(editor, 1, wxEXPAND);
|
|
|
|
SetSizer(sizer);
|
|
|
|
editor->SetText(
|
|
|
|
"<xml>\n"
|
|
|
|
" <text>\n"
|
|
|
|
" This is xml with syntax highlighting, line numbers, folding, word wrap and context menu\n"
|
|
|
|
" </text>\n"
|
|
|
|
"</xml>"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
wxFrame* App::MinimalEditor()
|
|
|
|
{
|
|
|
|
MinimalEditorFrame* frame = new MinimalEditorFrame;
|
|
|
|
frame->Show();
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void App::OnMinimalEditor(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
MinimalEditor();
|
|
|
|
}
|
|
|
|
|