Compare commits

..

1 Commits

Author SHA1 Message Date
Bryan Petty
6964b31048 This commit was manufactured by cvs2svn to create tag
'BEFORE_FONTCHANGE'.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/BEFORE_FONTCHANGE@2434 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-05-12 15:34:03 +00:00
30 changed files with 5809 additions and 19140 deletions

View File

@@ -1,90 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/scrolwin.h
// Purpose: wxGenericScrolledWindow class
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_SCROLLWIN_H_
#define _WX_GENERIC_SCROLLWIN_H_
// ----------------------------------------------------------------------------
// headers and constants
// ----------------------------------------------------------------------------
#include "wx/window.h"
#include "wx/panel.h"
extern WXDLLEXPORT_DATA(const wxChar*) wxPanelNameStr;
// default scrolled window style
#ifndef wxScrolledWindowStyle
#define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL)
#endif
// ----------------------------------------------------------------------------
// wxGenericScrolledWindow
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxGenericScrolledWindow : public wxPanel,
public wxScrollHelper
{
public:
wxGenericScrolledWindow() : wxScrollHelper(this) { }
wxGenericScrolledWindow(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
const wxString& name = wxPanelNameStr)
: wxScrollHelper(this)
{
Create(parent, winid, pos, size, style, name);
}
virtual ~wxGenericScrolledWindow();
bool Create(wxWindow *parent,
wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
const wxString& name = wxPanelNameStr);
virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); }
// lay out the window and its children
virtual bool Layout();
virtual void DoSetVirtualSize(int x, int y);
// wxWindow's GetBestVirtualSize returns the actual window size,
// whereas we want to return the virtual size
virtual wxSize GetBestVirtualSize() const;
// Return the size best suited for the current window
// (this isn't a virtual size, this is a sensible size for the window)
virtual wxSize DoGetBestSize() const;
protected:
// this is needed for wxEVT_PAINT processing hack described in
// wxScrollHelperEvtHandler::ProcessEvent()
void OnPaint(wxPaintEvent& event);
// we need to return a special WM_GETDLGCODE value to process just the
// arrows but let the other navigation characters through
#ifdef __WXMSW__
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
#endif // __WXMSW__
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxGenericScrolledWindow)
DECLARE_EVENT_TABLE()
};
#endif // _WX_GENERIC_SCROLLWIN_H_

View File

@@ -1,193 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/scrolwin.h
// Purpose: wxScrolledWindow class
// Author: Robert Roebling
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_SCROLLWIN_H_
#define _WX_GTK_SCROLLWIN_H_
// ----------------------------------------------------------------------------
// 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
// ----------------------------------------------------------------------------
// wxScrolledWindow
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxScrolledWindow : public wxPanel
{
public:
wxScrolledWindow()
{ Init(); }
wxScrolledWindow(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); }
void Init();
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
const wxString& name = wxPanelNameStr);
// Normally the wxScrolledWindow 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, bool pushEventHandler = FALSE );
virtual wxWindow *GetTargetWindow() const;
// Set the scrolled area of the window.
virtual void DoSetVirtualSize( int x, int y );
// wxWindow's GetBestVirtualSize returns the actual window size,
// whereas we want to return the virtual size
virtual wxSize GetBestVirtualSize() const;
// Return the size best suited for the current window
// (this isn't a virtual size, this is a sensible size for the window)
virtual wxSize DoGetBestSize() const;
// Set the x, y scrolling increments.
void SetScrollRate( int xstep, int ystep );
// 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
// Default action is to set the virtual size and alter scrollbars
// accordingly.
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);
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, wxWidgets 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;
// translate between scrolled and unscrolled coordinates
void CalcScrolledPosition(int x, int y, int *xx, int *yy) const
{ DoCalcScrolledPosition(x, y, xx, yy); }
wxPoint CalcScrolledPosition(const wxPoint& pt) const
{
wxPoint p2;
DoCalcScrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
return p2;
}
void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
{ DoCalcUnscrolledPosition(x, y, xx, yy); }
wxPoint CalcUnscrolledPosition(const wxPoint& pt) const
{
wxPoint p2;
DoCalcUnscrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
return p2;
}
virtual void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const;
virtual void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
// 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 wxScrolledWindow
// automatically change the origin according to the scroll position.
void PrepareDC(wxDC& dc) { DoPrepareDC(dc); }
// lay out the window and its children
virtual bool Layout();
// Adjust the scrollbars
virtual void AdjustScrollbars();
// 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; }
// implementation from now on
void OnScroll(wxScrollWinEvent& event);
void OnSize(wxSizeEvent& event);
void OnPaint(wxPaintEvent& event);
void OnChar(wxKeyEvent& event);
void GtkVScroll( float value, unsigned int scroll_type );
void GtkHScroll( float value, unsigned int scroll_type );
void GtkVConnectEvent();
void GtkHConnectEvent();
void GtkVDisconnectEvent();
void GtkHDisconnectEvent();
// Calculate scroll increment
virtual int CalcScrollInc(wxScrollWinEvent& event);
// Overridden from wxWidgets due callback being static
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
virtual void DoPrepareDC(wxDC& dc);
protected:
wxWindow *m_targetWindow;
int m_xScrollPixelsPerLine;
int m_yScrollPixelsPerLine;
bool m_xScrollingEnabled;
bool m_yScrollingEnabled;
// FIXME: these next four members are duplicated in the GtkAdjustment
// members of wxWindow. Can they be safely removed from here?
int m_xScrollPosition;
int m_yScrollPosition;
int m_xScrollLinesPerPage;
int m_yScrollLinesPerPage;
double m_scaleY,m_scaleX;
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxScrolledWindow)
};
#endif
// _WX_GTK_SCROLLWIN_H_
// vi:sts=4:sw=4:et

View File

@@ -1,300 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/window.h
// Purpose:
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __GTKWINDOWH__
#define __GTKWINDOWH__
// helper structure that holds class that holds GtkIMContext object and
// some additional data needed for key events processing
struct wxGtkIMData;
//-----------------------------------------------------------------------------
// callback definition for inserting a window (internal)
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowGTK;
typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* );
//-----------------------------------------------------------------------------
// wxWindowGTK
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowGTK : public wxWindowBase
{
public:
// creating the window
// -------------------
wxWindowGTK();
wxWindowGTK(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
virtual ~wxWindowGTK();
// implement base class (pure) virtual methods
// -------------------------------------------
virtual bool Destroy();
virtual void Raise();
virtual void Lower();
virtual bool Show( bool show = TRUE );
virtual bool Enable( bool enable = TRUE );
virtual bool IsRetained() const;
virtual void SetFocus();
virtual bool AcceptsFocus() const;
virtual bool Reparent( wxWindowBase *newParent );
virtual void WarpPointer(int x, int y);
virtual void Refresh( bool eraseBackground = TRUE,
const wxRect *rect = (const wxRect *) NULL );
virtual void Update();
virtual void ClearBackground();
virtual bool SetBackgroundColour( const wxColour &colour );
virtual bool SetForegroundColour( const wxColour &colour );
virtual bool SetCursor( const wxCursor &cursor );
virtual bool SetFont( const wxFont &font );
virtual bool SetBackgroundStyle(wxBackgroundStyle style) ;
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;
#if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
#endif // wxUSE_MENUS_NATIVE
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
#ifdef __WXGTK20__
virtual void AddChild( wxWindowBase *child );
virtual void RemoveChild( wxWindowBase *child );
#endif
// implementation
// --------------
virtual WXWidget GetHandle() const { return m_widget; }
// I don't want users to override what's done in idle so everything that
// has to be done in idle time in order for wxGTK to work is done in
// OnInternalIdle
virtual void OnInternalIdle();
// Internal represention of Update()
void GtkUpdate();
// For compatibility across platforms (not in event table)
void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
// wxGTK-specific: called recursively by Enable,
// to give widgets an oppprtunity to correct their colours after they
// have been changed by Enable
virtual void OnParentEnable( bool WXUNUSED(enable) ) {}
// Used by all window classes in the widget creation process.
bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size );
void PostCreation();
// Internal addition of child windows. differs from class
// to class not by using virtual functions but by using
// the m_insertCallback.
void DoAddChild(wxWindowGTK *child);
// This methods sends wxPaintEvents to the window. It reads the
// update region, breaks it up into rects and sends an event
// for each rect. It is also responsible for background erase
// events and NC paint events. It is called from "draw" and
// "expose" handlers as well as from ::Update()
void GtkSendPaintEvents();
// The methods below are required because many native widgets
// are composed of several subwidgets and setting a style for
// the widget means setting it for all subwidgets as well.
// also, it is nor clear, which native widget is the top
// widget where (most of) the input goes. even tooltips have
// to be applied to all subwidgets.
virtual GtkWidget* GetConnectWidget();
virtual bool IsOwnGtkWindow( GdkWindow *window );
void ConnectWidget( GtkWidget *widget );
#ifdef __WXGTK20__
// Returns the default context which usually is anti-aliased
PangoContext *GtkGetPangoDefaultContext();
// Returns the X11 context which renders on the X11 client
// side (which can be remote) and which usually is not
// anti-aliased and is thus faster
// MR: Now returns the default pango_context for the widget as GtkGetPangoDefaultContext to
// not depend on libpangox - which is completely deprecated.
//BCI: Remove GtkGetPangoX11Context and m_x11Context completely when symbols may be removed
PangoContext *GtkGetPangoX11Context();
PangoContext *m_x11Context; // MR: Now unused
#endif
#if wxUSE_TOOLTIPS
virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
#endif // wxUSE_TOOLTIPS
// Called from GTK signales handlers. it indicates that
// the layouting functions have to be called later on
// (i.e. in idle time, implemented in OnInternalIdle() ).
void GtkUpdateSize() { m_sizeSet = FALSE; }
// fix up the mouse event coords, used by wxListBox only so far
virtual void FixUpMouseEvent(GtkWidget * WXUNUSED(widget),
wxCoord& WXUNUSED(x),
wxCoord& WXUNUSED(y)) { }
// is this window transparent for the mouse events (as wxStaticBox is)?
virtual bool IsTransparentForMouse() const { return FALSE; }
// is this a radiobutton (used by radiobutton code itself only)?
virtual bool IsRadioButton() const { return FALSE; }
// position and size of the window
int m_x, m_y;
int m_width, m_height;
int m_oldClientWidth,m_oldClientHeight;
// see the docs in src/gtk/window.cpp
GtkWidget *m_widget; // mostly the widget seen by the rest of GTK
GtkWidget *m_wxwindow; // mostly the client area as per wxWidgets
// this widget will be queried for GTK's focus events
GtkWidget *m_focusWidget;
#ifdef __WXGTK20__
wxGtkIMData *m_imData;
#else // GTK 1
#ifdef HAVE_XIM
// XIM support for wxWidgets
GdkIC *m_ic;
GdkICAttr *m_icattr;
#endif // HAVE_XIM
#endif // GTK 2/1
#ifndef __WXGTK20__
// The area to be cleared (and not just refreshed)
// We cannot make this distinction under GTK 2.0.
wxRegion m_clearRegion;
#endif
// scrolling stuff
GtkAdjustment *m_hAdjust,*m_vAdjust;
float m_oldHorizontalPos;
float m_oldVerticalPos;
// extra (wxGTK-specific) flags
bool m_needParent:1; // ! wxFrame, wxDialog, wxNotebookPage ?
bool m_noExpose:1; // wxGLCanvas has its own redrawing
bool m_nativeSizeEvent:1; // wxGLCanvas sends wxSizeEvent upon "alloc_size"
bool m_hasScrolling:1;
bool m_hasVMT:1;
bool m_sizeSet:1;
bool m_resizing:1;
bool m_acceptsFocus:1; // true if not static
bool m_hasFocus:1; // true if == FindFocus()
bool m_isScrolling:1; // dragging scrollbar thumb?
bool m_clipPaintRegion:1; // TRUE after ScrollWindow()
#ifdef __WXGTK20__
bool m_dirtyTabOrder:1; // tab order changed, GTK focus
// chain needs update
#endif
bool m_needsStyleChange:1; // May not be able to change
// background style until OnIdle
// C++ has no virtual methods in the constrcutor of any class but we need
// different methods of inserting a child window into a wxFrame,
// wxMDIFrame, wxNotebook etc. this is the callback that will get used.
wxInsertChildFunction m_insertCallback;
// 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);
virtual void DoMoveWindow(int x, int y, int width, int height);
virtual void DoCaptureMouse();
virtual void DoReleaseMouse();
#if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip );
#endif // wxUSE_TOOLTIPS
protected:
// common part of all ctors (not virtual because called from ctor)
void Init();
#ifdef __WXGTK20__
virtual void DoMoveInTabOrder(wxWindow *win, MoveKind move);
// Copies m_children tab order to GTK focus chain:
void RealizeTabOrder();
#endif
// Called by ApplyWidgetStyle (which is called by SetFont() and
// SetXXXColour etc to apply style changed to native widgets) to create
// modified GTK style with non-standard attributes. If forceStyle=true,
// creates empty GtkRcStyle if there are no modifications, otherwise
// returns NULL in such case.
GtkRcStyle *CreateWidgetStyle(bool forceStyle = false);
// Overridden in many GTK widgets who have to handle subwidgets
virtual void ApplyWidgetStyle(bool forceStyle = false);
// helper function to ease native widgets wrapping, called by
// ApplyWidgetStyle -- override this, not ApplyWidgetStyle
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
private:
DECLARE_DYNAMIC_CLASS(wxWindowGTK)
DECLARE_NO_COPY_CLASS(wxWindowGTK)
};
extern WXDLLIMPEXP_CORE wxWindow *wxFindFocusedChild(wxWindowGTK *win);
#endif // __GTKWINDOWH__

View File

@@ -1,193 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/scrolwin.h
// Purpose: wxScrolledWindow class
// Author: Robert Roebling
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_SCROLLWIN_H_
#define _WX_GTK_SCROLLWIN_H_
// ----------------------------------------------------------------------------
// 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
// ----------------------------------------------------------------------------
// wxScrolledWindow
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxScrolledWindow : public wxPanel
{
public:
wxScrolledWindow()
{ Init(); }
wxScrolledWindow(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); }
void Init();
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
const wxString& name = wxPanelNameStr);
// Normally the wxScrolledWindow 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, bool pushEventHandler = FALSE );
virtual wxWindow *GetTargetWindow() const;
// Set the scrolled area of the window.
virtual void DoSetVirtualSize( int x, int y );
// wxWindow's GetBestVirtualSize returns the actual window size,
// whereas we want to return the virtual size
virtual wxSize GetBestVirtualSize() const;
// Return the size best suited for the current window
// (this isn't a virtual size, this is a sensible size for the window)
virtual wxSize DoGetBestSize() const;
// Set the x, y scrolling increments.
void SetScrollRate( int xstep, int ystep );
// 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
// Default action is to set the virtual size and alter scrollbars
// accordingly.
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);
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, wxWidgets 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;
// translate between scrolled and unscrolled coordinates
void CalcScrolledPosition(int x, int y, int *xx, int *yy) const
{ DoCalcScrolledPosition(x, y, xx, yy); }
wxPoint CalcScrolledPosition(const wxPoint& pt) const
{
wxPoint p2;
DoCalcScrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
return p2;
}
void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
{ DoCalcUnscrolledPosition(x, y, xx, yy); }
wxPoint CalcUnscrolledPosition(const wxPoint& pt) const
{
wxPoint p2;
DoCalcUnscrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
return p2;
}
virtual void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const;
virtual void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
// 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 wxScrolledWindow
// automatically change the origin according to the scroll position.
void PrepareDC(wxDC& dc) { DoPrepareDC(dc); }
// lay out the window and its children
virtual bool Layout();
// Adjust the scrollbars
virtual void AdjustScrollbars();
// 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; }
// implementation from now on
void OnScroll(wxScrollWinEvent& event);
void OnSize(wxSizeEvent& event);
void OnPaint(wxPaintEvent& event);
void OnChar(wxKeyEvent& event);
void GtkVScroll( float value, unsigned int scroll_type );
void GtkHScroll( float value, unsigned int scroll_type );
void GtkVConnectEvent();
void GtkHConnectEvent();
void GtkVDisconnectEvent();
void GtkHDisconnectEvent();
// Calculate scroll increment
virtual int CalcScrollInc(wxScrollWinEvent& event);
// Overridden from wxWidgets due callback being static
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
virtual void DoPrepareDC(wxDC& dc);
protected:
wxWindow *m_targetWindow;
int m_xScrollPixelsPerLine;
int m_yScrollPixelsPerLine;
bool m_xScrollingEnabled;
bool m_yScrollingEnabled;
// FIXME: these next four members are duplicated in the GtkAdjustment
// members of wxWindow. Can they be safely removed from here?
int m_xScrollPosition;
int m_yScrollPosition;
int m_xScrollLinesPerPage;
int m_yScrollLinesPerPage;
double m_scaleY,m_scaleX;
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxScrolledWindow)
};
#endif
// _WX_GTK_SCROLLWIN_H_
// vi:sts=4:sw=4:et

