Added first cut wxWindows Configuration Tool

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21083 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2003-06-12 20:43:55 +00:00
parent f2c3db9d7d
commit d7463f75f9
130 changed files with 19018 additions and 0 deletions

View File

@@ -0,0 +1,219 @@
#
# File: Makefile for wxconfigtool
# Author: Julian Smart
# Created: 2002.05.12
# Updated:
# Copyright: (c) Julian Smart
#
# To make absolutely everything:
#
# % mkdir /tmp/wxconfigtool-build
# % cd /tmp/wxconfigtool-build
# % make -f $(APPDIR)/src/Makefile WXDIR=$(WXDIR) WXBUILDDIR=$(WXBUILDDIR) APPDIR=$(APPDIR) LEVEL=debug full
#
# To make just ConfigTool:
#
# % make ... LEVEL=debug wxconfigtool
#
# To make wxWindows library:
#
# % make ... LEVEL=debug wx
#
# The result will be subdirectories under your /tmp/wxconfigtool-build (or other specified
# directory) containing:
#
# wxconfigtool-build-debug/
# wxwin-build-debug/
#
# To make a release version, specify LEVEL=release instead of LEVEL=debug.
#
# Current (build) directory
CURRDIR = $(shell pwd)
BUILDDIR=$(CURRDIR)
top_srcdir = $(WXDIR)
top_builddir = $(WXBUILDDIR)
program_dir =
# If we don't specify a location for wxWindows to be
# built, use a default.
ifeq "$(top_builddir)" ""
topbuilddir = $(CURRDIR)/wxwin-build-$(LEVEL)
WXBUILDDIR=$(top_builddir)
endif
# ConfigTool build directory
APPBUILDDIR=$(BUILDDIR)/wxconfigtool-build-$(LEVEL)
# StartingBlocks source hierarchy
# You have to specify this when invoking make.
APPDIR=You_should_override_the_APPDIR_variable
# ConfigTool source directory
APPSRCDIR=$(APPDIR)/src
# ConfigTool include directory
APPINCDIR=$(APPDIR)/src
# Extra includes
APPEXTRADEFS= \
-I$(WXDIR)/contrib/include \
-I$(APPSRCDIR) \
# -I$(UTILSDIR) \
WXVERSION=2.4
# Use the small C++ support library
APPEXTRALIBS=-lsupc++ ${top_builddir}/lib/libwx_$(WXTOOLKIT)$(WXDEBUGSUFFIX)_xrc-$(WXVERSION).a
PLATFORM_OS=$(shell echo $(OS))
ifeq "$(PLATFORM_OS)" "Windows_NT"
ARCHITECTURE="i686"
WXTOOLKIT=msw
else
ARCHITECTURE=$(shell arch)
ifeq "$(ARCHITECTURE)" "i686"
WXTOOLKIT=gtk
else
WXTOOLKIT=mac
endif
endif
#printit:
# @echo $(PLATFORM_OS)
ifeq "$(LEVEL)" "debug"
WXDEBUGSUFFIX=d
else
WXDEBUGSUFFIX=
endif
# Where to find the wx-config file
WXCONFIG=$(WXBUILDDIR)/wx-config $(WXCONFIGFLAGS)
ifeq "$(LEVEL)" "debug"
WXDEBUGFLAGS=--enable-debug --enable-debug_gdb --enable-debug_cntxt
endif
PROGRAM=$(APPBUILDDIR)/wxconfigtool
OBJECTS = \
$(APPBUILDDIR)/appsettings.o \
$(APPBUILDDIR)/configitem.o \
$(APPBUILDDIR)/configitemselector.o \
$(APPBUILDDIR)/configtooldoc.o \
$(APPBUILDDIR)/configtoolview.o \
$(APPBUILDDIR)/configtree.o \
$(APPBUILDDIR)/custompropertydialog.o \
$(APPBUILDDIR)/htmlparser.o \
$(APPBUILDDIR)/mainframe.o \
$(APPBUILDDIR)/propeditor.o \
$(APPBUILDDIR)/property.o \
$(APPBUILDDIR)/settingsdialog.o \
$(APPBUILDDIR)/utils.o \
$(APPBUILDDIR)/wxconfigtool.o
DEPFILES=$(PROGRAM).d
ifeq "$(USEDUMMYMAKEPROG)" "1"
include $(APPSRCDIR)/makeprog.env
else
include $(top_builddir)/src/makeprog.env
endif
CC=gcc
CXX=gcc
mkbuilddir:
mkdir -p $(APPBUILDDIR)
full: wx all
# --with-libpng=builtin --with-zlib=builtin --with-libjpeg=builtin
wx:
@mkdir -p $(WXBUILDDIR) ; \
cd $(WXBUILDDIR) ; \
if test ! -f Makefile ; then rm -f *.o *.d ; \
rm -f *.cache ; \
$(WXDIR)/configure --disable-shared --enable-gui --enable-log $(WXDEBUGFLAGS) --with-threads --disable-no_rtti --without-sockets --without-odbc --with-libjpeg --with-libpng=builtin --with-zlib=builtin --enable-wave ; \
fi; \
make; cd contrib/src/xrc; make
cleanapp: clean
cleanwx:
rm -f -r $(WXBUILDDIR)
cleanall: cleanapp cleanwx
wxconfigtool: mkbuilddir all
# Making a binary, RH Linux tarball release using the setup script.
# It will put the result in /tmp/wxconfigtool-deliver.
release:
echo "#include <stdio.h>" > /tmp/appver.c
echo "#include \"symbols.h\"" >> /tmp/appver.c
echo "int main() { printf(\"%.2f\", ctVERSION_NUMBER); }" >> /tmp/appver.c
cc /tmp/appver.c -I$(APPSRCDIR) -o /tmp/appver
chmod a+x $(APPSRCDIR)/../scripts/maketarball.sh
$(APPSRCDIR)/../scripts/maketarball.sh $(APPDIR) $(APPBUILDDIR) /tmp/wxconfigtool-deliver `/tmp/appver` # --upx
echo The release is in /tmp/wxconfigtool-deliver.
# rm -f /tmp/appver /tmp/appver.c
# Gives a list of targets
help:
@echo "Targets: full, wxconfigtool, wx, cleanall, clean, cleanwx, release"
### File dependencies
# Main app files
$(APPBUILDDIR)/wxconfigtool.o: $(APPSRCDIR)/wxconfigtool.cpp $(APPINCDIR)/wxconfigtool.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/appsettings.o: $(APPSRCDIR)/appsettings.cpp $(APPSRCDIR)/appsettings.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/configitem.o: $(APPSRCDIR)/configitem.cpp $(APPSRCDIR)/configitem.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/configitemselector.o: $(APPSRCDIR)/configitemselector.cpp $(APPSRCDIR)/configitemselector.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/configtooldoc.o: $(APPSRCDIR)/configtooldoc.cpp $(APPSRCDIR)/configtooldoc.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/configtoolview.o: $(APPSRCDIR)/configtoolview.cpp $(APPSRCDIR)/configtoolview.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/configtree.o: $(APPSRCDIR)/configtree.cpp $(APPSRCDIR)/configtree.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/custompropertydialog.o: $(APPSRCDIR)/custompropertydialog.cpp $(APPSRCDIR)/custompropertydialog.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/htmlparser.o: $(APPSRCDIR)/htmlparser.cpp $(APPSRCDIR)/htmlparser.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/mainframe.o: $(APPSRCDIR)/mainframe.cpp $(APPINCDIR)/mainframe.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/propeditor.o: $(APPSRCDIR)/propeditor.cpp $(APPINCDIR)/propeditor.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/property.o: $(APPSRCDIR)/property.cpp $(APPINCDIR)/property.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/settingsdialog.o: $(APPSRCDIR)/settingsdialog.cpp $(APPINCDIR)/settingsdialog.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/utils.o: $(APPSRCDIR)/utils.cpp $(APPINCDIR)/imagewindow.h $(APPSRCDIR)/symbols.h
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
$(APPBUILDDIR)/wxconfigtool_resources.o: $(APPSRCDIR)/wxconfigtool.rc
$(RESCOMP) -i $< -o $@ $(RESFLAGS) --include-dir $(APPSRCDIR)

View File

@@ -0,0 +1,28 @@
#
# File: Makefile.in
# Author: Julian Smart
# Created: 2003
# Updated:
# Copyright: (c) 2003 Julian Smart
#
# "%W% %G%"
#
# Makefile for wxWindows Configuration Tool (Unix)
top_srcdir = @top_srcdir@/..
top_builddir = ../../..
program_dir = utils/configtool/src
PROGRAM=wxconfigtool
OBJECTS = wxconfigtool.o appsettings.o configitem.o configitemselector.o configtooldoc.o \
configtoolview.o configtree.o custompropertydialog.o htmlparser.o mainframe.o \
propeditor.o property.o settingsdialog.o utils.o
DEPFILES=wxconfigtool.d appsettings.d configitem.d configitemselector.d configtooldoc.d \
configtoolview.d configtree.d custompropertydialog.d htmlparser.d mainframe.d \
propeditor.d property.d settingsdialog.o utils.d
include ../../../src/makeprog.env
-include $(DEPFILES)

View File

@@ -0,0 +1,272 @@
/////////////////////////////////////////////////////////////////////////////
// Name: appsettings.cpp
// Purpose: Implements settings-related functionality
// Author: Julian Smart
// Modified by:
// Created: 2002-09-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation appsettings.h
#endif
#include "wx/wx.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/wfstream.h"
#include "wx/datstrm.h"
#include "wx/config.h"
#include "wx/fileconf.h"
#include "wx/dir.h"
#include "wx/valgen.h"
#include "wx/colordlg.h"
#include "wx/wxhtml.h"
#include "wx/effects.h"
#include "wx/spinctrl.h"
#include "wx/tooltip.h"
#include "utils.h"
#include "wxconfigtool.h"
#include "appsettings.h"
#include "mainframe.h"
#include "symbols.h"
#include "settingsdialog.h"
/*
* User-changeable settings
*/
IMPLEMENT_DYNAMIC_CLASS(ctSettings, wxObject)
ctSettings::ctSettings()
{
m_noUses = 0;
m_showToolBar = TRUE;
m_showWelcomeDialog = TRUE;
m_exportDir = wxEmptyString;
m_frameSize = wxRect(10, 10, 600, 500);
// m_backgroundColour = wxColour(140, 172, 179); // blue-grey
m_editWindowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
m_appName = wxT("wxWindows Configuration Tool");
m_appNameShort = wxT("Configuration Tool");
m_showSplashScreen = FALSE;
m_userName = wxEmptyString;
m_frameStatus = ctSHOW_STATUS_NORMAL;
m_loadLastDocument = TRUE;
m_firstTimeRun = TRUE;
m_smallToolbar = TRUE;
m_mainSashSize = 200;
m_useToolTips = TRUE;
m_showTrayIcon = TRUE;
m_trayIconIsShown = FALSE;
m_useEnvironmentVariable = TRUE;
m_frameworkDir = wxEmptyString;
}
// Copy constructor
ctSettings::ctSettings(const ctSettings& settings)
{
Copy(settings);
}
ctSettings::~ctSettings()
{
}
void ctSettings::operator = (const ctSettings& settings)
{
Copy(settings);
}
void ctSettings::Copy (const ctSettings& settings)
{
m_currentDocumentDir = settings.m_currentDocumentDir;
m_lastDocument = settings.m_lastDocument;
m_showToolBar = settings.m_showToolBar;
m_frameSize = settings.m_frameSize;
m_editWindowFont = settings.m_editWindowFont;
m_showSplashScreen = settings.m_showSplashScreen;
m_userName = settings.m_userName;
m_loadLastDocument = settings.m_loadLastDocument;
m_exportDir = settings.m_exportDir;
m_firstTimeRun = settings.m_firstTimeRun;
m_noUses = settings.m_noUses;
m_smallToolbar = settings.m_smallToolbar;
m_useToolTips = settings.m_useToolTips;
m_showWelcomeDialog = settings.m_showWelcomeDialog;
m_mainSashSize = settings.m_mainSashSize;
m_showTrayIcon = settings.m_showTrayIcon;
m_trayIconIsShown = settings.m_trayIconIsShown;
m_useEnvironmentVariable = settings.m_useEnvironmentVariable;
m_frameworkDir = settings.m_frameworkDir;
}
// Do some initialisation within stApp::OnInit
bool ctSettings::Init()
{
m_currentDocumentDir = wxEmptyString;
if (m_userName.IsEmpty())
m_userName = wxGetUserName();
return TRUE;
}
// Create new filename
wxString ctSettings::GenerateFilename(const wxString& rootName)
{
wxString path;
if (!m_lastFilename.IsEmpty())
path = wxPathOnly(m_lastFilename);
else
path = wxGetApp().GetAppDir();
wxString filename(path);
if (filename.Last() != wxFILE_SEP_PATH )
filename += wxFILE_SEP_PATH;
filename += rootName;
wxString fullFilename = filename + wxT(".wxs");
int i = 0;
wxString postfixStr;
while (wxFileExists(fullFilename))
{
i ++;
postfixStr.Printf("%d", i);
fullFilename = filename + postfixStr + wxT(".wxs");
}
m_lastFilename = fullFilename;
return fullFilename;
}
// Load config info
bool ctSettings::LoadConfig()
{
wxConfig config(wxGetApp().GetSettings().GetAppName(), wxT("wxWindows"));
config.Read(wxT("Files/LastFile"), & m_lastFilename);
config.Read(wxT("Files/DocumentDir"), & m_currentDocumentDir);
config.Read(wxT("Files/ExportDir"), & m_exportDir);
config.Read(wxT("Files/FrameworkDir"), & m_frameworkDir);
config.Read(wxT("Files/UseEnvironmentVariable"), (bool*) & m_useEnvironmentVariable);
config.Read(wxT("Misc/UserName"), & m_userName);
config.Read(wxT("Misc/FrameStatus"), & m_frameStatus);
config.Read(wxT("Misc/ShowToolTips"), (bool*) & m_useToolTips);
config.Read(wxT("Misc/LastDocument"), & m_lastDocument);
config.Read(wxT("Misc/LoadLastDocument"), (bool*) & m_loadLastDocument);
config.Read(wxT("Misc/ShowWelcomeDialog"), (bool*) & m_showWelcomeDialog);
config.Read(wxT("Misc/Ran"), & m_noUses);
config.Read(wxT("Misc/ShowTrayIcon"), (bool*) & m_showTrayIcon);
m_noUses ++;
config.Read(wxT("Windows/ShowToolBar"), (bool*) & m_showToolBar);
m_firstTimeRun = !(config.Read(wxT("Windows/WindowX"), & m_frameSize.x));
config.Read(wxT("Windows/WindowY"), & m_frameSize.y);
config.Read(wxT("Windows/WindowWidth"), & m_frameSize.width);
config.Read(wxT("Windows/WindowHeight"), & m_frameSize.height);
config.Read(wxT("Windows/ShowSplashScreen"), (bool*) & m_showSplashScreen);
config.Read(wxT("Windows/SmallToolbar"), (bool*) & m_smallToolbar);
config.Read(wxT("Windows/MainSashSize"), & m_mainSashSize);
wxString fontSpec;
fontSpec = wxEmptyString;
config.Read(wxT("Style/EditWindowFont"), & fontSpec);
if (!fontSpec.IsEmpty())
m_editWindowFont = apStringToFont(fontSpec);
// Crash-resistance
int runningProgram = 0;
config.Read(wxT("Misc/RunningProgram"), & runningProgram);
#ifndef __WXDEBUG__
// runningProgram should be zero if all is well. If 1,
// it crashed during a run, so we should disable the auto-load
// facility just in case it's trying to load a damaged file.
if (runningProgram != 0)
{
m_loadLastDocument = FALSE;
}
#endif
config.Write(wxT("Misc/RunningProgram"), (long) 1);
return TRUE;
}
// Save config info
bool ctSettings::SaveConfig()
{
wxConfig config(wxGetApp().GetSettings().GetAppName(), wxT("wxWindows"));
config.Write(wxT("Files/LastFile"), m_lastFilename);
config.Write(wxT("Files/DocumentDir"), m_currentDocumentDir);
config.Write(wxT("Files/ExportDir"), m_exportDir);
config.Write(wxT("Files/FrameworkDir"), m_frameworkDir);
config.Write(wxT("Files/UseEnvironmentVariable"), m_useEnvironmentVariable);
config.Write(wxT("Misc/UserName"), m_userName);
config.Write(wxT("Misc/FrameStatus"), (long) m_frameStatus);
config.Write(wxT("Misc/ShowToolTips"), m_useToolTips);
config.Write(wxT("Misc/LastDocument"), m_lastDocument);
config.Write(wxT("Misc/LoadLastDocument"), (long) m_loadLastDocument);
config.Write(wxT("Misc/ShowWelcomeDialog"), (long) m_showWelcomeDialog);
config.Write(wxT("Misc/Ran"), m_noUses);
config.Write(wxT("Misc/ShowTrayIcon"), (long) m_showTrayIcon);
config.Write(wxT("Windows/ShowToolBar"), m_showToolBar);
config.Write(wxT("Windows/WindowX"), (long) m_frameSize.x);
config.Write(wxT("Windows/WindowY"), (long) m_frameSize.y);
config.Write(wxT("Windows/WindowWidth"), (long) m_frameSize.width);
config.Write(wxT("Windows/WindowHeight"), (long) m_frameSize.height);
config.Write(wxT("Windows/ShowSplashScreen"), m_showSplashScreen);
config.Write(wxT("Windows/SmallToolbar"), (long) m_smallToolbar);
config.Write(wxT("Windows/MainSashSize"), (long) m_mainSashSize);
/*
wxString backgroundColour(apColourToHexString(m_backgroundColour));
config.Write(wxT("Style/BackgroundColour"), backgroundColour);
*/
config.Write(wxT("Style/EditWindowFont"), apFontToString(m_editWindowFont));
// Indicate that we're no longer running, so we know if the program
// crashed last time around.
config.Write(wxT("Misc/RunningProgram"), (long) 0);
{
config.SetPath(wxT("FileHistory/"));
wxGetApp().GetDocManager()->FileHistorySave(config);
}
return TRUE;
}
void ctSettings::ShowSettingsDialog(const wxString& page)
{
ctSettingsDialog* dialog = new ctSettingsDialog(wxGetApp().GetTopWindow());
// if (!page.IsEmpty())
// dialog->GetNotebook()->SetSelection(apFindNotebookPage(dialog->GetNotebook(), page));
/* int ret = */ dialog->ShowModal();
dialog->Destroy();
}

View File

@@ -0,0 +1,124 @@
/////////////////////////////////////////////////////////////////////////////
// Name: appsettings.h
// Purpose: Settings-related classes
// Author: Julian Smart
// Modified by:
// Created: 2002-09-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _AP_APPSETTINGS_H_
#define _AP_APPSETTINGS_H_
#ifdef __GNUG__
#pragma interface appsettings.cpp
#endif
#include "wx/notebook.h"
#include "wx/dialog.h"
#include "wx/datetime.h"
#include "wx/wave.h"
#include "wxconfigtool.h"
// Frame status
#define ctSHOW_STATUS_NORMAL 0x01
#define ctSHOW_STATUS_MINIMIZED 0x02
#define ctSHOW_STATUS_MAXIMIZED 0x03
/*!
* \brief ctSettings holds all the settings that can be altered
* by the user (and probably some that can't).
*/
class ctSettings: public wxObject
{
DECLARE_DYNAMIC_CLASS(ctSettings)
public:
/// Default constructor.
ctSettings();
/// Copy constructor.
ctSettings(const ctSettings& settings);
/// Destructor.
~ctSettings();
// Operations
/// Assignment operator.
void operator = (const ctSettings& settings);
/// Copy function.
void Copy (const ctSettings& settings);
/// Loads configuration information from the registry or a file.
bool LoadConfig();
/// Saves configuration information to the registry or a file.
bool SaveConfig();
/// Initialisation before LoadConfig is called.
bool Init();
/// Shows the settings dialog.
void ShowSettingsDialog(const wxString& page = wxEmptyString);
/// Generates a new document filename.
wxString GenerateFilename(const wxString& rootName);
// Accessors
/// Returns the long application name. This name is used
/// for the registry key and main frame titlebar.
wxString GetAppName() const { return m_appName; }
/// Returns the short application name.
wxString GetShortAppName() const { return m_appNameShort; }
/// Gets the name of the last filename to be loaded.
/// May not be needed in this application.
wxString& GetLastFilename() { return m_lastFilename; }
/// Returns TRUE if this is the first time the application
/// has been run.
bool GetFirstTimeRun() const { return m_firstTimeRun; }
public:
wxString m_currentDocumentDir; // Not yet used
wxString m_lastDocument; // Last document
bool m_showToolBar;
bool m_smallToolbar;
wxRect m_frameSize;
// wxColour m_backgroundColour; // background colour
wxFont m_editWindowFont;
int m_noUses; // Number of times the app was invoked
wxString m_appName; // The current name of the app...
wxString m_appNameShort; // The short name of the app...
bool m_showSplashScreen; // Show the splash screen
wxString m_userName;
wxString m_lastFilename; // So we can auto-generate sensible filenames
bool m_loadLastDocument;
bool m_useToolTips; // Use tooltips on dialogs
int m_frameStatus;
wxString m_exportDir; // Where files are exported to
wxString m_frameworkDir; // Where the wxWin hierarchy is
bool m_useEnvironmentVariable; // Use WXWIN
/// This isn't explicitly held in the registry
/// but deduced from whether there are values there
bool m_firstTimeRun;
bool m_showWelcomeDialog; // Show opening helpful dialog
int m_mainSashSize;
bool m_showTrayIcon;
bool m_trayIconIsShown;
};
#endif
// _AP_APPSETTINGS_H_

View File

@@ -0,0 +1,23 @@
/* XPM */
static char * checked_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c Black",
"o c #c0c0c0",
" ",
" ",
" ............ ",
" .XXXXXXXXXXo ",
" .X o ",
" .X X o ",
" .X XX o ",
" .X X XXX o ",
" .X XX XXX o ",
" .X XXXXX o ",
" .X XXX o ",
" .X X o ",
" .X o ",
" .ooooooooooo ",
" ",
" "};

View File

@@ -0,0 +1,23 @@
/* XPM */
static char * checked_dis_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c Black",
"o c #c0c0c0",
" ",
" ",
" ............ ",
" .XXXXXXXXXXo ",
" .Xoooooooooo ",
" .Xooooooo.oo ",
" .Xoooooo..oo ",
" .Xo.ooo...oo ",
" .Xo..o...ooo ",
" .Xo.....oooo ",
" .Xoo...ooooo ",
" .Xooo.oooooo ",
" .Xoooooooooo ",
" .ooooooooooo ",
" ",
" "};

View File

@@ -0,0 +1,25 @@
/* XPM */
static char *checkedfolder_xpm[] = {
"16 16 6 1",
" c None",
". c #808080",
"X c #FFFF00",
"o c #C0C0C0",
"O c #FFFFFF",
"+ c #000000",
" ",
" ..... ",
" .XoXoX. ",
" .XoXoXoX...... ",
" .OOOOOOOOOOOO.+",
" .OXoXoXoXo+oX.+",
" .OoXoXoXo++Xo.+",
" .OXo+oXo+++oX.+",
" .OoX++o+++oXo.+",
" .OXo+++++oXoX.+",
" .OoXo+++oXoXo.+",
" .OXoXo+oXoXoX.+",
" ..............+",
" ++++++++++++++",
" ",
" "};

View File

@@ -0,0 +1,23 @@
/* XPM */
static char *checkedfolder_dis_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c #C0C0C0",
"o c #000000",
" ",
" ..... ",
" .XXXXX. ",
".XXXXXXX...... ",
".XXXXXXXXXXXX.o ",
".XXXXXXXXX.XX.o ",
".XXXXXXXX..XX.o ",
".XXX.XXX...XX.o ",
".XXX..X...XXX.o ",
".XXX.....XXXX.o ",
".XXXX...XXXXX.o ",
".XXXXX.XXXXXX.o ",
"..............o ",
" oooooooooooooo ",
" ",
" "};

View File

@@ -0,0 +1,25 @@
/* XPM */
static char * closedfolder_xpm[] = {
"16 16 6 1",
" c None",
". c #808080",
"X c Yellow",
"o c #c0c0c0",
"O c Gray100",
"+ c Black",
" ",
" ..... ",
" .XoXoX. ",
" .XoXoXoX...... ",
" .OOOOOOOOOOOO.+",
" .OXoXoXoXoXoX.+",
" .OoXoXoXoXoXo.+",
" .OXoXoXoXoXoX.+",
" .OoXoXoXoXoXo.+",
" .OXoXoXoXoXoX.+",
" .OoXoXoXoXoXo.+",
" .OXoXoXoXoXoX.+",
" ..............+",
" ++++++++++++++",
" ",
" "};

View File

@@ -0,0 +1,23 @@
/* XPM */
static char *closedfolder_dis_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c #C0C0C0",
"o c #000000",
" ",
" ..... ",
" .XXXXX. ",
" .XXXXXXX...... ",
" .XXXXXXXXXXXX.o",
" .XXXXXXXXXXXX.o",
" .XXXXXXXXXXXX.o",
" .XXXXXXXXXXXX.o",
" .XXXXXXXXXXXX.o",
" .XXXXXXXXXXXX.o",
" .XXXXXXXXXXXX.o",
" .XXXXXXXXXXXX.o",
" ..............o",
" oooooooooooooo",
" ",
" "};

View File

@@ -0,0 +1,25 @@
/* XPM */
static char *copy_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 4 1",
" c None",
". c Black",
"X c Gray100",
"o c #000080",
/* pixels */
" ",
" ...... ",
" .XXXX.. ",
" .XXXX.X. ",
" .X..X.oooooo ",
" .XXXXXoXXXXoo ",
" .X....oXXXXoXo ",
" .XXXXXoX..Xoooo",
" .X....oXXXXXXXo",
" .XXXXXoX.....Xo",
" ......oXXXXXXXo",
" oX.....Xo",
" oXXXXXXXo",
" ooooooooo",
" "
};

View File

@@ -0,0 +1,24 @@
/* XPM */
static char *cut_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 3 1",
" c None",
". c Black",
"X c #000080",
/* pixels */
" ",
" . . ",
" . . ",
" . . ",
" .. .. ",
" . . ",
" ... ",
" . ",
" X.X ",
" X XXX ",
" XXX X X ",
" X X X X ",
" X X X X ",
" X X XX ",
" XX "
};

View File

@@ -0,0 +1,21 @@
/* XPM */
static char *ellipsis_xpm[] = {
"16 16 2 1",
" c None",
". c #000000",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" .. .. .. ",
" .. .. .. ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,25 @@
/* XPM */
static char * folder1_xpm[] = {
"16 16 6 1",
" c None",
". c #808080",
"X c Yellow",
"o c None",
"O c Gray100",
"+ c Black",
" ",
" ..... ",
" .XoXoX. ",
" .XoXoXoX...... ",
" .OOOOOOOOOOOO.+",
" .OXoXoXoXoXoX.+",
" .OoXoXoXoXoXo.+",
" .OXoXoXoXoXoX.+",
" .OoXoXoXoXoXo.+",
" .OXoXoXoXoXoX.+",
" .OoXoXoXoXoXo.+",
" .OXoXoXoXoXoX.+",
" ..............+",
" ++++++++++++++",
" ",
" "};

View File

@@ -0,0 +1,24 @@
/* XPM */
static char *help_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 3 1",
" c None",
". c Black",
"X c #008080",
/* pixels */
" ",
" ...... ",
" .XXXXX.. ",
" .XX...XX.. ",
" .X.. .X.. ",
" .X.. .XX.. ",
" .. .XX.. ",
" .XX.. ",
" .X.. ",
" .X.. ",
" .X.. ",
" .. ",
" .XX.. ",
" .XX.. ",
" ... "
};

View File

@@ -0,0 +1,24 @@
/* XPM */
static char *helpcs_xpm[] = {
/* width height num_colors chars_per_pixel */
" 16 15 2 1",
/* colors */
". c #000000",
"# c None",
/* pixels */
"################",
".########.....##",
"..######..###..#",
"...####..####...",
"....###..####...",
".....###..###..#",
"......######..##",
".......####..###",
"........##..####",
".....#####..####",
"..#..###########",
".###..####...###",
"####..####...###",
"#####..#########",
"#####..#########"
};

View File

@@ -0,0 +1,24 @@
/* XPM */
static char *new_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 3 1",
" c None",
". c Black",
"X c Gray100",
/* pixels */
" ",
" ........ ",
" .XXXXXX.. ",
" .XXXXXX.X. ",
" .XXXXXX.... ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" ........... ",
" "
};

View File

@@ -0,0 +1,26 @@
/* XPM */
static char *open_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 5 1",
" c None",
". c Black",
"X c Yellow",
"o c Gray100",
"O c #bfbf00",
/* pixels */
" ",
" ... ",
" . . .",
" ..",
" ... ...",
" .XoX....... ",
" .oXoXoXoXo. ",
" .XoXoXoXoX. ",
" .oXoX..........",
" .XoX.OOOOOOOOO.",
" .oo.OOOOOOOOO. ",
" .X.OOOOOOOOO. ",
" ..OOOOOOOOO. ",
" ........... ",
" "
};

View File

@@ -0,0 +1,27 @@
/* XPM */
static char *paste_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 6 1",
" c None",
". c Black",
"X c Yellow",
"o c #808080",
"O c #000080",
"+ c Gray100",
/* pixels */
" ",
" .... ",
" .....XX..... ",
".ooo.X..X.ooo. ",
".oo. .oo. ",
".oo........oo. ",
".oooooooooooo. ",
".oooooOOOOOOO. ",
".oooooO+++++OO ",
".oooooO+++++O+O ",
".oooooO+OOO+OOO ",
".oooooO+++++++O ",
".oooooO+OOOOO+O ",
" .....O+++++++O ",
" OOOOOOOOO "
};

View File

@@ -0,0 +1,25 @@
/* XPM */
static char *radiofolderoff_xpm[] = {
"16 16 6 1",
" c None",
". c #808080",
"X c #FFFF00",
"o c #C0C0C0",
"O c #FFFFFF",
"+ c #000000",
" ",
" ..... ",
" .XoXoX. ",
" .XoXoXoX...... ",
" .OOOOOOOOOOOO.+",
" .OXoX...XoXoX.+",
" .OoX.OOO.XoXo.+",
" .OX.OOOOO.XoX.+",
" .Oo.OOOOO.oXo.+",
" .OX.OOOOO.XoX.+",
" .OoX.OOO.XoXo.+",
" .OXoX...XoXoX.+",
" ..............+",
" ++++++++++++++",
" ",
" "};

View File

@@ -0,0 +1,23 @@
/* XPM */
static char *radiofolderoff_dis_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c #C0C0C0",
"o c #000000",
" ",
" ..... ",
" .XXXXX. ",
" .XXXXXXX...... ",
" .XXXXXXXXXXXX.o",
" .XXXX...XXXXX.o",
" .XXX.XXX.XXXX.o",
" .XX.XXXXX.XXX.o",
" .XX.XXXXX.XXX.o",
" .XX.XXXXX.XXX.o",
" .XXX.XXX.XXXX.o",
" .XXXX...XXXXX.o",
" ..............o",
" oooooooooooooo",
" ",
" "};

View File

@@ -0,0 +1,25 @@
/* XPM */
static char *radiofolderon_xpm[] = {
"16 16 6 1",
" c None",
". c #808080",
"X c #FFFF00",
"o c #C0C0C0",
"O c #FFFFFF",
"+ c #000000",
" ",
" ..... ",
" .XoXoX. ",
" .XoXoXoX...... ",
" .OOOOOOOOOOOO.+",
" .OXoX...XoXoX.+",
" .OoX.OOO.XoXo.+",
" .OX.O+++O.XoX.+",
" .Oo.O+++O.oXo.+",
" .OX.O+++O.XoX.+",
" .OoX.OOO.XoXo.+",
" .OXoX...XoXoX.+",
" ..............+",
" ++++++++++++++",
" ",
" "};

View File

@@ -0,0 +1,23 @@
/* XPM */
static char *radiofolderon_dis_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c #C0C0C0",
"o c #000000",
" ",
" ..... ",
" .XXXXX. ",
" .XXXXXXX...... ",
" .XXXXXXXXXXXX.o",
" .XXXX...XXXXX.o",
" .XXX.XXX.XXXX.o",
" .XX.X...X.XXX.o",
" .XX.X...X.XXX.o",
" .XX.X...X.XXX.o",
" .XXX.XXX.XXXX.o",
" .XXXX...XXXXX.o",
" ..............o",
" oooooooooooooo",
" ",
" "};

View File

@@ -0,0 +1,23 @@
/* XPM */
static char * radiooff_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c Black",
"o c #c0c0c0",
" ",
" ",
" .... ",
" ..XXXX.. ",
" .XX XXo ",
" .X oo ",
" .X oo ",
" .X oo ",
" .X oo ",
" .X oo ",
" .X oo ",
" .oo ooo ",
" oooooooo ",
" oooo ",
" ",
" "};

View File

@@ -0,0 +1,23 @@
/* XPM */
static char * radiooff_dis_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c Black",
"o c #c0c0c0",
" ",
" ",
" .... ",
" ..XXXX.. ",
" .XXooooXXo ",
" .Xoooooooo ",
" .Xoooooooooo ",
" .Xoooooooooo ",
" .Xoooooooooo ",
" .Xoooooooooo ",
" .Xoooooooo ",
" .ooooooooo ",
" oooooooo ",
" oooo ",
" ",
" "};

View File

@@ -0,0 +1,23 @@
/* XPM */
static char * radioon_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c Black",
"o c #c0c0c0",
" ",
" ",
" .... ",
" ..XXXX.. ",
" .XX XXo ",
" .X oo ",
" .X XX oo ",
" .X XXXX oo ",
" .X XXXX oo ",
" .X XX oo ",
" .X oo ",
" .oo ooo ",
" oooooooo ",
" oooo ",
" ",
" "};

View File

@@ -0,0 +1,23 @@
/* XPM */
static char * radioon_dis_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c Black",
"o c #c0c0c0",
" ",
" ",
" .... ",
" ..XXXX.. ",
" .XXooooXXo ",
" .Xoooooooo ",
" .Xooo..ooooo ",
" .Xoo....oooo ",
" .Xoo....oooo ",
" .Xooo..ooooo ",
" .Xoooooooo ",
" .ooooooooo ",
" oooooooo ",
" oooo ",
" ",
" "};

View File

@@ -0,0 +1,25 @@
/* XPM */
static char *redo_xpm[] = {
/* width height num_colors chars_per_pixel */
" 16 15 3 1",
/* colors */
". c #000080",
"# c #c0c0c0",
"a c #808080",
/* pixels */
"################",
"################",
"################",
"################",
"###a....########",
"##a.####..###.##",
"##.#######.#..##",
"##.########...##",
"##.#######....##",
"##a.#####.....##",
"###.a###########",
"################",
"################",
"################",
"################"
};

View File

@@ -0,0 +1,25 @@
/* XPM */
static char *save_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 4 1",
" c None",
". c Black",
"X c #808000",
"o c #808080",
/* pixels */
" ",
" .............. ",
" .X. . . ",
" .X. ... ",
" .X. .X. ",
" .X. .X. ",
" .X. .X. ",
" .X. .X. ",
" .XX........oX. ",
" .XXXXXXXXXXXX. ",
" .XX.........X. ",
" .XX...... .X. ",
" .XX...... .X. ",
" .XX...... .X. ",
" ............. "
};

View File

@@ -0,0 +1,23 @@
/* XPM */
static char * unchecked_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c Black",
"o c #c0c0c0",
" ",
" ",
" ............ ",
" .XXXXXXXXXXo ",
" .X o ",
" .X o ",
" .X o ",
" .X o ",
" .X o ",
" .X o ",
" .X o ",
" .X o ",
" .X o ",
" .ooooooooooo ",
" ",
" "};

View File

@@ -0,0 +1,23 @@
/* XPM */
static char * unchecked_dis_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c Black",
"o c #c0c0c0",
" ",
" ",
" ............ ",
" .XXXXXXXXXXo ",
" .Xoooooooooo ",
" .Xoooooooooo ",
" .Xoooooooooo ",
" .Xoooooooooo ",
" .Xoooooooooo ",
" .Xoooooooooo ",
" .Xoooooooooo ",
" .Xoooooooooo ",
" .Xoooooooooo ",
" .ooooooooooo ",
" ",
" "};

View File

@@ -0,0 +1,25 @@
/* XPM */
static char *uncheckedfolder_xpm[] = {
"16 16 6 1",
" c None",
". c #808080",
"X c #FFFF00",
"o c #C0C0C0",
"O c #FFFFFF",
"+ c #000000",
" ",
" ..... ",
" .XoXoX. ",
" .XoXoXoX...... ",
" .OOOOOOOOOOOO.+",
" .OXoXoXoXoXoX.+",
" .OoX++oX++oXo.+",
" .OXoX++++oXoX.+",
" .OoXoX++oXoXo.+",
" .OXoX++++oXoX.+",
" .OoX++oX++oXo.+",
" .OXoXoXoXoXoX.+",
" ..............+",
" ++++++++++++++",
" ",
" "};

View File

@@ -0,0 +1,23 @@
/* XPM */
static char *uncheckedfolder_dis_xpm[] = {
"16 16 4 1",
" c None",
". c #808080",
"X c #C0C0C0",
"o c #000000",
" ",
" ..... ",
" .XXXXX. ",
" .XXXXXXX...... ",
" .XXXXXXXXXXXX.o",
" .XXXXXXXXXXXX.o",
" .XXX..XX..XXX.o",
" .XXXX....XXXX.o",
" .XXXXX..XXXXX.o",
" .XXXX....XXXX.o",
" .XXX..XX..XXX.o",
" .XXXXXXXXXXXX.o",
" ..............o",
" oooooooooooooo",
" ",
" "};

View File

@@ -0,0 +1,25 @@
/* XPM */
static char *undo_xpm[] = {
/* width height num_colors chars_per_pixel */
" 16 15 3 1",
/* colors */
". c #000080",
"# c #c0c0c0",
"a c #808080",
/* pixels */
"################",
"################",
"################",
"################",
"########....a###",
"##.###..####.a##",
"##..#.#######.##",
"##...########.##",
"##....#######.##",
"##.....#####.a##",
"###########a.###",
"################",
"################",
"################",
"################"
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,41 @@
/* XPM */
static char *wxconfigtool_xpm[] = {
"32 32 6 1",
" c None",
". c #000000",
"X c #000084",
"o c #FFFFFF",
"O c #FFFF00",
"+ c #FF0000",
" ",
" ",
" ",
" ",
" ",
" .............. ",
" .XXXXXXXXXXXX. ",
" .XXXXXXXXXXXX. ",
" .XooXXXXXXXXX. ",
" .XooXXXXXXXXX. ",
" .XooXXXXXXXXX. ",
" .XooXXXXXX..............",
" .XooXXXXXX.OOOOOOOOOOOO.",
".........XooXXXXXX.OOOOOOOOOOOO.",
".+++++++.XooXXXXXX.OooOOOOOOOOO.",
".+++++++.XooXXXXXX.OooOOOOOOOOO.",
".+oo++++.XXXXXXXXX.OooOOOOOOOOO.",
".+oo++++.XXXXXXXXX.OooOOOOOOOOO.",
".+oo++++...........OooOOOOOOOOO.",
".+oo+++++++++. .OooOOOOOOOOO.",
".+oo+++++++++. .OooOOOOOOOOO.",
".+oo+++++++++. .OooOOOOOOOOO.",
".+oo+++++++++. .OOOOOOOOOOOO.",
".+oo+++++++++. .OOOOOOOOOOOO.",
".++++++++++++. ..............",
".++++++++++++. ",
".............. ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,25 @@
/* XPM */
static char *wxconfigtool16x16_xpm[] = {
"16 16 6 1",
" c None",
". c #000000",
"X c #000084",
"o c #FFFFFF",
"O c #FFFF00",
"+ c #FF0000",
" ",
" ",
" ",
" ....... ",
" .XXXXX. ",
" .oXXXX. ",
" .oXXX.......",
".....oXXX.OOOOO.",
".+++.XXXX.oOOOO.",
".o++......oOOOO.",
".o++++. .oOOOO.",
".o++++. .OOOOO.",
".+++++. .......",
"....... ",
" ",
" "};

View File

@@ -0,0 +1,41 @@
/* XPM */
static char *wxconfigtool32x32_xpm[] = {
"32 32 6 1",
" c None",
". c #000000",
"X c #000084",
"o c #FFFFFF",
"O c #FFFF00",
"+ c #FF0000",
" ",
" ",
" ",
" ",
" ",
" .............. ",
" .XXXXXXXXXXXX. ",
" .XXXXXXXXXXXX. ",
" .XooXXXXXXXXX. ",
" .XooXXXXXXXXX. ",
" .XooXXXXXXXXX. ",
" .XooXXXXXX..............",
" .XooXXXXXX.OOOOOOOOOOOO.",
".........XooXXXXXX.OOOOOOOOOOOO.",
".+++++++.XooXXXXXX.OooOOOOOOOOO.",
".+++++++.XooXXXXXX.OooOOOOOOOOO.",
".+oo++++.XXXXXXXXX.OooOOOOOOOOO.",
".+oo++++.XXXXXXXXX.OooOOOOOOOOO.",
".+oo++++...........OooOOOOOOOOO.",
".+oo+++++++++. .OooOOOOOOOOO.",
".+oo+++++++++. .OooOOOOOOOOO.",
".+oo+++++++++. .OooOOOOOOOOO.",
".+oo+++++++++. .OOOOOOOOOOOO.",
".+oo+++++++++. .OOOOOOOOOOOO.",
".++++++++++++. ..............",
".++++++++++++. ",
".............. ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,755 @@
/////////////////////////////////////////////////////////////////////////////
// Name: configitem.cpp
// Purpose: wxWindows Configuration Tool config item class
// Author: Julian Smart
// Modified by:
// Created: 2003-06-03
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "configitem.h"
#endif
// Includes other headers for precompiled compilation
#include "wx/wx.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/tokenzr.h"
#include "configitem.h"
#include "configtree.h"
#include "configtooldoc.h"
#include "configtoolview.h"
#include "wxconfigtool.h"
#include "mainframe.h"
IMPLEMENT_CLASS(ctConfigItem, wxObject)
ctConfigItem::ctConfigItem()
{
m_modified = FALSE;
m_type = ctTypeBoolCheck;
m_treeItemId = wxTreeItemId();
m_enabled = TRUE;
m_parent = NULL;
m_active = TRUE;
}
ctConfigItem::ctConfigItem(ctConfigItem* parent, ctConfigType type, const wxString& name)
{
m_modified = FALSE;
m_type = type;
m_treeItemId = wxTreeItemId();
m_enabled = FALSE;
m_active = TRUE;
SetName(name);
m_parent = parent;
if (parent)
parent->AddChild(this);
}
ctConfigItem::~ctConfigItem()
{
ctConfigTreeCtrl* treeCtrl = wxGetApp().GetMainFrame()->GetConfigTreeCtrl();
if (m_treeItemId.IsOk() && treeCtrl)
{
ctTreeItemData* data = (ctTreeItemData*) treeCtrl->GetItemData(m_treeItemId);
if (data)
data->SetConfigItem(NULL);
}
if (GetParent())
GetParent()->RemoveChild(this);
else
{
if (wxGetApp().GetMainFrame()->GetDocument() &&
wxGetApp().GetMainFrame()->GetDocument()->GetTopItem() == this)
wxGetApp().GetMainFrame()->GetDocument()->SetTopItem(NULL);
}
Clear();
}
/// Can we edit this property?
bool ctConfigItem::CanEditProperty(const wxString& propName) const
{
ctProperty* prop = m_properties.FindProperty(propName);
if (prop)
return !prop->GetReadOnly();
else
return FALSE;
}
/// Assignment operator.
void ctConfigItem::operator= (const ctConfigItem& item)
{
m_properties = item.m_properties;
m_modified = item.m_modified;
m_defaultProperty = item.m_defaultProperty;
m_type = item.m_type;
m_enabled = item.m_enabled;
m_active = item.m_active;
}
/// Sets the name property.
void ctConfigItem::SetName(const wxString& name )
{
m_properties.SetProperty(wxT("name"), name);
}
/// Clear children
void ctConfigItem::Clear()
{
wxNode* node = m_children.GetFirst();
while (node)
{
wxNode* next = node->GetNext();
ctConfigItem* child = (ctConfigItem*) node->GetData();
// This should delete 'node' too, assuming
// child's m_parent points to 'this'. If not,
// it'll be cleaned up by m_children.Clear().
delete child;
node = next;
}
m_children.Clear();
}
// Get the nth child
ctConfigItem* ctConfigItem::GetChild(int n) const
{
wxASSERT ( n < GetChildCount() && n > -1 );
if ( n < GetChildCount() && n > -1 )
{
ctConfigItem* child = wxDynamicCast(m_children.Nth(n)->Data(), ctConfigItem);
return child;
}
else
return NULL;
}
// Get the child count
int ctConfigItem::GetChildCount() const
{
return m_children.GetCount();
}
/// Add a child
void ctConfigItem::AddChild(ctConfigItem* item)
{
m_children.Append(item);
item->SetParent(this);
}
/// Remove (but don't delete) a child
void ctConfigItem::RemoveChild(ctConfigItem* item)
{
m_children.DeleteObject(item);
item->SetParent(NULL);
}
/// Initialise standard properties
void ctConfigItem::InitProperties()
{
ctProperty* prop = m_properties.FindProperty(wxT("name"));
if (!prop)
{
prop = new ctProperty;
m_properties.AddProperty(prop);
}
prop->SetDescription(_("<B>Name</B><P> The name of the configuration setting."));
prop->SetReadOnly(TRUE);
m_properties.AddProperty(
new ctProperty(
wxT("<B>Description</B><P> The setting description."),
wxVariant(wxT(""), wxT("description")),
wxT("multiline")));
m_properties.AddProperty(
new ctProperty(
wxT("<B>Default-state</B><P> The default state."),
wxVariant((bool) TRUE, wxT("default-state")),
wxT("bool")));
if (GetType() == ctTypeString)
{
m_properties.AddProperty(
new ctProperty(
wxT("<B>Default-value</B><P> The default value."),
wxVariant((bool) TRUE, wxT("default-value")),
wxT("")));
}
else if (GetType() == ctTypeInteger)
{
m_properties.AddProperty(
new ctProperty(
wxT("<B>Default-value</B><P> The default value."),
wxVariant((long) 0, wxT("default-value")),
wxT("")));
}
m_properties.AddProperty(
new ctProperty(
wxT("<B>Requires</B><P> When any of the given settings are 0, this setting <I>must</I> be 0. Taking wxUSE_ZIPSTREAM as an example:<P> If wxUSE_STREAMS is 0, then wxUSE_ZIPSTREAM must be 0.<BR>If wxUSE_STREAMS is 1, then wxUSE_ZIPSTREAM may be 0 or 1."),
wxVariant(wxT(""), wxT("requires")),
wxT("configitems")));
m_properties.AddProperty(
new ctProperty(
wxT("<B>Precludes</B><P> When any of these settings are 1, this setting <I>must</I> be 0. Taking wxUSE_ODBC as an example:<P> If wxUSE_UNICODE is 1, then wxUSE_ODBC must be 0.<BR>If wxUSE_UNICODE is 0, then wxUSE_ODBC may be 0 or 1."),
wxVariant(wxT(""), wxT("precludes")),
wxT("configitems")));
m_properties.AddProperty(
new ctProperty(
wxT("<B>Enabled-if</B><P> When any of these settings are 1, this setting <I>must</I> be 1."),
wxVariant(wxT(""), wxT("enabled-if")),
wxT("configitems")));
m_properties.AddProperty(
new ctProperty(
wxT("<B>Enabled-if-not</B><P> When any of these settings are 0, this setting <I>must</I> be 1. Taking wxUSE_TOOLBAR_SIMPLE as an example:<P>If wxUSE_TOOLBAR_NATIVE is 0, wxUSE_TOOLBAR_SIMPLE must be 1.<BR>If wxUSE_TOOLBAR_NATIVE is 1, wxUSE_TOOLBAR_SIMPLE may be 0 or 1."),
wxVariant(wxT(""), wxT("enabled-if-not")),
wxT("configitems")));
m_properties.AddProperty(
new ctProperty(
wxT("<B>Exclusivity</B><P> The settings that are mutually exclusive with this one."),
wxVariant(wxT(""), wxT("exclusivity")),
wxT("configitems")));
m_properties.AddProperty(
new ctProperty(
wxT("<B>Context</B><P> A list of symbols (config settings), at least one of which must be enabled for this item to participate in dependency rules.<P>\nIf empty, this item will always be used in dependency rules.<P>\nMostly this will be used to specify the applicable platforms, but it can contain other symbols, for example compilers."),
wxVariant(wxT(""), wxT("context")),
wxT("configitems")));
m_properties.AddProperty(
new ctProperty(
wxT("<B>Configure-command</B><P> Configure command to generate if this is on."),
wxVariant(wxT(""), wxT("configure-command")),
wxT("multiline")));
m_properties.AddProperty(
new ctProperty(
wxT("<B>Help-topic</B><P> The help topic in the wxWindows manual for this component or setting."),
wxVariant(wxT(""), wxT("help-topic")),
wxT("multiline")));
m_properties.AddProperty(
new ctProperty(
wxT("<B>Notes</B><P> User notes."),
wxVariant(wxT(""), wxT("notes")),
wxT("multiline")));
m_defaultProperty = wxT("description");
}
/// Do additional actions to apply the property to the internal
/// representation.
void ctConfigItem::ApplyProperty(ctProperty* prop, const wxVariant& oldValue)
{
ctConfigToolDoc* doc = GetDocument();
bool oldModified = doc->IsModified();
doc->Modify(TRUE);
wxString name = prop->GetName();
if (name == wxT("requires") ||
name == wxT("precludes") ||
name == wxT("enabled-if") ||
name == wxT("enabled-if-not") ||
name == wxT("context"))
{
doc->RefreshDependencies();
}
if (doc && doc->GetFirstView() && oldModified != doc->IsModified())
((ctConfigToolView*)doc->GetFirstView())->OnChangeFilename();
}
/// Get the associated document (currently, assumes
/// there's only ever one document active)
ctConfigToolDoc* ctConfigItem::GetDocument()
{
ctConfigToolDoc* doc = wxGetApp().GetMainFrame()->GetDocument();
return doc;
}
/// Convert string containing config item names to
/// an array of config item names
void ctConfigItem::StringToArray(const wxString& items, wxArrayString& itemsArray)
{
wxStringTokenizer tokenizer(items, wxT(","));
while (tokenizer.HasMoreTokens())
{
wxString token = tokenizer.GetNextToken();
itemsArray.Add(token);
}
}
/// Convert array containing config item names to
/// a string
void ctConfigItem::ArrayToString(const wxArrayString& itemsArray, wxString& items)
{
items = wxEmptyString;
size_t i;
for (i = 0; i < itemsArray.GetCount(); i++)
{
items += itemsArray[i];
if (i < (itemsArray.GetCount() - 1))
items += wxT(",");
}
}
/// Populate a list of items found in the string.
void ctConfigItem::StringToItems(ctConfigItem* topItem, const wxString& items, wxList& list)
{
wxArrayString strArray;
StringToArray(items, strArray);
size_t i;
for (i = 0; i < strArray.GetCount(); i++)
{
wxString str(strArray[i]);
ctConfigItem* item = topItem->FindItem(str);
if (item)
list.Append(item);
}
}
/// Find an item in this hierarchy
ctConfigItem* ctConfigItem::FindItem(const wxString& name)
{
if (GetName() == name)
return this;
for ( wxNode* node = GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
ctConfigItem* found = child->FindItem(name);
if (found)
return found;
}
return NULL;
}
/// Find the next sibling
ctConfigItem* ctConfigItem::FindNextSibling()
{
if (!GetParent())
return NULL;
wxNode* node = GetParent()->GetChildren().Member(this);
if (node && node->GetNext())
{
return (ctConfigItem*) node->GetNext()->GetData();
}
return NULL;
}
/// Find the previous sibling
ctConfigItem* ctConfigItem::FindPreviousSibling()
{
if (!GetParent())
return NULL;
wxNode* node = GetParent()->GetChildren().Member(this);
if (node && node->GetPrevious())
{
return (ctConfigItem*) node->GetPrevious()->GetData();
}
return NULL;
}
/// Sync appearance
void ctConfigItem::Sync()
{
if (GetDocument())
{
ctConfigToolView* view = (ctConfigToolView*) GetDocument()->GetFirstView();
if (view)
{
view->SyncItem(wxGetApp().GetMainFrame()->GetConfigTreeCtrl(), this);
}
}
}
/// Create a clone of this and children
ctConfigItem* ctConfigItem::DeepClone()
{
ctConfigItem* newItem = Clone();
for ( wxNode* node = GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
ctConfigItem* newChild = child->DeepClone();
newItem->AddChild(newChild);
}
return newItem;
}
/// Detach: remove from parent, and remove tree items
void ctConfigItem::Detach()
{
if (GetParent())
GetParent()->RemoveChild(this);
else
GetDocument()->SetTopItem(NULL);
SetParent(NULL);
wxTreeItemId treeItem = GetTreeItemId();
DetachFromTree();
// Will delete the branch, but not the config items.
wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->Delete(treeItem);
}
/// Hide from tree: make sure tree deletions won't delete
/// the config items
void ctConfigItem::DetachFromTree()
{
wxTreeItemId item = GetTreeItemId();
ctTreeItemData* data = (ctTreeItemData*) wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetItemData(item);
data->SetConfigItem(NULL);
m_treeItemId = wxTreeItemId();
for ( wxNode* node = GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
child->DetachFromTree();
}
}
/// Attach: insert after the given position
void ctConfigItem::Attach(ctConfigItem* parent, ctConfigItem* insertBefore)
{
if (parent)
{
SetParent(parent);
wxNode* node = NULL;
if (insertBefore)
node = parent->GetChildren().Member(insertBefore);
if (node)
parent->GetChildren().Insert(node, this);
else
parent->GetChildren().Append(this);
}
else
{
GetDocument()->SetTopItem(this);
}
}
/// Can have children?
bool ctConfigItem::CanHaveChildren() const
{
return (GetType() == ctTypeGroup ||
GetType() == ctTypeCheckGroup ||
GetType() == ctTypeRadioGroup);
}
// An item is in the active context if:
// The context field is empty; or
// The context field contains a symbol that is currently enabled.
bool ctConfigItem::IsInActiveContext()
{
wxString context = GetPropertyString(wxT("context"));
if (context.IsEmpty())
return TRUE;
wxList contextItems;
StringToItems(GetDocument()->GetTopItem(), context, contextItems);
for ( wxNode* node = contextItems.GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* otherItem = (ctConfigItem*) node->GetData();
if (otherItem->IsEnabled())
return TRUE;
}
return FALSE;
}
/// Evaluate the requires properties:
/// if any of the 'requires' items are disabled,
/// then this one is disabled (and inactive).
void ctConfigItem::EvaluateDependencies()
{
wxList items;
wxString requires = GetPropertyString(wxT("requires"));
wxString precludes = GetPropertyString(wxT("precludes"));
wxString enabledIf = GetPropertyString(wxT("enabled-if"));
wxString enabledIfNot = GetPropertyString(wxT("enabled-if-not"));
bool active = TRUE;
bool enabled = IsEnabled();
bool oldEnabled = enabled;
bool oldActive = IsActive();
bool explicitlyEnabled = FALSE;
bool explicitlyDisabled = FALSE;
bool inActiveContext = IsInActiveContext();
// Add the parent to the list of dependencies, if the
// parent is a check or radio group.
ctConfigItem* parent = GetParent();
if (parent &&
(parent->GetType() == ctTypeCheckGroup ||
parent->GetType() == ctTypeRadioGroup))
items.Append(parent);
wxList tempItems;
StringToItems(GetDocument()->GetTopItem(), requires, tempItems);
wxNode* node;
for ( node = tempItems.GetFirst(); node; node = node->GetNext() )
{
// Only consider the dependency if both items are in
// an active context.
// Each is in the active context if:
// The context field is empty; or
// The context field contains a symbol that is currently enabled.
ctConfigItem* otherItem = (ctConfigItem*) node->GetData();
if (inActiveContext && otherItem->IsInActiveContext())
items.Append(otherItem);
}
{
int enabledCount = 0;
for ( node = items.GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* otherItem = (ctConfigItem*) node->GetData();
if (otherItem->IsEnabled())
{
enabledCount ++;
}
}
if (items.GetCount() > 0 && enabledCount == 0)
{
// None of the items were enabled
enabled = FALSE;
active = FALSE;
explicitlyDisabled = TRUE;
}
}
items.Clear();
if (!enabledIfNot.IsEmpty())
{
StringToItems(GetDocument()->GetTopItem(), enabledIfNot, items);
int disabledCount = 0;
int inContextCount = 0;
for ( wxNode* node = items.GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* otherItem = (ctConfigItem*) node->GetData();
if (inActiveContext && otherItem->IsInActiveContext())
{
// Make this enabled and inactive, _unless_ it's
// already been explicitly disabled in the previous
// requires evaluation (it really _has_ to be off)
if (!otherItem->IsEnabled())
{
disabledCount ++;
}
inContextCount ++;
}
}
// Enable if there were no related items that were enabled
if (inContextCount > 0 && (disabledCount == inContextCount) && !explicitlyDisabled)
{
explicitlyEnabled = TRUE;
enabled = TRUE;
active = FALSE;
}
}
items.Clear();
if (!enabledIf.IsEmpty())
{
StringToItems(GetDocument()->GetTopItem(), enabledIf, items);
int enabledCount = 0;
int inContextCount = 0;
for ( wxNode* node = items.GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* otherItem = (ctConfigItem*) node->GetData();
if (inActiveContext && otherItem->IsInActiveContext())
{
// Make this enabled and inactive, _unless_ it's
// already been explicitly disabled in the previous
// requires evaluation (it really _has_ to be off)
if (otherItem->IsEnabled())
{
enabledCount ++;
}
inContextCount ++;
}
}
// Enable if there were no related items that were disabled
if (inContextCount > 0 && (enabledCount > 0) && !explicitlyDisabled)
{
explicitlyEnabled = TRUE;
enabled = TRUE;
active = FALSE;
}
}
items.Clear();
if (!precludes.IsEmpty())
{
StringToItems(GetDocument()->GetTopItem(), precludes, items);
int enabledCount = 0;
int inContextCount = 0;
for ( wxNode* node = items.GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* otherItem = (ctConfigItem*) node->GetData();
if (inActiveContext && otherItem->IsInActiveContext())
{
// Make this enabled and inactive, _unless_ it's
// already been explicitly disabled in the previous
// requires evaluation (it really _has_ to be off)
if (otherItem->IsEnabled())
{
enabledCount ++;
}
}
}
// Disable if there were no related items that were disabled
if (inContextCount > 0 && (enabledCount == inContextCount) && !explicitlyEnabled)
{
enabled = FALSE;
active = FALSE;
}
}
// Finally check a sort of dependency: whether our
// context is active. If not, make this inactive.
if (!IsInActiveContext())
active = FALSE;
SetActive(active);
// If going active, set enabled state to the default state
if (active &&
oldActive != active &&
(GetType() == ctTypeBoolCheck || GetType() == ctTypeCheckGroup) &&
m_properties.FindProperty(wxT("default-state")))
{
bool defaultState = m_properties.FindProperty(wxT("default-state"))->GetVariant().GetBool();
enabled = defaultState;
}
Enable(enabled);
// Deal with setting a radio button
if (enabled && enabled != oldEnabled &&
(GetType() == ctTypeBoolRadio || GetType() == ctTypeRadioGroup))
{
wxList considered;
PropagateRadioButton(considered);
}
}
/// Get description, which may be dynamically
/// generated depending on the property.
wxString ctConfigItem::GetDescription(ctProperty* property)
{
if (property->GetName() == wxT("description"))
{
wxString value(property->GetValue());
if (value.IsEmpty())
return wxT("Double-click on <B>description</B> to write a brief explanation of the setting.<P>");
else
return value;
}
else if (property->GetName() == wxT("notes"))
{
wxString value(property->GetValue());
if (value.IsEmpty())
return wxT("Double-click on <B>notes</B> to write notes about this setting.<P>");
else
return value;
}
return property->GetDescription();
}
/// Get the title for the property editor
wxString ctConfigItem::GetTitle()
{
wxString title(GetName());
if (GetType() == ctTypeCheckGroup ||
GetType() == ctTypeRadioGroup ||
GetType() == ctTypeBoolCheck ||
GetType() == ctTypeBoolRadio)
{
if (IsEnabled())
title = title + _T(" - enabled");
else
title = title + _T(" - disabled");
}
return title;
}
/// Propagate a change in enabled/disabled status
void ctConfigItem::PropagateChange(wxList& considered)
{
if (GetType() == ctTypeCheckGroup ||
GetType() == ctTypeRadioGroup ||
GetType() == ctTypeBoolCheck ||
GetType() == ctTypeBoolRadio)
{
// TODO: what about string, integer? Can they have
// dependencies?
for ( wxNode* node = GetDependents().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
// Avoid loops
if (!considered.Member(child))
{
considered.Append(child);
child->EvaluateDependencies();
child->Sync();
child->PropagateChange(considered);
}
}
}
}
/// Process radio button selection
void ctConfigItem::PropagateRadioButton(wxList& considered)
{
if ((GetType() == ctTypeBoolRadio || GetType() == ctTypeRadioGroup) && IsEnabled())
{
wxString mutuallyExclusive(GetPropertyString(wxT("exclusivity")));
wxList list;
StringToItems(GetDocument()->GetTopItem(), mutuallyExclusive, list);
for ( wxNode* node = list.GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
if (child->IsEnabled() && child != this)
{
child->Enable(FALSE);
child->Sync();
if (!considered.Member(child))
child->PropagateChange(considered);
}
}
}
}

View File

@@ -0,0 +1,279 @@
/////////////////////////////////////////////////////////////////////////////
// Name: configitem.h
// Purpose: wxWindows Configuration Tool config item class
// Author: Julian Smart
// Modified by:
// Created: 2003-06-03
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _CT_CONFIGITEM_H_
#define _CT_CONFIGITEM_H_
#ifdef __GNUG__
#pragma interface "configitem.cpp"
#endif
#include "wx/wx.h"
#include "wx/treectrl.h"
#include "property.h"
class ctConfigToolDoc;
/*!
* The type of config item
*/
enum ctConfigType
{
ctTypeUnknown,
ctTypeGroup, // A group with no checkbox
ctTypeCheckGroup, // A group that can be switched on/off (check)
ctTypeRadioGroup, // A group that can be switched on/off (radio)
ctTypeString, // An option with a string value
ctTypeInteger, // An option with an integer value
ctTypeBoolCheck, // An on/off option
ctTypeBoolRadio // An on/off mutually exclusive option
};
/*!
* ctConfigItem represents a configuration setting.
* Each setting has a number of properties, some of
* which may be specific to a particular kind of
* setting, so we make it quite generic and extensible
* by using a property list.
*/
class ctConfigItem: public wxObject
{
public:
/// Ctor and dtor
ctConfigItem(ctConfigItem* parent, ctConfigType type, const wxString& name);
ctConfigItem();
~ctConfigItem();
/// Copy constructor.
ctConfigItem(const ctConfigItem& item)
{
(*this) = item;
}
/// Operations
/// Assignment operator.
void operator= (const ctConfigItem& item);
/// Create a clone
ctConfigItem* Clone()
{
ctConfigItem* item = new ctConfigItem;
*item = *this;
return item;
}
/// Create a clone of this and children
ctConfigItem* DeepClone();
/// Do additional actions to apply the property to the internal
/// representation.
void ApplyProperty(ctProperty* prop, const wxVariant& oldValue);
/// Clear children
void Clear();
/// Add a child
void AddChild(ctConfigItem* item);
/// Remove (but don't delete) a child
void RemoveChild(ctConfigItem* item);
/// Initialise standard properties
void InitProperties();
/// Convert string containing config item names to
/// an array of config item names
static void StringToArray(const wxString& items, wxArrayString& itemsArray);
/// Convert array containing config item names to
/// a string
static void ArrayToString(const wxArrayString& itemsArray, wxString& items);
/// Populate a list of items found in the string.
static void StringToItems(ctConfigItem* topItem, const wxString& items, wxList& list);
/// Find an item in this hierarchy
ctConfigItem* FindItem(const wxString& name);
/// Find the next sibling
ctConfigItem* FindNextSibling();
/// Find the previous sibling
ctConfigItem* FindPreviousSibling();
/// Sync appearance
void Sync();
/// Detach: remove from parent, and remove tree items
void Detach();
/// Attach: insert before the given position
void Attach(ctConfigItem* parent, ctConfigItem* insertbefore);
/// Hide from tree: make sure tree deletions won't delete
/// the config items
void DetachFromTree();
/// Evaluate the depends-on properties:
/// if any of the depends-on items are disabled,
/// then this one is disabled (and inactive).
void EvaluateDependencies();
/// Propagate a change in enabled/disabled status
void PropagateChange(wxList& considered);
/// Process radio button selection
void PropagateRadioButton(wxList& considered);
// An item is in the active context if:
// The context field is empty; or
// The context field contains a symbol that is currently enabled.
bool IsInActiveContext();
/// Accessors
/// Returns the name property.
wxString GetName() const { return GetPropertyString(wxT("name")); }
/// Sets the name property.
void SetName(const wxString& name ) ;
/// Returns the value property.
wxVariant GetValue() const { return m_properties.FindPropertyValue(wxT("value")); }
/// Sets the value property.
void SetValue(const wxVariant& value ) ;
/// Returns the string for the given property.
wxString GetPropertyString(const wxString& propName) const { return m_properties.FindPropertyValueString(propName); }
/// Sets the string for the given property.
void SetPropertyString(const wxString& propName, const wxString& value) { m_properties.SetProperty(propName, value); }
/// Can we edit this property?
bool CanEditProperty(const wxString& propName) const ;
/// Returns the list of properties for
/// this item.
ctProperties& GetProperties() { return m_properties; }
/// Set the default property.
void SetDefaultProperty(const wxString& defaultProp) { m_defaultProperty = defaultProp; }
/// Get the default property.
wxString GetDefaultProperty() const { return m_defaultProperty; }
/// Is this item modified?
bool IsModified() const { return m_modified; }
/// Mark this as modified.
void Modify(bool modified = TRUE) { m_modified = modified; }
/// Is this item enabled? (checked/unchecked)
bool IsEnabled() const { return m_enabled; }
/// Enable or disable (check/uncheck)
void Enable(bool enable = TRUE) { m_enabled = enable; }
/// Is this item active? (sensitive to user input)
bool IsActive() const { return m_active; }
/// Make this (in)active
void SetActive(bool active = TRUE) { m_active = active; }
/// Set the type
void SetType(ctConfigType type) { m_type = type; }
// Get the type
ctConfigType GetType() const { return m_type; }
/// Set the tree item id
void SetTreeItem(wxTreeItemId id) { m_treeItemId = id; }
// Get the type
wxTreeItemId GetTreeItemId() const { return m_treeItemId ; }
/// Get the list of children
wxList& GetChildren() { return m_children; }
/// Get the nth child
ctConfigItem* GetChild(int n) const;
/// Get the child count
int GetChildCount() const;
/// Get the list of dependents
wxList& GetDependents() { return m_dependents; }
/// Get the parent
ctConfigItem* GetParent() const { return m_parent; }
/// Set the parent
void SetParent(ctConfigItem* parent) { m_parent = parent; }
/// Get the associated document (currently, assumes
/// there's only ever one document active)
ctConfigToolDoc* GetDocument() ;
/// Can have children?
bool CanHaveChildren() const;
/// Get description, which may be dynamically
/// generated depending on the property.
wxString GetDescription(ctProperty* property);
/// Get the title for the property editor
wxString GetTitle();
protected:
/// The properties for this item.
ctProperties m_properties;
/// The default property, from the point of
/// of double-clicking the config item.
wxString m_defaultProperty;
/// Whether modified
bool m_modified;
/// The type of the config item
ctConfigType m_type;
/// The corresponding tree item
wxTreeItemId m_treeItemId;
/// Is this option enabled? (checked/unchecked)
bool m_enabled;
/// Is this option active? (i.e. sensitive to user input)
bool m_active;
/// The list of children.
wxList m_children;
/// The list of items that are dependent upon
// this one. This is refreshed when the configuration
// structurally changes, and is not saved to file.
wxList m_dependents;
/// The parent config item
ctConfigItem* m_parent;
DECLARE_CLASS(ctConfigItem)
};
#endif
// _CT_CONFIGITEM_H_

View File

@@ -0,0 +1,266 @@
/////////////////////////////////////////////////////////////////////////////
// Name: configitemselector.cpp
// Purpose: Selector for one or more config items
// Author: Julian Smart
// Modified by:
// Created: 2003-06-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation configitemselector.cpp
#endif
#include <wx/wx.h>
#include <wx/cshelp.h>
#include <wx/statline.h>
#include <wx/splitter.h>
#include <wx/scrolwin.h>
#include <wx/spinctrl.h>
#include <wx/spinbutt.h>
#include <wx/valgen.h>
#include "configitemselector.h"
#include "configtooldoc.h"
#include "configtoolview.h"
#include "configitem.h"
#include "mainframe.h"
#include "wxconfigtool.h"
////@begin XPM images
////@end XPM images
/*!
* ctConfigItemsSelector type definition
*/
IMPLEMENT_CLASS( ctConfigItemsSelector, wxDialog )
/*!
* ctConfigItemsSelector event table definition
*/
BEGIN_EVENT_TABLE( ctConfigItemsSelector, wxDialog )
////@begin ctConfigItemsSelector event table entries
EVT_BUTTON( ID_CONFIG_ADD, ctConfigItemsSelector::OnConfigAdd )
EVT_UPDATE_UI( ID_CONFIG_ADD, ctConfigItemsSelector::OnUpdateConfigAdd )
EVT_BUTTON( ID_CONFIG_REMOVE, ctConfigItemsSelector::OnConfigRemove )
EVT_UPDATE_UI( ID_CONFIG_REMOVE, ctConfigItemsSelector::OnUpdateConfigRemove )
EVT_BUTTON( wxID_OK, ctConfigItemsSelector::OnOk )
////@end ctConfigItemsSelector event table entries
END_EVENT_TABLE()
/*!
* ctConfigItemsSelector constructor
*/
ctConfigItemsSelector::ctConfigItemsSelector( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
InitSourceConfigList();
}
/*!
* Control creation for ctConfigItemsSelector
*/
void ctConfigItemsSelector::CreateControls()
{
////@begin ctConfigItemsSelector content construction
ctConfigItemsSelector* item1 = this;
wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL);
item1->SetSizer(item2);
item1->SetAutoLayout(TRUE);
wxBoxSizer* item3 = new wxBoxSizer(wxVERTICAL);
item2->Add(item3, 1, wxGROW|wxALL, 5);
wxStaticText* item4 = new wxStaticText(item1, wxID_STATIC, _("Please edit the list of configuration items by selecting from the\nlist below."), wxDefaultPosition, wxDefaultSize, 0);
item3->Add(item4, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
wxStaticText* item5 = new wxStaticText(item1, wxID_STATIC, _("&Available items:"), wxDefaultPosition, wxDefaultSize, 0);
item3->Add(item5, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
wxString* item6Strings = NULL;
wxListBox* item6 = new wxListBox(item1, ID_AVAILABLE_CONFIG_ITEMS, wxDefaultPosition, wxSize(-1, 150), 0, item6Strings, wxLB_SINGLE|wxLB_SORT);
item3->Add(item6, 1, wxGROW|wxALL, 5);
wxStaticText* item7 = new wxStaticText(item1, wxID_STATIC, _("&List of configuration items:"), wxDefaultPosition, wxDefaultSize, 0);
item3->Add(item7, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
wxBoxSizer* item8 = new wxBoxSizer(wxHORIZONTAL);
item3->Add(item8, 0, wxGROW, 5);
wxString* item9Strings = NULL;
wxListBox* item9 = new wxListBox(item1, ID_CONFIG_ITEMS, wxDefaultPosition, wxSize(-1, 100), 0, item9Strings, wxLB_SINGLE);
item8->Add(item9, 1, wxGROW|wxALL, 5);
wxBoxSizer* item10 = new wxBoxSizer(wxVERTICAL);
item8->Add(item10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* item11 = new wxButton(item1, ID_CONFIG_ADD, _("A&dd"), wxDefaultPosition, wxDefaultSize, 0);
item10->Add(item11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxButton* item12 = new wxButton(item1, ID_CONFIG_REMOVE, _("&Remove"), wxDefaultPosition, wxDefaultSize, 0);
item10->Add(item12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxBoxSizer* item13 = new wxBoxSizer(wxHORIZONTAL);
item3->Add(item13, 0, wxGROW, 5);
item13->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* item15 = new wxButton(item1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0);
item15->SetDefault();
item13->Add(item15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* item16 = new wxButton(item1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0);
item13->Add(item16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
Centre();
////@end ctConfigItemsSelector content construction
}
/*!
* Event handler for ID_CONFIG_ADD
*/
void ctConfigItemsSelector::OnConfigAdd( wxCommandEvent& event )
{
wxListBox* masterList = wxDynamicCast(FindWindow(ID_AVAILABLE_CONFIG_ITEMS), wxListBox);
wxListBox* listBox = wxDynamicCast(FindWindow(ID_CONFIG_ITEMS), wxListBox);
if (masterList)
{
if (masterList->GetSelection() > -1)
{
wxString str = masterList->GetStringSelection();
if (m_configItems.Index(str) == wxNOT_FOUND)
{
listBox->Append(str);
m_configItems.Add(str);
}
}
}
}
/*!
* Event handler for ID_CONFIG_REMOVE
*/
void ctConfigItemsSelector::OnConfigRemove( wxCommandEvent& event )
{
wxListBox* listBox = wxDynamicCast(FindWindow(ID_CONFIG_ITEMS), wxListBox);
if (listBox)
{
if (listBox->GetSelection() > -1)
{
wxString str = listBox->GetStringSelection();
listBox->Delete(listBox->GetSelection());
m_configItems.Remove(str);
}
}
}
/*!
* Event handler for wxID_OK
*/
void ctConfigItemsSelector::OnOk( wxCommandEvent& event )
{
// Replace with custom code
event.Skip();
}
/*!
* Should we show tooltips?
*/
bool ctConfigItemsSelector::ShowToolTips()
{
return TRUE;
}
/*!
* Update event handler for ID_CONFIG_ADD
*/
void ctConfigItemsSelector::OnUpdateConfigAdd( wxUpdateUIEvent& event )
{
wxListBox* masterList = wxDynamicCast(FindWindow(ID_AVAILABLE_CONFIG_ITEMS), wxListBox);
event.Enable(masterList && masterList->GetSelection() != -1);
}
/*!
* Update event handler for ID_CONFIG_REMOVE
*/
void ctConfigItemsSelector::OnUpdateConfigRemove( wxUpdateUIEvent& event )
{
wxListBox* listBox = wxDynamicCast(FindWindow(ID_CONFIG_ITEMS), wxListBox);
event.Enable(listBox && listBox->GetSelection() != -1);
}
/// Initialise the master list
void ctConfigItemsSelector::InitSourceConfigList(ctConfigItem* item)
{
wxListBox* masterList = wxDynamicCast(FindWindow(ID_AVAILABLE_CONFIG_ITEMS), wxListBox);
if (!item)
item = wxGetApp().GetMainFrame()->GetDocument()->GetTopItem();
if (!item)
return;
bool addIt = FALSE;
if (item->GetType() == ctTypeGroup)
addIt = FALSE;
else if (item->GetType() == ctTypeCheckGroup)
addIt = TRUE;
else if (item->GetType() == ctTypeRadioGroup)
addIt = TRUE;
else if (item->GetType() == ctTypeString)
addIt = TRUE;
else if (item->GetType() == ctTypeBoolCheck)
addIt = TRUE;
else if (item->GetType() == ctTypeBoolRadio)
addIt = TRUE;
else if (item->GetType() == ctTypeInteger)
addIt = TRUE;
if (addIt)
{
masterList->Append(item->GetName());
}
wxNode* node = item->GetChildren().GetFirst();
while (node)
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
InitSourceConfigList(child);
node = node->Next();
}
}
/// Set the initial list
void ctConfigItemsSelector::SetConfigList(const wxArrayString& items)
{
m_configItems = items;
wxListBox* listBox = wxDynamicCast(FindWindow(ID_CONFIG_ITEMS), wxListBox);
listBox->Clear();
size_t i;
for (i = 0; i < items.GetCount(); i++)
listBox->Append(items[i]);
}

View File

@@ -0,0 +1,104 @@
/////////////////////////////////////////////////////////////////////////////
// Name: configitemselector.h
// Purpose: Selector for one or more config items
// Author: Julian Smart
// Modified by:
// Created: 2003-06-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _CONFIGITEMSELECTOR_H_
#define _CONFIGITEMSELECTOR_H_
#ifdef __GNUG__
#pragma interface configitemselector.h
#endif
/*!
* Includes
*/
////@begin includes
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
#define ID_DIALOG 10000
#define ID_AVAILABLE_CONFIG_ITEMS 10002
#define ID_CONFIG_ITEMS 10005
#define ID_CONFIG_ADD 10006
#define ID_CONFIG_REMOVE 10007
////@end control identifiers
class ctConfigItem;
/*!
* ctConfigItemsSelector class declaration
*/
class ctConfigItemsSelector: public wxDialog
{
public:
/// Constructor
ctConfigItemsSelector( wxWindow* parent, wxWindowID id = -1, const wxString& caption = _("Configuration Items Selector"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU );
/// Creates the controls and sizers
void CreateControls();
////@begin ctConfigItemsSelector event handler declarations
/// Event handler for ID_CONFIG_ADD
void OnConfigAdd( wxCommandEvent& event );
/// Update event handler for ID_CONFIG_ADD
void OnUpdateConfigAdd( wxUpdateUIEvent& event );
/// Event handler for ID_CONFIG_REMOVE
void OnConfigRemove( wxCommandEvent& event );
/// Update event handler for ID_CONFIG_REMOVE
void OnUpdateConfigRemove( wxUpdateUIEvent& event );
/// Event handler for wxID_OK
void OnOk( wxCommandEvent& event );
////@end ctConfigItemsSelector event handler declarations
////@begin ctConfigItemsSelector member function declarations
////@end ctConfigItemsSelector member function declarations
/// Initialise the master list
void InitSourceConfigList(ctConfigItem* item = NULL);
/// Set the initial list
void SetConfigList(const wxArrayString& items);
/// Get the list
const wxArrayString& GetConfigList() const { return m_configItems; }
/// Should we show tooltips?
static bool ShowToolTips();
DECLARE_CLASS( ctConfigItemsSelector )
DECLARE_EVENT_TABLE()
protected:
wxArrayString m_configItems;
};
#endif
// _CONFIGITEMSELECTOR_H_

View File

@@ -0,0 +1,992 @@
/////////////////////////////////////////////////////////////////////////////
// Name: configtooldoc.h
// Purpose: Document class
// Author: Julian Smart
// Modified by:
// Created: 2003-06-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "configtooldoc.h"
#endif
#include "wx/wx.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/config.h"
#include "wx/textfile.h"
#include "wx/process.h"
#include "wx/mimetype.h"
#include "wx/process.h"
#include "wx/wfstream.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "configtooldoc.h"
#include "configtoolview.h"
#include "configtree.h"
#include "mainframe.h"
#include "utils.h"
#include "wxconfigtool.h"
#include "htmlparser.h"
IMPLEMENT_DYNAMIC_CLASS(ctConfigToolDoc, wxDocument)
// Ctor
ctConfigToolDoc::ctConfigToolDoc()
{
m_topItem = NULL;
m_clipboardItem = NULL;
}
// Dtor
ctConfigToolDoc::~ctConfigToolDoc()
{
DeleteItems();
ClearClipboard();
if (GetCommandProcessor())
GetCommandProcessor()->SetEditMenu(NULL);
}
// Delete all the items not already deleted
void ctConfigToolDoc::DeleteItems()
{
if (m_topItem)
delete m_topItem;
m_topItem = NULL;
}
/// Clears the clipboard item.
void ctConfigToolDoc::ClearClipboard()
{
if (m_clipboardItem)
delete m_clipboardItem;
m_clipboardItem = NULL;
}
/// Sets the clipboard item.
void ctConfigToolDoc::SetClipboardItem(ctConfigItem* item)
{
if (m_clipboardItem)
delete m_clipboardItem;
m_clipboardItem = item;
}
// Closes and clears the document
bool ctConfigToolDoc::OnCloseDocument()
{
if (wxDocument::OnCloseDocument())
{
ctConfigToolHint hint(NULL, ctClear);
UpdateAllViews (NULL, & hint);
DeleteItems();
return TRUE;
}
else
{
return FALSE;
}
}
// Saves the doc
bool ctConfigToolDoc::Save()
{
bool ret = FALSE;
if (!IsModified() && m_savedYet) return TRUE;
if (m_documentFile == wxT("") || !m_savedYet)
ret = SaveAs();
else
ret = OnSaveDocument(m_documentFile);
if ( ret )
SetDocumentSaved(TRUE);
return ret;
}
// Create the document
bool ctConfigToolDoc::OnCreate(const wxString& path, long flags)
{
GetCommandProcessor()->SetEditMenu(wxGetApp().GetMainFrame()->GetEditMenu());
GetCommandProcessor()->Initialize();
GetCommandProcessor()->ClearCommands();
// wxGetApp().m_currentDoc = this;
if (flags & wxDOC_NEW)
{
ctConfigItem* rootItem = new ctConfigItem(NULL, ctTypeGroup, _T("Configuration"));
//rootItem->InitProperties();
rootItem->GetProperties().AddProperty(
new ctProperty(
wxT("The item description."),
wxVariant(wxT(""), wxT("description")),
wxT("multiline")));
rootItem->SetPropertyString(_T("description"),
_T("<B>This is the top-level configuration item.</B>"));
SetTopItem(rootItem);
Modify(FALSE);
SetDocumentSaved(FALSE);
wxString rootName(wxT("untitled"));
wxStripExtension(rootName);
SetFilename(wxGetApp().GetSettings().GenerateFilename(rootName));
}
// Creates the view, so do any view updating after this
bool success = wxDocument::OnCreate(path, flags);
if (success)
{
if (flags & wxDOC_NEW)
{
wxBusyCursor wait;
ctConfigToolHint hint(NULL, ctInitialUpdate);
UpdateAllViews (NULL, & hint);
SetFilename(GetFilename(), TRUE);
}
}
return success;
}
// Save the document
bool ctConfigToolDoc::OnSaveDocument(const wxString& filename)
{
wxBusyCursor cursor;
const wxString strOldPath(GetFilename());
// Do some backing up first
// This is the backup filename
wxString backupFilename(filename);
backupFilename += wxT(".bak");
// This is the temporary copy of the backup
wxString tempFilename(filename);
tempFilename += wxT(".tmp");
if (wxFileExists(tempFilename))
wxRemoveFile(tempFilename);
bool leaveBackup = TRUE;
bool saved = DoSave(tempFilename);
if (saved)
{
// Remove the old .bak file
if (wxFileExists(backupFilename))
{
wxRemoveFile(backupFilename);
}
// Copy the old file to the .bak
if (leaveBackup)
{
if (wxFileExists(filename))
{
if (!wxRenameFile(filename, backupFilename))
{
wxCopyFile(filename, backupFilename);
wxRemoveFile(filename);
}
}
}
else
{
if (wxFileExists(filename))
wxRemoveFile(filename);
}
// Finally, copy the temporary file to the proper filename
if (!wxRenameFile(tempFilename, filename))
{
wxCopyFile(tempFilename, filename);
wxRemoveFile(tempFilename);
}
Modify(FALSE);
((ctConfigToolView*)GetFirstView())->OnChangeFilename();
SetDocumentSaved(TRUE);
SetFilename(filename);
wxGetApp().GetSettings().m_lastFilename = filename;
} else
{
SetFilename(strOldPath);
}
wxGetApp().GetMainFrame()->UpdateFrameTitle();
return saved;
}
// Open the document
bool ctConfigToolDoc::OnOpenDocument(const wxString& filename)
{
wxBusyCursor cursor;
bool opened = DoOpen(filename);
if (opened)
{
SetFilename(filename);
wxGetApp().GetSettings().m_lastFilename = filename;
((ctConfigToolView*)GetFirstView())->OnChangeFilename();
RefreshDependencies();
// ctConfigToolHint hint(NULL, ctFilenameChanged);
ctConfigToolHint hint(NULL, ctInitialUpdate);
UpdateAllViews (NULL, & hint);
}
SetDocumentSaved(TRUE); // Necessary or it will pop up the Save As dialog
return opened;
}
/// Save the settings file
bool ctConfigToolDoc::DoSave(const wxString& filename)
{
wxFileOutputStream stream(filename);
if (!stream.Ok())
return FALSE;
stream << wxT("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
stream << wxT("<settings xmlns=\"http://www.wxwindows.org/wxs\" version=\"2.5.0.1\">");
DoSave(m_topItem, stream, 1);
stream << wxT("\n</settings>\n");
return TRUE;
}
inline static void OutputIndentation(wxOutputStream& stream, int indent)
{
wxString str = wxT("\n");
for (int i = 0; i < indent; i++)
str << wxT(' ') << wxT(' ');
stream << str ;
}
/// Recursive helper function for file saving
bool ctConfigToolDoc::DoSave(ctConfigItem* item, wxOutputStream& stream, int indent)
{
OutputIndentation(stream, indent*2);
wxString name(item->GetName());
wxString s;
wxString typeStr;
if (item->GetType() == ctTypeGroup)
typeStr = wxT("group");
else if (item->GetType() == ctTypeCheckGroup)
typeStr = wxT("check-group");
else if (item->GetType() == ctTypeRadioGroup)
typeStr = wxT("radio-group");
else if (item->GetType() == ctTypeString)
typeStr = wxT("string");
else if (item->GetType() == ctTypeBoolCheck)
typeStr = wxT("bool-check");
else if (item->GetType() == ctTypeBoolRadio)
typeStr = wxT("bool-radio");
else if (item->GetType() == ctTypeInteger)
typeStr = wxT("integer");
else
typeStr = wxT("unknown");
stream << wxT("<setting type=\"") << typeStr << wxT("\">");
indent ++;
OutputIndentation(stream, indent*2);
if (item->IsActive())
stream << wxT("<active>1</active>");
else
stream << wxT("<active>0</active>");
OutputIndentation(stream, indent*2);
if (item->IsEnabled())
stream << wxT("<enabled>1</enabled>");
else
stream << wxT("<enabled>0</enabled>");
// Output properties
wxNode* node = item->GetProperties().GetList().GetFirst();
while (node)
{
ctProperty* prop = (ctProperty*) node->GetData();
OutputIndentation(stream, indent*2);
stream << wxT("<") << prop->GetName() ;
if (prop->IsCustom())
{
stream << wxT(" custom=\"true\"");
stream << wxT(" type=\"") << prop->GetVariant().GetType() << wxT("\"");
stream << wxT(" editor-type=\"") << prop->GetEditorType() << wxT("\"");
stream << wxT(" description=\"") << prop->GetDescription() << wxT("\"");
if (prop->GetChoices().GetCount() > 0)
{
wxString choices;
ctConfigItem::ArrayToString(prop->GetChoices(), choices);
stream << wxT(" choices=\"") << choices << wxT("\"");
}
}
stream << wxT(">");
stream << ctEscapeHTMLCharacters(prop->GetVariant().GetString()) ;
stream << wxT("</") << prop->GetName() << wxT(">");
node = node->Next();
}
// Output children
node = item->GetChildren().GetFirst();
while (node)
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
DoSave(child, stream, indent);
node = node->Next();
}
indent --;
OutputIndentation(stream, indent*2);
stream << wxT("</setting>");
return TRUE;
}
/// Open the settings file
bool ctConfigToolDoc::DoOpen(const wxString& filename)
{
wxSimpleHtmlParser parser;
if (parser.ParseFile(filename))
{
ctConfigToolHint hint(NULL, ctClear);
UpdateAllViews (NULL, & hint);
m_topItem = NULL;
if (parser.GetTopLevelTag()->GetChildren())
{
wxSimpleHtmlTag* settingsTag = parser.GetTopLevelTag()->GetChildren()->FindTag(wxT("settings"));
if (settingsTag && settingsTag->GetChildren())
{
wxSimpleHtmlTag* firstSettingTag = settingsTag->GetChildren();
if (firstSettingTag)
DoOpen(firstSettingTag, NULL);
return TRUE;
}
return TRUE;
}
}
return FALSE;
}
static bool GetHtmlBoolValue(const wxString& value)
{
if (value == wxT("true") || value == wxT("TRUE") || value == wxT("1"))
return TRUE;
else
return FALSE;
}
static int GetHtmlIntegerValue(const wxString& value)
{
return wxAtoi(value);
}
static double GetHtmlDoubleValue(const wxString& value)
{
return wxAtof(value);
}
bool ctConfigToolDoc::DoOpen(wxSimpleHtmlTag* tag, ctConfigItem* parent)
{
ctConfigItem* newItem = NULL;
if (tag->NameIs(wxT("setting")))
{
wxSimpleHtmlAttribute* attr = tag->FindAttribute(wxT("type"));
if (attr)
{
ctConfigType type = ctTypeUnknown;
wxString typeStr(attr->GetValue());
if (typeStr == wxT("group"))
type = ctTypeGroup;
else if (typeStr == wxT("option-group") || typeStr == wxT("check-group"))
type = ctTypeCheckGroup;
else if (typeStr == wxT("radio-group"))
type = ctTypeRadioGroup;
else if (typeStr == wxT("bool-check"))
type = ctTypeBoolCheck;
else if (typeStr == wxT("bool-radio"))
type = ctTypeBoolRadio;
else if (typeStr == wxT("string"))
type = ctTypeString;
else if (typeStr == wxT("integer"))
type = ctTypeInteger;
else
{
wxLogError(wxT("Unknown type %s"), (const wxChar*) typeStr);
}
if (type != ctTypeUnknown)
{
newItem = new ctConfigItem(parent, type, wxT(""));
newItem->InitProperties();
if (!parent)
SetTopItem(newItem);
}
}
}
wxSimpleHtmlTag* childTag = tag->GetChildren();
while (childTag)
{
if (childTag->GetType() == wxSimpleHtmlTag_Open)
{
if (childTag->GetName() == wxT("setting"))
{
DoOpen(childTag, newItem);
}
else if (childTag->GetName() == wxT("name"))
{
if (newItem)
{
wxString name(childTag->GetNext()->GetTagText());
newItem->SetName(name);
}
}
else if (childTag->GetName() == wxT("active"))
{
if (newItem)
newItem->SetActive(GetHtmlBoolValue(childTag->GetNext()->GetTagText()));
}
else if (childTag->GetName() == wxT("enabled"))
{
if (newItem)
newItem->Enable(GetHtmlBoolValue(childTag->GetNext()->GetTagText()));
}
else
{
if (newItem)
{
ctProperty* prop = newItem->GetProperties().FindProperty(childTag->GetName());
if (!prop)
{
// A custom property, else an obsolete
// property that we should ignore.
wxString isCustom;
if (childTag->GetAttributeValue(isCustom, wxT("custom")) &&
isCustom == wxT("true"))
{
prop = new ctProperty;
wxString name(childTag->GetName());
wxString type(wxT("string"));
wxString choices;
wxString editorType(wxT("string"));
wxString description(wxT(""));
childTag->GetAttributeValue(type, wxT("type"));
childTag->GetAttributeValue(type, wxT("editor-type"));
childTag->GetAttributeValue(type, wxT("choices"));
childTag->GetAttributeValue(description, wxT("description"));
if (type == wxT("bool"))
prop->GetVariant() = wxVariant((bool) FALSE, name);
else if (type == wxT("double"))
prop->GetVariant() = wxVariant((double) 0.0, name);
else if (type == wxT("long"))
prop->GetVariant() = wxVariant((long) 0, name);
else
prop->GetVariant() = wxVariant(wxT(""), name);
prop->SetDescription(description);
prop->SetCustom(TRUE);
prop->SetEditorType(editorType);
if (!choices.IsEmpty())
{
wxArrayString arr;
ctConfigItem::StringToArray(choices, arr);
prop->SetChoices(arr);
}
newItem->GetProperties().AddProperty(prop);
}
}
if (prop)
{
if (prop->GetVariant().GetType() == wxT("string"))
prop->GetVariant() = childTag->GetNext()->GetTagText();
else if (prop->GetVariant().GetType() == wxT("long"))
prop->GetVariant() = (long) GetHtmlIntegerValue(childTag->GetNext()->GetTagText());
else if (prop->GetVariant().GetType() == wxT("bool"))
prop->GetVariant() = (bool) GetHtmlBoolValue(childTag->GetNext()->GetTagText());
else if (prop->GetVariant().GetType() == wxT("double"))
prop->GetVariant() = (double) GetHtmlDoubleValue(childTag->GetNext()->GetTagText());
}
}
}
}
childTag = childTag->GetNext();
}
return TRUE;
}
/// Clear dependencies
void ctConfigToolDoc::ClearDependencies(ctConfigItem* item)
{
if (!item)
item = GetTopItem();
item->GetDependents().Clear();
for ( wxNode* node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
ClearDependencies(child);
}
}
/// Refresh dependencies
void ctConfigToolDoc::RefreshDependencies()
{
ClearDependencies(GetTopItem());
RefreshDependencies(GetTopItem());
}
/// Refresh dependencies
void ctConfigToolDoc::RefreshDependencies(ctConfigItem* item)
{
wxArrayString requiresArr;
wxString requires = item->GetPropertyString(wxT("requires"));
wxString precludes = item->GetPropertyString(wxT("precludes"));
wxString enabledIf = item->GetPropertyString(wxT("enabled-if"));
wxString enabledIfNot = item->GetPropertyString(wxT("enabled-if-not"));
wxString context = item->GetPropertyString(wxT("context"));
if (!requires.IsEmpty())
item->StringToArray(requires, requiresArr);
if (!precludes.IsEmpty())
item->StringToArray(precludes, requiresArr);
if (!enabledIfNot.IsEmpty())
item->StringToArray(enabledIfNot, requiresArr);
if (!enabledIf.IsEmpty())
item->StringToArray(enabledIf, requiresArr);
// Add the parent to the list of dependencies, if the
// parent is a check or radio group.
ctConfigItem* parent = item->GetParent();
if (parent &&
(parent->GetType() == ctTypeCheckGroup ||
parent->GetType() == ctTypeRadioGroup))
requiresArr.Add(parent->GetName());
// Also look in 'context' since these items
// are another kind of dependency (switching to
// a different platform may cause the dependencies
// to be evaluated differently).
if (!context.IsEmpty())
item->StringToArray(context, requiresArr);
size_t i;
for (i = 0; i < requiresArr.GetCount(); i++)
{
wxString itemName(requiresArr[i]);
ctConfigItem* otherItem = GetTopItem()->FindItem(itemName);
if (otherItem && !otherItem->GetDependents().Member(item))
{
otherItem->GetDependents().Append(item);
}
}
for ( wxNode* node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
RefreshDependencies(child);
}
}
/// Generate the text of a setup.h
wxString ctConfigToolDoc::GenerateSetup()
{
wxString str;
str << wxT("/*\n * setup.h\n * Generated by wxConfigTool\n *\n */\n\n");
GenerateSetup(GetTopItem(), str);
return str;
}
/// Helper function
void ctConfigToolDoc::GenerateSetup(ctConfigItem* item, wxString& str)
{
// Generate the setup.h entries for this item
wxString name = item->GetName();
// We don't process the platform choice
if (item->GetName() == wxT("Platform"))
return;
if (item->IsInActiveContext() &&
(item->GetType() == ctTypeCheckGroup ||
item->GetType() == ctTypeRadioGroup ||
item->GetType() == ctTypeBoolCheck ||
item->GetType() == ctTypeBoolRadio))
{
// TODO: write description
wxString name = item->GetName();
if (name.Left(6) == wxT("wxUSE_") ||
name == wxT("REMOVE_UNUSED_ARG") || // Hack alert: change to wxUSE_UNUSED_ARG_REMOVAL
name.Find(wxT("COMPATIBILITY")) != wxNOT_FOUND)
{
str << wxT("#define ") << name ;
if (item->IsEnabled())
str << wxT(" 1");
else
str << wxT(" 0");
str << wxT("\n\n");
}
}
for ( wxNode* node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
GenerateSetup(child, str);
}
}
/// Generate a configure command
wxString ctConfigToolDoc::GenerateConfigureCommand()
{
wxString str;
str << wxT("# configurewx\n# Generated by wxConfigTool\n\n");
wxString path = GetFrameworkDir(TRUE);
bool makeUnix = TRUE;
if (!path.IsEmpty())
{
if (makeUnix)
path += wxT("/");
else
path += wxFILE_SEP_PATH ;
}
str << path << wxT("configure");
// Find the platform option to use
ctConfigItem* platformsFolder = GetTopItem()->FindItem(wxT("Platform"));
if (platformsFolder)
{
for ( wxNode* node = platformsFolder->GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
if (child->GetType() == ctTypeBoolRadio && child->IsEnabled())
{
wxString configureCommand = child->GetPropertyString(wxT("configure-command"));
if (!configureCommand.IsEmpty())
str << wxT(" ") << configureCommand;
}
}
}
GenerateConfigureCommand(GetTopItem(), str);
return str;
}
/// Helper function
void ctConfigToolDoc::GenerateConfigureCommand(ctConfigItem* item, wxString& str)
{
// We don't process the platform group, since we've
// already done so.
if (item->GetName() == wxT("Platform"))
return;
if (item->IsInActiveContext() &&
(item->GetType() == ctTypeCheckGroup ||
item->GetType() == ctTypeRadioGroup ||
item->GetType() == ctTypeBoolCheck ||
item->GetType() == ctTypeBoolRadio))
{
wxString name = item->GetName();
wxString configureCommand = item->GetPropertyString(wxT("configure-command"));
if (!configureCommand.IsEmpty())
{
if (!item->IsEnabled())
{
// Replace 'enable' with 'disable' if this
// option is off.
configureCommand.Replace(wxT("--enable-"), wxT("--disable-"));
configureCommand.Replace(wxT("--with-"), wxT("--without-"));
}
ctProperty* prop = item->GetProperties().FindProperty(wxT("builtin"));
if (prop && prop->GetVariant().GetType() == wxT("bool"))
{
bool builtin = prop->GetVariant().GetBool();
str << wxT(" ") << configureCommand;
if (builtin)
str << wxT("=builtin");
else
str << wxT("=sys");
}
else
{
ctProperty* prop = item->GetProperties().FindProperty(wxT("value"));
if (prop && prop->GetVariant().GetType() == wxT("string"))
{
wxString val = prop->GetVariant().GetString();
if (item->IsEnabled() && !val.IsEmpty())
{
str << wxT(" ") << configureCommand;
str << wxT("=\"") << val << wxT("\"");
}
// If the string is empty, ignore this parameter,
// since it's obviously intended to be supplied
// only if there's a string to use and it's enabled.
}
else
{
str << wxT(" ") << configureCommand;
}
}
}
}
for ( wxNode* node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
GenerateConfigureCommand(child, str);
}
}
/// Gets the current framework directory
wxString ctConfigToolDoc::GetFrameworkDir(bool makeUnix)
{
wxString path = wxGetApp().GetSettings().m_frameworkDir;
if (wxGetApp().GetSettings().m_useEnvironmentVariable)
{
// Should probably allow other variables
// to be used, and maybe expand variables within m_frameworkDir
path = wxGetenv(wxT("WXWIN"));
#ifdef __WXMSW__
if (makeUnix)
path.Replace(wxT("\\"), wxT("/"));
#endif
}
return path;
}
/*
* Implements a document editing command.
*/
ctConfigCommand::ctConfigCommand(const wxString& name, int cmdId,
ctConfigItem* activeState, ctConfigItem* savedState,
ctConfigItem* parent, ctConfigItem* insertBefore,
bool ignoreFirstTime): wxCommand(TRUE, name)
{
m_activeState = activeState;
m_savedState = savedState;
m_ignoreThis = ignoreFirstTime;
m_cmdId = cmdId;
m_properties = NULL;
m_parent = parent;
m_insertBefore = insertBefore;
}
ctConfigCommand::ctConfigCommand(const wxString& name, int cmdId,
ctConfigItem* activeState, ctProperties* properties,
bool ignoreFirstTime): wxCommand(TRUE, name)
{
m_activeState = activeState;
m_savedState = NULL;
m_properties = properties;
m_ignoreThis = ignoreFirstTime;
m_cmdId = cmdId;
m_properties = properties;
m_parent = NULL;
m_insertBefore = NULL;
}
ctConfigCommand::~ctConfigCommand()
{
if (m_savedState)
delete m_savedState;
if (m_properties)
delete m_properties;
}
bool ctConfigCommand::Do()
{
return DoAndUndo(TRUE);
}
bool ctConfigCommand::Undo()
{
return DoAndUndo(FALSE);
}
// Combine Do and Undo into one
bool ctConfigCommand::DoAndUndo(bool doCmd)
{
switch (m_cmdId)
{
case ctCMD_CUT:
{
if (doCmd)
{
wxASSERT(m_savedState == NULL);
wxASSERT(m_activeState != NULL);
ctConfigItem* newItem = m_activeState->DeepClone();
ctConfigToolDoc* doc = m_activeState->GetDocument();
// This will delete the old clipboard contents, if any.
doc->SetClipboardItem(newItem);
m_parent = m_activeState->GetParent();
m_insertBefore = m_activeState->FindNextSibling();
m_activeState->Detach();
m_savedState = m_activeState;
m_activeState = NULL;
m_savedState->GetDocument()->Modify(TRUE);
ctConfigToolView* view = (ctConfigToolView*) m_savedState->GetDocument()->GetFirstView();
view->OnChangeFilename();
}
else
{
wxASSERT(m_savedState != NULL);
wxASSERT(m_activeState == NULL);
m_savedState->GetDocument()->Modify(TRUE);
m_savedState->Attach(m_parent, m_insertBefore);
ctConfigToolView* view = (ctConfigToolView*) m_savedState->GetDocument()->GetFirstView();
view->AddItems(wxGetApp().GetMainFrame()->GetConfigTreeCtrl(), m_savedState);
m_activeState = m_savedState;
m_savedState = NULL;
m_parent = NULL;
m_insertBefore = NULL;
view->OnChangeFilename();
}
break;
}
case ctCMD_PASTE:
{
if (doCmd)
{
wxASSERT(m_savedState != NULL);
wxASSERT(m_activeState == NULL);
m_savedState->GetDocument()->Modify(TRUE);
m_savedState->Attach(m_parent, m_insertBefore);
ctConfigToolView* view = (ctConfigToolView*) m_savedState->GetDocument()->GetFirstView();
view->AddItems(wxGetApp().GetMainFrame()->GetConfigTreeCtrl(), m_savedState);
wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->SelectItem(m_savedState->GetTreeItemId());
m_activeState = m_savedState;
m_savedState = NULL;
view->OnChangeFilename();
}
else
{
wxASSERT(m_savedState == NULL);
wxASSERT(m_activeState != NULL);
m_activeState->GetDocument()->Modify(TRUE);
ctConfigToolView* view = (ctConfigToolView*) m_activeState->GetDocument()->GetFirstView();
m_activeState->Detach();
m_savedState = m_activeState;
m_activeState = NULL;
view->OnChangeFilename();
}
break;
}
case ctCMD_NEW_ELEMENT:
{
if (doCmd)
{
wxASSERT(m_savedState != NULL);
wxASSERT(m_activeState == NULL);
m_savedState->GetDocument()->Modify(TRUE);
m_savedState->Attach(m_parent, m_insertBefore);
ctConfigToolView* view = (ctConfigToolView*) m_savedState->GetDocument()->GetFirstView();
view->AddItems(wxGetApp().GetMainFrame()->GetConfigTreeCtrl(), m_savedState);
wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->SelectItem(m_savedState->GetTreeItemId());
m_activeState = m_savedState;
m_savedState = NULL;
}
else
{
wxASSERT(m_savedState == NULL);
wxASSERT(m_activeState != NULL);
m_activeState->GetDocument()->Modify(TRUE);
m_activeState->Detach();
m_savedState = m_activeState;
m_activeState = NULL;
}
break;
}
case ctCMD_APPLY_PROPERTY:
{
wxASSERT(m_properties != NULL);
wxASSERT(m_activeState != NULL);
// Don't update the properties editor first time
// around since it will be done one property at a time
// initially (and no property editor update required)
if (!m_ignoreThis)
{
// Just swap the saved and current properties.
ctProperties propsTemp = m_activeState->GetProperties() ;
m_activeState->GetProperties() = (* m_properties);
(* m_properties) = propsTemp;
// Apply only those that need applying
// (those properties in activeState that are not in propsTemp)
wxNode* node = m_activeState->GetProperties().GetList().GetFirst();
while (node)
{
ctProperty* prop = (ctProperty*) node->GetData();
ctProperty* otherProp = propsTemp.FindProperty(prop->GetName());
if (otherProp && ((*prop) != (*otherProp)))
{
m_activeState->ApplyProperty(prop, otherProp->GetVariant());
}
node = node->GetNext();
}
m_activeState->GetDocument()->Modify(TRUE);
ctConfigToolView* view = (ctConfigToolView*) m_activeState->GetDocument()->GetFirstView();
if (view)
{
ctConfigToolHint hint(NULL, ctValueChanged);
m_activeState->GetDocument()->UpdateAllViews (NULL, & hint);
}
}
m_ignoreThis = FALSE;
break;
}
}
return TRUE;
}

View File

@@ -0,0 +1,149 @@
/////////////////////////////////////////////////////////////////////////////
// Name: configtooldoc.h
// Purpose: Document class
// Author: Julian Smart
// Modified by:
// Created: 2003-06-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _CT_CONFIGTOOLDOC_H_
#define _CT_CONFIGTOOLDOC_H_
#ifdef __GNUG__
#pragma interface "configtooldoc.cpp"
#endif
#include "wx/docview.h"
#include "wx/cmdproc.h"
#include "configitem.h"
class wxSimpleHtmlTag;
/*!
* ctConfigToolDoc
*/
class ctConfigToolDoc: public wxDocument
{
DECLARE_DYNAMIC_CLASS(ctConfigToolDoc)
public:
ctConfigToolDoc();
~ctConfigToolDoc();
//// Overrides
virtual bool OnCreate(const wxString& path, long flags);
virtual bool OnOpenDocument(const wxString& filename);
virtual bool OnSaveDocument(const wxString& filename);
virtual bool OnNewDocument() { return TRUE; }
virtual bool OnCloseDocument() ;
virtual bool Save(); // Overridden only to correct bug in wxWindows, docview.cpp
//// Accessors
/// Returns the top item.
ctConfigItem* GetTopItem() const { return m_topItem; }
/// Sets the top item.
void SetTopItem(ctConfigItem* item) { m_topItem = item; }
/// Returns the clipboard item.
ctConfigItem* GetClipboardItem() const { return m_clipboardItem; }
/// Sets the clipboard item.
void SetClipboardItem(ctConfigItem* item) ;
/// Clears the clipboard item.
void ClearClipboard() ;
/// Gets the current framework directory
wxString GetFrameworkDir(bool makeUnix);
//// Operations
/// Add items
void AddItems();
/// Delete items
void DeleteItems();
/// Save the settings file
bool DoSave(const wxString& filename);
/// Recursive helper function for file saving
bool DoSave(ctConfigItem* item, wxOutputStream& stream, int indent);
/// Open the settings file
bool DoOpen(const wxString& filename);
/// Helper for file opening.
bool DoOpen(wxSimpleHtmlTag* tag, ctConfigItem* parent);
/// Refresh dependencies
void RefreshDependencies();
void RefreshDependencies(ctConfigItem* item);
/// Clear dependencies
void ClearDependencies(ctConfigItem* item);
/// Generate the text of a setup.h
wxString GenerateSetup();
/// Helper function
void GenerateSetup(ctConfigItem* item, wxString& str);
/// Generate a configure command
wxString GenerateConfigureCommand();
/// Helper function
void GenerateConfigureCommand(ctConfigItem* item, wxString& str);
protected:
ctConfigItem* m_topItem;
ctConfigItem* m_clipboardItem;
};
/*!
* Implements a document editing command.
* We only need to store one state at a time,
* since we don't have (or need) multiple selection.
*/
#define ctCMD_NEW_ELEMENT 1
#define ctCMD_PASTE 2
#define ctCMD_CUT 3
#define ctCMD_APPLY_PROPERTY 4
class ctConfigCommand: public wxCommand
{
public:
ctConfigCommand(const wxString& name, int cmdId,
ctConfigItem* activeState, ctConfigItem* savedState,
ctConfigItem* parent = NULL, ctConfigItem* insertBefore = NULL,
bool ignoreFirstTime = FALSE);
ctConfigCommand(const wxString& name, int cmdId,
ctConfigItem* activeState, ctProperties* properties,
bool ignoreFirstTime = FALSE);
~ctConfigCommand();
bool Do();
bool Undo();
bool DoAndUndo(bool doCmd); // Combine Do and Undo into one
protected:
ctConfigItem* m_activeState;
ctConfigItem* m_savedState;
ctProperties* m_properties;
bool m_ignoreThis; // Ignore 1st Do because we already did it
int m_cmdId;
ctConfigItem* m_parent;
ctConfigItem* m_insertBefore;
};
#endif
// _CT_CONFIGTOOLDOC_H_

View File

@@ -0,0 +1,967 @@
/////////////////////////////////////////////////////////////////////////////
// Name: configtoolview.cpp
// Purpose: View class
// Author: Julian Smart
// Modified by:
// Created: 2003-06-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "configtoolview.cpp"
#endif
// Includes other headers for precompiled compilation
#include "wx/wx.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/wfstream.h"
#include "configtoolview.h"
#include "configtooldoc.h"
#include "configtree.h"
#include "wxconfigtool.h"
#include "mainframe.h"
#include "propeditor.h"
#include "utils.h"
#include "custompropertydialog.h"
IMPLEMENT_DYNAMIC_CLASS(ctConfigToolView, wxView)
BEGIN_EVENT_TABLE(ctConfigToolView, wxView)
EVT_MENU(ctID_ADD_ITEM_CHECKBOX, ctConfigToolView::OnAddCheckBoxItem)
EVT_MENU(ctID_ADD_ITEM_RADIOBUTTON, ctConfigToolView::OnAddRadioButtonItem)
EVT_MENU(ctID_ADD_ITEM_GROUP, ctConfigToolView::OnAddGroupItem)
EVT_MENU(ctID_ADD_ITEM_CHECK_GROUP, ctConfigToolView::OnAddCheckGroupItem)
EVT_MENU(ctID_ADD_ITEM_RADIO_GROUP, ctConfigToolView::OnAddRadioGroupItem)
EVT_MENU(ctID_ADD_ITEM_STRING, ctConfigToolView::OnAddStringItem)
EVT_MENU(ctID_RENAME_ITEM, ctConfigToolView::OnRenameItem)
EVT_MENU(ctID_DELETE_ITEM, ctConfigToolView::OnDeleteItem)
EVT_MENU(wxID_COPY, ctConfigToolView::OnCopy)
EVT_MENU(wxID_CUT, ctConfigToolView::OnCut)
EVT_MENU(wxID_PASTE, ctConfigToolView::OnPaste)
EVT_UPDATE_UI(wxID_COPY, ctConfigToolView::OnUpdateCopy)
EVT_UPDATE_UI(wxID_CUT, ctConfigToolView::OnUpdateCut)
EVT_UPDATE_UI(wxID_PASTE, ctConfigToolView::OnUpdatePaste)
EVT_MENU(ctID_ITEM_HELP, ctConfigToolView::OnItemHelp)
EVT_UPDATE_UI(ctID_ADD_ITEM_CHECKBOX, ctConfigToolView::OnUpdateAddItem)
EVT_UPDATE_UI(ctID_ADD_ITEM_RADIOBUTTON, ctConfigToolView::OnUpdateAddItem)
EVT_UPDATE_UI(ctID_ADD_ITEM_GROUP, ctConfigToolView::OnUpdateAddItem)
EVT_UPDATE_UI(ctID_ADD_ITEM_CHECK_GROUP, ctConfigToolView::OnUpdateAddItem)
EVT_UPDATE_UI(ctID_ADD_ITEM_RADIO_GROUP, ctConfigToolView::OnUpdateAddItem)
EVT_UPDATE_UI(ctID_ADD_ITEM_STRING, ctConfigToolView::OnUpdateAddItem)
EVT_UPDATE_UI(ctID_RENAME_ITEM, ctConfigToolView::OnUpdateCut)
EVT_UPDATE_UI(ctID_DELETE_ITEM, ctConfigToolView::OnUpdateCut)
EVT_UPDATE_UI(ctID_ITEM_HELP, ctConfigToolView::OnUpdateItemHelp)
EVT_MENU(ctID_TREE_COPY, ctConfigToolView::OnContextCopy)
EVT_MENU(ctID_TREE_CUT, ctConfigToolView::OnContextCut)
EVT_MENU(ctID_TREE_PASTE_BEFORE, ctConfigToolView::OnContextPasteBefore)
EVT_MENU(ctID_TREE_PASTE_AFTER, ctConfigToolView::OnContextPasteAfter)
EVT_MENU(ctID_TREE_PASTE_AS_CHILD, ctConfigToolView::OnContextPasteAsChild)
EVT_UPDATE_UI(ctID_TREE_COPY, ctConfigToolView::OnUpdateContextCopy)
EVT_UPDATE_UI(ctID_TREE_CUT, ctConfigToolView::OnUpdateContextCut)
EVT_UPDATE_UI(ctID_TREE_PASTE_BEFORE, ctConfigToolView::OnUpdateContextPasteBefore)
EVT_UPDATE_UI(ctID_TREE_PASTE_AFTER, ctConfigToolView::OnUpdateContextPasteAfter)
EVT_UPDATE_UI(ctID_TREE_PASTE_AS_CHILD, ctConfigToolView::OnUpdateContextPasteAsChild)
EVT_MENU(ctID_ADD_CUSTOM_PROPERTY, ctConfigToolView::OnAddCustomProperty)
EVT_MENU(ctID_EDIT_CUSTOM_PROPERTY, ctConfigToolView::OnEditCustomProperty)
EVT_MENU(ctID_DELETE_CUSTOM_PROPERTY, ctConfigToolView::OnDeleteCustomProperty)
EVT_UPDATE_UI(ctID_ADD_CUSTOM_PROPERTY, ctConfigToolView::OnUpdateAddCustomProperty)
EVT_UPDATE_UI(ctID_EDIT_CUSTOM_PROPERTY, ctConfigToolView::OnUpdateEditCustomProperty)
EVT_UPDATE_UI(ctID_DELETE_CUSTOM_PROPERTY, ctConfigToolView::OnUpdateDeleteCustomProperty)
EVT_NOTEBOOK_PAGE_CHANGED(-1, ctConfigToolView::OnTabSelect)
EVT_MENU(ctID_SAVE_SETUP_FILE, ctConfigToolView::OnSaveSetupFile)
EVT_MENU(ctID_SAVE_CONFIGURE_COMMAND, ctConfigToolView::OnSaveConfigureCommand)
EVT_UPDATE_UI(ctID_SAVE_SETUP_FILE, ctConfigToolView::OnUpdateSaveSetupFile)
EVT_UPDATE_UI(ctID_SAVE_CONFIGURE_COMMAND, ctConfigToolView::OnUpdateSaveConfigureCommand)
END_EVENT_TABLE()
ctConfigToolView::ctConfigToolView()
{
}
// What to do when a view is created. Creates actual
// windows for displaying the view.
bool ctConfigToolView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
{
wxGetApp().GetDocManager()->ActivateView(this, TRUE);
wxGetApp().GetMainFrame()->SetDocument((ctConfigToolDoc*) doc);
wxGetApp().GetMainFrame()->GetSetupPage()->SetDocument((ctConfigToolDoc*) doc) ;
wxGetApp().GetMainFrame()->GetConfigurePage()->SetDocument((ctConfigToolDoc*) doc) ;
return TRUE;
}
void ctConfigToolView::OnDraw(wxDC *dc)
{
}
void ctConfigToolView::OnUpdate(wxView *WXUNUSED(sender), wxObject *hintObj)
{
ctConfigToolDoc* doc = wxDynamicCast(GetDocument(), ctConfigToolDoc);
ctConfigTreeCtrl* treeCtrl = wxGetApp().GetMainFrame()->GetConfigTreeCtrl();
if (!treeCtrl)
return;
wxASSERT (doc != NULL);
ctConfigItem* selItem = NULL;
wxTreeItemId sel = treeCtrl->GetSelection();
if (sel.IsOk())
{
ctTreeItemData* data = (ctTreeItemData*) treeCtrl->GetItemData(sel);
if (data)
selItem = data->GetConfigItem() ;
}
ctConfigToolHint* hint = (ctConfigToolHint*) hintObj;
int hintOp = ctNoHint;
if (hint)
hintOp = hint->m_op;
switch (hintOp)
{
case ctInitialUpdate:
{
if (doc && doc->GetTopItem())
{
wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->DeleteAllItems();
AddItems(wxGetApp().GetMainFrame()->GetConfigTreeCtrl(), doc->GetTopItem());
wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->Expand(doc->GetTopItem()->GetTreeItemId());
}
}
break;
case ctSelChanged:
{
if (selItem)
{
wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(selItem);
}
}
break;
case ctAllSaved:
{
// TODO: update windows and frame title
}
break;
case ctFilenameChanged:
{
wxGetApp().GetMainFrame()->UpdateFrameTitle();
}
break;
case ctClear:
{
// TODO: update windows
treeCtrl->DeleteAllItems();
wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(NULL);
break;
}
case ctValueChanged:
{
// ctConfigItem& ti = *(ctConfigItem *)hint->m_item;
wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(selItem);
}
break;
default:
break;
}
}
// Clean up windows used for displaying the view.
bool ctConfigToolView::OnClose(bool deleteWindow)
{
if (!GetDocument()->Close())
return FALSE;
ctConfigToolHint hint(NULL, ctClear);
GetDocument()->UpdateAllViews (NULL, & hint);
wxGetApp().GetDocManager()->ActivateView(this, FALSE);
Activate(FALSE);
wxGetApp().GetMainFrame()->SetDocument(NULL);
wxGetApp().GetMainFrame()->GetSetupPage()->SetDocument(NULL) ;
wxGetApp().GetMainFrame()->GetConfigurePage()->SetDocument(NULL) ;
return TRUE;
}
void ctConfigToolView::OnChangeFilename()
{
if (wxGetApp().GetTopWindow() && GetDocument())
{
wxString docTitle(wxFileNameFromPath(GetDocument()->GetFilename()));
wxStripExtension(docTitle);
GetDocument()->SetTitle(docTitle);
wxString name(GetDocument()->GetFilename());
wxStripExtension(name);
wxString title;
wxString modifiedMarker;
if (GetDocument()->IsModified())
modifiedMarker = wxT("*");
title = docTitle + modifiedMarker + wxString(wxT(" - ")) + wxGetApp().GetSettings().GetAppName() ;
((wxFrame*) wxGetApp().GetTopWindow())->SetTitle(title);
}
}
// General disabler
void ctConfigToolView::OnUpdateDisable(wxUpdateUIEvent& event)
{
event.Enable( FALSE );
}
void ctConfigToolView::OnUpdateAddItem(wxUpdateUIEvent& event)
{
event.Enable( TRUE );
}
/// Add item and its children to the tree
void ctConfigToolView::AddItems(ctConfigTreeCtrl* treeControl, ctConfigItem* item)
{
SyncItem(treeControl, item);
int count = item->GetChildCount();
int i;
for (i = 0; i < count; i++)
{
ctConfigItem* child = item->GetChild(i);
AddItems(treeControl, child);
}
}
/// Gets the tree item in sync with the item
void ctConfigToolView::SyncItem(ctConfigTreeCtrl* treeControl, ctConfigItem* item)
{
if (!item->GetTreeItemId().IsOk())
{
if (!item->GetParent())
{
item->SetTreeItem(treeControl->AddRoot(_(""), -1, -1, new ctTreeItemData(item)));
}
else
{
// Find the item to insert the new item after.
ctConfigItem* previousItem = item->FindPreviousSibling();
if (previousItem && previousItem->GetTreeItemId().IsOk())
{
item->SetTreeItem(treeControl->InsertItem(item->GetParent()->GetTreeItemId(),
previousItem->GetTreeItemId(),
item->GetName(), -1, -1, new ctTreeItemData(item)));
}
else if (!previousItem && item->GetParent()->GetChildCount() > 1
)
{
// Insert at the beginning
item->SetTreeItem(treeControl->InsertItem(item->GetParent()->GetTreeItemId(),
(size_t) 0, // Insert at first position
item->GetName(), -1, -1, new ctTreeItemData(item)));
}
else
{
item->SetTreeItem(treeControl->AppendItem(item->GetParent()->GetTreeItemId(),
item->GetName(), -1, -1, new ctTreeItemData(item)));
}
}
}
if (item->GetTreeItemId().IsOk())
{
treeControl->SetItemText(item->GetTreeItemId(), item->GetName());
int iconId = 0;
if (item->GetType() == ctTypeGroup)
{
iconId = treeControl->GetIconTable().GetIconId(wxT("Group"), 0, item->IsActive());
}
else if (item->GetType() == ctTypeCheckGroup)
{
iconId = treeControl->GetIconTable().GetIconId(wxT("CheckGroup"), item->IsEnabled() ? 0 : 1, item->IsActive());
}
else if (item->GetType() == ctTypeRadioGroup)
{
iconId = treeControl->GetIconTable().GetIconId(wxT("RadioGroup"), item->IsEnabled() ? 0 : 1, item->IsActive());
}
else if (item->GetType() == ctTypeBoolCheck)
{
iconId = treeControl->GetIconTable().GetIconId(wxT("Checkbox"), item->IsEnabled() ? 0 : 1, item->IsActive());
}
else if (item->GetType() == ctTypeBoolRadio)
{
iconId = treeControl->GetIconTable().GetIconId(wxT("Radiobutton"), item->IsEnabled() ? 0 : 1, item->IsActive());
}
treeControl->SetItemImage(item->GetTreeItemId(), iconId, wxTreeItemIcon_Normal);
treeControl->SetItemImage(item->GetTreeItemId(), iconId, wxTreeItemIcon_Selected);
if (treeControl->GetSelection() == item->GetTreeItemId())
{
if (wxGetApp().GetMainFrame()->GetPropertyEditor()->GetItem())
wxGetApp().GetMainFrame()->GetPropertyEditor()->UpdateTitle();
}
}
}
/// Clicked an icon
void ctConfigToolView::OnIconLeftDown(ctConfigTreeCtrl* treeControl, ctConfigItem* item)
{
if (!item->IsActive())
return;
if (item->GetType() == ctTypeCheckGroup ||
item->GetType() == ctTypeBoolCheck ||
item->GetType() == ctTypeBoolRadio ||
item->GetType() == ctTypeRadioGroup
)
{
// Don't toggle a radio button that's already
// enabled.
if ((item->GetType() == ctTypeBoolRadio || item->GetType() == ctTypeRadioGroup)
&& item->IsEnabled())
return;
item->Enable(!item->IsEnabled());
GetDocument()->Modify(TRUE);
OnChangeFilename();
SyncItem(treeControl, item);
wxList considered;
item->PropagateChange(considered);
if ((item->GetType() == ctTypeBoolRadio || item->GetType() == ctTypeRadioGroup) && item->IsEnabled())
{
item->PropagateRadioButton(considered);
}
}
}
/// Returns the selected config item, if any.
ctConfigItem* ctConfigToolView::GetSelection()
{
wxTreeCtrl* treeCtrl = wxGetApp().GetMainFrame()->GetConfigTreeCtrl();
if (!treeCtrl)
return NULL;
wxTreeItemId sel = treeCtrl->GetSelection();
if (sel.IsOk())
{
ctTreeItemData* data = (ctTreeItemData*) treeCtrl->GetItemData(sel);
if (data)
return data->GetConfigItem() ;
}
return NULL;
}
/// Add a checkbox item
void ctConfigToolView::OnAddCheckBoxItem(wxCommandEvent& event)
{
AddItem(ctTypeBoolCheck, _("New checkbox item"));
}
/// Add a radiobutton item
void ctConfigToolView::OnAddRadioButtonItem(wxCommandEvent& event)
{
AddItem(ctTypeBoolRadio, _("New radio button item"));
}
/// Add a group item
void ctConfigToolView::OnAddGroupItem(wxCommandEvent& event)
{
AddItem(ctTypeGroup, _("New group item"));
}
/// Add a group option item
void ctConfigToolView::OnAddCheckGroupItem(wxCommandEvent& event)
{
AddItem(ctTypeCheckGroup, _("New check group item"));
}
/// Add a group option item
void ctConfigToolView::OnAddRadioGroupItem(wxCommandEvent& event)
{
AddItem(ctTypeRadioGroup, _("New radio group item"));
}
/// Add a string item
void ctConfigToolView::OnAddStringItem(wxCommandEvent& event)
{
AddItem(ctTypeString, _("New string item"));
}
/// Add an item
void ctConfigToolView::AddItem(ctConfigType type, const wxString& msg)
{
ctConfigItem* sel = GetSelection();
if (sel)
{
wxString name = wxGetTextFromUser(_("Please enter a name for the new item."),
msg, wxT(""));
if (!name.IsEmpty())
{
ctConfigItem* parent ;
ctConfigItem* insertBefore ;
if (sel->CanHaveChildren())
{
parent = sel;
insertBefore = NULL;
}
else
{
parent = sel->GetParent();
insertBefore = sel->FindNextSibling();
}
ctConfigItem* newItem = new ctConfigItem(NULL, type, name);
newItem->InitProperties();
newItem->GetDocument()->GetCommandProcessor()->Submit(
new ctConfigCommand(msg, ctCMD_NEW_ELEMENT, NULL, newItem,
parent, insertBefore));
}
}
}
/// Delete an item
void ctConfigToolView::OnDeleteItem(wxCommandEvent& event)
{
ctConfigItem* sel = GetSelection();
if (sel)
{
wxString msg;
msg.Printf(_("Delete %s?"), sel->GetName());
if (wxYES == wxMessageBox(msg, _("Delete item"), wxICON_QUESTION|wxYES_NO))
{
wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->Delete(sel->GetTreeItemId());
}
}
}
/// Rename an item
void ctConfigToolView::OnRenameItem(wxCommandEvent& event)
{
ctConfigItem* sel = GetSelection();
if (sel)
{
wxString name = wxGetTextFromUser(_("Please enter a new name for the item."),
_("Rename item"), sel->GetName());
if (!name.IsEmpty())
{
sel->SetName(name);
SyncItem(wxGetApp().GetMainFrame()->GetConfigTreeCtrl(), sel);
ctConfigToolHint hint(NULL, ctSelChanged);
GetDocument()->UpdateAllViews (NULL, & hint);
}
}
}
/// Copy an item to the clipboard
void ctConfigToolView::OnCopy(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = GetSelection();
if (sel)
{
doc->SetClipboardItem(sel->DeepClone());
}
}
/// Copy an item to the clipboard and cut the item
void ctConfigToolView::OnCut(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = GetSelection();
if (sel)
{
{
ctConfigCommand* cmd = new ctConfigCommand(wxT("Cut Config Item"), ctCMD_CUT,
sel, (ctConfigItem*) NULL);
doc->GetCommandProcessor()->Submit(cmd);
}
}
}
/// Paste an item from the clipboard to the tree
void ctConfigToolView::OnPaste(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = GetSelection();
if (sel && doc->GetClipboardItem())
{
ctConfigItem* parent ;
ctConfigItem* insertBefore ;
if (sel->CanHaveChildren())
{
parent = sel;
insertBefore = NULL;
}
else
{
parent = sel->GetParent();
insertBefore = sel->FindNextSibling();
}
ctConfigItem* newItem = doc->GetClipboardItem()->DeepClone();
ctConfigCommand* cmd = new ctConfigCommand(wxT("Paste Config Item"), ctCMD_PASTE,
NULL, newItem, parent, insertBefore);
doc->GetCommandProcessor()->Submit(cmd);
}
}
/// Update for copy command
void ctConfigToolView::OnUpdateCopy(wxUpdateUIEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
event.Enable( doc && GetSelection() && GetSelection()->GetParent() );
}
/// Update for cut
void ctConfigToolView::OnUpdateCut(wxUpdateUIEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
event.Enable( doc && GetSelection() && GetSelection()->GetParent() );
}
/// Update for paste
void ctConfigToolView::OnUpdatePaste(wxUpdateUIEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
event.Enable( doc && doc->GetClipboardItem() && GetSelection() );
}
/// Copy an item to the clipboard
void ctConfigToolView::OnContextCopy(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
if (doc && sel)
{
doc->SetClipboardItem(sel->DeepClone());
}
}
/// Copy an item to the clipboard and cut the item
void ctConfigToolView::OnContextCut(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
if (sel)
{
{
ctConfigCommand* cmd = new ctConfigCommand(wxT("Cut Config Item"), ctCMD_CUT,
sel, (ctConfigItem*) NULL);
doc->GetCommandProcessor()->Submit(cmd);
}
}
}
/// Paste an item from the clipboard to the tree
void ctConfigToolView::OnContextPasteBefore(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
if (sel && doc->GetClipboardItem())
{
ctConfigItem* parent = sel->GetParent();
ctConfigItem* insertBefore = sel;
ctConfigItem* newItem = doc->GetClipboardItem()->DeepClone();
ctConfigCommand* cmd = new ctConfigCommand(wxT("Paste Config Item"), ctCMD_PASTE,
NULL, newItem, parent, insertBefore);
doc->GetCommandProcessor()->Submit(cmd);
}
}
/// Paste an item from the clipboard to the tree
void ctConfigToolView::OnContextPasteAfter(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
if (sel && doc->GetClipboardItem())
{
ctConfigItem* parent = sel->GetParent();
ctConfigItem* insertBefore = sel->FindNextSibling();
ctConfigItem* newItem = doc->GetClipboardItem()->DeepClone();
ctConfigCommand* cmd = new ctConfigCommand(wxT("Paste Config Item"), ctCMD_PASTE,
NULL, newItem, parent, insertBefore);
doc->GetCommandProcessor()->Submit(cmd);
}
}
/// Paste an item from the clipboard to the tree
void ctConfigToolView::OnContextPasteAsChild(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
if (sel && doc->GetClipboardItem())
{
if (sel->CanHaveChildren())
{
ctConfigItem* parent = sel;
ctConfigItem* insertBefore = NULL;
ctConfigItem* newItem = doc->GetClipboardItem()->DeepClone();
ctConfigCommand* cmd = new ctConfigCommand(wxT("Paste Config Item"), ctCMD_PASTE,
NULL, newItem, parent, insertBefore);
doc->GetCommandProcessor()->Submit(cmd);
}
}
}
/// Copy an item to the clipboard
void ctConfigToolView::OnUpdateContextCopy(wxUpdateUIEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
event.Enable( doc && sel && sel->GetParent() );
}
/// Copy an item to the clipboard and cut the item
void ctConfigToolView::OnUpdateContextCut(wxUpdateUIEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
event.Enable( doc && sel && sel->GetParent() );
}
/// Paste an item from the clipboard to the tree
void ctConfigToolView::OnUpdateContextPasteBefore(wxUpdateUIEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
event.Enable( doc && sel && sel->GetParent() && doc->GetClipboardItem() );
}
/// Paste an item from the clipboard to the tree
void ctConfigToolView::OnUpdateContextPasteAfter(wxUpdateUIEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
event.Enable( doc && sel && sel->GetParent() && doc->GetClipboardItem() );
}
/// Paste an item from the clipboard to the tree
void ctConfigToolView::OnUpdateContextPasteAsChild(wxUpdateUIEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
event.Enable( doc && sel && sel->CanHaveChildren() && doc->GetClipboardItem() );
}
/// Item help
void ctConfigToolView::OnItemHelp(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
if ( doc && GetSelection() )
{
wxString helpTopic = GetSelection()->GetPropertyString(wxT("help-topic"));
if (!helpTopic.IsEmpty())
{
wxGetApp().GetReferenceHelpController().DisplaySection(helpTopic);
}
}
}
/// Item help update
void ctConfigToolView::OnUpdateItemHelp(wxUpdateUIEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
event.Enable( doc && GetSelection() );
}
/// Add a custom property
void ctConfigToolView::OnAddCustomProperty(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = GetSelection();
ctPropertyEditor* editor = wxGetApp().GetMainFrame()->GetPropertyEditor();
if (doc && sel && editor)
{
ctCustomPropertyDialog dialog(wxGetApp().GetMainFrame(),
-1, _("Add a custom property"));
if (dialog.ShowModal() == wxID_OK)
{
wxString name = dialog.GetPropertyName();
wxString type = dialog.GetPropertyType();
wxString descr = dialog.GetPropertyDescription();
wxString editorType = dialog.GetEditorType();
wxArrayString choices = dialog.GetChoices();
if (sel->GetProperties().FindProperty(name))
{
wxMessageBox(_("Sorry, this name already exists."), _T("Add custom property"),
wxOK|wxICON_INFORMATION);
return;
}
ctProperty* property = new ctProperty;
if (type == wxT("bool"))
property->GetVariant() = wxVariant((bool) FALSE, name);
else if (type == wxT("double"))
property->GetVariant() = wxVariant((double) 0.0, name);
else if (type == wxT("long"))
property->GetVariant() = wxVariant((long) 0, name);
else
property->GetVariant() = wxVariant(wxT(""), name);
property->SetCustom(TRUE);
property->SetDescription(descr);
property->SetChoices(choices);
property->SetEditorType(editorType);
sel->GetProperties().AddProperty(property);
editor->ShowItem(sel);
OnChangeFilename();
}
}
}
/// Edit a custom property
void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = GetSelection();
ctPropertyEditor* editor = wxGetApp().GetMainFrame()->GetPropertyEditor();
if (doc && sel && editor)
{
int row;
ctProperty* property = editor->FindSelectedProperty(row) ;
if (property && property->IsCustom())
{
wxString oldName = property->GetName();
wxString oldDescription = property->GetDescription();
wxString oldType = property->GetVariant().GetType();
wxString oldEditorType = property->GetEditorType();
wxArrayString oldChoices = property->GetChoices();
ctCustomPropertyDialog dialog(wxGetApp().GetMainFrame(),
-1, _("Edit custom property"));
dialog.SetPropertyName(oldName);
dialog.SetPropertyType(oldType);
dialog.SetPropertyDescription(oldDescription);
if (dialog.ShowModal() == wxID_OK)
{
wxString name = dialog.GetPropertyName();
wxString type = dialog.GetPropertyType();
wxString editorType = dialog.GetEditorType();
wxArrayString choices = dialog.GetChoices();
wxString descr = dialog.GetPropertyDescription();
if (name != oldName && sel->GetProperties().FindProperty(name))
{
wxMessageBox(_("Sorry, this name already exists."), _T("Add custom property"),
wxOK|wxICON_INFORMATION);
return;
}
if (type != oldType)
{
if (type == wxT("bool"))
property->GetVariant() = wxVariant((bool) FALSE, name);
else if (type == wxT("double"))
property->GetVariant() = wxVariant((double) 0.0, name);
else if (type == wxT("long"))
property->GetVariant() = wxVariant((long) 0, name);
else
property->GetVariant() = wxVariant(wxT(""), name);
}
if (name != oldName)
property->GetVariant().SetName(name);
if (choices != oldChoices)
property->SetChoices(choices);
if (editorType != oldEditorType)
property->SetEditorType(editorType);
if (name != oldName)
property->GetVariant().SetName(name);
property->SetCustom(TRUE);
if (descr != oldDescription)
property->SetDescription(descr);
editor->ShowItem(sel);
OnChangeFilename();
}
}
}
}
/// Delete a custom property
void ctConfigToolView::OnDeleteCustomProperty(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = GetSelection();
ctPropertyEditor* editor = wxGetApp().GetMainFrame()->GetPropertyEditor();
if (doc && sel && editor)
{
int row;
ctProperty* property = editor->FindSelectedProperty(row) ;
if (property && property->IsCustom())
{
wxString name(property->GetName());
wxString msg;
msg.Printf(_("Delete custom property '%s'?"), (const wxChar*) name);
if (wxYES == wxMessageBox(msg, _("Delete property"), wxICON_EXCLAMATION|wxYES_NO))
{
sel->GetProperties().RemoveProperty(property);
editor->ShowItem(sel);
delete property;
OnChangeFilename();
}
}
}
}
/// Add a custom property: update event
void ctConfigToolView::OnUpdateAddCustomProperty(wxUpdateUIEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
event.Enable( doc && GetSelection() && GetSelection()->GetParent() );
}
/// Edit a custom property: update event
void ctConfigToolView::OnUpdateEditCustomProperty(wxUpdateUIEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = GetSelection();
ctPropertyEditor* editor = wxGetApp().GetMainFrame()->GetPropertyEditor();
int row;
event.Enable( doc && sel && sel->GetParent() && editor &&
editor->FindSelectedProperty(row) &&
editor->FindSelectedProperty(row)->IsCustom() );
}
/// Delete a custom property: update event
void ctConfigToolView::OnUpdateDeleteCustomProperty(wxUpdateUIEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = GetSelection();
ctPropertyEditor* editor = wxGetApp().GetMainFrame()->GetPropertyEditor();
int row;
event.Enable( doc && sel && sel->GetParent() && editor &&
editor->FindSelectedProperty(row) &&
editor->FindSelectedProperty(row)->IsCustom() );
}
/// Regenerate setup.h and configure command
void ctConfigToolView::RegenerateSetup()
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctOutputWindow* setupPage = wxGetApp().GetMainFrame()->GetSetupPage() ;
ctOutputWindow* configurePage = wxGetApp().GetMainFrame()->GetConfigurePage() ;
wxString setupStr = doc->GenerateSetup();
wxString configureStr = doc->GenerateConfigureCommand();
setupPage->SetText(setupStr);
configurePage->SetText(configureStr);
}
/// Regenerate if selected a tab
void ctConfigToolView::OnTabSelect(wxNotebookEvent& event)
{
if (wxGetApp().GetMainFrame()->GetMainNotebook() != event.GetEventObject())
{
event.Skip();
return;
}
if (event.GetSelection() > 0)
{
RegenerateSetup();
}
}
void ctConfigToolView::OnSaveSetupFile(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
wxString setupStr = doc->GenerateSetup();
wxString filename = _T("setup.h");
wxString path = doc->GetFrameworkDir(FALSE);
wxString wildcard = _T("Header files (*.h)|*.h|All files (*.*)|*.*");
wxFileDialog dialog(wxTheApp->GetTopWindow(),
_("Save Setup File As"),
path, filename ,
wildcard, wxSAVE|wxOVERWRITE_PROMPT);
if (dialog.ShowModal() == wxID_OK)
{
wxString fullPath = dialog.GetPath();
// TODO: save last saved path in settings.
wxFileOutputStream stream(fullPath);
if (!stream.Ok())
{
wxMessageBox(_("Sorry, could not save this file."), _("Save Setup File"), wxICON_EXCLAMATION|wxOK);
return;
}
stream << setupStr;
}
}
void ctConfigToolView::OnSaveConfigureCommand(wxCommandEvent& event)
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
wxString configureStr = doc->GenerateConfigureCommand();
wxString filename = _T("configurewx.sh");
wxString path = doc->GetFrameworkDir(FALSE);
wxString wildcard = _T("Shell script files (*.sh)|*.sh|All files (*.*)|*.*");
wxFileDialog dialog(wxTheApp->GetTopWindow(),
_("Save Configure Command File As"),
path, filename ,
wildcard, wxSAVE|wxOVERWRITE_PROMPT);
if (dialog.ShowModal() == wxID_OK)
{
wxString fullPath = dialog.GetPath();
// TODO: save last saved path in settings.
wxFileOutputStream stream(fullPath);
if (!stream.Ok())
{
wxMessageBox(_("Sorry, could not save this file."), _("Save Configure Command File"), wxICON_EXCLAMATION|wxOK);
return;
}
stream << configureStr;
}
}
void ctConfigToolView::OnUpdateSaveSetupFile(wxUpdateUIEvent& event)
{
event.Enable(TRUE);
}
void ctConfigToolView::OnUpdateSaveConfigureCommand(wxUpdateUIEvent& event)
{
event.Enable(TRUE);
}

View File

@@ -0,0 +1,225 @@
/////////////////////////////////////////////////////////////////////////////
// Name: configtoolview.h
// Purpose: View class
// Author: Julian Smart
// Modified by:
// Created: 2003-06-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _CT_CONFIGTOOLVIEW_H_
#define _CT_CONFIGTOOLVIEW_H_
#ifdef __GNUG__
#pragma interface "configtoolview.cpp"
#endif
#include "wx/docview.h"
#include "wx/treectrl.h"
#include "configitem.h"
class ctConfigTreeCtrl;
class WXDLLEXPORT wxNotebookEvent;
/*
* ctConfigToolView
*/
class ctConfigItem;
class ctConfigToolView: public wxView
{
DECLARE_DYNAMIC_CLASS(ctConfigToolView)
public:
ctConfigToolView();
~ctConfigToolView() {};
//// Overrides
bool OnCreate(wxDocument *doc, long flags);
void OnDraw(wxDC *dc);
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
bool OnClose(bool deleteWindow = TRUE);
void OnChangeFilename();
//// Operations
/// Gets the tree item in sync with the item.
void SyncItem(ctConfigTreeCtrl* treeControl, ctConfigItem* item);
/// Add item and its children to the tree
void AddItems(ctConfigTreeCtrl* treeControl, ctConfigItem* item);
/// Clicked an icon
void OnIconLeftDown(ctConfigTreeCtrl* treeControl, ctConfigItem* item);
/// Add an item
void AddItem(ctConfigType type, const wxString& msg);
/// Regenerate setup.h and configure command
void RegenerateSetup();
//// Accessors
/// Returns the selected config item, if any.
ctConfigItem* GetSelection();
//// Event handlers
/// General disabler
void OnUpdateDisable(wxUpdateUIEvent& event);
/// Enable add item menu items
void OnUpdateAddItem(wxUpdateUIEvent& event);
/// Add a checkbox item
void OnAddCheckBoxItem(wxCommandEvent& event);
/// Add a radiobutton item
void OnAddRadioButtonItem(wxCommandEvent& event);
/// Add a group item
void OnAddGroupItem(wxCommandEvent& event);
/// Add a check group item
void OnAddCheckGroupItem(wxCommandEvent& event);
/// Add a radio group item
void OnAddRadioGroupItem(wxCommandEvent& event);
/// Add a string item
void OnAddStringItem(wxCommandEvent& event);
/// Delete an item
void OnDeleteItem(wxCommandEvent& event);
/// Rename an item
void OnRenameItem(wxCommandEvent& event);
/// Copy an item to the clipboard
void OnCopy(wxCommandEvent& event);
/// Copy an item to the clipboard and cut the item
void OnCut(wxCommandEvent& event);
/// Paste an item from the clipboard to the tree
void OnPaste(wxCommandEvent& event);
/// Item help
void OnItemHelp(wxCommandEvent& event);
/// Update for copy command
void OnUpdateCopy(wxUpdateUIEvent& event);
/// Update for cut
void OnUpdateCut(wxUpdateUIEvent& event);
/// Update for paste
void OnUpdatePaste(wxUpdateUIEvent& event);
/// Update for item help
void OnUpdateItemHelp(wxUpdateUIEvent& event);
// Context menu events
/// Copy an item to the clipboard
void OnContextCopy(wxCommandEvent& event);
/// Copy an item to the clipboard and cut the item
void OnContextCut(wxCommandEvent& event);
/// Paste an item from the clipboard to the tree
void OnContextPasteBefore(wxCommandEvent& event);
/// Paste an item from the clipboard to the tree
void OnContextPasteAfter(wxCommandEvent& event);
/// Paste an item from the clipboard to the tree
void OnContextPasteAsChild(wxCommandEvent& event);
/// Copy an item to the clipboard
void OnUpdateContextCopy(wxUpdateUIEvent& event);
/// Copy an item to the clipboard and cut the item
void OnUpdateContextCut(wxUpdateUIEvent& event);
/// Paste an item from the clipboard to the tree
void OnUpdateContextPasteBefore(wxUpdateUIEvent& event);
/// Paste an item from the clipboard to the tree
void OnUpdateContextPasteAfter(wxUpdateUIEvent& event);
/// Paste an item from the clipboard to the tree
void OnUpdateContextPasteAsChild(wxUpdateUIEvent& event);
// Custom property events
/// Add a custom property
void OnAddCustomProperty(wxCommandEvent& event);
/// Edit a custom property
void OnEditCustomProperty(wxCommandEvent& event);
/// Delete a custom property
void OnDeleteCustomProperty(wxCommandEvent& event);
/// Add a custom property: update event
void OnUpdateAddCustomProperty(wxUpdateUIEvent& event);
/// Edit a custom property: update event
void OnUpdateEditCustomProperty(wxUpdateUIEvent& event);
/// Delete a custom property: update event
void OnUpdateDeleteCustomProperty(wxUpdateUIEvent& event);
// Notebook events
/// Regenerate if selected a tab
void OnTabSelect(wxNotebookEvent& event);
/// Saving setup file
void OnSaveSetupFile(wxCommandEvent& event);
/// Save configure command file
void OnSaveConfigureCommand(wxCommandEvent& event);
/// Saving setup file update handler
void OnUpdateSaveSetupFile(wxUpdateUIEvent& event);
/// Save configure command file update handler
void OnUpdateSaveConfigureCommand(wxUpdateUIEvent& event);
DECLARE_EVENT_TABLE()
protected:
};
/*
* ctConfigToolHint
*
* Hint to pass to UpdateAllViews
*
*/
// Update hint symbols
#define ctNoHint 0
#define ctAllSaved 1
#define ctClear 2
#define ctValueChanged 3
#define ctSelChanged 4
#define ctFilenameChanged 5
#define ctInitialUpdate 6
class ctConfigItem;
class ctConfigToolHint: public wxObject
{
public:
ctConfigToolHint(ctConfigItem* item, int op) { m_item = item; m_op = op; }
ctConfigItem* m_item;
int m_op;
};
#endif
// _CT_CONFIGTOOLVIEW_H_

View File

@@ -0,0 +1,229 @@
/////////////////////////////////////////////////////////////////////////////
// Name: configtree.h
// Purpose: wxWindows Configuration Tool tree class
// Author: Julian Smart
// Modified by:
// Created: 2003-06-03
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "configtree.h"
#endif
// Includes other headers for precompiled compilation
#include "wx/wx.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/imaglist.h"
#include "wx/cshelp.h"
// Include XPM icons
#include "bitmaps/folder1.xpm"
#include "bitmaps/closedfolder.xpm"
#include "bitmaps/closedfolder_dis.xpm"
#include "bitmaps/checked.xpm"
#include "bitmaps/checked_dis.xpm"
#include "bitmaps/unchecked.xpm"
#include "bitmaps/unchecked_dis.xpm"
#include "bitmaps/radioon.xpm"
#include "bitmaps/radioon_dis.xpm"
#include "bitmaps/radiooff.xpm"
#include "bitmaps/radiooff_dis.xpm"
#include "bitmaps/checkedfolder.xpm"
#include "bitmaps/checkedfolder_dis.xpm"
#include "bitmaps/uncheckedfolder.xpm"
#include "bitmaps/uncheckedfolder_dis.xpm"
#include "bitmaps/radiofolderon.xpm"
#include "bitmaps/radiofolderon_dis.xpm"
#include "bitmaps/radiofolderoff.xpm"
#include "bitmaps/radiofolderoff_dis.xpm"
#include "configtree.h"
#include "configtooldoc.h"
#include "configtoolview.h"
#include "wxconfigtool.h"
#include "mainframe.h"
/*
* ctConfigTreeCtrl
*/
IMPLEMENT_CLASS(ctConfigTreeCtrl, wxTreeCtrl)
BEGIN_EVENT_TABLE(ctConfigTreeCtrl, wxTreeCtrl)
EVT_MOUSE_EVENTS(ctConfigTreeCtrl::OnMouseEvent)
EVT_CHAR(ctConfigTreeCtrl::OnKeyDown)
EVT_TREE_SEL_CHANGED(-1, ctConfigTreeCtrl::OnSelChanged)
EVT_HELP(-1, ctConfigTreeCtrl::OnHelp)
END_EVENT_TABLE()
ctConfigTreeCtrl::ctConfigTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt,
const wxSize& sz, long style):
wxTreeCtrl(parent, id, pt, sz, style)
{
LoadIcons();
m_contextMenu = NULL;
m_contextMenu = new wxMenu;
m_contextMenu->Append(ctID_TREE_PASTE_BEFORE, _("Paste &before this option"));
m_contextMenu->Append(ctID_TREE_PASTE_AFTER, _("Paste &after this option"));
m_contextMenu->Append(ctID_TREE_PASTE_AS_CHILD, _("Paste as &child of this option"));
m_contextMenu->AppendSeparator();
m_contextMenu->Append(ctID_TREE_COPY, _("C&opy"));
m_contextMenu->Append(ctID_TREE_CUT, _("Cu&t"));
SetHelpText(_("This shows configuration settings that you can enable and disable."));
}
// Load the icons and initialize the tree
void ctConfigTreeCtrl::LoadIcons()
{
m_imageList = new wxImageList(16, 16, TRUE);
m_iconTable.SetImageList(m_imageList);
SetImageList(m_imageList);
m_iconTable.AddInfo("Group", wxIcon(closedfolder_xpm), 0, TRUE);
m_iconTable.AddInfo("Group", wxIcon(closedfolder_dis_xpm), 0, FALSE);
m_iconTable.AddInfo("Checkbox", wxIcon(checked_xpm), 0, TRUE);
m_iconTable.AddInfo("Checkbox", wxIcon(checked_dis_xpm), 0, FALSE);
m_iconTable.AddInfo("Checkbox", wxIcon(unchecked_xpm), 1, TRUE);
m_iconTable.AddInfo("Checkbox", wxIcon(unchecked_dis_xpm), 1, FALSE);
m_iconTable.AddInfo("CheckGroup", wxIcon(checkedfolder_xpm), 0, TRUE);
m_iconTable.AddInfo("CheckGroup", wxIcon(checkedfolder_dis_xpm), 0, FALSE);
m_iconTable.AddInfo("CheckGroup", wxIcon(uncheckedfolder_xpm), 1, TRUE);
m_iconTable.AddInfo("CheckGroup", wxIcon(uncheckedfolder_dis_xpm), 1, FALSE);
m_iconTable.AddInfo("RadioGroup", wxIcon(radiofolderon_xpm), 0, TRUE);
m_iconTable.AddInfo("RadioGroup", wxIcon(radiofolderon_dis_xpm), 0, FALSE);
m_iconTable.AddInfo("RadioGroup", wxIcon(radiofolderoff_xpm), 1, TRUE);
m_iconTable.AddInfo("RadioGroup", wxIcon(radiofolderoff_dis_xpm), 1, FALSE);
m_iconTable.AddInfo("Radiobutton", wxIcon(radioon_xpm), 0, TRUE);
m_iconTable.AddInfo("Radiobutton", wxIcon(radioon_dis_xpm), 0, FALSE);
m_iconTable.AddInfo("Radiobutton", wxIcon(radiooff_xpm), 1, TRUE);
m_iconTable.AddInfo("Radiobutton", wxIcon(radiooff_dis_xpm), 1, FALSE);
}
ctConfigTreeCtrl::~ctConfigTreeCtrl()
{
SetImageList(NULL);
delete m_imageList;
delete m_contextMenu;
}
void ctConfigTreeCtrl::OnSelChanged(wxTreeEvent& event)
{
ctConfigToolDoc* doc = wxGetApp().GetMainFrame()->GetDocument();
if (doc)
{
ctConfigToolHint hint(NULL, ctSelChanged);
doc->UpdateAllViews(NULL, & hint);
}
}
void ctConfigTreeCtrl::OnMouseEvent(wxMouseEvent& event)
{
int flags = 0;
wxTreeItemId item = HitTest(wxPoint(event.GetX(), event.GetY()), flags);
if (event.LeftDown())
{
if (flags & wxTREE_HITTEST_ONITEMICON)
{
ctTreeItemData* data = (ctTreeItemData*) GetItemData(item);
ctConfigToolDoc* doc = wxGetApp().GetMainFrame()->GetDocument();
if (doc)
{
ctConfigToolView* view = wxDynamicCast(doc->GetFirstView(), ctConfigToolView);
if (view)
view->OnIconLeftDown(this, data->GetConfigItem());
}
}
}
else if (event.RightDown())
{
if ((flags & wxTREE_HITTEST_ONITEMBUTTON) ||
(flags & wxTREE_HITTEST_ONITEMICON) ||
(flags & wxTREE_HITTEST_ONITEMINDENT) ||
(flags & wxTREE_HITTEST_ONITEMLABEL))
{
ctTreeItemData* data = (ctTreeItemData*) GetItemData(item);
ctConfigToolDoc* doc = wxGetApp().GetMainFrame()->GetDocument();
if (doc && data)
{
m_contextItem = data->GetConfigItem();
PopupMenu(m_contextMenu, event.GetX(), event.GetY());
}
}
}
event.Skip();
}
void ctConfigTreeCtrl::OnKeyDown(wxKeyEvent& event)
{
wxTreeItemId id = GetSelection();
if (event.GetKeyCode() == WXK_SPACE)
{
if (id.IsOk())
{
ctConfigItem* item = ((ctTreeItemData*) GetItemData(id))->GetConfigItem();
ctConfigToolDoc* doc = wxGetApp().GetMainFrame()->GetDocument();
if (doc)
{
ctConfigToolView* view = wxDynamicCast(doc->GetFirstView(), ctConfigToolView);
if (view)
view->OnIconLeftDown(this, item);
}
}
}
else
{
event.Skip();
}
}
// Show help for this window
void ctConfigTreeCtrl::OnHelp(wxHelpEvent& event)
{
wxPoint pt = ScreenToClient(event.GetPosition());
int flags = 0;
wxTreeItemId id = HitTest(pt, flags);
wxHelpProvider *helpProvider = wxHelpProvider::Get();
if ( helpProvider && id > 0)
{
ctConfigItem* item = ((ctTreeItemData*) GetItemData(id))->GetConfigItem();
if (item)
{
wxString helpTopic = item->GetPropertyString(wxT("help-topic"));
if (!helpTopic.IsEmpty())
{
wxGetApp().GetReferenceHelpController().DisplaySection(helpTopic);
return;
}
}
}
event.Skip();
}
ctTreeItemData::~ctTreeItemData()
{
if (m_configItem) delete m_configItem;
}

View File

@@ -0,0 +1,91 @@
/////////////////////////////////////////////////////////////////////////////
// Name: configtree.h
// Purpose: wxWindows Configuration Tool tree class
// Author: Julian Smart
// Modified by:
// Created: 2003-06-03
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _CT_CONFIGTREE_H_
#define _CT_CONFIGTREE_H_
#ifdef __GNUG__
#pragma interface "configtree.cpp"
#endif
#include "wx/wx.h"
#include "wx/treectrl.h"
#include "configitem.h"
#include "utils.h"
/*!
* ctTreeItemData
* Holds the ctConfigItem for each tree item.
*/
class ctTreeItemData : public wxTreeItemData
{
public:
ctTreeItemData(ctConfigItem* item) : m_configItem(item) { }
~ctTreeItemData() ;
ctConfigItem *GetConfigItem() const { return m_configItem; }
void SetConfigItem(ctConfigItem *item) { m_configItem = item; }
private:
ctConfigItem* m_configItem;
};
/*!
* ctConfigTreeCtrl
* The options hierarchy viewer.
*/
class ctConfigTreeCtrl: public wxTreeCtrl
{
DECLARE_CLASS(ctConfigTreeCtrl)
public:
ctConfigTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS);
~ctConfigTreeCtrl();
//// Event handlers
void OnMouseEvent(wxMouseEvent& event);
void OnSelChanged(wxTreeEvent& event);
void OnHelp(wxHelpEvent& event);
void OnKeyDown(wxKeyEvent& event);
//// Accessors
/// Get the table of icons
wxIconTable& GetIconTable() { return m_iconTable; }
/// Get the context menu
wxMenu* GetMenu() { return m_contextMenu; }
/// Get the item associated with the context menu events
ctConfigItem* GetContextItem() { return m_contextItem; }
//// Operations
/// Loads the icons.
void LoadIcons();
protected:
wxImageList* m_imageList;
wxIconTable m_iconTable;
wxMenu* m_contextMenu;
// The item associated with the context menu events
ctConfigItem* m_contextItem;
DECLARE_EVENT_TABLE()
};
#endif
// _CT_CONFIGTREE_H_

View File

@@ -0,0 +1,261 @@
/////////////////////////////////////////////////////////////////////////////
// Name: custompropertydialog.cpp
// Purpose: Custom property dialog
// Author: Julian Smart
// Modified by:
// Created: 2003-06-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation custompropertydialog.h
#endif
#include <wx/wx.h>
#include <wx/cshelp.h>
#include <wx/statline.h>
#include <wx/splitter.h>
#include <wx/scrolwin.h>
#include <wx/spinctrl.h>
#include <wx/spinbutt.h>
#include <wx/valgen.h>
#include "custompropertydialog.h"
////@begin XPM images
////@end XPM images
/*!
* ctCustomPropertyDialog type definition
*/
IMPLEMENT_CLASS( ctCustomPropertyDialog, wxDialog )
/*!
* ctCustomPropertyDialog event table definition
*/
BEGIN_EVENT_TABLE( ctCustomPropertyDialog, wxDialog )
////@begin ctCustomPropertyDialog event table entries
EVT_UPDATE_UI( ID_PROPERTY_CHOICES, ctCustomPropertyDialog::OnUpdatePropertyChoices )
EVT_BUTTON( ID_PROPERTY_CHOICE_ADD, ctCustomPropertyDialog::OnPropertyChoiceAdd )
EVT_UPDATE_UI( ID_PROPERTY_CHOICE_ADD, ctCustomPropertyDialog::OnUpdatePropertyChoiceAdd )
EVT_BUTTON( ID_PROPERTY_CHOICE_REMOVE, ctCustomPropertyDialog::OnPropertyChoiceRemove )
EVT_UPDATE_UI( ID_PROPERTY_CHOICE_REMOVE, ctCustomPropertyDialog::OnUpdatePropertyChoiceRemove )
////@end ctCustomPropertyDialog event table entries
END_EVENT_TABLE()
/*!
* ctCustomPropertyDialog constructor
*/
ctCustomPropertyDialog::ctCustomPropertyDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
m_type = wxT("string");
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
}
/*!
* Control creation for ctCustomPropertyDialog
*/
void ctCustomPropertyDialog::CreateControls()
{
////@begin ctCustomPropertyDialog content construction
ctCustomPropertyDialog* item1 = this;
wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL);
item1->SetSizer(item2);
item1->SetAutoLayout(TRUE);
wxBoxSizer* item3 = new wxBoxSizer(wxVERTICAL);
item2->Add(item3, 1, wxGROW|wxALL, 5);
wxStaticText* item4 = new wxStaticText(item1, wxID_STATIC, _("&Enter name, type and description for your custom property."), wxDefaultPosition, wxDefaultSize, 0);
item3->Add(item4, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
wxStaticText* item5 = new wxStaticText(item1, wxID_STATIC, _("&Name:"), wxDefaultPosition, wxDefaultSize, 0);
item3->Add(item5, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
wxTextCtrl* item6 = new wxTextCtrl(item1, ID_CUSTOMPROPERTYNAME, _(""), wxDefaultPosition, wxDefaultSize, 0);
item3->Add(item6, 0, wxGROW|wxALL, 5);
wxBoxSizer* item7 = new wxBoxSizer(wxHORIZONTAL);
item3->Add(item7, 0, wxGROW, 5);
wxBoxSizer* item8 = new wxBoxSizer(wxVERTICAL);
item7->Add(item8, 1, wxGROW, 5);
wxStaticText* item9 = new wxStaticText(item1, wxID_STATIC, _("&Data type:"), wxDefaultPosition, wxDefaultSize, 0);
item8->Add(item9, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
wxString item10Strings[] = {
_("string"),
_("bool"),
_("double"),
_("long")
};
wxChoice* item10 = new wxChoice(item1, ID_CUSTOMPROPERTYTYPE, wxDefaultPosition, wxDefaultSize, 4, item10Strings, 0);
item10->SetStringSelection(_("string"));
item8->Add(item10, 1, wxGROW|wxALL, 5);
wxBoxSizer* item11 = new wxBoxSizer(wxVERTICAL);
item7->Add(item11, 0, wxALIGN_CENTER_VERTICAL, 5);
wxStaticText* item12 = new wxStaticText(item1, wxID_STATIC, _("&Editor type:"), wxDefaultPosition, wxDefaultSize, 0);
item11->Add(item12, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
wxString item13Strings[] = {
_("string"),
_("choice"),
_("bool"),
_("float"),
_("integer"),
_("configitems")
};
wxChoice* item13 = new wxChoice(item1, ID_CUSTOMPROPERTYEDITORTYPE, wxDefaultPosition, wxDefaultSize, 6, item13Strings, 0);
item13->SetStringSelection(_("string"));
item11->Add(item13, 1, wxGROW|wxALL, 5);
wxStaticBox* item14Static = new wxStaticBox(item1, -1, _("Choices"));
wxStaticBoxSizer* item14 = new wxStaticBoxSizer(item14Static, wxHORIZONTAL);
item3->Add(item14, 0, wxGROW|wxALL, 5);
wxString* item15Strings = NULL;
wxListBox* item15 = new wxListBox(item1, ID_PROPERTY_CHOICES, wxDefaultPosition, wxDefaultSize, 0, item15Strings, wxLB_SINGLE);
item14->Add(item15, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* item16 = new wxBoxSizer(wxVERTICAL);
item14->Add(item16, 0, wxALIGN_CENTER_VERTICAL, 5);
wxButton* item17 = new wxButton(item1, ID_PROPERTY_CHOICE_ADD, _("&Add..."), wxDefaultPosition, wxDefaultSize, 0);
item16->Add(item17, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxButton* item18 = new wxButton(item1, ID_PROPERTY_CHOICE_REMOVE, _("&Remove"), wxDefaultPosition, wxDefaultSize, 0);
item16->Add(item18, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxStaticText* item19 = new wxStaticText(item1, wxID_STATIC, _("&Description:"), wxDefaultPosition, wxDefaultSize, 0);
item3->Add(item19, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
wxTextCtrl* item20 = new wxTextCtrl(item1, ID_CUSTOMPROPERTYDESCRIPTION, _(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_RICH);
item3->Add(item20, 1, wxGROW|wxALL, 5);
wxBoxSizer* item21 = new wxBoxSizer(wxHORIZONTAL);
item3->Add(item21, 0, wxGROW|wxALL, 5);
item21->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* item23 = new wxButton(item1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0);
item21->Add(item23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* item24 = new wxButton(item1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0);
item21->Add(item24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* item25 = new wxButton(item1, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, 0);
item21->Add(item25, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
Centre();
////@end ctCustomPropertyDialog content construction
// Add validators
FindWindow(ID_CUSTOMPROPERTYNAME)->SetValidator(wxGenericValidator(& m_name));
FindWindow(ID_CUSTOMPROPERTYTYPE)->SetValidator(wxGenericValidator(& m_type));
FindWindow(ID_CUSTOMPROPERTYEDITORTYPE)->SetValidator(wxGenericValidator(& m_editorType));
FindWindow(ID_CUSTOMPROPERTYDESCRIPTION)->SetValidator(wxGenericValidator(& m_description));
}
/*!
* Should we show tooltips?
*/
bool ctCustomPropertyDialog::ShowToolTips()
{
return TRUE;
}
/*!
* Update event handler for ID_PROPERTY_CHOICES
*/
void ctCustomPropertyDialog::OnUpdatePropertyChoices( wxUpdateUIEvent& event )
{
wxChoice* choice = (wxChoice* ) FindWindow(ID_CUSTOMPROPERTYTYPE);
event.Enable( choice->GetSelection() > -1 && choice->GetStringSelection() == wxT("choice") );
}
/*!
* Event handler for ID_PROPERTY_CHOICE_ADD
*/
void ctCustomPropertyDialog::OnPropertyChoiceAdd( wxCommandEvent& event )
{
wxChoice* choice = (wxChoice* ) FindWindow(ID_CUSTOMPROPERTYTYPE);
if ( choice->GetSelection() > -1 && choice->GetStringSelection() == wxT("choice") )
{
wxString str = wxGetTextFromUser(_T("New choice"), _("Add choice"));
if (!str.IsEmpty())
{
wxListBox* listBox = (wxListBox* ) FindWindow(ID_PROPERTY_CHOICES);
listBox->Append(str);
m_choices.Add(str);
}
}
}
/*!
* Update event handler for ID_PROPERTY_CHOICE_ADD
*/
void ctCustomPropertyDialog::OnUpdatePropertyChoiceAdd( wxUpdateUIEvent& event )
{
wxChoice* choice = (wxChoice* ) FindWindow(ID_CUSTOMPROPERTYEDITORTYPE);
event.Enable( choice->GetSelection() > -1 && choice->GetStringSelection() == wxT("choice") );
}
/*!
* Event handler for ID_PROPERTY_CHOICE_REMOVE
*/
void ctCustomPropertyDialog::OnPropertyChoiceRemove( wxCommandEvent& event )
{
wxChoice* choice = (wxChoice* ) FindWindow(ID_CUSTOMPROPERTYEDITORTYPE);
wxListBox* listBox = (wxListBox* ) FindWindow(ID_PROPERTY_CHOICES);
if (listBox->GetSelection() > -1)
{
listBox->Delete(listBox->GetSelection());
m_choices.Remove(listBox->GetSelection());
}
}
/*!
* Update event handler for ID_PROPERTY_CHOICE_REMOVE
*/
void ctCustomPropertyDialog::OnUpdatePropertyChoiceRemove( wxUpdateUIEvent& event )
{
wxChoice* choice = (wxChoice* ) FindWindow(ID_CUSTOMPROPERTYEDITORTYPE);
wxListBox* listBox = (wxListBox* ) FindWindow(ID_PROPERTY_CHOICES);
event.Enable( choice->GetSelection() > -1 && choice->GetStringSelection() == wxT("choice") &&
listBox->GetSelection() > -1 );
}
void ctCustomPropertyDialog::SetChoices(const wxArrayString& choices)
{
wxListBox* listBox = (wxListBox* ) FindWindow(ID_PROPERTY_CHOICES);
size_t i, len = choices.GetCount();
for (i = 0; i < len; i++)
listBox->Append(m_choices[i]);
}

View File

@@ -0,0 +1,113 @@
/////////////////////////////////////////////////////////////////////////////
// Name: custompropertydialog.h
// Purpose: Custom property dialog
// Author: Julian Smart
// Modified by:
// Created: 2003-06-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _CUSTOMPROPERTYDIALOG_H_
#define _CUSTOMPROPERTYDIALOG_H_
#ifdef __GNUG__
#pragma interface custompropertydialog.cpp
#endif
/*!
* Includes
*/
////@begin includes
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
#define ID_CUSTOMPROPERTYDIALOG 10000
#define ID_CUSTOMPROPERTYNAME 10003
#define ID_CUSTOMPROPERTYTYPE 10002
#define ID_CUSTOMPROPERTYEDITORTYPE 10008
#define ID_PROPERTY_CHOICES 10001
#define ID_PROPERTY_CHOICE_ADD 10005
#define ID_PROPERTY_CHOICE_REMOVE 10006
#define ID_CUSTOMPROPERTYDESCRIPTION 10004
////@end control identifiers
/*!
* ctCustomPropertyDialog class declaration
*/
class ctCustomPropertyDialog: public wxDialog
{
public:
/// Constructor
ctCustomPropertyDialog( wxWindow* parent, wxWindowID id = -1, const wxString& caption = _("Edit Custom Property"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU );
/// Creates the controls and sizers
void CreateControls();
////@begin ctCustomPropertyDialog event handler declarations
/// Update event handler for ID_PROPERTY_CHOICES
void OnUpdatePropertyChoices( wxUpdateUIEvent& event );
/// Event handler for ID_PROPERTY_CHOICE_ADD
void OnPropertyChoiceAdd( wxCommandEvent& event );
/// Update event handler for ID_PROPERTY_CHOICE_ADD
void OnUpdatePropertyChoiceAdd( wxUpdateUIEvent& event );
/// Event handler for ID_PROPERTY_CHOICE_REMOVE
void OnPropertyChoiceRemove( wxCommandEvent& event );
/// Update event handler for ID_PROPERTY_CHOICE_REMOVE
void OnUpdatePropertyChoiceRemove( wxUpdateUIEvent& event );
////@end ctCustomPropertyDialog event handler declarations
////@begin ctCustomPropertyDialog member function declarations
////@end ctCustomPropertyDialog member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
void SetPropertyName(const wxString& name) { m_name = name; }
wxString GetPropertyName() { return m_name; }
void SetPropertyType(const wxString& type) { m_type = type; }
wxString GetPropertyType() { return m_type; }
void SetEditorType(const wxString& type) { m_editorType = type; }
wxString GetEditorType() { return m_editorType; }
void SetPropertyDescription(const wxString& descr) { m_description = descr; }
wxString GetPropertyDescription() { return m_description; }
void SetChoices(const wxArrayString& choices) ;
wxArrayString GetChoices() { return m_choices; }
DECLARE_CLASS( ctCustomPropertyDialog )
DECLARE_EVENT_TABLE()
wxString m_name;
wxString m_type;
wxString m_description;
wxString m_editorType;
wxArrayString m_choices;
};
#endif
// _CUSTOMPROPERTYDIALOG_H_

View File

@@ -0,0 +1,989 @@
/////////////////////////////////////////////////////////////////////////////
// Name: htmlparser.cpp
// Purpose: Simple HTML parser
// Author: Julian Smart
// Modified by:
// Created: 2002-09-25
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma implementation "htmlparser.h"
#endif
#include "wx/wx.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/textfile.h"
#include "wx/wfstream.h"
#include "wx/txtstrm.h"
#include <ctype.h>
#include "htmlparser.h"
/// Useful insertion operators for wxOutputStream.
static wxOutputStream& operator <<(wxOutputStream& stream, const wxString& s)
{
wxTextOutputStream txt(stream); // This is to make sure the line-ending is native!
txt.WriteString(s);
return stream;
}
#if 0 // Gives warning because not used...
static wxOutputStream& operator <<(wxOutputStream& stream, long l)
{
wxString str;
str.Printf("%ld", l);
return stream << str;
}
static wxOutputStream& operator <<(wxOutputStream& stream, const char c)
{
wxString str;
str.Printf("%c", c);
return stream << str;
}
#endif // 0
/*
* wxSimpleHtmlAttribute
* Representation of an attribute
*/
wxSimpleHtmlParser::wxSimpleHtmlParser()
{
m_topLevel = NULL;
m_pos = 0;
}
wxSimpleHtmlParser::~wxSimpleHtmlParser()
{
Clear();
}
bool wxSimpleHtmlParser::ParseFile(const wxString& filename)
{
wxTextFile textFile;
if (textFile.Open(filename))
{
wxString text;
wxString line;
int i;
int count = textFile.GetLineCount();
for (i = 0; i < count; i++)
{
if (i == 0)
line = textFile.GetFirstLine();
else
line = textFile.GetNextLine();
text += line;
if (i != (count - 1))
text += wxT("\n");
}
#if 0
for ( line = textFile.GetFirstLine(); !textFile.Eof(); line = textFile.GetNextLine() )
{
text += line;
if (!textFile.Eof())
text += wxT("\n");
}
#endif
return ParseString(text);
}
else
return FALSE;
}
bool wxSimpleHtmlParser::ParseString(const wxString& str)
{
Clear();
m_pos = 0;
m_text = str;
m_length = str.Length();
m_topLevel = new wxSimpleHtmlTag(wxT("TOPLEVEL"), wxSimpleHtmlTag_TopLevel);
bool bResult = ParseHtml(m_topLevel);
wxASSERT(bResult); // Failed to parse the TAGs.
// Hint: Check if every open tag has a close tag!
return bResult;
}
// Main recursive parsing function
bool wxSimpleHtmlParser::ParseHtml(wxSimpleHtmlTag* parent)
{
if (!parent)
return FALSE;
while (!Eof())
{
EatWhitespace();
if (IsComment())
{
ParseComment();
}
else if (IsDirective())
{
wxSimpleHtmlTag* tag = ParseDirective();
if (tag)
parent->AppendTag(tag);
}
else if (IsXMLDeclaration())
{
wxSimpleHtmlTag* tag = ParseXMLDeclaration();
if (tag)
parent->AppendTag(tag);
}
else if (IsTagClose())
{
wxSimpleHtmlTag* tag = ParseTagClose();
if (tag)
{
if (IsCloseTagNeeded(tag->GetName()))
{
if (!parent->GetParent())
return FALSE;
parent->GetParent()->AppendTag(tag);
return TRUE;
}
else
parent->AppendTag(tag);
}
}
else if (IsTagStartBracket(GetChar(m_pos)))
{
wxSimpleHtmlTag* tag = ParseTagHeader();
if (tag)
parent->AppendTag(tag);
if (IsCloseTagNeeded(tag->GetName()))
{
if (!ParseHtml(tag))
return FALSE; // Something didn't go ok, so don't continue.
}
}
else
{
// Just a text string
wxString text;
ParseText(text);
wxSimpleHtmlTag* tag = new wxSimpleHtmlTag(wxT("TEXT"), wxSimpleHtmlTag_Text);
tag->SetText(text);
if(parent->GetParent())
parent->GetParent()->AppendTag(tag);
else
parent->AppendTag(tag); // When this occurs it is probably the
// empty lines at the end of the file...
}
}
return TRUE;
}
// Plain text, up until an angled bracket
bool wxSimpleHtmlParser::ParseText(wxString& text)
{
while (!Eof() && GetChar(m_pos) != wxT('<'))
{
text += GetChar(m_pos);
m_pos ++;
}
DecodeSpecialChars(text);
return TRUE;
}
wxSimpleHtmlTag* wxSimpleHtmlParser::ParseTagHeader()
{
if (IsTagStartBracket(GetChar(m_pos)))
{
m_pos ++;
EatWhitespace();
wxString word;
ReadWord(word, TRUE);
EatWhitespace();
wxSimpleHtmlTag* tag = new wxSimpleHtmlTag(word, wxSimpleHtmlTag_Open);
ParseAttributes(tag);
EatWhitespace();
if (IsTagEndBracket(GetChar(m_pos)))
m_pos ++;
return tag;
}
else
return NULL;
}
wxSimpleHtmlTag* wxSimpleHtmlParser::ParseTagClose()
{
Matches(wxT("</"), TRUE);
EatWhitespace();
wxString word;
ReadWord(word, TRUE);
EatWhitespace();
m_pos ++;
wxSimpleHtmlTag* tag = new wxSimpleHtmlTag(word, wxSimpleHtmlTag_Close);
return tag;
}
bool wxSimpleHtmlParser::ParseAttributes(wxSimpleHtmlTag* tag)
{
// Parse attributes of a tag header until we reach >
while (!IsTagEndBracket(GetChar(m_pos)) && !Eof())
{
EatWhitespace();
wxString attrName, attrValue;
if (IsString())
{
ReadString(attrName, TRUE);
tag->AppendAttribute(attrName, wxEmptyString);
}
else if (IsNumeric(GetChar(m_pos)))
{
ReadNumber(attrName, TRUE);
tag->AppendAttribute(attrName, wxEmptyString);
}
else
{
// Try to read an attribute name/value pair, or at least a name
// without the value
ReadLiteral(attrName, TRUE);
EatWhitespace();
if (GetChar(m_pos) == wxT('='))
{
m_pos ++;
EatWhitespace();
if (IsString())
ReadString(attrValue, TRUE);
else if (!Eof() && !IsTagEndBracket(GetChar(m_pos)))
ReadLiteral(attrValue, TRUE);
}
if (!attrName.IsEmpty())
tag->AppendAttribute(attrName, attrValue);
}
}
return TRUE;
}
// e.g. <!DOCTYPE ....>
wxSimpleHtmlTag* wxSimpleHtmlParser::ParseDirective()
{
Matches(wxT("<!"), TRUE);
EatWhitespace();
wxString word;
ReadWord(word, TRUE);
EatWhitespace();
wxSimpleHtmlTag* tag = new wxSimpleHtmlTag(word, wxSimpleHtmlTag_Directive);
ParseAttributes(tag);
EatWhitespace();
if (IsTagEndBracket(GetChar(m_pos)))
m_pos ++;
return tag;
}
// e.g. <?xml .... ?>
wxSimpleHtmlTag* wxSimpleHtmlParser::ParseXMLDeclaration()
{
Matches(wxT("<?"), TRUE);
EatWhitespace();
wxString word;
ReadWord(word, TRUE);
EatWhitespace();
wxSimpleHtmlTag* tag = new wxSimpleHtmlTag(word, wxSimpleHtmlTag_XMLDeclaration);
ParseAttributes(tag);
EatWhitespace();
if (IsTagEndBracket(GetChar(m_pos)))
m_pos ++;
return tag;
}
bool wxSimpleHtmlParser::ParseComment()
{
// Eat the comment tag start
Matches(wxT("<!--"), TRUE);
while (!Eof() && !Matches(wxT("-->"), TRUE))
{
m_pos ++;
}
return TRUE;
}
bool wxSimpleHtmlParser::EatWhitespace()
{
while (!Eof() && IsWhitespace(GetChar(m_pos)))
m_pos ++;
return TRUE;
}
bool wxSimpleHtmlParser::EatWhitespace(int& pos)
{
while (!Eof(pos) && IsWhitespace(GetChar(pos)))
pos ++;
return TRUE;
}
bool wxSimpleHtmlParser::ReadString(wxString& str, bool eatIt)
{
int pos = m_pos;
if (GetChar(pos) == (int) '"')
{
pos ++;
while (!Eof(pos) && GetChar(pos) != (int) '"')
{
// TODO: how are quotes escaped in HTML?
str += (wxChar) GetChar(pos);
pos ++;
}
if (GetChar(pos) == (int) '"')
pos ++;
if (eatIt)
m_pos = pos;
DecodeSpecialChars(str);
return TRUE;
}
else
return FALSE;
}
bool wxSimpleHtmlParser::ReadWord(wxString& str, bool eatIt)
{
int pos = m_pos;
if (!IsAlpha(GetChar(pos)))
return FALSE;
str += (wxChar) GetChar(pos) ;
pos ++;
while (!Eof(pos) && IsWordChar(GetChar(pos)))
{
str += (wxChar) GetChar(pos);
pos ++;
}
if (eatIt)
m_pos = pos;
DecodeSpecialChars(str);
return TRUE;
}
bool wxSimpleHtmlParser::ReadNumber(wxString& str, bool eatIt)
{
int pos = m_pos;
if (!IsNumeric(GetChar(pos)))
return FALSE;
str += (wxChar) GetChar(pos) ;
pos ++;
while (!Eof(pos) && IsNumeric(GetChar(pos)))
{
str += (wxChar) GetChar(pos);
pos ++;
}
if (eatIt)
m_pos = pos;
DecodeSpecialChars(str);
return TRUE;
}
// Could be number, string, whatever, but read up until whitespace or end of tag (but not a quoted string)
bool wxSimpleHtmlParser::ReadLiteral(wxString& str, bool eatIt)
{
int pos = m_pos;
while (!Eof(pos) && !IsWhitespace(GetChar(pos)) && !IsTagEndBracket(GetChar(pos)) && GetChar(pos) != wxT('='))
{
str += GetChar(pos);
pos ++;
}
if (eatIt)
m_pos = pos;
DecodeSpecialChars(str);
return TRUE;
}
bool wxSimpleHtmlParser::IsComment()
{
return Matches(wxT("<!--"));
}
bool wxSimpleHtmlParser::IsDirective()
{
return Matches(wxT("<!"));
}
bool wxSimpleHtmlParser::IsXMLDeclaration()
{
return Matches(wxT("<?xml"));
}
bool wxSimpleHtmlParser::IsString()
{
return (GetChar(m_pos) == (int) '"') ;
}
bool wxSimpleHtmlParser::IsWord()
{
return (IsAlpha(GetChar(m_pos)));
}
bool wxSimpleHtmlParser::IsTagClose()
{
return Matches(wxT("</"));
}
bool wxSimpleHtmlParser::IsTagStartBracket(int ch)
{
return (ch == wxT('<'));
}
bool wxSimpleHtmlParser::IsTagEndBracket(int ch)
{
return (ch == wxT('>'));
}
bool wxSimpleHtmlParser::IsWhitespace(int ch)
{
return ((ch == 13) || (ch == 10) || (ch == 32) || (ch == (int) '\t')) ;
}
bool wxSimpleHtmlParser::IsAlpha(int ch)
{
return (wxIsalpha((wxChar) ch) != 0);
}
bool wxSimpleHtmlParser::IsWordChar(int ch)
{
return (wxIsalpha((wxChar) ch) != 0 || ch == wxT('-') || ch == wxT('_') || IsNumeric(ch));
}
bool wxSimpleHtmlParser::IsNumeric(int ch)
{
return (wxIsdigit((wxChar) ch) != 0 || ch == wxT('-') || ch == wxT('.')) ;
}
bool wxSimpleHtmlParser::IsCloseTagNeeded(const wxString &name)
{
if (name.IsSameAs(wxT("P"), FALSE)) // e.g <P>
return FALSE;
// ToDo add more items here.
return TRUE;
}
// Encode/Decode Special Characters.
// See here for the used table: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsql/ac_xml1_1nqk.asp
/* static */ void wxSimpleHtmlParser::DecodeSpecialChars(wxString &value)
{
// XML translation
value.Replace(wxT("&gt;"), wxT(">"), TRUE);
value.Replace(wxT("&lt;"), wxT("<"), TRUE);
value.Replace(wxT("&quot;"), wxT("\""), TRUE);
value.Replace(wxT("&apos;"), wxT("'"), TRUE);
value.Replace(wxT("&amp;"), wxT("&"), TRUE); // Note: do this as last to prevent replace problems.
}
/* static */ wxString wxSimpleHtmlParser::EncodeSpecialChars(const wxString &value)
{
wxString newvalue = value;
// XML translation
newvalue.Replace(wxT("&"), wxT("&amp;"), TRUE); // Note: do this as first to prevent replace problems.
newvalue.Replace(wxT(">"), wxT("&gt;"), TRUE);
newvalue.Replace(wxT("<"), wxT("&lt;"), TRUE);
newvalue.Replace(wxT("\""),wxT("&quot;"), TRUE);
newvalue.Replace(wxT("'"), wxT("&apos;"), TRUE);
return newvalue;
}
// Matches this string (case insensitive)
bool wxSimpleHtmlParser::Matches(const wxString& tok, bool eatIt)
{
wxString text(m_text.Mid(m_pos, tok.Length()));
bool success = (text.CmpNoCase(tok) == 0) ;
if (success && eatIt)
{
m_pos += tok.Length();
}
return success;
}
// Safe way of getting a character
int wxSimpleHtmlParser::GetChar(size_t i) const
{
if (i >= (size_t) m_length)
return -1;
return m_text[i];
}
void wxSimpleHtmlParser::Clear()
{
if (m_topLevel)
delete m_topLevel;
m_topLevel = NULL;
m_text = wxEmptyString;
m_pos = 0;
m_length = 0;
}
// Write this file
void wxSimpleHtmlParser::Write(wxOutputStream& stream)
{
if (m_topLevel)
m_topLevel->Write(stream);
}
bool wxSimpleHtmlParser::WriteFile(wxString& filename)
{
wxFileOutputStream fstream(filename);
if (fstream.Ok())
{
Write(fstream);
return TRUE;
}
else
return FALSE;
}
/*
* wxSimpleHtmlTag
* Representation of a tag or chunk of text
*/
wxSimpleHtmlTag::wxSimpleHtmlTag(const wxString& tagName, int tagType)
{
m_name = tagName;
m_type = tagType;
m_attributes = NULL;
m_children = NULL;
m_parent = NULL;
m_next = NULL;
}
wxSimpleHtmlTag::~wxSimpleHtmlTag()
{
ClearAttributes();
ClearChildren();
}
//// Operations
void wxSimpleHtmlTag::ClearAttributes()
{
if (m_attributes)
{
wxSimpleHtmlAttribute* attr = m_attributes;
while (attr)
{
wxSimpleHtmlAttribute* next = attr->m_next;
attr->m_next = NULL;
delete attr;
attr = next;
}
m_attributes = NULL;
}
}
wxSimpleHtmlAttribute* wxSimpleHtmlTag::FindAttribute(const wxString& name) const
{
wxSimpleHtmlAttribute* attr = m_attributes;
while (attr)
{
if (attr->GetName().CmpNoCase(name) == 0)
{
return attr;
}
attr = attr->m_next;
}
return NULL;
}
void wxSimpleHtmlTag::AppendAttribute(const wxString& name, const wxString& value)
{
wxSimpleHtmlAttribute* attr = new wxSimpleHtmlAttribute(name, value);
if (m_attributes)
{
// Find tail
wxSimpleHtmlAttribute* last = m_attributes;
while (last->m_next)
last = last->m_next;
last->m_next = attr;
}
else
m_attributes = attr;
}
void wxSimpleHtmlTag::ClearChildren()
{
if (m_children)
{
wxSimpleHtmlTag* child = m_children;
while (child)
{
wxSimpleHtmlTag* next = child->m_next;
child->m_next = NULL;
delete child;
child = next;
}
m_children = NULL;
}
}
void wxSimpleHtmlTag::RemoveChild(wxSimpleHtmlTag *remove)
{
if (m_children)
{
wxSimpleHtmlTag* child = m_children;
wxSimpleHtmlTag* prev = NULL;
while (child)
{
wxSimpleHtmlTag* next = child->m_next;
if (child == remove)
{
child->m_next = NULL;
delete child;
if (prev != NULL)
prev->m_next = next;
else
m_children = next;
return;
}
prev = child;
child = next;
}
}
}
void wxSimpleHtmlTag::AppendTag(wxSimpleHtmlTag* tag)
{
if (!tag)
return;
if (m_children)
{
// Find tail
wxSimpleHtmlTag* last = m_children;
while (last->m_next)
last = last->m_next;
last->m_next = tag;
}
else
{
m_children = tag;
}
tag->m_parent = this;
}
void wxSimpleHtmlTag::AppendTagAfterUs(wxSimpleHtmlTag* tag)
{
if (!tag)
return;
tag->m_parent = m_parent;
tag->m_next = m_next;
m_next = tag;
}
// Gets the text from this tag and its descendants
wxString wxSimpleHtmlTag::GetTagText()
{
wxString text;
if (m_children)
{
wxSimpleHtmlTag* tag = m_children;
while (tag)
{
text += tag->GetTagText();
tag = tag->m_next;
}
return text;
}
else if (GetType() == wxSimpleHtmlTag_Text)
return GetText();
else
return wxEmptyString;
}
int wxSimpleHtmlTag::GetAttributeCount() const
{
int count = 0;
wxSimpleHtmlAttribute* attr = m_attributes;
while (attr)
{
count ++;
attr = attr->m_next;
}
return count;
}
wxSimpleHtmlAttribute* wxSimpleHtmlTag::GetAttribute(int i) const
{
int count = 0;
wxSimpleHtmlAttribute* attr = m_attributes;
while (attr)
{
if (count == i)
return attr;
count ++;
attr = attr->m_next;
}
return NULL;
}
int wxSimpleHtmlTag::GetChildCount() const
{
int count = 0;
wxSimpleHtmlTag* tag = m_children;
while (tag)
{
count ++;
tag = tag->m_next;
}
return count;
}
bool wxSimpleHtmlTag::HasAttribute(const wxString& name, const wxString& value) const
{
wxSimpleHtmlAttribute* attr = FindAttribute(name);
return (attr && (attr->GetValue().CmpNoCase(value) == 0)) ;
}
bool wxSimpleHtmlTag::HasAttribute(const wxString& name) const
{
return FindAttribute(name) != NULL ;
}
bool wxSimpleHtmlTag::GetAttributeValue(wxString& value, const wxString& attrName)
{
wxSimpleHtmlAttribute* attr = FindAttribute(attrName);
if (attr)
{
value = attr->GetValue();
return TRUE;
}
else
return FALSE;
}
// Search forward from this tag until we find a tag with this name & attribute
wxSimpleHtmlTag* wxSimpleHtmlTag::FindTag(const wxString& tagName, const wxString& attrName)
{
wxSimpleHtmlTag* tag = m_next;
while (tag)
{
if (tag->NameIs(tagName) && (attrName.IsEmpty() || tag->FindAttribute(attrName)))
return tag;
tag = tag->m_next;
}
return NULL;
}
bool wxSimpleHtmlTag::FindTextUntilTagClose(wxString& text, const wxString& tagName)
{
wxSimpleHtmlTag* tag = this;
while (tag)
{
if (tag->GetType() == wxSimpleHtmlTag_Close && tag->NameIs(tagName))
return TRUE;
if (tag->GetType() == wxSimpleHtmlTag_Text)
text += tag->GetText();
tag = tag->m_next;
}
return TRUE;
}
wxSimpleHtmlTag* wxSimpleHtmlTag::GetChild(int i) const
{
int count = 0;
wxSimpleHtmlTag* tag = m_children;
while (tag)
{
if (count == i)
return tag;
count ++;
tag = tag->m_next;
}
return NULL;
}
void wxSimpleHtmlTag::Write(wxOutputStream& stream)
{
// Some helpers to layout the open and close tags.
static bool sbUseTab = TRUE;
static size_t snTabLevel = 0;
#if 0 // Enable if no tabs should be used to align the tags.
snTabLevel = 0;
#endif
// Handle the different types of tags we can write.
switch (GetType())
{
case wxSimpleHtmlTag_Text:
{
stream << wxSimpleHtmlParser::EncodeSpecialChars(m_text);
break;
}
case wxSimpleHtmlTag_Open:
{
size_t tab;
for(tab = 0; tab < snTabLevel; tab++)
stream << wxT("\t");
stream << wxT("<") << wxSimpleHtmlParser::EncodeSpecialChars(m_name);
if (GetAttributeCount() > 0)
stream << wxT(" ");
int i;
for (i = 0; i < GetAttributeCount(); i++)
{
wxSimpleHtmlAttribute* attr = GetAttribute(i);
attr->Write(stream);
if (i < GetAttributeCount() - 1)
stream << wxT(" ");
}
if(!m_children)
{
sbUseTab = FALSE; // We're putting the open a close tag on the same line,
// so we don't wan't any tabs
stream << wxT(">");
}
else
{
// sbUseTab = TRUE;
stream << wxT(">\n");
}
snTabLevel++;
break;
}
case wxSimpleHtmlTag_Directive:
{
stream << wxT("<!") << wxSimpleHtmlParser::EncodeSpecialChars(m_name) << wxT(" ");
int i;
for (i = 0; i < GetAttributeCount(); i++)
{
wxSimpleHtmlAttribute* attr = GetAttribute(i);
attr->Write(stream);
if (i < GetAttributeCount() - 1)
stream << wxT(" ");
}
stream << wxT(">\n");
break;
}
case wxSimpleHtmlTag_XMLDeclaration:
{
stream << wxT("<?") << wxSimpleHtmlParser::EncodeSpecialChars(m_name) << wxT(" ");
int i;
for (i = 0; i < GetAttributeCount(); i++)
{
wxSimpleHtmlAttribute* attr = GetAttribute(i);
attr->Write(stream);
if (i < GetAttributeCount() - 1)
stream << wxT(" ");
}
stream << wxT(">\n\n");
break;
}
case wxSimpleHtmlTag_Close:
{
if (snTabLevel) // Safety to prevent going around...
snTabLevel--; // Reduce the tab level
if (sbUseTab) // Do we write the open tag and close tag on a other line?
{
size_t tab;
for(tab = 0; tab < snTabLevel; tab++)
stream << wxT("\t");
}
stream << wxT("</") << wxSimpleHtmlParser::EncodeSpecialChars(m_name) << wxT(">\n");
sbUseTab = TRUE;
break;
}
default:
{
break;
}
}
wxSimpleHtmlTag* tag = m_children;
while (tag)
{
tag->Write(stream);
tag = tag->m_next;
}
}
void wxSimpleHtmlAttribute::Write(wxOutputStream& stream)
{
if (m_value.IsEmpty())
stream << wxSimpleHtmlParser::EncodeSpecialChars(m_name);
else
{
stream << wxSimpleHtmlParser::EncodeSpecialChars(m_name);
stream << wxT("=\"");
stream << wxSimpleHtmlParser::EncodeSpecialChars(m_value);
stream << wxT("\"");
}
}

View File

@@ -0,0 +1,277 @@
/////////////////////////////////////////////////////////////////////////////
// Name: htmlparser.cpp
// Purpose: Simple HTML parser
// Author: Julian Smart
// Modified by:
// Created: 2002-09-25
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _HTMLPARSER_H_
#define _HTMLPARSER_H_
#ifdef __GNUG__
#pragma interface "htmlparser.h"
#endif
//#include "wx/module.h"
#include "wx/stream.h"
/*
* wxSimpleHtmlAttribute
* Representation of an attribute
*/
class wxSimpleHtmlAttribute
{
friend class wxSimpleHtmlTag;
public:
wxSimpleHtmlAttribute(const wxString& name, const wxString& value)
{
m_name = name; m_value = value; m_next = NULL;
}
//// Operations
// Write this attribute
void Write(wxOutputStream& stream);
//// Accessors
const wxString& GetName() const { return m_name; }
const wxString& GetValue() const { return m_value; }
void SetName(const wxString& name) { m_name = name; }
void SetValue(const wxString& value) { m_value = value; }
wxSimpleHtmlAttribute* GetNextAttribute() { return m_next; }
void SetNextAttribute(wxSimpleHtmlAttribute* attr) { m_next = attr; }
bool HasName(const wxString& name) const { return (0 == m_name.CmpNoCase(name)); }
bool HasValue(const wxString& val) const { return (0 == m_value.CmpNoCase(val)); }
private:
wxString m_name;
wxString m_value;
wxSimpleHtmlAttribute* m_next;
};
/*
* wxSimpleHtmlTag
* Representation of a tag or chunk of text
*/
enum { wxSimpleHtmlTag_Text, wxSimpleHtmlTag_TopLevel, wxSimpleHtmlTag_Open, wxSimpleHtmlTag_Close, wxSimpleHtmlTag_Directive, wxSimpleHtmlTag_XMLDeclaration };
class wxSimpleHtmlTag
{
public:
wxSimpleHtmlTag(const wxString& tagName, int tagType);
~wxSimpleHtmlTag();
//// Operations
void ClearAttributes();
wxSimpleHtmlAttribute* FindAttribute(const wxString& name) const ;
void AppendAttribute(const wxString& name, const wxString& value);
void ClearChildren();
// Remove 1 tag from the child list.
void RemoveChild(wxSimpleHtmlTag *remove);
// Appaned tag to the end of the child list.
void AppendTag(wxSimpleHtmlTag* tag);
// Insert tag after ourself in the parents child list.
void AppendTagAfterUs(wxSimpleHtmlTag* tag);
// Write this tag
void Write(wxOutputStream& stream);
// Gets the text from this tag and its descendants
wxString GetTagText();
//// Accessors
const wxString& GetName() const { return m_name; }
void SetName(const wxString& name) { m_name = name; }
int GetType() const { return m_type; }
void SetType(int t) { m_type = t; }
// If type is wxSimpleHtmlTag_Text, m_text will contain some text.
const wxString& GetText() const { return m_text; }
void SetText(const wxString& text) { m_text = text; }
wxSimpleHtmlAttribute* GetFirstAttribute() { return m_attributes; }
void SetFirstAttribute(wxSimpleHtmlAttribute* attr) { m_attributes = attr; }
int GetAttributeCount() const ;
wxSimpleHtmlAttribute* GetAttribute(int i) const ;
wxSimpleHtmlTag* GetChildren() const { return m_children; }
void SetChildren(wxSimpleHtmlTag* children) { m_children = children; }
wxSimpleHtmlTag* GetParent() const { return m_parent; }
void SetParent(wxSimpleHtmlTag* parent) { m_parent = parent; }
int GetChildCount() const;
wxSimpleHtmlTag* GetChild(int i) const;
wxSimpleHtmlTag* GetNext() const { return m_next; }
//// Convenience accessors & search functions
bool NameIs(const wxString& name) { return (m_name.CmpNoCase(name) == 0); }
bool HasAttribute(const wxString& name, const wxString& value) const;
bool HasAttribute(const wxString& name) const;
bool GetAttributeValue(wxString& value, const wxString& attrName);
// Search forward from this tag until we find a tag with this name & optionally attribute
wxSimpleHtmlTag* FindTag(const wxString& tagName, const wxString& attrName = wxEmptyString);
// Gather the text until we hit the given close tag
bool FindTextUntilTagClose(wxString& text, const wxString& tagName);
private:
wxString m_name;
int m_type;
wxString m_text;
wxSimpleHtmlAttribute* m_attributes;
// List of children
wxSimpleHtmlTag* m_children;
wxSimpleHtmlTag* m_next; // Next sibling
wxSimpleHtmlTag* m_parent;
};
/*
* wxSimpleHtmlParser
* Simple HTML parser, for such tasks as scanning HTML for keywords, contents, etc.
*/
class wxSimpleHtmlParser : public wxObject
{
public:
wxSimpleHtmlParser();
~wxSimpleHtmlParser();
//// Operations
bool ParseFile(const wxString& filename);
bool ParseString(const wxString& str);
void Clear();
// Write this file
void Write(wxOutputStream& stream);
bool WriteFile(wxString& filename);
//// Helpers
// Main recursive parsing function
bool ParseHtml(wxSimpleHtmlTag* parent);
wxSimpleHtmlTag* ParseTagHeader();
wxSimpleHtmlTag* ParseTagClose();
bool ParseAttributes(wxSimpleHtmlTag* tag);
wxSimpleHtmlTag* ParseDirective(); // e.g. <!DOCTYPE ....>
wxSimpleHtmlTag* ParseXMLDeclaration(); // e.g. <?xml .... ?>
bool ParseComment(); // Throw away comments
// Plain text, up until an angled bracket
bool ParseText(wxString& text);
bool EatWhitespace(); // Throw away whitespace
bool EatWhitespace(int& pos); // Throw away whitespace: using 'pos'
bool ReadString(wxString& str, bool eatIt = FALSE);
bool ReadWord(wxString& str, bool eatIt = FALSE);
bool ReadNumber(wxString& str, bool eatIt = FALSE);
// Could be number, string, whatever, but read up until whitespace.
bool ReadLiteral(wxString& str, bool eatIt = FALSE);
bool IsComment();
bool IsDirective();
bool IsXMLDeclaration();
bool IsString();
bool IsWord();
bool IsTagClose();
bool IsTagStartBracket(int ch);
bool IsTagEndBracket(int ch);
bool IsWhitespace(int ch);
bool IsAlpha(int ch);
bool IsWordChar(int ch);
bool IsNumeric(int ch);
// Check if a specific tag needs a close tag. If not this function should return FALSE.
// If no close tag is needed the result will be that the tag will be insert in a none
// hierarchical way. i.e. if the function would return FALSE all the time we would get
// a flat list of all tags (like it used to be previously).
virtual bool IsCloseTagNeeded(const wxString &name);
// Encode/Decode Special Characters like:
// > Begins a tag. &gt;
// < Ends a tag. &lt;
// " Quotation mark. &quot;
// ' Apostrophe. &apos;
// & Ampersand. &amp;
static void DecodeSpecialChars(wxString &value);
static wxString EncodeSpecialChars(const wxString &value);
// Matches this string (case insensitive)
bool Matches(const wxString& tok, bool eatIt = FALSE) ;
bool Eof() const { return (m_pos >= m_length); }
bool Eof(int pos) const { return (pos >= m_length); }
void SetPosition(int pos) { m_pos = pos; }
//// Accessors
wxSimpleHtmlTag* GetTopLevelTag() const { return m_topLevel; }
// Safe way of getting a character
int GetChar(size_t i) const;
private:
wxSimpleHtmlTag* m_topLevel;
int m_pos; // Position in string
int m_length; // Length of string
wxString m_text; // The actual text
};
/*
* wxSimpleHtmlTagSpec
* Describes a tag, and what type it is.
* wxSimpleHtmlModule will initialise/cleanup a list of these, one per tag type
*/
#if 0
class wxSimpleHtmlTagSpec : public wxObject
{
public:
wxSimpleHtmlTagSpec(const wxString& name, int type);
//// Operations
static void AddTagSpec(wxSimpleHtmlTagSpec* spec);
static void Clear();
//// Accessors
const wxString& GetName() const { return m_name; }
int GetType() const { return m_type; }
private:
wxString m_name;
int m_type;
static wxList* sm_tagSpecs;
};
/*
* wxSimpleHtmlModule
* Responsible for init/cleanup of appropriate data structures
*/
class wxSimpleHtmlModule : public wxModule
{
DECLARE_DYNAMIC_CLASS(wxSimpleHtmlModule)
public:
wxSimpleHtmlModule() {};
bool OnInit() ;
void OnExit() ;
};
#endif
#endif

View File

@@ -0,0 +1,521 @@
/////////////////////////////////////////////////////////////////////////////
// Name: mainframe.cpp
// Purpose: Main frame
// Author: Julian Smart
// Modified by:
// Created: 2002-09-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#include "wx/wx.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/html/htmlwin.h"
#include "wx/notebook.h"
#include "wx/splitter.h"
#include "wx/clipbrd.h"
#include "wx/cshelp.h"
#include "wxconfigtool.h"
#include "mainframe.h"
#include "appsettings.h"
#include "symbols.h"
#include "configtree.h"
#include "propeditor.h"
#include "configtooldoc.h"
#include "configtoolview.h"
#include "bitmaps/wxconfigtool.xpm"
#include "bitmaps/copy.xpm"
#include "bitmaps/cut.xpm"
#include "bitmaps/paste.xpm"
#include "bitmaps/open.xpm"
#include "bitmaps/save.xpm"
#include "bitmaps/print.xpm"
#include "bitmaps/new.xpm"
#include "bitmaps/help.xpm"
#include "bitmaps/undo.xpm"
#include "bitmaps/redo.xpm"
#include "bitmaps/helpcs.xpm"
IMPLEMENT_CLASS(ctMainFrame, wxDocParentFrame)
BEGIN_EVENT_TABLE(ctMainFrame, wxDocParentFrame)
EVT_CLOSE(ctMainFrame::OnCloseWindow)
EVT_MENU(wxID_ABOUT, ctMainFrame::OnAbout)
EVT_MENU(wxID_OPEN, ctMainFrame::OnOpen)
EVT_MENU(wxID_NEW, ctMainFrame::OnNew)
EVT_MENU(wxID_EXIT, ctMainFrame::OnExit)
EVT_MENU(ctID_SETTINGS, ctMainFrame::OnSettings)
EVT_MENU(ctID_SHOW_TOOLBAR, ctMainFrame::OnShowToolbar)
EVT_MENU(wxID_HELP, ctMainFrame::OnHelp)
EVT_MENU(ctID_REFERENCE_CONTENTS, ctMainFrame::OnReferenceHelp)
EVT_MENU(wxID_HELP_CONTEXT, ctMainFrame::OnContextHelp)
EVT_UPDATE_UI(ctID_ADD_ITEM_CHECKBOX, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_ADD_ITEM_RADIOBUTTON, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_ADD_ITEM_GROUP, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_ADD_ITEM_CHECK_GROUP, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_ADD_ITEM_RADIO_GROUP, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_ADD_ITEM_STRING, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_DELETE_ITEM, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_RENAME_ITEM, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(wxID_COPY, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(wxID_CUT, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(wxID_PASTE, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_ITEM_HELP, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_ADD_CUSTOM_PROPERTY, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_EDIT_CUSTOM_PROPERTY, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_DELETE_CUSTOM_PROPERTY, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_SAVE_SETUP_FILE, ctMainFrame::OnUpdateDisable)
EVT_UPDATE_UI(ctID_SAVE_CONFIGURE_COMMAND, ctMainFrame::OnUpdateDisable)
END_EVENT_TABLE()
// Define my frame constructor
ctMainFrame::ctMainFrame(wxDocManager *manager, wxFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size,
long style):
wxDocParentFrame(manager, parent, id, title, pos, size, style)
{
m_document = NULL;
m_editMenu = NULL;
m_configurePage = NULL;
m_setupPage = NULL;
m_mainNotebook = NULL;
m_treeSplitterWindow = new wxSplitterWindow(this, -1, wxDefaultPosition, wxSize(400, 300),
wxSP_3DSASH|wxSP_3DBORDER);
m_configTreeCtrl = new ctConfigTreeCtrl(m_treeSplitterWindow, -1, wxDefaultPosition, wxDefaultSize,
wxTR_HAS_BUTTONS|wxNO_BORDER);
m_mainNotebook = new wxNotebook(m_treeSplitterWindow, -1, wxDefaultPosition, wxSize(300, 300));
m_propertyEditor = new ctPropertyEditor(m_mainNotebook, -1, wxDefaultPosition, wxSize(300, 200),
wxNO_BORDER);
m_setupPage = new ctOutputWindow(m_mainNotebook, -1, wxDefaultPosition, wxSize(300, 200),
wxNO_BORDER);
m_configurePage = new ctOutputWindow(m_mainNotebook, -1, wxDefaultPosition, wxSize(300, 200),
wxNO_BORDER);
m_mainNotebook->AddPage(m_propertyEditor, _T("Properties"));
m_mainNotebook->AddPage(m_setupPage, _T("setup.h"));
m_mainNotebook->AddPage(m_configurePage, _T("configure"));
// Need to do this afterwards since wxWin sets the XP background
// in AddPage
m_propertyEditor->GetDescriptionWindow()->SetBackgroundColour(ctDESCRIPTION_BACKGROUND_COLOUR);
int sashPos = wxGetApp().GetSettings().m_mainSashSize;
m_treeSplitterWindow->SplitVertically(m_configTreeCtrl, m_mainNotebook, sashPos);
SetIcon(wxIcon(wxconfigtool_xpm));
CreateStatusBar(2);
wxMenuBar* menuBar = CreateMenuBar();
SetMenuBar(menuBar);
CreateToolBar(wxNO_BORDER|wxTB_FLAT|wxTB_HORIZONTAL);
InitToolBar(GetToolBar());
if (wxGetApp().GetSettings().m_showToolBar)
{
menuBar->Check(ctID_SHOW_TOOLBAR, TRUE);
}
else
{
menuBar->Check(ctID_SHOW_TOOLBAR, FALSE);
GetToolBar()->Show(FALSE);
ResizeFrame();
}
}
void ctMainFrame::OnCloseWindow(wxCloseEvent& event)
{
if (GetDocument())
{
if (!GetDocument()->DeleteAllViews() && event.CanVeto())
{
event.Veto();
return;
}
}
Show(FALSE);
if (IsMaximized())
wxGetApp().GetSettings().m_frameStatus = ctSHOW_STATUS_MAXIMIZED ;
else if (IsIconized())
wxGetApp().GetSettings().m_frameStatus = ctSHOW_STATUS_MINIMIZED ;
else
wxGetApp().GetSettings().m_frameStatus = ctSHOW_STATUS_NORMAL ;
// Must delete this now since the DLL loading library will be
// uninitialised by the time the app object is deleted
wxGetApp().ClearHelpControllers();
if (!IsMaximized() && !IsIconized())
{
wxGetApp().GetSettings().m_frameSize = GetRect();
wxGetApp().GetSettings().m_mainSashSize = m_treeSplitterWindow->GetSashPosition();
}
Destroy();
}
void ctMainFrame::OnAbout(wxCommandEvent& event)
{
wxString msg = wxGetApp().GetSettings().GetAppName() + wxT(" (c) Julian Smart");
wxString caption = wxT("About ") + wxGetApp().GetSettings().GetAppName();
wxMessageBox(msg, caption, wxID_OK|wxICON_INFORMATION);
}
void ctMainFrame::OnOpen(wxCommandEvent& event)
{
wxGetApp().GetDocManager()->OnFileOpen(event);
}
void ctMainFrame::OnNew(wxCommandEvent& event)
{
wxGetApp().GetDocManager()->OnFileNew(event);
}
void ctMainFrame::OnExit(wxCommandEvent& event)
{
Close();
}
void ctMainFrame::OnSettings(wxCommandEvent& event)
{
wxGetApp().GetSettings().ShowSettingsDialog();
}
void ctMainFrame::InitToolBar(wxToolBar* toolBar)
{
toolBar->SetHelpText(wxT("The toolbar gives you easy access to commonly used commands."));
// Set up toolbar
wxBitmap toolBarBitmaps[20];
toolBarBitmaps[0] = wxBitmap(new_xpm);
toolBarBitmaps[1] = wxBitmap(open_xpm);
toolBarBitmaps[2] = wxBitmap(save_xpm);
toolBarBitmaps[3] = wxBitmap(copy_xpm);
toolBarBitmaps[4] = wxBitmap(cut_xpm);
toolBarBitmaps[5] = wxBitmap(paste_xpm);
toolBarBitmaps[6] = wxBitmap(print_xpm);
toolBarBitmaps[7] = wxBitmap(help_xpm);
toolBarBitmaps[10] = wxBitmap(undo_xpm);
toolBarBitmaps[11] = wxBitmap(redo_xpm);
toolBarBitmaps[12] = wxBitmap(help_xpm);
toolBarBitmaps[13] = wxBitmap(helpcs_xpm);
toolBar->AddTool(wxID_NEW, toolBarBitmaps[0], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("New project"));
toolBar->AddTool(wxID_OPEN, toolBarBitmaps[1], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Open project"));
toolBar->AddTool(wxID_SAVE, toolBarBitmaps[2], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Save project"));
toolBar->AddSeparator();
toolBar->AddTool(wxID_CUT, toolBarBitmaps[4], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Cut"));
toolBar->AddTool(wxID_COPY, toolBarBitmaps[3], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Copy"));
toolBar->AddTool(wxID_PASTE, toolBarBitmaps[5], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Paste"));
toolBar->AddSeparator();
toolBar->AddTool(wxID_UNDO, toolBarBitmaps[10], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Undo"));
toolBar->AddTool(wxID_REDO, toolBarBitmaps[11], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Redo"));
toolBar->AddSeparator();
toolBar->AddTool(ctID_ITEM_HELP, toolBarBitmaps[12], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Show help for this option"));
toolBar->AddTool(wxID_HELP_CONTEXT, toolBarBitmaps[13], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Show help on the clicked item"));
// after adding the buttons to the toolbar, must call Realize() to reflect
// the changes
toolBar->Realize();
}
wxMenuBar* ctMainFrame::CreateMenuBar()
{
// Make a menubar
wxMenu *fileMenu = new wxMenu;
wxGetApp().GetFileHistory().UseMenu(fileMenu);
fileMenu->Append(wxID_NEW, wxT("&New...\tCtrl+N"), wxT("Create a new settings document"));
fileMenu->Append(wxID_OPEN, wxT("&Open...\tCtrl+O"), wxT("Open a settings document"));
fileMenu->Append(wxID_CLOSE, wxT("&Close\tCtrl+W"), wxT("Close the current settings document"));
fileMenu->AppendSeparator();
fileMenu->Append(wxID_SAVE, wxT("&Save\tCtrl+S"), wxT("Save the settings document"));
fileMenu->Append(wxID_SAVEAS, wxT("&Save As..."), wxT("Save the settings document under a new filename"));
fileMenu->AppendSeparator();
fileMenu->Append(ctID_SAVE_SETUP_FILE, wxT("Save Setup.&h...\tCtrl+H"), wxT("Save the setup.h file"));
fileMenu->Append(ctID_SAVE_CONFIGURE_COMMAND, wxT("Save Configure Script...\tCtrl+G"), wxT("Save the configure script file"));
fileMenu->AppendSeparator();
fileMenu->Append(wxID_EXIT, wxT("E&xit\tAlt+F4"), wxT("Exit the application"));
wxGetApp().GetDocManager()->FileHistoryUseMenu(fileMenu);
wxMenu *editMenu = new wxMenu;
editMenu->Append(wxID_UNDO, _("&Undo\tCtrl+Z"));
editMenu->Append(wxID_REDO, _("&Redo\tCtrl+Y"));
editMenu->AppendSeparator();
editMenu->Append(wxID_COPY, _("&Copy\tCtrl+C"));
editMenu->Append(wxID_CUT, _("Cu&t\tCtrl+X"));
editMenu->Append(wxID_PASTE, _("&Paste\tCtrl+V"));
editMenu->AppendSeparator();
wxMenu* itemMenu = new wxMenu;
itemMenu->Append(ctID_ADD_ITEM_CHECKBOX, _("Add &Checkbox Option"), _("Add a checkbox configuration option"));
itemMenu->Append(ctID_ADD_ITEM_RADIOBUTTON, _("Add &Radio Button Option"), _("Add a radio button configuration option"));
// TODO. However we can also simply use custom properties;
// but then the C++ code has to be special-cased.
// itemMenu->Append(ctID_ADD_ITEM_STRING, _("Add &String Option"), _("Add a string configuration option"));
itemMenu->Append(ctID_ADD_ITEM_GROUP, _("Add &Group Option"), _("Add a group configuration option"));
itemMenu->Append(ctID_ADD_ITEM_CHECK_GROUP, _("Add Chec&k Group Option"), _("Add a check group configuration option"));
itemMenu->Append(ctID_ADD_ITEM_RADIO_GROUP, _("Add Rad&io Group Option"), _("Add a radio group configuration option"));
editMenu->Append(ctID_ADD_ITEM, wxT("Add &Option"), itemMenu, _("Add a configuration option"));
editMenu->AppendSeparator();
wxMenu* propertyMenu = new wxMenu;
propertyMenu->Append(ctID_ADD_CUSTOM_PROPERTY, _("&Add Custom Property"), _("Adds a custom property to the current option"));
propertyMenu->Append(ctID_EDIT_CUSTOM_PROPERTY, _("&Edit Custom Property"), _("Edits the currently selected custom property"));
propertyMenu->Append(ctID_DELETE_CUSTOM_PROPERTY, _("&Delete Custom Property"), _("Deletes the currently selected custom property"));
editMenu->Append(ctID_CUSTOM_PROPERTY, _("Custom P&roperty"), propertyMenu, _("Custom property commands"));
editMenu->AppendSeparator();
editMenu->Append(ctID_DELETE_ITEM, _("&Delete Option"), _("Delete a configuration option"));
editMenu->Append(ctID_RENAME_ITEM, _("&Rename Option"), _("Rename a configuration option"));
// Save for the command processor.
m_editMenu = editMenu;
wxMenu *viewMenu = new wxMenu;
viewMenu->Append(ctID_SHOW_TOOLBAR, wxT("Show &Toolbar"), wxT("Toggle the toolbar on and off"),
wxITEM_CHECK);
viewMenu->Append(ctID_SETTINGS, wxT("&Settings...\tCtrl+T"), wxT("Show application settings"));
wxMenu *helpMenu = new wxMenu;
helpMenu->Append(wxID_HELP, wxT("&Help Contents"), wxT("Show Configuration Tool help"));
helpMenu->Append(ctID_REFERENCE_CONTENTS, wxT("&wxWindows Help Contents"), wxT("Show wxWindows reference"));
helpMenu->AppendSeparator();
helpMenu->Append(ctID_ITEM_HELP, wxT("&Configuration Option Help\tF1"), wxT("Show help for the selected option"));
helpMenu->Append(wxID_HELP_CONTEXT, wxT("&What's this?"), wxT("Show help on the clicked item"));
helpMenu->AppendSeparator();
helpMenu->Append(wxID_ABOUT, wxT("&About..."), wxT("Show details about this application"));
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(fileMenu, wxT("&File"));
menuBar->Append(editMenu, wxT("&Edit"));
menuBar->Append(viewMenu, wxT("&View"));
menuBar->Append(helpMenu, wxT("&Help"));
{
wxConfig config(wxGetApp().GetSettings().GetAppName(), wxT("wxWindows"));
config.SetPath(wxT("FileHistory/"));
wxGetApp().GetDocManager()->FileHistoryLoad(config);
}
return menuBar;
}
/// Handles the Show Toolbar menu event.
void ctMainFrame::OnShowToolbar(wxCommandEvent& event)
{
wxGetApp().GetSettings().m_showToolBar = !wxGetApp().GetSettings().m_showToolBar;
GetToolBar()->Show(wxGetApp().GetSettings().m_showToolBar);
ResizeFrame();
}
/// Handles the Help Contents menu event.
void ctMainFrame::OnHelp(wxCommandEvent& event)
{
wxGetApp().GetHelpController().DisplayContents();
}
/// Handles context help
void ctMainFrame::OnContextHelp(wxCommandEvent& event)
{
wxContextHelp contextHelp;
}
/// Handles the Help Contents menu event for the reference manual.
void ctMainFrame::OnReferenceHelp(wxCommandEvent& event)
{
wxGetApp().GetReferenceHelpController().DisplayContents();
}
/// Resizes the main frame according to the
/// state of the toolbar
void ctMainFrame::ResizeFrame()
{
PositionToolBar();
wxSizeEvent event(GetSize(), GetId());
this->ProcessEvent(event);
}
/// Update the frame title.
void ctMainFrame::UpdateFrameTitle()
{
// TODO
}
// General disabler
void ctMainFrame::OnUpdateDisable(wxUpdateUIEvent& event)
{
event.Enable( FALSE );
}
/*!
* ctOutputWindow represents a page showing a setup.h file or config command.
*/
IMPLEMENT_CLASS(ctOutputWindow, wxPanel)
BEGIN_EVENT_TABLE(ctOutputWindow, wxPanel)
EVT_BUTTON(wxID_COPY, ctOutputWindow::OnCopyToClipboard)
EVT_BUTTON(wxID_SAVE, ctOutputWindow::OnSaveText)
EVT_BUTTON(ctID_REGENERATE, ctOutputWindow::OnRegenerate)
EVT_UPDATE_UI(wxID_SAVE, ctOutputWindow::OnUpdateSaveText)
EVT_UPDATE_UI(ctID_REGENERATE, ctOutputWindow::OnUpdateRegenerate)
EVT_UPDATE_UI(wxID_COPY, ctOutputWindow::OnUpdateCopy)
END_EVENT_TABLE()
ctOutputWindow::ctOutputWindow(wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style):
wxPanel(parent, id, pos, size, style)
{
m_codeCtrl = NULL;
m_filenameCtrl = NULL;
m_doc = NULL;
CreateWindows();
}
ctOutputWindow::~ctOutputWindow()
{
}
/// Initialise the windows.
void ctOutputWindow::CreateWindows()
{
wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer *item2 = new wxBoxSizer( wxHORIZONTAL );
item0->Add( item2, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5 );
wxButton *item4 = new wxButton( this, wxID_COPY, _("&Copy"), wxDefaultPosition, wxDefaultSize, 0 );
item2->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM|wxRIGHT, 5 );
item4->SetHelpText(_("Copies the selection or whole file to the clipboard."));
wxButton *item5 = new wxButton( this, ctID_REGENERATE, _("Re&generate"), wxDefaultPosition, wxDefaultSize, 0 );
item2->Add( item5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
item5->SetHelpText(_("Regenerates the code."));
#if 0
m_filenameCtrl = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTE_READONLY);
item2->Add( m_filenameCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_filenameCtrl->SetHelpText(_("Shows the filename where the code is being saved."));
#else
m_filenameCtrl = NULL;
#endif
// The code editor
m_codeCtrl = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxSize(100, 100), wxTE_RICH|wxTE_MULTILINE|wxSUNKEN_BORDER);
item0->Add( m_codeCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
SetAutoLayout( TRUE );
SetSizer( item0 );
}
/// Copies the text to the clipboard.
void ctOutputWindow::OnCopyToClipboard(wxCommandEvent& event)
{
// Try to copy the selection first
long int selFrom, selTo;
m_codeCtrl->GetSelection(& selFrom, & selTo);
if (selFrom != selTo)
{
m_codeCtrl->Copy();
return;
}
// Copy the whole amount
if (!wxTheClipboard->Open())
{
wxMessageBox(_("Sorry, could not open the clipboard."), _("Clipboard problem"), wxICON_EXCLAMATION|wxOK);
return;
}
wxString value(m_codeCtrl->GetValue());
#ifdef __WXMSW__
value.Replace(_T("\n"), _T("\r\n"));
#endif
wxTextDataObject *data = new wxTextDataObject( value );
if (!wxTheClipboard->SetData( data ))
{
wxTheClipboard->Close();
wxMessageBox(_("Sorry, could not copy to the clipboard."), _("Clipboard problem"), wxICON_EXCLAMATION|wxOK);
}
else
{
wxTheClipboard->Close();
}
}
/// Sets the code in the text control.
void ctOutputWindow::SetText(const wxString& text)
{
if (m_codeCtrl)
m_codeCtrl->SetValue(text);
}
/// Sets the filename.
void ctOutputWindow::SetFilename(const wxString& filename)
{
if (m_filenameCtrl)
m_filenameCtrl->SetValue(filename);
}
/// Saves the file.
void ctOutputWindow::OnSaveText(wxCommandEvent& event)
{
if (m_codeCtrl->IsModified())
{
wxString filename(m_filenameCtrl->GetValue());
if (!filename.IsEmpty())
{
m_codeCtrl->SaveFile(filename);
m_codeCtrl->DiscardEdits();
}
}
}
void ctOutputWindow::OnUpdateSaveText(wxUpdateUIEvent& event)
{
event.Enable(m_doc && m_codeCtrl && m_codeCtrl->IsModified());
}
void ctOutputWindow::OnRegenerate(wxCommandEvent& event)
{
if (m_doc)
{
ctConfigToolView* view = (ctConfigToolView*) m_doc->GetFirstView();
view->RegenerateSetup();
}
}
void ctOutputWindow::OnUpdateRegenerate(wxUpdateUIEvent& event)
{
event.Enable( m_doc != NULL );
}
void ctOutputWindow::OnUpdateCopy(wxUpdateUIEvent& event)
{
event.Enable( m_doc != NULL );
}

View File

@@ -0,0 +1,199 @@
/////////////////////////////////////////////////////////////////////////////
// Name: mainframe.h
// Purpose: Main frame class
// Author: Julian Smart
// Modified by:
// Created: 2002-09-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _AP_MAINFRAME_H_
#define _AP_MAINFRAME_H_
#include "wx/imaglist.h"
#include "wx/docview.h"
class WXDLLEXPORT wxHtmlWindow;
class WXDLLEXPORT wxSplitterWindow;
class WXDLLEXPORT wxNotebookEvent;
class ctConfigTreeCtrl;
class ctPropertyEditor;
class ctOutputWindow;
/*!
* \brief The main window of the application.
*/
class ctMainFrame: public wxDocParentFrame
{
DECLARE_CLASS(ctMainFrame)
public:
/// Constructor.
ctMainFrame(wxDocManager *manager, wxFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style);
// Event handlers
/// Handles the close window event.
void OnCloseWindow(wxCloseEvent& event);
/// Handles the About menu event.
void OnAbout(wxCommandEvent& event);
/// Handles the frame activation event.
void OnActivate(wxActivateEvent& event);
/// Handles the File Open menu event.
void OnOpen(wxCommandEvent& event);
/// Handles the File New menu event.
void OnNew(wxCommandEvent& event);
/// Handles the Exit menu event.
void OnExit(wxCommandEvent& event);
/// Handles the Settings menu event.
void OnSettings(wxCommandEvent& event);
/// Handles the Show Toolbar menu event.
void OnShowToolbar(wxCommandEvent& event);
/// Handles the Help Contents menu event.
void OnHelp(wxCommandEvent& event);
/// Handles context help
void OnContextHelp(wxCommandEvent& event);
/// Handles the Help Contents menu event for the reference manual.
void OnReferenceHelp(wxCommandEvent& event);
/// General disabler
void OnUpdateDisable(wxUpdateUIEvent& event);
// Operations
/// Creates the main frame subwindows.
bool CreateWindows(wxWindow* parent);
/// Initialises the toolbar.
void InitToolBar(wxToolBar* toolbar);
/// Creates the menubar.
wxMenuBar* CreateMenuBar();
/// Resizes the main frame according to the
/// state of the toolbar
void ResizeFrame();
/// Update the frame title.
void UpdateFrameTitle();
// Accessors
/// Returns the tree control.
ctConfigTreeCtrl* GetConfigTreeCtrl() const { return m_configTreeCtrl; }
/// Returns the property editor window.
ctPropertyEditor* GetPropertyEditor() const { return m_propertyEditor; }
/// Returns the document for this frame.
ctConfigToolDoc* GetDocument() const { return m_document; }
/// Sets the document for this frame.
void SetDocument(ctConfigToolDoc* doc) { m_document = doc; }
/// Returns the edit menu.
wxMenu* GetEditMenu() const { return m_editMenu; }
/// Returns the setup page window
ctOutputWindow* GetSetupPage() const { return m_setupPage; }
/// Returns the configure page window
ctOutputWindow* GetConfigurePage() const { return m_configurePage; }
/// Returns the main notebook containing editor and text tabs
wxNotebook* GetMainNotebook() const { return m_mainNotebook; }
DECLARE_EVENT_TABLE()
protected:
wxImageList m_imageList;
/// The splitter between the tree and the property window.
wxSplitterWindow* m_treeSplitterWindow;
/// The config tree window.
ctConfigTreeCtrl* m_configTreeCtrl;
/// The property editor window.
ctPropertyEditor* m_propertyEditor;
/// The document for this frame.
ctConfigToolDoc* m_document;
/// The edit menu.
wxMenu* m_editMenu;
/// The notebook with property editor and setup.h/configure
/// views
wxNotebook* m_mainNotebook;
ctOutputWindow* m_setupPage;
ctOutputWindow* m_configurePage;
};
/*!
* ctOutputWindow represents a page showing a setup.h file or config command.
*/
class ctOutputWindow: public wxPanel
{
DECLARE_CLASS(ctOutputWindow)
public:
ctOutputWindow(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0);
~ctOutputWindow();
/// Initialise the windows.
void CreateWindows();
/// Copies the text to the clipboard.
void OnCopyToClipboard(wxCommandEvent& event);
void OnUpdateCopy(wxUpdateUIEvent& event);
/// Regenerates setup.h/configure command
void OnRegenerate(wxCommandEvent& event);
void OnUpdateRegenerate(wxUpdateUIEvent& event);
/// Saves the file.
void OnSaveText(wxCommandEvent& event);
void OnUpdateSaveText(wxUpdateUIEvent& event);
/// Sets the code in the text control.
void SetText(const wxString& text);
/// Sets the filename.
void SetFilename(const wxString& filename);
/// Sets the document
void SetDocument(ctConfigToolDoc* doc) { m_doc = doc; }
/// Get text control
wxTextCtrl* GetCodeCtrl() const { return m_codeCtrl; }
/// Get filename control
wxTextCtrl* GetFilenameCtrl() const { return m_filenameCtrl; }
protected:
wxTextCtrl* m_codeCtrl;
wxTextCtrl* m_filenameCtrl;
ctConfigToolDoc* m_doc;
DECLARE_EVENT_TABLE()
};
#endif
// _AP_MAINFRAME_H_

View File

@@ -0,0 +1,19 @@
#
# File: makefile.b32
# Author: Julian Smart
# Created: 1999
# Updated:
# Copyright:
#
# Makefile : Builds application for 32-bit BC++
WXDIR = $(WXWIN)
TARGET=wxconfigtool
OBJECTS = $(TARGET).obj wxconfigtool.obj appsettings.obj configitem.obj \
configitemselector.obj configtooldoc.obj configtoolview.obj configtree.obj \
custompropertydialog.obj htmlparser.obj mainframe.obj propeditor.obj \
property.obj settingsdialog.obj utils.obj
!include $(WXDIR)\src\makeprog.b32

View File

@@ -0,0 +1,19 @@
#
# File: makefile.g95
# Author: Julian Smart
# Created: 2003
# Updated:
# Copyright: (c) Julian Smart, 2003
#
# Makefile for wxWindows Configuration Tool (Cygwin/Mingw32).
WXDIR = ../../..
TARGET=wxconfigtool
OBJECTS = $(TARGET).o wxconfigtool.o appsettings.o configitem.o \
configitemselector.o configtooldoc.o configtoolview.o configtree.o \
custompropertydialog.o htmlparser.o mainframe.o propeditor.o \
property.o settingsdialog.o utils.o
include $(WXDIR)/src/makeprog.g95

View File

@@ -0,0 +1,27 @@
# makefile
CXXFLAGS = `wx-config --cxxflags`
LDFLAGS = `wx-config --libs`
PROGRAM = wxconfigtool
OBJECTS = $(TARGET).o wxconfigtool.o appsettings.o configitem.o \
configitemselector.o configtooldoc.o configtoolview.o configtree.o \
custompropertydialog.o htmlparser.o mainframe.o propeditor.o \
property.o settingsdialog.o utils.o
# implementation
.SUFFIXES: .o .cpp
.cpp.o :
$(CXX) -c $(CXXFLAGS) -o $@ $<
all: $(PROGRAM)
$(PROGRAM): $(OBJECTS)
$(CXX) -o $(PROGRAM) $(OBJECTS) $(LDFLAGS)
clean:
rm -f *.o $(PROGRAM)

View File

@@ -0,0 +1,20 @@
#
# File: makefile.vc
# Author: Julian Smart
# Created: 2003
# Updated:
# Copyright: (c) Julian Smart
#
# Makefile : Builds wxWindows Configuration Tool (VC++, WIN32)
# Use FINAL=1 argument to nmake to build final version with no debug info.
# Set WXDIR for your system
WXDIR = $(WXWIN)
PROGRAM=wxconfigtool
OBJECTS = wxconfigtool.obj appsettings.obj configitem.obj configitemselector.obj configtooldoc.obj \
configtoolview.obj configtree.obj custompropertydialog.obj htmlparser.obj mainframe.obj \
propeditor.obj property.obj settingsdialog.obj utils.obj
!include $(WXDIR)\src\makeprog.vc

View File

@@ -0,0 +1,18 @@
#
# Makefile for WATCOM
#
# Created by Julian Smart, January 1999
#
#
#
#
PROGRAM = wxconfigtool
OBJECTS = $(OUTPUTDIR)\$(PROGRAM).obj $(OUTPUTDIR)\appsettings.obj &
$(OUTPUTDIR)\configitem.obj $(OUTPUTDIR)\configitemselector.obj &
$(OUTPUTDIR)\configtooldoc.obj $(OUTPUTDIR)\configtoolview.obj &
$(OUTPUTDIR)\configtree.obj $(OUTPUTDIR)\custompropertydialog.obj &
$(OUTPUTDIR)\htmlparser.obj $(OUTPUTDIR)\mainframe.obj $(OUTPUTDIR)\propeditor.obj &
$(OUTPUTDIR)\property.obj $(OUTPUTDIR)\settingsdialog.obj $(OUTPUTDIR)\utils.obj
#
!include $(%WXWIN)\src\makeprog.wat

View File

@@ -0,0 +1,115 @@
# THIS IS JUST A DUMMY FILE for allowing the makefile
# to work before there a real makeprog.env has been
# created by configure.
# Make environment for making samples on Unix
# The binary program extension, if any, including dots (e.g. '.exe')
PROGRAM_EXT =
BIN_PROGRAM = $(PROGRAM)$(PROGRAM_EXT)
RES_PROGRAM_OBJ =
BUNDLE = $(BIN_PROGRAM).app/Contents
# NB: see remark in Makefile.in as to why we don't use %.foo: %.bar rules
.SUFFIXES: .o .c .cpp .cxx .rc _resources.o
.c.o:
$(CC) -c $(CFLAGS) $(APPEXTRADEFS) -o $@ $<
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $<
.rc_resources.o:
$(RESCOMP) -i $< -o $@ $(RESFLAGS)
# the comment at the end of the next line is needed because otherwise autoconf
# would remove this line completely - it contains a built-in hack to remove
# any VPATH assignment not containing ':'
VPATH = :$(top_srcdir)/$(program_dir) # ':' for autoconf
#
# File: make.env
# Author: Julian Smart, Robert Roebling, Vadim Zeitlin, Ron Lee
# Created: 1993
# Updated: 2001
# Copyright:(c) 1993, AIAI, University of Edinburgh,
# Copyright:(c) 1999, Vadim Zeitlin
# Copyright:(c) 1999, Robert Roebling
# Copyright:(c) 2001, Ron Lee
#
####################### GENERAL SETTINGS ############################
# see comment near LDFLAGS at the end of file
EXTRALIBS = -framework Carbon -framework System -lz -lm -lpthread
OPENGLLIBS =
LDLIBS = ${APPEXTRALIBS} ${top_builddir}/lib/libwx_macd-2.3.a ${EXTRALIBS}
TOOLKIT = MAC
TOOLKITDIR = mac
WXLIB = libwx_macd-2.3.a
WXSHLIB = libwx_macd-2.3.dylib.2.0.0
########################### VERSION #################################
WX_MAJOR_VERSION_NUMBER = 2
WX_MINOR_VERSION_NUMBER = 3
WX_RELEASE_NUMBER = 3
########################### Programs #################################
CXX = c++
CC = gcc
# Compiler for lex/yacc .c programs
CCLEX = gcc
LEX = flex
YACC = bison -y
AR = ar
AS =
NM =
LN_S = ln -s
STRIP = strip
AROPTIONS = rcu
RANLIB = ranlib
LD =
MAKEINFO =
RM = rm -f
SHARED_LD =
RESFLAGS =
RESCOMP = /Developer/Tools/Rez
DEREZ = /Developer/Tools/DeRez
DLLTOOL =
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = cp -fp
INSTALL_DATA = cp -fp
INSTALL_SCRIPT = /usr/bin/install -c
########################### Flags #################################
CPPFLAGS = ${APPEXTRACPPFLAGS} -no-cpp-precomp -I/Developer/Headers/FlatCarbon -I${top_srcdir}/src/mac/morefile $(EXTRADEFS) $(APPEXTRADEFS) -D__WXMAC__ -D__WXDEBUG__
CFLAGS = ${APPEXTRACFLAGS} ${CPPFLAGS} -MMD -fpascal-strings -g -I${top_builddir}/lib/wx/include/macd-2.3 -I${top_srcdir}/include -I${top_srcdir}/src/png -I${top_srcdir}/src/tiff -Wall
CXXFLAGS = ${APPEXTRACXXFLAGS} ${CPPFLAGS} -MMD -fpascal-strings -g -I${top_builddir}/lib/wx/include/macd-2.3 -I${top_srcdir}/include -I${top_srcdir}/src/png -I${top_srcdir}/src/tiff -Wall
PICFLAGS =
# taking into account how SHARED_LD is defined, appending LDFLAGS to it
# doesn't work, so we put them in the end of the linker command line in
# EXTRALIBS instead (see above)
# LDFLAGS = -framework Carbon -framework System
# specific linker flags for when building executables since there
# Mac OS X requires specific linker flags for executables linked
# against dynamic shared libraries
LDFLAGS_EXE =

View File

@@ -0,0 +1,855 @@
/////////////////////////////////////////////////////////////////////////////
// Name: propeditor.cpp
// Purpose: wxWindows Configuration Tool property editor
// Author: Julian Smart
// Modified by:
// Created: 2003-06-03
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "propeditor.h"
#endif
#include <wx/wx.h>
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/html/htmlwin.h"
#include "wx/grid.h"
#include "wx/filedlg.h"
#include "wx/tokenzr.h"
#include "wx/valgen.h"
#include "propeditor.h"
#include "symbols.h"
#include "utils.h"
#include "configtooldoc.h"
#include "configitemselector.h"
#include "bitmaps/ellipsis.xpm"
/*!
* A container window for the property editor.
* and attribute editor.
*/
IMPLEMENT_CLASS(ctPropertyEditor, wxPanel)
BEGIN_EVENT_TABLE(ctPropertyEditor, wxPanel)
EVT_BUTTON(ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS, ctPropertyEditor::OnEditDetails)
EVT_GRID_SELECT_CELL(ctPropertyEditor::OnSelectCell)
EVT_GRID_CELL_CHANGE(ctPropertyEditor::OnChangeCell)
EVT_GRID_CELL_LEFT_DCLICK(ctPropertyEditor::OnDClickCell)
EVT_UPDATE_UI(ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS, ctPropertyEditor::OnUpdateEditDetails)
END_EVENT_TABLE()
ctPropertyEditor::ctPropertyEditor(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style):
wxPanel(parent, id, pos, size, style)
{
m_splitterWindow = NULL;
m_attributeEditorGrid = NULL;
m_propertyDescriptionWindow = NULL;
m_elementTitleTextCtrl = NULL;
CreateControls(this);
}
ctPropertyEditor::~ctPropertyEditor()
{
}
void ctPropertyEditor::CreateControls(wxWindow* parent)
{
m_elementTitleTextCtrl = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
wxBitmap detailsIcon(ellipsis_xpm);
wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
wxTextCtrl *item2 = m_elementTitleTextCtrl;
item1->Add( item2, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxButton *item3a = new wxButton( parent, ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS, wxT("Edit..."), wxDefaultPosition, wxSize(-1, -1));
item1->Add( item3a, 0, wxALIGN_CENTRE|wxRIGHT|wxTOP|wxBOTTOM, 5 );
item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5 );
// TODO: find sash pos from last time
int sashPos = 100;
m_splitterWindow = new wxSplitterWindow(parent, ctID_PROPERTY_EDITOR_SPLITTER, wxDefaultPosition, wxSize(500, 400), wxSP_3DSASH|wxSP_FULLSASH/*|wxCLIP_CHILDREN*/ |wxBORDER_NONE|wxNO_FULL_REPAINT_ON_RESIZE);
m_splitterWindow->SetMinimumPaneSize(10);
m_propertyDescriptionWindow = new wxHtmlWindow(m_splitterWindow, ctID_ATTRIBUTE_EDITOR_DESCRIPTION, wxDefaultPosition, wxSize(200, 60), wxSUNKEN_BORDER);
m_propertyDescriptionWindow->SetBackgroundColour(ctDESCRIPTION_BACKGROUND_COLOUR);
m_propertyDescriptionWindow->SetBorders(4);
m_attributeEditorGrid = new ctPropertyEditorGrid(m_splitterWindow, ctID_ATTRIBUTE_EDITOR_GRID , wxPoint(0, 0), wxSize(200, 100), wxBORDER_SUNKEN | wxWANTS_CHARS);
m_splitterWindow->SplitHorizontally(m_propertyDescriptionWindow, m_attributeEditorGrid, sashPos);
// TODO: show or hide description window
// if (some-setting)
// ShowDescriptionWindow(FALSE);
item0->Add( m_splitterWindow, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
this->SetAutoLayout( TRUE );
this->SetSizer( item0 );
/// Add help text
m_elementTitleTextCtrl->SetHelpText(_("The title of the property being edited."));
FindWindow(ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS)->SetHelpText(_("Click to use an appropriate editor for the selected property (if any)."));
FindWindow(ctID_ATTRIBUTE_EDITOR_GRID)->SetHelpText(_("Shows the properties of the selected item."));
FindWindow(ctID_ATTRIBUTE_EDITOR_DESCRIPTION)->SetHelpText(_("Shows a description of the selected property, or a summary of the whole item."));
/// Set up the grid to display properties
m_attributeEditorGrid->RegisterDataType(ctGRID_VALUE_STRING,
new wxGridCellStringRenderer,
new ctGridCellTextEditor);
m_attributeEditorGrid->CreateGrid( 0, 2, wxGrid::wxGridSelectRows );
m_attributeEditorGrid->SetRowLabelSize(0);
m_attributeEditorGrid->SetColLabelSize(0 /* 18 */);
wxArrayString columns;
columns.Add(_T("Name"));
columns.Add(_T("Value"));
m_attributeEditorGrid->SetColSize(0, 140);
m_attributeEditorGrid->SetColSize(1, 80);
m_attributeEditorGrid->SetColumnsToDisplay(columns);
m_attributeEditorGrid->DisplayLabels();
m_attributeEditorGrid->SetStretchableColumn(1);
m_attributeEditorGrid->SetDefaultCellBackgroundColour(ctCELL_BACKGROUND_COLOUR);
UpdateDescription();
}
/// Show/hide the description control
void ctPropertyEditor::ShowDescriptionWindow(bool show)
{
if (!show)
{
if (m_splitterWindow->IsSplit())
m_splitterWindow->Unsplit(m_propertyDescriptionWindow);
}
else
{
// TODO
int pos = 100;
m_propertyDescriptionWindow->Show(TRUE);
if (!m_splitterWindow->IsSplit())
{
m_splitterWindow->SplitHorizontally(m_propertyDescriptionWindow, m_attributeEditorGrid, pos);
}
}
}
/// Clear grid editor
void ctPropertyEditor::ClearEditor()
{
m_attributeEditorGrid->ClearAttributes();
m_propertyDescriptionWindow->SetPage(WrapDescription(wxEmptyString));
m_elementTitleTextCtrl->SetValue(_T(""));
}
/// Handles detailed editing event.
void ctPropertyEditor::OnEditDetails(wxCommandEvent& event)
{
wxWindow* parentFrame = this;
while (parentFrame && !parentFrame->IsKindOf(CLASSINFO(wxFrame)))
parentFrame = parentFrame->GetParent();
EditDetails(parentFrame);
}
/// Handles detailed editing update event.
void ctPropertyEditor::OnUpdateEditDetails(wxUpdateUIEvent& event)
{
event.Enable(CanEditDetails());
}
/// Can we edit the details of the selected property?
bool ctPropertyEditor::CanEditDetails()
{
if (!m_item)
return FALSE;
int row;
ctProperty* prop = FindSelectedProperty(row);
if (!prop || prop->GetEditorType().IsEmpty())
return FALSE;
return TRUE;
}
/// Shows the item
void ctPropertyEditor::ShowItem(ctConfigItem* item)
{
if (m_attributeEditorGrid->IsCellEditControlEnabled())
m_attributeEditorGrid->SaveEditControlValue();
ClearEditor();
if (item)
{
m_item = item;
UpdateTitle();
m_attributeEditorGrid->AppendRows(m_item->GetProperties().GetCount());
wxNode* node = m_item->GetProperties().GetList().GetFirst();
int i = 0;
while (node)
{
ctProperty* prop = (ctProperty*) node->GetData();
DisplayProperty(i, prop);
i ++;
node = node->GetNext();
}
// Make sure scrollbars are up-to-date, etc.
wxSizeEvent event(m_attributeEditorGrid->GetSize(), m_attributeEditorGrid->GetId());
m_attributeEditorGrid->GetEventHandler()->ProcessEvent(event);
DisplayDefaultProperty();
}
else
{
m_item = NULL;
}
}
/// Determine background colour for this property.
void ctPropertyEditor::DeterminePropertyColour(ctProperty* prop, wxColour& colour)
{
if (prop->IsCustom())
colour = ctCUSTOM_CELL_BACKGROUND_COLOUR;
else
colour = ctCELL_BACKGROUND_COLOUR;
}
/// Update the title at the top of the property editor
void ctPropertyEditor::UpdateTitle()
{
if (m_item)
{
wxString name(m_item->GetTitle());
m_elementTitleTextCtrl->SetValue(name);
}
}
/// Updates the item display, assuming it was already displayed.
void ctPropertyEditor::UpdateItem()
{
if (m_attributeEditorGrid->IsCellEditControlEnabled())
m_attributeEditorGrid->SaveEditControlValue();
if (m_item)
{
UpdateTitle();
wxNode* node = m_item->GetProperties().GetList().GetFirst();
int i = 0;
while (node)
{
ctProperty* prop = (ctProperty*) node->GetData();
DisplayProperty(i, prop, TRUE);
i ++;
node = node->GetNext();
}
// Make sure scrollbars are up-to-date, etc.
wxSizeEvent event(m_attributeEditorGrid->GetSize(), this->GetId());
m_attributeEditorGrid->GetEventHandler()->ProcessEvent(event);
}
}
/// Display attribute at given row
bool ctPropertyEditor::DisplayProperty(int row, ctProperty* prop, bool valueOnly)
{
wxColour backgroundColour;
DeterminePropertyColour(prop, backgroundColour);
if (!valueOnly)
{
m_attributeEditorGrid->SetCellBackgroundColour(row, 0, backgroundColour);
m_attributeEditorGrid->SetCellBackgroundColour(row, 1, backgroundColour);
m_attributeEditorGrid->SetCellValue(row, 0, prop->GetName());
m_attributeEditorGrid->SetReadOnly(row, 0);
// Set the alignment
m_attributeEditorGrid->SetCellAlignment(row, 1, wxALIGN_LEFT, wxALIGN_CENTER);
}
if (!m_item->CanEditProperty(prop->GetName()))
{
m_attributeEditorGrid->SetReadOnly(row, 1);
wxColour col(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
m_attributeEditorGrid->SetCellTextColour(row, 1, col);
}
else
{
m_attributeEditorGrid->SetReadOnly(row, 1, FALSE);
m_attributeEditorGrid->SetCellTextColour(row, 1, * wxBLACK);
}
// Set the value
m_attributeEditorGrid->SetCellValue(row, 1, ctConvertToSingleText(prop->GetValue()));
if (valueOnly)
return TRUE;
// Set the value type
if (prop->GetEditorType() == _T("choice"))
{
wxString* strArr = prop->GetChoices().GetStringArray();
m_attributeEditorGrid->SetCellEditor(row, 1,
new wxGridCellChoiceEditor(prop->GetChoices().GetCount(), strArr));
delete[] strArr;
}
else if (prop->GetEditorType() == _T("integer") || prop->GetVariant().GetType() == _T("long"))
{
m_attributeEditorGrid->SetCellEditor(row, 1,
new wxGridCellNumberEditor);
}
else if (prop->GetEditorType() == _T("float") || prop->GetVariant().GetType() == _T("double"))
{
m_attributeEditorGrid->SetCellEditor(row, 1,
new wxGridCellFloatEditor);
}
else if (prop->GetEditorType() == _T("bool") || prop->GetVariant().GetType() == _T("bool"))
{
m_attributeEditorGrid->SetCellValue(row, 1, prop->GetVariant().GetBool() ? _T("1") : _T("0"));
m_attributeEditorGrid->SetCellEditor(row, 1,
new wxGridCellBoolEditor);
m_attributeEditorGrid->SetCellRenderer(row, 1, new wxGridCellBoolRenderer);
}
else
{
m_attributeEditorGrid->SetCellEditor(row, 1,
new ctGridCellTextEditor);
}
return TRUE;
}
/// Display attribute value
bool ctPropertyEditor::DisplayProperty(ctProperty* prop)
{
if (!m_item)
return FALSE;
int index = m_item->GetProperties().GetList().IndexOf(prop);
return DisplayProperty(index, prop, TRUE);
}
/// Display the default property
bool ctPropertyEditor::DisplayDefaultProperty()
{
if (!m_item)
return FALSE;
wxString str = m_item->GetDefaultProperty();
ctProperty* prop = m_item->GetProperties().FindProperty(str);
if (prop)
{
int index = m_item->GetProperties().GetList().IndexOf(prop);
this->m_attributeEditorGrid->SelectRow(index);
this->m_attributeEditorGrid->SetGridCursor(index, 1);
}
return TRUE;
}
/// Edit the default property
bool ctPropertyEditor::EditDefaultProperty(ctConfigItem* item)
{
wxString defaultPropertyName = item->GetDefaultProperty();
if (!defaultPropertyName.IsEmpty())
{
ctProperty* prop = item->GetProperties().FindProperty(defaultPropertyName);
if (prop)
{
int index = item->GetProperties().GetList().IndexOf(prop);
if (index >= 0)
{
this->m_attributeEditorGrid->SelectRow(index);
this->m_attributeEditorGrid->SetGridCursor(index, 1);
EditDetails(wxTheApp->GetTopWindow());
return TRUE;
}
}
}
return FALSE;
}
/// Find the selected property
ctProperty* ctPropertyEditor::FindSelectedProperty(int& row)
{
if (!m_item)
return NULL;
int selRow = m_attributeEditorGrid->GetCursorRow();
if (selRow > -1)
{
row = selRow;
if (selRow < (int) m_item->GetProperties().GetCount())
{
ctProperty* prop = m_item->GetProperties().GetNth(selRow);
return prop;
}
}
return NULL;
}
/// Find the property
ctProperty* ctPropertyEditor::FindProperty(int row)
{
if (!m_item)
return NULL;
if (row > -1)
{
if (row < (int) m_item->GetProperties().GetCount())
{
ctProperty* prop = m_item->GetProperties().GetNth(row);
return prop;
}
}
return NULL;
}
/// Edit the details of this cell appropriately.
bool ctPropertyEditor::EditDetails(wxWindow* parent)
{
if (CanEditDetails())
{
int row;
ctProperty* prop = FindSelectedProperty(row);
if (!prop)
return FALSE;
wxString type(prop->GetEditorType());
wxString value = m_attributeEditorGrid->GetCellValue(row, 1);
if (type == _T("multiline"))
{
value = ctConvertToMultilineText(value);
wxString msg;
msg.Printf(wxT("Edit %s:"), (const wxChar*) prop->GetName());
ctMultiLineTextEditor dialog(wxTheApp->GetTopWindow(),
-1, wxT("Edit Text Property"), msg, value);
if (dialog.ShowModal() == wxID_OK)
{
value = ctConvertToSingleText(dialog.GetText());
m_attributeEditorGrid->SetCellValue(row, 1, value);
ApplyCellValueToProperty(row, 1);
return TRUE;
}
else
return FALSE;
}
else if (type == _T("filename"))
{
wxString fullPath = value;
wxString defaultDir ;
wxString defaultFilename = wxFileNameFromPath(fullPath);
defaultDir = wxPathOnly(value);
wxString msg = wxT("Choose a filename");
wxFileDialog dialog(wxTheApp->GetTopWindow(),
msg, defaultDir, defaultFilename, wxT("*.*"));
if (dialog.ShowModal() == wxID_OK)
{
fullPath = dialog.GetPath();
value = fullPath;
m_attributeEditorGrid->SetCellValue(row, 1, value);
ApplyCellValueToProperty(row, 1);
return TRUE;
}
else
return FALSE;
}
else if (type == _T("configitems"))
{
wxArrayString items;
ctConfigItem::StringToArray(value, items);
ctConfigItemsSelector dialog(wxTheApp->GetTopWindow(),
-1, wxT("Select Configuration Items"));
dialog.SetConfigList(items);
if (dialog.ShowModal() == wxID_OK)
{
wxString newValue;
items = dialog.GetConfigList();
ctConfigItem::ArrayToString(items, newValue);
m_attributeEditorGrid->SetCellValue(row, 1, newValue);
ApplyCellValueToProperty(row, 1);
return TRUE;
}
else
return FALSE;
}
}
return FALSE;
}
/// Intercept selection event.
void ctPropertyEditor::OnSelectCell(wxGridEvent& event)
{
int row = event.GetRow();
UpdateDescription(row);
event.Skip();
}
/// Update the description
void ctPropertyEditor::UpdateDescription(int row)
{
if (row == -1)
{
row = m_attributeEditorGrid->GetCursorRow();
}
if (row == -1)
{
wxString str = WrapDescription(wxEmptyString);
m_propertyDescriptionWindow->SetPage(str);
}
else
{
ctProperty* prop = FindProperty(row);
if (prop)
{
wxString str = WrapDescription(m_item->GetDescription(prop));
m_propertyDescriptionWindow->SetPage(str);
}
}
}
/// Wraps a description string in HTML
wxString ctPropertyEditor::WrapDescription(const wxString& s)
{
/// Convert a colour to a 6-digit hex string
wxColour col = ctDESCRIPTION_BACKGROUND_COLOUR;
wxString colStr = apColourToHexString(col);
colStr = wxT("#") + colStr;
wxString str;
str << _T("<HTML><BODY BGCOLOR=\"") << colStr << wxT("\"><FONT SIZE=-1>") ;
str << s;
str << _T("</FONT></BODY></HTML>");
return str;
}
/// Intercept cell data change event.
void ctPropertyEditor::OnChangeCell(wxGridEvent& event)
{
int row = event.GetRow();
int col = event.GetCol();
ApplyCellValueToProperty(row, col);
}
/// Double-click to show specialised editor.
void ctPropertyEditor::OnDClickCell(wxGridEvent& event)
{
wxWindow* parentFrame = this;
while (parentFrame && !parentFrame->IsKindOf(CLASSINFO(wxFrame)))
parentFrame = parentFrame->GetParent();
EditDetails(parentFrame);
}
/// Apply the cell value to the property, and notify the
/// item object.
void ctPropertyEditor::ApplyCellValueToProperty(int row, int col)
{
static bool s_Applying = FALSE;
if (s_Applying)
return;
s_Applying = TRUE;
if (col == 1 && m_item)
{
ctProperty* prop = m_item->GetProperties().GetNth(row);
wxString value = m_attributeEditorGrid->GetCellValue(row, col);
if (prop->GetEditorType() == wxT("multiline"))
value = ctConvertToMultilineText(value);
wxVariant variant = prop->GetVariant();
if (prop->GetVariant().GetType() == _T("bool"))
{
if (value == _T("1"))
variant = (bool) TRUE;
else
variant = (bool) FALSE;
}
else if (prop->GetVariant().GetType() == _T("long"))
{
long l;
value.ToLong(& l);
variant = l;
}
else if (prop->GetVariant().GetType() == _T("double"))
{
double d;
value.ToDouble(& d);
variant = d;
}
else
{
variant = value;
}
ApplyPropertyValue(m_item, prop, variant);
if (prop->GetName() == _T("description"))
UpdateDescription(row);
}
s_Applying = FALSE;
}
/// Apply the cell value to the property, and notify the
/// item object.
void ctPropertyEditor::ApplyPropertyValue(ctConfigItem* item, ctProperty* property, const wxVariant& variant)
{
static bool s_Applying = FALSE;
if (s_Applying)
return;
s_Applying = TRUE;
// Save the old values
ctProperties* oldProperties = new ctProperties(item->GetProperties());
wxVariant oldValue = property->GetVariant();
// Apply the new value
property->GetVariant() = variant;
item->ApplyProperty(property, oldValue);
item->Modify();
UpdateItem();
wxString menuLabel(_T("Change ") + property->GetName());
// This won't do anything first time Do is applied,
// since we've already done the action for this property.
// But when we Undo or Redo, the changed properties will be applied.
item->GetDocument()->GetCommandProcessor()->Submit(
new ctConfigCommand(menuLabel, ctCMD_APPLY_PROPERTY,
item, oldProperties, TRUE));
s_Applying = FALSE;
}
/*!
* Attribute editor grid
*/
IMPLEMENT_CLASS(ctPropertyEditorGrid, wxGrid)
BEGIN_EVENT_TABLE(ctPropertyEditorGrid, wxGrid)
EVT_SIZE(ctPropertyEditorGrid::OnSize)
END_EVENT_TABLE()
ctPropertyEditorGrid::ctPropertyEditorGrid(wxWindow* parent, wxWindowID id,
const wxPoint& pos,
const wxSize& sz, long style):
wxGrid(parent, id, pos, sz, style)
{
m_stretchableColumn = -1;
}
void ctPropertyEditorGrid::OnSize(wxSizeEvent& event)
{
if (m_stretchableColumn != -1)
{
// This window's client size = the internal window's
// client size if it has no borders
wxSize sz = GetClientSize();
int totalSize = 0;
int i;
for (i = 0; i < GetNumberCols(); i ++)
{
if (i != m_stretchableColumn)
{
totalSize += GetColSize(i);
}
}
// Allow for grid lines
totalSize += 1;
int stretchSize = wxMax(5, sz.x - totalSize);
SetColSize(m_stretchableColumn, stretchSize);
}
event.Skip();
}
/// Use m_columnsToDisplay to set the label strings
void ctPropertyEditorGrid::DisplayLabels()
{
size_t i;
for (i = 0; i < m_columnsToDisplay.GetCount(); i++)
{
SetColLabelValue(i, m_columnsToDisplay[i]);
}
}
/// Clear attributes
bool ctPropertyEditorGrid::ClearAttributes()
{
if (GetNumberRows() > 0)
DeleteRows(0, GetNumberRows());
return TRUE;
}
/*!
* Use a single-line text control.
*/
void ctGridCellTextEditor::Create(wxWindow* parent, wxWindowID id,
wxEvtHandler* evtHandler)
{
m_control = new wxTextCtrl(parent, id, wxEmptyString,
wxDefaultPosition, wxDefaultSize
);
wxGridCellEditor::Create(parent, id, evtHandler);
}
/// Translate the value to one which can be edited in a single-line
/// text control
wxString ctConvertToSingleText(const wxString& value)
{
wxString value1(value);
value1.Replace(wxT("\n"), wxT("\\n"));
value1.Replace(wxT("\t"), wxT("\\t"));
return value1;
}
/// Translate back to 'real' characters, i.e. newlines are real
/// newlines.
wxString ctConvertToMultilineText(const wxString& value)
{
wxString value1(value);
value1.Replace(wxT("\\n"), wxT("\n"));
value1.Replace(wxT("\\t"), wxT("\t"));
return value1;
}
//----------------------------------------------------------------------------
// ctMultiLineTextEditor
//----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(ctMultiLineTextEditor, wxDialog)
END_EVENT_TABLE()
ctMultiLineTextEditor::ctMultiLineTextEditor( wxWindow *parent, wxWindowID id, const wxString &title,
const wxString& msg,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
long style):
wxDialog(parent, id, title, pos, size, style)
{
m_text = value;
AddControls(this, msg);
Centre();
}
bool ctMultiLineTextEditor::AddControls(wxWindow* parent, const wxString& msg)
{
wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer *item1 = new wxBoxSizer( wxVERTICAL );
wxStaticText *item2 = new wxStaticText( parent, wxID_STATIC, msg, wxDefaultPosition, wxDefaultSize, 0 );
item1->Add( item2, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT, 5 );
wxTextCtrl *item3 = new wxTextCtrl( parent, -1, wxT(""), wxDefaultPosition, wxSize(330,180), wxTE_MULTILINE|wxTE_RICH );
item1->Add( item3, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxBoxSizer *item4 = new wxBoxSizer( wxHORIZONTAL );
item4->Add( 5, 5, 1, wxALIGN_CENTRE|wxALL, 5 );
wxButton *item5 = new wxButton( parent, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
item5->SetDefault();
item4->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
wxButton *item6 = new wxButton( parent, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
item4->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
item1->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5 );
item0->Add( item1, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
item3->SetValue(m_text);
item3->SetValidator(wxGenericValidator(& m_text));
item3->SetFocus();
((wxButton*) FindWindow(wxID_OK))->SetDefault();
parent->SetAutoLayout( TRUE );
parent->SetSizer(item0);
item0->Fit(parent);
return TRUE;
}
/*
* Special-purpose splitter window for changing sash look and
* also saving sash width
*/
BEGIN_EVENT_TABLE(ctSplitterWindow, wxSplitterWindow)
EVT_SPLITTER_SASH_POS_CHANGED(-1, ctSplitterWindow::OnChangeSash)
END_EVENT_TABLE()
ctSplitterWindow::ctSplitterWindow(wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style):
wxSplitterWindow(parent, id, pos, size, style)
{
m_updateSettings = FALSE;
m_position = 0;
}
void ctSplitterWindow::OnChangeSash(wxSplitterEvent& event)
{
if (!m_updateSettings)
return;
m_position = event.GetSashPosition();
}

View File

@@ -0,0 +1,275 @@
/////////////////////////////////////////////////////////////////////////////
// Name: propeditor.cpp
// Purpose: Property editor for wxWindows configuration tool
// Author: Julian Smart
// Modified by:
// Created: 2003-06-03
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _CT_PROPEDITOR_H_
#define _CT_PROPEDITOR_H_
#ifdef __GNUG__
#pragma interface "propeditor.cpp"
#endif
#include "wx/splitter.h"
#include "wx/grid.h"
#include "configitem.h"
#include "property.h"
class WXDLLEXPORT wxHtmlWindow;
class ctPropertyEditorGrid;
/*!
* A container window for the property editor.
*/
class ctPropertyEditor: public wxPanel
{
DECLARE_CLASS(ctPropertyEditor)
public:
ctPropertyEditor(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
~ctPropertyEditor();
// Event handlers
/// Handles detailed editing event.
void OnEditDetails(wxCommandEvent& event);
/// Handles detailed editing update event.
void OnUpdateEditDetails(wxUpdateUIEvent& event);
/// Intercept selection event.
void OnSelectCell(wxGridEvent& event);
/// Intercept cell data change event.
void OnChangeCell(wxGridEvent& event);
/// Double-click to show specialised editor.
void OnDClickCell(wxGridEvent& event);
// Operations
/// Creates the controls
void CreateControls(wxWindow* parent);
/// Clear grid editor
void ClearEditor();
/// Can we edit the details of the selected property?
bool CanEditDetails();
/// Edit the details of this cell appropriately.
bool EditDetails(wxWindow* parent);
/// Shows the given config item
void ShowItem(ctConfigItem* configItem);
/// Updates the proxy display, assuming it was already displayed.
void UpdateItem();
/// Display attribute at given row
bool DisplayProperty(int row, ctProperty* prop, bool valueOnly = FALSE);
/// Display attribute value
bool DisplayProperty(ctProperty* prop);
/// Edit the default property
bool EditDefaultProperty(ctConfigItem* proxy);
/// Select the default property
bool DisplayDefaultProperty();
/// Determine background colour for this property.
void DeterminePropertyColour(ctProperty* prop, wxColour& colour);
/// Update the title at the top of the property editor
void UpdateTitle();
/// Update the description
void UpdateDescription(int row = -1);
/// Wraps a description string in HTML
wxString WrapDescription(const wxString& str);
/// Find the selected property
ctProperty* FindSelectedProperty(int& row);
/// Find the nth property
ctProperty* FindProperty(int row);
/// Apply the cell value to the property, and notify the
/// proxy object.
void ApplyCellValueToProperty(int row, int col);
/// Apply the cell value to the property, and notify the
/// proxy object. This will be undoable.
void ApplyPropertyValue(ctConfigItem* item, ctProperty* property, const wxVariant& variant);
/// Show/hide the description control
void ShowDescriptionWindow(bool show);
// Accessors
//// Returns the grid used as the attribute editor
ctPropertyEditorGrid* GetAttributeEditorGrid() const { return m_attributeEditorGrid; }
/// Returns the title text control
wxTextCtrl* GetElementTitleTextCtrl() const { return m_elementTitleTextCtrl; }
/// Returns the splitter window between the property grid and
/// the description window.
wxSplitterWindow* GetSplitterWindow() const { return m_splitterWindow; }
/// Returns the HTML description window
wxHtmlWindow* GetDescriptionWindow() const { return m_propertyDescriptionWindow; }
/// Returns the config item
ctConfigItem* GetItem() const { return m_item; }
/// Sets the proxy
void SetItem(ctConfigItem* configItem) { m_item = configItem; }
DECLARE_EVENT_TABLE()
protected:
ctPropertyEditorGrid* m_attributeEditorGrid;
wxHtmlWindow* m_propertyDescriptionWindow;
wxSplitterWindow* m_splitterWindow;
// Displays the title of the element being edited
wxTextCtrl* m_elementTitleTextCtrl;
// The config item object being edited
ctConfigItem* m_item;
};
#define ctID_ATTRIBUTE_EDITOR_INSERT 2001
#define ctID_ATTRIBUTE_EDITOR_GRID 2002
#define ctID_ATTRIBUTE_EDITOR_DESCRIPTION 2003
#define ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS 2004
/*!
* Attribute editor grid
*/
class ctPropertyEditorGrid: public wxGrid
{
DECLARE_CLASS(ctPropertyEditorGrid)
public:
ctPropertyEditorGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, long style = wxWANTS_CHARS);
/// Intercept size event.
void OnSize(wxSizeEvent& event);
void SetStretchableColumn(int which) { m_stretchableColumn = which; }
int GetStretchableColumn() const { return m_stretchableColumn; }
/// An array denoting which columns to display,
/// and in what order.
void SetColumnsToDisplay(wxArrayString& columns) { m_columnsToDisplay = columns; }
wxArrayString& GetColumnsToDisplay() { return m_columnsToDisplay; }
/// Use m_columnsToDisplay to set the label strings
void DisplayLabels();
/// Clear attributes
bool ClearAttributes();
DECLARE_EVENT_TABLE()
private:
int m_stretchableColumn;
wxArrayString m_columnsToDisplay;
};
// Utility functions
/// Translate the value to one which can be edited in a single-line
/// text control
wxString ctConvertToSingleText(const wxString& value);
/// Translate back to 'real' characters, i.e. newlines are real
/// newlines.
wxString ctConvertToMultilineText(const wxString& value);
//----------------------------------------------------------------------------
// ctMultiLineTextEditor
//----------------------------------------------------------------------------
class ctMultiLineTextEditor: public wxDialog
{
public:
// constructors and destructors
ctMultiLineTextEditor( wxWindow *parent, wxWindowID id, const wxString &title,
const wxString& msg,
const wxString& value,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
bool AddControls(wxWindow* parent, const wxString& msg);
wxString GetText() const { return m_text; }
void SetText(const wxString& text) { m_text = text; }
private:
DECLARE_EVENT_TABLE()
wxString m_text;
};
/*
* Special-purpose splitter window for changing sash look and
* also saving sash width
*/
class ctSplitterWindow: public wxSplitterWindow
{
public:
ctSplitterWindow(wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style);
// Draws the sash
//virtual void DrawSash(wxDC& dc);
void OnChangeSash(wxSplitterEvent& event);
void UpdateSettings(bool updateSettings) { m_updateSettings = updateSettings; }
int GetLastPosition() const { return m_position; }
void SetLastPosition(int pos) { m_position = pos; }
protected:
// Don't update settings if the window is still being created,
// since it could override the saved settings
bool m_updateSettings;
int m_position;
DECLARE_EVENT_TABLE()
};
/*!
* Use a single-line text control.
*/
class ctGridCellTextEditor: public wxGridCellTextEditor
{
public:
virtual void Create(wxWindow* parent, wxWindowID id,
wxEvtHandler* evtHandler);
};
#define ctGRID_VALUE_STRING wxT("singlelinestring")
#define ctID_PROPERTY_EDITOR_SPLITTER 1600
#endif
// _WB_PROPEDITOR_H_

View File

@@ -0,0 +1,232 @@
/////////////////////////////////////////////////////////////////////////////
// Name: property.cpp
// Purpose: ctProperty objects represent name/value pairs,
// for properties of a configuration item.
// Author: Julian Smart
// Modified by:
// Created: 2003-06-03
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "property.h"
#endif
#include "wx/wx.h"
#include "property.h"
IMPLEMENT_CLASS(ctProperty, wxObject)
IMPLEMENT_CLASS(ctProperties, wxObject)
void ctProperties::AddProperty(ctProperty* property, const wxString& insertAfter)
{
ctProperty* oldProp = FindProperty(property->GetName());
if (oldProp)
m_list.DeleteObject(oldProp);
wxNode* insertBeforeNode = NULL;
if (insertAfter)
{
ctProperty* insertAfterProp = FindProperty(insertAfter);
if (insertAfterProp)
{
wxNode* node = m_list.Member(insertAfterProp);
if (node)
insertBeforeNode = node->GetNext();
}
}
if (insertBeforeNode)
m_list.Insert(insertBeforeNode, property);
else
m_list.Append(property);
if (oldProp)
{
property->GetVariant() = oldProp->GetVariant();
delete oldProp;
}
}
void ctProperties::RemoveProperty(ctProperty* property)
{
m_list.DeleteObject(property);
}
void ctProperties::DeleteProperty(const wxString& name)
{
ctProperty* prop = FindProperty(name);
if (prop)
{
m_list.DeleteObject(prop);
delete prop;
}
}
ctProperty* ctProperties::FindProperty(const wxString& name) const
{
wxNode* node = m_list.GetFirst();
while (node)
{
ctProperty* prop = (ctProperty*) node->GetData();
if (prop->GetName() == name)
return prop;
node = node->GetNext();
}
return (ctProperty*) NULL;
}
wxVariant ctProperties::FindPropertyValue(const wxString& name) const
{
ctProperty* prop = FindProperty(name);
if (prop)
return prop->m_variant;
else
return wxEmptyString;
}
wxString ctProperties::FindPropertyValueString(const wxString& name) const
{
ctProperty* prop = FindProperty(name);
if (prop)
return prop->m_variant.GetString();
else
return wxEmptyString;
}
ctProperty* ctProperties::FindOrCreateProperty(const wxString& name)
{
ctProperty* prop = FindProperty(name);
if (!prop)
{
prop = new ctProperty(name);
AddProperty(prop);
}
return prop;
}
void ctProperties::Clear()
{
m_list.DeleteContents(TRUE);
m_list.Clear();
m_list.DeleteContents(FALSE);
}
void ctProperties::Copy(const ctProperties& properties)
{
wxNode* node = properties.m_list.GetFirst();
while (node)
{
ctProperty* prop = (ctProperty*) node->GetData();
AddProperty(new ctProperty(* prop));
node = node->GetNext();
}
}
void ctProperties::SetProperty(const wxString& name, const wxString& value)
{
ctProperty* prop = FindOrCreateProperty(name);
prop->SetValue(value);
}
void ctProperties::SetProperty(const wxString& name, long value)
{
ctProperty* prop = FindOrCreateProperty(name);
prop->GetVariant() = value;
}
void ctProperties::SetProperty(const wxString& name, bool value)
{
ctProperty* prop = FindOrCreateProperty(name);
prop->GetVariant() = (bool) value;
}
void ctProperties::SetProperty(const wxString& name, const wxVariant& value)
{
ctProperty* prop = FindOrCreateProperty(name);
prop->SetValue(value);
}
ctProperty* ctProperties::GetNth(int i) const
{
wxASSERT( i < (int) GetCount() );
if (i < (int) GetCount())
{
wxNode* node = m_list.Nth(i);
return (ctProperty*) node->GetData();
}
return NULL;
}
#if 0
/// Combine the styles of all selected properties
/// with this group name.
long ctProperties::CombineStyles(const wxString& groupName)
{
long styleValue = 0;
wxNode* node = m_list.GetFirst();
while (node)
{
ctProperty* prop = (ctProperty*) node->GetData();
if (prop->GetGroupName() == groupName && prop->GetVariant().GetBool())
{
styleValue |= prop->GetStyleValue();
}
node = node->GetNext();
}
return styleValue;
}
/// Combine the styles of all selected properties
/// with this group name.
wxString ctProperties::CombineStylesString(const wxString& groupName)
{
wxString styleList;
wxNode* node = m_list.GetFirst();
while (node)
{
ctProperty* prop = (ctProperty*) node->GetData();
if (prop->GetGroupName() == groupName && prop->GetVariant().GetBool())
{
if (styleList.IsEmpty())
styleList = prop->GetName();
else
styleList = styleList + _T("|") + prop->GetName();
}
node = node->GetNext();
}
return styleList;
}
// Remove any spurious properties that need garbage
// collecting.
void ctProperties::RemoveHiddenProperties()
{
wxNode* node = m_list.GetFirst();
while (node)
{
ctProperty* prop = (ctProperty*) node->GetData();
wxNode* next = node->GetNext();
if (!prop->IsShown())
{
delete node;
delete prop;
}
node = next;
}
}
#endif

View File

@@ -0,0 +1,168 @@
/////////////////////////////////////////////////////////////////////////////
// Name: property.h
// Purpose: ctProperty objects represent name/value pairs,
// for properties of a configuration item.
// Author: Julian Smart
// Modified by:
// Created: 2003-06-03
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _CT_PROPERTY_H_
#define _CT_PROPERTY_H_
#ifdef __GNUG__
#pragma interface "property.cpp"
#endif
#include "wx/variant.h"
/*!
* A property/name pair, with other specialised members for
* storing window/sizer information.
*/
class ctProperty: public wxObject
{
DECLARE_CLASS(ctProperty)
public:
ctProperty()
{
m_readOnly = FALSE;
m_custom = FALSE;
m_show = TRUE;
}
ctProperty(const ctProperty& property) { Copy(property); }
ctProperty(const wxString& descr, const wxVariant& variant,
const wxString& editorType = wxEmptyString,
bool readOnly = FALSE)
{
m_description = descr;
m_variant = variant;
m_editorType = editorType;
m_show = TRUE;
m_readOnly = readOnly;
m_custom = FALSE;
}
ctProperty(const wxString& name, const wxString& value = wxEmptyString)
{
m_variant.SetName(name);
m_variant = value;
m_readOnly = FALSE;
m_custom = FALSE;
m_show = TRUE;
}
void operator= (const ctProperty& property) { Copy(property); }
void Copy(const ctProperty& property)
{
m_variant = property.m_variant;
m_editorType = property.m_editorType;
m_description = property.m_description;
m_choices = property.m_choices;
m_show = property.m_show;
m_readOnly = property.m_readOnly;
m_custom = property.m_custom;
}
bool operator== (const ctProperty& property) const
{
return ((m_variant == property.m_variant) &&
(m_editorType == property.m_editorType) &&
(m_description == property.m_description) &&
(m_show == property.m_show) &&
(m_custom == property.m_custom) &&
(m_readOnly == property.m_readOnly) &&
(m_choices == property.m_choices));
}
bool operator!= (const ctProperty& property) const
{
return !((*this) == property);
}
inline const wxString& GetName() const { return m_variant.GetName(); }
inline wxString GetValue() const { return m_variant.GetString(); }
inline wxVariant& GetVariant() { return m_variant; }
inline const wxString& GetEditorType() const { return m_editorType; }
inline const wxArrayString& GetChoices() const { return m_choices; }
inline const wxString& GetDescription() const { return m_description; }
inline bool IsCustom() const { return m_custom; }
inline void SetName(const wxString& name) { m_variant.SetName(name); }
inline void SetValue(const wxString& value) { m_variant = value; }
inline void SetValue(const wxVariant& value) { m_variant = value; }
inline void SetEditorType(const wxString& type) { m_editorType = type; }
inline void SetChoices(const wxArrayString& choices) { m_choices = choices; }
inline void SetDescription(const wxString& descr) { m_description = descr; }
inline void Show(bool show) { m_show = show; }
inline bool IsShown() const { return m_show; }
inline bool GetReadOnly() const { return m_readOnly; }
inline void SetReadOnly(bool readOnly) { m_readOnly = readOnly; }
inline void SetCustom(bool custom) { m_custom = custom; }
// The name and value
wxVariant m_variant;
// The editor type name (e.g. "file")
// used to choose an editor.
wxString m_editorType;
// Array of choices
wxArrayString m_choices;
// Description
wxString m_description;
// Whether to show or hide (e.g. not properly initialized)
bool m_show;
// Read-only
bool m_readOnly;
// Whether it's a custom property (so save
// type/description)
bool m_custom;
};
// A class to manage properties
class ctProperties: public wxObject
{
DECLARE_CLASS(ctProperties)
public:
ctProperties() {}
ctProperties(const ctProperties& properties) { Copy(properties); }
~ctProperties() { Clear(); }
void operator = (const ctProperties& properties) { Clear(); Copy(properties); }
void Copy(const ctProperties& properties);
inline const wxList& GetList() const { return m_list; }
inline size_t GetCount() const { return m_list.GetCount(); }
void AddProperty(ctProperty* property, const wxString& insertAfter = wxEmptyString);
void SetProperty(const wxString& name, const wxString& value);
void SetProperty(const wxString& name, long value);
void SetProperty(const wxString& name, bool value);
void SetProperty(const wxString& name, const wxVariant& value);
void RemoveProperty(ctProperty* property);
void DeleteProperty(const wxString& name);
ctProperty* FindProperty(const wxString& name) const;
ctProperty* FindOrCreateProperty(const wxString& name);
wxString FindPropertyValueString(const wxString& name) const;
wxVariant FindPropertyValue(const wxString& name) const;
ctProperty* GetNth(int i) const;
void Clear();
private:
wxList m_list;
};
#endif
// _CT_PROPERTY_H_

View File

@@ -0,0 +1,364 @@
/////////////////////////////////////////////////////////////////////////////
// Name: settingsdialog.cpp
// Purpose:
// Author:
// Modified by:
// Created:
// RCS-ID:
// Copyright:
// Licence:
/////////////////////////////////////////////////////////////////////////////
#include "wx/wx.h"
#include "wx/cshelp.h"
#include "wx/statline.h"
#include "wx/splitter.h"
#include "wx/scrolwin.h"
#include "wx/spinctrl.h"
#include "wx/spinbutt.h"
#include "wx/valgen.h"
#include "wx/notebook.h"
#include "wxconfigtool.h"
#include "settingsdialog.h"
////@begin XPM images
////@end XPM images
/*!
* ctSettingsDialog type definition
*/
IMPLEMENT_CLASS( ctSettingsDialog, wxDialog )
/*!
* ctSettingsDialog event table definition
*/
BEGIN_EVENT_TABLE( ctSettingsDialog, wxDialog )
////@begin ctSettingsDialog event table entries
EVT_BUTTON( wxID_OK, ctSettingsDialog::OnOk )
EVT_BUTTON( wxID_CANCEL, ctSettingsDialog::OnCancel )
EVT_BUTTON( wxID_HELP, ctSettingsDialog::OnHelp )
////@end ctSettingsDialog event table entries
END_EVENT_TABLE()
/*!
* ctSettingsDialog constructor
*/
ctSettingsDialog::ctSettingsDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
}
/*!
* Control creation for ctSettingsDialog
*/
void ctSettingsDialog::CreateControls()
{
////@begin ctSettingsDialog content construction
ctSettingsDialog* item1 = this;
wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL);
item1->SetSizer(item2);
item1->SetAutoLayout(TRUE);
wxNotebook* item3 = new wxNotebook(item1, ID_NOTEBOOK, wxDefaultPosition, wxSize(200, 200), wxNB_TOP);
wxNotebookSizer* item3Sizer = new wxNotebookSizer(item3);
ctGeneralSettingsDialog* item4 = new ctGeneralSettingsDialog(item3, ID_GENERAL_SETTINGS_DIALOG, wxDefaultPosition, wxSize(100, 80), 0);
item3->AddPage(item4, _("General"));
ctLocationSettingsDialog* item9 = new ctLocationSettingsDialog(item3, ID_LOCATION_SETTINGS_DIALOG, wxDefaultPosition, wxSize(100, 80), 0);
item3->AddPage(item9, _("Locations"));
item2->Add(item3Sizer, 0, wxGROW|wxALL, 5);
wxBoxSizer* item19 = new wxBoxSizer(wxHORIZONTAL);
item2->Add(item19, 0, wxGROW|wxALL, 5);
item19->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* item21 = new wxButton(item1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0);
item21->SetDefault();
item19->Add(item21, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* item22 = new wxButton(item1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0);
item19->Add(item22, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* item23 = new wxButton(item1, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, 0);
item19->Add(item23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
#if defined(__WXGTK__) || defined(__WXMAC__)
wxContextHelpButton* item24 = new wxContextHelpButton(item1, wxID_CONTEXT_HELP, wxDefaultPosition, wxSize(20, -1), wxBU_AUTODRAW);
item19->Add(item24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
#endif
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
Centre();
////@end ctSettingsDialog content construction
}
/*!
* Event handler for wxID_OK
*/
void ctSettingsDialog::OnOk( wxCommandEvent& event )
{
// Replace with custom code
event.Skip();
}
/*!
* Event handler for wxID_CANCEL
*/
void ctSettingsDialog::OnCancel( wxCommandEvent& event )
{
// Replace with custom code
event.Skip();
}
/*!
* Event handler for wxID_HELP
*/
void ctSettingsDialog::OnHelp( wxCommandEvent& event )
{
wxNotebook* notebook = (wxNotebook*) FindWindow(ID_NOTEBOOK);
int sel = notebook->GetSelection();
wxASSERT_MSG( (sel != -1), wxT("A notebook tab should always be selected."));
wxWindow* page = (wxWindow*) notebook->GetPage(sel);
wxString helpTopic;
if (page->GetId() == ID_GENERAL_SETTINGS_DIALOG)
{
helpTopic = wxT("General settings dialog");
}
else if (page->GetId() == ID_LOCATION_SETTINGS_DIALOG)
{
helpTopic = wxT("Location dialog");
}
if (!helpTopic.IsEmpty())
{
wxGetApp().GetHelpController().DisplaySection(helpTopic);
}
}
/*!
* Should we show tooltips?
*/
bool ctSettingsDialog::ShowToolTips()
{
return TRUE;
}
/*!
* ctGeneralSettingsDialog type definition
*/
IMPLEMENT_CLASS( ctGeneralSettingsDialog, wxPanel )
/*!
* ctGeneralSettingsDialog event table definition
*/
BEGIN_EVENT_TABLE( ctGeneralSettingsDialog, wxPanel )
////@begin ctGeneralSettingsDialog event table entries
////@end ctGeneralSettingsDialog event table entries
END_EVENT_TABLE()
/*!
* ctGeneralSettingsDialog constructor
*/
ctGeneralSettingsDialog::ctGeneralSettingsDialog( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
{
wxPanel::Create( parent, id, pos, size, style );
CreateControls();
}
/*!
* Control creation for ctGeneralSettingsDialog
*/
void ctGeneralSettingsDialog::CreateControls()
{
////@begin ctGeneralSettingsDialog content construction
ctGeneralSettingsDialog* item4 = this;
wxBoxSizer* item5 = new wxBoxSizer(wxVERTICAL);
item4->SetSizer(item5);
item4->SetAutoLayout(TRUE);
wxStaticBox* item6Static = new wxStaticBox(item4, -1, _("General settings"));
wxStaticBoxSizer* item6 = new wxStaticBoxSizer(item6Static, wxVERTICAL);
item5->Add(item6, 1, wxGROW|wxALL, 5);
wxCheckBox* item7 = new wxCheckBox(item4, ID_LOAD_LAST_DOCUMENT, _("&Load last document"), wxDefaultPosition, wxDefaultSize, 0);
item7->SetValue(FALSE);
item6->Add(item7, 0, wxALIGN_LEFT|wxALL, 5);
wxCheckBox* item8 = new wxCheckBox(item4, ID_SHOW_TOOLTIPS, _("&Show tooltips"), wxDefaultPosition, wxDefaultSize, 0);
item8->SetValue(FALSE);
item6->Add(item8, 0, wxALIGN_LEFT|wxALL, 5);
GetSizer()->Fit(this);
////@end ctGeneralSettingsDialog content construction
FindWindow(ID_LOAD_LAST_DOCUMENT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_loadLastDocument));
FindWindow(ID_SHOW_TOOLTIPS)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useToolTips));
}
/*!
* Should we show tooltips?
*/
bool ctGeneralSettingsDialog::ShowToolTips()
{
return TRUE;
}
/*!
* ctLocationSettingsDialog type definition
*/
IMPLEMENT_CLASS( ctLocationSettingsDialog, wxPanel )
/*!
* ctLocationSettingsDialog event table definition
*/
BEGIN_EVENT_TABLE( ctLocationSettingsDialog, wxPanel )
////@begin ctLocationSettingsDialog event table entries
EVT_UPDATE_UI( ID_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnUpdateWxwinHierarchy )
EVT_BUTTON( ID_CHOOSE_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnChooseWxwinHierarchy )
EVT_UPDATE_UI( ID_CHOOSE_WXWIN_HIERARCHY, ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy )
////@end ctLocationSettingsDialog event table entries
END_EVENT_TABLE()
/*!
* ctLocationSettingsDialog constructor
*/
ctLocationSettingsDialog::ctLocationSettingsDialog( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
{
wxPanel::Create( parent, id, pos, size, style );
CreateControls();
}
/*!
* Control creation for ctLocationSettingsDialog
*/
void ctLocationSettingsDialog::CreateControls()
{
////@begin ctLocationSettingsDialog content construction
ctLocationSettingsDialog* item9 = this;
wxBoxSizer* item10 = new wxBoxSizer(wxVERTICAL);
item9->SetSizer(item10);
item9->SetAutoLayout(TRUE);
wxStaticBox* item11Static = new wxStaticBox(item9, -1, _("Locations"));
wxStaticBoxSizer* item11 = new wxStaticBoxSizer(item11Static, wxVERTICAL);
item10->Add(item11, 1, wxGROW|wxALL, 5);
wxStaticText* item12 = new wxStaticText(item9, wxID_STATIC, _("&wxWindows hierarchy:"), wxDefaultPosition, wxDefaultSize, 0);
item11->Add(item12, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
wxBoxSizer* item13 = new wxBoxSizer(wxHORIZONTAL);
item11->Add(item13, 0, wxGROW, 5);
wxTextCtrl* item14 = new wxTextCtrl(item9, ID_WXWIN_HIERARCHY, _(""), wxDefaultPosition, wxSize(200, -1), 0);
item13->Add(item14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* item15 = new wxButton(item9, ID_CHOOSE_WXWIN_HIERARCHY, _("&Choose..."), wxDefaultPosition, wxDefaultSize, 0);
item13->Add(item15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* item16 = new wxBoxSizer(wxHORIZONTAL);
item11->Add(item16, 0, wxGROW, 5);
item16->Add(60, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxCheckBox* item18 = new wxCheckBox(item9, ID_USE_WXWIN, _("&Use WXWIN environment variable"), wxDefaultPosition, wxDefaultSize, 0);
item18->SetValue(FALSE);
item16->Add(item18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
GetSizer()->Fit(this);
////@end ctLocationSettingsDialog content construction
FindWindow(ID_WXWIN_HIERARCHY)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_frameworkDir));
FindWindow(ID_USE_WXWIN)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_useEnvironmentVariable));
}
/*!
* Update event handler for ID_WXWIN_HIERARCHY
*/
void ctLocationSettingsDialog::OnUpdateWxwinHierarchy( wxUpdateUIEvent& event )
{
wxCheckBox* checkbox = (wxCheckBox*) FindWindow(ID_USE_WXWIN);
event.Enable(!checkbox->GetValue());
}
/*!
* Event handler for ID_CHOOSE_WXWIN_HIERARCHY
*/
void ctLocationSettingsDialog::OnChooseWxwinHierarchy( wxCommandEvent& event )
{
wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow( ID_WXWIN_HIERARCHY );
wxASSERT( textCtrl != NULL );
wxString defaultPath = textCtrl->GetValue();
wxDirDialog dialog(this, _("Choose the location of the wxWindows hierarchy"),
defaultPath);
if (dialog.ShowModal() == wxID_OK)
{
textCtrl->SetValue(dialog.GetPath());
}
}
/*!
* Update event handler for ID_CHOOSE_WXWIN_HIERARCHY
*/
void ctLocationSettingsDialog::OnUpdateChooseWxwinHierarchy( wxUpdateUIEvent& event )
{
wxCheckBox* checkbox = (wxCheckBox*) FindWindow(ID_USE_WXWIN);
event.Enable(!checkbox->GetValue());
}
/*!
* Should we show tooltips?
*/
bool ctLocationSettingsDialog::ShowToolTips()
{
return wxGetApp().GetSettings().m_useToolTips;
}

View File

@@ -0,0 +1,154 @@
/////////////////////////////////////////////////////////////////////////////
// Name: settingsdialog.h
// Purpose:
// Author:
// Modified by:
// Created:
// RCS-ID:
// Copyright:
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _SETTINGSDIALOG_H_
#define _SETTINGSDIALOG_H_
/*!
* Includes
*/
////@begin includes
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
class ctGeneralSettingsDialog;
class ctLocationSettingsDialog;
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
#define ID_SETTINGS_DIALOG 10000
#define ID_NOTEBOOK 10001
#define ID_GENERAL_SETTINGS_DIALOG 10005
#define ID_LOAD_LAST_DOCUMENT 10006
#define ID_SHOW_TOOLTIPS 10007
#define ID_LOCATION_SETTINGS_DIALOG 10008
#define ID_WXWIN_HIERARCHY 10010
#define ID_CHOOSE_WXWIN_HIERARCHY 10011
#define ID_USE_WXWIN 10012
////@end control identifiers
/*!
* ctSettingsDialog class declaration
*/
class ctSettingsDialog: public wxDialog
{
public:
/// Constructor
ctSettingsDialog( wxWindow* parent, wxWindowID id = -1,
const wxString& caption = _("Configuration Settings"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCAPTION|wxSYSTEM_MENU );
/// Creates the controls and sizers
void CreateControls();
////@begin ctSettingsDialog event handler declarations
/// Event handler for wxID_OK
void OnOk( wxCommandEvent& event );
/// Event handler for wxID_CANCEL
void OnCancel( wxCommandEvent& event );
/// Event handler for wxID_HELP
void OnHelp( wxCommandEvent& event );
////@end ctSettingsDialog event handler declarations
////@begin ctSettingsDialog member function declarations
////@end ctSettingsDialog member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
DECLARE_CLASS( ctSettingsDialog )
DECLARE_EVENT_TABLE()
};
/*!
* ctGeneralSettingsDialog class declaration
*/
class ctGeneralSettingsDialog: public wxPanel
{
public:
/// Constructor
ctGeneralSettingsDialog( wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER|wxTAB_TRAVERSAL );
/// Creates the controls and sizers
void CreateControls();
////@begin ctGeneralSettingsDialog event handler declarations
////@end ctGeneralSettingsDialog event handler declarations
////@begin ctGeneralSettingsDialog member function declarations
////@end ctGeneralSettingsDialog member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
DECLARE_CLASS( ctGeneralSettingsDialog )
DECLARE_EVENT_TABLE()
};
/*!
* ctLocationSettingsDialog class declaration
*/
class ctLocationSettingsDialog: public wxPanel
{
public:
/// Constructor
ctLocationSettingsDialog( wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER|wxTAB_TRAVERSAL );
/// Creates the controls and sizers
void CreateControls();
////@begin ctLocationSettingsDialog event handler declarations
/// Update event handler for ID_WXWIN_HIERARCHY
void OnUpdateWxwinHierarchy( wxUpdateUIEvent& event );
/// Event handler for ID_CHOOSE_WXWIN_HIERARCHY
void OnChooseWxwinHierarchy( wxCommandEvent& event );
/// Update event handler for ID_CHOOSE_WXWIN_HIERARCHY
void OnUpdateChooseWxwinHierarchy( wxUpdateUIEvent& event );
////@end ctLocationSettingsDialog event handler declarations
////@begin ctLocationSettingsDialog member function declarations
////@end ctLocationSettingsDialog member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
DECLARE_CLASS( ctLocationSettingsDialog )
DECLARE_EVENT_TABLE()
};
#endif
// _SETTINGSDIALOG_H_

View File

@@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////
// Name: symbols.h
// Purpose: Application symbols file
// Author:
// Modified by:
// Created:
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _CT_SYMBOLS_H_
#define _CT_SYMBOLS_H_
//// Build settings
// Version
#define ctVERSION_NUMBER 1.0
// Whether to have a splash screen
#define ctUSE_SPLASH_SCREEN 0
// Cell background colour in property editor
// Light blue
#define ctCELL_BACKGROUND_COLOUR wxColour(227, 228, 255)
// Custom property cell background colour in property editor
// Light blue
#define ctCUSTOM_CELL_BACKGROUND_COLOUR wxColour(255, 227, 227)
// Description window colour in property editor
// Light yellow
#define ctDESCRIPTION_BACKGROUND_COLOUR wxColour(255, 255, 192)
// Misc symbols
#define ctSYMBOL_WEBSITE wxT("http://www.wxwindows.org")
#endif

View File

@@ -0,0 +1,477 @@
/////////////////////////////////////////////////////////////////////////////
// Name: utils.cpp
// Purpose: Utility functions and classes
// Author: Julian Smart
// Modified by:
// Created: 2002-09-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
// #pragma implementation
#endif
#include "wx/wx.h"
#include "wx/image.h"
#include "wx/notebook.h"
#include "wx/splitter.h"
#include "wx/wfstream.h"
#include "wx/datstrm.h"
#include "wx/file.h"
#include "wx/listctrl.h"
#include "wx/tokenzr.h"
#include "wx/process.h"
#include "wx/mimetype.h"
#include "wx/variant.h"
#include "wx/cshelp.h"
#include "wx/cmdline.h"
#include <math.h>
#ifdef __WXMSW__
#include <windows.h>
#include "wx/msw/winundef.h"
#endif
#include "utils.h"
// Returns the image type, or -1, determined from the extension.
int apDetermineImageType(const wxString& filename)
{
wxString path, name, ext;
wxSplitPath(filename, & path, & name, & ext);
ext.MakeLower();
if (ext == "jpg" || ext == "jpeg")
return wxBITMAP_TYPE_JPEG;
else if (ext == "gif")
return wxBITMAP_TYPE_GIF;
else if (ext == "bmp")
return wxBITMAP_TYPE_BMP;
else if (ext == "png")
return wxBITMAP_TYPE_PNG;
else if (ext == "pcx")
return wxBITMAP_TYPE_PCX;
else if (ext == "tif" || ext == "tiff")
return wxBITMAP_TYPE_TIF;
else
return -1;
}
// Convert a colour to a 6-digit hex string
wxString apColourToHexString(const wxColour& col)
{
wxString hex;
hex += wxDecToHex(col.Red());
hex += wxDecToHex(col.Green());
hex += wxDecToHex(col.Blue());
return hex;
}
// Convert 6-digit hex string to a colour
wxColour apHexStringToColour(const wxString& hex)
{
unsigned int r = 0;
unsigned int g = 0;
unsigned int b = 0;
r = wxHexToDec(hex.Mid(0, 2));
g = wxHexToDec(hex.Mid(2, 2));
b = wxHexToDec(hex.Mid(4, 2));
return wxColour(r, g, b);
}
// Convert a wxFont to a string
wxString apFontToString(const wxFont& font)
{
wxString str;
str.Printf(wxT("%d,%d,%d,%d,%d,%s"), (int) font.GetPointSize(),
(int) font.GetFamily(), (int) font.GetStyle(), (int) font.GetWeight(),
(int) font.GetUnderlined(), font.GetFaceName().c_str());
return str;
}
// Convert a string to a wxFont
wxFont apStringToFont(const wxString& str)
{
int pointSize = 12;
int family = wxSWISS;
int style = wxNORMAL;
int weight = wxNORMAL;
int underlined = 0;
wxString facename(wxT(""));
wxStringTokenizer tkz(str, wxT(","));
int i = 0;
while (tkz.HasMoreTokens())
{
wxString token = tkz.GetNextToken();
if (i == 0)
{
StringToInt(token, & pointSize);
#if defined(__WXGTK__) || defined(__WXMAC__)
if (pointSize < 8)
pointSize = 8;
if (pointSize == 9)
pointSize = 10;
#endif
}
else if (i == 1)
StringToInt(token, & family);
else if (i == 2)
StringToInt(token, & style);
else if (i == 3)
StringToInt(token, & weight);
else if (i == 4)
StringToInt(token, & underlined);
else if (i == 5)
{
facename = token;
#if defined(__WXGTK__)
if (facename == wxT("Arial"))
facename = wxT("helvetica");
#endif
}
i ++;
}
return wxFont(pointSize, family, style, weight, (underlined != 0), facename);
}
// Get the index of the given named wxNotebook page
int apFindNotebookPage(wxNotebook* notebook, const wxString& name)
{
int i;
for (i = 0; i < notebook->GetPageCount(); i++)
if (name == notebook->GetPageText(i))
return i;
return -1;
}
/*
* View an HTML file
*/
void apViewHTMLFile(const wxString& url)
{
#ifdef __WXMSW__
HKEY hKey;
TCHAR szCmdName[1024];
DWORD dwType, dw = sizeof(szCmdName);
LONG lRes;
lRes = RegOpenKey(HKEY_CLASSES_ROOT, "htmlfile\\shell\\open\\command", &hKey);
if(lRes == ERROR_SUCCESS && RegQueryValueEx(hKey,(LPTSTR)NULL, NULL,
&dwType, (LPBYTE)szCmdName, &dw) == ERROR_SUCCESS)
{
strcat(szCmdName, (const char*) url);
PROCESS_INFORMATION piProcInfo;
STARTUPINFO siStartInfo;
memset(&siStartInfo, 0, sizeof(STARTUPINFO));
siStartInfo.cb = sizeof(STARTUPINFO);
CreateProcess(NULL, szCmdName, NULL, NULL, FALSE, 0, NULL,
NULL, &siStartInfo, &piProcInfo );
}
if(lRes == ERROR_SUCCESS)
RegCloseKey(hKey);
#else
wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(wxT("html"));
if ( !ft )
{
wxLogError(_T("Impossible to determine the file type for extension html. Please edit your MIME types."));
return ;
}
wxString cmd;
bool ok = ft->GetOpenCommand(&cmd,
wxFileType::MessageParameters(url, _T("")));
delete ft;
if (!ok)
{
// TODO: some kind of configuration dialog here.
wxMessageBox(_("Could not determine the command for running the browser."),
wxT("Browsing problem"), wxOK|wxICON_EXCLAMATION);
return ;
}
ok = (wxExecute(cmd, FALSE) != 0);
#endif
}
wxString wxGetTempDir()
{
wxString dir;
#if defined(__WXMAC__) && !defined(__DARWIN__)
dir = wxMacFindFolder( (short) kOnSystemDisk, kTemporaryFolderType, kCreateFolder ) ;
#else // !Mac
dir = wxGetenv(_T("TMP"));
if ( dir.empty() )
{
dir = wxGetenv(_T("TEMP"));
}
if ( dir.empty() )
{
// default
#ifdef __DOS__
dir = _T(".");
#else
dir = _T("/tmp");
#endif
}
#endif // Mac/!Mac
return dir;
}
// Invoke app for file type
// Eventually we should allow the user to select an app.
bool apInvokeAppForFile(const wxString& filename)
{
wxString path, file, ext;
wxSplitPath(filename, & path, & file, & ext);
wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
if ( !ft )
{
wxString msg;
msg.Printf(wxT("Sorry, could not determine what application to invoke for extension %s\nYou may need to edit your MIME types."),
ext.c_str());
wxMessageBox(msg, wxT("Application Invocation"), wxICON_EXCLAMATION|wxOK);
return FALSE;
}
wxString cmd;
bool ok = ft->GetOpenCommand(&cmd,
wxFileType::MessageParameters(filename, _T("")));
delete ft;
ok = (wxExecute(cmd, FALSE) != 0);
return ok;
}
// Find the absolute path where this application has been run from.
// argv0 is wxTheApp->argv[0]
// cwd is the current working directory (at startup)
// appVariableName is the name of a variable containing the directory for this app, e.g.
// MYAPPDIR. This is checked first.
wxString apFindAppPath(const wxString& argv0, const wxString& cwd, const wxString& appVariableName)
{
wxString str;
// Try appVariableName
if (!appVariableName.IsEmpty())
{
str = wxGetenv(appVariableName);
if (!str.IsEmpty())
return str;
}
if (wxIsAbsolutePath(argv0))
return wxPathOnly(argv0);
else
{
// Is it a relative path?
wxString currentDir(cwd);
if (currentDir.Last() != wxFILE_SEP_PATH)
currentDir += wxFILE_SEP_PATH;
str = currentDir + argv0;
if (wxFileExists(str))
return wxPathOnly(str);
}
// OK, it's neither an absolute path nor a relative path.
// Search PATH.
wxPathList pathList;
pathList.AddEnvList(wxT("PATH"));
str = pathList.FindAbsoluteValidPath(argv0);
if (!str.IsEmpty())
return wxPathOnly(str);
// Failed
return wxEmptyString;
}
// Adds a context-sensitive help button, for non-Windows platforms
void apAddContextHelpButton(wxWindow* parent, wxSizer* sizer, int sizerFlags, int sizerBorder)
{
#if defined(__WXGTK__) || defined(__WXMAC__)
#ifdef __WXMAC__
wxSize buttonSize(20, 20);
#else
wxSize buttonSize(-1, -1);
#endif
wxButton *contextButton = new wxContextHelpButton( parent, wxID_CONTEXT_HELP,
wxDefaultPosition, buttonSize);
sizer->Add( contextButton, 0, sizerFlags, sizerBorder );
// Add a bit of space on the right, to allow for the dialog resizing
// handle
#ifdef __WXMAC__
sizer->Add(0, 0, 0, wxRIGHT, 10);
#endif
contextButton->SetHelpText(_("Invokes context-sensitive help for the clicked-on window."));
if (wxGetApp().UsingTooltips())
{
contextButton->SetToolTip(_("Invokes context-sensitive help for the clicked-on window."));
}
#endif
}
// Get selected wxNotebook page
wxWindow* apNotebookGetSelectedPage(wxNotebook* notebook)
{
int sel = notebook->GetSelection();
if (sel > -1)
{
return notebook->GetPage(sel);
}
return NULL;
}
/*
* wxIconInfo
*/
wxIconInfo::wxIconInfo(const wxString& name)
{
m_maxStates = 0;
m_name = name;
int i;
for (i = 0; i < wxMAX_ICON_STATES; i++)
m_states[i] = 0;
}
int wxIconInfo::GetIconId(int state, bool enabled) const
{
wxASSERT ( state < (wxMAX_ICON_STATES * 2) );
wxASSERT ( state < m_maxStates );
return m_states[state * 2 + (enabled ? 0 : 1)];
}
void wxIconInfo::SetIconId(int state, bool enabled, int iconId)
{
wxASSERT ( state < (wxMAX_ICON_STATES * 2) );
if (state+1 > m_maxStates)
m_maxStates = state+1;
m_states[state * 2 + (enabled ? 0 : 1)] = iconId;
}
/*
* wxIconTable
* Contains a list of wxIconInfos
*/
wxIconTable::wxIconTable(wxImageList* imageList)
{
m_imageList = imageList;
DeleteContents(TRUE);
}
void wxIconTable::AppendInfo(wxIconInfo* info)
{
Append(info);
}
// Easy way of initialising both the image list and the
// table. It will generate image ids itself while appending the icon.
bool wxIconTable::AddInfo(const wxString& name, const wxIcon& icon, int state, bool enabled)
{
wxASSERT (m_imageList != NULL);
wxIconInfo* info = FindInfo(name);
if (!info)
{
info = new wxIconInfo(name);
Append(info);
}
info->SetIconId(state, enabled, m_imageList->Add(icon));
return TRUE;
}
wxIconInfo* wxIconTable::FindInfo(const wxString& name) const
{
wxNode* node = First();
while (node)
{
wxIconInfo* info = (wxIconInfo*) node->Data();
if (info->GetName() == name)
return info;
node = node->Next();
}
return NULL;
}
int wxIconTable::GetIconId(const wxString& name, int state, bool enabled) const
{
wxIconInfo* info = FindInfo(name);
if (!info)
return -1;
return info->GetIconId(state, enabled);
}
bool wxIconTable::SetIconId(const wxString& name, int state, bool enabled, int iconId)
{
wxIconInfo* info = FindInfo(name);
if (!info)
return FALSE;
info->SetIconId(state, enabled, iconId);
return TRUE;
}
// Output stream operators
wxOutputStream& operator <<(wxOutputStream& stream, const wxString& s)
{
stream.Write(s, s.Length());
return stream;
}
wxOutputStream& operator <<(wxOutputStream& stream, long l)
{
wxString str;
str.Printf(_T("%ld"), l);
return stream << str;
}
wxOutputStream& operator <<(wxOutputStream& stream, const char c)
{
wxString str;
str.Printf(_T("%c"), c);
return stream << str;
}
// Convert characters to HTML equivalents
wxString ctEscapeHTMLCharacters(const wxString& str)
{
wxString s;
size_t len = str.Length();
size_t i;
for (i = 0; i < len; i++)
{
wxChar c = str.GetChar(i);
if (c == _T('<'))
s += _T("&lt;");
else if (c == _T('>'))
s += _T("&gt;");
else if (c == _T('&'))
s += _T("&amp;");
else
s += c;
}
return s;
}

View File

@@ -0,0 +1,200 @@
/////////////////////////////////////////////////////////////////////////////
// Name: utils.h
// Purpose: Utility functions and classes
// Author: Julian Smart
// Modified by:
// Created: 2002-09-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
/*!
* \file
* \brief A file of utility functions and classes.
*/
#ifdef __GNUG__
// #pragma interface
#endif
#ifndef _AP_UTILS_H_
#define _AP_UTILS_H_
#ifndef DOXYGEN_SKIP
/*!
* \defgroup ForwardDeclarations Forward Declations
*/
/*@{*/
class WXDLLEXPORT wxImage;
class WXDLLEXPORT wxNotebook;
class WXDLLEXPORT wxInputStream;
class WXDLLEXPORT wxOutputStream;
class WXDLLEXPORT wxFileInputStream;
class WXDLLEXPORT wxFileOutputStream;
class WXDLLEXPORT wxDataInputStream;
class WXDLLEXPORT wxDataOutputStream;
class WXDLLEXPORT wxSplitterWindow;
class WXDLLEXPORT wxVariant;
class WXDLLEXPORT wxListCtrl;
/* \endif
*/
/*@}*/
#endif
#ifdef __WXMSW__
#define wxNEWLINE wxT("\r\n")
#else
#define wxNEWLINE wxT("\n")
#endif
/// Returns the image type, or -1, determined from the extension.
int apDetermineImageType(const wxString& filename);
/// Convert a colour to a 6-digit hex string
wxString apColourToHexString(const wxColour& col);
/// Convert 6-digit hex string to a colour
wxColour apHexStringToColour(const wxString& hex);
/// Convert a wxFont to a string
wxString apFontToString(const wxFont& font);
/// Convert a string to a wxFont
wxFont apStringToFont(const wxString& str);
/// Get the index of the given named wxNotebook page
int apFindNotebookPage(wxNotebook* notebook, const wxString& name);
/// View the given URL
void apViewHTMLFile(const wxString& url);
/// Returns the system temporary directory.
wxString wxGetTempDir();
/// Launch the application associated with the filename's extension
bool apInvokeAppForFile(const wxString& filename);
/// \brief Find the absolute path where this application has been run from.
///
/// \param argv0 wxTheApp->argv[0]
/// \param cwd The current working directory (at startup)
/// \param appVariableName The name of a variable containing the directory for this app, e.g.
/// MYAPPDIR. This is used as a last resort.
wxString apFindAppPath(const wxString& argv0, const wxString& cwd, const wxString& appVariableName = wxEmptyString);
/// Adds a context-sensitive help button, for non-Windows platforms
void apAddContextHelpButton(wxWindow* parent, wxSizer* sizer, int sizerFlags = wxALIGN_CENTRE|wxALL, int sizerBorder = 5);
/// Get selected wxNotebook page
wxWindow* apNotebookGetSelectedPage(wxNotebook* notebook);
#define wxMAX_ICON_STATES 4
/*
wxIconInfo, wxIconTable
associate multiple state icons with items in tree controls
(and potentially other controls).
So instead of having to remember a lot of image list ids,
you have a named state info object which contains up to 4 different states
(identified by the integers 0 - 3). Each of these states can
be in a further 2 sub-states - enabled or disabled.
wxIconTable holds a list of these state info objects
and has a convenient API. For example, the following adds
icons for a checkbox item that can be: on/enabled, off/enabled,
on/disabled,off/disabled.
m_iconTable.AddInfo("Checkbox", wxICON(checked), 0, TRUE);
m_iconTable.AddInfo("Checkbox", wxICON(checked_dis), 0, FALSE);
m_iconTable.AddInfo("Checkbox", wxICON(unchecked), 1, TRUE);
m_iconTable.AddInfo("Checkbox", wxICON(unchecked_dis), 1, FALSE);
When you update the item image in response to (e.g.) user interaction,
you can say something like this:
int iconId = m_iconTable.GetIconId("Checkbox", 0, FALSE);
treeCtrl.SetItemImage(itemId, iconId, wxTreeItemIcon_Normal);
treeCtrl.SetItemImage(itemId, iconId, wxTreeItemIcon_Selected);
*/
/*
* wxIconInfo
* Stores information about the visual state of an item in a tree control
*/
class wxIconInfo: public wxObject
{
public:
wxIconInfo(const wxString& name);
// How many states? (Each state
// has enabled/disabled state)
// Max (say) 4 states, each with
// enabled/disabled
int GetStateCount() const { return m_maxStates; };
void SetStateCount(int count) { m_maxStates; }
int GetIconId(int state, bool enabled = TRUE) const;
void SetIconId(int state, bool enabled, int iconId);
const wxString& GetName() const { return m_name; }
protected:
int m_maxStates;
int m_states[wxMAX_ICON_STATES * 2]; // Enabled/disabled
wxString m_name; // Name of icon, e.g. "Package"
};
/*!
* wxIconTable
* Contains a list of wxIconInfos
*/
class wxIconTable: public wxList
{
public:
wxIconTable(wxImageList* imageList = NULL);
void AppendInfo(wxIconInfo* info);
// Easy way of initialising both the image list and the
// info db. It will generate image ids itself while appending the icon.
// 'state' is an integer from 0 up to the max allowed, representing a different
// state. There may be only one, or (for a checkbox) there may be two.
// A folder that can be open or closed would have two states.
// Enabled/disabled is taken as a special case.
bool AddInfo(const wxString& name, const wxIcon& icon, int state, bool enabled);
wxIconInfo* FindInfo(const wxString& name) const;
int GetIconId(const wxString& name, int state, bool enabled = TRUE) const;
bool SetIconId(const wxString& name, int state, bool enabled, int iconId) ;
void SetImageList(wxImageList* imageList) { m_imageList = imageList; }
wxImageList* GetImageList() const { return m_imageList; }
protected:
wxImageList* m_imageList;
};
/// Useful insertion operators for wxOutputStream.
wxOutputStream& operator <<(wxOutputStream&, const wxString& s);
wxOutputStream& operator <<(wxOutputStream&, const char c);
wxOutputStream& operator <<(wxOutputStream&, long l);
// Convert characters to HTML equivalents
wxString ctEscapeHTMLCharacters(const wxString& str);
#endif
// _AP_UTILS_H_

View File

@@ -0,0 +1,250 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wxconfigtool.cpp
// Purpose: Generic application class
// Author: Julian Smart
// Modified by:
// Created: 2002-09-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation wxconfigtool.h
#endif
#include "wx/wx.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/config.h"
#include "wx/laywin.h"
#include "wx/image.h"
#include "wx/menuitem.h"
#include "wx/tooltip.h"
#include "wx/cshelp.h"
#include "wx/html/htmprint.h"
#include "wx/html/htmlwin.h"
#include "wx/filesys.h"
#include "wx/fs_mem.h"
#include "wx/fs_zip.h"
#include "wx/wfstream.h"
#include "wx/variant.h"
#include "wxconfigtool.h"
#include "configtooldoc.h"
#include "configtoolview.h"
#include "mainframe.h"
#include "utils.h"
IMPLEMENT_APP(ctApp)
BEGIN_EVENT_TABLE(ctApp, wxApp)
END_EVENT_TABLE()
ctApp::ctApp()
{
m_helpController = NULL;
m_helpControllerReference = NULL;
m_docManager = NULL;
}
ctApp::~ctApp()
{
}
bool ctApp::OnInit(void)
{
wxLog::SetTimestamp(NULL);
wxHelpProvider::Set(new wxSimpleHelpProvider);
#if wxUSE_LIBPNG
wxImage::AddHandler( new wxPNGHandler );
#endif
#if wxUSE_LIBJPEG
wxImage::AddHandler( new wxJPEGHandler );
#endif
#if wxUSE_GIF
wxImage::AddHandler( new wxGIFHandler );
#endif
#ifdef __WXMSW__
m_helpController = new wxCHMHelpController;
m_helpControllerReference = new wxCHMHelpController;
#else
m_helpController = new wxHtmlHelpController;
m_helpControllerReference = new wxHtmlHelpController;
#endif
// Required for HTML help
#if wxUSE_STREAMS && wxUSE_ZIPSTREAM && wxUSE_ZLIB
wxFileSystem::AddHandler(new wxZipFSHandler);
#endif
wxString currentDir = wxGetCwd();
// Use argv to get current app directory
m_appDir = apFindAppPath(argv[0], currentDir, wxT("WXCONFIGTOOLDIR"));
#ifdef __WXMSW__
// If the development version, go up a directory.
if ((m_appDir.Right(5).CmpNoCase("DEBUG") == 0) ||
(m_appDir.Right(11).CmpNoCase("DEBUGSTABLE") == 0) ||
(m_appDir.Right(7).CmpNoCase("RELEASE") == 0) ||
(m_appDir.Right(13).CmpNoCase("RELEASESTABLE") == 0) ||
(m_appDir.Right(10).CmpNoCase("RELEASEDEV") == 0) ||
(m_appDir.Right(8).CmpNoCase("DEBUGDEV") == 0)
)
m_appDir = wxPathOnly(m_appDir);
#endif
m_docManager = new wxDocManager;
m_docManager->SetMaxDocsOpen(1);
//// Create a template relating documents to their views
(void) new wxDocTemplate(m_docManager, wxGetApp().GetSettings().GetShortAppName(), wxT("*.wxs"), wxT(""), wxT("wxs"), wxT("Doc"), wxT("View"),
CLASSINFO(ctConfigToolDoc), CLASSINFO(ctConfigToolView));
m_settings.Init();
LoadConfig();
wxString helpFilePathReference(GetFullAppPath(_("wx")));
m_helpControllerReference->Initialize(helpFilePathReference);
wxString helpFilePath(GetFullAppPath(_("configtool")));
m_helpController->Initialize(helpFilePath);
ctMainFrame* frame = new ctMainFrame(m_docManager, NULL, -1, wxGetApp().GetSettings().GetAppName(),
GetSettings().m_frameSize.GetPosition(), GetSettings().m_frameSize.GetSize(),
wxDEFAULT_FRAME_STYLE);
SetTopWindow(frame);
switch (wxGetApp().GetSettings().m_frameStatus)
{
case ctSHOW_STATUS_MAXIMIZED:
{
frame->Maximize(TRUE);
break;
}
case ctSHOW_STATUS_MINIMIZED:
{
frame->Iconize(TRUE);
break;
}
default:
case ctSHOW_STATUS_NORMAL:
{
break;
}
}
// Load the file history. This has to be done AFTER the
// main frame has been created, so that the items
// will get appended to the file menu.
{
wxConfig config(wxGetApp().GetSettings().GetAppName(), wxT("Generic Organisation"));
GetFileHistory().Load(config);
}
if (argc > 1)
{
// Concatenate strings since it could have spaces (and quotes)
wxString arg;
int i;
for (i = 1; i < argc; i++)
{
arg += argv[i];
if (i < (argc - 1))
arg += wxString(wxT(" "));
}
if (arg[0u] == '"')
arg = arg.Mid(1);
if (arg.Last() == '"')
arg = arg.Mid(0, arg.Len() - 1);
// Load the file
wxDocument* doc = m_docManager->CreateDocument(arg, wxDOC_SILENT);
if (doc)
doc->SetDocumentSaved(TRUE);
}
else
{
if (GetSettings().m_loadLastDocument)
{
// Load the file that was last loaded
wxDocument* doc = m_docManager->CreateDocument(GetSettings().m_lastFilename, wxDOC_SILENT);
if (doc)
doc->SetDocumentSaved(TRUE);
}
}
GetTopWindow()->Show(TRUE);
return TRUE;
}
int ctApp::OnExit(void)
{
SaveConfig();
// Save the file history
{
wxConfig config(wxGetApp().GetSettings().GetAppName(), wxT("Generic Organisation"));
GetFileHistory().Save(config);
}
delete m_docManager;
m_docManager = NULL;
return 0;
}
void ctApp::ClearHelpControllers()
{
delete m_helpController;
m_helpController = NULL;
delete m_helpControllerReference;
m_helpControllerReference = NULL;
}
// Prepend the current program directory to the name
wxString ctApp::GetFullAppPath(const wxString& filename) const
{
wxString path(m_appDir);
if (path.Last() != wxFILE_SEP_PATH && filename[0] != wxFILE_SEP_PATH)
path += wxFILE_SEP_PATH;
path += filename;
return path;
}
// Load config info
bool ctApp::LoadConfig()
{
return m_settings.LoadConfig();
}
// Save config info
bool ctApp::SaveConfig()
{
return m_settings.SaveConfig();
}
bool ctApp::UsingTooltips()
{
return GetSettings().m_useToolTips;
}
/// Returns the main frame
ctMainFrame* ctApp::GetMainFrame()
{
return wxDynamicCast(wxTheApp->GetTopWindow(), ctMainFrame);
}

View File

@@ -0,0 +1,473 @@
# Microsoft Developer Studio Project File - Name="wxconfigtool" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=wxconfigtool - Win32 DebugDev
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "wxconfigtool.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wxconfigtool.mak" CFG="wxconfigtool - Win32 DebugDev"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "wxconfigtool - Win32 Debug DLL" (based on "Win32 (x86) Application")
!MESSAGE "wxconfigtool - Win32 Release DLL" (based on "Win32 (x86) Application")
!MESSAGE "wxconfigtool - Win32 DebugStable" (based on "Win32 (x86) Application")
!MESSAGE "wxconfigtool - Win32 ReleaseStable" (based on "Win32 (x86) Application")
!MESSAGE "wxconfigtool - Win32 DebugDev" (based on "Win32 (x86) Application")
!MESSAGE "wxconfigtool - Win32 ReleaseDev" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "wxconfigtool - Win32 Debug DLL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "DebugDLL"
# PROP BASE Intermediate_Dir "DebugDLL"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "DebugDLL"
# PROP Intermediate_Dir "DebugDLL"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "$(WXWIN)/include" /I "$(WXWIN)/lib/mswdlld" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /FD /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 wxvc.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wininet.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /pdbtype:sept /libpath:"$(WXWIN)\lib"
!ELSEIF "$(CFG)" == "wxconfigtool - Win32 Release DLL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "ReleaseDLL"
# PROP BASE Intermediate_Dir "ReleaseDLL"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "ReleaseDLL"
# PROP Intermediate_Dir "ReleaseDLL"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "$(WXWIN)/include" /I "$(WXWIN)/lib/mswdll" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 wxvc.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wininet.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /libpath:"$(WXWIN)\lib"
!ELSEIF "$(CFG)" == "wxconfigtool - Win32 DebugStable"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "wxconfigtool___Win32_DebugStable"
# PROP BASE Intermediate_Dir "wxconfigtool___Win32_DebugStable"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "DebugStable"
# PROP Intermediate_Dir "DebugStable"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "$(WXWIN)\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /Yu"wx/wxprec.h" /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "$(WXWINSTABLE)/include" /I "$(WXWINSTABLE)/lib/mswd" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxvc.lib jpeg.lib tiff.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /pdbtype:sept /libpath:"$(WXWIN)\src\Debug" /libpath:"$(WXWIN)\src\jpeg\Debug" /libpath:"$(WXWIN)\src\tiff\Debug" /libpath:"$(WXWIN)\lib"
# ADD LINK32 winmm.lib wxmswd.lib jpegd.lib tiffd.lib pngd.lib zlibd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wininet.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /pdbtype:sept /libpath:"$(WXWINSTABLE)\lib"
!ELSEIF "$(CFG)" == "wxconfigtool - Win32 ReleaseStable"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "wxconfigtool___Win32_ReleaseStable"
# PROP BASE Intermediate_Dir "wxconfigtool___Win32_ReleaseStable"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "ReleaseStable"
# PROP Intermediate_Dir "ReleaseStable"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "$(WXWIN)\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /MD /W3 /GX /O2 /Ob2 /I "$(WXWINSTABLE)/include" /I "$(WXWINSTABLE)/lib/msw" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxvc.lib jpeg.lib tiff.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /libpath:"$(WXWIN)\src\Release" /libpath:"$(WXWIN)\src\jpeg\Release" /libpath:"$(WXWIN)\src\tiff\Release" /libpath:"$(WXWIN)\lib"
# ADD LINK32 winmm.lib wxmsw.lib jpeg.lib tiff.lib png.lib zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wininet.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /libpath:"$(WXWINSTABLE)\lib"
!ELSEIF "$(CFG)" == "wxconfigtool - Win32 DebugDev"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "wxconfigtool___Win32_DebugDev"
# PROP BASE Intermediate_Dir "wxconfigtool___Win32_DebugDev"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "DebugDev"
# PROP Intermediate_Dir "DebugDev"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "$(WXWINDEV)\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "$(WXWINDEV)/include" /I "$(WXWINDEV)/lib/mswd" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxd.lib jpegd.lib tiffd.lib pngd.lib zlibd.lib xpmd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /pdbtype:sept /libpath:"$(WXWINDEV)\lib"
# ADD LINK32 winmm.lib wxmswd.lib jpegd.lib tiffd.lib pngd.lib zlibd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wininet.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /pdbtype:sept /libpath:"$(WXWIN)\lib"
!ELSEIF "$(CFG)" == "wxconfigtool - Win32 ReleaseDev"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "wxconfigtool___Win32_ReleaseDev"
# PROP BASE Intermediate_Dir "wxconfigtool___Win32_ReleaseDev"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "ReleaseDev"
# PROP Intermediate_Dir "ReleaseDev"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "$(WXWINDEV)\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "$(WXWINDEV)/include" /I "$(WXWINDEV)/lib/mswd" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx.lib jpeg.lib tiff.lib png.lib xpm.lib zlib.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /libpath:"$(WXWINDEV)\lib"
# ADD LINK32 winmm.lib wxmsw.lib jpeg.lib tiff.lib png.lib zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wininet.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /libpath:"$(WXWIN)\lib"
!ENDIF
# Begin Target
# Name "wxconfigtool - Win32 Debug DLL"
# Name "wxconfigtool - Win32 Release DLL"
# Name "wxconfigtool - Win32 DebugStable"
# Name "wxconfigtool - Win32 ReleaseStable"
# Name "wxconfigtool - Win32 DebugDev"
# Name "wxconfigtool - Win32 ReleaseDev"
# Begin Group "Source files"
# PROP Default_Filter ""
# Begin Group "Header files"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\appsettings.h
# End Source File
# Begin Source File
SOURCE=.\configitem.h
# End Source File
# Begin Source File
SOURCE=.\configitemselector.h
# End Source File
# Begin Source File
SOURCE=.\configtooldoc.h
# End Source File
# Begin Source File
SOURCE=.\configtoolview.h
# End Source File
# Begin Source File
SOURCE=.\configtree.h
# End Source File
# Begin Source File
SOURCE=.\custompropertydialog.h
# End Source File
# Begin Source File
SOURCE=.\htmlparser.h
# End Source File
# Begin Source File
SOURCE=.\mainframe.h
# End Source File
# Begin Source File
SOURCE=.\propeditor.h
# End Source File
# Begin Source File
SOURCE=.\property.h
# End Source File
# Begin Source File
SOURCE=.\settingsdialog.h
# End Source File
# Begin Source File
SOURCE=.\symbols.h
# End Source File
# Begin Source File
SOURCE=.\utils.h
# End Source File
# Begin Source File
SOURCE=.\wxconfigtool.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\appsettings.cpp
# End Source File
# Begin Source File
SOURCE=.\configitem.cpp
# End Source File
# Begin Source File
SOURCE=.\configitemselector.cpp
# End Source File
# Begin Source File
SOURCE=.\configtooldoc.cpp
# End Source File
# Begin Source File
SOURCE=.\configtoolview.cpp
# End Source File
# Begin Source File
SOURCE=.\configtree.cpp
# End Source File
# Begin Source File
SOURCE=.\custompropertydialog.cpp
# End Source File
# Begin Source File
SOURCE=.\htmlparser.cpp
# End Source File
# Begin Source File
SOURCE=.\mainframe.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=.\makefile.b32
# End Source File
# Begin Source File
SOURCE=.\propeditor.cpp
# End Source File
# Begin Source File
SOURCE=.\property.cpp
# End Source File
# Begin Source File
SOURCE=.\settingsdialog.cpp
# End Source File
# Begin Source File
SOURCE=.\utils.cpp
# End Source File
# Begin Source File
SOURCE=.\wxconfigtool.cpp
# SUBTRACT CPP /YX /Yc
# End Source File
# Begin Source File
SOURCE=.\wxconfigtool.rc
!IF "$(CFG)" == "wxconfigtool - Win32 Debug DLL"
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809 /i "$(WXWIN)\include"
!ELSEIF "$(CFG)" == "wxconfigtool - Win32 Release DLL"
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809 /i "$(WXWIN)\include"
!ELSEIF "$(CFG)" == "wxconfigtool - Win32 DebugStable"
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809 /i "$(WXWINSTABLE)\include"
!ELSEIF "$(CFG)" == "wxconfigtool - Win32 ReleaseStable"
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809 /i "$(WXWINSTABLE)\include"
!ELSEIF "$(CFG)" == "wxconfigtool - Win32 DebugDev"
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809 /i "$(WXWINDEV)\include"
!ELSEIF "$(CFG)" == "wxconfigtool - Win32 ReleaseDev"
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809 /i "$(WXWINDEV)\include"
!ENDIF
# End Source File
# End Group
# Begin Group "Documents"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\docs\licence.txt
# End Source File
# Begin Source File
SOURCE=..\docs\notes.txt
# End Source File
# Begin Source File
SOURCE="..\docs\readme-after.txt"
# End Source File
# Begin Source File
SOURCE=..\docs\readme.txt
# End Source File
# Begin Source File
SOURCE=..\docs\todo.txt
# End Source File
# End Group
# Begin Group "Resources"
# PROP Default_Filter ""
# End Group
# Begin Group "Distribution"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\scripts\buildapp
# End Source File
# Begin Source File
SOURCE=..\scripts\innobott.txt
# End Source File
# Begin Source File
SOURCE=..\scripts\innotop.txt
# End Source File
# Begin Source File
SOURCE=..\scripts\makeapp
# End Source File
# Begin Source File
SOURCE=.\Makefile
# End Source File
# Begin Source File
SOURCE=..\scripts\makeinno.sh
# End Source File
# Begin Source File
SOURCE=.\makeprog.env
# End Source File
# Begin Source File
SOURCE=..\scripts\makesetup.sh
# End Source File
# Begin Source File
SOURCE=..\scripts\maketarball.sh
# End Source File
# Begin Source File
SOURCE=..\scripts\setup.var
# End Source File
# End Group
# Begin Group "Manual"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\docs\manual\configtool.tex
# End Source File
# Begin Source File
SOURCE=..\docs\manual\Makefile
# End Source File
# Begin Source File
SOURCE=..\docs\manual\makefile.vc
# End Source File
# Begin Source File
SOURCE=..\docs\manual\tex2rtf.ini
# End Source File
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "wxconfigtool"=.\wxconfigtool.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,187 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wxconfigtool.h
// Purpose: Generic application class
// Author: Julian Smart
// Modified by:
// Created: 2002-09-04
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _AP_WXCONFIGTOOL_H_
#define _AP_WXCONFIGTOOL_H_
#ifdef __GNUG__
#pragma interface wxconfigtool.cpp
#endif
#include "wx/docview.h"
#include "wx/help.h"
#ifdef __WXMSW__
#include "wx/msw/helpchm.h"
#else
#include "wx/html/helpctrl.h"
#endif
#include "appsettings.h"
class ctMainFrame;
class ctConfigToolDoc;
/*!
* \brief The application class.
* The application class controls initialisation,
* cleanup and other application-wide issues.
*/
class ctApp: public wxApp
{
public:
/// Constructor.
ctApp();
/// Destructor.
~ctApp();
// Accessors
/// Returns the application directory.
wxString GetAppDir() const { return m_appDir; }
/// Prepends the current app program directory to the name.
wxString GetFullAppPath(const wxString& filename) const;
/// Returns an object containing the application settings.
ctSettings& GetSettings() { return m_settings; }
/// Returns the file history object.
wxFileHistory& GetFileHistory() { return m_fileHistory; }
/// Returns the notebook window.
wxNotebook* GetNotebookWindow() { return m_notebookWindow; }
/// Returns TRUE if the application should show tooltips.
virtual bool UsingTooltips();
/// Returns the help controller object for the manual.
wxHelpControllerBase& GetHelpController() { return *m_helpController; }
/// Returns the help controller object for the wxWindows reference manual.
wxHelpControllerBase& GetReferenceHelpController() { return *m_helpControllerReference; }
/// Returns the document manager object.
wxDocManager* GetDocManager() const { return m_docManager; }
/// Returns the main frame.
ctMainFrame* GetMainFrame();
// Operations
/// Called on application initialisation.
bool OnInit(void);
/// Called on application exit.
int OnExit(void);
/// Loads config info from the registry or a file.
virtual bool LoadConfig();
/// Saves config info to the registry or a file.
virtual bool SaveConfig();
/// The help controller needs to be cleared before wxWindows
/// cleanup happens.
void ClearHelpControllers() ;
protected:
/// The application directory.
wxString m_appDir;
/// Global print data, to remember settings during the session.
wxPrintData m_printData;
/// Global page setup data.
wxPageSetupDialogData m_pageSetupData;
/// Notebook window.
wxNotebook* m_notebookWindow;
/// The help controller object.
wxHelpControllerBase* m_helpController;
/// The help controller object (reference manual).
wxHelpControllerBase* m_helpControllerReference;
/// The file history.
wxFileHistory m_fileHistory;
/// The configuration data.
ctSettings m_settings;
/// The document manager.
wxDocManager* m_docManager;
public:
DECLARE_EVENT_TABLE()
};
DECLARE_APP(ctApp)
/////////////////////////////////////////////////
// Menu ids
/////////////////////////////////////////////////
// File menu ids
#define ctID_SAVE_SETUP_FILE 1001
#define ctID_SAVE_CONFIGURE_COMMAND 1002
// Edit menu ids
#define ctID_ADD_ITEM 1030
#define ctID_ADD_ITEM_CHECKBOX 1031
#define ctID_ADD_ITEM_RADIOBUTTON 1032
#define ctID_ADD_ITEM_STRING 1033
#define ctID_ADD_ITEM_GROUP 1034
#define ctID_ADD_ITEM_CHECK_GROUP 1035
#define ctID_ADD_ITEM_RADIO_GROUP 1036
#define ctID_DELETE_ITEM 1037
#define ctID_RENAME_ITEM 1038
#define ctID_CUSTOM_PROPERTY 1039
#define ctID_ADD_CUSTOM_PROPERTY 1040
#define ctID_EDIT_CUSTOM_PROPERTY 1041
#define ctID_DELETE_CUSTOM_PROPERTY 1042
// View menu ids
#define ctID_SETTINGS 1020
#define ctID_SHOW_TOOLBAR 1021
// Help menu ids
#define ctID_GOTO_WEBSITE 1050
#define ctID_ITEM_HELP 1051
#define ctID_REFERENCE_CONTENTS 1052
// Taskbar menu ids
#define ctID_TASKBAR_EXIT_APP 1202
#define ctID_TASKBAR_SHOW_APP 1203
// Tree context menu
#define ctID_TREE_PASTE_BEFORE 1300
#define ctID_TREE_PASTE_AFTER 1301
#define ctID_TREE_PASTE_AS_CHILD 1302
#define ctID_TREE_COPY 1303
#define ctID_TREE_CUT 1304
/////////////////////////////////////////////////
// Window/control ids
/////////////////////////////////////////////////
// Settings dialogs
#define ctID_SETTINGS_GENERAL 1500
// Regenerate setup.h/configure command
#define ctID_REGENERATE 1600
#endif
// _AP_WXCONFIGTOOL_H_

View File

@@ -0,0 +1,8 @@
aaaa ICON "bitmaps/wxconfigtool.ico"
wxconfigtool ICON "bitmaps/wxconfigtool.ico"
#include "wx/msw/wx.rc"
1 24 "wxconfigtool.exe.manifest"