Added ability to use xml resource files. Still need to add ability to
subclass wxXmlResourceHandler, etc... Added wxGridAutoEditMixin to the mixins library package. Made ColourSelect be derived from wxButton. Fixed a few bugs here and there, added some missing methods, etc. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10588 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
1
wxPython/contrib/xrc/.cvsignore
Normal file
1
wxPython/contrib/xrc/.cvsignore
Normal file
@@ -0,0 +1 @@
|
||||
contrib
|
5
wxPython/contrib/xrc/b.bat
Executable file
5
wxPython/contrib/xrc/b.bat
Executable file
@@ -0,0 +1,5 @@
|
||||
@echo off
|
||||
cd %WXWIN%\wxPython
|
||||
call b.bat %$
|
||||
cd -
|
||||
|
1283
wxPython/contrib/xrc/xrc.cpp
Normal file
1283
wxPython/contrib/xrc/xrc.cpp
Normal file
File diff suppressed because it is too large
Load Diff
161
wxPython/contrib/xrc/xrc.i
Normal file
161
wxPython/contrib/xrc/xrc.i
Normal file
@@ -0,0 +1,161 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: xrc.i
|
||||
// Purpose: Wrappers for the XML based Resource system
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 4-June-2001
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2001 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
%module xrc
|
||||
|
||||
|
||||
%{
|
||||
#include "export.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
%include typemaps.i
|
||||
%include my_typemaps.i
|
||||
|
||||
%extern wx.i
|
||||
%extern windows.i
|
||||
%extern _defs.i
|
||||
%extern events.i
|
||||
%extern controls.i
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// This class holds XML resources from one or more .xml files
|
||||
// (or derived forms, either binary or zipped -- see manual for
|
||||
// details).
|
||||
|
||||
class wxXmlResource : public wxObject
|
||||
{
|
||||
public:
|
||||
// Ctor. If use_locale is TRUE, translatable strings are
|
||||
// translated via _(). You can disable it by passing use_locale=FALSE
|
||||
// (for example if you provide resource file for each locale)
|
||||
%name(wxXmlResourceEmpty)wxXmlResource(bool use_locale = TRUE); // TODO, a better %name
|
||||
|
||||
%addmethods {
|
||||
wxXmlResource(const wxString* filemask, bool use_locale = TRUE) {
|
||||
wxXmlResource* res = new wxXmlResource(*filemask, use_locale);
|
||||
res->InitAllHandlers();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
~wxXmlResource();
|
||||
|
||||
|
||||
// Loads resources from XML files that match given filemask.
|
||||
// This method understands VFS (see filesys.h).
|
||||
bool Load(const wxString& filemask);
|
||||
|
||||
// Initialize handlers for all supported controls/windows. This will
|
||||
// make the executable quite big because it forces linking against
|
||||
// most of wxWin library
|
||||
void InitAllHandlers();
|
||||
|
||||
// Initialize only specific handler (or custom handler). Convention says
|
||||
// that handler name is equal to control's name plus 'XmlHandler', e.g.
|
||||
// wxTextCtrlXmlHandler, wxHtmlWindowXmlHandler. XML resource compiler
|
||||
// (xmlres) can create include file that contains initialization code for
|
||||
// all controls used within the resource.
|
||||
void AddHandler(wxXmlResourceHandler *handler);
|
||||
|
||||
// Removes all handlers
|
||||
void ClearHandlers();
|
||||
|
||||
// Loads menu from resource. Returns NULL on failure.
|
||||
wxMenu *LoadMenu(const wxString& name);
|
||||
|
||||
// Loads menubar from resource. Returns NULL on failure.
|
||||
wxMenuBar *LoadMenuBar(const wxString& name);
|
||||
|
||||
// Loads toolbar
|
||||
wxToolBar *LoadToolBar(wxWindow *parent, const wxString& name);
|
||||
|
||||
// Loads dialog. dlg points to parent window (if any). Second form
|
||||
// is used to finish creation of already existing instance (main reason
|
||||
// for this is that you may want to use derived class with new event table)
|
||||
// Example (typical usage):
|
||||
// MyDialog dlg;
|
||||
// wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog");
|
||||
// dlg->ShowModal();
|
||||
wxDialog *LoadDialog(wxWindow *parent, const wxString& name);
|
||||
%name(LoadOnDialog)bool LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name);
|
||||
|
||||
// Loads panel. panel points to parent window (if any). Second form
|
||||
// is used to finish creation of already existing instance.
|
||||
wxPanel *LoadPanel(wxWindow *parent, const wxString& name);
|
||||
%name(LoadOnPanel)bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name);
|
||||
|
||||
bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name);
|
||||
|
||||
// Loads bitmap or icon resource from file:
|
||||
wxBitmap LoadBitmap(const wxString& name);
|
||||
wxIcon LoadIcon(const wxString& name);
|
||||
|
||||
// Attaches unknown control into given panel/window/dialog:
|
||||
// (unknown controls are used in conjunction with <object class="unknown">)
|
||||
bool AttachUnknownControl(const wxString& name, wxWindow *control,
|
||||
wxWindow *parent = NULL);
|
||||
|
||||
// Returns numeric ID that is equivalent to string id used in XML
|
||||
// resource. To be used in event tables
|
||||
// Macro XMLID is provided for convenience
|
||||
static int GetXMLID(const char *str_id);
|
||||
|
||||
// Returns version info (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a)
|
||||
long GetVersion() const;
|
||||
|
||||
// Compares resources version to argument. Returns -1 if resources version
|
||||
// is less than the argument, +1 if greater and 0 if they equal.
|
||||
int CompareVersion(int major, int minor, int release, int revision) const;
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
%readonly
|
||||
// Global instance of resource class. For your convenience.
|
||||
wxXmlResource *wxTheXmlResource;
|
||||
%readwrite
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
%pragma(python) code = "
|
||||
def XMLID(str_id):
|
||||
return wxXmlResource_GetXMLID(str_id)
|
||||
|
||||
def XMLCTRL(window, str_id, *args):
|
||||
return window.FindWindowById(XMLID(str_id))
|
||||
|
||||
"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// TODO: Add wxXmlResourceHandler and etc.
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
%init %{
|
||||
|
||||
wxClassInfo::CleanUpClasses();
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
wxXmlInitXmlModule();
|
||||
wxXmlInitResourceModule();
|
||||
wxTheXmlResource->InitAllHandlers();
|
||||
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
139
wxPython/contrib/xrc/xrc.py
Normal file
139
wxPython/contrib/xrc/xrc.py
Normal file
@@ -0,0 +1,139 @@
|
||||
# This file was created automatically by SWIG.
|
||||
import xrcc
|
||||
|
||||
from misc import *
|
||||
|
||||
from misc2 import *
|
||||
|
||||
from windows import *
|
||||
|
||||
from gdi import *
|
||||
|
||||
from clip_dnd import *
|
||||
|
||||
from events import *
|
||||
|
||||
from streams import *
|
||||
|
||||
from mdi import *
|
||||
|
||||
from frames import *
|
||||
|
||||
from stattool import *
|
||||
|
||||
from controls import *
|
||||
|
||||
from controls2 import *
|
||||
|
||||
from windows2 import *
|
||||
|
||||
from cmndlgs import *
|
||||
|
||||
from windows3 import *
|
||||
|
||||
from image import *
|
||||
|
||||
from printfw import *
|
||||
|
||||
from sizers import *
|
||||
|
||||
from filesys import *
|
||||
|
||||
from utils import *
|
||||
|
||||
def XMLID(str_id):
|
||||
return wxXmlResource_GetXMLID(str_id)
|
||||
|
||||
def XMLCTRL(window, str_id, *args):
|
||||
return window.FindWindowById(XMLID(str_id))
|
||||
|
||||
|
||||
class wxXmlResourcePtr(wxObjectPtr):
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
self.thisown = 0
|
||||
def __del__(self,xrcc=xrcc):
|
||||
if self.thisown == 1 :
|
||||
xrcc.delete_wxXmlResource(self)
|
||||
def Load(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_Load,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def InitAllHandlers(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_InitAllHandlers,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def AddHandler(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_AddHandler,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def ClearHandlers(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_ClearHandlers,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadMenu(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadMenu,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadMenuBar(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadMenuBar,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadToolBar(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadToolBar,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadDialog(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadDialog,(self,) + _args, _kwargs)
|
||||
if val: val = wxDialogPtr(val)
|
||||
return val
|
||||
def LoadOnDialog(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadOnDialog,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadPanel(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadPanel,(self,) + _args, _kwargs)
|
||||
if val: val = wxPanelPtr(val)
|
||||
return val
|
||||
def LoadOnPanel(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadOnPanel,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadFrame(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadFrame,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadBitmap(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadBitmap,(self,) + _args, _kwargs)
|
||||
if val: val = wxBitmapPtr(val) ; val.thisown = 1
|
||||
return val
|
||||
def LoadIcon(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadIcon,(self,) + _args, _kwargs)
|
||||
if val: val = wxIconPtr(val) ; val.thisown = 1
|
||||
return val
|
||||
def AttachUnknownControl(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_AttachUnknownControl,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetVersion(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_GetVersion,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def CompareVersion(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_CompareVersion,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def __repr__(self):
|
||||
return "<C wxXmlResource instance at %s>" % (self.this,)
|
||||
class wxXmlResource(wxXmlResourcePtr):
|
||||
def __init__(self,*_args,**_kwargs):
|
||||
self.this = apply(xrcc.new_wxXmlResourceEmpty,_args,_kwargs)
|
||||
self.thisown = 1
|
||||
|
||||
|
||||
|
||||
def wxXmlResource(*_args,**_kwargs):
|
||||
val = wxXmlResourcePtr(apply(xrcc.new_wxXmlResource,_args,_kwargs))
|
||||
val.thisown = 1
|
||||
return val
|
||||
|
||||
|
||||
|
||||
|
||||
#-------------- FUNCTION WRAPPERS ------------------
|
||||
|
||||
wxXmlResource_GetXMLID = xrcc.wxXmlResource_GetXMLID
|
||||
|
||||
|
||||
|
||||
#-------------- VARIABLE WRAPPERS ------------------
|
||||
|
||||
cvar = xrcc.cvar
|
||||
wxTheXmlResource = wxXmlResourcePtr(xrcc.cvar.wxTheXmlResource)
|
Reference in New Issue
Block a user