View File

@@ -1,300 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/window.h
// Purpose:
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __GTKWINDOWH__
#define __GTKWINDOWH__
// helper structure that holds class that holds GtkIMContext object and
// some additional data needed for key events processing
struct wxGtkIMData;
//-----------------------------------------------------------------------------
// callback definition for inserting a window (internal)
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowGTK;
typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* );
//-----------------------------------------------------------------------------
// wxWindowGTK
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowGTK : public wxWindowBase
{
public:
// creating the window
// -------------------
wxWindowGTK();
wxWindowGTK(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
virtual ~wxWindowGTK();
// implement base class (pure) virtual methods
// -------------------------------------------
virtual bool Destroy();
virtual void Raise();
virtual void Lower();
virtual bool Show( bool show = TRUE );
virtual bool Enable( bool enable = TRUE );
virtual bool IsRetained() const;
virtual void SetFocus();
virtual bool AcceptsFocus() const;
virtual bool Reparent( wxWindowBase *newParent );
virtual void WarpPointer(int x, int y);
virtual void Refresh( bool eraseBackground = TRUE,
const wxRect *rect = (const wxRect *) NULL );
virtual void Update();
virtual void ClearBackground();
virtual bool SetBackgroundColour( const wxColour &colour );
virtual bool SetForegroundColour( const wxColour &colour );
virtual bool SetCursor( const wxCursor &cursor );
virtual bool SetFont( const wxFont &font );
virtual bool SetBackgroundStyle(wxBackgroundStyle style) ;
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;
#if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
#endif // wxUSE_MENUS_NATIVE
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
#ifdef __WXGTK20__
virtual void AddChild( wxWindowBase *child );
virtual void RemoveChild( wxWindowBase *child );
#endif
// implementation
// --------------
virtual WXWidget GetHandle() const { return m_widget; }
// I don't want users to override what's done in idle so everything that
// has to be done in idle time in order for wxGTK to work is done in
// OnInternalIdle
virtual void OnInternalIdle();
// Internal represention of Update()
void GtkUpdate();
// For compatibility across platforms (not in event table)
void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
// wxGTK-specific: called recursively by Enable,
// to give widgets an oppprtunity to correct their colours after they
// have been changed by Enable
virtual void OnParentEnable( bool WXUNUSED(enable) ) {}
// Used by all window classes in the widget creation process.
bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size );
void PostCreation();
// Internal addition of child windows. differs from class
// to class not by using virtual functions but by using
// the m_insertCallback.
void DoAddChild(wxWindowGTK *child);
// This methods sends wxPaintEvents to the window. It reads the
// update region, breaks it up into rects and sends an event
// for each rect. It is also responsible for background erase
// events and NC paint events. It is called from "draw" and
// "expose" handlers as well as from ::Update()
void GtkSendPaintEvents();
// The methods below are required because many native widgets
// are composed of several subwidgets and setting a style for
// the widget means setting it for all subwidgets as well.
// also, it is nor clear, which native widget is the top
// widget where (most of) the input goes. even tooltips have
// to be applied to all subwidgets.
virtual GtkWidget* GetConnectWidget();
virtual bool IsOwnGtkWindow( GdkWindow *window );
void ConnectWidget( GtkWidget *widget );
#ifdef __WXGTK20__
// Returns the default context which usually is anti-aliased
PangoContext *GtkGetPangoDefaultContext();
// Returns the X11 context which renders on the X11 client
// side (which can be remote) and which usually is not
// anti-aliased and is thus faster
// MR: Now returns the default pango_context for the widget as GtkGetPangoDefaultContext to
// not depend on libpangox - which is completely deprecated.
//BCI: Remove GtkGetPangoX11Context and m_x11Context completely when symbols may be removed
PangoContext *GtkGetPangoX11Context();
PangoContext *m_x11Context; // MR: Now unused
#endif
#if wxUSE_TOOLTIPS
virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
#endif // wxUSE_TOOLTIPS
// Called from GTK signales handlers. it indicates that
// the layouting functions have to be called later on
// (i.e. in idle time, implemented in OnInternalIdle() ).
void GtkUpdateSize() { m_sizeSet = FALSE; }
// fix up the mouse event coords, used by wxListBox only so far
virtual void FixUpMouseEvent(GtkWidget * WXUNUSED(widget),
wxCoord& WXUNUSED(x),
wxCoord& WXUNUSED(y)) { }
// is this window transparent for the mouse events (as wxStaticBox is)?
virtual bool IsTransparentForMouse() const { return FALSE; }
// is this a radiobutton (used by radiobutton code itself only)?
virtual bool IsRadioButton() const { return FALSE; }
// position and size of the window
int m_x, m_y;
int m_width, m_height;
int m_oldClientWidth,m_oldClientHeight;
// see the docs in src/gtk/window.cpp
GtkWidget *m_widget; // mostly the widget seen by the rest of GTK
GtkWidget *m_wxwindow; // mostly the client area as per wxWidgets
// this widget will be queried for GTK's focus events
GtkWidget *m_focusWidget;
#ifdef __WXGTK20__
wxGtkIMData *m_imData;
#else // GTK 1
#ifdef HAVE_XIM
// XIM support for wxWidgets
GdkIC *m_ic;
GdkICAttr *m_icattr;
#endif // HAVE_XIM
#endif // GTK 2/1
#ifndef __WXGTK20__
// The area to be cleared (and not just refreshed)
// We cannot make this distinction under GTK 2.0.
wxRegion m_clearRegion;
#endif
// scrolling stuff
GtkAdjustment *m_hAdjust,*m_vAdjust;
float m_oldHorizontalPos;
float m_oldVerticalPos;
// extra (wxGTK-specific) flags
bool m_needParent:1; // ! wxFrame, wxDialog, wxNotebookPage ?
bool m_noExpose:1; // wxGLCanvas has its own redrawing
bool m_nativeSizeEvent:1; // wxGLCanvas sends wxSizeEvent upon "alloc_size"
bool m_hasScrolling:1;
bool m_hasVMT:1;
bool m_sizeSet:1;
bool m_resizing:1;
bool m_acceptsFocus:1; // true if not static
bool m_hasFocus:1; // true if == FindFocus()
bool m_isScrolling:1; // dragging scrollbar thumb?
bool m_clipPaintRegion:1; // TRUE after ScrollWindow()
#ifdef __WXGTK20__
bool m_dirtyTabOrder:1; // tab order changed, GTK focus
// chain needs update
#endif
bool m_needsStyleChange:1; // May not be able to change
// background style until OnIdle
// C++ has no virtual methods in the constrcutor of any class but we need
// different methods of inserting a child window into a wxFrame,
// wxMDIFrame, wxNotebook etc. this is the callback that will get used.
wxInsertChildFunction m_insertCallback;
// 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);
virtual void DoMoveWindow(int x, int y, int width, int height);
virtual void DoCaptureMouse();
virtual void DoReleaseMouse();
#if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip );
#endif // wxUSE_TOOLTIPS
protected:
// common part of all ctors (not virtual because called from ctor)
void Init();
#ifdef __WXGTK20__
virtual void DoMoveInTabOrder(wxWindow *win, MoveKind move);
// Copies m_children tab order to GTK focus chain:
void RealizeTabOrder();
#endif
// Called by ApplyWidgetStyle (which is called by SetFont() and
// SetXXXColour etc to apply style changed to native widgets) to create
// modified GTK style with non-standard attributes. If forceStyle=true,
// creates empty GtkRcStyle if there are no modifications, otherwise
// returns NULL in such case.
GtkRcStyle *CreateWidgetStyle(bool forceStyle = false);
// Overridden in many GTK widgets who have to handle subwidgets
virtual void ApplyWidgetStyle(bool forceStyle = false);
// helper function to ease native widgets wrapping, called by
// ApplyWidgetStyle -- override this, not ApplyWidgetStyle
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
private:
DECLARE_DYNAMIC_CLASS(wxWindowGTK)
DECLARE_NO_COPY_CLASS(wxWindowGTK)
};
extern WXDLLIMPEXP_CORE wxWindow *wxFindFocusedChild(wxWindowGTK *win);
#endif // __GTKWINDOWH__

View File

@@ -1,238 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: include/wx/scrolwin.h
// Purpose: wxScrolledWindow, wxScrolledControl and wxScrollHelper
// Author: Vadim Zeitlin
// Modified by:
// Created: 30.08.00
// RCS-ID: $Id$
// Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SCROLWIN_H_BASE_
#define _WX_SCROLWIN_H_BASE_
#include "wx/window.h"
class WXDLLEXPORT wxScrollHelperEvtHandler;
class WXDLLEXPORT wxTimer;
// ----------------------------------------------------------------------------
// wxScrollHelper: this class implements the scrolling logic which is used by
// wxScrolledWindow and wxScrolledControl. It is a mix-in: just derive from it
// to implement scrolling in your class.
// ----------------------------------------------------------------------------
#if !defined(__WXGTK__) || defined(__WXUNIVERSAL__)
class WXDLLEXPORT wxScrollHelper
{
public:
// ctor and dtor
wxScrollHelper(wxWindow *winToScroll = (wxWindow *)NULL);
void SetWindow(wxWindow *winToScroll);
virtual ~wxScrollHelper();
// configure the scrolling
virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
int noUnitsX, int noUnitsY,
int xPos = 0, int yPos = 0,
bool noRefresh = false );
// scroll to the given (in logical coords) position
virtual void Scroll(int x, int y);
// get/set the page size for this orientation (wxVERTICAL/wxHORIZONTAL)
int GetScrollPageSize(int orient) const;
void SetScrollPageSize(int orient, int pageSize);
// Set the x, y scrolling increments.
void SetScrollRate( int xstep, int ystep );
// get the size of one logical unit in physical ones
virtual void GetScrollPixelsPerUnit(int *pixelsPerUnitX,
int *pixelsPerUnitY) const;
// Enable/disable Windows scrolling in either direction. If true, wxWidgets
// 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;
// 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; }
// translate between scrolled and unscrolled coordinates
void CalcScrolledPosition(int x, int y, int *xx, int *yy) const
{ DoCalcScrolledPosition(x, y, xx, yy); }
wxPoint CalcScrolledPosition(const wxPoint& pt) const
{
wxPoint p2;
DoCalcScrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
return p2;
}
void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
{ DoCalcUnscrolledPosition(x, y, xx, yy); }
wxPoint CalcUnscrolledPosition(const wxPoint& pt) const
{
wxPoint p2;
DoCalcUnscrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
return p2;
}
virtual void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const;
virtual void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
// Adjust the scrollbars
virtual void AdjustScrollbars(void);
// Calculate scroll increment
virtual int CalcScrollInc(wxScrollWinEvent& event);
// Normally the wxScrolledWindow will scroll itself, but in some rare
// occasions you might want it to scroll [part of] 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() const;
void SetTargetRect(const wxRect& rect) { m_rectToScroll = rect; }
wxRect GetTargetRect() const { return m_rectToScroll; }
// Override this function to draw the graphic (or just process EVT_PAINT)
virtual void OnDraw(wxDC& WXUNUSED(dc)) { }
// change the DC origin according to the scroll position.
virtual void DoPrepareDC(wxDC& dc);
// are we generating the autoscroll events?
bool IsAutoScrolling() const { return m_timerAutoScroll != NULL; }
// stop generating the scroll events when mouse is held outside the window
void StopAutoScrolling();
// this method can be overridden in a derived class to forbid sending the
// auto scroll events - note that unlike StopAutoScrolling() it doesn't
// stop the timer, so it will be called repeatedly and will typically
// return different values depending on the current mouse position
//
// the base class version just returns true
virtual bool SendAutoScrollEvents(wxScrollWinEvent& event) const;
// the methods to be called from the window event handlers
void HandleOnScroll(wxScrollWinEvent& event);
void HandleOnSize(wxSizeEvent& event);
void HandleOnPaint(wxPaintEvent& event);
void HandleOnChar(wxKeyEvent& event);
void HandleOnMouseEnter(wxMouseEvent& event);
void HandleOnMouseLeave(wxMouseEvent& event);
#if wxUSE_MOUSEWHEEL
void HandleOnMouseWheel(wxMouseEvent& event);
#endif // wxUSE_MOUSEWHEEL
// FIXME: this is needed for now for wxPlot compilation, should be removed
// once it is fixed!
void OnScroll(wxScrollWinEvent& event) { HandleOnScroll(event); }
protected:
// get pointer to our scroll rect if we use it or NULL
const wxRect *GetScrollRect() const
{
return m_rectToScroll.width != 0 ? &m_rectToScroll : NULL;
}
// get the size of the target window
wxSize GetTargetSize() const
{
return m_rectToScroll.width != 0 ? m_rectToScroll.GetSize()
: m_targetWindow->GetClientSize();
}
void GetTargetSize(int *w, int *h)
{
wxSize size = GetTargetSize();
if ( w )
*w = size.x;
if ( h )
*h = size.y;
}
// change just the target window (unlike SetWindow which changes m_win as
// well)
void DoSetTargetWindow(wxWindow *target);
// delete the event handler we installed
void DeleteEvtHandler();
double m_scaleX;
double m_scaleY;
wxWindow *m_win,
*m_targetWindow;
wxRect m_rectToScroll;
wxTimer *m_timerAutoScroll;
int m_xScrollPixelsPerLine;
int m_yScrollPixelsPerLine;
int m_xScrollPosition;
int m_yScrollPosition;
int m_xScrollLines;
int m_yScrollLines;
int m_xScrollLinesPerPage;
int m_yScrollLinesPerPage;
bool m_xScrollingEnabled;
bool m_yScrollingEnabled;
#if wxUSE_MOUSEWHEEL
int m_wheelRotation;
#endif // wxUSE_MOUSEWHEEL
wxScrollHelperEvtHandler *m_handler;
DECLARE_NO_COPY_CLASS(wxScrollHelper)
};
#endif
// ----------------------------------------------------------------------------
// wxScrolledWindow: a wxWindow which knows how to scroll
// ----------------------------------------------------------------------------
#if defined(__WXGTK__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/scrolwin.h"
#else // !wxGTK
#include "wx/generic/scrolwin.h"
class WXDLLEXPORT wxScrolledWindow : public wxGenericScrolledWindow
{
public:
wxScrolledWindow() { }
wxScrolledWindow(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
const wxString& name = wxPanelNameStr)
: wxGenericScrolledWindow(parent, winid, pos, size, style, name)
{
}
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxScrolledWindow)
};
#define wxSCROLLED_WINDOW_IS_GENERIC 1
#endif
#endif
// _WX_SCROLWIN_H_BASE_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2
user/wxLayout/.cvsignore Normal file
View File

