Compare commits
1 Commits
xrced-0_1_
...
b4_mousewh
Author | SHA1 | Date | |
---|---|---|---|
|
236c7dd7b2 |
347
docs/latex/wx/mouseevt.tex
Normal file
@@ -0,0 +1,347 @@
|
||||
\section{\class{wxMouseEvent}}\label{wxmouseevent}
|
||||
|
||||
This event class contains information about mouse events.
|
||||
See \helpref{wxWindow::OnMouseEvent}{wxwindowonmouseevent}.
|
||||
|
||||
{\bf NB: } Note that under Windows mouse enter and leave events are not natively supported
|
||||
by the system but are generated by wxWindows itself. This has several
|
||||
drawbacks: the LEAVE\_WINDOW event might be received some time after the mouse
|
||||
left the window and the state variables for it may have changed during this
|
||||
time.
|
||||
|
||||
{\bf NB: } Note the difference between methods like
|
||||
\helpref{LeftDown}{wxmouseeventleftdown} and
|
||||
\helpref{LeftIsDown}{wxmouseeventleftisdown}: the formet returns {\tt TRUE}
|
||||
when the event corresponds to the left mouse button click while the latter
|
||||
returns {\tt TRUE} if the left mouse button is currently being pressed. For
|
||||
example, when the user is dragging the mouse you can use
|
||||
\helpref{LeftIsDown}{wxmouseeventleftisdown} to test
|
||||
whether the left mouse button is (still) depressed. Also, by convention, if
|
||||
\helpref{LeftDown}{wxmouseeventleftdown} returns {\tt TRUE},
|
||||
\helpref{LeftIsDown}{wxmouseeventleftisdown} will also return {\tt TRUE} in
|
||||
wxWindows whatever the underlying GUI behaviour is (which is
|
||||
platform-dependent). The same applies, of course, to other mouse buttons as
|
||||
well.
|
||||
|
||||
\wxheading{Derived from}
|
||||
|
||||
\helpref{wxEvent}{wxevent}
|
||||
|
||||
\wxheading{Include files}
|
||||
|
||||
<wx/event.h>
|
||||
|
||||
\wxheading{Event table macros}
|
||||
|
||||
To process a mouse event, use these event handler macros to direct input to member
|
||||
functions that take a wxMouseEvent argument.
|
||||
|
||||
\twocolwidtha{7cm}
|
||||
\begin{twocollist}\itemsep=0pt
|
||||
\twocolitem{{\bf EVT\_LEFT\_DOWN(func)}}{Process a wxEVT\_LEFT\_DOWN event.}
|
||||
\twocolitem{{\bf EVT\_LEFT\_UP(func)}}{Process a wxEVT\_LEFT\_UP event.}
|
||||
\twocolitem{{\bf EVT\_LEFT\_DCLICK(func)}}{Process a wxEVT\_LEFT\_DCLICK event.}
|
||||
\twocolitem{{\bf EVT\_MIDDLE\_DOWN(func)}}{Process a wxEVT\_MIDDLE\_DOWN event.}
|
||||
\twocolitem{{\bf EVT\_MIDDLE\_UP(func)}}{Process a wxEVT\_MIDDLE\_UP event.}
|
||||
\twocolitem{{\bf EVT\_MIDDLE\_DCLICK(func)}}{Process a wxEVT\_MIDDLE\_DCLICK event.}
|
||||
\twocolitem{{\bf EVT\_RIGHT\_DOWN(func)}}{Process a wxEVT\_RIGHT\_DOWN event.}
|
||||
\twocolitem{{\bf EVT\_RIGHT\_UP(func)}}{Process a wxEVT\_RIGHT\_UP event.}
|
||||
\twocolitem{{\bf EVT\_RIGHT\_DCLICK(func)}}{Process a wxEVT\_RIGHT\_DCLICK event.}
|
||||
\twocolitem{{\bf EVT\_MOTION(func)}}{Process a wxEVT\_MOTION event.}
|
||||
\twocolitem{{\bf EVT\_ENTER\_WINDOW(func)}}{Process a wxEVT\_ENTER\_WINDOW event.}
|
||||
\twocolitem{{\bf EVT\_LEAVE\_WINDOW(func)}}{Process a wxEVT\_LEAVE\_WINDOW event.}
|
||||
\twocolitem{{\bf EVT\_MOUSE\_EVENTS(func)}}{Process all mouse events.}
|
||||
\end{twocollist}%
|
||||
|
||||
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||
|
||||
\membersection{wxMouseEvent::m\_altDown}
|
||||
|
||||
\member{bool}{m\_altDown}
|
||||
|
||||
TRUE if the Alt key is pressed down.
|
||||
|
||||
\membersection{wxMouseEvent::m\_controlDown}
|
||||
|
||||
\member{bool}{m\_controlDown}
|
||||
|
||||
TRUE if control key is pressed down.
|
||||
|
||||
\membersection{wxMouseEvent::m\_leftDown}
|
||||
|
||||
\member{bool}{m\_leftDown}
|
||||
|
||||
TRUE if the left mouse button is currently pressed down.
|
||||
|
||||
\membersection{wxMouseEvent::m\_middleDown}
|
||||
|
||||
\member{bool}{m\_middleDown}
|
||||
|
||||
TRUE if the middle mouse button is currently pressed down.
|
||||
|
||||
\membersection{wxMouseEvent::m\_rightDown}
|
||||
|
||||
\member{bool}{m\_rightDown}
|
||||
|
||||
TRUE if the right mouse button is currently pressed down.
|
||||
|
||||
\membersection{wxMouseEvent::m\_leftDown}
|
||||
|
||||
\member{bool}{m\_leftDown}
|
||||
|
||||
TRUE if the left mouse button is currently pressed down.
|
||||
|
||||
\membersection{wxMouseEvent::m\_metaDown}
|
||||
|
||||
\member{bool}{m\_metaDown}
|
||||
|
||||
TRUE if the Meta key is pressed down.
|
||||
|
||||
\membersection{wxMouseEvent::m\_shiftDown}
|
||||
|
||||
\member{bool}{m\_shiftDown}
|
||||
|
||||
TRUE if shift is pressed down.
|
||||
|
||||
\membersection{wxMouseEvent::m\_x}
|
||||
|
||||
\member{long}{m\_x}
|
||||
|
||||
X-coordinate of the event.
|
||||
|
||||
\membersection{wxMouseEvent::m\_y}
|
||||
|
||||
\member{long}{m\_y}
|
||||
|
||||
Y-coordinate of the event.
|
||||
|
||||
\membersection{wxMouseEvent::wxMouseEvent}
|
||||
|
||||
\func{}{wxMouseEvent}{\param{WXTYPE}{ mouseEventType = 0}, \param{int}{ id = 0}}
|
||||
|
||||
Constructor. Valid event types are:
|
||||
|
||||
\begin{itemize}
|
||||
\itemsep=0pt
|
||||
\item {\bf wxEVT\_ENTER\_WINDOW}
|
||||
\item {\bf wxEVT\_LEAVE\_WINDOW}
|
||||
\item {\bf wxEVT\_LEFT\_DOWN}
|
||||
\item {\bf wxEVT\_LEFT\_UP}
|
||||
\item {\bf wxEVT\_LEFT\_DCLICK}
|
||||
\item {\bf wxEVT\_MIDDLE\_DOWN}
|
||||
\item {\bf wxEVT\_MIDDLE\_UP}
|
||||
\item {\bf wxEVT\_MIDDLE\_DCLICK}
|
||||
\item {\bf wxEVT\_RIGHT\_DOWN}
|
||||
\item {\bf wxEVT\_RIGHT\_UP}
|
||||
\item {\bf wxEVT\_RIGHT\_DCLICK}
|
||||
\item {\bf wxEVT\_MOTION}
|
||||
\end{itemize}
|
||||
|
||||
\membersection{wxMouseEvent::AltDown}
|
||||
|
||||
\func{bool}{AltDown}{\void}
|
||||
|
||||
Returns TRUE if the Alt key was down at the time of the event.
|
||||
|
||||
\membersection{wxMouseEvent::Button}
|
||||
|
||||
\func{bool}{Button}{\param{int}{ button}}
|
||||
|
||||
Returns TRUE if the identified mouse button is changing state. Valid
|
||||
values of {\it button} are 1, 2 or 3 for left, middle and right
|
||||
buttons respectively.
|
||||
|
||||
Not all mice have middle buttons so a portable application should avoid
|
||||
this one.
|
||||
|
||||
\membersection{wxMouseEvent::ButtonDClick}\label{buttondclick}
|
||||
|
||||
\func{bool}{ButtonDClick}{\param{int}{ but = -1}}
|
||||
|
||||
If the argument is omitted, this returns TRUE if the event was a mouse
|
||||
double click event. Otherwise the argument specifies which double click event
|
||||
was generated (1, 2 or 3 for left, middle and right buttons respectively).
|
||||
|
||||
\membersection{wxMouseEvent::ButtonDown}
|
||||
|
||||
\func{bool}{ButtonDown}{\param{int}{ but = -1}}
|
||||
|
||||
If the argument is omitted, this returns TRUE if the event was a mouse
|
||||
button down event. Otherwise the argument specifies which button-down event
|
||||
was generated (1, 2 or 3 for left, middle and right buttons respectively).
|
||||
|
||||
\membersection{wxMouseEvent::ButtonUp}
|
||||
|
||||
\func{bool}{ButtonUp}{\param{int}{ but = -1}}
|
||||
|
||||
If the argument is omitted, this returns TRUE if the event was a mouse
|
||||
button up event. Otherwise the argument specifies which button-up event
|
||||
was generated (1, 2 or 3 for left, middle and right buttons respectively).
|
||||
|
||||
\membersection{wxMouseEvent::ControlDown}
|
||||
|
||||
\func{bool}{ControlDown}{\void}
|
||||
|
||||
Returns TRUE if the control key was down at the time of the event.
|
||||
|
||||
\membersection{wxMouseEvent::Dragging}
|
||||
|
||||
\func{bool}{Dragging}{\void}
|
||||
|
||||
Returns TRUE if this was a dragging event (motion while a button is depressed).
|
||||
|
||||
\membersection{wxMouseEvent::Entering}\label{wxmouseevententering}
|
||||
|
||||
\func{bool}{Entering}{\void}
|
||||
|
||||
Returns TRUE if the mouse was entering the window.
|
||||
|
||||
See also \helpref{wxMouseEvent::Leaving}{wxmouseeventleaving}.
|
||||
|
||||
\membersection{wxMouseEvent::GetPosition}\label{wxmouseeventgetposition}
|
||||
|
||||
\constfunc{wxPoint}{GetPosition}{\void}
|
||||
|
||||
\constfunc{void}{GetPosition}{\param{wxCoord*}{ x}, \param{wxCoord*}{ y}}
|
||||
|
||||
\constfunc{void}{GetPosition}{\param{long*}{ x}, \param{long*}{ y}}
|
||||
|
||||
Sets *x and *y to the position at which the event occurred.
|
||||
|
||||
Returns the physical mouse position in pixels.
|
||||
|
||||
\membersection{wxMouseEvent::GetLogicalPosition}\label{wxmouseeventgetlogicalposition}
|
||||
|
||||
\constfunc{wxPoint}{GetLogicalPosition}{\param{const wxDC\&}{ dc}}
|
||||
|
||||
Returns the logical mouse position in pixels (i.e. translated according to the
|
||||
translation set for the DC, which usually indicates that the window has been scrolled).
|
||||
|
||||
\membersection{wxMouseEvent::GetX}\label{wxmouseeventgetx}
|
||||
|
||||
\constfunc{long}{GetX}{\void}
|
||||
|
||||
Returns X coordinate of the physical mouse event position.
|
||||
|
||||
\membersection{wxMouseEvent::GetY}\label{wxmouseeventgety}
|
||||
|
||||
\func{long}{GetY}{\void}
|
||||
|
||||
Returns Y coordinate of the physical mouse event position.
|
||||
|
||||
\membersection{wxMouseEvent::IsButton}
|
||||
|
||||
\constfunc{bool}{IsButton}{\void}
|
||||
|
||||
Returns TRUE if the event was a mouse button event (not necessarily a button down event -
|
||||
that may be tested using {\it ButtonDown}).
|
||||
|
||||
\membersection{wxMouseEvent::Leaving}\label{wxmouseeventleaving}
|
||||
|
||||
\constfunc{bool}{Leaving}{\void}
|
||||
|
||||
Returns TRUE if the mouse was leaving the window.
|
||||
|
||||
See also \helpref{wxMouseEvent::Entering}{wxmouseevententering}.
|
||||
|
||||
\membersection{wxMouseEvent::LeftDClick}
|
||||
|
||||
\constfunc{bool}{LeftDClick}{\void}
|
||||
|
||||
Returns TRUE if the event was a left double click.
|
||||
|
||||
\membersection{wxMouseEvent::LeftDown}\label{wxmouseeventleftdown}
|
||||
|
||||
\constfunc{bool}{LeftDown}{\void}
|
||||
|
||||
Returns TRUE if the left mouse button changed to down.
|
||||
|
||||
\membersection{wxMouseEvent::LeftIsDown}\label{wxmouseeventleftisdown}
|
||||
|
||||
\constfunc{bool}{LeftIsDown}{\void}
|
||||
|
||||
Returns TRUE if the left mouse button is currently down, independent
|
||||
of the current event type.
|
||||
|
||||
Please notice that it is {\bf not} the same as
|
||||
\helpref{LeftDown}{wxmouseeventleftdown} which returns TRUE if the left mouse
|
||||
button was just pressed. Rather, it describes the state of the mouse button
|
||||
before the event happened.
|
||||
|
||||
This event is usually used in the mouse event handlers which process "move
|
||||
mouse" messages to determine whether the user is (still) dragging the mouse.
|
||||
|
||||
\membersection{wxMouseEvent::LeftUp}
|
||||
|
||||
\constfunc{bool}{LeftUp}{\void}
|
||||
|
||||
Returns TRUE if the left mouse button changed to up.
|
||||
|
||||
\membersection{wxMouseEvent::MetaDown}
|
||||
|
||||
\constfunc{bool}{MetaDown}{\void}
|
||||
|
||||
Returns TRUE if the Meta key was down at the time of the event.
|
||||
|
||||
\membersection{wxMouseEvent::MiddleDClick}
|
||||
|
||||
\constfunc{bool}{MiddleDClick}{\void}
|
||||
|
||||
Returns TRUE if the event was a middle double click.
|
||||
|
||||
\membersection{wxMouseEvent::MiddleDown}
|
||||
|
||||
\constfunc{bool}{MiddleDown}{\void}
|
||||
|
||||
Returns TRUE if the middle mouse button changed to down.
|
||||
|
||||
\membersection{wxMouseEvent::MiddleIsDown}\label{wxmouseeventmiddleisdown}
|
||||
|
||||
\constfunc{bool}{MiddleIsDown}{\void}
|
||||
|
||||
Returns TRUE if the middle mouse button is currently down, independent
|
||||
of the current event type.
|
||||
|
||||
\membersection{wxMouseEvent::MiddleUp}
|
||||
|
||||
\constfunc{bool}{MiddleUp}{\void}
|
||||
|
||||
Returns TRUE if the middle mouse button changed to up.
|
||||
|
||||
\membersection{wxMouseEvent::Moving}
|
||||
|
||||
\constfunc{bool}{Moving}{\void}
|
||||
|
||||
Returns TRUE if this was a motion event (no buttons depressed).
|
||||
|
||||
\membersection{wxMouseEvent::RightDClick}
|
||||
|
||||
\constfunc{bool}{RightDClick}{\void}
|
||||
|
||||
Returns TRUE if the event was a right double click.
|
||||
|
||||
\membersection{wxMouseEvent::RightDown}
|
||||
|
||||
\constfunc{bool}{RightDown}{\void}
|
||||
|
||||
Returns TRUE if the right mouse button changed to down.
|
||||
|
||||
\membersection{wxMouseEvent::RightIsDown}\label{wxmouseeventrightisdown}
|
||||
|
||||
\constfunc{bool}{RightIsDown}{\void}
|
||||
|
||||
Returns TRUE if the right mouse button is currently down, independent
|
||||
of the current event type.
|
||||
|
||||
\membersection{wxMouseEvent::RightUp}
|
||||
|
||||
\constfunc{bool}{RightUp}{\void}
|
||||
|
||||
Returns TRUE if the right mouse button changed to up.
|
||||
|
||||
\membersection{wxMouseEvent::ShiftDown}
|
||||
|
||||
\constfunc{bool}{ShiftDown}{\void}
|
||||
|
||||
Returns TRUE if the shift key was down at the time of the event.
|
||||
|
1936
include/wx/event.h
Normal file
154
include/wx/generic/scrolwin.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/generic/scrolwin.h
|
||||
// Purpose: wxScrolledWindow class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart and Markus Holzem
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_GENERIC_SCROLLWIN_H_
|
||||
#define _WX_GENERIC_SCROLLWIN_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "scrolwin.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers and constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/window.h"
|
||||
#include "wx/panel.h"
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
|
||||
|
||||
// default scrolled window style
|
||||
#ifndef wxScrolledWindowStyle
|
||||
#define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGenericScrolledWindow
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxGenericScrolledWindow : public wxPanel
|
||||
{
|
||||
public:
|
||||
wxGenericScrolledWindow();
|
||||
wxGenericScrolledWindow(wxWindow *parent,
|
||||
wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxScrolledWindowStyle,
|
||||
const wxString& name = wxPanelNameStr)
|
||||
{
|
||||
Create(parent, id, pos, size, style, name);
|
||||
}
|
||||
|
||||
~wxGenericScrolledWindow();
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxScrolledWindowStyle,
|
||||
const wxString& name = wxPanelNameStr);
|
||||
|
||||
// Normally the wxGenericScrolledWindow will scroll itself, but in
|
||||
// some rare occasions you might want it to scroll another
|
||||
// window (e.g. a child of it in order to scroll only a portion
|
||||
// the area between the scrollbars (spreadsheet: only cell area
|
||||
// will move).
|
||||
virtual void SetTargetWindow( wxWindow *target );
|
||||
virtual wxWindow *GetTargetWindow();
|
||||
|
||||
// Number of pixels per user unit (0 or -1 for no scrollbar)
|
||||
// Length of virtual canvas in user units
|
||||
// Length of page in user units
|
||||
virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
|
||||
int noUnitsX, int noUnitsY,
|
||||
int xPos = 0, int yPos = 0,
|
||||
bool noRefresh = FALSE );
|
||||
|
||||
// Physically scroll the window
|
||||
virtual void Scroll(int x_pos, int y_pos);
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
virtual void GetScrollUnitsPerPage(int *x_page, int *y_page) const;
|
||||
virtual void CalcUnscrolledPosition(int x, int y, float *xx, float *yy) const;
|
||||
#endif
|
||||
|
||||
int GetScrollPageSize(int orient) const;
|
||||
void SetScrollPageSize(int orient, int pageSize);
|
||||
|
||||
virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const;
|
||||
|
||||
// Enable/disable Windows scrolling in either direction.
|
||||
// If TRUE, wxWindows scrolls the canvas and only a bit of
|
||||
// the canvas is invalidated; no Clear() is necessary.
|
||||
// If FALSE, the whole canvas is invalidated and a Clear() is
|
||||
// necessary. Disable for when the scroll increment is used
|
||||
// to actually scroll a non-constant distance
|
||||
virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
|
||||
|
||||
// Get the view start
|
||||
virtual void GetViewStart(int *x, int *y) const;
|
||||
// Compatibility
|
||||
void ViewStart(int *x, int *y) const
|
||||
{ GetViewStart( x, y ); }
|
||||
|
||||
// Actual size in pixels when scrolling is taken into account
|
||||
virtual void GetVirtualSize(int *x, int *y) const;
|
||||
|
||||
// Set the scale factor, used in PrepareDC
|
||||
void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; }
|
||||
double GetScaleX() const { return m_scaleX; }
|
||||
double GetScaleY() const { return m_scaleY; }
|
||||
|
||||
virtual void CalcScrolledPosition(int x, int y, int *xx, int *yy) const;
|
||||
virtual void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
|
||||
|
||||
// Adjust the scrollbars
|
||||
virtual void AdjustScrollbars(void);
|
||||
|
||||
// Override this function to draw the graphic (or just process EVT_PAINT)
|
||||
virtual void OnDraw(wxDC& WXUNUSED(dc)) {};
|
||||
|
||||
// Override this function if you don't want to have wxGenericScrolledWindow
|
||||
// automatically change the origin according to the scroll position.
|
||||
virtual void PrepareDC(wxDC& dc);
|
||||
|
||||
// implementation from now on
|
||||
void OnScroll(wxScrollWinEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnChar(wxKeyEvent& event);
|
||||
|
||||
// Calculate scroll increment
|
||||
virtual int CalcScrollInc(wxScrollWinEvent& event);
|
||||
|
||||
protected:
|
||||
wxWindow *m_targetWindow;
|
||||
int m_xScrollPixelsPerLine;
|
||||
int m_yScrollPixelsPerLine;
|
||||
bool m_xScrollingEnabled;
|
||||
bool m_yScrollingEnabled;
|
||||
int m_xScrollPosition;
|
||||
int m_yScrollPosition;
|
||||
int m_xScrollLines;
|
||||
int m_yScrollLines;
|
||||
int m_xScrollLinesPerPage;
|
||||
int m_yScrollLinesPerPage;
|
||||
double m_scaleX;
|
||||
double m_scaleY;
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_ABSTRACT_CLASS(wxGenericScrolledWindow)
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_GENERIC_SCROLLWIN_H_
|
936
include/wx/msw/setup0.h
Normal file
@@ -0,0 +1,936 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/msw/setup.h
|
||||
// Purpose: Configuration for the library
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_SETUP_H_
|
||||
#define _WX_SETUP_H_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global settings
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// define this to 0 when building wxBase library - this can also be done from
|
||||
// makefile/project file overriding the value here
|
||||
#ifndef wxUSE_GUI
|
||||
#define wxUSE_GUI 1
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// compatibility settings
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// This setting determines the compatibility with 1.68 API:
|
||||
// Level 0: no backward compatibility, all new features
|
||||
// Level 1: some extra methods are defined for compatibility.
|
||||
//
|
||||
// Default is 0.
|
||||
//
|
||||
// Recommended setting: 0 (in fact the compatibility code is now very minimal
|
||||
// so there is little advantage to setting it to 1.
|
||||
#define WXWIN_COMPATIBILITY 0
|
||||
|
||||
// in wxMSW version 2.1.11 and earlier, wxIcon always derives from wxBitmap,
|
||||
// but this is very dangerous because you can mistakenly pass an icon instead
|
||||
// of a bitmap to a function taking "const wxBitmap&" - which will *not* work
|
||||
// because an icon is not a valid bitmap
|
||||
//
|
||||
// Starting from 2.1.12, you have the choice under this backwards compatible
|
||||
// behaviour (your code will still compile, but probably won't behave as
|
||||
// expected!) and not deriving wxIcon class from wxBitmap, but providing a
|
||||
// conversion ctor wxBitmap(const wxIcon&) instead.
|
||||
//
|
||||
// Recommended setting: 0
|
||||
#define wxICON_IS_BITMAP 0
|
||||
|
||||
// Define as 1 for font size to be backward compatible to 1.63 and earlier.
|
||||
// 1.64 and later define point sizes to be compatible with Windows.
|
||||
//
|
||||
// Default is 0
|
||||
//
|
||||
// Recommended setting: 0
|
||||
#define wxFONT_SIZE_COMPATIBILITY 0
|
||||
|
||||
// Set to 0 for accurate dialog units, else 1 to be as per 2.1.16 and before.
|
||||
// If migrating between versions, your dialogs may seem to shrink.
|
||||
//
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 0 (the new calculations are more correct!)
|
||||
#define wxDIALOG_UNIT_COMPATIBILITY 1
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// debugging settings
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Generic comment about debugging settings: they are very useful if you don't
|
||||
// use any other memory leak detection tools such as Purify/BoundsChecker, but
|
||||
// are probably redundant otherwise. Also, Visual C++ CRT has the same features
|
||||
// as wxWindows memory debugging subsystem built in since version 5.0 and you
|
||||
// may prefer to use it instead of built in memory debugging code because it is
|
||||
// faster and more fool proof.
|
||||
//
|
||||
// Using VC++ CRT memory debugging is enabled by default in debug mode
|
||||
// (__WXDEBUG__) if wxUSE_GLOBAL_MEMORY_OPERATORS is *not* enabled (i.e. is 0)
|
||||
// and if __NO_VC_CRTDBG__ is not defined.
|
||||
|
||||
// If 1, enables wxDebugContext, for writing error messages to file, etc. If
|
||||
// __WXDEBUG__ is not defined, will still use normal memory operators. It's
|
||||
// recommended to set this to 1, since you may well need to output an error log
|
||||
// in a production version (or non-debugging beta).
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 but see comment above
|
||||
#define wxUSE_DEBUG_CONTEXT 1
|
||||
|
||||
// If 1, enables debugging versions of wxObject::new and wxObject::delete *IF*
|
||||
// __WXDEBUG__ is also defined.
|
||||
//
|
||||
// WARNING: this code may not work with all architectures, especially if
|
||||
// alignment is an issue. This switch is currently ignored for mingw / cygwin
|
||||
//
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1 but see comment in the beginning of this section
|
||||
#define wxUSE_MEMORY_TRACING 1
|
||||
|
||||
// In debug mode, cause new and delete to be redefined globally.
|
||||
// If this causes problems (e.g. link errors), set this to 0.
|
||||
// This switch is currently ignored for mingw / cygwin
|
||||
//
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1 but see comment in the beginning of this section
|
||||
#define wxUSE_GLOBAL_MEMORY_OPERATORS 1
|
||||
|
||||
// In debug mode, causes new to be defined to be WXDEBUG_NEW (see object.h). If
|
||||
// this causes problems (e.g. link errors), set this to 0. You may need to set
|
||||
// this to 0 if using templates (at least for VC++). This switch is currently
|
||||
// ignored for mingw / cygwin
|
||||
//
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1 but see comment in the beginning of this section
|
||||
#define wxUSE_DEBUG_NEW_ALWAYS 1
|
||||
|
||||
// wxHandleFatalExceptions() may be used to catch the program faults at run
|
||||
// time and, instead of terminating the program with a usual GPF message box,
|
||||
// call the user-defined wxApp::OnFatalException() function. If you set
|
||||
// wxUSE_ON_FATAL_EXCEPTION to 0, wxHandleFatalExceptions() will not work.
|
||||
//
|
||||
// This setting is for Win32 only and can only be enabled if your compiler
|
||||
// supports Win32 structured exception handling (currently only VC++ does)
|
||||
//
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1 if your compiler supports it.
|
||||
#ifdef _MSC_VER
|
||||
#define wxUSE_ON_FATAL_EXCEPTION 1
|
||||
#else
|
||||
#define wxUSE_ON_FATAL_EXCEPTION 0
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Unicode support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Set wxUSE_UNICODE to 1 to compile wxWindows in Unicode mode: wxChar will be
|
||||
// defined as wchar_t, wxString will use Unicode internally. If you set this
|
||||
// to 1, you must use wxT() macro for all literal strings in the program.
|
||||
//
|
||||
// Unicode is currently only fully supported under Windows NT/2000 (Windows 9x
|
||||
// doesn't support it and the programs compiled in Unicode mode will not run
|
||||
// under 9x).
|
||||
//
|
||||
// Default is 0
|
||||
//
|
||||
// Recommended setting: 0 (unless you only plan to use Windows NT/2000)
|
||||
#define wxUSE_UNICODE 0
|
||||
|
||||
// Setting wxUSE_WCHAR_T to 1 gives you some degree of Unicode support without
|
||||
// compiling the program in Unicode mode. More precisely, it will be possible
|
||||
// to construct wxString from a wide (Unicode) string and convert any wxString
|
||||
// to Unicode.
|
||||
//
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_WCHAR_T 1
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global features
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Support for message/error logging. This includes wxLogXXX() functions and
|
||||
// wxLog and derived classes. Don't set this to 0 unless you really know what
|
||||
// you are doing.
|
||||
//
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1 (always)
|
||||
#define wxUSE_LOG 1
|
||||
|
||||
// Support for multithreaded applications: if 1, compile in thread classes
|
||||
// (thread.h) and make the library a bit more thread safe. Although thread
|
||||
// support is quite stable by now, you may still consider recompiling the
|
||||
// library without it if you have no use for it - this will result in a
|
||||
// somewhat smaller and faster operation.
|
||||
//
|
||||
// This is ignored under Win16, threads are only supported under Win32.
|
||||
//
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 0 unless you do plan to develop MT applications
|
||||
#define wxUSE_THREADS 1
|
||||
|
||||
// If enabled (1), compiles wxWindows streams classes
|
||||
#define wxUSE_STREAMS 1
|
||||
|
||||
// Use standard C++ streams if 1. If 0, use wxWin streams implementation.
|
||||
#define wxUSE_STD_IOSTREAM 0
|
||||
|
||||
// Use serialization (requires utils/serialize)
|
||||
#define wxUSE_SERIAL 0
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// non GUI features selection
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Set wxUSE_LONGLONG to 1 to compile the wxLongLong class. This is a 64 bit
|
||||
// integer which is implemented in terms of native 64 bit integers if any or
|
||||
// uses emulation otherwise.
|
||||
//
|
||||
// This class is required by wxDateTime and so you should enable it if you want
|
||||
// to use wxDateTime. For most modern platforms, it will use the native 64 bit
|
||||
// integers in which case (almost) all of its functions are inline and it
|
||||
// almost does not take any space, so there should be no reason to switch it
|
||||
// off.
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_LONGLONG 1
|
||||
|
||||
// Set wxUSE_TIMEDATE to 1 to compile the wxDateTime and related classes which
|
||||
// allow to manipulate dates, times and time intervals. wxDateTime replaces the
|
||||
// old wxTime and wxDate classes which are still provided for backwards
|
||||
// compatibility (and implemented in terms of wxDateTime).
|
||||
//
|
||||
// Note that this class is relatively new and is still officially in alpha
|
||||
// stage because some features are not yet (fully) implemented. It is already
|
||||
// quite useful though and should only be disabled if you are aiming at
|
||||
// absolutely minimal version of the library.
|
||||
//
|
||||
// Requires: wxUSE_LONGLONG
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_TIMEDATE 1
|
||||
|
||||
// Setting wxUSE_CONFIG to 1 enables the use of wxConfig and related classes
|
||||
// which allow the application to store its settings in the persistent
|
||||
// storage. Setting this to 1 will also enable on-demand creation of the
|
||||
// global config object in wxApp.
|
||||
//
|
||||
// See also wxUSE_CONFIG_NATIVE below.
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_CONFIG 1
|
||||
|
||||
// If wxUSE_CONFIG is 1, you may choose to use either the native config
|
||||
// classes under Windows (using .INI files under Win16 and the registry under
|
||||
// Win32) or the portable text file format used by the config classes under
|
||||
// Unix.
|
||||
//
|
||||
// Default is 1 to use native classes. Note that you may still use
|
||||
// wxFileConfig even if you set this to 1 - just the config object created by
|
||||
// default for the applications needs will be a wxRegConfig or wxIniConfig and
|
||||
// not wxFileConfig.
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_CONFIG_NATIVE 1
|
||||
|
||||
// If wxUSE_DIALUP_MANAGER is 1, compile in wxDialUpManager class which allows
|
||||
// to connect/disconnect from the network and be notified whenever the dial-up
|
||||
// network connection is established/terminated. Requires wxUSE_DYNLIB_CLASS.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_DIALUP_MANAGER 1
|
||||
|
||||
// Compile in wxLibrary class for run-time DLL loading and function calling.
|
||||
// Required by wxUSE_DIALUP_MANAGER.
|
||||
//
|
||||
// This setting is for Win32 only
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_DYNLIB_CLASS 1
|
||||
|
||||
// Set to 1 to use socket classes
|
||||
#define wxUSE_SOCKETS 1
|
||||
|
||||
// Set to 1 to enable virtual file systems (required by wxHTML)
|
||||
#define wxUSE_FILESYSTEM 1
|
||||
|
||||
// Set to 1 to enable virtual ZIP filesystem (requires wxUSE_FILESYSTEM)
|
||||
#define wxUSE_FS_ZIP 1
|
||||
|
||||
// Set to 1 to enable virtual Internet filesystem (requires wxUSE_FILESYSTEM)
|
||||
#define wxUSE_FS_INET 1
|
||||
|
||||
// Set to 1 to compile wxZipInput/OutputStream classes.
|
||||
#define wxUSE_ZIPSTREAM 1
|
||||
|
||||
// Set to 1 to compile wxZlibInput/OutputStream classes. Also required by
|
||||
// wxUSE_LIBPNG.
|
||||
#define wxUSE_ZLIB 1
|
||||
|
||||
// If enabled, the code written by Apple will be used to write, in a portable
|
||||
// way, float on the disk. See extended.c for the license which is different
|
||||
// from wxWindows one.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 unless you don't like the license terms (unlikely)
|
||||
#define wxUSE_APPLE_IEEE 1
|
||||
|
||||
// Use wxFile class.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 (highly recommended, required i18n code, wxConfig...)
|
||||
#define wxUSE_FILE 1
|
||||
|
||||
// use wxTextFile class: requires wxFile, required by wxFileConfig
|
||||
#define wxUSE_TEXTFILE 1
|
||||
|
||||
// i18n support: _() macro, wxLocale class. Requires wxTextFile.
|
||||
#define wxUSE_INTL 1
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Optional controls
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// wxToolBar related settings: if wxUSE_TOOLBAR is 0, don't compile any toolbar
|
||||
// classes at all. Otherwise, use the native toolbar class unless
|
||||
// wxUSE_TOOLBAR_NATIVE is 0. Additionally, the generic toolbar class which
|
||||
// supports some features which might not be supported by the native wxToolBar
|
||||
// class may be compiled in if wxUSE_TOOLBAR_SIMPLE is 1.
|
||||
//
|
||||
// Default is 1 for all settings.
|
||||
//
|
||||
// Recommended setting: 1 for wxUSE_TOOLBAR and wxUSE_TOOLBAR_NATIVE and 0 for
|
||||
// wxUSE_TOOLBAR_SIMPLE (the default is 1 mainly for backwards compatibility).
|
||||
#define wxUSE_TOOLBAR 1
|
||||
#define wxUSE_TOOLBAR_NATIVE 1
|
||||
#define wxUSE_TOOLBAR_SIMPLE 1
|
||||
|
||||
// wxNotebook is a control with several "tabs" located on one of its sides. It
|
||||
// may be used ot logically organise the data presented to the user instead of
|
||||
// putting everything in one huge dialog. It replaces wxTabControl and related
|
||||
// classes of wxWin 1.6x.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_NOTEBOOK 1
|
||||
|
||||
// The corresponding controls will be compiled in if wxUSE_<CONTROL> is set to
|
||||
// 1 and not compiled into the library otherwise.
|
||||
//
|
||||
// Default is 1 for everything.
|
||||
//
|
||||
// Recommended setting: 1 (library might fail to compile for some combinations
|
||||
// of disabled controls)
|
||||
#define wxUSE_CARET 1
|
||||
#define wxUSE_CHECKBOX 1
|
||||
#define wxUSE_CHECKLISTBOX 1 // requires wxUSE_OWNER_DRAWN
|
||||
#define wxUSE_CHOICE 1
|
||||
#define wxUSE_COMBOBOX 1
|
||||
#define wxUSE_GAUGE 1
|
||||
#define wxUSE_LISTBOX 1
|
||||
#define wxUSE_RADIOBOX 1
|
||||
#define wxUSE_RADIOBTN 1
|
||||
#define wxUSE_SASH 1 // wxSashWindow
|
||||
#define wxUSE_SCROLLBAR 1
|
||||
#define wxUSE_SLIDER 1
|
||||
#define wxUSE_SPINBTN 1
|
||||
#define wxUSE_SPINCTRL 1
|
||||
#define wxUSE_STATLINE 1
|
||||
#define wxUSE_STATUSBAR 1
|
||||
#define wxUSE_TOGGLEBTN 1 // requires wxButton
|
||||
#define wxUSE_TOOLTIPS 1 // wxToolTip and wxWindow::SetToolTip()
|
||||
|
||||
// Two status bar implementations are available under Win32: the generic one
|
||||
// or the wrapper around native control. For native look and feel the native
|
||||
// version should be used.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_NATIVE_STATUSBAR 1
|
||||
|
||||
// this setting is obsolete, value is ignored
|
||||
#define wxUSE_BUTTONBAR 1
|
||||
|
||||
// wxGrid class comes in two flavours: the original (pre wxWin 2.2) one and
|
||||
// the new, much imporved and enhanced version. The new version is backwards
|
||||
// compatible with the old one and should be used whenever possible, i.e. if
|
||||
// you set wxUSE_GRID to 1, set wxUSE_NEW_GRID to 1 too.
|
||||
//
|
||||
// Default is 1 for both options.
|
||||
//
|
||||
// Recommended setting: 1 for wxUSE_NEW_GRID, 0 if you have an old code using
|
||||
// wxGrid and 100% backwards compatibality (with all old wxGrid quirks) is
|
||||
// essential.
|
||||
//
|
||||
// WIN16/BC++ resets wxUSE_NEW_GRID to 0 because it exceeds the data limit.
|
||||
#define wxUSE_GRID 1
|
||||
#define wxUSE_NEW_GRID 1
|
||||
|
||||
// wxValidator class and related methods
|
||||
#define wxUSE_VALIDATORS 1
|
||||
|
||||
// wxAcceleratorTable/Entry classes and support for them in wxMenu(Bar)
|
||||
#define wxUSE_ACCEL 1
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// common dialogs
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Define 1 to use generic dialogs in Windows, even though they duplicate
|
||||
// native common dialog (e.g. wxColourDialog). This is mainly useful for
|
||||
// testing.
|
||||
//
|
||||
// Default is 0
|
||||
//
|
||||
// Recommended setting: 0
|
||||
#define wxUSE_GENERIC_DIALOGS_IN_MSW 0
|
||||
|
||||
// On rare occasions (e.g. using DJGPP) may want to omit common dialogs (e.g.
|
||||
// file selector, printer dialog). Switching this off also switches off the
|
||||
// printing architecture and interactive wxPrinterDC.
|
||||
//
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1 (unless it really doesn't work)
|
||||
#define wxUSE_COMMON_DIALOGS 1
|
||||
|
||||
// text entry dialog and wxGetTextFromUser function
|
||||
#define wxUSE_TEXTDLG 1
|
||||
|
||||
// progress dialog class for lengthy operations
|
||||
#define wxUSE_PROGRESSDLG 1
|
||||
|
||||
// wxBusyInfo displays window with message when app is busy. Works in same way
|
||||
// as wxBusyCursor
|
||||
#define wxUSE_BUSYINFO 1
|
||||
|
||||
// wxDirDlg class for getting a directory name from user
|
||||
#define wxUSE_DIRDLG 1
|
||||
|
||||
// support for startup tips (wxShowTip &c)
|
||||
#define wxUSE_STARTUP_TIPS 1
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Metafiles support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Windows supports the graphics format known as metafile which is, though not
|
||||
// portable, is widely used under Windows and so is supported by wxWin (under
|
||||
// Windows only, of course). Win16 (Win3.1) used the so-called "Window
|
||||
// MetaFiles" or WMFs which were replaced with "Enhanced MetaFiles" or EMFs in
|
||||
// Win32 (Win9x, NT, 2000). Both of these are supported in wxWin and, by
|
||||
// default, WMFs will be used under Win16 and EMFs under Win32. This may be
|
||||
// changed by setting wxUSE_WIN_METAFILES_ALWAYS to 1 and/or setting
|
||||
// wxUSE_ENH_METAFILE to 0. You may also set wxUSE_METAFILE to 0 to not compile
|
||||
// in any metafile related classes at all.
|
||||
//
|
||||
// Default is 1 for wxUSE_ENH_METAFILE and 0 for wxUSE_WIN_METAFILES_ALWAYS.
|
||||
//
|
||||
// Recommended setting: default or 0 for everything for portable programs.
|
||||
#define wxUSE_METAFILE 1
|
||||
#define wxUSE_ENH_METAFILE 1
|
||||
#define wxUSE_WIN_METAFILES_ALWAYS 0
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Big GUI components
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Set to 0 to disable document/view architecture
|
||||
#define wxUSE_DOC_VIEW_ARCHITECTURE 1
|
||||
|
||||
// Set to 0 to disable MDI document/view architecture
|
||||
#define wxUSE_MDI_ARCHITECTURE 1
|
||||
|
||||
// Set to 0 to disable print/preview architecture code
|
||||
#define wxUSE_PRINTING_ARCHITECTURE 1
|
||||
|
||||
// wxHTML sublibrary allows to display HTML in wxWindow programs and much,
|
||||
// much more.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 (wxHTML is great!), set to 0 if you want compile a
|
||||
// smaller library.
|
||||
#define wxUSE_HTML 1
|
||||
|
||||
// wxPlot is a class to display functions plots in wxWindow.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_PLOT 1
|
||||
|
||||
// OpenGL canvas
|
||||
#define wxUSE_GLCANVAS 0
|
||||
|
||||
// wxTreeLayout class
|
||||
#define wxUSE_TREELAYOUT 1
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// miscellaneous settings
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define wxUSE_IPC 1
|
||||
// 0 for no interprocess comms
|
||||
#define wxUSE_HELP 1
|
||||
// 0 for no help facility
|
||||
#define wxUSE_MS_HTML_HELP 0
|
||||
// 0 for no MS HTML Help
|
||||
#define wxUSE_RESOURCES 1
|
||||
// 0 for no wxGetResource/wxWriteResource
|
||||
#define wxUSE_CONSTRAINTS 1
|
||||
// 0 for no window layout constraint system
|
||||
|
||||
#define wxUSE_CLIPBOARD 1
|
||||
// 0 for no clipboard functions
|
||||
|
||||
#define wxUSE_SPLINES 1
|
||||
// 0 for no splines
|
||||
|
||||
#define wxUSE_DRAG_AND_DROP 1
|
||||
// 0 for no drag and drop
|
||||
|
||||
#define wxUSE_XPM_IN_MSW 1
|
||||
// 0 for no XPM support in wxBitmap.
|
||||
// Default is 1, as XPM is now fully
|
||||
// supported this makes easier the issue
|
||||
// of portable icons and bitmaps.
|
||||
#define wxUSE_IMAGE_LOADING_IN_MSW 1
|
||||
// Use dynamic DIB loading/saving code in utils/dib under MSW.
|
||||
#define wxUSE_RESOURCE_LOADING_IN_MSW 1
|
||||
// Use dynamic icon/cursor loading/saving code
|
||||
// under MSW.
|
||||
#define wxUSE_WX_RESOURCES 1
|
||||
// Use .wxr resource mechanism (requires PrologIO library)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// postscript support settings
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Set to 1 for PostScript device context.
|
||||
#define wxUSE_POSTSCRIPT 0
|
||||
|
||||
// Set to 1 to use font metric files in GetTextExtent
|
||||
#define wxUSE_AFM_FOR_POSTSCRIPT 0
|
||||
|
||||
// Set to 0 to disable PostScript print/preview architecture code under Windows
|
||||
// (just use Windows printing).
|
||||
#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 1
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// database classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Define 1 to use ODBC classes
|
||||
#define wxUSE_ODBC 0
|
||||
|
||||
// For backward compatibility reasons, this parameter now only controls the
|
||||
// default scrolling method used by cursors. This default behavior can be
|
||||
// overriden by setting the second param of wxDB::wxDbGetConnection() or
|
||||
// wxDb() constructor to indicate whether the connection (and any wxDbTable()s
|
||||
// that use the connection) should support forward only scrolling of cursors,
|
||||
// or both forward and backward support for backward scrolling cursors is
|
||||
// dependent on the data source as well as the ODBC driver being used.
|
||||
#define wxODBC_FWD_ONLY_CURSORS 1
|
||||
|
||||
// Default is 0. Set to 1 to use the deprecated classes, enum types, function,
|
||||
// member variables. With a setting of 1, full backward compatability with the
|
||||
// 2.0.x release is possible. It is STRONGLY recommended that this be set to 0,
|
||||
// as future development will be done only on the non-deprecated
|
||||
// functions/classes/member variables/etc.
|
||||
#define wxODBC_BACKWARD_COMPATABILITY 0
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// other compiler (mis)features
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Set this to 0 if your compiler can't cope with omission of prototype
|
||||
// parameters.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 (should never need to set this to 0)
|
||||
#define REMOVE_UNUSED_ARG 1
|
||||
|
||||
// VC++ 4.2 and above allows <iostream> and <iostream.h> but you can't mix
|
||||
// them. Set to 1 for <iostream.h>, 0 for <iostream>
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: whatever your compiler likes more
|
||||
#define wxUSE_IOSTREAMH 1
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// image format support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// wxImage supports many different image formats which can be configured at
|
||||
// compile-time. BMP is always supported, others are optional and can be safely
|
||||
// disabled if you don't plan to use images in such format sometimes saving
|
||||
// substantial amount of code in the final library.
|
||||
//
|
||||
// Some formats require an extra library which is included in wxWin sources
|
||||
// which is mentioned if it is the case.
|
||||
|
||||
// Set to 1 for wxImage support (recommended).
|
||||
#define wxUSE_IMAGE 1
|
||||
|
||||
// Set to 1 for PNG format support (requires libpng). Also requires wxUSE_ZLIB.
|
||||
#define wxUSE_LIBPNG 1
|
||||
|
||||
// Set to 1 for JPEG format support (requires libjpeg)
|
||||
#define wxUSE_LIBJPEG 1
|
||||
|
||||
// Set to 1 for TIFF format support (requires libtiff)
|
||||
#define wxUSE_LIBTIFF 1
|
||||
|
||||
// Set to 1 for GIF format support
|
||||
#define wxUSE_GIF 1
|
||||
|
||||
// Set to 1 for PNM format support
|
||||
#define wxUSE_PNM 1
|
||||
|
||||
// Set to 1 for PCX format support
|
||||
#define wxUSE_PCX 1
|
||||
|
||||
// Set to 1 for XPM format support
|
||||
#define wxUSE_XPM 1
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Windows-only settings
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Set this to 1 if you want to use wxWindows and MFC in the same program. This
|
||||
// will override some other settings (see below)
|
||||
//
|
||||
// Default is 0.
|
||||
//
|
||||
// Recommended setting: 0 unless you really have to use MFC
|
||||
#define wxUSE_MFC 0
|
||||
|
||||
// Set this to 1 for generic OLE support: this is required for drag-and-drop,
|
||||
// clipboard, OLE Automation. Only set it to 0 if your compiler is very old and
|
||||
// can't compile/doesn't have the OLE headers.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_OLE 1
|
||||
|
||||
// Set this to 1 to use Microsoft CTL3D library for "3D-look" under Win16 or NT
|
||||
// 3.x. This setting is ignored under Win9x and NT 4.0+.
|
||||
//
|
||||
// Default is 0 for (most) Win32 (systems), 1 for Win16
|
||||
//
|
||||
// Recommended setting: same as default
|
||||
#if defined(__WIN95__)
|
||||
#define wxUSE_CTL3D 0
|
||||
#else
|
||||
#define wxUSE_CTL3D 1
|
||||
#endif
|
||||
|
||||
// Define as 1 to use Microsoft's ItsyBitsy small title bar library, for
|
||||
// wxMiniFrame. This setting is only used for Win3.1; Win9x and NT use native
|
||||
// miniframes support instead.
|
||||
//
|
||||
// Default is 0 for (most) Win32 (systems), 1 for Win16
|
||||
//
|
||||
// Recommended setting: same as default
|
||||
#if defined(__WIN95__)
|
||||
#define wxUSE_ITSY_BITSY 0
|
||||
#else
|
||||
#define wxUSE_ITSY_BITSY 1
|
||||
#endif
|
||||
|
||||
// Set this to 1 to use RICHEDIT controls for wxTextCtrl with style wxTE_RICH
|
||||
// which allows to put more than ~32Kb of text in it even under Win9x (NT
|
||||
// doesn't have such limitation).
|
||||
//
|
||||
// Default is 1 for compilers which support it
|
||||
//
|
||||
// Recommended setting: 1, only set it to 0 if your compiler doesn't have
|
||||
// or can't compile <richedit.h>
|
||||
#if defined(__WIN95__) && !defined(__TWIN32__) && !defined(__GNUWIN32_OLD__)
|
||||
#define wxUSE_RICHEDIT 1
|
||||
#else
|
||||
#define wxUSE_RICHEDIT 0
|
||||
#endif
|
||||
|
||||
// Set this to 1 to enable support for the owner-drawn menu and listboxes. This
|
||||
// is required by wxUSE_CHECKLISTBOX.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1, set to 0 for a small library size reduction
|
||||
#define wxUSE_OWNER_DRAWN 1
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// obsolete settings
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// NB: all settings in this section are obsolete and should not be used/changed
|
||||
// at all, they will disappear
|
||||
|
||||
// Set to 1 to use PenWindows
|
||||
#define wxUSE_PENWINDOWS 0
|
||||
|
||||
// Define 1 to use bitmap messages.
|
||||
#define wxUSE_BITMAP_MESSAGE 1
|
||||
|
||||
// If 1, enables provision of run-time type information.
|
||||
// NOW MANDATORY: don't change.
|
||||
#define wxUSE_DYNAMIC_CLASSES 1
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// disable the settings which don't work for some compilers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifndef wxUSE_NORLANDER_HEADERS
|
||||
#if (defined(__MINGW32__) || defined(__CYGWIN__)) && ((__GNUC__>2) ||((__GNUC__==2) && (__GNUC_MINOR__>=95)))
|
||||
# define wxUSE_NORLANDER_HEADERS 1
|
||||
#else
|
||||
# define wxUSE_NORLANDER_HEADERS 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__GNUWIN32__)
|
||||
// These don't work as expected for mingw32 and cygwin32
|
||||
#undef wxUSE_MEMORY_TRACING
|
||||
#define wxUSE_MEMORY_TRACING 0
|
||||
|
||||
#undef wxUSE_GLOBAL_MEMORY_OPERATORS
|
||||
#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
|
||||
|
||||
#undef wxUSE_DEBUG_NEW_ALWAYS
|
||||
#define wxUSE_DEBUG_NEW_ALWAYS 0
|
||||
|
||||
#undef wxUSE_MS_HTML_HELP
|
||||
#define wxUSE_MS_HTML_HELP 0
|
||||
|
||||
// Cygwin betas don't have wcslen
|
||||
#if defined(__CYGWIN__) || defined(__CYGWIN32__)
|
||||
# if ! ((__GNUC__>2) ||((__GNUC__==2) && (__GNUC_MINOR__>=95)))
|
||||
# undef wxUSE_WCHAR_T
|
||||
# define wxUSE_WCHAR_T 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif // __GNUWIN32__
|
||||
|
||||
// MFC duplicates these operators
|
||||
#if wxUSE_MFC
|
||||
#undef wxUSE_GLOBAL_MEMORY_OPERATORS
|
||||
#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
|
||||
|
||||
#undef wxUSE_DEBUG_NEW_ALWAYS
|
||||
#define wxUSE_DEBUG_NEW_ALWAYS 0
|
||||
#endif // wxUSE_MFC
|
||||
|
||||
// ODBC classes aren't Unicode-compatible yet
|
||||
#if wxUSE_UNICODE
|
||||
#undef wxUSE_ODBC
|
||||
#define wxUSE_ODBC 0
|
||||
#endif
|
||||
|
||||
#if (!defined(WIN32) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS)
|
||||
// Can't use OLE drag and drop in Windows 3.1 because we don't know how
|
||||
// to implement UUIDs
|
||||
// GnuWin32 doesn't have appropriate headers for e.g. IUnknown.
|
||||
#undef wxUSE_DRAG_AND_DROP
|
||||
#define wxUSE_DRAG_AND_DROP 0
|
||||
#endif
|
||||
|
||||
// Only WIN32 supports wxStatusBar95
|
||||
#if !defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR
|
||||
#undef wxUSE_NATIVE_STATUSBAR
|
||||
#define wxUSE_NATIVE_STATUSBAR 0
|
||||
#endif
|
||||
|
||||
#if !wxUSE_OWNER_DRAWN
|
||||
#undef wxUSE_CHECKLISTBOX
|
||||
#define wxUSE_CHECKLISTBOX 0
|
||||
#endif
|
||||
|
||||
// Salford C++ doesn't like some of the memory operator definitions
|
||||
#ifdef __SALFORDC__
|
||||
#undef wxUSE_MEMORY_TRACING
|
||||
#define wxUSE_MEMORY_TRACING 0
|
||||
|
||||
#undef wxUSE_GLOBAL_MEMORY_OPERATORS
|
||||
#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
|
||||
|
||||
#undef wxUSE_DEBUG_NEW_ALWAYS
|
||||
#define wxUSE_DEBUG_NEW_ALWAYS 0
|
||||
|
||||
#undef wxUSE_THREADS
|
||||
#define wxUSE_THREADS 0
|
||||
|
||||
#undef wxUSE_OWNER_DRAWN
|
||||
#define wxUSE_OWNER_DRAWN 0
|
||||
#endif // __SALFORDC__
|
||||
|
||||
#ifdef __TWIN32__
|
||||
|
||||
#undef wxUSE_THREADS
|
||||
#define wxUSE_THREADS 0
|
||||
|
||||
#undef wxUSE_ODBC
|
||||
#define wxUSE_ODBC 0
|
||||
|
||||
#endif // __TWIN32__
|
||||
|
||||
// BC++/Win16 can't cope with the amount of data in resource.cpp
|
||||
#if defined(__WIN16__) && defined(__BORLANDC__)
|
||||
#undef wxUSE_WX_RESOURCES
|
||||
#define wxUSE_WX_RESOURCES 0
|
||||
|
||||
#undef wxUSE_ODBC
|
||||
#define wxUSE_ODBC 0
|
||||
|
||||
#undef wxUSE_NEW_GRID
|
||||
#define wxUSE_NEW_GRID 0
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
|
||||
// BC++ 4.0 can't compile JPEG library
|
||||
#undef wxUSE_LIBJPEG
|
||||
#define wxUSE_LIBJPEG 0
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
// Need a BC++-specific htmlhelp.lib before we can enable this
|
||||
#undef wxUSE_MS_HTML_HELP
|
||||
#define wxUSE_MS_HTML_HELP 0
|
||||
#endif
|
||||
|
||||
// wxUSE_DEBUG_NEW_ALWAYS = 1 not compatible with BC++ in DLL mode
|
||||
#if defined(__BORLANDC__) && (defined(WXMAKINGDLL) || defined(WXUSINGDLL))
|
||||
#undef wxUSE_DEBUG_NEW_ALWAYS
|
||||
#define wxUSE_DEBUG_NEW_ALWAYS 0
|
||||
#endif
|
||||
|
||||
#if defined(__WXMSW__) && defined(__WATCOMC__)
|
||||
/*
|
||||
#undef wxUSE_GLCANVAS
|
||||
#define wxUSE_GLCANVAS 0
|
||||
*/
|
||||
|
||||
#undef wxUSE_MS_HTML_HELP
|
||||
#define wxUSE_MS_HTML_HELP 0
|
||||
|
||||
#undef wxUSE_WCHAR_T
|
||||
#define wxUSE_WCHAR_T 0
|
||||
#endif
|
||||
|
||||
#if defined(__WXMSW__) && !defined(__WIN32__)
|
||||
|
||||
#undef wxUSE_SOCKETS
|
||||
#define wxUSE_SOCKETS 0
|
||||
|
||||
#undef wxUSE_THREADS
|
||||
#define wxUSE_THREADS 0
|
||||
|
||||
#undef wxUSE_TOOLTIPS
|
||||
#define wxUSE_TOOLTIPS 0
|
||||
|
||||
#undef wxUSE_SPINCTRL
|
||||
#define wxUSE_SPINCTRL 0
|
||||
|
||||
#undef wxUSE_SPINBTN
|
||||
#define wxUSE_SPINBTN 0
|
||||
|
||||
#undef wxUSE_LIBPNG
|
||||
#define wxUSE_LIBPNG 0
|
||||
|
||||
#undef wxUSE_LIBJPEG
|
||||
#define wxUSE_LIBJPEG 0
|
||||
|
||||
#undef wxUSE_LIBTIFF
|
||||
#define wxUSE_LIBTIFF 0
|
||||
|
||||
#undef wxUSE_GIF
|
||||
#define wxUSE_GIF 0
|
||||
|
||||
#undef wxUSE_PNM
|
||||
#define wxUSE_PNM 0
|
||||
|
||||
#undef wxUSE_PCX
|
||||
#define wxUSE_PCX 0
|
||||
|
||||
#undef wxUSE_GLCANVAS
|
||||
#define wxUSE_GLCANVAS 0
|
||||
|
||||
#undef wxUSE_MS_HTML_HELP
|
||||
#define wxUSE_MS_HTML_HELP 0
|
||||
|
||||
#undef wxUSE_WCHAR_T
|
||||
#define wxUSE_WCHAR_T 0
|
||||
|
||||
#endif // Win16
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// undef the things which don't make sense for wxBase build
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if !wxUSE_GUI
|
||||
|
||||
#undef wxUSE_HTML
|
||||
#define wxUSE_HTML 0
|
||||
|
||||
#endif // !wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// check the settings consistency: do it here to abort compilation immediately
|
||||
// and not almost in the very end when the relevant file fails to compile and
|
||||
// you need to modify setup.h and rebuild everything
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_TIMEDATE && !wxUSE_LONGLONG
|
||||
#error wxDateTime requires wxLongLong
|
||||
#endif
|
||||
|
||||
#if wxUSE_TEXTFILE && !wxUSE_FILE
|
||||
#error You cannot compile wxTextFile without wxFile
|
||||
#endif
|
||||
|
||||
#if wxUSE_FILESYSTEM && !wxUSE_STREAMS
|
||||
#error You cannot compile virtual file systems without wxUSE_STREAMS
|
||||
#endif
|
||||
|
||||
#if wxUSE_HTML && !wxUSE_FILESYSTEM
|
||||
#error You cannot compile wxHTML without virtual file systems
|
||||
#endif
|
||||
|
||||
// add more tests here...
|
||||
|
||||
#endif
|
||||
// _WX_SETUP_H_
|
451
include/wx/msw/window.h
Normal file
@@ -0,0 +1,451 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: window.h
|
||||
// Purpose: wxWindow class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart and Markus Holzem
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_WINDOW_H_
|
||||
#define _WX_WINDOW_H_
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// headers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "window.h"
|
||||
#endif
|
||||
|
||||
// #include "wx/msw/winundef.h"
|
||||
|
||||
// VZ: apparently some version of Windows send extra mouse move messages after
|
||||
// a mouse click. My tests under NT 4.0 and 95 didn't show it so I'm
|
||||
// tempted to think that it was just an effect of a poor mouse and so the
|
||||
// code to work around this is currently disabled - just define this as 1
|
||||
// to reenable it
|
||||
#define wxUSE_MOUSEEVENT_HACK 0
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxButton;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// constants
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// FIXME does anybody use those? they're unused by wxWindows...
|
||||
enum
|
||||
{
|
||||
wxKEY_SHIFT = 1,
|
||||
wxKEY_CTRL = 2
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxWindow declaration for MSW
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxWindow : public wxWindowBase
|
||||
{
|
||||
public:
|
||||
wxWindow() { Init(); }
|
||||
|
||||
wxWindow(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxPanelNameStr)
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, pos, size, style, name);
|
||||
}
|
||||
|
||||
virtual ~wxWindow();
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxPanelNameStr);
|
||||
|
||||
// implement base class pure virtuals
|
||||
virtual void SetTitle( const wxString& title);
|
||||
virtual wxString GetTitle() const;
|
||||
|
||||
virtual void Raise();
|
||||
virtual void Lower();
|
||||
|
||||
virtual bool Show( bool show = TRUE );
|
||||
virtual bool Enable( bool enable = TRUE );
|
||||
|
||||
virtual void SetFocus();
|
||||
|
||||
virtual bool Reparent( wxWindowBase *newParent );
|
||||
|
||||
virtual void WarpPointer(int x, int y);
|
||||
virtual void CaptureMouse();
|
||||
virtual void ReleaseMouse();
|
||||
|
||||
virtual void Refresh( bool eraseBackground = TRUE,
|
||||
const wxRect *rect = (const wxRect *) NULL );
|
||||
virtual void Clear();
|
||||
|
||||
virtual bool SetCursor( const wxCursor &cursor );
|
||||
virtual bool SetFont( const wxFont &font );
|
||||
|
||||
virtual int GetCharHeight() const;
|
||||
virtual int GetCharWidth() const;
|
||||
virtual void GetTextExtent(const wxString& string,
|
||||
int *x, int *y,
|
||||
int *descent = (int *) NULL,
|
||||
int *externalLeading = (int *) NULL,
|
||||
const wxFont *theFont = (const wxFont *) NULL)
|
||||
const;
|
||||
|
||||
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
|
||||
|
||||
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
|
||||
int range, bool refresh = TRUE );
|
||||
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
|
||||
virtual int GetScrollPos( int orient ) const;
|
||||
virtual int GetScrollThumb( int orient ) const;
|
||||
virtual int GetScrollRange( int orient ) const;
|
||||
virtual void ScrollWindow( int dx, int dy,
|
||||
const wxRect* rect = (wxRect *) NULL );
|
||||
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
virtual void SetDropTarget( wxDropTarget *dropTarget );
|
||||
#endif // wxUSE_DRAG_AND_DROP
|
||||
|
||||
// Accept files for dragging
|
||||
virtual void DragAcceptFiles(bool accept);
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
// Set/get scroll attributes
|
||||
virtual void SetScrollRange(int orient, int range, bool refresh = TRUE);
|
||||
virtual void SetScrollPage(int orient, int page, bool refresh = TRUE);
|
||||
virtual int OldGetScrollRange(int orient) const;
|
||||
virtual int GetScrollPage(int orient) const;
|
||||
|
||||
// event handlers
|
||||
// Handle a control command
|
||||
virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
|
||||
|
||||
// Override to define new behaviour for default action (e.g. double
|
||||
// clicking on a listbox)
|
||||
virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { }
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
#if wxUSE_CARET && WXWIN_COMPATIBILITY
|
||||
// caret manipulation (old MSW only functions, see wxCaret class for the
|
||||
// new API)
|
||||
void CreateCaret(int w, int h);
|
||||
void CreateCaret(const wxBitmap *bitmap);
|
||||
void DestroyCaret();
|
||||
void ShowCaret(bool show);
|
||||
void SetCaretPos(int x, int y);
|
||||
void GetCaretPos(int *x, int *y) const;
|
||||
#endif // wxUSE_CARET
|
||||
|
||||
// Native resource loading (implemented in src/msw/nativdlg.cpp)
|
||||
// FIXME: should they really be all virtual?
|
||||
virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id);
|
||||
virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
|
||||
wxWindow* GetWindowChild1(wxWindowID id);
|
||||
wxWindow* GetWindowChild(wxWindowID id);
|
||||
|
||||
// a MSW only function which sends a size event to the window using its
|
||||
// current size - this has an effect of refreshing the window layout
|
||||
/*
|
||||
FUNCTION IS NOW A MEMBER OF wxFrame - gt
|
||||
void SendSizeEvent();
|
||||
*/
|
||||
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
// simple accessors
|
||||
// ----------------
|
||||
|
||||
WXHWND GetHWND() const { return m_hWnd; }
|
||||
void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
|
||||
virtual WXWidget GetHandle() const { return GetHWND(); }
|
||||
|
||||
bool GetUseCtl3D() const { return m_useCtl3D; }
|
||||
bool GetTransparentBackground() const { return m_backgroundTransparent; }
|
||||
void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; }
|
||||
|
||||
// event handlers
|
||||
// --------------
|
||||
|
||||
void OnSetFocus(wxFocusEvent& event);
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
void OnIdle(wxIdleEvent& event);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
|
||||
public:
|
||||
// For implementation purposes - sometimes decorations make the client area
|
||||
// smaller
|
||||
virtual wxPoint GetClientAreaOrigin() const;
|
||||
|
||||
// Makes an adjustment to the window position (for example, a frame that has
|
||||
// a toolbar that it manages itself).
|
||||
virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
|
||||
|
||||
// Windows subclassing
|
||||
void SubclassWin(WXHWND hWnd);
|
||||
void UnsubclassWin();
|
||||
|
||||
WXFARPROC MSWGetOldWndProc() const { return m_oldWndProc; }
|
||||
void MSWSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; }
|
||||
|
||||
wxWindow *FindItem(long id) const;
|
||||
wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
|
||||
|
||||
// Make a Windows extended style from the given wxWindows window style
|
||||
static WXDWORD MakeExtendedStyle(long style,
|
||||
bool eliminateBorders = FALSE);
|
||||
// Determine whether 3D effects are wanted
|
||||
WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const;
|
||||
|
||||
// MSW only: TRUE if this control is part of the main control
|
||||
virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
|
||||
|
||||
// returns TRUE if the window has been created
|
||||
bool MSWCreate(int id,
|
||||
wxWindow *parent,
|
||||
const wxChar *wclass,
|
||||
wxWindow *wx_win,
|
||||
const wxChar *title,
|
||||
int x, int y, int width, int height,
|
||||
WXDWORD style,
|
||||
const wxChar *dialog_template = NULL,
|
||||
WXDWORD exendedStyle = 0);
|
||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
wxObject *GetChild(int number) const;
|
||||
virtual void MSWDeviceToLogical(float *x, float *y) const;
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
// Create an appropriate wxWindow from a HWND
|
||||
virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd);
|
||||
|
||||
// Make sure the window style reflects the HWND style (roughly)
|
||||
virtual void AdoptAttributesFromHWND();
|
||||
|
||||
// Setup background and foreground colours correctly
|
||||
virtual void SetupColours();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// helpers for message handlers: these perform the same function as the
|
||||
// message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
|
||||
// the correct parameters
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void UnpackCommand(WXWPARAM wParam, WXLPARAM lParam,
|
||||
WXWORD *id, WXHWND *hwnd, WXWORD *cmd);
|
||||
void UnpackActivate(WXWPARAM wParam, WXLPARAM lParam,
|
||||
WXWORD *state, WXWORD *minimized, WXHWND *hwnd);
|
||||
void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
|
||||
WXWORD *code, WXWORD *pos, WXHWND *hwnd);
|
||||
void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
|
||||
WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd);
|
||||
void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
|
||||
WXWORD *item, WXWORD *flags, WXHMENU *hmenu);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// internal handlers for MSW messages: all handlers return a boolean value:
|
||||
// TRUE means that the handler processed the event and FALSE that it didn't
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// there are several cases where we have virtual functions for Windows
|
||||
// message processing: this is because these messages often require to be
|
||||
// processed in a different manner in the derived classes. For all other
|
||||
// messages, however, we do *not* have corresponding MSWOnXXX() function
|
||||
// and if the derived class wants to process them, it should override
|
||||
// MSWWindowProc() directly.
|
||||
|
||||
// scroll event (both horizontal and vertical)
|
||||
virtual bool MSWOnScroll(int orientation, WXWORD nSBCode,
|
||||
WXWORD pos, WXHWND control);
|
||||
|
||||
// child control notifications
|
||||
#ifdef __WIN95__
|
||||
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
||||
#endif // __WIN95__
|
||||
|
||||
// owner-drawn controls need to process these messages
|
||||
virtual bool MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *item);
|
||||
virtual bool MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item);
|
||||
|
||||
// the rest are not virtual
|
||||
bool HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate);
|
||||
bool HandleInitDialog(WXHWND hWndFocus);
|
||||
bool HandleDestroy();
|
||||
|
||||
bool HandlePaint();
|
||||
bool HandleEraseBkgnd(WXHDC pDC);
|
||||
|
||||
bool HandleMinimize();
|
||||
bool HandleMaximize();
|
||||
bool HandleSize(int x, int y, WXUINT flag);
|
||||
bool HandleGetMinMaxInfo(void *mmInfo);
|
||||
|
||||
bool HandleShow(bool show, int status);
|
||||
bool HandleActivate(int flag, bool minimized, WXHWND activate);
|
||||
|
||||
bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
|
||||
bool HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
bool HandleCtlColor(WXHBRUSH *hBrush,
|
||||
WXHDC hdc,
|
||||
WXHWND hWnd,
|
||||
WXUINT nCtlColor,
|
||||
WXUINT message,
|
||||
WXWPARAM wParam,
|
||||
WXLPARAM lParam);
|
||||
|
||||
bool HandlePaletteChanged(WXHWND hWndPalChange);
|
||||
bool HandleQueryNewPalette();
|
||||
bool HandleSysColorChange();
|
||||
|
||||
bool HandleQueryEndSession(long logOff, bool *mayEnd);
|
||||
bool HandleEndSession(bool endSession, long logOff);
|
||||
|
||||
bool HandleSetFocus(WXHWND wnd);
|
||||
bool HandleKillFocus(WXHWND wnd);
|
||||
|
||||
bool HandleDropFiles(WXWPARAM wParam);
|
||||
|
||||
bool HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags);
|
||||
bool HandleMouseMove(int x, int y, WXUINT flags);
|
||||
|
||||
bool HandleChar(WXWPARAM wParam, WXLPARAM lParam, bool isASCII = FALSE);
|
||||
bool HandleKeyDown(WXWPARAM wParam, WXLPARAM lParam);
|
||||
bool HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
bool HandleQueryDragIcon(WXHICON *hIcon);
|
||||
|
||||
bool HandleSetCursor(WXHWND hWnd, short nHitTest, int mouseMsg);
|
||||
|
||||
// Window procedure
|
||||
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
// Calls an appropriate default window procedure
|
||||
virtual long MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual bool MSWProcessMessage(WXMSG* pMsg);
|
||||
virtual bool MSWTranslateMessage(WXMSG* pMsg);
|
||||
virtual void MSWDestroyWindow();
|
||||
|
||||
// Detach "Window" menu from menu bar so it doesn't get deleted
|
||||
void MSWDetachWindowMenu();
|
||||
|
||||
// this function should return the brush to paint the window background
|
||||
// with or 0 for the default brush
|
||||
virtual WXHBRUSH OnCtlColor(WXHDC hDC,
|
||||
WXHWND hWnd,
|
||||
WXUINT nCtlColor,
|
||||
WXUINT message,
|
||||
WXWPARAM wParam,
|
||||
WXLPARAM lParam);
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
void SetShowing(bool show) { (void)Show(show); }
|
||||
bool IsUserEnabled() const { return IsEnabled(); }
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
// Responds to colour changes: passes event on to children.
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
|
||||
// initialize various fields of wxMouseEvent (common part of MSWOnMouseXXX)
|
||||
void InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags);
|
||||
|
||||
protected:
|
||||
// the window handle
|
||||
WXHWND m_hWnd;
|
||||
|
||||
// the old window proc (we subclass all windows)
|
||||
WXFARPROC m_oldWndProc;
|
||||
|
||||
// additional (MSW specific) flags
|
||||
bool m_useCtl3D:1; // Using CTL3D for this control
|
||||
bool m_backgroundTransparent:1;
|
||||
bool m_mouseInWindow:1;
|
||||
bool m_doubleClickAllowed:1;
|
||||
bool m_winCaptured:1;
|
||||
|
||||
// the size of one page for scrolling
|
||||
int m_xThumbSize;
|
||||
int m_yThumbSize;
|
||||
|
||||
#if wxUSE_MOUSEEVENT_HACK
|
||||
// the coordinates of the last mouse event and the type of it
|
||||
long m_lastMouseX,
|
||||
m_lastMouseY;
|
||||
int m_lastMouseEvent;
|
||||
#endif // wxUSE_MOUSEEVENT_HACK
|
||||
|
||||
WXHMENU m_hMenu; // Menu, if any
|
||||
|
||||
// the return value of WM_GETDLGCODE handler
|
||||
long m_lDlgCode;
|
||||
|
||||
// implement the base class pure virtuals
|
||||
virtual void DoClientToScreen( int *x, int *y ) const;
|
||||
virtual void DoScreenToClient( int *x, int *y ) const;
|
||||
virtual void DoGetPosition( int *x, int *y ) const;
|
||||
virtual void DoGetSize( int *width, int *height ) const;
|
||||
virtual void DoGetClientSize( int *width, int *height ) const;
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
virtual void DoSetClientSize(int width, int height);
|
||||
|
||||
// move the window to the specified location and resize it: this is called
|
||||
// from both DoSetSize() and DoSetClientSize() and would usually just call
|
||||
// ::MoveWindow() except for composite controls which will want to arrange
|
||||
// themselves inside the given rectangle
|
||||
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
virtual void DoSetToolTip( wxToolTip *tip );
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
|
||||
private:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// the (non-virtual) handlers for the events
|
||||
bool HandleMove(int x, int y);
|
||||
bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
|
||||
|
||||
#ifdef __WIN95__
|
||||
bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
||||
#endif // __WIN95__
|
||||
|
||||
// the helper functions used by HandleChar/KeyXXX methods
|
||||
wxKeyEvent CreateKeyEvent(wxEventType evType, int id, WXLPARAM lp) const;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxWindow);
|
||||
DECLARE_NO_COPY_CLASS(wxWindow);
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// global functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// kbd code translation
|
||||
WXDLLEXPORT int wxCharCodeMSWToWX(int keySym);
|
||||
WXDLLEXPORT int wxCharCodeWXToMSW(int id, bool *IsVirtual);
|
||||
|
||||
#endif
|
||||
// _WX_WINDOW_H_
|
1145
src/common/event.cpp
Normal file
8538
src/generic/grid.cpp
Normal file
704
src/generic/scrolwin.cpp
Normal file
@@ -0,0 +1,704 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: generic/scrolwin.cpp
|
||||
// Purpose: wxGenericScrolledWindow implementation
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart and Markus Holzem
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "scrolwin.h"
|
||||
#endif
|
||||
|
||||
#ifdef __VMS
|
||||
#define XtDisplay XTDISPLAY
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/utils.h"
|
||||
#include "wx/dcclient.h"
|
||||
|
||||
#include "wx/generic/scrolwin.h"
|
||||
#include "wx/panel.h"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include "windows.h"
|
||||
#endif
|
||||
|
||||
#ifdef __WXMOTIF__
|
||||
// For wxRETAINED implementation
|
||||
#ifdef __VMS__ //VMS's Xm.h is not (yet) compatible with C++
|
||||
//This code switches off the compiler warnings
|
||||
# pragma message disable nosimpint
|
||||
#endif
|
||||
#include <Xm/Xm.h>
|
||||
#ifdef __VMS__
|
||||
# pragma message enable nosimpint
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __WXGTK__
|
||||
#include "wx/scrolwin.h"
|
||||
IMPLEMENT_CLASS(wxScrolledWindow, wxGenericScrolledWindow)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event tables
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_EVENT_TABLE(wxGenericScrolledWindow, wxPanel)
|
||||
EVT_SCROLLWIN(wxGenericScrolledWindow::OnScroll)
|
||||
EVT_SIZE(wxGenericScrolledWindow::OnSize)
|
||||
EVT_PAINT(wxGenericScrolledWindow::OnPaint)
|
||||
EVT_CHAR(wxGenericScrolledWindow::OnChar)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxGenericScrolledWindow, wxPanel)
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGenericScrolledWindow creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxGenericScrolledWindow::wxGenericScrolledWindow()
|
||||
{
|
||||
m_xScrollPixelsPerLine = 0;
|
||||
m_yScrollPixelsPerLine = 0;
|
||||
m_xScrollingEnabled = TRUE;
|
||||
m_yScrollingEnabled = TRUE;
|
||||
m_xScrollPosition = 0;
|
||||
m_yScrollPosition = 0;
|
||||
m_xScrollLines = 0;
|
||||
m_yScrollLines = 0;
|
||||
m_xScrollLinesPerPage = 0;
|
||||
m_yScrollLinesPerPage = 0;
|
||||
m_scaleX = 1.0;
|
||||
m_scaleY = 1.0;
|
||||
m_targetWindow = (wxWindow*) NULL;
|
||||
}
|
||||
|
||||
bool wxGenericScrolledWindow::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
m_xScrollPixelsPerLine = 0;
|
||||
m_yScrollPixelsPerLine = 0;
|
||||
m_xScrollingEnabled = TRUE;
|
||||
m_yScrollingEnabled = TRUE;
|
||||
m_xScrollPosition = 0;
|
||||
m_yScrollPosition = 0;
|
||||
m_xScrollLines = 0;
|
||||
m_yScrollLines = 0;
|
||||
m_xScrollLinesPerPage = 0;
|
||||
m_yScrollLinesPerPage = 0;
|
||||
m_scaleX = 1.0;
|
||||
m_scaleY = 1.0;
|
||||
|
||||
m_targetWindow = this;
|
||||
|
||||
bool ok = wxPanel::Create(parent, id, pos, size, style, name);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// we need to process arrows ourselves for scrolling
|
||||
m_lDlgCode |= DLGC_WANTARROWS;
|
||||
#endif // __WXMSW__
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
wxGenericScrolledWindow::~wxGenericScrolledWindow()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// setting scrolling parameters
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* pixelsPerUnitX/pixelsPerUnitY: number of pixels per unit (e.g. pixels per text line)
|
||||
* noUnitsX/noUnitsY: : no. units per scrollbar
|
||||
*/
|
||||
void wxGenericScrolledWindow::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY,
|
||||
int noUnitsX, int noUnitsY,
|
||||
int xPos, int yPos, bool noRefresh )
|
||||
{
|
||||
int xpos, ypos;
|
||||
|
||||
CalcUnscrolledPosition(xPos, yPos, &xpos, &ypos);
|
||||
bool do_refresh =
|
||||
(
|
||||
(noUnitsX != 0 && m_xScrollLines == 0) ||
|
||||
(noUnitsX < m_xScrollLines && xpos > pixelsPerUnitX*noUnitsX) ||
|
||||
|
||||
(noUnitsY != 0 && m_yScrollLines == 0) ||
|
||||
(noUnitsY < m_yScrollLines && ypos > pixelsPerUnitY*noUnitsY) ||
|
||||
(xPos != m_xScrollPosition) ||
|
||||
(yPos != m_yScrollPosition)
|
||||
// (pixelsPerUnitX != m_xScrollPixelsPerLine) ||
|
||||
// (pixelsPerUnitY != m_yScrollPixelsPerLine)
|
||||
);
|
||||
|
||||
m_xScrollPixelsPerLine = pixelsPerUnitX;
|
||||
m_yScrollPixelsPerLine = pixelsPerUnitY;
|
||||
m_xScrollPosition = xPos;
|
||||
m_yScrollPosition = yPos;
|
||||
m_xScrollLines = noUnitsX;
|
||||
m_yScrollLines = noUnitsY;
|
||||
|
||||
#ifdef __WXMOTIF__
|
||||
// Sorry, some Motif-specific code to implement a backing pixmap
|
||||
// for the wxRETAINED style. Implementing a backing store can't
|
||||
// be entirely generic because it relies on the wxWindowDC implementation
|
||||
// to duplicate X drawing calls for the backing pixmap.
|
||||
|
||||
if ((m_windowStyle & wxRETAINED) == wxRETAINED)
|
||||
{
|
||||
Display* dpy = XtDisplay((Widget) GetMainWidget());
|
||||
|
||||
int totalPixelWidth = m_xScrollLines * m_xScrollPixelsPerLine;
|
||||
int totalPixelHeight = m_yScrollLines * m_yScrollPixelsPerLine;
|
||||
if (m_backingPixmap &&
|
||||
!((m_pixmapWidth == totalPixelWidth) &&
|
||||
(m_pixmapHeight == totalPixelHeight)))
|
||||
{
|
||||
XFreePixmap (dpy, (Pixmap) m_backingPixmap);
|
||||
m_backingPixmap = (WXPixmap) 0;
|
||||
}
|
||||
|
||||
if (!m_backingPixmap &&
|
||||
(noUnitsX != 0) && (noUnitsY != 0))
|
||||
{
|
||||
int depth = wxDisplayDepth();
|
||||
m_pixmapWidth = totalPixelWidth;
|
||||
m_pixmapHeight = totalPixelHeight;
|
||||
m_backingPixmap = (WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
|
||||
m_pixmapWidth, m_pixmapHeight, depth);
|
||||
}
|
||||
|
||||
}
|
||||
#endif // Motif
|
||||
|
||||
AdjustScrollbars();
|
||||
|
||||
if (do_refresh && !noRefresh)
|
||||
m_targetWindow->Refresh();
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// GRG: if this turns out to be really necessary, we could
|
||||
// at least move it to the above if { ... } so that it is
|
||||
// only done if noRefresh = FALSE (the default). OTOH, if
|
||||
// this doesn't break anything, which seems to be the
|
||||
// case, we could just leave it out.
|
||||
|
||||
// Necessary?
|
||||
// UpdateWindow ((HWND) m_targetWindow->GetHWND());
|
||||
#endif
|
||||
#ifdef __WXMAC__
|
||||
m_targetWindow->MacUpdateImmediately() ;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// target window handling
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxGenericScrolledWindow::SetTargetWindow( wxWindow *target )
|
||||
{
|
||||
wxASSERT_MSG( target, wxT("target window must not be NULL") );
|
||||
m_targetWindow = target;
|
||||
}
|
||||
|
||||
wxWindow *wxGenericScrolledWindow::GetTargetWindow()
|
||||
{
|
||||
return m_targetWindow;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// scrolling implementation itself
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxGenericScrolledWindow::OnScroll(wxScrollWinEvent& event)
|
||||
{
|
||||
int orient = event.GetOrientation();
|
||||
|
||||
int nScrollInc = CalcScrollInc(event);
|
||||
if (nScrollInc == 0) return;
|
||||
|
||||
if (orient == wxHORIZONTAL)
|
||||
{
|
||||
int newPos = m_xScrollPosition + nScrollInc;
|
||||
SetScrollPos(wxHORIZONTAL, newPos, TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
int newPos = m_yScrollPosition + nScrollInc;
|
||||
SetScrollPos(wxVERTICAL, newPos, TRUE );
|
||||
}
|
||||
|
||||
if (orient == wxHORIZONTAL)
|
||||
{
|
||||
m_xScrollPosition += nScrollInc;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_yScrollPosition += nScrollInc;
|
||||
}
|
||||
|
||||
if (orient == wxHORIZONTAL)
|
||||
{
|
||||
if (m_xScrollingEnabled)
|
||||
m_targetWindow->ScrollWindow(-m_xScrollPixelsPerLine * nScrollInc, 0, (const wxRect *) NULL);
|
||||
else
|
||||
m_targetWindow->Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_yScrollingEnabled)
|
||||
m_targetWindow->ScrollWindow(0, -m_yScrollPixelsPerLine * nScrollInc, (const wxRect *) NULL);
|
||||
else
|
||||
m_targetWindow->Refresh();
|
||||
}
|
||||
#ifdef __WXMAC__
|
||||
m_targetWindow->MacUpdateImmediately() ;
|
||||
#endif
|
||||
}
|
||||
|
||||
int wxGenericScrolledWindow::CalcScrollInc(wxScrollWinEvent& event)
|
||||
{
|
||||
int pos = event.GetPosition();
|
||||
int orient = event.GetOrientation();
|
||||
|
||||
int nScrollInc = 0;
|
||||
if (event.GetEventType() == wxEVT_SCROLLWIN_TOP)
|
||||
{
|
||||
if (orient == wxHORIZONTAL)
|
||||
nScrollInc = - m_xScrollPosition;
|
||||
else
|
||||
nScrollInc = - m_yScrollPosition;
|
||||
} else
|
||||
if (event.GetEventType() == wxEVT_SCROLLWIN_BOTTOM)
|
||||
{
|
||||
if (orient == wxHORIZONTAL)
|
||||
nScrollInc = m_xScrollLines - m_xScrollPosition;
|
||||
else
|
||||
nScrollInc = m_yScrollLines - m_yScrollPosition;
|
||||
} else
|
||||
if (event.GetEventType() == wxEVT_SCROLLWIN_LINEUP)
|
||||
{
|
||||
nScrollInc = -1;
|
||||
} else
|
||||
if (event.GetEventType() == wxEVT_SCROLLWIN_LINEDOWN)
|
||||
{
|
||||
nScrollInc = 1;
|
||||
} else
|
||||
if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEUP)
|
||||
{
|
||||
if (orient == wxHORIZONTAL)
|
||||
nScrollInc = -GetScrollPageSize(wxHORIZONTAL);
|
||||
else
|
||||
nScrollInc = -GetScrollPageSize(wxVERTICAL);
|
||||
} else
|
||||
if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN)
|
||||
{
|
||||
if (orient == wxHORIZONTAL)
|
||||
nScrollInc = GetScrollPageSize(wxHORIZONTAL);
|
||||
else
|
||||
nScrollInc = GetScrollPageSize(wxVERTICAL);
|
||||
} else
|
||||
if ((event.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK) ||
|
||||
(event.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE))
|
||||
{
|
||||
if (orient == wxHORIZONTAL)
|
||||
nScrollInc = pos - m_xScrollPosition;
|
||||
else
|
||||
nScrollInc = pos - m_yScrollPosition;
|
||||
}
|
||||
|
||||
if (orient == wxHORIZONTAL)
|
||||
{
|
||||
if (m_xScrollPixelsPerLine > 0)
|
||||
{
|
||||
int w, h;
|
||||
m_targetWindow->GetClientSize(&w, &h);
|
||||
|
||||
int nMaxWidth = m_xScrollLines*m_xScrollPixelsPerLine;
|
||||
int noPositions = (int) ( ((nMaxWidth - w)/(double)m_xScrollPixelsPerLine) + 0.5 );
|
||||
if (noPositions < 0)
|
||||
noPositions = 0;
|
||||
|
||||
if ( (m_xScrollPosition + nScrollInc) < 0 )
|
||||
nScrollInc = -m_xScrollPosition; // As -ve as we can go
|
||||
else if ( (m_xScrollPosition + nScrollInc) > noPositions )
|
||||
nScrollInc = noPositions - m_xScrollPosition; // As +ve as we can go
|
||||
}
|
||||
else
|
||||
m_targetWindow->Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_yScrollPixelsPerLine > 0)
|
||||
{
|
||||
int w, h;
|
||||
m_targetWindow->GetClientSize(&w, &h);
|
||||
|
||||
int nMaxHeight = m_yScrollLines*m_yScrollPixelsPerLine;
|
||||
int noPositions = (int) ( ((nMaxHeight - h)/(double)m_yScrollPixelsPerLine) + 0.5 );
|
||||
if (noPositions < 0)
|
||||
noPositions = 0;
|
||||
|
||||
if ( (m_yScrollPosition + nScrollInc) < 0 )
|
||||
nScrollInc = -m_yScrollPosition; // As -ve as we can go
|
||||
else if ( (m_yScrollPosition + nScrollInc) > noPositions )
|
||||
nScrollInc = noPositions - m_yScrollPosition; // As +ve as we can go
|
||||
}
|
||||
else
|
||||
m_targetWindow->Refresh();
|
||||
}
|
||||
|
||||
return nScrollInc;
|
||||
}
|
||||
|
||||
// Adjust the scrollbars - new version.
|
||||
void wxGenericScrolledWindow::AdjustScrollbars()
|
||||
{
|
||||
int w, h;
|
||||
m_targetWindow->GetClientSize(&w, &h);
|
||||
|
||||
int oldXScroll = m_xScrollPosition;
|
||||
int oldYScroll = m_yScrollPosition;
|
||||
|
||||
if (m_xScrollLines > 0)
|
||||
{
|
||||
// Calculate page size i.e. number of scroll units you get on the
|
||||
// current client window
|
||||
int noPagePositions = (int) ( (w/(double)m_xScrollPixelsPerLine) + 0.5 );
|
||||
if (noPagePositions < 1) noPagePositions = 1;
|
||||
|
||||
// Correct position if greater than extent of canvas minus
|
||||
// the visible portion of it or if below zero
|
||||
m_xScrollPosition = wxMin( m_xScrollLines-noPagePositions, m_xScrollPosition);
|
||||
m_xScrollPosition = wxMax( 0, m_xScrollPosition );
|
||||
|
||||
SetScrollbar(wxHORIZONTAL, m_xScrollPosition, noPagePositions, m_xScrollLines);
|
||||
// The amount by which we scroll when paging
|
||||
SetScrollPageSize(wxHORIZONTAL, noPagePositions);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xScrollPosition = 0;
|
||||
SetScrollbar (wxHORIZONTAL, 0, 0, 0, FALSE);
|
||||
}
|
||||
|
||||
if (m_yScrollLines > 0)
|
||||
{
|
||||
// Calculate page size i.e. number of scroll units you get on the
|
||||
// current client window
|
||||
int noPagePositions = (int) ( (h/(double)m_yScrollPixelsPerLine) + 0.5 );
|
||||
if (noPagePositions < 1) noPagePositions = 1;
|
||||
|
||||
// Correct position if greater than extent of canvas minus
|
||||
// the visible portion of it or if below zero
|
||||
m_yScrollPosition = wxMin( m_yScrollLines-noPagePositions, m_yScrollPosition );
|
||||
m_yScrollPosition = wxMax( 0, m_yScrollPosition );
|
||||
|
||||
SetScrollbar(wxVERTICAL, m_yScrollPosition, noPagePositions, m_yScrollLines);
|
||||
// The amount by which we scroll when paging
|
||||
SetScrollPageSize(wxVERTICAL, noPagePositions);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_yScrollPosition = 0;
|
||||
SetScrollbar (wxVERTICAL, 0, 0, 0, FALSE);
|
||||
}
|
||||
|
||||
if (oldXScroll != m_xScrollPosition)
|
||||
{
|
||||
if (m_xScrollingEnabled)
|
||||
m_targetWindow->ScrollWindow( m_xScrollPixelsPerLine * (oldXScroll-m_xScrollPosition), 0, (const wxRect *) NULL );
|
||||
else
|
||||
m_targetWindow->Refresh();
|
||||
}
|
||||
|
||||
if (oldYScroll != m_yScrollPosition)
|
||||
{
|
||||
if (m_yScrollingEnabled)
|
||||
m_targetWindow->ScrollWindow( 0, m_yScrollPixelsPerLine * (oldYScroll-m_yScrollPosition), (const wxRect *) NULL );
|
||||
else
|
||||
m_targetWindow->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
// Override this function if you don't want to have wxGenericScrolledWindow
|
||||
// automatically change the origin according to the scroll position.
|
||||
void wxGenericScrolledWindow::PrepareDC(wxDC& dc)
|
||||
{
|
||||
dc.SetDeviceOrigin( -m_xScrollPosition * m_xScrollPixelsPerLine,
|
||||
-m_yScrollPosition * m_yScrollPixelsPerLine );
|
||||
dc.SetUserScale( m_scaleX, m_scaleY );
|
||||
}
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
void wxGenericScrolledWindow::GetScrollUnitsPerPage (int *x_page, int *y_page) const
|
||||
{
|
||||
*x_page = GetScrollPageSize(wxHORIZONTAL);
|
||||
*y_page = GetScrollPageSize(wxVERTICAL);
|
||||
}
|
||||
|
||||
void wxGenericScrolledWindow::CalcUnscrolledPosition(int x, int y, float *xx, float *yy) const
|
||||
{
|
||||
if ( xx )
|
||||
*xx = (float)(x + m_xScrollPosition * m_xScrollPixelsPerLine);
|
||||
if ( yy )
|
||||
*yy = (float)(y + m_yScrollPosition * m_yScrollPixelsPerLine);
|
||||
}
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
void wxGenericScrolledWindow::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const
|
||||
{
|
||||
if ( x_unit )
|
||||
*x_unit = m_xScrollPixelsPerLine;
|
||||
if ( y_unit )
|
||||
*y_unit = m_yScrollPixelsPerLine;
|
||||
}
|
||||
|
||||
int wxGenericScrolledWindow::GetScrollPageSize(int orient) const
|
||||
{
|
||||
if ( orient == wxHORIZONTAL )
|
||||
return m_xScrollLinesPerPage;
|
||||
else
|
||||
return m_yScrollLinesPerPage;
|
||||
}
|
||||
|
||||
void wxGenericScrolledWindow::SetScrollPageSize(int orient, int pageSize)
|
||||
{
|
||||
if ( orient == wxHORIZONTAL )
|
||||
m_xScrollLinesPerPage = pageSize;
|
||||
else
|
||||
m_yScrollLinesPerPage = pageSize;
|
||||
}
|
||||
|
||||
/*
|
||||
* Scroll to given position (scroll position, not pixel position)
|
||||
*/
|
||||
void wxGenericScrolledWindow::Scroll( int x_pos, int y_pos )
|
||||
{
|
||||
if (!m_targetWindow)
|
||||
return;
|
||||
|
||||
if (((x_pos == -1) || (x_pos == m_xScrollPosition)) &&
|
||||
((y_pos == -1) || (y_pos == m_yScrollPosition))) return;
|
||||
|
||||
int w, h;
|
||||
m_targetWindow->GetClientSize(&w, &h);
|
||||
|
||||
if ((x_pos != -1) && (m_xScrollPixelsPerLine))
|
||||
{
|
||||
int old_x = m_xScrollPosition;
|
||||
m_xScrollPosition = x_pos;
|
||||
|
||||
// Calculate page size i.e. number of scroll units you get on the
|
||||
// current client window
|
||||
int noPagePositions = (int) ( (w/(double)m_xScrollPixelsPerLine) + 0.5 );
|
||||
if (noPagePositions < 1) noPagePositions = 1;
|
||||
|
||||
// Correct position if greater than extent of canvas minus
|
||||
// the visible portion of it or if below zero
|
||||
m_xScrollPosition = wxMin( m_xScrollLines-noPagePositions, m_xScrollPosition );
|
||||
m_xScrollPosition = wxMax( 0, m_xScrollPosition );
|
||||
|
||||
if (old_x != m_xScrollPosition) {
|
||||
m_targetWindow->SetScrollPos( wxHORIZONTAL, m_xScrollPosition, TRUE );
|
||||
m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0 );
|
||||
}
|
||||
}
|
||||
if ((y_pos != -1) && (m_yScrollPixelsPerLine))
|
||||
{
|
||||
int old_y = m_yScrollPosition;
|
||||
m_yScrollPosition = y_pos;
|
||||
|
||||
// Calculate page size i.e. number of scroll units you get on the
|
||||
// current client window
|
||||
int noPagePositions = (int) ( (h/(double)m_yScrollPixelsPerLine) + 0.5 );
|
||||
if (noPagePositions < 1) noPagePositions = 1;
|
||||
|
||||
// Correct position if greater than extent of canvas minus
|
||||
// the visible portion of it or if below zero
|
||||
m_yScrollPosition = wxMin( m_yScrollLines-noPagePositions, m_yScrollPosition );
|
||||
m_yScrollPosition = wxMax( 0, m_yScrollPosition );
|
||||
|
||||
if (old_y != m_yScrollPosition) {
|
||||
m_targetWindow->SetScrollPos( wxVERTICAL, m_yScrollPosition, TRUE );
|
||||
m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __WXMAC__
|
||||
m_targetWindow->MacUpdateImmediately();
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxGenericScrolledWindow::EnableScrolling (bool x_scroll, bool y_scroll)
|
||||
{
|
||||
m_xScrollingEnabled = x_scroll;
|
||||
m_yScrollingEnabled = y_scroll;
|
||||
}
|
||||
|
||||
void wxGenericScrolledWindow::GetVirtualSize (int *x, int *y) const
|
||||
{
|
||||
if ( x )
|
||||
*x = m_xScrollPixelsPerLine * m_xScrollLines;
|
||||
if ( y )
|
||||
*y = m_yScrollPixelsPerLine * m_yScrollLines;
|
||||
}
|
||||
|
||||
// Where the current view starts from
|
||||
void wxGenericScrolledWindow::GetViewStart (int *x, int *y) const
|
||||
{
|
||||
if ( x )
|
||||
*x = m_xScrollPosition;
|
||||
if ( y )
|
||||
*y = m_yScrollPosition;
|
||||
}
|
||||
|
||||
void wxGenericScrolledWindow::CalcScrolledPosition(int x, int y, int *xx, int *yy) const
|
||||
{
|
||||
if ( xx )
|
||||
*xx = x - m_xScrollPosition * m_xScrollPixelsPerLine;
|
||||
if ( yy )
|
||||
*yy = y - m_yScrollPosition * m_yScrollPixelsPerLine;
|
||||
}
|
||||
|
||||
void wxGenericScrolledWindow::CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
|
||||
{
|
||||
if ( xx )
|
||||
*xx = x + m_xScrollPosition * m_xScrollPixelsPerLine;
|
||||
if ( yy )
|
||||
*yy = y + m_yScrollPosition * m_yScrollPixelsPerLine;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event handlers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Default OnSize resets scrollbars, if any
|
||||
void wxGenericScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event))
|
||||
{
|
||||
#if wxUSE_CONSTRAINTS
|
||||
if (GetAutoLayout())
|
||||
Layout();
|
||||
#endif
|
||||
|
||||
AdjustScrollbars();
|
||||
}
|
||||
|
||||
// This calls OnDraw, having adjusted the origin according to the current
|
||||
// scroll position
|
||||
void wxGenericScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
PrepareDC(dc);
|
||||
|
||||
OnDraw(dc);
|
||||
}
|
||||
|
||||
// kbd handling: notice that we use OnChar() and not OnKeyDown() for
|
||||
// compatibility here - if we used OnKeyDown(), the programs which process
|
||||
// arrows themselves in their OnChar() would never get the message and like
|
||||
// this they always have the priority
|
||||
void wxGenericScrolledWindow::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
int stx, sty, // view origin
|
||||
szx, szy, // view size (total)
|
||||
clix, cliy; // view size (on screen)
|
||||
|
||||
ViewStart(&stx, &sty);
|
||||
GetClientSize(&clix, &cliy);
|
||||
GetVirtualSize(&szx, &szy);
|
||||
|
||||
if( m_xScrollPixelsPerLine )
|
||||
{
|
||||
clix /= m_xScrollPixelsPerLine;
|
||||
szx /= m_xScrollPixelsPerLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
clix = 0;
|
||||
szx = -1;
|
||||
}
|
||||
if( m_yScrollPixelsPerLine )
|
||||
{
|
||||
cliy /= m_yScrollPixelsPerLine;
|
||||
szy /= m_yScrollPixelsPerLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
cliy = 0;
|
||||
szy = -1;
|
||||
}
|
||||
|
||||
int dsty;
|
||||
switch ( event.KeyCode() )
|
||||
{
|
||||
case WXK_PAGEUP:
|
||||
case WXK_PRIOR:
|
||||
dsty = sty - (5 * cliy / 6);
|
||||
Scroll(-1, (dsty == -1) ? 0 : dsty);
|
||||
break;
|
||||
|
||||
case WXK_PAGEDOWN:
|
||||
case WXK_NEXT:
|
||||
Scroll(-1, sty + (5 * cliy / 6));
|
||||
break;
|
||||
|
||||
case WXK_HOME:
|
||||
Scroll(0, event.ControlDown() ? 0 : -1);
|
||||
break;
|
||||
|
||||
case WXK_END:
|
||||
Scroll(szx - clix, event.ControlDown() ? szy - cliy : -1);
|
||||
break;
|
||||
|
||||
case WXK_UP:
|
||||
Scroll(-1, sty - 1);
|
||||
break;
|
||||
|
||||
case WXK_DOWN:
|
||||
Scroll(-1, sty + 1);
|
||||
break;
|
||||
|
||||
case WXK_LEFT:
|
||||
Scroll(stx - 1, -1);
|
||||
break;
|
||||
|
||||
case WXK_RIGHT:
|
||||
Scroll(stx + 1, -1);
|
||||
break;
|
||||
|
||||
default:
|
||||
// not for us
|
||||
event.Skip();
|
||||
}
|
||||
}
|
4473
src/msw/window.cpp
Normal file
@@ -1,262 +0,0 @@
|
||||
0.1.5-3
|
||||
-------
|
||||
|
||||
xxxStdDialogButtonSizer pulldown menu with standard buttons.
|
||||
|
||||
Some fixes for selecting tools inside toolbar with test window open
|
||||
(whole toolbar is selected).
|
||||
|
||||
Toolbars can be added inside windows.
|
||||
|
||||
0.1.5-2
|
||||
-------
|
||||
|
||||
Using wx.GetDefaultPyEncoding/wx.SetDefaultPyEncoding for changing active encoding.
|
||||
|
||||
Fixed pasting siblings (Ctrl key pressed while pasting).
|
||||
|
||||
Dealed with ascii build (Python does not recognize 'ascii' as valid encoding).
|
||||
If encoding is not specified it is not written in XRC. Will add more
|
||||
customization in the future.
|
||||
|
||||
Changed to use SimpleTool instead or Toggle tool (does not work on Win32).
|
||||
|
||||
0.1.5-1
|
||||
-------
|
||||
|
||||
Added wxWizard, wxWizardPageSimple (only from pull-down menu).
|
||||
|
||||
Hide command for test window.
|
||||
|
||||
Replacing classes works better.
|
||||
|
||||
Added Locate tool.
|
||||
|
||||
0.1.4-1
|
||||
-------
|
||||
|
||||
Edit->Locate command (Ctrl-L) for quick selection of items.
|
||||
Works with event-handling controls (buttons, text fields) but
|
||||
not with labels/sizers.
|
||||
|
||||
Some improvements: relative paths for files supplied as command-
|
||||
line argument work correctly, notebook panels are highlighted
|
||||
better.
|
||||
|
||||
0.1.2-1
|
||||
_______
|
||||
|
||||
Added support for wxGridBagSizer (supported in wxPython 2.5).
|
||||
|
||||
0.1.1-5
|
||||
-------
|
||||
|
||||
Added subclass attribute.
|
||||
|
||||
0.1.1-4
|
||||
-------
|
||||
|
||||
Fixed problems with wxStaticBitmap (stock_id attribute, icon type
|
||||
switching).
|
||||
|
||||
Changed some dimensions in properties panel elements.
|
||||
|
||||
0.1.1-3
|
||||
-------
|
||||
|
||||
Sizes of some controls were not normal on wxMSW. Fixed.
|
||||
|
||||
Some changes to test window code to make it resize better and to
|
||||
have focus control with sawfish for all types of windows.
|
||||
|
||||
0.1.1-2
|
||||
-------
|
||||
|
||||
Bugs with currentEncoding and frame testing fixed.
|
||||
|
||||
Some required parameters are set to default if missing.
|
||||
|
||||
Unsupported classes are tolerated, with warning message.
|
||||
|
||||
wxScrolledWindow added (to 'control' pulldown menu, not yet to the
|
||||
tool palette).
|
||||
|
||||
Multi-line editing for labels and some values (wxTextCtrl,
|
||||
wxHtmlWindow).
|
||||
|
||||
0.1.1-1
|
||||
-------
|
||||
|
||||
Changed internationalization support. '-i' option removed, default
|
||||
encoding is used (should be defined in sitecustomize.py, or 'ascii' by
|
||||
default). When XRC file is opened with encoding specified,
|
||||
translations are not used.
|
||||
|
||||
0.1.1
|
||||
-----
|
||||
|
||||
Replace command added (not quite finished yet).
|
||||
|
||||
0.1.0
|
||||
-----
|
||||
|
||||
Finally implemented tools panel for almost all controls (except
|
||||
wxHtmlWindow, wxCalendarCtrl and wxGenericDirCtrl - they are too
|
||||
rarely used).
|
||||
|
||||
Changed some sizes in panel to better work with different fonts.
|
||||
|
||||
Fixed double-refreshing after Ctrl+R.
|
||||
|
||||
Maybe something else that I've forgot. It's been a looong day... :)
|
||||
|
||||
|
||||
0.0.9-6
|
||||
-------
|
||||
|
||||
Added dialog unit support.
|
||||
|
||||
Dealing with non-specified required values (set to defaults, if exist).
|
||||
|
||||
Added 'minsize' parameter of sizeritem.
|
||||
|
||||
Added '-i' option to turn off translations and use international characters.
|
||||
|
||||
0.0.9-5
|
||||
-------
|
||||
|
||||
Mac platform-specific checks.
|
||||
|
||||
0.0.9-4
|
||||
-------
|
||||
|
||||
Implemented standard bitmap selection.
|
||||
|
||||
Fixed a bug in FlexGridSizer code.
|
||||
|
||||
0.0.9-3
|
||||
-------
|
||||
|
||||
File browsing (for bitmaps/icons, etc.) had a small problem when current
|
||||
file was not saved yet.
|
||||
|
||||
0.0.9-2
|
||||
-------
|
||||
|
||||
Small bug fix for initial don't panic message.
|
||||
|
||||
0.0.9-1
|
||||
-------
|
||||
|
||||
Changed program structure, reduced use of global variables (grouped in
|
||||
module 'globals', which creates an instanse 'g' of class Globals.
|
||||
|
||||
First version of undo/redo working!
|
||||
|
||||
Support for toolbars inside panels and frames.
|
||||
|
||||
Added 'container' submenu for creating Panel, Notebook and ToolBar objects.
|
||||
|
||||
wxMSW-only: added code to switch focus back to main window when test
|
||||
window is updated.
|
||||
|
||||
0.0.8-2
|
||||
-------
|
||||
|
||||
Fixed unicode problem for unicode build.
|
||||
|
||||
0.0.8-1
|
||||
-------
|
||||
|
||||
Using WX_2_4_BRANCH.
|
||||
|
||||
Added new controls: wxSpinCtrl, wxGenericDirCtrl, unknown (custom
|
||||
control), improved wxXRC format suppor (menu styles, etc.).
|
||||
|
||||
Some I18N support: parsing "encoding" attribute in XML header, later
|
||||
it can be modified in "properties" panel for "XML tree".
|
||||
|
||||
UNIX note: currently XML writing for non-ascii chars works only if
|
||||
sys.getdefaultencoding() returns good value. To do this, one has to
|
||||
put following lines to "sitecustomize.py" file:
|
||||
|
||||
# Start code segment
|
||||
import sys
|
||||
sys.setdefaultencoding('iso-8859-1') # or whatever
|
||||
# End code segment
|
||||
|
||||
0.0.7
|
||||
-----
|
||||
|
||||
Some command-line arguments.
|
||||
|
||||
"Test window" command and toolbar button.
|
||||
|
||||
New panel interphace (wxHTMLWindow is not used anymore).
|
||||
|
||||
Toggling between embedded and detached panel.
|
||||
|
||||
Cache for already used windows.
|
||||
|
||||
Current top-level control is bold, if test window shown.
|
||||
|
||||
Undo/redo broken.
|
||||
|
||||
CheckListBox does not work unless wxXRC source fixed (in both wxPytnon and
|
||||
wxWin):
|
||||
|
||||
contrib/src/xrc/xmlrsall.cpp
|
||||
45,46c45,46
|
||||
< AddHandler(new wxListCtrlXmlHandler);
|
||||
< #if CHECKLISTBOX
|
||||
---
|
||||
> AddHandler(new wxListCtrlXmlHandler);
|
||||
> #if wxUSE_CHECKLISTBOX
|
||||
|
||||
This is fixed in CVS.
|
||||
|
||||
0.0.6
|
||||
-----
|
||||
|
||||
Toolbar, bitmap, icon support (no display yet).
|
||||
|
||||
Changed parameter objects, added support for multiple parameters (like
|
||||
`growablecols').
|
||||
|
||||
Fixed double-clicking problem with tree control on Windows.
|
||||
|
||||
Some performance improovements.
|
||||
|
||||
|
||||
0.0.5
|
||||
-----
|
||||
|
||||
Added notebook with properties page and style page. Fixed some problems
|
||||
on Windows.
|
||||
|
||||
|
||||
0.0.4
|
||||
-----
|
||||
|
||||
Some fixes suggested by RD
|
||||
|
||||
|
||||
0.0.3
|
||||
-----
|
||||
|
||||
Faster preview window refresh.
|
||||
|
||||
Cut/Paste works better.
|
||||
|
||||
Some tree icons.
|
||||
|
||||
Tree item names.
|
||||
|
||||
Bugfixes.
|
||||
|
||||
|
||||
0.0.2
|
||||
-----
|
||||
|
||||
The first release.
|
||||
|
@@ -1,68 +0,0 @@
|
||||
********************************************************************************
|
||||
|
||||
XRCed README
|
||||
|
||||
********************************************************************************
|
||||
|
||||
System requirements
|
||||
-------------------
|
||||
|
||||
XRCed requires wxWindows and wxPython greater or equal to 2.3.3, and
|
||||
Python 2.2 or newer (it may work with earlier version, but was not tested).
|
||||
|
||||
wxPython must be compiled with XRC support.
|
||||
|
||||
|
||||
Short manual
|
||||
------------
|
||||
|
||||
XRCed's idea is very straightforward: it is a visual tool for editing an XML
|
||||
file conforming to XRC format. Every operation performed in XRCed has direct
|
||||
correspondence to XML structure. So it is not really a usual point-and-click
|
||||
GUI builder, but don't let that scare you.
|
||||
|
||||
To start xrced, change to the directory where you installed it and run
|
||||
"python2.2 xrced.py".
|
||||
|
||||
On UNIX you can edit wrapper script "xrced.sh" to point to your installation
|
||||
directory.
|
||||
|
||||
To create an object, first you should select some object in the tree (or the
|
||||
root item if it's empty) then press the right mouse button and select an
|
||||
appropriate command. The pulldown menu is context-dependent on the selected
|
||||
object.
|
||||
|
||||
XRCed tries to guess if new object should be added as a next sibling or a
|
||||
child of current object, depending on the possibility of the object to have
|
||||
child objects and expanded state (if tree item is collapsed, new object will
|
||||
be sibling). You can change this behavior to create siblings by pressing and
|
||||
holding the Shift and Control keys before clicking the mouse.
|
||||
|
||||
Pressed Control key while pressing right button makes next item a sibling of
|
||||
selected item regardless of its expanded state.
|
||||
|
||||
Pressed Shift key changes the place for inserting new child to be before
|
||||
selected child, not after as by default.
|
||||
|
||||
Panel on the right contains object properties. Properties which are optional
|
||||
should be "checked" first. This panel can be made separate by unchecking
|
||||
"Embed Panel" in View menu.
|
||||
|
||||
All properties can be edited as text, and some are supplied with special
|
||||
editing controls.
|
||||
|
||||
The names of the properties are exactly as in XRC file, and it's usually not
|
||||
hard to guess what they do. XML ID is the name of the window, and must be
|
||||
present for top-level windows (though this is not enforced by XRCed).
|
||||
|
||||
To display the preview window double-click a top-level object (you should
|
||||
assign an XMLID to it first), press "Test" toolbar button or select command
|
||||
from View menu, or press F5. After that, if you select a child object, it
|
||||
becomes highlighted, and if you change it, preview is updated when you select
|
||||
another item or press Ctrl-R (refresh). To turn off automatic update, toggle
|
||||
"View->Auto-refresh" or toolbar auto-refresh button (to the right of the
|
||||
refresh button).
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Copyright 2001-2003 Roman Rolinsky <rollrom@xrced.sourceforge.net>
|
@@ -1,29 +0,0 @@
|
||||
TODO for XRCed
|
||||
==============
|
||||
|
||||
- better help
|
||||
|
||||
+ undo/redo
|
||||
|
||||
+ tree icons
|
||||
|
||||
- replace object with another, keeping children
|
||||
|
||||
+ write tmp file for current dialog/panel/etc.
|
||||
|
||||
+ XML indents
|
||||
|
||||
+ select same notebook pages after update
|
||||
|
||||
- put some default values in tree ctrl etc.
|
||||
|
||||
- special (fast) update for some values: pos/size, value/content, sizeritem
|
||||
stuff (?), well, as much as possible
|
||||
|
||||
- highlighting with better method
|
||||
|
||||
- import XRC/WXR files
|
||||
|
||||
+ disable some window creation when it's not valid
|
||||
|
||||
- selecting object by clicking in test window
|
Before Width: | Height: | Size: 542 B |
Before Width: | Height: | Size: 677 B |
@@ -1,4 +0,0 @@
|
||||
#
|
||||
|
||||
|
||||
|
@@ -1,34 +0,0 @@
|
||||
"""
|
||||
A simple script to encode all the images the XRCed needs into a Python module
|
||||
"""
|
||||
|
||||
import sys, os, glob
|
||||
from wx.tools import img2py
|
||||
|
||||
def main():
|
||||
output = 'images.py'
|
||||
|
||||
# get the list of PNG files
|
||||
files = glob.glob('src-images/*.png')
|
||||
files.sort()
|
||||
|
||||
# Truncate the inages module
|
||||
open(output, 'w')
|
||||
|
||||
# call img2py on each file
|
||||
for file in files:
|
||||
|
||||
# extract the basename to be used as the image name
|
||||
name = os.path.splitext(os.path.basename(file))[0]
|
||||
|
||||
# encode it
|
||||
if file == files[0]:
|
||||
cmd = "-u -i -n %s %s %s" % (name, file, output)
|
||||
else:
|
||||
cmd = "-a -u -i -n %s %s %s" % (name, file, output)
|
||||
img2py.main(cmd.split())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@@ -1,63 +0,0 @@
|
||||
# Name: globals.py
|
||||
# Purpose: XRC editor, global variables
|
||||
# Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be>
|
||||
# Created: 02.12.2002
|
||||
# RCS-ID: $Id$
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.xrc import *
|
||||
try:
|
||||
from wxPython.wizard import *
|
||||
except:
|
||||
pass
|
||||
import sys
|
||||
|
||||
# Global constants
|
||||
|
||||
progname = 'XRCed'
|
||||
version = '0.1.5-3'
|
||||
# Can be changed to set other default encoding different
|
||||
#defaultEncoding = ''
|
||||
# you comment above and can uncomment this:
|
||||
defaultEncoding = wxGetDefaultPyEncoding()
|
||||
|
||||
try:
|
||||
True
|
||||
except NameError:
|
||||
True = 1==1
|
||||
False = 1==0
|
||||
|
||||
# Global variables
|
||||
|
||||
class Globals:
|
||||
panel = None
|
||||
tree = None
|
||||
frame = None
|
||||
tools = None
|
||||
undoMan = None
|
||||
testWin = None
|
||||
testWinPos = wxDefaultPosition
|
||||
currentXXX = None
|
||||
currentEncoding = defaultEncoding
|
||||
|
||||
def _makeFonts(self):
|
||||
self._sysFont = wxSystemSettings_GetFont(wxSYS_SYSTEM_FONT)
|
||||
self._labelFont = wxFont(self._sysFont.GetPointSize(), wxDEFAULT, wxNORMAL, wxBOLD)
|
||||
self._modernFont = wxFont(self._sysFont.GetPointSize(), wxMODERN, wxNORMAL, wxNORMAL)
|
||||
self._smallerFont = wxFont(self._sysFont.GetPointSize()-2, wxDEFAULT, wxNORMAL, wxNORMAL)
|
||||
|
||||
def sysFont(self):
|
||||
if not hasattr(self, "_sysFont"): self._makeFonts()
|
||||
return self._sysFont
|
||||
def labelFont(self):
|
||||
if not hasattr(self, "_labelFont"): self._makeFonts()
|
||||
return self._labelFont
|
||||
def modernFont(self):
|
||||
if not hasattr(self, "_modernFont"): self._makeFonts()
|
||||
return self._modernFont
|
||||
def smallerFont(self):
|
||||
if not hasattr(self, "_smallerFont"): self._makeFonts()
|
||||
return self._smallerFont
|
||||
|
||||
|
||||
g = Globals()
|
@@ -1,23 +0,0 @@
|
||||
Copyright (c) 2002, Roman Rolinsky <rollrom@users.sourceforge.net>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
@@ -1,384 +0,0 @@
|
||||
# Name: panel.py
|
||||
# Purpose: XRC editor, Panel class and related
|
||||
# Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be>
|
||||
# Created: 02.12.2002
|
||||
# RCS-ID: $Id$
|
||||
|
||||
from xxx import * # xxx imports globals and params
|
||||
from undo import *
|
||||
from wxPython.html import wxHtmlWindow
|
||||
|
||||
# Properties panel containing notebook
|
||||
class Panel(wxNotebook):
|
||||
def __init__(self, parent, id = -1):
|
||||
if wxPlatform != '__WXMAC__': # some problems with this style on macs
|
||||
wxNotebook.__init__(self, parent, id, style=wxNB_BOTTOM)
|
||||
else:
|
||||
wxNotebook.__init__(self, parent, id)
|
||||
global panel
|
||||
g.panel = panel = self
|
||||
self.modified = False
|
||||
|
||||
# Set common button size for parameter buttons
|
||||
bTmp = wxButton(self, -1, '')
|
||||
import params
|
||||
params.buttonSize = (self.DLG_SZE(buttonSize)[0], bTmp.GetSize()[1])
|
||||
bTmp.Destroy()
|
||||
del bTmp
|
||||
|
||||
# List of child windows
|
||||
self.pages = []
|
||||
# Create scrolled windows for pages
|
||||
self.page1 = wxScrolledWindow(self, -1)
|
||||
sizer = wxBoxSizer()
|
||||
sizer.Add(wxBoxSizer()) # dummy sizer
|
||||
self.page1.SetAutoLayout(True)
|
||||
self.page1.SetSizer(sizer)
|
||||
self.AddPage(self.page1, 'Properties')
|
||||
# Second page
|
||||
self.page2 = wxScrolledWindow(self, -1)
|
||||
self.page2.Hide()
|
||||
sizer = wxBoxSizer()
|
||||
sizer.Add(wxBoxSizer()) # dummy sizer
|
||||
self.page2.SetAutoLayout(True)
|
||||
self.page2.SetSizer(sizer)
|
||||
# Cache for already used panels
|
||||
self.pageCache = {} # cached property panels
|
||||
self.stylePageCache = {} # cached style panels
|
||||
|
||||
# Delete child windows and recreate page sizer
|
||||
def ResetPage(self, page):
|
||||
topSizer = page.GetSizer()
|
||||
sizer = topSizer.GetChildren()[0].GetSizer()
|
||||
for w in page.GetChildren():
|
||||
sizer.Detach(w)
|
||||
if isinstance(w, ParamPage):
|
||||
if w.IsShown():
|
||||
w.Hide()
|
||||
else:
|
||||
w.Destroy()
|
||||
topSizer.Remove(sizer)
|
||||
# Create new windows
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
# Special case - resize html window
|
||||
if g.conf.panic:
|
||||
topSizer.Add(sizer, 1, wxEXPAND)
|
||||
else:
|
||||
topSizer.Add(sizer, 0, wxALL, 5)
|
||||
return sizer
|
||||
|
||||
def SetData(self, xxx):
|
||||
self.pages = []
|
||||
# First page
|
||||
# Remove current objects and sizer
|
||||
sizer = self.ResetPage(self.page1)
|
||||
if not xxx or (not xxx.allParams and not xxx.hasName and not xxx.hasChild):
|
||||
if g.tree.selection:
|
||||
sizer.Add(wxStaticText(self.page1, -1, 'This item has no properties.'))
|
||||
else: # nothing selected
|
||||
# If first time, show some help
|
||||
if g.conf.panic:
|
||||
html = wxHtmlWindow(self.page1, -1, wxDefaultPosition,
|
||||
wxDefaultSize, wxSUNKEN_BORDER)
|
||||
html.SetPage(g.helpText)
|
||||
sizer.Add(html, 1, wxEXPAND)
|
||||
g.conf.panic = False
|
||||
else:
|
||||
sizer.Add(wxStaticText(self.page1, -1, 'Select a tree item.'))
|
||||
else:
|
||||
g.currentXXX = xxx.treeObject()
|
||||
# Normal or SizerItem page
|
||||
isGBSizerItem = isinstance(xxx.parent, xxxGridBagSizer)
|
||||
cacheID = (xxx.__class__, isGBSizerItem)
|
||||
try:
|
||||
page = self.pageCache[cacheID]
|
||||
page.box.SetLabel(xxx.panelName())
|
||||
page.Show()
|
||||
except KeyError:
|
||||
page = PropPage(self.page1, xxx.panelName(), xxx)
|
||||
self.pageCache[cacheID] = page
|
||||
page.SetValues(xxx)
|
||||
self.pages.append(page)
|
||||
sizer.Add(page, 1, wxEXPAND)
|
||||
if xxx.hasChild:
|
||||
# Special label for child objects - they may have different GUI
|
||||
cacheID = (xxx.child.__class__, xxx.__class__)
|
||||
try:
|
||||
page = self.pageCache[cacheID]
|
||||
page.box.SetLabel(xxx.child.panelName())
|
||||
page.Show()
|
||||
except KeyError:
|
||||
page = PropPage(self.page1, xxx.child.panelName(), xxx.child)
|
||||
self.pageCache[cacheID] = page
|
||||
page.SetValues(xxx.child)
|
||||
self.pages.append(page)
|
||||
sizer.Add(page, 0, wxEXPAND | wxTOP, 5)
|
||||
self.page1.Layout()
|
||||
size = self.page1.GetSizer().GetMinSize()
|
||||
self.page1.SetScrollbars(1, 1, size.width, size.height, 0, 0, True)
|
||||
|
||||
# Second page
|
||||
# Create if does not exist
|
||||
if xxx and xxx.treeObject().hasStyle:
|
||||
xxx = xxx.treeObject()
|
||||
# Simplest case: set data if class is the same
|
||||
sizer = self.ResetPage(self.page2)
|
||||
try:
|
||||
page = self.stylePageCache[xxx.__class__]
|
||||
page.Show()
|
||||
except KeyError:
|
||||
page = StylePage(self.page2, xxx.className + ' style', xxx)
|
||||
self.stylePageCache[xxx.__class__] = page
|
||||
page.SetValues(xxx)
|
||||
self.pages.append(page)
|
||||
sizer.Add(page, 0, wxEXPAND)
|
||||
# Add page if not exists
|
||||
if not self.GetPageCount() == 2:
|
||||
self.AddPage(self.page2, 'Style')
|
||||
self.page2.Layout()
|
||||
if 'wxGTK' in wx.PlatformInfo:
|
||||
self.page2.Show(True)
|
||||
size = self.page2.GetSizer().GetMinSize()
|
||||
self.page2.SetScrollbars(1, 1, size.width, size.height, 0, 0, True)
|
||||
else:
|
||||
# Remove page if exists
|
||||
if self.GetPageCount() == 2:
|
||||
self.SetSelection(0)
|
||||
self.page1.Refresh()
|
||||
self.RemovePage(1)
|
||||
self.modified = False
|
||||
|
||||
def Clear(self):
|
||||
self.SetData(None)
|
||||
self.modified = False
|
||||
|
||||
# If some parameter has changed
|
||||
def IsModified(self):
|
||||
return self.modified
|
||||
|
||||
def SetModified(self, value):
|
||||
# Register undo object when modifying first time
|
||||
if not self.modified and value:
|
||||
g.undoMan.RegisterUndo(UndoEdit())
|
||||
self.modified = value
|
||||
|
||||
def Apply(self):
|
||||
for p in self.pages: p.Apply()
|
||||
|
||||
################################################################################
|
||||
|
||||
# General class for notebook pages
|
||||
class ParamPage(wxPanel):
|
||||
def __init__(self, parent, xxx):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.xxx = xxx
|
||||
# Register event handlers
|
||||
for id in paramIDs.values():
|
||||
EVT_CHECKBOX(self, id, self.OnCheckParams)
|
||||
self.checks = {}
|
||||
self.controls = {} # save python objects
|
||||
self.controlName = None
|
||||
|
||||
def OnCheckParams(self, evt):
|
||||
xxx = self.xxx
|
||||
param = evt.GetEventObject().GetName()
|
||||
w = self.controls[param]
|
||||
w.Enable(True)
|
||||
objElem = xxx.element
|
||||
if evt.IsChecked():
|
||||
# Ad new text node in order of allParams
|
||||
w.SetValue('') # set empty (default) value
|
||||
w.SetModified() # mark as changed
|
||||
elem = g.tree.dom.createElement(param)
|
||||
# Some classes are special
|
||||
if param == 'font':
|
||||
xxx.params[param] = xxxParamFont(xxx.element, elem)
|
||||
elif param in xxxObject.bitmapTags:
|
||||
xxx.params[param] = xxxParamBitmap(elem)
|
||||
else:
|
||||
xxx.params[param] = xxxParam(elem)
|
||||
# Find place to put new element: first present element after param
|
||||
found = False
|
||||
if xxx.hasStyle:
|
||||
paramStyles = xxx.allParams + xxx.styles
|
||||
else:
|
||||
paramStyles = xxx.allParams
|
||||
for p in paramStyles[paramStyles.index(param) + 1:]:
|
||||
# Content params don't have same type
|
||||
if xxx.params.has_key(p) and p != 'content':
|
||||
found = True
|
||||
break
|
||||
if found:
|
||||
nextTextElem = xxx.params[p].node
|
||||
objElem.insertBefore(elem, nextTextElem)
|
||||
else:
|
||||
objElem.appendChild(elem)
|
||||
else:
|
||||
# Remove parameter
|
||||
xxx.params[param].remove()
|
||||
del xxx.params[param]
|
||||
w.SetValue('')
|
||||
w.modified = False # mark as not changed
|
||||
w.Enable(False)
|
||||
# Set modified flag (provokes undo storing is necessary)
|
||||
panel.SetModified(True)
|
||||
def Apply(self):
|
||||
xxx = self.xxx
|
||||
if self.controlName:
|
||||
name = self.controlName.GetValue()
|
||||
if xxx.name != name:
|
||||
xxx.name = name
|
||||
xxx.element.setAttribute('name', name)
|
||||
for param, w in self.controls.items():
|
||||
if w.modified:
|
||||
paramObj = xxx.params[param]
|
||||
value = w.GetValue()
|
||||
if param in xxx.specials:
|
||||
xxx.setSpecial(param, value)
|
||||
else:
|
||||
paramObj.update(value)
|
||||
# Save current state
|
||||
def SaveState(self):
|
||||
self.origChecks = map(lambda i: (i[0], i[1].GetValue()), self.checks.items())
|
||||
self.origControls = map(lambda i: (i[0], i[1].GetValue(), i[1].IsEnabled()),
|
||||
self.controls.items())
|
||||
if self.controlName:
|
||||
self.origName = self.controlName.GetValue()
|
||||
# Return original values
|
||||
def GetState(self):
|
||||
if self.controlName:
|
||||
return (self.origChecks, self.origControls, self.origName)
|
||||
else:
|
||||
return (self.origChecks, self.origControls)
|
||||
# Set values from undo data
|
||||
def SetState(self, state):
|
||||
for k,v in state[0]:
|
||||
self.checks[k].SetValue(v)
|
||||
for k,v,e in state[1]:
|
||||
self.controls[k].SetValue(v)
|
||||
self.controls[k].Enable(e)
|
||||
if e: self.controls[k].modified = True
|
||||
if self.controlName:
|
||||
self.controlName.SetValue(state[2])
|
||||
|
||||
################################################################################
|
||||
|
||||
LABEL_WIDTH = 125
|
||||
|
||||
# Panel for displaying properties
|
||||
class PropPage(ParamPage):
|
||||
def __init__(self, parent, label, xxx):
|
||||
ParamPage.__init__(self, parent, xxx)
|
||||
self.box = wxStaticBox(self, -1, label)
|
||||
self.box.SetFont(g.labelFont())
|
||||
topSizer = wxStaticBoxSizer(self.box, wxVERTICAL)
|
||||
sizer = wxFlexGridSizer(len(xxx.allParams), 2, 1, 1)
|
||||
sizer.AddGrowableCol(1)
|
||||
if xxx.hasName:
|
||||
label = wxStaticText(self, -1, 'XML ID:', size=(LABEL_WIDTH,-1))
|
||||
control = ParamText(self, 'XML_name', 200)
|
||||
sizer.AddMany([ (label, 0, wxALIGN_CENTER_VERTICAL),
|
||||
(control, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM | wxGROW, 5) ])
|
||||
self.controlName = control
|
||||
for param in xxx.allParams:
|
||||
present = xxx.params.has_key(param)
|
||||
if param in xxx.required:
|
||||
label = wxStaticText(self, paramIDs[param], param + ':',
|
||||
size = (LABEL_WIDTH,-1), name = param)
|
||||
else:
|
||||
# Notebook has one very loooooong parameter
|
||||
if param == 'usenotebooksizer': sParam = 'usesizer:'
|
||||
else: sParam = param + ':'
|
||||
label = wxCheckBox(self, paramIDs[param], sParam,
|
||||
size = (LABEL_WIDTH,-1), name = param)
|
||||
self.checks[param] = label
|
||||
try:
|
||||
typeClass = xxx.paramDict[param]
|
||||
except KeyError:
|
||||
try:
|
||||
# Standart type
|
||||
typeClass = paramDict[param]
|
||||
except KeyError:
|
||||
# Default
|
||||
typeClass = ParamText
|
||||
control = typeClass(self, param)
|
||||
control.Enable(present)
|
||||
sizer.AddMany([ (label, 0, wxALIGN_CENTER_VERTICAL),
|
||||
(control, 0, wxALIGN_CENTER_VERTICAL | wxGROW) ])
|
||||
self.controls[param] = control
|
||||
topSizer.Add(sizer, 1, wxALL | wxEXPAND, 3)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(topSizer)
|
||||
topSizer.Fit(self)
|
||||
def SetValues(self, xxx):
|
||||
self.xxx = xxx
|
||||
self.origChecks = []
|
||||
self.origControls = []
|
||||
# Set values, checkboxes to False, disable defaults
|
||||
if xxx.hasName:
|
||||
self.controlName.SetValue(xxx.name)
|
||||
self.origName = xxx.name
|
||||
for param in xxx.allParams:
|
||||
w = self.controls[param]
|
||||
w.modified = False
|
||||
try:
|
||||
value = xxx.params[param].value()
|
||||
w.Enable(True)
|
||||
w.SetValue(value)
|
||||
if not param in xxx.required:
|
||||
self.checks[param].SetValue(True)
|
||||
self.origChecks.append((param, True))
|
||||
self.origControls.append((param, value, True))
|
||||
except KeyError:
|
||||
self.checks[param].SetValue(False)
|
||||
w.SetValue('')
|
||||
w.Enable(False)
|
||||
self.origChecks.append((param, False))
|
||||
self.origControls.append((param, '', False))
|
||||
|
||||
################################################################################
|
||||
|
||||
# Style notebook page
|
||||
class StylePage(ParamPage):
|
||||
def __init__(self, parent, label, xxx):
|
||||
ParamPage.__init__(self, parent, xxx)
|
||||
box = wxStaticBox(self, -1, label)
|
||||
box.SetFont(g.labelFont())
|
||||
topSizer = wxStaticBoxSizer(box, wxVERTICAL)
|
||||
sizer = wxFlexGridSizer(len(xxx.styles), 2, 1, 1)
|
||||
sizer.AddGrowableCol(1)
|
||||
for param in xxx.styles:
|
||||
present = xxx.params.has_key(param)
|
||||
check = wxCheckBox(self, paramIDs[param],
|
||||
param + ':', size = (LABEL_WIDTH,-1), name = param)
|
||||
check.SetValue(present)
|
||||
control = paramDict[param](self, name = param)
|
||||
control.Enable(present)
|
||||
sizer.AddMany([ (check, 0, wxALIGN_CENTER_VERTICAL),
|
||||
(control, 0, wxALIGN_CENTER_VERTICAL | wxGROW) ])
|
||||
self.checks[param] = check
|
||||
self.controls[param] = control
|
||||
topSizer.Add(sizer, 1, wxALL | wxEXPAND, 3)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(topSizer)
|
||||
topSizer.Fit(self)
|
||||
# Set data for a cahced page
|
||||
def SetValues(self, xxx):
|
||||
self.xxx = xxx
|
||||
self.origChecks = []
|
||||
self.origControls = []
|
||||
for param in xxx.styles:
|
||||
present = xxx.params.has_key(param)
|
||||
check = self.checks[param]
|
||||
check.SetValue(present)
|
||||
w = self.controls[param]
|
||||
w.modified = False
|
||||
if present:
|
||||
value = xxx.params[param].value()
|
||||
else:
|
||||
value = ''
|
||||
w.SetValue(value)
|
||||
w.Enable(present)
|
||||
self.origChecks.append((param, present))
|
||||
self.origControls.append((param, value, present))
|
||||
|
@@ -1,879 +0,0 @@
|
||||
# Name: params.py
|
||||
# Purpose: Classes for parameter introduction
|
||||
# Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be>
|
||||
# Created: 22.08.2001
|
||||
# RCS-ID: $Id$
|
||||
|
||||
import string
|
||||
import os.path
|
||||
from globals import *
|
||||
from types import *
|
||||
from wxPython.xrc import *
|
||||
|
||||
genericStyles = [
|
||||
'wxSIMPLE_BORDER', 'wxDOUBLE_BORDER', 'wxSUNKEN_BORDER',
|
||||
'wxRAISED_BORDER', 'wxSTATIC_BORDER', 'wxNO_BORDER',
|
||||
'wxTRANSPARENT_WINDOW', 'wxTAB_TRAVERSAL',
|
||||
'wxWANTS_CHARS',
|
||||
'wxNO_FULL_REPAINT_ON_RESIZE',
|
||||
'wxVSCROLL', 'wxHSCROLL', 'wxALWAYS_SHOW_SB',
|
||||
'wxCLIP_CHILDREN',
|
||||
'wxFULL_REPAINT_ON_RESIZE'
|
||||
]
|
||||
|
||||
genericExStyles = [
|
||||
'wxWS_EX_VALIDATE_RECURSIVELY',
|
||||
'wxWS_EX_BLOCK_EVENTS',
|
||||
'wxWS_EX_TRANSIENT',
|
||||
'wxFRAME_EX_CONTEXTHELP',
|
||||
'wxWS_EX_PROCESS_IDLE',
|
||||
'wxWS_EX_PROCESS_UI_UPDATES'
|
||||
]
|
||||
|
||||
buttonSize = (35,-1) # in dialog units, transformed to pixels in panel ctor
|
||||
|
||||
# Class that can properly disable children
|
||||
class PPanel(wxPanel):
|
||||
def __init__(self, parent, name):
|
||||
wxPanel.__init__(self, parent, -1, name=name)
|
||||
self.modified = self.freeze = False
|
||||
def Enable(self, value):
|
||||
# Something strange is going on with enable so we make sure...
|
||||
for w in self.GetChildren():
|
||||
w.Enable(value)
|
||||
wxPanel.Enable(self, value)
|
||||
def SetModified(self):
|
||||
self.modified = True
|
||||
g.panel.SetModified(True)
|
||||
# Common method to set modified state
|
||||
def OnChange(self, evt):
|
||||
if self.freeze: return
|
||||
self.SetModified()
|
||||
evt.Skip()
|
||||
|
||||
class ParamBinaryOr(PPanel):
|
||||
def __init__(self, parent, name):
|
||||
PPanel.__init__(self, parent, name)
|
||||
self.ID_TEXT_CTRL = wxNewId()
|
||||
self.ID_BUTTON_CHOICES = wxNewId()
|
||||
sizer = wxBoxSizer()
|
||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1))
|
||||
sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5)
|
||||
self.button = wxButton(self, self.ID_BUTTON_CHOICES, 'Edit...', size=buttonSize)
|
||||
sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(sizer)
|
||||
sizer.Fit(self)
|
||||
EVT_BUTTON(self, self.ID_BUTTON_CHOICES, self.OnButtonChoices)
|
||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||
def GetValue(self):
|
||||
return self.text.GetValue()
|
||||
def SetValue(self, value):
|
||||
self.freeze = True
|
||||
self.text.SetValue(value)
|
||||
self.freeze = False
|
||||
def OnButtonChoices(self, evt):
|
||||
dlg = g.frame.res.LoadDialog(self, 'DIALOG_CHOICES')
|
||||
listBox = XRCCTRL(dlg, 'CHECK_LIST')
|
||||
listBox.InsertItems(self.values, 0)
|
||||
value = map(string.strip, self.text.GetValue().split('|'))
|
||||
if value == ['']: value = []
|
||||
ignored = []
|
||||
for i in value:
|
||||
try:
|
||||
listBox.Check(self.values.index(i))
|
||||
except ValueError:
|
||||
# Try to find equal
|
||||
if self.equal.has_key(i):
|
||||
listBox.Check(self.values.index(self.equal[i]))
|
||||
else:
|
||||
print 'WARNING: unknown flag: %s: ignored.' % i
|
||||
ignored.append(i)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
value = []
|
||||
for i in range(listBox.GetCount()):
|
||||
if listBox.IsChecked(i):
|
||||
value.append(self.values[i])
|
||||
# Add ignored flags
|
||||
value.extend(ignored)
|
||||
if value:
|
||||
self.SetValue(reduce(lambda a,b: a+'|'+b, value))
|
||||
else:
|
||||
self.SetValue('')
|
||||
self.SetModified()
|
||||
dlg.Destroy()
|
||||
|
||||
class ParamFlag(ParamBinaryOr):
|
||||
values = ['wxTOP', 'wxBOTTOM', 'wxLEFT', 'wxRIGHT', 'wxALL',
|
||||
'wxEXPAND', 'wxGROW', 'wxSHAPED', 'wxALIGN_CENTRE', 'wxALIGN_RIGHT',
|
||||
'wxFIXED_MINSIZE',
|
||||
'wxALIGN_BOTTOM', 'wxALIGN_CENTRE_VERTICAL',
|
||||
'wxALIGN_CENTRE_HORIZONTAL',
|
||||
]
|
||||
equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE',
|
||||
'wxALIGN_CENTER_VERTICAL': 'wxALIGN_CENTRE_VERTICAL',
|
||||
'wxALIGN_CENTER_HORIZONTAL': 'wxALIGN_CENTRE_HORIZONTAL'}
|
||||
def __init__(self, parent, name):
|
||||
ParamBinaryOr.__init__(self, parent, name)
|
||||
|
||||
class ParamStyle(ParamBinaryOr):
|
||||
equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE'}
|
||||
def __init__(self, parent, name):
|
||||
self.values = g.currentXXX.winStyles + genericStyles
|
||||
ParamBinaryOr.__init__(self, parent, name)
|
||||
|
||||
class ParamNonGenericStyle(ParamBinaryOr):
|
||||
def __init__(self, parent, name):
|
||||
self.values = g.currentXXX.winStyles
|
||||
ParamBinaryOr.__init__(self, parent, name)
|
||||
|
||||
class ParamExStyle(ParamBinaryOr):
|
||||
def __init__(self, parent, name):
|
||||
if g.currentXXX:
|
||||
self.values = g.currentXXX.exStyles + genericExStyles
|
||||
else:
|
||||
self.values = []
|
||||
ParamBinaryOr.__init__(self, parent, name)
|
||||
|
||||
class ParamColour(PPanel):
|
||||
def __init__(self, parent, name):
|
||||
PPanel.__init__(self, parent, name)
|
||||
self.ID_TEXT_CTRL = wxNewId()
|
||||
self.ID_BUTTON = wxNewId()
|
||||
sizer = wxBoxSizer()
|
||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(65,-1))
|
||||
sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5)
|
||||
self.button = wxPanel(self, self.ID_BUTTON, wxDefaultPosition, wxSize(20, 1))
|
||||
sizer.Add(self.button, 0, wxGROW | wxALIGN_CENTER_VERTICAL)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(sizer)
|
||||
sizer.Fit(self)
|
||||
self.textModified = False
|
||||
EVT_PAINT(self.button, self.OnPaintButton)
|
||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||
EVT_LEFT_DOWN(self.button, self.OnLeftDown)
|
||||
def GetValue(self):
|
||||
return self.text.GetValue()
|
||||
def SetValue(self, value):
|
||||
self.freeze = True
|
||||
if not value: value = '#FFFFFF'
|
||||
self.text.SetValue(str(value)) # update text ctrl
|
||||
colour = wxColour(int(value[1:3], 16), int(value[3:5], 16), int(value[5:7], 16))
|
||||
self.button.SetBackgroundColour(colour)
|
||||
self.button.Refresh()
|
||||
self.freeze = False
|
||||
def OnPaintButton(self, evt):
|
||||
dc = wxPaintDC(self.button)
|
||||
dc.SetBrush(wxTRANSPARENT_BRUSH)
|
||||
if self.IsEnabled(): dc.SetPen(wxBLACK_PEN)
|
||||
else: dc.SetPen(wxGREY_PEN)
|
||||
size = self.button.GetSize()
|
||||
dc.DrawRectangle(0, 0, size.width, size.height)
|
||||
def OnLeftDown(self, evt):
|
||||
data = wxColourData()
|
||||
data.SetColour(self.GetValue())
|
||||
dlg = wxColourDialog(self, data)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
self.SetValue('#%02X%02X%02X' % dlg.GetColourData().GetColour().Get())
|
||||
self.SetModified()
|
||||
dlg.Destroy()
|
||||
|
||||
################################################################################
|
||||
|
||||
# Mapping from wx constants ro XML strings
|
||||
fontFamiliesWx2Xml = {wxDEFAULT: 'default', wxDECORATIVE: 'decorative',
|
||||
wxROMAN: 'roman', wxSCRIPT: 'script', wxSWISS: 'swiss',
|
||||
wxMODERN: 'modern'}
|
||||
fontStylesWx2Xml = {wxNORMAL: 'normal', wxSLANT: 'slant', wxITALIC: 'italic'}
|
||||
fontWeightsWx2Xml = {wxNORMAL: 'normal', wxLIGHT: 'light', wxBOLD: 'bold'}
|
||||
def ReverseMap(m):
|
||||
rm = {}
|
||||
for k,v in m.items(): rm[v] = k
|
||||
return rm
|
||||
fontFamiliesXml2wx = ReverseMap(fontFamiliesWx2Xml)
|
||||
fontStylesXml2wx = ReverseMap(fontStylesWx2Xml)
|
||||
fontWeightsXml2wx = ReverseMap(fontWeightsWx2Xml)
|
||||
|
||||
class ParamFont(PPanel):
|
||||
def __init__(self, parent, name):
|
||||
PPanel.__init__(self, parent, name)
|
||||
self.ID_TEXT_CTRL = wxNewId()
|
||||
self.ID_BUTTON_SELECT = wxNewId()
|
||||
sizer = wxBoxSizer()
|
||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(200,-1))
|
||||
sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5)
|
||||
self.button = wxButton(self, self.ID_BUTTON_SELECT, 'Select...', size=buttonSize)
|
||||
sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(sizer)
|
||||
sizer.Fit(self)
|
||||
self.textModified = False
|
||||
EVT_BUTTON(self, self.ID_BUTTON_SELECT, self.OnButtonSelect)
|
||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||
def OnChange(self, evt):
|
||||
PPanel.OnChange(self, evt)
|
||||
self.textModified = True
|
||||
def _defaultValue(self):
|
||||
return ['12', 'default', 'normal', 'normal', '0', '', '']
|
||||
def GetValue(self):
|
||||
if self.textModified: # text has newer value
|
||||
try:
|
||||
return eval(self.text.GetValue())
|
||||
except SyntaxError:
|
||||
wxLogError('Syntax error in parameter value: ' + self.GetName())
|
||||
return self._defaultValue()
|
||||
return self.value
|
||||
def SetValue(self, value):
|
||||
self.freeze = True # disable other handlers
|
||||
if not value: value = self._defaultValue()
|
||||
self.value = value
|
||||
self.text.SetValue(str(value)) # update text ctrl
|
||||
self.freeze = False
|
||||
def OnButtonSelect(self, evt):
|
||||
if self.textModified: # text has newer value
|
||||
try:
|
||||
self.value = eval(self.text.GetValue())
|
||||
except SyntaxError:
|
||||
wxLogError('Syntax error in parameter value: ' + self.GetName())
|
||||
self.value = self._defaultValue()
|
||||
# Make initial font
|
||||
# Default values
|
||||
size = 12
|
||||
family = wxDEFAULT
|
||||
style = weight = wxNORMAL
|
||||
underlined = 0
|
||||
face = ''
|
||||
enc = wxFONTENCODING_DEFAULT
|
||||
# Fall back to default if exceptions
|
||||
error = False
|
||||
try:
|
||||
try: size = int(self.value[0])
|
||||
except ValueError: error = True; wxLogError('Invalid size specification')
|
||||
try: family = fontFamiliesXml2wx[self.value[1]]
|
||||
except KeyError: error = True; wxLogError('Invalid family specification')
|
||||
try: style = fontStylesXml2wx[self.value[2]]
|
||||
except KeyError: error = True; wxLogError('Invalid style specification')
|
||||
try: weight = fontWeightsXml2wx[self.value[3]]
|
||||
except KeyError: error = True; wxLogError('Invalid weight specification')
|
||||
try: underlined = bool(self.value[4])
|
||||
except ValueError: error = True; wxLogError('Invalid underlined flag specification')
|
||||
face = self.value[5]
|
||||
except IndexError:
|
||||
error = True
|
||||
mapper = wxFontMapper()
|
||||
if not self.value[6]: enc = mapper.CharsetToEncoding(self.value[6])
|
||||
|
||||
if error: wxLogError('Invalid font specification')
|
||||
if enc == wxFONTENCODING_DEFAULT: enc = wxFONTENCODING_SYSTEM
|
||||
font = wxFont(size, family, style, weight, underlined, face, enc)
|
||||
data = wxFontData()
|
||||
data.SetInitialFont(font)
|
||||
dlg = wxFontDialog(self, data)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
font = dlg.GetFontData().GetChosenFont()
|
||||
print font.GetEncoding()
|
||||
if font.GetEncoding() == wxFONTENCODING_SYSTEM:
|
||||
encName = ''
|
||||
else:
|
||||
encName = wxFontMapper_GetEncodingName(font.GetEncoding()).encode()
|
||||
value = [str(font.GetPointSize()),
|
||||
fontFamiliesWx2Xml.get(font.GetFamily(), "default"),
|
||||
fontStylesWx2Xml.get(font.GetStyle(), "normal"),
|
||||
fontWeightsWx2Xml.get(font.GetWeight(), "normal"),
|
||||
str(int(font.GetUnderlined())),
|
||||
font.GetFaceName().encode(),
|
||||
encName
|
||||
]
|
||||
# Add ignored flags
|
||||
self.SetValue(value)
|
||||
self.SetModified()
|
||||
self.textModified = False
|
||||
dlg.Destroy()
|
||||
|
||||
################################################################################
|
||||
|
||||
class ParamInt(PPanel):
|
||||
def __init__(self, parent, name):
|
||||
PPanel.__init__(self, parent, name)
|
||||
self.ID_SPIN_CTRL = wxNewId()
|
||||
sizer = wxBoxSizer()
|
||||
self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, size=(50,-1))
|
||||
sizer.Add(self.spin)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(sizer)
|
||||
sizer.Fit(self)
|
||||
EVT_SPINCTRL(self, self.ID_SPIN_CTRL, self.OnChange)
|
||||
def GetValue(self):
|
||||
return str(self.spin.GetValue())
|
||||
def SetValue(self, value):
|
||||
self.freeze = True
|
||||
if not value: value = 0
|
||||
self.spin.SetValue(int(value))
|
||||
self.freeze = False
|
||||
|
||||
# Same as int but allows dialog units (XXXd)
|
||||
class ParamUnit(PPanel):
|
||||
def __init__(self, parent, name):
|
||||
PPanel.__init__(self, parent, name)
|
||||
self.ID_TEXT_CTRL = wxNewId()
|
||||
self.ID_SPIN_BUTTON = wxNewId()
|
||||
sizer = wxBoxSizer()
|
||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(35,-1))
|
||||
self.spin = wxSpinButton(self, self.ID_SPIN_BUTTON, style = wxSP_VERTICAL, size=(-1,1))
|
||||
self.spin.SetRange(-10000, 10000)
|
||||
sizer.Add(self.text, 0, wxEXPAND | wxRIGHT, 2)
|
||||
sizer.Add(self.spin, 0, wxEXPAND)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(sizer)
|
||||
sizer.Fit(self)
|
||||
EVT_SPIN_UP(self, self.ID_SPIN_BUTTON, self.OnSpinUp)
|
||||
EVT_SPIN_DOWN(self, self.ID_SPIN_BUTTON, self.OnSpinDown)
|
||||
def GetValue(self):
|
||||
return self.text.GetValue()
|
||||
def SetValue(self, value):
|
||||
self.freeze = True
|
||||
if not value: value = '0'
|
||||
self.text.SetValue(value)
|
||||
self.freeze = False
|
||||
def Change(self, x):
|
||||
# Check if we are working with dialog units
|
||||
value = self.text.GetValue()
|
||||
units = ''
|
||||
if value[-1].upper() == 'D':
|
||||
units = value[-1]
|
||||
value = value[:-1]
|
||||
try:
|
||||
intValue = int(value) + x
|
||||
self.spin.SetValue(intValue)
|
||||
self.text.SetValue(str(intValue) + units)
|
||||
self.SetModified()
|
||||
except:
|
||||
# !!! Strange, if I use wxLogWarning, event is re-generated
|
||||
print 'incorrect unit format'
|
||||
def OnSpinUp(self, evt):
|
||||
self.Change(1)
|
||||
def OnSpinDown(self, evt):
|
||||
self.Change(-1)
|
||||
|
||||
class ParamMultilineText(PPanel):
|
||||
def __init__(self, parent, name, textWidth=-1):
|
||||
PPanel.__init__(self, parent, name)
|
||||
self.ID_TEXT_CTRL = wxNewId()
|
||||
self.ID_BUTTON_EDIT = wxNewId()
|
||||
sizer = wxBoxSizer()
|
||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1))
|
||||
sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5)
|
||||
self.button = wxButton(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize)
|
||||
sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(sizer)
|
||||
sizer.Fit(self)
|
||||
EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit)
|
||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||
def GetValue(self):
|
||||
return self.text.GetValue()
|
||||
def SetValue(self, value):
|
||||
self.freeze = True # disable other handlers
|
||||
self.text.SetValue(value)
|
||||
self.freeze = False # disable other handlers
|
||||
def OnButtonEdit(self, evt):
|
||||
dlg = g.frame.res.LoadDialog(self, 'DIALOG_TEXT')
|
||||
textCtrl = XRCCTRL(dlg, 'TEXT')
|
||||
textCtrl.SetValue(self.text.GetValue())
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
self.text.SetValue(textCtrl.GetValue())
|
||||
self.SetModified()
|
||||
dlg.Destroy()
|
||||
|
||||
class ParamText(PPanel):
|
||||
def __init__(self, parent, name, textWidth=-1):
|
||||
PPanel.__init__(self, parent, name)
|
||||
self.ID_TEXT_CTRL = wxNewId()
|
||||
# We use sizer even here to have the same size of text control
|
||||
sizer = wxBoxSizer()
|
||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(textWidth,-1))
|
||||
if textWidth == -1: option = 1
|
||||
else: option = 0
|
||||
sizer.Add(self.text, option, wxALIGN_CENTER_VERTICAL)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(sizer)
|
||||
sizer.Fit(self)
|
||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||
def GetValue(self):
|
||||
return self.text.GetValue()
|
||||
def SetValue(self, value):
|
||||
self.freeze = True # disable other handlers
|
||||
self.text.SetValue(value)
|
||||
self.freeze = False # disable other handlers
|
||||
|
||||
class ParamAccel(ParamText):
|
||||
def __init__(self, parent, name):
|
||||
ParamText.__init__(self, parent, name, 100)
|
||||
|
||||
class ParamPosSize(ParamText):
|
||||
def __init__(self, parent, name):
|
||||
ParamText.__init__(self, parent, name, 80)
|
||||
|
||||
class ParamLabel(ParamText):
|
||||
def __init__(self, parent, name):
|
||||
ParamText.__init__(self, parent, name, 200)
|
||||
|
||||
class ParamEncoding(ParamText):
|
||||
def __init__(self, parent, name):
|
||||
ParamText.__init__(self, parent, name, 100)
|
||||
|
||||
class ContentDialog(wxDialog):
|
||||
def __init__(self, parent, value):
|
||||
# Load from resource
|
||||
pre = wxPreDialog()
|
||||
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT')
|
||||
self.this = pre.this
|
||||
self._setOORInfo(self)
|
||||
self.list = XRCCTRL(self, 'LIST')
|
||||
# Set list items
|
||||
for v in value:
|
||||
self.list.Append(v)
|
||||
self.SetAutoLayout(True)
|
||||
self.GetSizer().Fit(self)
|
||||
# Callbacks
|
||||
self.ID_BUTTON_APPEND = XRCID('BUTTON_APPEND')
|
||||
self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE')
|
||||
self.ID_BUTTON_UP = XRCID('BUTTON_UP')
|
||||
self.ID_BUTTON_DOWN = XRCID('BUTTON_DOWN')
|
||||
EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp)
|
||||
EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown)
|
||||
EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend)
|
||||
EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove)
|
||||
EVT_UPDATE_UI(self, self.ID_BUTTON_UP, self.OnUpdateUI)
|
||||
EVT_UPDATE_UI(self, self.ID_BUTTON_DOWN, self.OnUpdateUI)
|
||||
EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI)
|
||||
def OnButtonUp(self, evt):
|
||||
i = self.list.GetSelection()
|
||||
str = self.list.GetString(i)
|
||||
self.list.Delete(i)
|
||||
self.list.InsertItems([str], i-1)
|
||||
self.list.SetSelection(i-1)
|
||||
def OnButtonDown(self, evt):
|
||||
i = self.list.GetSelection()
|
||||
str = self.list.GetString(i)
|
||||
self.list.Delete(i)
|
||||
self.list.InsertItems([str], i+1)
|
||||
self.list.SetSelection(i+1)
|
||||
def OnButtonAppend(self, evt):
|
||||
str = wxGetTextFromUser('Enter new item:', 'Append', '', self)
|
||||
self.list.Append(str)
|
||||
def OnButtonRemove(self, evt):
|
||||
self.list.Delete(self.list.GetSelection())
|
||||
def OnUpdateUI(self, evt):
|
||||
if evt.GetId() == self.ID_BUTTON_REMOVE:
|
||||
evt.Enable(self.list.GetSelection() != -1)
|
||||
elif evt.GetId() == self.ID_BUTTON_UP:
|
||||
evt.Enable(self.list.GetSelection() > 0)
|
||||
elif evt.GetId() == self.ID_BUTTON_DOWN:
|
||||
evt.Enable(self.list.GetSelection() != -1 and \
|
||||
self.list.GetSelection() < self.list.GetCount() - 1)
|
||||
|
||||
class ContentCheckListDialog(wxDialog):
|
||||
def __init__(self, parent, value):
|
||||
pre = wxPreDialog()
|
||||
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT_CHECK_LIST')
|
||||
self.this = pre.this
|
||||
self._setOORInfo(self)
|
||||
self.list = XRCCTRL(self, 'CHECK_LIST')
|
||||
# Set list items
|
||||
i = 0
|
||||
for v,ch in value:
|
||||
self.list.Append(v)
|
||||
self.list.Check(i, ch)
|
||||
i += 1
|
||||
self.SetAutoLayout(True)
|
||||
self.GetSizer().Fit(self)
|
||||
# Callbacks
|
||||
self.ID_BUTTON_APPEND = XRCID('BUTTON_APPEND')
|
||||
self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE')
|
||||
self.ID_BUTTON_UP = XRCID('BUTTON_UP')
|
||||
self.ID_BUTTON_DOWN = XRCID('BUTTON_DOWN')
|
||||
EVT_CHECKLISTBOX(self, self.list.GetId(), self.OnCheck)
|
||||
EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp)
|
||||
EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown)
|
||||
EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend)
|
||||
EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove)
|
||||
EVT_UPDATE_UI(self, self.ID_BUTTON_UP, self.OnUpdateUI)
|
||||
EVT_UPDATE_UI(self, self.ID_BUTTON_DOWN, self.OnUpdateUI)
|
||||
EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI)
|
||||
def OnCheck(self, evt):
|
||||
# !!! Wrong wxGTK (wxMSW?) behavior: toggling selection if checking
|
||||
self.list.Deselect(evt.GetSelection())
|
||||
def OnButtonUp(self, evt):
|
||||
i = self.list.GetSelection()
|
||||
str, ch = self.list.GetString(i), self.list.IsChecked(i)
|
||||
self.list.Delete(i)
|
||||
self.list.InsertItems([str], i-1)
|
||||
self.list.Check(i-1, ch)
|
||||
self.list.SetSelection(i-1)
|
||||
def OnButtonDown(self, evt):
|
||||
i = self.list.GetSelection()
|
||||
str, ch = self.list.GetString(i), self.list.IsChecked(i)
|
||||
self.list.Delete(i)
|
||||
self.list.InsertItems([str], i+1)
|
||||
self.list.Check(i+1, ch)
|
||||
self.list.SetSelection(i+1)
|
||||
def OnButtonAppend(self, evt):
|
||||
str = wxGetTextFromUser('Enter new item:', 'Append', '', self)
|
||||
self.list.Append(str)
|
||||
def OnButtonRemove(self, evt):
|
||||
self.list.Delete(self.list.GetSelection())
|
||||
def OnUpdateUI(self, evt):
|
||||
if evt.GetId() == self.ID_BUTTON_REMOVE:
|
||||
evt.Enable(self.list.GetSelection() != -1)
|
||||
elif evt.GetId() == self.ID_BUTTON_UP:
|
||||
evt.Enable(self.list.GetSelection() > 0)
|
||||
elif evt.GetId() == self.ID_BUTTON_DOWN:
|
||||
evt.Enable(self.list.GetSelection() != -1 and \
|
||||
self.list.GetSelection() < self.list.GetCount() - 1)
|
||||
|
||||
class ParamContent(PPanel):
|
||||
def __init__(self, parent, name):
|
||||
PPanel.__init__(self, parent, name)
|
||||
self.ID_TEXT_CTRL = wxNewId()
|
||||
self.ID_BUTTON_EDIT = wxNewId()
|
||||
sizer = wxBoxSizer()
|
||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1))
|
||||
sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5)
|
||||
self.button = wxButton(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize)
|
||||
sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(sizer)
|
||||
sizer.Fit(self)
|
||||
self.textModified = False
|
||||
EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit)
|
||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||
def OnChange(self, evt):
|
||||
PPanel.OnChange(self, evt)
|
||||
self.textModified = True
|
||||
def GetValue(self):
|
||||
if self.textModified: # text has newer value
|
||||
try:
|
||||
return eval(self.text.GetValue())
|
||||
except SyntaxError:
|
||||
wxLogError('Syntax error in parameter value: ' + self.GetName())
|
||||
return []
|
||||
return self.value
|
||||
def SetValue(self, value):
|
||||
self.freeze = True
|
||||
if not value: value = []
|
||||
self.value = value
|
||||
self.text.SetValue(str(value)) # update text ctrl
|
||||
self.freeze = False
|
||||
def OnButtonEdit(self, evt):
|
||||
if self.textModified: # text has newer value
|
||||
try:
|
||||
self.value = eval(self.text.GetValue())
|
||||
except SyntaxError:
|
||||
wxLogError('Syntax error in parameter value: ' + self.GetName())
|
||||
self.value = []
|
||||
dlg = ContentDialog(self, self.value)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
value = []
|
||||
for i in range(dlg.list.GetCount()):
|
||||
value.append(dlg.list.GetString(i))
|
||||
# Add ignored flags
|
||||
self.SetValue(value)
|
||||
self.SetModified()
|
||||
self.textModified = False
|
||||
dlg.Destroy()
|
||||
|
||||
# CheckList content
|
||||
class ParamContentCheckList(ParamContent):
|
||||
def __init__(self, parent, name):
|
||||
ParamContent.__init__(self, parent, name)
|
||||
def OnButtonEdit(self, evt):
|
||||
if self.textModified: # text has newer value
|
||||
try:
|
||||
self.value = eval(self.text.GetValue())
|
||||
except SyntaxError:
|
||||
wxLogError('Syntax error in parameter value: ' + self.GetName())
|
||||
self.value = []
|
||||
dlg = ContentCheckListDialog(self, self.value)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
value = []
|
||||
for i in range(dlg.list.GetCount()):
|
||||
value.append((dlg.list.GetString(i), dlg.list.IsChecked(i)))
|
||||
# Add ignored flags
|
||||
self.SetValue(value)
|
||||
self.SetModified()
|
||||
self.textModified = False
|
||||
dlg.Destroy()
|
||||
|
||||
class IntListDialog(wxDialog):
|
||||
def __init__(self, parent, value):
|
||||
pre = wxPreDialog()
|
||||
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_INTLIST')
|
||||
self.this = pre.this
|
||||
self._setOORInfo(self)
|
||||
self.list = XRCCTRL(self, 'LIST')
|
||||
# Set list items
|
||||
value.sort()
|
||||
for v in value:
|
||||
if type(v) != IntType:
|
||||
wxLogError('Invalid item type')
|
||||
else:
|
||||
self.list.Append(str(v))
|
||||
self.SetAutoLayout(True)
|
||||
self.GetSizer().Fit(self)
|
||||
# Callbacks
|
||||
self.ID_BUTTON_ADD = XRCID('BUTTON_ADD')
|
||||
self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE')
|
||||
EVT_BUTTON(self, self.ID_BUTTON_ADD, self.OnButtonAppend)
|
||||
EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove)
|
||||
EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI)
|
||||
def OnButtonAppend(self, evt):
|
||||
s = wxGetTextFromUser('Enter new number:', 'Add', '', self)
|
||||
if not s: return
|
||||
# Check that it's unique
|
||||
try:
|
||||
v = int(s)
|
||||
s = str(v) # to be sure
|
||||
i = self.list.FindString(s)
|
||||
if i == -1: # ignore non-unique
|
||||
# Find place to insert
|
||||
found = False
|
||||
for i in range(self.list.GetCount()):
|
||||
if int(self.list.GetString(i)) > v:
|
||||
found = True
|
||||
break
|
||||
if found: self.list.InsertItems([s], i)
|
||||
else: self.list.Append(s)
|
||||
except ValueError:
|
||||
wxLogError('List item is not an int!')
|
||||
def OnButtonRemove(self, evt):
|
||||
self.list.Delete(self.list.GetSelection())
|
||||
def OnUpdateUI(self, evt):
|
||||
if evt.GetId() == self.ID_BUTTON_REMOVE:
|
||||
evt.Enable(self.list.GetSelection() != -1)
|
||||
|
||||
# For growable list
|
||||
class ParamIntList(ParamContent):
|
||||
def __init__(self, parent, name):
|
||||
ParamContent.__init__(self, parent, name)
|
||||
def OnButtonEdit(self, evt):
|
||||
if self.textModified: # text has newer value
|
||||
try:
|
||||
self.value = eval(self.text.GetValue())
|
||||
except SyntaxError:
|
||||
wxLogError('Syntax error in parameter value: ' + self.GetName())
|
||||
self.value = []
|
||||
dlg = IntListDialog(self, self.value)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
value = []
|
||||
for i in range(dlg.list.GetCount()):
|
||||
value.append(int(dlg.list.GetString(i)))
|
||||
# Add ignored flags
|
||||
self.SetValue(value)
|
||||
self.SetModified()
|
||||
self.textModified = False
|
||||
dlg.Destroy()
|
||||
|
||||
# Boxless radiobox
|
||||
class RadioBox(PPanel):
|
||||
def __init__(self, parent, id, choices,
|
||||
pos=wxDefaultPosition, name='radiobox'):
|
||||
PPanel.__init__(self, parent, name)
|
||||
self.choices = choices
|
||||
topSizer = wxBoxSizer()
|
||||
for i in choices:
|
||||
button = wxRadioButton(self, -1, i, size=(-1,buttonSize[1]), name=i)
|
||||
topSizer.Add(button, 0, wxRIGHT, 5)
|
||||
EVT_RADIOBUTTON(self, button.GetId(), self.OnRadioChoice)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(topSizer)
|
||||
topSizer.Fit(self)
|
||||
def SetStringSelection(self, value):
|
||||
self.freeze = True
|
||||
for i in self.choices:
|
||||
self.FindWindowByName(i).SetValue(i == value)
|
||||
self.value = value
|
||||
self.freeze = False
|
||||
def OnRadioChoice(self, evt):
|
||||
if self.freeze: return
|
||||
if evt.GetSelection():
|
||||
self.value = evt.GetEventObject().GetName()
|
||||
self.SetModified()
|
||||
def GetStringSelection(self):
|
||||
return self.value
|
||||
|
||||
class ParamBool(RadioBox):
|
||||
values = {'yes': '1', 'no': '0'}
|
||||
seulav = {'1': 'yes', '0': 'no'}
|
||||
def __init__(self, parent, name):
|
||||
RadioBox.__init__(self, parent, -1, choices=self.values.keys(), name=name)
|
||||
def GetValue(self):
|
||||
return self.values[self.GetStringSelection()]
|
||||
def SetValue(self, value):
|
||||
if not value: value = '1'
|
||||
self.SetStringSelection(self.seulav[value])
|
||||
|
||||
class ParamOrient(RadioBox):
|
||||
values = {'horizontal': 'wxHORIZONTAL', 'vertical': 'wxVERTICAL'}
|
||||
seulav = {'wxHORIZONTAL': 'horizontal', 'wxVERTICAL': 'vertical'}
|
||||
def __init__(self, parent, name):
|
||||
RadioBox.__init__(self, parent, -1, choices=self.values.keys(), name=name)
|
||||
def GetValue(self):
|
||||
return self.values[self.GetStringSelection()]
|
||||
def SetValue(self, value):
|
||||
if not value: value = 'wxHORIZONTAL'
|
||||
self.SetStringSelection(self.seulav[value])
|
||||
|
||||
class ParamOrientation(RadioBox):
|
||||
values = {'horizontal': 'horizontal', 'vertical': 'vertical'}
|
||||
seulav = {'horizontal': 'horizontal', 'vertical': 'vertical'}
|
||||
def __init__(self, parent, name):
|
||||
RadioBox.__init__(self, parent, -1, choices=self.values.keys(), name=name)
|
||||
def GetValue(self):
|
||||
return self.values[self.GetStringSelection()]
|
||||
def SetValue(self, value):
|
||||
if not value: value = 'vertical'
|
||||
self.SetStringSelection(self.seulav[value])
|
||||
|
||||
class ParamFile(PPanel):
|
||||
def __init__(self, parent, name):
|
||||
PPanel.__init__(self, parent, name)
|
||||
self.ID_TEXT_CTRL = wxNewId()
|
||||
self.ID_BUTTON_BROWSE = wxNewId()
|
||||
sizer = wxBoxSizer()
|
||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1))
|
||||
sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5)
|
||||
self.button = wxButton(self, self.ID_BUTTON_BROWSE, 'Browse...',size=buttonSize)
|
||||
sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(sizer)
|
||||
sizer.Fit(self)
|
||||
self.textModified = False
|
||||
EVT_BUTTON(self, self.ID_BUTTON_BROWSE, self.OnButtonBrowse)
|
||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||
def OnChange(self, evt):
|
||||
PPanel.OnChange(self, evt)
|
||||
self.textModified = True
|
||||
def GetValue(self):
|
||||
if self.textModified: # text has newer value
|
||||
return self.text.GetValue()
|
||||
return self.value
|
||||
def SetValue(self, value):
|
||||
self.freeze = True
|
||||
self.value = value
|
||||
self.text.SetValue(value) # update text ctrl
|
||||
self.freeze = False
|
||||
def OnButtonBrowse(self, evt):
|
||||
if self.textModified: # text has newer value
|
||||
self.value = self.text.GetValue()
|
||||
dlg = wxFileDialog(self,
|
||||
defaultDir = os.path.abspath(os.path.dirname(self.value)),
|
||||
defaultFile = os.path.basename(self.value))
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
# Get common part of selected path and current
|
||||
if g.frame.dataFile:
|
||||
curpath = os.path.abspath(g.frame.dataFile)
|
||||
else:
|
||||
curpath = os.path.join(os.getcwd(), '')
|
||||
common = os.path.commonprefix([curpath, dlg.GetPath()])
|
||||
self.SetValue(dlg.GetPath()[len(common):])
|
||||
self.SetModified()
|
||||
self.textModified = False
|
||||
dlg.Destroy()
|
||||
|
||||
class ParamBitmap(PPanel):
|
||||
def __init__(self, parent, name):
|
||||
pre = wxPrePanel()
|
||||
g.frame.res.LoadOnPanel(pre, parent, 'PANEL_BITMAP')
|
||||
self.this = pre.this
|
||||
self._setOORInfo(self)
|
||||
self.modified = self.freeze = False
|
||||
self.radio_std = XRCCTRL(self, 'RADIO_STD')
|
||||
self.radio_file = XRCCTRL(self, 'RADIO_FILE')
|
||||
self.combo = XRCCTRL(self, 'COMBO_STD')
|
||||
self.text = XRCCTRL(self, 'TEXT_FILE')
|
||||
self.button = XRCCTRL(self, 'BUTTON_BROWSE')
|
||||
self.textModified = False
|
||||
self.SetAutoLayout(True)
|
||||
self.GetSizer().SetMinSize((260, -1))
|
||||
self.GetSizer().Fit(self)
|
||||
EVT_RADIOBUTTON(self, XRCID('RADIO_STD'), self.OnRadioStd)
|
||||
EVT_RADIOBUTTON(self, XRCID('RADIO_FILE'), self.OnRadioFile)
|
||||
EVT_BUTTON(self, XRCID('BUTTON_BROWSE'), self.OnButtonBrowse)
|
||||
EVT_COMBOBOX(self, XRCID('COMBO_STD'), self.OnCombo)
|
||||
EVT_TEXT(self, XRCID('COMBO_STD'), self.OnChange)
|
||||
EVT_TEXT(self, XRCID('TEXT_FILE'), self.OnChange)
|
||||
def OnRadioStd(self, evt):
|
||||
self.SetModified()
|
||||
self.SetValue(['wxART_MISSING_IMAGE',''])
|
||||
def OnRadioFile(self, evt):
|
||||
self.SetModified()
|
||||
self.SetValue(['',''])
|
||||
def updateRadios(self):
|
||||
if self.value[0]:
|
||||
self.radio_std.SetValue(True)
|
||||
self.radio_file.SetValue(False)
|
||||
self.text.Enable(False)
|
||||
self.button.Enable(False)
|
||||
self.combo.Enable(True)
|
||||
else:
|
||||
self.radio_std.SetValue(False)
|
||||
self.radio_file.SetValue(True)
|
||||
self.text.Enable(True)
|
||||
self.button.Enable(True)
|
||||
self.combo.Enable(False)
|
||||
def OnChange(self, evt):
|
||||
PPanel.OnChange(self, evt)
|
||||
self.textModified = True
|
||||
def OnCombo(self, evt):
|
||||
PPanel.OnChange(self, evt)
|
||||
self.value[0] = self.combo.GetValue()
|
||||
def GetValue(self):
|
||||
if self.textModified: # text has newer value
|
||||
return [self.combo.GetValue(), self.text.GetValue()]
|
||||
return self.value
|
||||
def SetValue(self, value):
|
||||
self.freeze = True
|
||||
if not value:
|
||||
self.value = ['', '']
|
||||
else:
|
||||
self.value = value
|
||||
self.combo.SetValue(self.value[0])
|
||||
self.text.SetValue(self.value[1]) # update text ctrl
|
||||
self.updateRadios()
|
||||
self.freeze = False
|
||||
def OnButtonBrowse(self, evt):
|
||||
if self.textModified: # text has newer value
|
||||
self.value[1] = self.text.GetValue()
|
||||
dlg = wxFileDialog(self,
|
||||
defaultDir = os.path.abspath(os.path.dirname(self.value[1])),
|
||||
defaultFile = os.path.basename(self.value[1]))
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
# Get common part of selected path and current
|
||||
if g.frame.dataFile:
|
||||
curpath = os.path.abspath(g.frame.dataFile)
|
||||
else:
|
||||
curpath = os.path.join(os.getcwd(), '')
|
||||
common = os.path.commonprefix([curpath, dlg.GetPath()])
|
||||
self.SetValue(['', dlg.GetPath()[len(common):]])
|
||||
self.SetModified()
|
||||
self.textModified = False
|
||||
dlg.Destroy()
|
||||
|
||||
paramDict = {
|
||||
'flag': ParamFlag,
|
||||
'style': ParamStyle, 'exstyle': ParamExStyle,
|
||||
'pos': ParamPosSize, 'size': ParamPosSize,
|
||||
'cellpos': ParamPosSize, 'cellspan': ParamPosSize,
|
||||
'border': ParamUnit, 'cols': ParamInt, 'rows': ParamInt,
|
||||
'vgap': ParamUnit, 'hgap': ParamUnit,
|
||||
'checkable': ParamBool, 'checked': ParamBool, 'radio': ParamBool,
|
||||
'accel': ParamAccel,
|
||||
'label': ParamMultilineText, 'title': ParamText, 'value': ParamText,
|
||||
'content': ParamContent, 'selection': ParamInt,
|
||||
'min': ParamInt, 'max': ParamInt,
|
||||
'fg': ParamColour, 'bg': ParamColour, 'font': ParamFont,
|
||||
'enabled': ParamBool, 'focused': ParamBool, 'hidden': ParamBool,
|
||||
'tooltip': ParamText, 'bitmap': ParamBitmap, 'icon': ParamBitmap,
|
||||
'encoding': ParamEncoding
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
(require 'sawmill-defaults)
|
||||
|
||||
;;; Define two hooks to reset focus behavior while mapping test window
|
||||
|
||||
(define (xrced-match-window-before w)
|
||||
(setq prop (aref (get-x-text-property w 'WM_CLASS) 0))
|
||||
(cond ((equal prop "_XRCED_T_W")
|
||||
(setq transients-get-focus-b transients-get-focus)
|
||||
(setq transients-get-focus nil)
|
||||
(setq focus-windows-when-mapped-b focus-windows-when-mapped)
|
||||
(setq focus-windows-when-mapped nil)
|
||||
)
|
||||
)
|
||||
)
|
||||
(define (xrced-match-window-after w)
|
||||
(setq prop (aref (get-x-text-property w 'WM_CLASS) 0))
|
||||
(cond ((equal prop "_XRCED_T_W")
|
||||
(setq transients-get-focus-b transients-get-focus-b)
|
||||
(setq focus-windows-when-mapped focus-windows-when-mapped-b)
|
||||
)
|
||||
)
|
||||
)
|
||||
(add-hook 'map-notify-hook xrced-match-window-before)
|
||||
(add-hook 'map-notify-hook xrced-match-window-after 't)
|
Before Width: | Height: | Size: 316 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 513 B |
Before Width: | Height: | Size: 502 B |
Before Width: | Height: | Size: 275 B |
Before Width: | Height: | Size: 350 B |
Before Width: | Height: | Size: 616 B |
Before Width: | Height: | Size: 141 B |
Before Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 233 B |
Before Width: | Height: | Size: 193 B |
Before Width: | Height: | Size: 233 B |
Before Width: | Height: | Size: 154 B |
Before Width: | Height: | Size: 146 B |
Before Width: | Height: | Size: 139 B |
Before Width: | Height: | Size: 131 B |
Before Width: | Height: | Size: 141 B |
Before Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 133 B |
Before Width: | Height: | Size: 184 B |
Before Width: | Height: | Size: 167 B |
Before Width: | Height: | Size: 166 B |
Before Width: | Height: | Size: 171 B |
Before Width: | Height: | Size: 135 B |
Before Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 140 B |
Before Width: | Height: | Size: 296 B |
Before Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 170 B |
Before Width: | Height: | Size: 254 B |
Before Width: | Height: | Size: 80 B |
Before Width: | Height: | Size: 185 B |
Before Width: | Height: | Size: 249 B |
Before Width: | Height: | Size: 161 B |
Before Width: | Height: | Size: 308 B |
Before Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 576 B |
Before Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 173 B |
Before Width: | Height: | Size: 82 B |
Before Width: | Height: | Size: 166 B |
Before Width: | Height: | Size: 129 B |
Before Width: | Height: | Size: 119 B |
Before Width: | Height: | Size: 165 B |
Before Width: | Height: | Size: 154 B |
Before Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 154 B |
Before Width: | Height: | Size: 146 B |
Before Width: | Height: | Size: 131 B |
Before Width: | Height: | Size: 166 B |
Before Width: | Height: | Size: 171 B |
Before Width: | Height: | Size: 139 B |
Before Width: | Height: | Size: 140 B |
Before Width: | Height: | Size: 170 B |
Before Width: | Height: | Size: 103 B |
Before Width: | Height: | Size: 139 B |
Before Width: | Height: | Size: 133 B |
Before Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 141 B |
Before Width: | Height: | Size: 136 B |
Before Width: | Height: | Size: 173 B |
Before Width: | Height: | Size: 177 B |
Before Width: | Height: | Size: 141 B |
Before Width: | Height: | Size: 185 B |
@@ -1,285 +0,0 @@
|
||||
# Name: tools.py
|
||||
# Purpose: XRC editor, toolbar
|
||||
# Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be>
|
||||
# Created: 19.03.2003
|
||||
# RCS-ID: $Id$
|
||||
|
||||
from xxx import * # xxx imports globals and params
|
||||
from tree import ID_NEW
|
||||
|
||||
# Icons
|
||||
import images
|
||||
|
||||
# Groups of controls
|
||||
GROUPNUM = 4
|
||||
GROUP_WINDOWS, GROUP_MENUS, GROUP_SIZERS, GROUP_CONTROLS = range(GROUPNUM)
|
||||
|
||||
# States depending on current selection and Control/Shift keys
|
||||
STATE_ROOT, STATE_MENUBAR, STATE_TOOLBAR, STATE_MENU, STATE_ELSE = range(5)
|
||||
|
||||
# Left toolbar for GUI elements
|
||||
class Tools(wxPanel):
|
||||
TOOL_SIZE = (30, 30)
|
||||
def __init__(self, parent):
|
||||
if wxPlatform == '__WXGTK__':
|
||||
wxPanel.__init__(self, parent, -1,
|
||||
style=wxRAISED_BORDER|wxWANTS_CHARS)
|
||||
else:
|
||||
wxPanel.__init__(self, parent, -1, style=wxWANTS_CHARS)
|
||||
# Create sizer for groups
|
||||
self.sizer = wxBoxSizer(wxVERTICAL)
|
||||
# Data to create buttons
|
||||
pullDownMenu = g.pullDownMenu
|
||||
self.groups = []
|
||||
self.ctrl = self.shift = False
|
||||
# Current state (what to enable/disable)
|
||||
self.state = None
|
||||
groups = [
|
||||
["Windows",
|
||||
(ID_NEW.FRAME, images.getToolFrameBitmap()),
|
||||
(ID_NEW.DIALOG, images.getToolDialogBitmap()),
|
||||
(ID_NEW.PANEL, images.getToolPanelBitmap())],
|
||||
["Menus",
|
||||
(ID_NEW.TOOL_BAR, images.getToolToolBarBitmap()),
|
||||
(ID_NEW.MENU_BAR, images.getToolMenuBarBitmap()),
|
||||
(ID_NEW.MENU, images.getToolMenuBitmap()),
|
||||
(ID_NEW.TOOL, images.getToolToolBitmap()),
|
||||
(ID_NEW.MENU_ITEM, images.getToolMenuItemBitmap()),
|
||||
(ID_NEW.SEPARATOR, images.getToolSeparatorBitmap())],
|
||||
["Sizers",
|
||||
(ID_NEW.BOX_SIZER, images.getToolBoxSizerBitmap()),
|
||||
(ID_NEW.STATIC_BOX_SIZER, images.getToolStaticBoxSizerBitmap()),
|
||||
(ID_NEW.GRID_SIZER, images.getToolGridSizerBitmap()),
|
||||
(ID_NEW.FLEX_GRID_SIZER, images.getToolFlexGridSizerBitmap()),
|
||||
(ID_NEW.GRID_BAG_SIZER, images.getToolGridBagSizerBitmap()),
|
||||
(ID_NEW.SPACER, images.getToolSpacerBitmap())],
|
||||
["Controls",
|
||||
(ID_NEW.STATIC_TEXT, images.getToolStaticTextBitmap()),
|
||||
(ID_NEW.STATIC_BITMAP, images.getToolStaticBitmapBitmap()),
|
||||
(ID_NEW.STATIC_LINE, images.getToolStaticLineBitmap()),
|
||||
|
||||
(ID_NEW.BUTTON, images.getToolButtonBitmap()),
|
||||
(ID_NEW.BITMAP_BUTTON, images.getToolBitmapButtonBitmap()),
|
||||
(ID_NEW.STATIC_BOX, images.getToolStaticBoxBitmap()),
|
||||
|
||||
(ID_NEW.TEXT_CTRL, images.getToolTextCtrlBitmap()),
|
||||
(ID_NEW.COMBO_BOX, images.getToolComboBoxBitmap()),
|
||||
(ID_NEW.CHOICE, images.getToolChoiceBitmap()),
|
||||
|
||||
(ID_NEW.RADIO_BUTTON, images.getToolRadioButtonBitmap()),
|
||||
(ID_NEW.CHECK_BOX, images.getToolCheckBoxBitmap()),
|
||||
(ID_NEW.RADIO_BOX, images.getToolRadioBoxBitmap()),
|
||||
|
||||
(ID_NEW.SPIN_CTRL, images.getToolSpinCtrlBitmap()),
|
||||
(ID_NEW.SPIN_BUTTON, images.getToolSpinButtonBitmap()),
|
||||
(ID_NEW.SCROLL_BAR, images.getToolScrollBarBitmap()),
|
||||
|
||||
(ID_NEW.SLIDER, images.getToolSliderBitmap()),
|
||||
(ID_NEW.GAUGE, images.getToolGaugeBitmap()),
|
||||
(ID_NEW.TREE_CTRL, images.getToolTreeCtrlBitmap()),
|
||||
|
||||
(ID_NEW.LIST_BOX, images.getToolListBoxBitmap()),
|
||||
(ID_NEW.CHECK_LIST, images.getToolCheckListBitmap()),
|
||||
(ID_NEW.LIST_CTRL, images.getToolListCtrlBitmap()),
|
||||
|
||||
(ID_NEW.NOTEBOOK, images.getToolNotebookBitmap()),
|
||||
(ID_NEW.SPLITTER_WINDOW, images.getToolSplitterWindowBitmap()),
|
||||
|
||||
(ID_NEW.UNKNOWN, images.getToolUnknownBitmap())]
|
||||
]
|
||||
for grp in groups:
|
||||
self.AddGroup(grp[0])
|
||||
for b in grp[1:]:
|
||||
self.AddButton(b[0], b[1], g.pullDownMenu.createMap[b[0]])
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizerAndFit(self.sizer)
|
||||
# Allow to be resized in vertical direction only
|
||||
self.SetSizeHints(self.GetSize()[0], -1)
|
||||
# Events
|
||||
EVT_COMMAND_RANGE(self, ID_NEW.PANEL, ID_NEW.LAST,
|
||||
wxEVT_COMMAND_BUTTON_CLICKED, g.frame.OnCreate)
|
||||
EVT_KEY_DOWN(self, self.OnKeyDown)
|
||||
EVT_KEY_UP(self, self.OnKeyUp)
|
||||
|
||||
def AddButton(self, id, image, text):
|
||||
from wxPython.lib import buttons
|
||||
button = buttons.wxGenBitmapButton(self, id, image, size=self.TOOL_SIZE,
|
||||
style=wxNO_BORDER|wxWANTS_CHARS)
|
||||
button.SetBezelWidth(0)
|
||||
EVT_KEY_DOWN(button, self.OnKeyDown)
|
||||
EVT_KEY_UP(button, self.OnKeyUp)
|
||||
button.SetToolTipString(text)
|
||||
self.curSizer.Add(button)
|
||||
self.groups[-1][1][id] = button
|
||||
|
||||
def AddGroup(self, name):
|
||||
# Each group is inside box
|
||||
box = wxStaticBox(self, -1, name, style=wxWANTS_CHARS)
|
||||
box.SetFont(g.smallerFont())
|
||||
boxSizer = wxStaticBoxSizer(box, wxVERTICAL)
|
||||
boxSizer.Add((0, 4))
|
||||
self.curSizer = wxGridSizer(0, 3)
|
||||
boxSizer.Add(self.curSizer)
|
||||
self.sizer.Add(boxSizer, 0, wxTOP | wxLEFT | wxRIGHT, 4)
|
||||
self.groups.append((box,{}))
|
||||
|
||||
# Enable/disable group
|
||||
def EnableGroup(self, gnum, enable = True):
|
||||
grp = self.groups[gnum]
|
||||
grp[0].Enable(enable)
|
||||
for b in grp[1].values(): b.Enable(enable)
|
||||
|
||||
# Enable/disable group item
|
||||
def EnableGroupItem(self, gnum, id, enable = True):
|
||||
grp = self.groups[gnum]
|
||||
grp[1][id].Enable(enable)
|
||||
|
||||
# Enable/disable group items
|
||||
def EnableGroupItems(self, gnum, ids, enable = True):
|
||||
grp = self.groups[gnum]
|
||||
for id in ids:
|
||||
grp[1][id].Enable(enable)
|
||||
|
||||
# Process key events
|
||||
def OnKeyDown(self, evt):
|
||||
if evt.GetKeyCode() == WXK_CONTROL:
|
||||
g.tree.ctrl = True
|
||||
elif evt.GetKeyCode() == WXK_SHIFT:
|
||||
g.tree.shift = True
|
||||
self.UpdateIfNeeded()
|
||||
evt.Skip()
|
||||
|
||||
def OnKeyUp(self, evt):
|
||||
if evt.GetKeyCode() == WXK_CONTROL:
|
||||
g.tree.ctrl = False
|
||||
elif evt.GetKeyCode() == WXK_SHIFT:
|
||||
g.tree.shift = False
|
||||
self.UpdateIfNeeded()
|
||||
evt.Skip()
|
||||
|
||||
def OnMouse(self, evt):
|
||||
# Update control and shift states
|
||||
g.tree.ctrl = evt.ControlDown()
|
||||
g.tree.shift = evt.ShiftDown()
|
||||
self.UpdateIfNeeded()
|
||||
evt.Skip()
|
||||
|
||||
# Update UI after key presses, if necessary
|
||||
def UpdateIfNeeded(self):
|
||||
tree = g.tree
|
||||
if self.ctrl != tree.ctrl or self.shift != tree.shift:
|
||||
# Enabling is needed only for ctrl
|
||||
if self.ctrl != tree.ctrl: self.UpdateUI()
|
||||
self.ctrl = tree.ctrl
|
||||
self.shift = tree.shift
|
||||
if tree.ctrl:
|
||||
status = 'SBL'
|
||||
elif tree.shift:
|
||||
status = 'INS'
|
||||
else:
|
||||
status = ''
|
||||
g.frame.SetStatusText(status, 1)
|
||||
|
||||
# Update interface
|
||||
def UpdateUI(self):
|
||||
if not self.IsShown(): return
|
||||
# Update status bar
|
||||
pullDownMenu = g.pullDownMenu
|
||||
tree = g.tree
|
||||
item = tree.selection
|
||||
# If nothing selected, disable everything and return
|
||||
if not item:
|
||||
# Disable everything
|
||||
for grp in range(GROUPNUM):
|
||||
self.EnableGroup(grp, False)
|
||||
self.state = None
|
||||
return
|
||||
if tree.ctrl: needInsert = True
|
||||
else: needInsert = tree.NeedInsert(item)
|
||||
# Enable depending on selection
|
||||
if item == tree.root or needInsert and tree.GetItemParent(item) == tree.root:
|
||||
state = STATE_ROOT
|
||||
else:
|
||||
xxx = tree.GetPyData(item).treeObject()
|
||||
# Check parent for possible child nodes if inserting sibling
|
||||
if needInsert: xxx = xxx.parent
|
||||
if xxx.__class__ == xxxMenuBar:
|
||||
state = STATE_MENUBAR
|
||||
elif xxx.__class__ in [xxxToolBar, xxxTool] or \
|
||||
xxx.__class__ == xxxSeparator and xxx.parent.__class__ == xxxToolBar:
|
||||
state = STATE_TOOLBAR
|
||||
elif xxx.__class__ in [xxxMenu, xxxMenuItem]:
|
||||
state = STATE_MENU
|
||||
else:
|
||||
state = STATE_ELSE
|
||||
|
||||
# Enable depending on selection
|
||||
if state != self.state:
|
||||
# Disable everything
|
||||
for grp in range(GROUPNUM):
|
||||
self.EnableGroup(grp, False)
|
||||
# Enable some
|
||||
if state == STATE_ROOT:
|
||||
self.EnableGroup(GROUP_WINDOWS, True)
|
||||
self.EnableGroup(GROUP_MENUS, True)
|
||||
# But disable items
|
||||
self.EnableGroupItems(GROUP_MENUS,
|
||||
[ ID_NEW.TOOL,
|
||||
ID_NEW.MENU_ITEM,
|
||||
ID_NEW.SEPARATOR ],
|
||||
False)
|
||||
elif state == STATE_MENUBAR:
|
||||
self.EnableGroup(GROUP_MENUS)
|
||||
self.EnableGroupItems(GROUP_MENUS,
|
||||
[ ID_NEW.TOOL_BAR,
|
||||
ID_NEW.MENU_BAR,
|
||||
ID_NEW.TOOL ],
|
||||
False)
|
||||
elif state == STATE_TOOLBAR:
|
||||
self.EnableGroup(GROUP_MENUS)
|
||||
self.EnableGroupItems(GROUP_MENUS,
|
||||
[ ID_NEW.TOOL_BAR,
|
||||
ID_NEW.MENU,
|
||||
ID_NEW.MENU_BAR,
|
||||
ID_NEW.MENU_ITEM ],
|
||||
False)
|
||||
self.EnableGroup(GROUP_CONTROLS)
|
||||
self.EnableGroupItems(GROUP_CONTROLS,
|
||||
[ ID_NEW.TREE_CTRL,
|
||||
ID_NEW.NOTEBOOK,
|
||||
ID_NEW.SPLITTER_WINDOW ],
|
||||
False)
|
||||
elif state == STATE_MENU:
|
||||
self.EnableGroup(GROUP_MENUS)
|
||||
self.EnableGroupItems(GROUP_MENUS,
|
||||
[ ID_NEW.TOOL_BAR,
|
||||
ID_NEW.MENU_BAR,
|
||||
ID_NEW.TOOL ],
|
||||
False)
|
||||
else:
|
||||
self.EnableGroup(GROUP_WINDOWS)
|
||||
self.EnableGroupItems(GROUP_WINDOWS,
|
||||
[ ID_NEW.FRAME,
|
||||
ID_NEW.DIALOG ],
|
||||
False)
|
||||
self.EnableGroup(GROUP_MENUS)
|
||||
self.EnableGroupItems(GROUP_MENUS,
|
||||
[ ID_NEW.MENU_BAR,
|
||||
ID_NEW.MENU_BAR,
|
||||
ID_NEW.MENU,
|
||||
ID_NEW.MENU_ITEM,
|
||||
ID_NEW.TOOL,
|
||||
ID_NEW.SEPARATOR ],
|
||||
False)
|
||||
self.EnableGroup(GROUP_SIZERS)
|
||||
self.EnableGroup(GROUP_CONTROLS)
|
||||
# Special case for notebook (always executed)
|
||||
if state == STATE_ELSE:
|
||||
if xxx.__class__ == xxxNotebook:
|
||||
self.EnableGroup(GROUP_SIZERS, False)
|
||||
else:
|
||||
self.EnableGroup(GROUP_SIZERS)
|
||||
if not (xxx.isSizer or xxx.parent and xxx.parent.isSizer):
|
||||
self.EnableGroupItem(GROUP_SIZERS, ID_NEW.SPACER, False)
|
||||
# Save state
|
||||
self.state = state
|
@@ -1,151 +0,0 @@
|
||||
# Name: undo.py
|
||||
# Purpose: XRC editor, undo/redo module
|
||||
# Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be>
|
||||
# Created: 01.12.2002
|
||||
# RCS-ID: $Id$
|
||||
|
||||
from globals import *
|
||||
#from panel import *
|
||||
|
||||
# Undo/redo classes
|
||||
class UndoManager:
|
||||
# Undo/redo stacks
|
||||
undo = []
|
||||
redo = []
|
||||
def RegisterUndo(self, undoObj):
|
||||
self.undo.append(undoObj)
|
||||
for i in self.redo: i.destroy()
|
||||
self.redo = []
|
||||
def Undo(self):
|
||||
undoObj = self.undo.pop()
|
||||
undoObj.undo()
|
||||
self.redo.append(undoObj)
|
||||
g.frame.modified = True
|
||||
g.frame.SetStatusText('Undone')
|
||||
def Redo(self):
|
||||
undoObj = self.redo.pop()
|
||||
undoObj.redo()
|
||||
self.undo.append(undoObj)
|
||||
g.frame.modified = True
|
||||
g.frame.SetStatusText('Redone')
|
||||
def Clear(self):
|
||||
for i in self.undo: i.destroy()
|
||||
self.undo = []
|
||||
for i in self.redo: i.destroy()
|
||||
self.redo = []
|
||||
def CanUndo(self):
|
||||
return not not self.undo
|
||||
def CanRedo(self):
|
||||
return not not self.redo
|
||||
|
||||
class UndoCutDelete:
|
||||
def __init__(self, itemIndex, parent, elem):
|
||||
self.itemIndex = itemIndex
|
||||
self.parent = parent
|
||||
self.elem = elem
|
||||
def destroy(self):
|
||||
if self.elem: self.elem.unlink()
|
||||
def undo(self):
|
||||
item = g.tree.InsertNode(g.tree.ItemAtFullIndex(self.itemIndex[:-1]),
|
||||
self.parent, self.elem,
|
||||
g.tree.ItemAtFullIndex(self.itemIndex))
|
||||
# Scroll to show new item (!!! redundant?)
|
||||
g.tree.EnsureVisible(item)
|
||||
g.tree.SelectItem(item)
|
||||
self.elem = None
|
||||
# Update testWin if needed
|
||||
if g.testWin and g.tree.IsHighlatable(item):
|
||||
if g.conf.autoRefresh:
|
||||
g.tree.needUpdate = True
|
||||
g.tree.pendingHighLight = item
|
||||
else:
|
||||
g.tree.pendingHighLight = None
|
||||
def redo(self):
|
||||
item = g.tree.ItemAtFullIndex(self.itemIndex)
|
||||
# Delete testWin?
|
||||
if g.testWin:
|
||||
# If deleting top-level item, delete testWin
|
||||
if item == g.testWin.item:
|
||||
g.testWin.Destroy()
|
||||
g.testWin = None
|
||||
else:
|
||||
# Remove highlight, update testWin
|
||||
if g.testWin.highLight:
|
||||
g.testWin.highLight.Remove()
|
||||
g.tree.needUpdate = True
|
||||
self.elem = g.tree.RemoveLeaf(item)
|
||||
g.tree.Unselect()
|
||||
g.panel.Clear()
|
||||
|
||||
class UndoPasteCreate:
|
||||
def __init__(self, itemParent, parent, item, selected):
|
||||
self.itemParentIndex = g.tree.ItemFullIndex(itemParent)
|
||||
self.parent = parent
|
||||
self.itemIndex = g.tree.ItemFullIndex(item) # pasted item
|
||||
self.selectedIndex = g.tree.ItemFullIndex(selected) # maybe different from item
|
||||
self.elem = None
|
||||
def destroy(self):
|
||||
if self.elem: self.elem.unlink()
|
||||
def undo(self):
|
||||
self.elem = g.tree.RemoveLeaf(g.tree.ItemAtFullIndex(self.itemIndex))
|
||||
# Restore old selection
|
||||
selected = g.tree.ItemAtFullIndex(self.selectedIndex)
|
||||
g.tree.EnsureVisible(selected)
|
||||
g.tree.SelectItem(selected)
|
||||
# Delete testWin?
|
||||
if g.testWin:
|
||||
# If deleting top-level item, delete testWin
|
||||
if selected == g.testWin.item:
|
||||
g.testWin.Destroy()
|
||||
g.testWin = None
|
||||
else:
|
||||
# Remove highlight, update testWin
|
||||
if g.testWin.highLight:
|
||||
g.testWin.highLight.Remove()
|
||||
g.tree.needUpdate = True
|
||||
def redo(self):
|
||||
item = g.tree.InsertNode(g.tree.ItemAtFullIndex(self.itemParentIndex),
|
||||
self.parent, self.elem,
|
||||
g.tree.ItemAtFullIndex(self.itemIndex))
|
||||
# Scroll to show new item
|
||||
g.tree.EnsureVisible(item)
|
||||
g.tree.SelectItem(item)
|
||||
self.elem = None
|
||||
# Update testWin if needed
|
||||
if g.testWin and g.tree.IsHighlatable(item):
|
||||
if g.conf.autoRefresh:
|
||||
g.tree.needUpdate = True
|
||||
g.tree.pendingHighLight = item
|
||||
else:
|
||||
g.tree.pendingHighLight = None
|
||||
|
||||
class UndoEdit:
|
||||
def __init__(self):
|
||||
self.pages = map(ParamPage.GetState, g.panel.pages)
|
||||
self.selectedIndex = g.tree.ItemFullIndex(g.tree.GetSelection())
|
||||
def destroy(self):
|
||||
pass
|
||||
# Update test view
|
||||
def update(self, selected):
|
||||
g.tree.Apply(g.tree.GetPyData(selected), selected)
|
||||
# Update view
|
||||
if g.testWin:
|
||||
if g.testWin.highLight:
|
||||
g.testWin.highLight.Remove()
|
||||
g.tree.pendingHighLight = selected
|
||||
if g.testWin:
|
||||
g.tree.needUpdate = True
|
||||
def undo(self):
|
||||
# Restore selection
|
||||
selected = g.tree.ItemAtFullIndex(self.selectedIndex)
|
||||
if selected != g.tree.GetSelection():
|
||||
g.tree.SelectItem(selected)
|
||||
# Save current state for redo
|
||||
map(ParamPage.SaveState, g.panel.pages)
|
||||
pages = map(ParamPage.GetState, g.panel.pages)
|
||||
map(ParamPage.SetState, g.panel.pages, self.pages)
|
||||
self.pages = pages
|
||||
self.update(selected)
|
||||
def redo(self):
|
||||
self.undo()
|
||||
self.update(g.tree.GetSelection())
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1 +0,0 @@
|
||||
python2.2 YOUR_PATH_TO_XRCED/xrced.py $*
|
@@ -1,434 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<resource>
|
||||
<object class="wxDialog" name="DIALOG_TEXT">
|
||||
<title>Text Dialog</title>
|
||||
<centered>1</centered>
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxHORIZONTAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxTextCtrl" name="TEXT">
|
||||
<size>250,100</size>
|
||||
<style>wxTE_MULTILINE</style>
|
||||
</object>
|
||||
<option>1</option>
|
||||
<flag>wxALL|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
</object>
|
||||
<option>1</option>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticLine"/>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxHORIZONTAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="wxID_OK">
|
||||
<label>OK</label>
|
||||
<default>1</default>
|
||||
</object>
|
||||
<flag>wxRIGHT</flag>
|
||||
<border>10</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="wxID_CANCEL">
|
||||
<label>Cancel</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
|
||||
<border>10</border>
|
||||
</object>
|
||||
</object>
|
||||
<style>wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</style>
|
||||
</object>
|
||||
<object class="wxDialog" name="DIALOG_CONTENT">
|
||||
<title>Content</title>
|
||||
<centered>1</centered>
|
||||
<size>250,300</size>
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxHORIZONTAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxListBox" name="LIST">
|
||||
<content/>
|
||||
</object>
|
||||
<option>1</option>
|
||||
<flag>wxTOP|wxBOTTOM|wxLEFT|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="BUTTON_UP">
|
||||
<label>Move Up</label>
|
||||
</object>
|
||||
<flag>wxBOTTOM|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="BUTTON_DOWN">
|
||||
<label>Move Down</label>
|
||||
</object>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="spacer">
|
||||
<size>10,20</size>
|
||||
<option>1</option>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="BUTTON_APPEND">
|
||||
<label>Append...</label>
|
||||
</object>
|
||||
<flag>wxBOTTOM|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="BUTTON_REMOVE">
|
||||
<label>Remove</label>
|
||||
</object>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
</object>
|
||||
<flag>wxALL|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
</object>
|
||||
<option>1</option>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticLine"/>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxHORIZONTAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="wxID_OK">
|
||||
<label>OK</label>
|
||||
<default>1</default>
|
||||
</object>
|
||||
<flag>wxRIGHT</flag>
|
||||
<border>10</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="wxID_CANCEL">
|
||||
<label>Cancel</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
|
||||
<border>10</border>
|
||||
</object>
|
||||
</object>
|
||||
<style>wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</style>
|
||||
</object>
|
||||
<object class="wxDialog" name="DIALOG_CONTENT_CHECK_LIST">
|
||||
<title>Content</title>
|
||||
<centered>1</centered>
|
||||
<size>250,300</size>
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxHORIZONTAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxCheckListBox" name="CHECK_LIST">
|
||||
<content/>
|
||||
</object>
|
||||
<option>1</option>
|
||||
<flag>wxTOP|wxBOTTOM|wxLEFT|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="BUTTON_UP">
|
||||
<label>Move Up</label>
|
||||
</object>
|
||||
<flag>wxBOTTOM|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="BUTTON_DOWN">
|
||||
<label>Move Down</label>
|
||||
</object>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="spacer">
|
||||
<size>10,20</size>
|
||||
<option>1</option>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="BUTTON_APPEND">
|
||||
<label>Append...</label>
|
||||
</object>
|
||||
<flag>wxBOTTOM|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="BUTTON_REMOVE">
|
||||
<label>Remove</label>
|
||||
</object>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
</object>
|
||||
<flag>wxALL|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
</object>
|
||||
<option>1</option>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticLine"/>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxHORIZONTAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="wxID_OK">
|
||||
<label>OK</label>
|
||||
<default>1</default>
|
||||
</object>
|
||||
<flag>wxRIGHT</flag>
|
||||
<border>10</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="wxID_CANCEL">
|
||||
<label>Cancel</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
|
||||
<border>10</border>
|
||||
</object>
|
||||
</object>
|
||||
<style>wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</style>
|
||||
</object>
|
||||
<object class="wxDialog" name="DIALOG_CHOICES">
|
||||
<title>Choices</title>
|
||||
<centered>1</centered>
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxCheckListBox" name="CHECK_LIST">
|
||||
<content/>
|
||||
<size>250,250</size>
|
||||
<style></style>
|
||||
</object>
|
||||
<option>1</option>
|
||||
<flag>wxALL|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticLine"/>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxHORIZONTAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="wxID_OK">
|
||||
<label>OK</label>
|
||||
<default>1</default>
|
||||
</object>
|
||||
<flag>wxRIGHT</flag>
|
||||
<border>10</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="wxID_CANCEL">
|
||||
<label>Cancel</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
|
||||
<border>10</border>
|
||||
</object>
|
||||
</object>
|
||||
<style>wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</style>
|
||||
</object>
|
||||
<object class="wxDialog" name="DIALOG_INTLIST">
|
||||
<title>Numbers</title>
|
||||
<centered>1</centered>
|
||||
<size>100,300</size>
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxListBox" name="LIST">
|
||||
<content/>
|
||||
<size>80,100</size>
|
||||
<style>wxLB_SORT</style>
|
||||
</object>
|
||||
<option>1</option>
|
||||
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
|
||||
<border>10</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="BUTTON_ADD">
|
||||
<label>Add...</label>
|
||||
</object>
|
||||
<flag>wxBOTTOM</flag>
|
||||
<border>3</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="BUTTON_REMOVE">
|
||||
<label>Remove</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
</object>
|
||||
<option>1</option>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticLine"/>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="wxID_OK">
|
||||
<label>OK</label>
|
||||
<default>1</default>
|
||||
</object>
|
||||
<flag>wxBOTTOM</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="wxID_CANCEL">
|
||||
<label>Cancel</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
|
||||
<border>10</border>
|
||||
</object>
|
||||
</object>
|
||||
<style>wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</style>
|
||||
</object>
|
||||
<object class="wxPanel" name="PANEL_BITMAP">
|
||||
<object class="wxStaticBoxSizer">
|
||||
<label></label>
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxFlexGridSizer">
|
||||
<cols>2</cols>
|
||||
<rows>2</rows>
|
||||
<object class="sizeritem">
|
||||
<object class="wxRadioButton" name="RADIO_STD">
|
||||
<label>art:</label>
|
||||
</object>
|
||||
<flag>wxALIGN_CENTRE_VERTICAL</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxComboBox" name="COMBO_STD">
|
||||
<content>
|
||||
<item>wxART_ADD_BOOKMARK</item>
|
||||
<item>wxART_DEL_BOOKMARK</item>
|
||||
<item>wxART_HELP_SIDE_PANEL</item>
|
||||
<item>wxART_HELP_SETTINGS</item>
|
||||
<item>wxART_HELP_BOOK</item>
|
||||
<item>wxART_HELP_FOLDER</item>
|
||||
<item>wxART_HELP_PAGE</item>
|
||||
<item>wxART_GO_BACK</item>
|
||||
<item>wxART_GO_FORWARD</item>
|
||||
<item>wxART_GO_UP</item>
|
||||
<item>wxART_GO_DOWN</item>
|
||||
<item>wxART_GO_TO_PARENT</item>
|
||||
<item>wxART_GO_HOME</item>
|
||||
<item>wxART_FILE_OPEN</item>
|
||||
<item>wxART_FILE_SAVE</item>
|
||||
<item>wxART_FILE_SAVE_AS</item>
|
||||
<item>wxART_PRINT</item>
|
||||
<item>wxART_HELP</item>
|
||||
<item>wxART_TIP</item>
|
||||
<item>wxART_REPORT_VIEW</item>
|
||||
<item>wxART_LIST_VIEW</item>
|
||||
<item>wxART_NEW_DIR</item>
|
||||
<item>wxART_HARDDISK</item>
|
||||
<item>wxART_FLOPPY</item>
|
||||
<item>wxART_CDROM</item>
|
||||
<item>wxART_REMOVABLE</item>
|
||||
<item>wxART_FOLDER</item>
|
||||
<item>wxART_FOLDER_OPEN</item>
|
||||
<item>wxART_GO_DIR_UP</item>
|
||||
<item>wxART_EXECUTABLE_FILE</item>
|
||||
<item>wxART_NORMAL_FILE</item>
|
||||
<item>wxART_TICK_MARK</item>
|
||||
<item>wxART_CROSS_MARK</item>
|
||||
<item>wxART_ERROR</item>
|
||||
<item>wxART_QUESTION</item>
|
||||
<item>wxART_WARNING</item>
|
||||
<item>wxART_INFORMATION</item>
|
||||
<item>wxART_MISSING_IMAGE</item>
|
||||
<item>wxART_COPY</item>
|
||||
<item>wxART_CUT</item>
|
||||
<item>wxART_PASTE</item>
|
||||
<item>wxART_DELETE</item>
|
||||
<item>wxART_NEW</item>
|
||||
<item>wxART_UNDO</item>
|
||||
<item>wxART_REDO</item>
|
||||
<item>wxART_QUIT</item>
|
||||
<item>wxART_FIND</item>
|
||||
<item>wxART_FIND_AND_REPLACE</item>
|
||||
</content>
|
||||
</object>
|
||||
<flag>wxRIGHT|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxRadioButton" name="RADIO_FILE">
|
||||
<label>file:</label>
|
||||
</object>
|
||||
<flag>wxALIGN_CENTRE_VERTICAL</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxHORIZONTAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxTextCtrl" name="TEXT_FILE"/>
|
||||
<option>1</option>
|
||||
<flag>wxRIGHT|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="BUTTON_BROWSE">
|
||||
<label>Browse...</label>
|
||||
<size>40,-1d</size>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<flag>wxRIGHT|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<vgap>2</vgap>
|
||||
<growablecols>1</growablecols>
|
||||
</object>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</resource>
|
@@ -1,937 +0,0 @@
|
||||
# Name: xxx.py ('xxx' is easy to distinguish from 'wx' :) )
|
||||
# Purpose: XML interface classes
|
||||
# Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be>
|
||||
# Created: 22.08.2001
|
||||
# RCS-ID: $Id$
|
||||
|
||||
from xml.dom import minidom
|
||||
from globals import *
|
||||
from params import *
|
||||
|
||||
# Base class for interface parameter classes
|
||||
class xxxNode:
|
||||
def __init__(self, node):
|
||||
self.node = node
|
||||
def remove(self):
|
||||
self.node.parentNode.removeChild(self.node)
|
||||
self.node.unlink()
|
||||
|
||||
# Generic (text) parameter class
|
||||
class xxxParam(xxxNode):
|
||||
# Standard use: for text nodes
|
||||
def __init__(self, node):
|
||||
xxxNode.__init__(self, node)
|
||||
if not node.hasChildNodes():
|
||||
# If does not have child nodes, create empty text node
|
||||
text = g.tree.dom.createTextNode('')
|
||||
node.appendChild(text)
|
||||
else:
|
||||
text = node.childNodes[0] # first child must be text node
|
||||
assert text.nodeType == minidom.Node.TEXT_NODE
|
||||
# Append other text nodes if present and delete them
|
||||
extraText = ''
|
||||
for n in node.childNodes[1:]:
|
||||
if n.nodeType == minidom.Node.TEXT_NODE:
|
||||
extraText += n.data
|
||||
node.removeChild(n)
|
||||
n.unlink()
|
||||
else: break
|
||||
if extraText: text.data = text.data + extraText
|
||||
# Use convertion from unicode to current encoding
|
||||
self.textNode = text
|
||||
# Value returns string
|
||||
if wxUSE_UNICODE: # no conversion is needed
|
||||
def value(self):
|
||||
return self.textNode.data
|
||||
def update(self, value):
|
||||
self.textNode.data = value
|
||||
else:
|
||||
def value(self):
|
||||
try:
|
||||
return self.textNode.data.encode(g.currentEncoding)
|
||||
except LookupError:
|
||||
return self.textNode.data.encode()
|
||||
def update(self, value):
|
||||
try: # handle exception if encoding is wrong
|
||||
self.textNode.data = unicode(value, g.currentEncoding)
|
||||
except UnicodeDecodeError:
|
||||
self.textNode.data = unicode(value)
|
||||
#wxLogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate")
|
||||
|
||||
# Integer parameter
|
||||
class xxxParamInt(xxxParam):
|
||||
# Standard use: for text nodes
|
||||
def __init__(self, node):
|
||||
xxxParam.__init__(self, node)
|
||||
# Value returns string
|
||||
def value(self):
|
||||
try:
|
||||
return int(self.textNode.data)
|
||||
except ValueError:
|
||||
return -1 # invalid value
|
||||
def update(self, value):
|
||||
self.textNode.data = str(value)
|
||||
|
||||
# Content parameter
|
||||
class xxxParamContent(xxxNode):
|
||||
def __init__(self, node):
|
||||
xxxNode.__init__(self, node)
|
||||
data, l = [], [] # data is needed to quicker value retrieval
|
||||
nodes = node.childNodes[:] # make a copy of the child list
|
||||
for n in nodes:
|
||||
if n.nodeType == minidom.Node.ELEMENT_NODE:
|
||||
assert n.tagName == 'item', 'bad content content'
|
||||
if not n.hasChildNodes():
|
||||
# If does not have child nodes, create empty text node
|
||||
text = g.tree.dom.createTextNode('')
|
||||
node.appendChild(text)
|
||||
else:
|
||||
# !!! normalize?
|
||||
text = n.childNodes[0] # first child must be text node
|
||||
assert text.nodeType == minidom.Node.TEXT_NODE
|
||||
l.append(text)
|
||||
data.append(str(text.data))
|
||||
else: # remove other
|
||||
node.removeChild(n)
|
||||
n.unlink()
|
||||
self.l, self.data = l, data
|
||||
def value(self):
|
||||
return self.data
|
||||
def update(self, value):
|
||||
# If number if items is not the same, recreate children
|
||||
if len(value) != len(self.l): # remove first if number of items has changed
|
||||
childNodes = self.node.childNodes[:]
|
||||
for n in childNodes:
|
||||
self.node.removeChild(n)
|
||||
l = []
|
||||
for str in value:
|
||||
itemElem = g.tree.dom.createElement('item')
|
||||
itemText = g.tree.dom.createTextNode(str)
|
||||
itemElem.appendChild(itemText)
|
||||
self.node.appendChild(itemElem)
|
||||
l.append(itemText)
|
||||
self.l = l
|
||||
else:
|
||||
for i in range(len(value)):
|
||||
self.l[i].data = value[i]
|
||||
self.data = value
|
||||
|
||||
# Content parameter for checklist
|
||||
class xxxParamContentCheckList(xxxNode):
|
||||
def __init__(self, node):
|
||||
xxxNode.__init__(self, node)
|
||||
data, l = [], [] # data is needed to quicker value retrieval
|
||||
nodes = node.childNodes[:] # make a copy of the child list
|
||||
for n in nodes:
|
||||
if n.nodeType == minidom.Node.ELEMENT_NODE:
|
||||
assert n.tagName == 'item', 'bad content content'
|
||||
checked = n.getAttribute('checked')
|
||||
if not checked: checked = 0
|
||||
if not n.hasChildNodes():
|
||||
# If does not have child nodes, create empty text node
|
||||
text = g.tree.dom.createTextNode('')
|
||||
node.appendChild(text)
|
||||
else:
|
||||
# !!! normalize?
|
||||
text = n.childNodes[0] # first child must be text node
|
||||
assert text.nodeType == minidom.Node.TEXT_NODE
|
||||
l.append((text, n))
|
||||
data.append((str(text.data), int(checked)))
|
||||
else: # remove other
|
||||
node.removeChild(n)
|
||||
n.unlink()
|
||||
self.l, self.data = l, data
|
||||
def value(self):
|
||||
return self.data
|
||||
def update(self, value):
|
||||
# If number if items is not the same, recreate children
|
||||
if len(value) != len(self.l): # remove first if number of items has changed
|
||||
childNodes = self.node.childNodes[:]
|
||||
for n in childNodes:
|
||||
self.node.removeChild(n)
|
||||
l = []
|
||||
for s,ch in value:
|
||||
itemElem = g.tree.dom.createElement('item')
|
||||
# Add checked only if True
|
||||
if ch: itemElem.setAttribute('checked', '1')
|
||||
itemText = g.tree.dom.createTextNode(s)
|
||||
itemElem.appendChild(itemText)
|
||||
self.node.appendChild(itemElem)
|
||||
l.append((itemText, itemElem))
|
||||
self.l = l
|
||||
else:
|
||||
for i in range(len(value)):
|
||||
self.l[i][0].data = value[i][0]
|
||||
self.l[i][1].setAttribute('checked', str(value[i][1]))
|
||||
self.data = value
|
||||
|
||||
# Bitmap parameter
|
||||
class xxxParamBitmap(xxxParam):
|
||||
def __init__(self, node):
|
||||
xxxParam.__init__(self, node)
|
||||
self.stock_id = node.getAttribute('stock_id')
|
||||
def value(self):
|
||||
return [self.stock_id, xxxParam.value(self)]
|
||||
def update(self, value):
|
||||
self.stock_id = value[0]
|
||||
if self.stock_id:
|
||||
self.node.setAttribute('stock_id', self.stock_id)
|
||||
elif self.node.hasAttribute('stock_id'):
|
||||
self.node.removeAttribute('stock_id')
|
||||
xxxParam.update(self, value[1])
|
||||
|
||||
################################################################################
|
||||
|
||||
# Classes to interface DOM objects
|
||||
class xxxObject:
|
||||
# Default behavior
|
||||
hasChildren = False # has children elements?
|
||||
hasStyle = True # almost everyone
|
||||
hasName = True # has name attribute?
|
||||
isSizer = hasChild = False
|
||||
allParams = None # Some nodes have no parameters
|
||||
# Style parameters (all optional)
|
||||
styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'tooltip']
|
||||
# Special parameters
|
||||
specials = []
|
||||
# Bitmap tags
|
||||
bitmapTags = ['bitmap', 'bitmap2', 'icon']
|
||||
# Required paremeters: none by default
|
||||
required = []
|
||||
# Default parameters with default values
|
||||
default = {}
|
||||
# Parameter types
|
||||
paramDict = {}
|
||||
# Window styles and extended styles
|
||||
winStyles = []
|
||||
# Tree icon index
|
||||
#image = -1
|
||||
# Construct a new xxx object from DOM element
|
||||
# parent is parent xxx object (or None if none), element is DOM element object
|
||||
def __init__(self, parent, element):
|
||||
self.parent = parent
|
||||
self.element = element
|
||||
self.undo = None
|
||||
# Get attributes
|
||||
self.className = element.getAttribute('class')
|
||||
self.subclass = element.getAttribute('subclass')
|
||||
if self.hasName: self.name = element.getAttribute('name')
|
||||
# Set parameters (text element children)
|
||||
self.params = {}
|
||||
nodes = element.childNodes[:]
|
||||
for node in nodes:
|
||||
if node.nodeType == minidom.Node.ELEMENT_NODE:
|
||||
tag = node.tagName
|
||||
if tag == 'object':
|
||||
continue # do nothing for object children here
|
||||
if tag not in self.allParams and tag not in self.styles:
|
||||
print 'WARNING: unknown parameter for %s: %s' % \
|
||||
(self.className, tag)
|
||||
elif tag in self.specials:
|
||||
self.special(tag, node)
|
||||
elif tag == 'content':
|
||||
if self.className == 'wxCheckListBox':
|
||||
self.params[tag] = xxxParamContentCheckList(node)
|
||||
else:
|
||||
self.params[tag] = xxxParamContent(node)
|
||||
elif tag == 'font': # has children
|
||||
self.params[tag] = xxxParamFont(element, node)
|
||||
elif tag in self.bitmapTags:
|
||||
# Can have attributes
|
||||
self.params[tag] = xxxParamBitmap(node)
|
||||
else: # simple parameter
|
||||
self.params[tag] = xxxParam(node)
|
||||
elif node.nodeType == minidom.Node.TEXT_NODE and node.data.isspace():
|
||||
# Remove empty text nodes
|
||||
element.removeChild(node)
|
||||
node.unlink()
|
||||
|
||||
# Check that all required params are set
|
||||
for param in self.required:
|
||||
if not self.params.has_key(param):
|
||||
# If default is specified, set it
|
||||
if self.default.has_key(param):
|
||||
elem = g.tree.dom.createElement(param)
|
||||
if param == 'content':
|
||||
if self.className == 'wxCheckListBox':
|
||||
self.params[param] = xxxParamContentCheckList(elem)
|
||||
else:
|
||||
self.params[param] = xxxParamContent(elem)
|
||||
else:
|
||||
self.params[param] = xxxParam(elem)
|
||||
# Find place to put new element: first present element after param
|
||||
found = False
|
||||
paramStyles = self.allParams + self.styles
|
||||
for p in paramStyles[paramStyles.index(param) + 1:]:
|
||||
# Content params don't have same type
|
||||
if self.params.has_key(p) and p != 'content':
|
||||
found = True
|
||||
break
|
||||
if found:
|
||||
nextTextElem = self.params[p].node
|
||||
self.element.insertBefore(elem, nextTextElem)
|
||||
else:
|
||||
self.element.appendChild(elem)
|
||||
else:
|
||||
wxLogWarning('Required parameter %s of %s missing' %
|
||||
(param, self.className))
|
||||
# Returns real tree object
|
||||
def treeObject(self):
|
||||
if self.hasChild: return self.child
|
||||
return self
|
||||
# Returns tree image index
|
||||
def treeImage(self):
|
||||
if self.hasChild: return self.child.treeImage()
|
||||
return self.image
|
||||
# Class name plus wx name
|
||||
def treeName(self):
|
||||
if self.hasChild: return self.child.treeName()
|
||||
if self.subclass: className = self.subclass
|
||||
else: className = self.className
|
||||
if self.hasName and self.name: return className + ' "' + self.name + '"'
|
||||
return className
|
||||
# Class name or subclass
|
||||
def panelName(self):
|
||||
if self.subclass: return self.subclass + '(' + self.className + ')'
|
||||
else: return self.className
|
||||
# Sets name of tree object
|
||||
def setTreeName(self, name):
|
||||
if self.hasChild: obj = self.child
|
||||
else: obj = self
|
||||
obj.name = name
|
||||
obj.element.setAttribute('name', name)
|
||||
|
||||
################################################################################
|
||||
|
||||
# This is a little special: it is both xxxObject and xxxNode
|
||||
class xxxParamFont(xxxObject, xxxNode):
|
||||
allParams = ['size', 'family', 'style', 'weight', 'underlined',
|
||||
'face', 'encoding']
|
||||
def __init__(self, parent, element):
|
||||
xxxObject.__init__(self, parent, element)
|
||||
xxxNode.__init__(self, element)
|
||||
self.parentNode = parent # required to behave similar to DOM node
|
||||
v = []
|
||||
for p in self.allParams:
|
||||
try:
|
||||
v.append(str(self.params[p].value()))
|
||||
except KeyError:
|
||||
v.append('')
|
||||
self.data = v
|
||||
def update(self, value):
|
||||
# `value' is a list of strings corresponding to all parameters
|
||||
elem = self.element
|
||||
# Remove old elements first
|
||||
childNodes = elem.childNodes[:]
|
||||
for node in childNodes: elem.removeChild(node)
|
||||
i = 0
|
||||
self.params.clear()
|
||||
v = []
|
||||
for param in self.allParams:
|
||||
if value[i]:
|
||||
fontElem = g.tree.dom.createElement(param)
|
||||
textNode = g.tree.dom.createTextNode(value[i])
|
||||
self.params[param] = textNode
|
||||
fontElem.appendChild(textNode)
|
||||
elem.appendChild(fontElem)
|
||||
v.append(value[i])
|
||||
i += 1
|
||||
self.data = v
|
||||
def value(self):
|
||||
return self.data
|
||||
|
||||
################################################################################
|
||||
|
||||
class xxxContainer(xxxObject):
|
||||
hasChildren = True
|
||||
exStyles = []
|
||||
|
||||
# Simulate normal parameter for encoding
|
||||
class xxxEncoding:
|
||||
def value(self):
|
||||
return g.currentEncoding
|
||||
def update(self, val):
|
||||
g.currentEncoding = val
|
||||
|
||||
# Special class for root node
|
||||
class xxxMainNode(xxxContainer):
|
||||
allParams = ['encoding']
|
||||
hasStyle = hasName = False
|
||||
def __init__(self, dom):
|
||||
xxxContainer.__init__(self, None, dom.documentElement)
|
||||
self.className = 'XML tree'
|
||||
# Reset required parameters after processing XML, because encoding is
|
||||
# a little special
|
||||
self.required = ['encoding']
|
||||
self.params['encoding'] = xxxEncoding()
|
||||
|
||||
################################################################################
|
||||
# Top-level windwows
|
||||
|
||||
class xxxPanel(xxxContainer):
|
||||
allParams = ['pos', 'size', 'style']
|
||||
styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle',
|
||||
'tooltip']
|
||||
|
||||
class xxxDialog(xxxContainer):
|
||||
allParams = ['title', 'centered', 'pos', 'size', 'style']
|
||||
paramDict = {'centered': ParamBool}
|
||||
required = ['title']
|
||||
default = {'title': ''}
|
||||
winStyles = ['wxDEFAULT_DIALOG_STYLE',
|
||||
'wxCAPTION', 'wxMINIMIZE_BOX', 'wxMAXIMIZE_BOX', 'wxCLOSE_BOX',
|
||||
'wxSTAY_ON_TOP',
|
||||
'wxTHICK_FRAME',
|
||||
'wxNO_3D', 'wxDIALOG_NO_PARENT']
|
||||
styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle',
|
||||
'tooltip']
|
||||
|
||||
class xxxFrame(xxxContainer):
|
||||
allParams = ['title', 'centered', 'pos', 'size', 'style']
|
||||
paramDict = {'centered': ParamBool}
|
||||
required = ['title']
|
||||
default = {'title': ''}
|
||||
winStyles = ['wxDEFAULT_FRAME_STYLE',
|
||||
'wxCAPTION', 'wxMINIMIZE_BOX', 'wxMAXIMIZE_BOX', 'wxCLOSE_BOX',
|
||||
'wxSTAY_ON_TOP',
|
||||
'wxSYSTEM_MENU', 'wxRESIZE_BORDER',
|
||||
'wxFRAME_TOOL_WINDOW', 'wxFRAME_NO_TASKBAR',
|
||||
'wxFRAME_FLOAT_ON_PARENT', 'wxFRAME_SHAPED'
|
||||
]
|
||||
styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle',
|
||||
'tooltip']
|
||||
|
||||
class xxxTool(xxxObject):
|
||||
allParams = ['bitmap', 'bitmap2', 'radio', 'toggle', 'tooltip', 'longhelp', 'label']
|
||||
required = ['bitmap']
|
||||
paramDict = {'bitmap2': ParamBitmap, 'radio': ParamBool, 'toggle': ParamBool}
|
||||
hasStyle = False
|
||||
|
||||
class xxxToolBar(xxxContainer):
|
||||
allParams = ['bitmapsize', 'margins', 'packing', 'separation', 'dontattachtoframe',
|
||||
'pos', 'size', 'style']
|
||||
hasStyle = False
|
||||
paramDict = {'bitmapsize': ParamPosSize, 'margins': ParamPosSize,
|
||||
'packing': ParamInt, 'separation': ParamInt,
|
||||
'dontattachtoframe': ParamBool, 'style': ParamNonGenericStyle}
|
||||
winStyles = ['wxTB_FLAT', 'wxTB_DOCKABLE', 'wxTB_VERTICAL', 'wxTB_HORIZONTAL',
|
||||
'wxTB_3DBUTTONS','wxTB_TEXT', 'wxTB_NOICONS', 'wxTB_NODIVIDER',
|
||||
'wxTB_NOALIGN', 'wxTB_HORZ_LAYOUT', 'wxTB_HORZ_TEXT']
|
||||
|
||||
class xxxWizard(xxxContainer):
|
||||
allParams = ['title', 'bitmap', 'pos']
|
||||
required = ['title']
|
||||
default = {'title': ''}
|
||||
winStyles = []
|
||||
exStyles = ['wxWIZARD_EX_HELPBUTTON']
|
||||
|
||||
class xxxWizardPage(xxxContainer):
|
||||
allParams = ['bitmap']
|
||||
winStyles = []
|
||||
exStyles = []
|
||||
|
||||
class xxxWizardPageSimple(xxxContainer):
|
||||
allParams = ['bitmap']
|
||||
winStyles = []
|
||||
exStyles = []
|
||||
|
||||
################################################################################
|
||||
# Bitmap, Icon
|
||||
|
||||
class xxxBitmap(xxxObject):
|
||||
allParams = ['bitmap']
|
||||
required = ['bitmap']
|
||||
|
||||
# Just like bitmap
|
||||
class xxxIcon(xxxObject):
|
||||
allParams = []
|
||||
|
||||
################################################################################
|
||||
# Controls
|
||||
|
||||
class xxxStaticText(xxxObject):
|
||||
allParams = ['label', 'pos', 'size', 'style']
|
||||
required = ['label']
|
||||
default = {'label': ''}
|
||||
winStyles = ['wxALIGN_LEFT', 'wxALIGN_RIGHT', 'wxALIGN_CENTRE', 'wxST_NO_AUTORESIZE']
|
||||
|
||||
class xxxStaticLine(xxxObject):
|
||||
allParams = ['pos', 'size', 'style']
|
||||
winStyles = ['wxLI_HORIZONTAL', 'wxLI_VERTICAL']
|
||||
|
||||
class xxxStaticBitmap(xxxObject):
|
||||
allParams = ['bitmap', 'pos', 'size', 'style']
|
||||
required = ['bitmap']
|
||||
|
||||
class xxxTextCtrl(xxxObject):
|
||||
allParams = ['value', 'pos', 'size', 'style']
|
||||
winStyles = ['wxTE_PROCESS_ENTER', 'wxTE_PROCESS_TAB', 'wxTE_MULTILINE',
|
||||
'wxTE_PASSWORD', 'wxTE_READONLY', 'wxHSCROLL']
|
||||
paramDict = {'value': ParamMultilineText}
|
||||
|
||||
class xxxChoice(xxxObject):
|
||||
allParams = ['content', 'selection', 'pos', 'size', 'style']
|
||||
required = ['content']
|
||||
default = {'content': '[]'}
|
||||
winStyles = ['wxCB_SORT']
|
||||
|
||||
class xxxSlider(xxxObject):
|
||||
allParams = ['value', 'min', 'max', 'pos', 'size', 'style',
|
||||
'tickfreq', 'pagesize', 'linesize', 'thumb', 'tick',
|
||||
'selmin', 'selmax']
|
||||
paramDict = {'value': ParamInt, 'tickfreq': ParamInt, 'pagesize': ParamInt,
|
||||
'linesize': ParamInt, 'thumb': ParamInt, 'thumb': ParamInt,
|
||||
'tick': ParamInt, 'selmin': ParamInt, 'selmax': ParamInt}
|
||||
required = ['value', 'min', 'max']
|
||||
winStyles = ['wxSL_HORIZONTAL', 'wxSL_VERTICAL', 'wxSL_AUTOTICKS', 'wxSL_LABELS',
|
||||
'wxSL_LEFT', 'wxSL_RIGHT', 'wxSL_TOP', 'wxSL_BOTTOM',
|
||||
'wxSL_BOTH', 'wxSL_SELRANGE', 'wxSL_INVERSE']
|
||||
|
||||
class xxxGauge(xxxObject):
|
||||
allParams = ['range', 'pos', 'size', 'style', 'value', 'shadow', 'bezel']
|
||||
paramDict = {'range': ParamInt, 'value': ParamInt,
|
||||
'shadow': ParamInt, 'bezel': ParamInt}
|
||||
winStyles = ['wxGA_HORIZONTAL', 'wxGA_VERTICAL', 'wxGA_PROGRESSBAR', 'wxGA_SMOOTH']
|
||||
|
||||
class xxxScrollBar(xxxObject):
|
||||
allParams = ['pos', 'size', 'style', 'value', 'thumbsize', 'range', 'pagesize']
|
||||
paramDict = {'value': ParamInt, 'range': ParamInt, 'thumbsize': ParamInt,
|
||||
'pagesize': ParamInt}
|
||||
winStyles = ['wxSB_HORIZONTAL', 'wxSB_VERTICAL']
|
||||
|
||||
class xxxListCtrl(xxxObject):
|
||||
allParams = ['pos', 'size', 'style']
|
||||
winStyles = ['wxLC_LIST', 'wxLC_REPORT', 'wxLC_ICON', 'wxLC_SMALL_ICON',
|
||||
'wxLC_ALIGN_TOP', 'wxLC_ALIGN_LEFT', 'wxLC_AUTOARRANGE',
|
||||
'wxLC_USER_TEXT', 'wxLC_EDIT_LABELS', 'wxLC_NO_HEADER',
|
||||
'wxLC_SINGLE_SEL', 'wxLC_SORT_ASCENDING', 'wxLC_SORT_DESCENDING']
|
||||
|
||||
class xxxTreeCtrl(xxxObject):
|
||||
allParams = ['pos', 'size', 'style']
|
||||
winStyles = ['wxTR_HAS_BUTTONS', 'wxTR_NO_LINES', 'wxTR_LINES_AT_ROOT',
|
||||
'wxTR_EDIT_LABELS', 'wxTR_MULTIPLE']
|
||||
|
||||
class xxxHtmlWindow(xxxObject):
|
||||
allParams = ['pos', 'size', 'style', 'borders', 'url', 'htmlcode']
|
||||
paramDict = {'borders': ParamInt, 'htmlcode':ParamMultilineText}
|
||||
winStyles = ['wxHW_SCROLLBAR_NEVER', 'wxHW_SCROLLBAR_AUTO']
|
||||
|
||||
class xxxCalendarCtrl(xxxObject):
|
||||
allParams = ['pos', 'size', 'style']
|
||||
|
||||
class xxxNotebook(xxxContainer):
|
||||
allParams = ['usenotebooksizer', 'pos', 'size', 'style']
|
||||
paramDict = {'usenotebooksizer': ParamBool}
|
||||
winStyles = ['wxNB_FIXEDWIDTH', 'wxNB_LEFT', 'wxNB_RIGHT', 'wxNB_BOTTOM']
|
||||
|
||||
class xxxSplitterWindow(xxxContainer):
|
||||
allParams = ['orientation', 'sashpos', 'minsize', 'pos', 'size', 'style']
|
||||
paramDict = {'orientation': ParamOrientation, 'sashpos': ParamUnit, 'minsize': ParamUnit }
|
||||
winStyles = ['wxSP_3D', 'wxSP_3DSASH', 'wxSP_3DBORDER', 'wxSP_BORDER',
|
||||
'wxSP_NOBORDER', 'wxSP_PERMIT_UNSPLIT', 'wxSP_LIVE_UPDATE',
|
||||
'wxSP_NO_XP_THEME' ]
|
||||
|
||||
class xxxGenericDirCtrl(xxxObject):
|
||||
allParams = ['defaultfolder', 'filter', 'defaultfilter', 'pos', 'size', 'style']
|
||||
paramDict = {'defaultfilter': ParamInt}
|
||||
winStyles = ['wxDIRCTRL_DIR_ONLY', 'wxDIRCTRL_3D_INTERNAL', 'wxDIRCTRL_SELECT_FIRST',
|
||||
'wxDIRCTRL_SHOW_FILTERS', 'wxDIRCTRL_EDIT_LABELS']
|
||||
|
||||
class xxxScrolledWindow(xxxContainer):
|
||||
allParams = ['pos', 'size', 'style']
|
||||
winStyles = ['wxHSCROLL', 'wxVSCROLL']
|
||||
|
||||
################################################################################
|
||||
# Buttons
|
||||
|
||||
class xxxButton(xxxObject):
|
||||
allParams = ['label', 'default', 'pos', 'size', 'style']
|
||||
paramDict = {'default': ParamBool}
|
||||
required = ['label']
|
||||
winStyles = ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM']
|
||||
|
||||
class xxxBitmapButton(xxxObject):
|
||||
allParams = ['bitmap', 'selected', 'focus', 'disabled', 'default',
|
||||
'pos', 'size', 'style']
|
||||
required = ['bitmap']
|
||||
winStyles = ['wxBU_AUTODRAW', 'wxBU_LEFT', 'wxBU_TOP',
|
||||
'wxBU_RIGHT', 'wxBU_BOTTOM']
|
||||
|
||||
class xxxRadioButton(xxxObject):
|
||||
allParams = ['label', 'value', 'pos', 'size', 'style']
|
||||
paramDict = {'value': ParamBool}
|
||||
required = ['label']
|
||||
winStyles = ['wxRB_GROUP']
|
||||
|
||||
class xxxSpinButton(xxxObject):
|
||||
allParams = ['value', 'min', 'max', 'pos', 'size', 'style']
|
||||
paramDict = {'value': ParamInt}
|
||||
winStyles = ['wxSP_HORIZONTAL', 'wxSP_VERTICAL', 'wxSP_ARROW_KEYS', 'wxSP_WRAP']
|
||||
|
||||
class xxxSpinCtrl(xxxObject):
|
||||
allParams = ['value', 'min', 'max', 'pos', 'size', 'style']
|
||||
paramDict = {'value': ParamInt}
|
||||
winStyles = ['wxSP_HORIZONTAL', 'wxSP_VERTICAL', 'wxSP_ARROW_KEYS', 'wxSP_WRAP']
|
||||
|
||||
class xxxToggleButton(xxxObject):
|
||||
allParams = ['label', 'checked', 'pos', 'size', 'style']
|
||||
paramDict = {'checked': ParamBool}
|
||||
required = ['label']
|
||||
|
||||
################################################################################
|
||||
# Boxes
|
||||
|
||||
class xxxStaticBox(xxxObject):
|
||||
allParams = ['label', 'pos', 'size', 'style']
|
||||
required = ['label']
|
||||
|
||||
class xxxRadioBox(xxxObject):
|
||||
allParams = ['label', 'content', 'selection', 'dimension', 'pos', 'size', 'style']
|
||||
paramDict = {'dimension': ParamInt}
|
||||
required = ['label', 'content']
|
||||
default = {'content': '[]'}
|
||||
winStyles = ['wxRA_SPECIFY_ROWS', 'wxRA_SPECIFY_COLS']
|
||||
|
||||
class xxxCheckBox(xxxObject):
|
||||
allParams = ['label', 'checked', 'pos', 'size', 'style']
|
||||
paramDict = {'checked': ParamBool}
|
||||
winStyles = ['wxCHK_2STATE', 'wxCHK_3STATE', 'wxCHK_ALLOW_3RD_STATE_FOR_USER',
|
||||
'wxALIGN_RIGHT']
|
||||
required = ['label']
|
||||
|
||||
class xxxComboBox(xxxObject):
|
||||
allParams = ['content', 'selection', 'value', 'pos', 'size', 'style']
|
||||
required = ['content']
|
||||
default = {'content': '[]'}
|
||||
winStyles = ['wxCB_SIMPLE', 'wxCB_SORT', 'wxCB_READONLY', 'wxCB_DROPDOWN']
|
||||
|
||||
class xxxListBox(xxxObject):
|
||||
allParams = ['content', 'selection', 'pos', 'size', 'style']
|
||||
required = ['content']
|
||||
default = {'content': '[]'}
|
||||
winStyles = ['wxLB_SINGLE', 'wxLB_MULTIPLE', 'wxLB_EXTENDED', 'wxLB_HSCROLL',
|
||||
'wxLB_ALWAYS_SB', 'wxLB_NEEDED_SB', 'wxLB_SORT']
|
||||
|
||||
class xxxCheckList(xxxObject):
|
||||
allParams = ['content', 'pos', 'size', 'style']
|
||||
required = ['content']
|
||||
default = {'content': '[]'}
|
||||
winStyles = ['wxLC_LIST', 'wxLC_REPORT', 'wxLC_ICON', 'wxLC_SMALL_ICON',
|
||||
'wxLC_ALIGN_TOP', 'wxLC_ALIGN_LEFT', 'wxLC_AUTOARRANGE',
|
||||
'wxLC_USER_TEXT', 'wxLC_EDIT_LABELS', 'wxLC_NO_HEADER',
|
||||
'wxLC_SINGLE_SEL', 'wxLC_SORT_ASCENDING', 'wxLC_SORT_DESCENDING']
|
||||
paramDict = {'content': ParamContentCheckList}
|
||||
|
||||
################################################################################
|
||||
# Sizers
|
||||
|
||||
class xxxSizer(xxxContainer):
|
||||
hasName = hasStyle = False
|
||||
paramDict = {'orient': ParamOrient}
|
||||
isSizer = True
|
||||
itemTag = 'sizeritem' # different for some sizers
|
||||
|
||||
class xxxBoxSizer(xxxSizer):
|
||||
allParams = ['orient']
|
||||
required = ['orient']
|
||||
default = {'orient': 'wxVERTICAL'}
|
||||
# Tree icon depends on orientation
|
||||
def treeImage(self):
|
||||
if self.params['orient'].value() == 'wxHORIZONTAL': return self.imageH
|
||||
else: return self.imageV
|
||||
|
||||
class xxxStaticBoxSizer(xxxBoxSizer):
|
||||
allParams = ['label', 'orient']
|
||||
required = ['label', 'orient']
|
||||
|
||||
class xxxGridSizer(xxxSizer):
|
||||
allParams = ['cols', 'rows', 'vgap', 'hgap']
|
||||
required = ['cols']
|
||||
default = {'cols': '2', 'rows': '2'}
|
||||
|
||||
class xxxStdDialogButtonSizer(xxxSizer):
|
||||
allParams = []
|
||||
itemTag = 'button'
|
||||
|
||||
# For repeated parameters
|
||||
class xxxParamMulti:
|
||||
def __init__(self, node):
|
||||
self.node = node
|
||||
self.l, self.data = [], []
|
||||
def append(self, param):
|
||||
self.l.append(param)
|
||||
self.data.append(param.value())
|
||||
def value(self):
|
||||
return self.data
|
||||
def remove(self):
|
||||
for param in self.l:
|
||||
param.remove()
|
||||
self.l, self.data = [], []
|
||||
|
||||
class xxxFlexGridSizer(xxxGridSizer):
|
||||
specials = ['growablecols', 'growablerows']
|
||||
allParams = ['cols', 'rows', 'vgap', 'hgap'] + specials
|
||||
paramDict = {'growablecols':ParamIntList, 'growablerows':ParamIntList}
|
||||
# Special processing for growable* parameters
|
||||
# (they are represented by several nodes)
|
||||
def special(self, tag, node):
|
||||
if not self.params.has_key(tag):
|
||||
# Create new multi-group
|
||||
self.params[tag] = xxxParamMulti(node)
|
||||
self.params[tag].append(xxxParamInt(node))
|
||||
def setSpecial(self, param, value):
|
||||
# Straightforward implementation: remove, add again
|
||||
self.params[param].remove()
|
||||
del self.params[param]
|
||||
for i in value:
|
||||
node = g.tree.dom.createElement(param)
|
||||
text = g.tree.dom.createTextNode(str(i))
|
||||
node.appendChild(text)
|
||||
self.element.appendChild(node)
|
||||
self.special(param, node)
|
||||
|
||||
class xxxGridBagSizer(xxxSizer):
|
||||
specials = ['growablecols', 'growablerows']
|
||||
allParams = ['vgap', 'hgap'] + specials
|
||||
paramDict = {'growablecols':ParamIntList, 'growablerows':ParamIntList}
|
||||
# Special processing for growable* parameters
|
||||
# (they are represented by several nodes)
|
||||
def special(self, tag, node):
|
||||
if not self.params.has_key(tag):
|
||||
# Create new multi-group
|
||||
self.params[tag] = xxxParamMulti(node)
|
||||
self.params[tag].append(xxxParamInt(node))
|
||||
def setSpecial(self, param, value):
|
||||
# Straightforward implementation: remove, add again
|
||||
self.params[param].remove()
|
||||
del self.params[param]
|
||||
for i in value:
|
||||
node = g.tree.dom.createElement(param)
|
||||
text = g.tree.dom.createTextNode(str(i))
|
||||
node.appendChild(text)
|
||||
self.element.appendChild(node)
|
||||
self.special(param, node)
|
||||
|
||||
# Container with only one child.
|
||||
# Not shown in tree.
|
||||
class xxxChildContainer(xxxObject):
|
||||
hasName = hasStyle = False
|
||||
hasChild = True
|
||||
def __init__(self, parent, element):
|
||||
xxxObject.__init__(self, parent, element)
|
||||
# Must have one child with 'object' tag, but we don't check it
|
||||
nodes = element.childNodes[:] # create copy
|
||||
for node in nodes:
|
||||
if node.nodeType == minidom.Node.ELEMENT_NODE:
|
||||
if node.tagName == 'object':
|
||||
# Create new xxx object for child node
|
||||
self.child = MakeXXXFromDOM(self, node)
|
||||
self.child.parent = parent
|
||||
# Copy hasChildren and isSizer attributes
|
||||
self.hasChildren = self.child.hasChildren
|
||||
self.isSizer = self.child.isSizer
|
||||
return # success
|
||||
else:
|
||||
element.removeChild(node)
|
||||
node.unlink()
|
||||
assert 0, 'no child found'
|
||||
|
||||
class xxxSizerItem(xxxChildContainer):
|
||||
allParams = ['option', 'flag', 'border', 'minsize', 'ratio']
|
||||
paramDict = {'option': ParamInt, 'minsize': ParamPosSize, 'ratio': ParamPosSize}
|
||||
#default = {'cellspan': '1,1'}
|
||||
def __init__(self, parent, element):
|
||||
# For GridBag sizer items, extra parameters added
|
||||
if isinstance(parent, xxxGridBagSizer):
|
||||
self.allParams = self.allParams + ['cellpos', 'cellspan']
|
||||
xxxChildContainer.__init__(self, parent, element)
|
||||
# Remove pos parameter - not needed for sizeritems
|
||||
if 'pos' in self.child.allParams:
|
||||
self.child.allParams = self.child.allParams[:]
|
||||
self.child.allParams.remove('pos')
|
||||
|
||||
class xxxSizerItemButton(xxxSizerItem):
|
||||
allParams = []
|
||||
paramDict = {}
|
||||
def __init__(self, parent, element):
|
||||
xxxChildContainer.__init__(self, parent, element)
|
||||
# Remove pos parameter - not needed for sizeritems
|
||||
if 'pos' in self.child.allParams:
|
||||
self.child.allParams = self.child.allParams[:]
|
||||
self.child.allParams.remove('pos')
|
||||
|
||||
class xxxNotebookPage(xxxChildContainer):
|
||||
allParams = ['label', 'selected']
|
||||
paramDict = {'selected': ParamBool}
|
||||
required = ['label']
|
||||
def __init__(self, parent, element):
|
||||
xxxChildContainer.__init__(self, parent, element)
|
||||
# pos and size dont matter for notebookpages
|
||||
if 'pos' in self.child.allParams:
|
||||
self.child.allParams = self.child.allParams[:]
|
||||
self.child.allParams.remove('pos')
|
||||
if 'size' in self.child.allParams:
|
||||
self.child.allParams = self.child.allParams[:]
|
||||
self.child.allParams.remove('size')
|
||||
|
||||
class xxxSpacer(xxxObject):
|
||||
hasName = hasStyle = False
|
||||
allParams = ['size', 'option', 'flag', 'border']
|
||||
paramDict = {'option': ParamInt}
|
||||
default = {'size': '0,0'}
|
||||
|
||||
class xxxMenuBar(xxxContainer):
|
||||
allParams = ['style']
|
||||
paramDict = {'style': ParamNonGenericStyle} # no generic styles
|
||||
winStyles = ['wxMB_DOCKABLE']
|
||||
|
||||
class xxxMenu(xxxContainer):
|
||||
allParams = ['label', 'help', 'style']
|
||||
default = {'label': ''}
|
||||
paramDict = {'style': ParamNonGenericStyle} # no generic styles
|
||||
winStyles = ['wxMENU_TEAROFF']
|
||||
|
||||
class xxxMenuItem(xxxObject):
|
||||
allParams = ['label', 'bitmap', 'accel', 'help',
|
||||
'checkable', 'radio', 'enabled', 'checked']
|
||||
default = {'label': ''}
|
||||
hasStyle = False
|
||||
|
||||
class xxxSeparator(xxxObject):
|
||||
hasName = hasStyle = False
|
||||
|
||||
################################################################################
|
||||
# Unknown control
|
||||
|
||||
class xxxUnknown(xxxObject):
|
||||
allParams = ['pos', 'size', 'style']
|
||||
paramDict = {'style': ParamNonGenericStyle} # no generic styles
|
||||
|
||||
################################################################################
|
||||
|
||||
xxxDict = {
|
||||
'wxPanel': xxxPanel,
|
||||
'wxDialog': xxxDialog,
|
||||
'wxFrame': xxxFrame,
|
||||
'tool': xxxTool,
|
||||
'wxToolBar': xxxToolBar,
|
||||
'wxWizard': xxxWizard,
|
||||
'wxWizardPage': xxxWizardPage,
|
||||
'wxWizardPageSimple': xxxWizardPageSimple,
|
||||
|
||||
'wxBitmap': xxxBitmap,
|
||||
'wxIcon': xxxIcon,
|
||||
|
||||
'wxButton': xxxButton,
|
||||
'wxBitmapButton': xxxBitmapButton,
|
||||
'wxRadioButton': xxxRadioButton,
|
||||
'wxSpinButton': xxxSpinButton,
|
||||
'wxToggleButton' : xxxToggleButton,
|
||||
|
||||
'wxStaticBox': xxxStaticBox,
|
||||
'wxStaticBitmap': xxxStaticBitmap,
|
||||
'wxRadioBox': xxxRadioBox,
|
||||
'wxComboBox': xxxComboBox,
|
||||
'wxCheckBox': xxxCheckBox,
|
||||
'wxListBox': xxxListBox,
|
||||
|
||||
'wxStaticText': xxxStaticText,
|
||||
'wxStaticLine': xxxStaticLine,
|
||||
'wxTextCtrl': xxxTextCtrl,
|
||||
'wxChoice': xxxChoice,
|
||||
'wxSlider': xxxSlider,
|
||||
'wxGauge': xxxGauge,
|
||||
'wxScrollBar': xxxScrollBar,
|
||||
'wxTreeCtrl': xxxTreeCtrl,
|
||||
'wxListCtrl': xxxListCtrl,
|
||||
'wxCheckListBox': xxxCheckList,
|
||||
'wxNotebook': xxxNotebook,
|
||||
'wxSplitterWindow': xxxSplitterWindow,
|
||||
'notebookpage': xxxNotebookPage,
|
||||
'wxHtmlWindow': xxxHtmlWindow,
|
||||
'wxCalendarCtrl': xxxCalendarCtrl,
|
||||
'wxGenericDirCtrl': xxxGenericDirCtrl,
|
||||
'wxSpinCtrl': xxxSpinCtrl,
|
||||
'wxScrolledWindow': xxxScrolledWindow,
|
||||
|
||||
'wxBoxSizer': xxxBoxSizer,
|
||||
'wxStaticBoxSizer': xxxStaticBoxSizer,
|
||||
'wxGridSizer': xxxGridSizer,
|
||||
'wxFlexGridSizer': xxxFlexGridSizer,
|
||||
'wxGridBagSizer': xxxGridBagSizer,
|
||||
'wxStdDialogButtonSizer': xxxStdDialogButtonSizer,
|
||||
'sizeritem': xxxSizerItem, 'button': xxxSizerItemButton,
|
||||
'spacer': xxxSpacer,
|
||||
|
||||
'wxMenuBar': xxxMenuBar,
|
||||
'wxMenu': xxxMenu,
|
||||
'wxMenuItem': xxxMenuItem,
|
||||
'separator': xxxSeparator,
|
||||
|
||||
'unknown': xxxUnknown,
|
||||
}
|
||||
|
||||
# Create IDs for all parameters of all classes
|
||||
paramIDs = {'fg': wxNewId(), 'bg': wxNewId(), 'exstyle': wxNewId(), 'font': wxNewId(),
|
||||
'enabled': wxNewId(), 'focused': wxNewId(), 'hidden': wxNewId(),
|
||||
'tooltip': wxNewId(), 'encoding': wxNewId(),
|
||||
'cellpos': wxNewId(), 'cellspan': wxNewId()
|
||||
}
|
||||
for cl in xxxDict.values():
|
||||
if cl.allParams:
|
||||
for param in cl.allParams + cl.paramDict.keys():
|
||||
if not paramIDs.has_key(param):
|
||||
paramIDs[param] = wxNewId()
|
||||
|
||||
################################################################################
|
||||
# Helper functions
|
||||
|
||||
# Test for object elements
|
||||
def IsObject(node):
|
||||
return node.nodeType == minidom.Node.ELEMENT_NODE and node.tagName == 'object'
|
||||
|
||||
# Make XXX object from some DOM object, selecting correct class
|
||||
def MakeXXXFromDOM(parent, element):
|
||||
try:
|
||||
klass = xxxDict[element.getAttribute('class')]
|
||||
except KeyError:
|
||||
# If we encounter a weird class, use unknown template
|
||||
print 'WARNING: unsupported class:', element.getAttribute('class')
|
||||
klass = xxxUnknown
|
||||
return klass(parent, element)
|
||||
|
||||
# Make empty DOM element
|
||||
def MakeEmptyDOM(className):
|
||||
elem = g.tree.dom.createElement('object')
|
||||
elem.setAttribute('class', className)
|
||||
# Set required and default parameters
|
||||
xxxClass = xxxDict[className]
|
||||
defaultNotRequired = filter(lambda x, l=xxxClass.required: x not in l,
|
||||
xxxClass.default.keys())
|
||||
for param in xxxClass.required + defaultNotRequired:
|
||||
textElem = g.tree.dom.createElement(param)
|
||||
try:
|
||||
textNode = g.tree.dom.createTextNode(xxxClass.default[param])
|
||||
except KeyError:
|
||||
textNode = g.tree.dom.createTextNode('')
|
||||
textElem.appendChild(textNode)
|
||||
elem.appendChild(textElem)
|
||||
return elem
|
||||
|
||||
# Make empty XXX object
|
||||
def MakeEmptyXXX(parent, className):
|
||||
# Make corresponding DOM object first
|
||||
elem = MakeEmptyDOM(className)
|
||||
# If parent is a sizer, we should create sizeritem object, except for spacers
|
||||
if parent:
|
||||
if parent.isSizer and className != 'spacer':
|
||||
sizerItemElem = MakeEmptyDOM(parent.itemTag)
|
||||
sizerItemElem.appendChild(elem)
|
||||
elem = sizerItemElem
|
||||
elif isinstance(parent, xxxNotebook):
|
||||
pageElem = MakeEmptyDOM('notebookpage')
|
||||
pageElem.appendChild(elem)
|
||||
elem = pageElem
|
||||
# Now just make object
|
||||
return MakeXXXFromDOM(parent, elem)
|
||||
|