@@ -0,0 +1,2 @@
Linux
linux-gnu

1
user/wxLayout/Makefile Normal file
View File

@@ -0,0 +1 @@
include ../../setup/general/makeapp

26
user/wxLayout/Makefile.in Normal file
View File

@@ -0,0 +1,26 @@
# WXXT base directory
WXBASEDIR=@WXBASEDIR@
# set the OS type for compilation
OS=@OS@
# compile a library only
RULE=bin
# define library name
BIN_TARGET=wxLayout
# define library sources
BIN_SRC=\
wxLayout.cpp kbList.cpp wxlist.cpp wxlwindow.cpp wxlparser.cpp
#define library objects
BIN_OBJ=\
wxLayout.o kbList.o wxllist.o wxlwindow.o wxlparser.o
# additional things needed to link
BIN_LINK=
# additional things needed to compile
ADD_COMPILE=
# include the definitions now
include ../../../template.mak

309
user/wxLayout/Micon.xpm Normal file
View File

@@ -0,0 +1,309 @@
/* XPM */
static char *Micon_xpm[] = {
/* width height num_colors chars_per_pixel */
" 64 48 254 2",
/* colors */
".. c #040207",
".# c #6482b4",
".a c #2a4471",
".b c #9cc2d4",
".c c #4c627f",
".d c #94918e",
".e c #0c243e",
".f c #4c4a4a",
".g c #3c63a8",
".h c #7ca2ac",
".i c #24447e",
".j c #2c2c2c",
".k c #5482cc",
".l c #d4d0d0",
".m c #99aab7",
".n c #5c74b1",
".o c #2c5287",
".p c #1a2a4d",
".q c #acdefc",
".r c #646362",
".s c #7491d0",
".t c #bcc4bf",
".u c #5273aa",
".v c #b4b1aa",
".w c #3d5583",
".x c #828482",
".y c #8c9490",
".z c #6f7369",
".A c #1c365c",
".B c #041220",
".C c #2c325c",
".D c #94b6e4",
".E c #3e4242",
".F c #648edc",
".G c #d4f2fc",
".H c #cbd3d1",
".I c #3c54a1",
".J c #243244",
".K c #4c69aa",
".L c #7c8ba2",
".M c #4c5d84",
".N c #34497f",
".O c #1c2228",
".P c #6484c5",
".Q c #6a7788",
".R c #9ba09b",
".S c #2c3634",
".T c #acb6b4",
".U c #141517",
".V c #a0c4e8",
".W c #515753",
".X c #5c76cc",
".Y c #1b2f51",
".Z c #4472c4",
".0 c #7c8a88",
".1 c #5a6262",
".2 c #a4aba6",
".3 c #bcc8d5",
".4 c #7494df",
".5 c #84b2d4",
".6 c #6784d9",
".7 c #acd3e4",
".8 c #304b72",
".9 c #2c4c81",
"#. c #3c5b93",
"## c #5468bc",
"#a c #b5bbb0",
"#b c #1c3765",
"#c c #444e44",
"#d c #ecece8",
"#e c #7ca3dc",
"#f c #d4deda",
"#g c #345495",
"#h c #1c2641",
"#i c #94a6cc",
"#j c #243252",
"#k c #a7acb5",
"#l c #5c7ab3",
"#m c #0a152d",
"#n c #c4def0",
"#o c #686e84",
"#p c #a4a19e",
"#q c #3e3c3a",
"#r c #84aaee",
"#s c #040a09",
"#t c #3c6294",
"#u c #7c929c",
"#v c #3c5c9d",
"#w c #4e6ead",
"#x c #344458",
"#y c #446bae",
"#z c #696b6a",
"#A c #547cbc",
"#B c #789ae3",
"#C c #112a44",
"#D c #4f504b",
"#E c #2c3140",
"#F c #8c8688",
"#G c #5e5c5c",
"#H c #8c8c80",
"#I c #cccccc",
"#J c #4c6398",
"#K c #c7cbc4",
"#L c #5174b8",
"#M c #3d558e",
"#N c #2c3c5f",
"#O c #acbad4",
"#P c #3f495a",
"#Q c #354e82",
"#R c #6a8ac7",
"#S c #767c84",
"#T c #30374b",
"#U c #b1c9e7",
"#V c #1b315d",
"#W c #537bcb",
"#X c #c4bec0",
"#Y c #243e6a",
"#Z c #969892",
"#0 c #7e858e",
"#1 c #94b3f1",
"#2 c #c2d4e8",
"#3 c #141e35",
"#4 c #acb2ac",
"#5 c #c4ced0",
"#6 c #2b4d8e",
"#7 c #445ca2",
"#8 c #2c3e6f",
"#9 c #14243e",
"a. c #f1fdfa",
"a# c #8c9abc",
"aa c #d7f9f9",
"ab c #5a697e",
"ac c #c7ebf7",
"ad c #bceefc",
"ae c #b4c2b4",
"af c #889cf0",
"ag c #d8d6c8",
"ah c #748598",
"ai c #b4d2fc",
"aj c #4c5eb0",
"ak c #3f4f64",
"al c #8492bc",
"am c #161d1e",
"an c #5d7dcf",
"ao c #5c86d6",
"ap c #9cacc8",
"aq c #6c92e6",
"ar c #e4ecec",
"as c #89b7ef",
"at c #a6d0f8",
"au c #e4e2e0",
"av c #8c98a4",
"aw c #ccdaec",
"ax c #94bee4",
"ay c #232b2b",
"az c #1c2b43",
"aA c #0c1c33",
"aB c #99bcf7",
"aC c #6c72bc",
"aD c #7c766c",
"aE c #a4a2b4",
"aF c #6c7eac",
"aG c #e4d6dc",
"aH c #e4fefc",
"aI c #84aeb4",
"aJ c #b4b6bf",
"aK c #345b9b",
"aL c #bce2ef",
"aM c #ccc6bc",
"aN c #82a3ef",
"aO c #7c7b77",
"aP c #040c1e",
"aQ c #6c7e94",
"aR c #9ca69c",
"aS c #acbebc",
"aT c #a2cafa",
"aU c #545e5f",
"aV c #5c6a74",
"aW c #cae6ee",
"aX c #5c6e7c",
"aY c #5474c6",
"aZ c #fcfaf4",
"a0 c #344672",
"a1 c #446ec4",
"a2 c #b4c4d4",
"a3 c #313231",
"a4 c #9cb2b4",
"a5 c #345a8c",
"a6 c #7496d4",
"a7 c #0c1a24",
"a8 c #444a47",
"a9 c #343e3c",
"b. c #dce6e4",
"b# c #a9b2bc",
"ba c #a6a6a3",
"bb c #446a9c",
"bc c #c4f2f8",
"bd c #445667",
"be c #727475",
"bf c #6a7896",
"bg c #9aa0a7",
"bh c #9ec4fa",
"bi c #545a61",
"bj c #6474e0",
"bk c #546674",
"bl c #b8bcbd",
"bm c #5d7cbf",
"bn c #515255",
"bo c #979a9f",
"bp c #849cd0",
"bq c #546a8f",
"br c #d7d8d5",
"bs c #688ada",
"bt c #4f6ebe",
"bu c #343e4c",
"bv c #dafefc",
"bw c #acd6fc",
"bx c #b4b6b0",
"by c #8c9a94",
"bz c #203a44",
"bA c #a4b6c8",
"bB c #4c6a98",
"bC c #040214",
"bD c #5c74be",
"bE c #4c5c98",
"bF c #24325c",
"bG c #8c8c8f",
"bH c #4464a7",
"bI c #2c457e",
"bJ c #5c83c7",
"bK c #34538a",
"bL c #b4dff1",
"bM c #7c92d4",
"bN c #c4c4c0",
"bO c #243759",
"bP c #0c151e",
"bQ c #9cb2d4",
"bR c #6c8fd3",
"bS c #546aab",
"bT c #848c9f",
"bU c #242420",
"bV c #6c83c0",
"bW c #343935",
"bX c #848b89",
"bY c #acaca6",
"bZ c #c4cad0",
"b0 c #445c90",
"b1 c #243865",
"b2 c #dce0dc",
"b3 c #747b76",
"b4 c #8cacee",
"b5 c #0c0c08",
"b6 c #446299",
"b7 c #8493a4",
/* pixels */
"................................................................................................................................",
"..................................bC....bC....bC..bC....bC..bCbCbCbC..bCbC..bC..bC..bC..bCbC..bC..bC....bC....bC................",
"..#9#C#h#C.p.Y.Y.Y#j.Y.Y.Y#V#V#Vb1bFb1b1#8#Y.a.a#Q#Q.a.N#Q.abI.i.9bI#Q#MbK#M.wb0#M.9.N.N.N.9.abI.a#Y#Yb1b1#b#bb1b1b1#V#V#V#Vaz..",
"..#h#C.p.p#9.Y.Y#j.AbObO.A.AbO.Ab1#Y#Y#8.a.aa0.N.8.w.w#QbK.w.ibI.9#6#Q#.#Mb0b0#J#MbK#M.NbK.N.9.NbI.N#YbIb1#Y#8#8bOb1bO#j#V#Caz..",
"..#9.e#h#C.p.p.Y.YbO.A#b#N.a#8#Y#bb1#8#Y.Na0.9.8#Q.w.Mb0#Q#MbK.9bK#g#6.Kb6#J#J#wb0#M#MbKbK#Q#M.9bI.N.N.a.N.a.a.ab1b1#V.Y#V.Y.Y..",
"..#9#C.p#h.p.p.p.Y#VbO#b.a.ia0.9#Q.N#YbI.a.N.N.N.w#Q.wb6b6b0b6#.#g#v#M.K#w#L.n.n#vbH#.bH.Ib6aK#MbK.9#Q#Q#Q#Q.a#Yb1.AbF#VbO.Y#j..",
"..#h#h.p.p.p.Y.p#bbF#bb1#Y.a.8.N#Q#M#M#Q.N.9#QbK#M#Mb0b0.ubB.K.K#..K#v#w.nbmbV.nbHbS#w#7#w#vb0#.#M#Mb0#M#Q.9#Y#Yb1#Yb1b1.Y.Y.Y..",
"..#h#9.p.p.p#V#V#b#b#Y#Y.a.ibI.N.w#Mb0b6#7#M#Q#QbK#.b6b6bq#l.n#LbHbH#y#L#R.s.4#AaY#w#w#L.K.KbH.g.KbH#v#M.9bI.i.8.a#Yb1.A.A.A#j..",
"..#h#C.p.p.Y#V#V#bb1.abIbI#6.o.o#g.oaK#tbH.K.KbH#M.Iaj.K#w.n#R.P#Rbt#W#W.4bpb4aoanbsaobm#La1#L#A#L.ga5bK#g#g#Q.8#Y#bb1b1bOb1bO..",
"...p.p.Y#V.Y#V.Ab1#YbI.9#Q#Q#M#M#7#7#M#v.M#J.K.K.nbS#MbH.nbm.#b4.s#Baq#Wb4aB#1aqaq#R.P.##l#RbmbD.K#7#J#J#.#Q.9.i.N.a#Y#Yb1.Aaz..",
"..az#C#V#j#V.A#N#8.N.N.ibObz#T.J#E.J#T#Tbu.Y.8#..K.nbVbD#wbm.4a6aTb4aoaNaTaiasaNa6.n.m.3bZ#2bN.3aR#2#2.3#J#Q#MbK.8.a#8#b.AbO#j..",
"..#h.p.p.Y.Yb1bO.ibI#g#Mbd#hambU.jbW.Sa3aybP.Y.9bHbH.ubm#BbM.P#rbhbc.qasbL.G.VbhaBbpbZaJbobxbl#I#a#abXbP#V.9#6.NbI#8#8#bbF#V#j..",
"..az#C.Y.Y.Y#bb1.abI#Q.oaj#Pa3a3aya3a3bW.Eayb0.K.g#y.K#LanbRbhaTaxbLbvbLbvbvaLadaTai.mbobYba#Xbl.H#I#P#m#.#M#QbIbI#Y#Yb1#b#V#j..",
"..az.p.p#VbObO#Y.a.N#g#g.I#xbW.j.ja3.E.Ebnbib0bmananbm#wanbs.4asacbLbvaHa.aHbvbc.7aIbY#p#pblbl#Kbe#F#k#9#..I#g#6.i#8#8b1b1.A#j..",
"..#h#C.p.YbO#bb1a0bIbKbK#7#xaya3.jaya3#q.Wbn.J.wbD#Lbm.X#Bb4bhat.b#na.a.a.aZaHaHaW#k#a.vagbNaObl#I.vb3#3#w.K#7#v#M#QbIa0#Y#N#N..",
"..#haz.p#V.YbO#Y#Y.N.9#g#7#P.EbUa8#q#D.f.f.fbi#hbB#LaY.n.P#R#e.5.7aLa.a.aZaZa.a.aS#5#p.d#p.t.l.HbYaObo.Y#w.Kb6#.#M.Na0.a#8#NbO..",
"..#h#C.YbO#V#N#Y.8#Q#g#t##ak.j.W.f.Wbn#Gbe#zbnaU.M#Ra6#eaNb4bh.7bLaWa.aZaZaZa.br.H.2ba.H.T#fau.H.H#p.x#3#w.K#tb0#Q#Q.a#8#Nb1bO..",
"..az#j#j.Ab1#N.a.8#Q#.bb##ak.Ebnbn.1.Ua8.zaO#z.xbubqbsbR.saqaN#1bw.7aaaHa.b.a.a4bZ#k#dbgbP.H#IbG#4bY#o#9#w.K#7b0#Q.8.a#8#NbObO..",
"..az#j.Y.YbO#8.a.8#Q#7#t##bd.r#D#D.rbPaV#G#z.x.y#z.p.u#W.6#B#r#eaTaTaLaWaaaI#5#aau#XbraU#8.HbN.T.RbY#0#9#w.Kb6#M#Q#Qa0#Y#Y#N#N..",
"..#h#j.YbOb1bO#Ya0.NbKa5aj.c.f#G#z.1#3.Mbe#zaO.x#pbT#.bmbsbs.F#1#easat.Gbc.hb.b2aragbgbPaC.3#k.v#4babe#9.KbH#7b0#Qak.a.i#N#Y#T..",
"..az.Y#j.Y.Ab1#Y.8.N#gbK.IaX.r.raDaV.Bb0bfbeb3bab3#HazbBaYbsaqbRaf#1.DaB#na2#K#4b3.ybC.Yaf#k#Z.y.d#p#S#3#v#7#M#g.N.N.a#N#Y#NbO..",
"..#h.p#C#jbFbO#8.a.NbK#.#7bk.z.zb3#H#9aKbm#J.y#Hbablb#.e.PaqbmbsaNaN#1aB#2bZ.x.2aub3.AbSbjapbobobo.rbn#9#v#gbK.9bI.a.a#Yb1bObO..",
"..#haz.YbF#VbO#Y.abI#QaK.I.Q.z.WaO#za7b0an.ub#.R.y.R#XbXbEbtbJbR#Bbsb4.D.3.v#p#za3#s.ubJbj#u.WbWb3.Rbe#9#v#v#g.9bI#Yb1b1#b.A#j..",
"..#h#C.p#C.Y#bbO#YbI.9.o.Iab#Zb3.x.da7bK#WbmalbTae.t#F#Gaz.nbsaqbJ.6#R#U#aaMbx#KbPbz#laoanb#ba.2.RbG#G#9#v#v#g.9bI.ab1#bbF#Vaz..",
"..#haz.p.p#V#Vb1#Y.a#6bK#7bk.1#z#Z.y#m#.a1a1bq.LbX#HblbN.3#N.PaobJafbQ.3.tblbx.TazbB.X.kaYb7bG.d.x#ZaV#3bH#v#Q.NbI#8b1b1.A.Y.Y..",
"..az#h#C.p#VbO#b#YbIbK#g#7aQ.d.y.RbX#mbK#y#ybt.#bZ#IaM.l.2bdbmanaobMap.t.2bY.2.ObO.s.X#W.6bX#F.yaOaD#G#9b6#7.I#Q.a.ab1#bbF.Y.Y..",
"..#9#h.p.p#V#Vb1.a.NbK#..IaQ.xbob3aO#m.9#L.ZaY#w#iaJagaGbr#5.8aF.4a#blbN#Z#Z.WaP#l#l.6#WaY#0aO.y.xb3#PaA#7b6bK#QbI#8b1bO.A#V.Y..",
"..#h.p#C#V.YbO#Y.abI.9aK.Ibf#D.1bYbY#mbK#ybt#ybHbSbT#aba.tbx#S.M#B.y#kbxbYbYaP.YbR#A.6bmbt.Lb3#z.W#Dbn#3bK#.#M#Q.N#Yb1b1#V.Yaz..",
"..#h#C.p#V.p#b.A.a#Y#Q#..Ib7#kbe#4#pa7bK#ybH.g.gbHbfbZbN#4bNbgakah#Zbg#F.x.1#9bK.P#A.X.#btbTaO.W.r.ra8.e#Q.o#Q#Q.a.ab1bO.A.Yaz..",
"..#h.p#h#C#VbOb1#YbI.9.o.I.L#H#Z.2.vaA#QbHaK.g.g#y#7#nbr#a.H.vaE.zaU#4blbebCbIaK#Lbm#LbJbtaXaO.z#z#G.EaA#g#Q.9bI.a.a#Nb1#jbO.Y..",
"..#h#C#h#V.p#V.A.a#8.9.9.Iah#4bY#4bGbP#QaKaKaKaK#7#wbEbg.z.zay.E#a#K.2#ZbCbO#v#gbH.Xbb.ubDbk#z.r#c.f.E#9#Q#6bI.i#8b1#YbO.AbO.J..",
"..#h.p#9.p.p#b.A#8#Y.9.9.I.0.R.2bN#XbP.NaK.IaK#v.IbS.KaQaR.Wbl#K.RbY.R.y#9#M#gaKbH.Kbb#yaCbk.r#Ga8#D#TaAbK#6.i.a#Y#bbObO.Y#jaz..",
"..#9#9.p.p.Y#V.Ab1#YbI.9#7a#bn.Hb2#FaP.a.I#g#g#g#v#7bHb0.L.HbY.y.0#ZaObC.8b0#g#6aKbH#wbb#LaX#D#q.Ea3.UaAbK#QbI#Y#Y#bbO.AbO.Y.Y..",
"..#9#h#h#C.p.Y#V#Y#Y#6.obEbk.H.2bUbe#m.a#g#g#Q#M#M#vaK#6bq#k.d.x.y#Z..az#M#v.o#6.o#v#L#tbSbda8bU.Ub5.O#3#6#6bI.ib1#bbF.Y#C.Yaz..",
"..#9#9.p.p.p#Vb1#Y.N#6.o#Q#O.R.xaM.HaPa0bK#Q#Q#M#M#MbK#gb0akb3aO.xbX#9#x#v#g.N#6.9.wbH#yb0bn#D.f#q.j.U#3.N#6#8.i#b#b.Y.p.Y.paz..",
"..#9#h#9.p.p#V#bb1#8bI#g.NbAb.br.t#H#m#Y#Q#g#Q.9.9.N#6.o#gb0avbG#Z...Y.w#g#6bIbIbIbK#v.K#Ma7#s#s....#haA#Q.NbI#Yb1#V#V#V.p.paz..",
"..#9#9#9.p.p#VbO#Y#8#6.i#M.Q#z.H#f#K.B#Y#6.9.N.9bIbI.9.9#M#M#JbybP.B.Nb0.NbIbI#Y.ibI#vbH.wbubW.E.Sa3a7#m.o#Q#Y#Yb1#V#V#C.p.p.e..",
"..#3#9#9#9.Y#V#VbF#Y#8#6ak#O#db2br.HaP#N.N#QbIbI.a#Y.i.8#M#Qa0.L.B.p#Q#Q.i.i.i#Y.ibI#Q#..c.E.ja3a3bWambP.N.9#Y#Y#b#b#V.p.p.p#9..",
"..#3.e#9.p.p.Y.Yb1b1#Y#.#Ubgbl.T#S..aw#obI.a.a#8#Y#Y.a#YbI.Na0.8bO#8a0#Qa0#8b1#Y#Y#8#Q.ibO#Ta9a9bWa3ay#Eb1.a.ab1#V#V.Y.p.p.e#9..",
"..#3#9.p#h#C.p.Y#Vb1#b#V.a.Y.Y.Y#CazbO.eb1#8#Y#b#bb1b1#8bI#Y.8.abIb1#Y.Nb1#Y#Y#Y#b#Y.9.8.8.C.JbO#j.Yaz#C.p.Y#bb1#V.p.p.p#C.e#9..",
"..#9#9#9.p#9.p.Y.Y#V#b#bb1#8.i#8.a.a#Y#Y#Y#Yb1b1#b#bb1#N#Y#8b1#Y#Yb1#8#Yb1#b#b#b#bb1#Y.N.w.8.N.8#Q.8.i.a#b#Y#bbO#V.Y.p#C.p.p#9..",
"..#3#9.e#9.p.p#9#C.Y#V#b#b#b#Y#Y#Y#Y#Y#Yb1b1bO#V.Y#j#Vb1b1bObObObO.Ab1#N.A.AbF#V#V#V#b#8.aa0.a.ibI.8#Y#Yb1#V#V#V#V.p.p#9.p.e#9..",
"..#3#3#9.e.e.p.p.p.p#V.Y#b#b#Vb1#b#Yb1.A#V.Y.Y.Y.Y.Y.A#j.YbO#VbO.Y#jbO#b#j#j#V.Y#V#V#bb1#Y.a#Yb1.a#8b1b1#b.A#V#C.p.p.p.p.e.e#9..",
"..#3aAaA#3#9.e.e#9#C#C.Y.p.Y#V#VbF#VbO.Y#j.p.p.Y#C#j.Y#j.Y#j.Y#j.Y.YbO.Y#j.Y.p.p.p.p.Y#VbOb1#NbObOb1b1.A#V.p.p.p#C.p#9#9#9.e#9..",
"..#3#9.e#3aA#9.e#9.p.p.e.p.p.p#V#j.Y.Y.Y#9.p.p#9.Yaz.Yaz.paz.Y.paz.Y.Y#j#C.p#C.p#C#C.p#V#VbO#VbF#V#j#V#j.p.p.p#C.p#9#C#C#9.e#9..",
"..#3aA#9aA#9aA.e#9.e#9#9.p.p.p.p#Caz.Y#C.p.p#9.p#C#Caz.p#Caz.Y#C.p#9#j.p#h.p#C#C#C.e.p#9.Y#j.Y.Y.p.p.p#C.p.p#9#9#9#9#9.e#9.e#3..",
"..#3.e#3.e#3.e#9#9aA#9.e.e.e.p#C.p#h#Caz#9.p.p.p#h.Y#9.p.p#C.paz.p#h.Yaz#9.p#C.e.e.e.p.p#9.p.paz#C.paz.Y#9.p.e#9.e#9#9#9#9aA#9..",
"......bC..bC..bCbCbCbCbCbCbC..bC....bC..bCbCbCbCbC..bC....bC......bC..bCbCbCbCbCbCbCbCbCbCbC....bC......bCbC..bC..bC..bC........"
};

8
user/wxLayout/Mpch.h Normal file
View File

@@ -0,0 +1,8 @@
/*
This is an empty Mpch.h file to allow me to move the
wxl* files between Mahogany and the wxLayout sample
without modifying them.
*/
static int _mpch_dummy = 0;

50
user/wxLayout/README Normal file
View File

@@ -0,0 +1,50 @@
README for wxLayout classes
---------------------------
All the source in this directory is copyrighted under the
GPL (GNU GENERAL PUBLIC LICENSE), version 2,
by Karsten Ballueder <ballueder@usa.net>.
This is still work in progress, so if you want to make any significant
changes, please get in touch with me before.
There are three building blocks for rich text editing:
wxllist :
The wxLayoutList layout engine. It is a linked list of wxLayoutObjects
which can arrange and display them on any wxDC. I am trying to keep
this class as simple as possible, to be just the core layout
engine. All "convenience" functions should be defined in classes built
on top of this.
The wxLayoutList is derived from kbList, a double-linked list with an
interface modelled after the STL list. As wxLayoutList depends on the
way kbList treats iterators (i.e. the iterator value after an insert()
or erase() operation), I don't feel like rewriting it for wxList.
wxlwindow :
Contains a class wxLayoutWindow, derived from wxScrolledWindow which
can directly be used as a rich-text display or editing window. The
function responsible for keyboard handling is virtual and can be
overloaded for different keybindings. wxLayoutWindow can sent fake
menu-events to the application to react to the user clicking on
objects.
wxlparser:
Contains several high level functions operating on
wxLayoutList. Currently implemented is inserting of text (including
linebreaks) and export of objects, text or html.
Planned for the future is an html parser for importing html.
wxLayout.cpp is a simple test program. It will export Text and HTML to
stdout and demonstrate some of the features and bugs of wxLayoutList.
There are still things to do and I'm working on them. :-)
Karsten Ballueder <Ballueder@usa.ne> 29 June 1998

56
user/wxLayout/TODO Normal file
View File

@@ -0,0 +1,56 @@
BUGS
=====================================================================
- dmalloc shows duplicate deletion after merging two lines and
deleting the second half
- word wrap for objects with lots of non-space needs to search in positive
direction if begin of first object is reached
- delete in empty line doesn't always work
- fix initial scrollbar sizes
- fix horiz scrollbar size
- occasionally wraps lines wongly (twice) ??
TODO
=====================================================================
- Image at end of a message doesn't get considered properly in
wxLayoutList::GetSize(), so it cannot be seen
- searching for text
- moving cursor in non-edit mode
- cursor screen positioning ignores font sizes once again :-(
--> UpdateCursorScreenPos() cannot work as it ignores previous font formatting commands.
Either draw cursor when drawing text, or wait for new wxLayoutObjectCmd to be fully
implemented.
RECENTLY FIXED (?)
- fix(simplify) cursor size calculation
- delete in empty line doesn't work
- fix horiz scrollbar size OK here, a Mahogany problem?
- with a large number of lines, wraps to top of scrolled window
--> check where the problem lies, add a debug function showing all coordinates
- update rectangle (needs support in wxllist and wxWindows)
--> needs a bit of fixing still
some code bits are commented out in wxlwindow.cpp
offset handling seems a bit dodgy, white shadow to top/left of cursor
- replacement of llist in window
- undo
- font optimisations(!)
- occasionally wraps lines wongly (twice) ??
- UNDO
later:
- DragNDrop ... broken in wxGTK at present
- cut&paste ... broken in wxGTK at present, Paste already implemented
- Selections
- More optimisations:
- let each line have a pointer to the last layoutcommand and let that
one only store the settings that changed, then we no longer need to
recalculate all the lines

336
user/wxLayout/kbList.cpp Normal file
View File

@@ -0,0 +1,336 @@
/*-*- c++ -*-********************************************************
* kbList.cc : a double linked list *
* *
* (C) 1998 by Karsten Ball<6C>der (Ballueder@usa.net) *
* *
* $Id$ *
* *
* $Log$
* Revision 1.3 1998/11/19 20:34:50 KB
* fixes
*
* Revision 1.8 1998/09/23 08:57:27 KB
* changed deletion behaviour
*
* Revision 1.7 1998/08/16 21:21:29 VZ
*
* 1) fixed config file bug: it was never created (attempt to create ~/.M/config
* always failed, must mkdir("~/.M") first)
* 2) "redesign" of "Folder properties" dialog and bug corrected, small change to
* MInputBox (it was too wide)
* 3) bug in ProvFC when it didn't reckognize the books as being in the correct
* format (=> messages "can't reopen book") corrected
* 4) I tried to enhance MDialog_About(), but it didn't really work... oh well,
* I've never said I was an artist
*
* Revision 1.6 1998/07/08 11:56:56 KB
* M compiles and runs on Solaris 2.5/gcc 2.8/c-client gso
*
* Revision 1.5 1998/06/27 20:07:18 KB
* several bug fixes for kbList
* started adding my layout stuff
*
* Revision 1.1.1.1 1998/06/13 21:51:12 karsten
* initial code
*
* Revision 1.4 1998/05/24 14:48:00 KB
* lots of progress on Python, but cannot call functions yet
* kbList fixes again?
*
* Revision 1.3 1998/05/18 17:48:34 KB
* more list<>->kbList changes, fixes for wxXt, improved makefiles
*
* Revision 1.2 1998/05/14 16:39:31 VZ
*
* fixed SIGSEGV in ~kbList if the list is empty
*
* Revision 1.1 1998/05/13 19:02:11 KB
* added kbList, adapted MimeTypes for it, more python, new icons
*
*******************************************************************/
#ifdef __GNUG__
# pragma implementation "kbList.h"
#endif
#include "kbList.h"
kbListNode::kbListNode( void *ielement,
kbListNode *iprev,
kbListNode *inext)
{
next = inext;
prev = iprev;
if(prev)
prev->next = this;
if(next)
next->prev = this;
element = ielement;
}
kbListNode::~kbListNode()
{
if(prev)
prev->next = next;
if(next)
next->prev = prev;
}
kbList::iterator::iterator(kbListNode *n)
{
node = n;
}
void *
kbList::iterator::operator*()
{
return node->element;
}
kbList::iterator &
kbList::iterator::operator++()
{
node = node ? node->next : NULL;
return *this;
}
kbList::iterator &
kbList::iterator::operator--()
{
node = node ? node->prev : NULL;
return *this;
}
kbList::iterator &
kbList::iterator::operator++(int /* foo */)
{
return operator++();
}
kbList::iterator &
kbList::iterator::operator--(int /* bar */)
{
return operator--();
}
bool
kbList::iterator::operator !=(kbList::iterator const & i) const
{
return node != i.node;
}
bool
kbList::iterator::operator ==(kbList::iterator const & i) const
{
return node == i.node;
}
kbList::kbList(bool ownsEntriesFlag)
{
first = NULL;
last = NULL;
ownsEntries = ownsEntriesFlag;
}
void
kbList::push_back(void *element)
{
if(! first) // special case of empty list
{
first = new kbListNode(element);
last = first;
return;
}
else
last = new kbListNode(element, last);
}
void
kbList::push_front(void *element)
{
if(! first) // special case of empty list
{
push_back(element);
return;
}
else
first = new kbListNode(element, NULL, first);
}
void *
kbList::pop_back(void)
{
iterator i;
void *data;
bool ownsFlagBak = ownsEntries;
i = tail();
data = *i;
ownsEntries = false;
erase(i);
ownsEntries = ownsFlagBak;
return data;
}
void *
kbList::pop_front(void)
{
iterator i;
void *data;
bool ownsFlagBak = ownsEntries;
i = begin();
data = *i;
ownsEntries = false;
erase(i);
ownsEntries = ownsFlagBak;
return data;
}
void
kbList::insert(kbList::iterator & i, void *element)
{
if(! i.Node())
return;
else if(i.Node() == first)
{
push_front(element);
i = first;
return;
}
i = kbList::iterator(new kbListNode(element, i.Node()->prev, i.Node()));
}
void
kbList::doErase(kbList::iterator & i)
{
kbListNode
*node = i.Node(),
*prev, *next;
if(! node) // illegal iterator
return;
prev = node->prev;
next = node->next;
// correct first/last:
if(node == first)
first = node->next;
if(node == last) // don't put else here!
last = node->prev;
// build new links:
if(prev)
prev->next = next;
if(next)
next->prev = prev;
// delete this node and contents:
// now done separately
//if(ownsEntries)
//delete *i;
delete i.Node();
// change the iterator to next element:
i = kbList::iterator(next);
}
kbList::~kbList()
{
kbListNode *next;
while ( first != NULL )
{
next = first->next;
if(ownsEntries)
delete first->element;
delete first;
first = next;
}
}
kbList::iterator
kbList::begin(void) const
{
return kbList::iterator(first);
}
kbList::iterator
kbList::tail(void) const
{
return kbList::iterator(last);
}
kbList::iterator
kbList::end(void) const
{
return kbList::iterator(NULL); // the one after the last
}
unsigned
kbList::size(void) const // inefficient
{
unsigned count = 0;
kbList::iterator i;
for(i = begin(); i != end(); i++, count++)
;
return count;
}
#ifdef KBLIST_TEST
#include <iostream.h>
KBLIST_DEFINE(kbListInt,int);
int main(void)
{
int
n, *ptr;
kbListInt
l;
kbListInt::iterator
i;
for(n = 0; n < 10; n++)
{
ptr = new int;
*ptr = n*n;
l.push_back(ptr);
}
i = l.begin(); // first element
i++; // 2nd
i++; // 3rd
i++; // 4th, insert here:
ptr = new int;
*ptr = 4444;
l.insert(i,ptr);
// this cannot work, because l.end() returns NULL:
i = l.end(); // behind last
i--; // still behind last
l.erase(i); // doesn't do anything
// this works:
i = l.tail(); // last element
i--;
--i;
l.erase(i); // erase 3rd last element (49)
for(i = l.begin(); i != l.end(); i++)
cout << *i << '\t' << *((int *)*i) << endl;
return 0;
}
#endif

315
user/wxLayout/kbList.h Normal file
View File

@@ -0,0 +1,315 @@
/*-*- c++ -*-********************************************************
* kbList.h : a double linked list *
* *
* (C) 1998 by Karsten Ball<6C>der (Ballueder@usa.net) *
* *
* $Id$
*
*******************************************************************/
#ifndef KBLIST_H
# define KBLIST_H
#ifdef __GNUG__
# pragma interface "kbList.h"
#endif
#ifndef NULL
# define NULL 0
#endif
/**@name Double linked list implementation. */
//@{
/** kbListNode is a class used by kbList. It represents a single
element in the list. It is not intended for general use outside
kbList functions.
*/
struct kbListNode
{
/// pointer to next node or NULL
struct kbListNode *next;
/// pointer to previous node or NULL
struct kbListNode *prev;
/// pointer to the actual data
void *element;
/** Constructor - it automatically links the node into the list, if
the iprev, inext parameters are given.
@param ielement pointer to the data for this node (i.e. the data itself)
@param iprev if not NULL, use this as previous element in list
@param inext if not NULL, use this as next element in list
*/
kbListNode( void *ielement,
kbListNode *iprev = NULL,
kbListNode *inext = NULL);
/// Destructor.
~kbListNode();
};
/** The main list class, handling void pointers as data.
*/
class kbList
{
public:
/// An iterator class for kbList, just like for the STL classes.
class iterator
{
protected:
/// the node to which this iterator points
kbListNode *node;
friend class kbList;
public:
/** Constructor.
@param n if not NULL, the node to which to point
*/
iterator(kbListNode *n = NULL);
/** Dereference operator.
@return the data pointer of the node belonging to this
iterator
*/
void * operator*();
/** This operator allows us to write if(i). It is <em>not</em> a
dereference operator and the result is always useless apart
from its logical value!
*/
operator void*() const { return node == NULL ? (void*)0 : (void*)(-1); }
/** Increment operator - prefix, goes to next node in list.
@return itself
*/
iterator & operator++();
/** Decrement operator - prefix, goes to previous node in list.
@return itself
*/
iterator & operator--();
/** Increment operator - prefix, goes to next node in list.
@return itself
*/
iterator & operator++(int); //postfix
/** Decrement operator - prefix, goes to previous node in list.
@return itself
*/
iterator & operator--(int); //postfix
/** Comparison operator.
@return true if not equal.
*/
bool operator !=(iterator const &) const;
/* Comparison operator.
@return true if equal
*/
bool operator ==(iterator const &) const;
/** Returns a pointer to the node associated with this iterator.
This function is not for general use and should be
protected. However, if protected, it cannot be called from
derived classes' iterators. (Is this a bug in gcc/egcs?)
@return the node pointer
*/
inline kbListNode * Node(void) const
{ return node; }
};
/** Constructor.
@param ownsEntriesFlag if true, the list owns the entries and
will issue a delete on each of them when deleting them. If
false, the entries themselves will not get deleted. Do not use
this with array types!
*/
kbList(bool ownsEntriesFlag = true);
/** Destructor.
If entries are owned, they will all get deleted from here.
*/
~kbList();
/** Tell list whether it owns objects. If owned, they can be
deleted by list. See the constructor for more details.
@param ownsflag if true, list will own entries
*/
void ownsObjects(bool ownsflag = true)
{ ownsEntries = ownsflag; }
/** Query whether list owns entries.
@return true if list owns entries
*/
bool ownsObjects(void)
{ return ownsEntries; }
/** Add an entry at the end of the list.
@param element pointer to data
*/
void push_back(void *element);
/** Add an entry at the head of the list.
@param element pointer to data
*/
void push_front(void *element);
/** Get element from end of the list and delete it.
NOTE: In this case the element's data will not get deleted by
the list. It is the responsibility of the caller to free it.
@return the element data
*/
void *pop_back(void);
/** Get element from head of the list and delete it.
NOTE: In this case the element's data will not get deleted by
the list. It is the responsibility of the caller to free it.
@return the element data
*/
void *pop_front(void);
/** Insert an element into the list.
@param i an iterator pointing to the element, before which the new one should be inserted
@param element the element data
*/
void insert(iterator & i, void *element);
/** Remove an element from the list _without_ deleting the object.
@param i iterator pointing to the element to be deleted
@return the value of the element just removed
*/
void *remove(iterator& i) { void *p = *i; doErase(i); return p; }
/** Erase an element, move iterator to following element.
@param i iterator pointing to the element to be deleted
*/
void erase(iterator & i) { deleteContent(i); doErase(i); }
/* Get head of list.
@return iterator pointing to head of list
*/
iterator begin(void) const;
/* Get end of list.
@return iterator pointing after the end of the list. This is an
invalid iterator which cannot be dereferenced or decremented. It is
only of use in comparisons. NOTE: this is different from STL!
@see tail
*/
iterator end(void) const;
/* Get last element in list.
@return iterator pointing to the last element in the list.
@see end
*/
iterator tail(void) const;
/* Get the number of elements in the list.
@return number of elements in the list
*/
unsigned size(void) const;
/* Query whether list is empty.
@return true if list is empty
*/
inline bool empty(void) const
{ return first == NULL ; }
protected:
/// if true, list owns entries
bool ownsEntries;
/// pointer to first element in list
kbListNode *first;
/// pointer to last element in list
kbListNode *last;
protected:
/** Erase an element, move iterator to following element.
@param i iterator pointing to the element to be deleted
*/
void doErase(iterator & i);
/** Deletes the actual content if ownsflag is set.
param iterator i
*/
inline void deleteContent(iterator i)
{ if(ownsEntries) delete *i; }
private:
/// forbid copy construction
kbList(kbList const &foo);
/// forbid assignments
kbList& operator=(const kbList& foo);
};
/// just for backward compatibility, will be removed soon
typedef kbList::iterator kbListIterator;
/// cast an iterator to a pointer, compatibility only to be removed
#define kbListICast(type, iterator) ((type *)*iterator)
/// cast an iterator to a const pointer, compatibility only to be removed
#define kbListIcCast(type, iterator) ((type const *)*iterator)
/** Macro to define a kbList with a given name, having elements of
pointer to the given type. I.e. KBLIST_DEFINE(Int,int) would
create a kbListInt type holding int pointers.
*/
#define KBLIST_DEFINE(name,type) \
class name : public kbList \
{ \
public: \
class iterator : public kbList::iterator \
{ \
protected: \
inline iterator(kbList::iterator const & i) \
{ node = i.Node(); } \
friend class name; \
public: \
inline iterator(kbListNode *n = NULL) \
: kbList::iterator(n) {} \
inline type * operator*() \
/* the cast is needed for MS VC++ 5.0 */ \
{ return (type *)((kbList::iterator *)this)->operator*() ; } \
}; \
inline name(bool ownsEntriesFlag = TRUE) \
: kbList(ownsEntriesFlag) {} \
\
inline type *pop_back(void) \
{ return (type *) kbList::pop_back(); } \
\
inline type *pop_front(void) \
{ return (type *) kbList::pop_front(); } \
\
type *remove(iterator& i) \
{ return (type *)kbList::remove(i); } \
inline void erase(iterator & i) \
{ deleteContent(i); doErase(i); } \
\
inline iterator begin(void) const \
{ return kbList::begin(); } \
\
inline iterator end(void) const \
{ return kbList::end(); } \
\
inline iterator tail(void) const \
{ return kbList::tail(); } \
~name() \
{ \
kbListNode *next; \
while ( first != NULL ) \
{ \
next = first->next; \
if(ownsEntries) \
delete (type *)first->element; \
delete first; \
first = next; \
} \
} \
protected: \
inline void deleteContent(iterator i) \
{ if(ownsEntries) delete *i; } \
}
#ifdef MCONFIG_H
/// define the most commonly used list type once:
KBLIST_DEFINE(kbStringList, String);
#endif
//@}
#endif // KBLIST_H

431
user/wxLayout/wxLayout.cpp Normal file
View File

@@ -0,0 +1,431 @@
/*
* Program: wxLayout
*
* Author: Karsten Ball<6C>der
*
* Copyright: (C) 1998, Karsten Ball<6C>der <Ballueder@usa.net>
*
*/
#ifdef __GNUG__
#pragma implementation "wxLayout.h"
#endif
#include "wx/wxprec.h"
#ifdef __BORLANDC__
# pragma hdrstop
#endif
#include "wxLayout.h"
#include "wx/textfile.h"
#include "Micon.xpm"
//-----------------------------------------------------------------------------
// main program
//-----------------------------------------------------------------------------
IMPLEMENT_APP(MyApp)
//-----------------------------------------------------------------------------
// MyFrame
//-----------------------------------------------------------------------------
enum ids{ ID_ADD_SAMPLE = 1, ID_CLEAR, ID_PRINT,
ID_PRINT_SETUP, ID_PAGE_SETUP, ID_PREVIEW, ID_PRINT_PS,
ID_PRINT_SETUP_PS, ID_PAGE_SETUP_PS,ID_PREVIEW_PS,
ID_WRAP, ID_NOWRAP, ID_PASTE, ID_COPY,
ID_WXLAYOUT_DEBUG, ID_QUIT, ID_CLICK, ID_HTML, ID_TEXT,
ID_TEST, ID_LONG_TEST };
IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
BEGIN_EVENT_TABLE(MyFrame,wxFrame)
EVT_MENU(ID_PRINT, MyFrame::OnPrint)
EVT_MENU(ID_PREVIEW, MyFrame::OnPrintPreview)
EVT_MENU(ID_PRINT_SETUP, MyFrame::OnPrintSetup)
EVT_MENU(ID_PAGE_SETUP, MyFrame::OnPageSetup)
EVT_MENU(ID_PRINT_PS, MyFrame::OnPrintPS)
EVT_MENU(ID_PREVIEW_PS, MyFrame::OnPrintPreviewPS)
EVT_MENU(ID_PRINT_SETUP_PS, MyFrame::OnPrintSetupPS)
EVT_MENU(ID_PAGE_SETUP_PS, MyFrame::OnPageSetupPS)
EVT_MENU (-1, MyFrame::OnCommand)
EVT_COMMAND (-1,-1, MyFrame::OnCommand)
EVT_CHAR ( wxLayoutWindow::OnChar )
END_EVENT_TABLE()
MyFrame::MyFrame(void) :
wxFrame( (wxFrame *) NULL, -1, (char *) "wxLayout", wxPoint(20,20), wxSize(600,360) )
{
CreateStatusBar( 1 );
SetStatusText( "wxLayout by Karsten Ball<6C>der." );
wxMenuBar *menu_bar = new wxMenuBar();
wxMenu *file_menu = new wxMenu;
file_menu->Append(ID_PRINT, "&Print...", "Print");
file_menu->Append(ID_PRINT_SETUP, "Print &Setup...","Setup printer properties");
file_menu->Append(ID_PAGE_SETUP, "Page Set&up...", "Page setup");
file_menu->Append(ID_PREVIEW, "Print Pre&view", "Preview");
#ifdef __WXMSW__
file_menu->AppendSeparator();
file_menu->Append(ID_PRINT_PS, "Print PostScript...", "Print (PostScript)");
file_menu->Append(ID_PRINT_SETUP_PS, "Print Setup PostScript...", "Setup printer properties (PostScript)");
file_menu->Append(ID_PAGE_SETUP_PS, "Page Setup PostScript...", "Page setup (PostScript)");
file_menu->Append(ID_PREVIEW_PS, "Print Preview PostScript", "Preview (PostScript)");
#endif
file_menu->AppendSeparator();
file_menu->Append( ID_TEXT, "Export Text");
file_menu->Append( ID_HTML, "Export HTML");
file_menu->Append( ID_QUIT, "Exit");
menu_bar->Append(file_menu, "File" );
wxMenu *edit_menu = new wxMenu;
edit_menu->Append( ID_CLEAR, "Clear");
edit_menu->Append( ID_ADD_SAMPLE, "Example");
edit_menu->Append( ID_LONG_TEST, "Add many lines");
edit_menu->AppendSeparator();
edit_menu->Append(ID_WRAP, "Wrap mode", "Activate wrapping at pixel 200.");
edit_menu->Append(ID_NOWRAP, "No-wrap mode", "Deactivate wrapping.");
edit_menu->AppendSeparator();
edit_menu->Append(ID_COPY, "Copy", "Copy text to clipboard.");
edit_menu->Append(ID_PASTE,"Paste", "Paste text from clipboard.");
menu_bar->Append(edit_menu, "Edit" );
#ifndef __WXMSW__
menu_bar->Show( TRUE );
#endif // MSW
SetMenuBar( menu_bar );
m_lwin = new wxLayoutWindow(this);
m_lwin->SetMouseTracking(true);
m_lwin->SetEditable(true);
m_lwin->SetWrapMargin(40);
m_lwin->Clear(wxROMAN,16,wxNORMAL,wxNORMAL, false);
m_lwin->SetFocus();
};
void
MyFrame::AddSampleText(wxLayoutList *llist)
{
llist->SetFont(wxROMAN,16,wxNORMAL,wxNORMAL, false);
llist->Insert("--");
llist->LineBreak();
llist->SetFont(wxROMAN);
llist->Insert("The quick brown fox jumps over the lazy dog.");
llist->LineBreak();
llist->Insert("Hello ");
llist->Insert(new wxLayoutObjectIcon(new wxICON(Micon)));
llist->SetFontWeight(wxBOLD);
llist->Insert("World! ");
llist->SetFontWeight(wxNORMAL);
llist->Insert("The quick brown fox jumps...");
llist->LineBreak();
llist->Insert("over the lazy dog.");
llist->SetFont(-1,-1,-1,-1,true);
llist->Insert("underlined");
llist->SetFont(-1,-1,-1,-1,false);
llist->SetFont(wxROMAN);
llist->Insert("This is ");
llist->SetFont(-1,-1,-1,wxBOLD); llist->Insert("BOLD "); llist->SetFont(-1,-1,-1,wxNORMAL);
llist->Insert("and ");
llist->SetFont(-1,-1,wxITALIC);
llist->Insert("italics ");
llist->SetFont(-1,-1,wxNORMAL);
llist->LineBreak();
llist->Insert("and ");
llist->SetFont(-1,-1,wxSLANT);
llist->Insert("slanted");
llist->SetFont(-1,-1,wxNORMAL);
llist->Insert(" text.");
llist->LineBreak();
llist->Insert("and ");
llist->SetFont(-1,-1,-1,-1,-1,"blue");
llist->Insert("blue");
llist->SetFont(-1,-1,-1,-1,-1,"black");
llist->Insert(" and ");
llist->SetFont(-1,-1,-1,-1,-1,"green","black");
llist->Insert("green on black");
llist->SetFont(-1,-1,-1,-1,-1,"black","white");
llist->Insert(" text.");
llist->LineBreak();
llist->SetFont(-1,-1,wxSLANT);
llist->Insert("Slanted");
llist->SetFont(-1,-1,wxNORMAL);
llist->Insert(" and normal text and ");
llist->SetFont(-1,-1,wxSLANT);
llist->Insert("slanted");
llist->SetFont(-1,-1,wxNORMAL);
llist->Insert(" again.");
llist->LineBreak();
// add some more text for testing:
llist->Insert("And here the source for the test program:");
llist->LineBreak();
llist->SetFont(wxTELETYPE,16);
char buffer[1024];
FILE *in = fopen("wxLayout.cpp","r");
if(in)
{
for(;;)
{
fgets(buffer,1024,in);
if(feof(in))
break;
llist->Insert(buffer);
llist->LineBreak();
}
}
llist->MoveCursorTo(wxPoint(0,0));
m_lwin->SetDirty();
m_lwin->Refresh();
}
void
MyFrame::Clear(void)
{
m_lwin->Clear(wxROMAN,16,wxNORMAL,wxNORMAL, false);
}
void MyFrame::OnCommand( wxCommandEvent &event )
{
switch (event.GetId())
{
case ID_QUIT:
Close( TRUE );
break;
case ID_PRINT:
{
wxPrinter printer;
wxLayoutPrintout printout(m_lwin->GetLayoutList(),_("M: Printout"));
if (! printer.Print(this, &printout, TRUE))
wxMessageBox(
_("There was a problem with printing the message:\n"
"perhaps your current printer is not set up correctly?"),
_("Printing"), wxOK);
}
break;
case ID_NOWRAP:
case ID_WRAP:
m_lwin->SetWrapMargin(event.GetId() == ID_NOWRAP ? 0 : 40);
break;
case ID_ADD_SAMPLE:
AddSampleText(m_lwin->GetLayoutList());
break;
case ID_CLEAR:
Clear();
break;
case ID_CLICK:
cerr << "Received click event." << endl;
break;
case ID_PASTE:
m_lwin->Paste();
break;
case ID_COPY:
m_lwin->Copy();
break;
case ID_HTML:
{
wxLayoutExportObject *export;
wxLayoutExportStatus status(m_lwin->GetLayoutList());
while((export = wxLayoutExport( &status,
WXLO_EXPORT_AS_HTML)) != NULL)
{
if(export->type == WXLO_EXPORT_HTML)
cout << *(export->content.text);
else
cout << "<!--UNKNOWN OBJECT>";
delete export;
}
}
break;
case ID_TEXT:
{
wxLayoutExportObject *export;
wxLayoutExportStatus status(m_lwin->GetLayoutList());
while((export = wxLayoutExport( &status, WXLO_EXPORT_AS_TEXT)) != NULL)
{
if(export->type == WXLO_EXPORT_TEXT)
cout << *(export->content.text);
else
cout << "<!--UNKNOWN OBJECT>";
delete export;
}
}
break;
case ID_LONG_TEST:
{
wxString line;
wxLayoutList *llist = m_lwin->GetLayoutList();
for(int i = 1; i < 5000; i++)
{
line.Printf("This is line number %d.", i);
llist->Insert(line);
llist->LineBreak();
}
llist->MoveCursorTo(wxPoint(0,0));
m_lwin->SetDirty();
m_lwin->Refresh();
break;
}
}
};
void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
{
#ifdef __WXMSW__
wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
#else
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
#endif
wxPrinter printer;
wxLayoutPrintout printout( m_lwin->GetLayoutList(),"Printout from wxLayout");
if (! printer.Print(this, &printout, TRUE))
wxMessageBox(
"There was a problem printing.\nPerhaps your current printer is not set correctly?",
"Printing", wxOK);
}
void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event))
{
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
#ifdef OS_UNIX
wxPostScriptPrinter printer;
wxLayoutPrintout printout( m_lwin->GetLayoutList(),"My printout");
printer.Print(this, &printout, TRUE);
#endif
}
void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
{
#ifdef __WXMSW__
wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
#else
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
#endif
wxPrintData printData;
// Pass two printout objects: for preview, and possible printing.
wxPrintPreview *preview = new wxPrintPreview(new
wxLayoutPrintout(
m_lwin->GetLayoutList()), new wxLayoutPrintout( m_lwin->GetLayoutList()), & printData);
if (!preview->Ok())
{
delete preview;
wxMessageBox("There was a problem previewing.\nPerhaps your current printer is not set correctly?", "Previewing", wxOK);
return;
}
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
frame->Centre(wxBOTH);
frame->Initialize();
frame->Show(TRUE);
}
void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event))
{
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
wxPrintData printData;
// Pass two printout objects: for preview, and possible printing.
wxPrintPreview *preview = new wxPrintPreview(new wxLayoutPrintout( m_lwin->GetLayoutList()), new wxLayoutPrintout( m_lwin->GetLayoutList()), & printData);
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
frame->Centre(wxBOTH);
frame->Initialize();
frame->Show(TRUE);
}
void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
{
#ifdef OS_WIN
wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
#else
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
#endif
wxPrintDialog printerDialog(this, & m_PrintData);
printerDialog.ShowModal();
}
void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
{
#ifdef __WXMSW__
wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
#else
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
#endif
wxPageSetupData data;
#ifdef __WXMSW__
wxPageSetupDialog pageSetupDialog(this, & data);
#else
wxGenericPageSetupDialog pageSetupDialog(this, & data);
#endif
pageSetupDialog.ShowModal();
data = pageSetupDialog.GetPageSetupData();
}
void MyFrame::OnPrintSetupPS(wxCommandEvent& WXUNUSED(event))
{
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
wxPrintData data;
#ifdef __WXMSW__
wxPrintDialog printerDialog(this, & data);
#else
wxGenericPrintDialog printerDialog(this, & data);
#endif
printerDialog.ShowModal();
}
void MyFrame::OnPageSetupPS(wxCommandEvent& WXUNUSED(event))
{
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
wxPageSetupData data;
#ifdef __WXMSW__
wxPageSetupDialog pageSetupDialog(this, & data);
#else
wxGenericPageSetupDialog pageSetupDialog(this, & data);
#endif
pageSetupDialog.ShowModal();
}
//-----------------------------------------------------------------------------
// MyApp
//-----------------------------------------------------------------------------
MyApp::MyApp(void) :
wxApp( )
{
};
bool MyApp::OnInit(void)
{
wxFrame *frame = new MyFrame();
frame->Show( TRUE );
// wxSetAFMPath("/usr/local/src/wxWindows/misc/afm/");
return TRUE;
};

66
user/wxLayout/wxLayout.h Normal file
View File

@@ -0,0 +1,66 @@
/* -*- c++ -*- */
#ifndef __WXLAYOUTH__
#define __WXLAYOUTH__
#ifdef __GNUG__
#pragma interface
#endif
#include "wx/wx.h"
#include "wxllist.h"
#include "wxlwindow.h"
#include "wxlparser.h"
//-----------------------------------------------------------------------------
// derived classes
//-----------------------------------------------------------------------------
class MyFrame;
class MyApp;
//-----------------------------------------------------------------------------
// MyFrame
//-----------------------------------------------------------------------------
class MyFrame: public wxFrame
{
DECLARE_DYNAMIC_CLASS(MyFrame)
public:
MyFrame(void);
void AddSampleText(wxLayoutList *llist);
void Clear(void);
void OnCommand( wxCommandEvent &event );
void OnPrint(wxCommandEvent& event);
void OnPrintPreview(wxCommandEvent& event);
void OnPrintSetup(wxCommandEvent& event);
void OnPageSetup(wxCommandEvent& event);
void OnPrintPS(wxCommandEvent& event);
void OnPrintPreviewPS(wxCommandEvent& event);
void OnPrintSetupPS(wxCommandEvent& event);
void OnPageSetupPS(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
private:
wxLayoutWindow *m_lwin;
wxPrintData m_PrintData;
};
//-----------------------------------------------------------------------------
// MyApp
//-----------------------------------------------------------------------------
class MyApp: public wxApp
{
public:
MyApp(void);
virtual bool OnInit(void);
};
#endif // __WXCONVERTH__

1975
user/wxLayout/wxllist.cpp Normal file

File diff suppressed because it is too large Load Diff

1003
user/wxLayout/wxllist.h Normal file

File diff suppressed because it is too large Load Diff

253
user/wxLayout/wxlparser.cpp Normal file
View File

@@ -0,0 +1,253 @@
/*-*- c++ -*-********************************************************
* wxlparser.h : parsers, import/export for wxLayoutList *
* *
* (C) 1998,1999 by Karsten Ball<6C>der (Ballueder@usa.net) *
* *
* $Id$
*******************************************************************/
#ifdef __GNUG__
# pragma implementation "wxlparser.h"
#endif
#include "Mpch.h"
#ifdef M_PREFIX
# include "gui/wxllist.h"
# include "gui/wxlparser.h"
#else
# include "wxllist.h"
# include "wxlparser.h"
#endif
#define BASE_SIZE 12
inline static bool IsEndOfLine(const char *p, int mode)
{
// in addition to Unix EOL convention we also (but not instead) understand
// the DOS one under Windows
return
(mode == WXLO_EXPORT_WITH_CRLF) ?
((*p == '\r') && (*(p + 1) == '\n'))
:
(((*p == '\r') && (*(p + 1) == '\n'))||(*p == '\n'));
}
void wxLayoutImportText(wxLayoutList *list, wxString const &str, int withflag)
{
if(str.Length() == 0)
return;
char * cptr = (char *)str.c_str(); // string gets changed only temporarily
const char * begin = cptr;
char backup;
for(;;)
{
begin = cptr;
while( *cptr && !IsEndOfLine(cptr, withflag) )
cptr++;
backup = *cptr;
*cptr = '\0';
list->Insert(begin);
*cptr = backup;
// check if it's the end of this line
if ( IsEndOfLine(cptr, withflag) )
{
// if it was "\r\n", skip the following '\n'
if ( *cptr == '\r' )
cptr++;
list->LineBreak();
}
else if(backup == '\0') // reached end of string
break;
cptr++;
}
}
static
wxString wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd,
wxLayoutStyleInfo *styleInfo)
{
static char buffer[20];
wxString html;
wxLayoutStyleInfo si;
cmd.GetStyle(&si);
int size, sizecount;
html += "<font ";
html +="color=";
sprintf(buffer,"\"#%02X%02X%02X\"", si.fg_red,si.fg_green,si.fg_blue);
html += buffer;
html += " bgcolor=";
sprintf(buffer,"\"#%02X%02X%02X\"", si.bg_red,si.bg_green,si.bg_blue);
html += buffer;
switch(si.family)
{
case wxSWISS:
case wxMODERN:
html += " face=\"Arial,Helvetica\""; break;
case wxROMAN:
html += " face=\"Times New Roman, Times\""; break;
case wxTELETYPE:
html += " face=\"Courier New, Courier\""; break;
default:
;
}
size = BASE_SIZE; sizecount = 0;
while(size < si.size && sizecount < 5)
{
sizecount ++;
size = (size*12)/10;
}
while(size > si.size && sizecount > -5)
{
sizecount --;
size = (size*10)/12;
}
html += "size=";
sprintf(buffer,"%+1d", sizecount);
html += buffer;
html +=">";
if(styleInfo != NULL)
html ="</font>"+html; // terminate any previous font command
if((si.weight == wxBOLD) && ( (!styleInfo) || (styleInfo->weight != wxBOLD)))
html += "<b>";
else
if(si.weight != wxBOLD && ( styleInfo && (styleInfo->weight == wxBOLD)))
html += "</b>";
if(si.style == wxSLANT)
si.style = wxITALIC; // the same for html
if((si.style == wxITALIC) && ( (!styleInfo) || (styleInfo->style != wxITALIC)))
html += "<i>";
else
if(si.style != wxITALIC && ( styleInfo && (styleInfo->style == wxITALIC)))
html += "</i>";
if(si.underline && ( (!styleInfo) || ! styleInfo->underline))
html += "<u>";
else if(si.underline == false && ( styleInfo && styleInfo->underline))
html += "</u>";
*styleInfo = si; // update last style info
return html;
}
wxLayoutExportStatus::wxLayoutExportStatus(wxLayoutList *list)
{
list->GetDefaults()->GetStyle(&m_si);
m_line = list->GetFirstLine();
m_iterator = m_line->GetFirstObject();
}
#define WXLO_IS_TEXT(type) \
( type == WXLO_TYPE_TEXT \
|| (type == WXLO_TYPE_CMD \
&& mode == WXLO_EXPORT_AS_HTML))
wxLayoutExportObject *wxLayoutExport(wxLayoutExportStatus *status,
int mode, int flags)
{
wxASSERT(status);
wxLayoutExportObject * export;
if(status->m_iterator == NULLIT) // end of line
{
if(!status->m_line || status->m_line->GetNextLine() == NULL)
// reached end of list
return NULL;
}
export = new wxLayoutExportObject();
wxLayoutObjectType type;
if(status->m_iterator != NULLIT)
{
type = (** status->m_iterator).GetType();
if( mode == WXLO_EXPORT_AS_OBJECTS || ! WXLO_IS_TEXT(type)) // simple case
{
export->type = WXLO_EXPORT_OBJECT;
export->content.object = *status->m_iterator;
status->m_iterator++;
return export;
}
}
else
{ // iterator == NULLIT
if(mode == WXLO_EXPORT_AS_OBJECTS)
{
export->type = WXLO_EXPORT_EMPTYLINE;
export->content.object = NULL; //empty line
status->m_line = status->m_line->GetNextLine();
if(status->m_line)
status->m_iterator = status->m_line->GetFirstObject();
return export;
}
else
type = WXLO_TYPE_TEXT;
}
wxString *str = new wxString();
// text must be concatenated
for(;;)
{
while(status->m_iterator == NULLIT)
{
if(flags & WXLO_EXPORT_AS_HTML)
*str += "<br>";
if(flags & WXLO_EXPORT_WITH_CRLF)
*str += "\r\n";
else
*str += '\n';
status->m_line = status->m_line->GetNextLine();
if(status->m_line)
status->m_iterator = status->m_line->GetFirstObject();
else
break; // end of list
}
if(! status->m_line) // reached end of list, fall through
break;
type = (** status->m_iterator).GetType();
if(type == WXLO_TYPE_ICON)
break;
switch(type)
{
case WXLO_TYPE_TEXT:
*str += ((wxLayoutObjectText *)*status->m_iterator)->GetText();
break;
case WXLO_TYPE_CMD:
wxASSERT_MSG( mode == WXLO_EXPORT_AS_HTML,
"reached cmd object in text mode" );
*str += wxLayoutExportCmdAsHTML(*(wxLayoutObjectCmd const
*)*status->m_iterator, & status->m_si);
break;
default: // ignore icons
;
}
status->m_iterator++;
}
export->type = (mode == WXLO_EXPORT_AS_HTML)
? WXLO_EXPORT_HTML : WXLO_EXPORT_TEXT;
export->content.text = str;
return export;
}

85
user/wxLayout/wxlparser.h Normal file
View File

@@ -0,0 +1,85 @@
/*-*- c++ -*-********************************************************
* wxlparser.h : parsers, import/export for wxLayoutList *
* *
* (C) 1998 by Karsten Ball<6C>der (Ballueder@usa.net) *
* *
* $Id$
*******************************************************************/
#ifndef WXLPARSER_H
# define WXLPARSER_H
#ifdef __GNUG__
# pragma interface "wxlparser.h"
#endif
#ifndef NULL
# define NULL 0
#endif
enum wxLayoutExportType
{
WXLO_EXPORT_TEXT,
WXLO_EXPORT_HTML,
WXLO_EXPORT_OBJECT,
// this can be caused by empty lines:
WXLO_EXPORT_EMPTYLINE
};
enum wxLayoutExportMode
{
WXLO_EXPORT_AS_TEXT = 0x00,
WXLO_EXPORT_AS_TEXT_AND_COMMANDS = 0x01,
WXLO_EXPORT_AS_HTML = 0x02,
WXLO_EXPORT_AS_OBJECTS = 0x03,
// non 0:
WXLO_EXPORT_WITH_CRLF = 0x10,
WXLO_EXPORT_WITH_LF_ONLY = 0x20
};
struct wxLayoutExportObject
{
wxLayoutExportType type;
union
{
wxString *text;
wxLayoutObject *object;
}content;
~wxLayoutExportObject()
{
if(type == WXLO_EXPORT_TEXT || type == WXLO_EXPORT_HTML)
delete content.text;
}
};
struct wxLayoutExportStatus
{
wxLayoutExportStatus(wxLayoutList *list);
wxLayoutLine * m_line;
wxLOiterator m_iterator;
wxLayoutStyleInfo m_si;
};
#ifdef OS_WIN
/// import text into a wxLayoutList (including linefeeds):
void wxLayoutImportText(wxLayoutList *list, wxString const &str,
int withflag = WXLO_EXPORT_WITH_CRLF);
wxLayoutExportObject *wxLayoutExport(wxLayoutExportStatus *status,
int mode = WXLO_EXPORT_AS_TEXT,
int flags =
WXLO_EXPORT_WITH_CRLF);
#else
/// import text into a wxLayoutList (including linefeeds):
void wxLayoutImportText(wxLayoutList *list, wxString const &str,
int withflag = WXLO_EXPORT_WITH_LF_ONLY);
/// export text in a given format
wxLayoutExportObject *wxLayoutExport(wxLayoutExportStatus *status,
int mode = WXLO_EXPORT_AS_TEXT,
int flags =
WXLO_EXPORT_WITH_LF_ONLY);
#endif
#endif //WXLPARSER_H

683
user/wxLayout/wxlwindow.cpp Normal file
View File

@@ -0,0 +1,683 @@
/*-*- c++ -*-********************************************************
* wxLwindow.h : a scrolled Window for displaying/entering rich text*
* *
* (C) 1998, 1999 by Karsten Ball<6C>der (Ballueder@usa.net) *
* *
* $Id$
*******************************************************************/
#ifdef __GNUG__
# pragma implementation "wxlwindow.h"
#endif
#include "wx/wxprec.h"
#ifdef __BORLANDC__
# pragma hdrstop
#endif
#include "Mpch.h"
#ifdef M_BASEDIR
# ifndef USE_PCH
# include "Mcommon.h"
# include "gui/wxMenuDefs.h"
# include "gui/wxMApp.h"
# endif // USE_PCH
# include "gui/wxlwindow.h"
# include "gui/wxlparser.h"
#else
# ifdef __WXMSW__
# include <windows.h>
# undef FindWindow
# undef GetCharWidth
# undef StartDoc
# endif
# include "wxlwindow.h"
# include "wxlparser.h"
#endif
#include <wx/clipbrd.h>
#include <wx/textctrl.h>
#include <wx/dataobj.h>
#include <ctype.h>
#ifdef WXLAYOUT_DEBUG
# define WXLO_DEBUG(x) wxLogDebug x
#else
# define WXLO_DEBUG(x)
#endif
/// offsets to put a nice frame around text
#define WXLO_XOFFSET 4
#define WXLO_YOFFSET 4
/// offset to the right and bottom for when to redraw scrollbars
#define WXLO_ROFFSET 20
#define WXLO_BOFFSET 20
BEGIN_EVENT_TABLE(wxLayoutWindow,wxScrolledWindow)
EVT_PAINT (wxLayoutWindow::OnPaint)
EVT_CHAR (wxLayoutWindow::OnChar)
EVT_KEY_UP (wxLayoutWindow::OnKeyUp)
EVT_LEFT_DOWN(wxLayoutWindow::OnLeftMouseClick)
EVT_RIGHT_DOWN(wxLayoutWindow::OnRightMouseClick)
EVT_LEFT_DCLICK(wxLayoutWindow::OnMouseDblClick)
EVT_MOTION (wxLayoutWindow::OnMouseMove)
EVT_MENU_RANGE(WXLOWIN_MENU_FIRST, WXLOWIN_MENU_LAST, wxLayoutWindow::OnMenu)
EVT_SET_FOCUS(wxLayoutWindow::OnSetFocus)
EVT_KILL_FOCUS(wxLayoutWindow::OnKillFocus)
END_EVENT_TABLE()
wxLayoutWindow::wxLayoutWindow(wxWindow *parent)
: wxScrolledWindow(parent, -1, wxDefaultPosition, wxDefaultSize,
wxHSCROLL | wxVSCROLL | wxBORDER)
{
m_Editable = false;
m_doSendEvents = false;
m_ViewStartX = 0; m_ViewStartY = 0;
m_DoPopupMenu = true;
m_PopupMenu = MakeFormatMenu();
m_memDC = new wxMemoryDC;
m_bitmap = new wxBitmap(4,4);
m_bitmapSize = wxPoint(4,4);
m_llist = new wxLayoutList();
m_BGbitmap = NULL;
m_ScrollToCursor = false;
SetWrapMargin(0);
wxPoint max = m_llist->GetSize();
SetScrollbars(10, 20 /*lineHeight*/, max.x/10+1, max.y/20+1);
EnableScrolling(true,true);
m_maxx = max.x; m_maxy = max.y;
m_Selecting = false;
SetCursor(wxCURSOR_IBEAM);
SetDirty();
}
wxLayoutWindow::~wxLayoutWindow()
{
delete m_memDC; // deletes bitmap automatically (?)
delete m_bitmap;
delete m_llist;
delete m_PopupMenu;
SetBackgroundBitmap(NULL);
}
#ifdef __WXMSW__
long
wxLayoutWindow::MSWGetDlgCode()
{
// if we don't return this, we won't get OnChar() events for TABs and ENTER
return DLGC_WANTCHARS | DLGC_WANTARROWS | DLGC_WANTMESSAGE;
}
#endif //MSW
void
wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
{
wxPaintDC dc( this );
PrepareDC( dc );
SetFocus();
wxPoint findPos;
findPos.x = dc.DeviceToLogicalX(event.GetX());
findPos.y = dc.DeviceToLogicalY(event.GetY());
findPos.x -= WXLO_XOFFSET;
findPos.y -= WXLO_YOFFSET;
if(findPos.x < 0) findPos.x = 0;
if(findPos.y < 0) findPos.y = 0;
m_ClickPosition = wxPoint(event.GetX(), event.GetY());
wxPoint cursorPos;
bool found;
wxLayoutObject *obj = m_llist->FindObjectScreen(dc, findPos,
&cursorPos, &found);
//has the mouse only been moved?
if(eventId == WXLOWIN_MENU_MOUSEMOVE)
{
// found is only true if we are really over an object, not just
// behind it
if(found && obj && obj->GetUserData() != NULL)
{
if(!m_HandCursor)
SetCursor(wxCURSOR_HAND);
m_HandCursor = TRUE;
}
else
{
if(m_HandCursor)
SetCursor(wxCURSOR_IBEAM);
m_HandCursor = FALSE;
}
return;
}
// always move cursor to mouse click:
if(obj && eventId == WXLOWIN_MENU_LCLICK)
{
m_llist->MoveCursorTo(cursorPos);
ScrollToCursor();
Refresh(FALSE); // DoPaint suppresses flicker under GTK
}
if(!m_doSendEvents) // nothing to do
return;
// only do the menu if activated, editable and not on a clickable object
if(eventId == WXLOWIN_MENU_RCLICK
&& IsEditable()
&& (! obj || (obj && obj->GetUserData() == NULL))
)
{
PopupMenu(m_PopupMenu, m_ClickPosition.x, m_ClickPosition.y);
return;
}
// find the object at this position
if(obj)
{
wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, eventId);
commandEvent.SetEventObject( this );
commandEvent.SetClientData((char *)obj);
GetEventHandler()->ProcessEvent(commandEvent);
}
}
/*
* Some simple keyboard handling.
*/
void
wxLayoutWindow::OnChar(wxKeyEvent& event)
{
#ifdef WXLAYOUT_DEBUG
if(event.KeyCode() == WXK_F1)
{
m_llist->Debug();
return;
}
#endif
long keyCode = event.KeyCode();
if(m_Selecting && ! event.ShiftDown())
{
m_llist->EndSelection();
m_Selecting = false;
}
else
if(! m_Selecting && event.ShiftDown())
{
switch(keyCode)
{
case WXK_UP:
case WXK_DOWN:
case WXK_RIGHT:
case WXK_LEFT:
case WXK_PRIOR:
case WXK_NEXT:
case WXK_HOME:
case WXK_END:
m_Selecting = true;
m_llist->StartSelection();
break;
default:
;
}
}
/* These two nested switches work like this:
The first one processes all non-editing keycodes, to move the
cursor, etc. It's default will process all keycodes causing
modifications to the buffer, but only if editing is allowed.
*/
switch(keyCode)
{
case WXK_RIGHT:
m_llist->MoveCursorHorizontally(1);
break;
case WXK_LEFT:
m_llist->MoveCursorHorizontally(-1);
break;
case WXK_UP:
m_llist->MoveCursorVertically(-1);
break;
case WXK_DOWN:
m_llist->MoveCursorVertically(1);
break;
case WXK_PRIOR:
m_llist->MoveCursorVertically(-20);
break;
case WXK_NEXT:
m_llist->MoveCursorVertically(20);
break;
case WXK_HOME:
m_llist->MoveCursorToBeginOfLine();
break;
case WXK_END:
m_llist->MoveCursorToEndOfLine();
break;
default:
if(keyCode == 'c' && event.ControlDown())
Copy();
if( IsEditable() )
{
/* First, handle control keys */
if(event.ControlDown() && ! event.AltDown())
{
switch(keyCode)
{
case WXK_DELETE :
case 'd':
m_llist->Delete(1);
break;
case 'y':
m_llist->DeleteLines(1);
break;
case 'h': // like backspace
if(m_llist->MoveCursorHorizontally(-1)) m_llist->Delete(1);
break;
case 'u':
m_llist->DeleteToBeginOfLine();
break;
case 'k':
m_llist->DeleteToEndOfLine();
break;
case 'v':
Paste();
break;
#ifdef WXLAYOUT_DEBUG
case WXK_F1:
m_llist->SetFont(-1,-1,-1,-1,true); // underlined
break;
#endif
default:
;
}
}
// ALT only:
else if( event.AltDown() && ! event.ControlDown() )
{
switch(keyCode)
{
case WXK_DELETE:
case 'd':
m_llist->DeleteWord();
break;
default:
;
}
}
// no control keys:
else if ( ! event.AltDown() && ! event.ControlDown())
{
switch(keyCode)
{
case WXK_INSERT:
if(event.ShiftDown())
Paste();
break;
case WXK_DELETE :
m_llist->Delete(1);
break;
case WXK_BACK: // backspace
if(m_llist->MoveCursorHorizontally(-1)) m_llist->Delete(1);
break;
case WXK_RETURN:
if(m_WrapMargin > 0)
m_llist->WrapLine(m_WrapMargin);
m_llist->LineBreak();
break;
default:
if((!(event.ControlDown() || event.AltDown() || event.MetaDown()))
&& (keyCode < 256 && keyCode >= 32)
)
{
wxString tmp;
tmp += keyCode;
if(m_WrapMargin > 0 && isspace(keyCode))
m_llist->WrapLine(m_WrapMargin);
m_llist->Insert(tmp);
}
break;
}
}
SetDirty();
SetModified();
}// if(IsEditable())
}// first switch()
ScrollToCursor();
wxRect r = *m_llist->GetUpdateRect();
DoPaint(&r);
}
void
wxLayoutWindow::OnKeyUp(wxKeyEvent& event)
{
if(event.KeyCode() == WXK_SHIFT && m_llist->IsSelecting())
m_llist->EndSelection();
event.Skip();
}
void
wxLayoutWindow::ScrollToCursor(void)
{
wxClientDC dc( this );
PrepareDC( dc );
int x0,y0,x1,y1, dx, dy;
// Calculate where the top of the visible area is:
ViewStart(&x0,&y0);
GetScrollPixelsPerUnit(&dx, &dy);
x0 *= dx; y0 *= dy;
// Get the size of the visible window:
GetClientSize(&x1,&y1);
wxASSERT(x1 > 0);
wxASSERT(y1 > 0);
// As we have the values anyway, use them to avoid unnecessary
// scrollbar updates.
if(x1 > m_maxx) m_maxx = x1;
if(y1 > m_maxy) m_maxy = y1;
/* Make sure that the scrollbars are at a position so that the
cursor is visible if we are editing. */
/** Scroll so that cursor is visible! */
WXLO_DEBUG(("m_ScrollToCursor = %d", (int) m_ScrollToCursor));
wxPoint cc = m_llist->GetCursorScreenPos(*m_memDC);
if(cc.x < x0 || cc.y < y0
|| cc.x >= x0+(9*x1)/10 || cc.y >= y0+(9*y1/10)) // (9*x)/10 == 90%
{
int nx, ny;
nx = cc.x - x1/2; if(nx < 0) nx = 0;
ny = cc.y - y1/2; if(ny < 0) ny = 0;
Scroll(nx/dx,ny/dy); // new view start
x0 = nx; y0 = ny;
m_ScrollToCursor = false; // avoid recursion
}
}
void
wxLayoutWindow::OnPaint( wxPaintEvent &WXUNUSED(event)) // or: OnDraw(wxDC& dc)
{
wxRect region = GetUpdateRegion().GetBox();
InternalPaint(& region);
}
void
wxLayoutWindow::DoPaint(const wxRect *updateRect)
{
#ifdef __WXGTK__
InternalPaint(updateRect);
#else
Refresh(FALSE, updateRect); // Causes bad flicker under wxGTK!!!
#endif
}
void
wxLayoutWindow::InternalPaint(const wxRect *updateRect)
{
wxPaintDC dc( this );
PrepareDC( dc );
int x0,y0,x1,y1, dx, dy;
// Calculate where the top of the visible area is:
ViewStart(&x0,&y0);
GetScrollPixelsPerUnit(&dx, &dy);
x0 *= dx; y0 *= dy;
// Get the size of the visible window:
GetClientSize(&x1,&y1);
wxASSERT(x1 > 0);
wxASSERT(y1 > 0);
// As we have the values anyway, use them to avoid unnecessary
// scrollbar updates.
if(x1 > m_maxx) m_maxx = x1;
if(y1 > m_maxy) m_maxy = y1;
WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
updateRect->x, updateRect->y,
updateRect->x+updateRect->width,
updateRect->y+updateRect->height));
if(IsDirty())
ResizeScrollbars();
/* Check whether the window has grown, if so, we need to reallocate
the bitmap to be larger. */
if(x1 > m_bitmapSize.x || y1 > m_bitmapSize.y)
{
wxASSERT(m_bitmapSize.x > 0);
wxASSERT(m_bitmapSize.y > 0);
m_memDC->SelectObject(wxNullBitmap);
delete m_bitmap;
m_bitmapSize = wxPoint(x1,y1);
m_bitmap = new wxBitmap(x1,y1);
m_memDC->SelectObject(*m_bitmap);
}
m_memDC->SetDeviceOrigin(0,0);
m_memDC->SetBrush(wxBrush(m_llist->GetDefaults()->GetBGColour(),wxSOLID));
m_memDC->SetPen(wxPen(m_llist->GetDefaults()->GetBGColour(),
0,wxTRANSPARENT));
m_memDC->SetLogicalFunction(wxCOPY);
/* Either fill the background with the background bitmap, or clear
it. */
if(m_BGbitmap)
{
CoordType
y, x,
w = m_BGbitmap->GetWidth(),
h = m_BGbitmap->GetHeight();
for(y = 0; y < y1; y+=h)
for(x = 0; x < x1; x+=w)
m_memDC->DrawBitmap(*m_BGbitmap, x, y);
m_memDC->SetBackgroundMode(wxTRANSPARENT);
}
else
{
// clear the background: (must not be done if we use the update rectangle!)
m_memDC->SetBackgroundMode(wxSOLID);
m_memDC->DrawRectangle(0,0,x1, y1);
}
/* This is the important bit: we tell the list to draw itself: */
WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
updateRect->x, updateRect->y,
updateRect->x+updateRect->width,
updateRect->y+updateRect->height));
// Device origins on the memDC are suspect, we translate manually
// with the translate parameter of Draw().
wxPoint offset(-x0+WXLO_XOFFSET,-y0+WXLO_YOFFSET);
m_llist->Draw(*m_memDC,offset, y0, y0+y1);
// We start calculating a new update rect before drawing the
// cursor, so that the cursor coordinates get included in the next
// update rectangle (although they are drawn on the memDC, this is
// needed to erase it):
m_llist->InvalidateUpdateRect();
m_llist->DrawCursor(*m_memDC,
m_HaveFocus && IsEditable(), // draw a thick
// cursor for editable windows with focus
offset);
// Now copy everything to the screen:
#if 0
// This somehow doesn't work, but even the following bit with the
// whole rect at once is still a bit broken I think.
wxRegionIterator ri ( GetUpdateRegion() );
if(ri)
while(ri)
{
WXLO_DEBUG(("UpdateRegion: %ld,%ld, %ld,%ld",
ri.GetX(),ri.GetY(),ri.GetW(),ri.GetH()));
dc.Blit(x0+ri.GetX(),y0+ri.GetY(),ri.GetW(),ri.GetH(),
m_memDC,ri.GetX(),ri.GetY(),wxCOPY,FALSE);
ri++;
}
else
#endif
{
// FIXME: Trying to copy only the changed parts, but it does not seem
// to work:
// x0 = updateRect->x; y0 = updateRect->y;
// if(updateRect->height < y1)
// y1 = updateRect->height;
// y1 += WXLO_YOFFSET; //FIXME might not be needed
dc.Blit(x0,y0,x1,y1,m_memDC,0,0,wxCOPY,FALSE);
}
ResetDirty();
m_ScrollToCursor = false;
}
// change the range and position of scrollbars
void
wxLayoutWindow::ResizeScrollbars(bool exact)
{
wxPoint max = m_llist->GetSize();
if(max.x > m_maxx || max.y > m_maxy
|| max.x > m_maxx-WXLO_ROFFSET || max.y > m_maxy-WXLO_BOFFSET
|| exact)
{
if(! exact)
{
// add an extra bit to the sizes to avoid future updates
max.x = max.x+WXLO_ROFFSET;
max.y = max.y+WXLO_BOFFSET;
}
ViewStart(&m_ViewStartX, &m_ViewStartY);
SetScrollbars(10, 20, max.x/10+1,max.y/20+1,m_ViewStartX,m_ViewStartY,true);
m_maxx = max.x; m_maxy = max.y;
}
}
void
wxLayoutWindow::Paste(void)
{
wxString text;
// Read some text
if (wxTheClipboard->Open())
{
wxTextDataObject data;
if (wxTheClipboard->IsSupported( data.GetFormat() ))
{
wxTheClipboard->GetData(&data);
text += data.GetText();
}
wxTheClipboard->Close();
}
#if 0
/* My attempt to get the primary selection, but it does not
work. :-( */
if(text.Length() == 0)
{
wxTextCtrl tmp_tctrl(this,-1);
tmp_tctrl.Paste();
text += tmp_tctrl.GetValue();
}
#endif
wxLayoutImportText( m_llist, text);
}
bool
wxLayoutWindow::Copy(void)
{
wxLayoutList *llist = m_llist->GetSelection();
if(! llist)
return FALSE;
wxString text;
wxLayoutExportObject *export;
wxLayoutExportStatus status(llist);
while((export = wxLayoutExport( &status, WXLO_EXPORT_AS_TEXT)) != NULL)
{
if(export->type == WXLO_EXPORT_TEXT)
text << *(export->content.text);
delete export;
}
delete llist;
// Read some text
if (wxTheClipboard->Open())
{
wxTextDataObject *data = new wxTextDataObject( text );
bool rc = wxTheClipboard->SetData( data );
wxTheClipboard->Close();
return rc;
}
return FALSE;
}
wxMenu *
wxLayoutWindow::MakeFormatMenu()
{
wxMenu *m = new wxMenu(_("Layout Menu"));
m->Append(WXLOWIN_MENU_LARGER ,_("&Larger"),_("Switch to larger font."), false);
m->Append(WXLOWIN_MENU_SMALLER ,_("&Smaller"),_("Switch to smaller font."), false);
m->AppendSeparator();
m->Append(WXLOWIN_MENU_UNDERLINE_ON, _("&Underline on"),_("Activate underline mode."), false);
m->Append(WXLOWIN_MENU_UNDERLINE_OFF,_("&Underline off"),_("Deactivate underline mode."), false);
m->Append(WXLOWIN_MENU_BOLD_ON ,_("&Bold on"),_("Activate bold mode."), false);
m->Append(WXLOWIN_MENU_BOLD_OFF ,_("&Bold off"),_("Deactivate bold mode."), false);
m->Append(WXLOWIN_MENU_ITALICS_ON ,_("&Italics on"),_("Activate italics mode."), false);
m->Append(WXLOWIN_MENU_ITALICS_OFF ,_("&Italics off"),_("Deactivate italics mode."), false);
m->AppendSeparator();
m->Append(WXLOWIN_MENU_ROMAN ,_("&Roman"),_("Switch to roman font."), false);
m->Append(WXLOWIN_MENU_TYPEWRITER,_("&Typewriter"),_("Switch to typewriter font."), false);
m->Append(WXLOWIN_MENU_SANSSERIF ,_("&Sans Serif"),_("Switch to sans serif font."), false);
return m;
}
void wxLayoutWindow::OnMenu(wxCommandEvent& event)
{
switch (event.GetId())
{
case WXLOWIN_MENU_LARGER:
m_llist->SetFontLarger(); break;
case WXLOWIN_MENU_SMALLER:
m_llist->SetFontSmaller(); break;
case WXLOWIN_MENU_UNDERLINE_ON:
m_llist->SetFontUnderline(true); break;
case WXLOWIN_MENU_UNDERLINE_OFF:
m_llist->SetFontUnderline(false); break;
case WXLOWIN_MENU_BOLD_ON:
m_llist->SetFontWeight(wxBOLD); break;
case WXLOWIN_MENU_BOLD_OFF:
m_llist->SetFontWeight(wxNORMAL); break;
case WXLOWIN_MENU_ITALICS_ON:
m_llist->SetFontStyle(wxITALIC); break;
case WXLOWIN_MENU_ITALICS_OFF:
m_llist->SetFontStyle(wxNORMAL); break;
case WXLOWIN_MENU_ROMAN:
m_llist->SetFontFamily(wxROMAN); break;
case WXLOWIN_MENU_TYPEWRITER:
m_llist->SetFontFamily(wxFIXED); break;
case WXLOWIN_MENU_SANSSERIF:
m_llist->SetFontFamily(wxSWISS); break;
}
}
void
wxLayoutWindow::OnSetFocus(wxFocusEvent &ev)
{
m_HaveFocus = true;
//FIXME: need argument DoPaint(); // to repaint the cursor
}
void
wxLayoutWindow::OnKillFocus(wxFocusEvent &ev)
{
m_HaveFocus = false;
//FIXME: need argument DoPaint(); // to repaint the cursor
}

210
user/wxLayout/wxlwindow.h Normal file
View File

@@ -0,0 +1,210 @@
/*-*- c++ -*-********************************************************
* wxLwindow.h : a scrolled Window for displaying/entering rich text*
* *
* (C) 1998,1999 by Karsten Ball<6C>der (Ballueder@usa.net) *
* *
* $Id$
*******************************************************************/
#ifndef WXLWINDOW_H
#define WXLWINDOW_H
#ifdef __GNUG__
# pragma interface "wxlwindow.h"
#endif
#ifndef USE_PCH
# include <wx/wx.h>
#endif
#include "wxllist.h"
#ifndef WXLOWIN_MENU_FIRST
# define WXLOWIN_MENU_FIRST 12000
#endif
enum
{
WXLOWIN_MENU_LARGER = WXLOWIN_MENU_FIRST,
WXLOWIN_MENU_SMALLER,
WXLOWIN_MENU_UNDERLINE_ON,
WXLOWIN_MENU_UNDERLINE_OFF,
WXLOWIN_MENU_BOLD_ON,
WXLOWIN_MENU_BOLD_OFF,
WXLOWIN_MENU_ITALICS_ON,
WXLOWIN_MENU_ITALICS_OFF,
WXLOWIN_MENU_ROMAN,
WXLOWIN_MENU_TYPEWRITER,
WXLOWIN_MENU_SANSSERIF,
WXLOWIN_MENU_RCLICK,
WXLOWIN_MENU_LCLICK,
WXLOWIN_MENU_DBLCLICK,
WXLOWIN_MENU_MOUSEMOVE,
WXLOWIN_MENU_LAST = WXLOWIN_MENU_MOUSEMOVE
};
/**
This class is a rich text editing widget.
*/
class wxLayoutWindow : public wxScrolledWindow
{
public:
/** Constructor.
@param parent parent window to display this panel in
*/
wxLayoutWindow(wxWindow *parent);
/// Destructor.
virtual ~wxLayoutWindow();
/**@name Editing functionality */
//@{
/// Clears the window and sets default parameters.
void Clear(int family = wxROMAN,
int size=12,
int style=wxNORMAL,
int weight=wxNORMAL,
int underline=0,
wxColour *fg=NULL,
wxColour *bg=NULL)
{
GetLayoutList()->Clear(family,size,style,weight,underline,fg,bg);
SetBackgroundColour(GetLayoutList()->GetDefaults()->GetBGColour());
ResizeScrollbars(true);
SetDirty();
SetModified(false);
wxRect r;
int w,h;
r.x = r.y = 0; GetSize(&w,&h);
r.width = w;
r.height = h;
DoPaint(&r);
}
/** Sets a background image, only used on screen, not on printouts.
@param bitmap a pointer to a wxBitmap or NULL to remove it
*/
void SetBackgroundBitmap(wxBitmap *bitmap = NULL)
{
if(m_BGbitmap) delete m_BGbitmap;
m_BGbitmap = bitmap;
}
/// Enable or disable editing, i.e. processing of keystrokes.
void SetEditable(bool toggle) { m_Editable = toggle; }
/// Query whether list can be edited by user.
bool IsEditable(void) const { return m_Editable; }
/// Pastes text from clipboard.
void Paste(void);
/// Copies selection to clipboard.
bool Copy(void);
//@}
void EnablePopup(bool enable = true) { m_DoPopupMenu = enable; }
/** Sets the wrap margin.
@param margin set this to 0 to disable it
*/
void SetWrapMargin(CoordType margin) { m_WrapMargin = margin; }
/** Redraws the window.
Internally, this stores the parameter and calls a refresh on
wxMSW, draws directly on wxGTK.
*/
void DoPaint(const wxRect *updateRect);
#ifdef __WXMSW__
virtual long MSWGetDlgCode();
#endif //MSW
/// if exact == false, assume 50% extra size for the future
void ResizeScrollbars(bool exact = false); // don't change this to true!
/// if the flag is true, we send events when user clicks on embedded objects
inline void SetMouseTracking(bool doIt = true) { m_doSendEvents = doIt; }
/* Returns a pointer to the wxLayoutList object.
@return the list
*/
wxLayoutList * GetLayoutList(void) { return m_llist; }
/**@name Callbacks */
//@{
void OnPaint(wxPaintEvent &event);
void OnChar(wxKeyEvent& event);
void OnKeyUp(wxKeyEvent& event);
void OnMenu(wxCommandEvent& event);
void OnLeftMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_LCLICK, event); }
void OnRightMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_RCLICK, event); }
void OnMouseDblClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_DBLCLICK, event); }
void OnMouseMove(wxMouseEvent &event) { OnMouse(WXLOWIN_MENU_MOUSEMOVE, event) ; }
void OnSetFocus(wxFocusEvent &ev);
void OnKillFocus(wxFocusEvent &ev);
//@}
/// Creates a wxMenu for use as a format popup.
static wxMenu * MakeFormatMenu(void);
/**@name Dirty flag handling for optimisations. */
//@{
/// Set dirty flag.
void SetDirty(void) { m_Dirty = true; }
/// Query whether window needs redrawing.
bool IsDirty(void) const { return m_Dirty; }
/// Reset dirty flag.
void ResetDirty(void) { m_Dirty = false; }
//@}
/// Redraws the window, used by DoPaint() or OnPaint().
void InternalPaint(const wxRect *updateRect);
/// Has list been modified/edited?
bool IsModified(void) const { return m_Modified; }
/// Mark list as modified or unchanged.
void SetModified(bool modified = true) { m_Modified = modified; }
protected:
/// generic function for mouse events processing
void OnMouse(int eventId, wxMouseEvent& event);
/// as the name says
void ScrollToCursor(void);
/// for sending events
wxWindow *m_Parent;
/// Shall we send events?
bool m_doSendEvents;
/// Where does the current view start?
int m_ViewStartX; int m_ViewStartY;
/// Do we currently have the focus?
bool m_HaveFocus;
/// do we handle clicks of the right mouse button?
bool m_DoPopupMenu;
/// Should InternalPaint() scroll to cursor.
bool m_ScrollToCursor;
/// Do we currently have a non-standard cursor?
bool m_HandCursor;
/// the menu
wxMenu * m_PopupMenu;
/// for derived classes, set when mouse is clicked
wxPoint m_ClickPosition;
/// for scrollbar calculations:
int m_maxx;
int m_maxy;
int m_lineHeight;
private:
/// The layout list to be displayed.
wxLayoutList *m_llist;
/// Can user edit the window?
bool m_Editable;
/// Are we currently building a selection with the keyboard?
bool m_Selecting;
/// wrap margin
CoordType m_WrapMargin;
/// Is list dirty (for redraws, internal use)?
bool m_Dirty;
/// Has list been edited?
bool m_Modified;
wxMemoryDC *m_memDC;
wxBitmap *m_bitmap;
wxPoint m_bitmapSize;
/// a pointer to a bitmap for the background
wxBitmap *m_BGbitmap;
DECLARE_EVENT_TABLE()
};
#endif