1998-06-29 08:44:36 -04:00
|
|
|
|
/*-*- c++ -*-********************************************************
|
|
|
|
|
* wxLayoutList.h - a formatted text rendering engine for wxWindows *
|
|
|
|
|
* *
|
|
|
|
|
* (C) 1998 by Karsten Ball<EFBFBD>der (Ballueder@usa.net) *
|
|
|
|
|
* *
|
|
|
|
|
* $Id$
|
|
|
|
|
*******************************************************************/
|
|
|
|
|
#ifndef WXLLIST_H
|
|
|
|
|
#define WXLLIST_H
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
# pragma interface "wxllist.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "kbList.h"
|
|
|
|
|
|
1998-08-12 04:33:34 -04:00
|
|
|
|
#include "wx/wx.h"
|
1998-10-24 14:08:20 -04:00
|
|
|
|
#include "wx/print.h"
|
|
|
|
|
#include "wx/printdlg.h"
|
|
|
|
|
#include "wx/generic/printps.h"
|
|
|
|
|
#include "wx/generic/prntdlgg.h"
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1998-07-12 11:02:44 -04:00
|
|
|
|
// skip the following defines if embedded in M application
|
1998-08-06 15:23:19 -04:00
|
|
|
|
#ifdef M_BASEDIR
|
|
|
|
|
# ifdef DEBUG
|
|
|
|
|
//# define WXLAYOUT_DEBUG
|
|
|
|
|
# endif
|
|
|
|
|
#else
|
|
|
|
|
// for testing only:
|
1998-07-12 11:02:44 -04:00
|
|
|
|
# define WXLAYOUT_DEBUG
|
1998-08-06 15:23:19 -04:00
|
|
|
|
// The wxLayout classes can be compiled with std::string instead of wxString
|
|
|
|
|
//# define USE_STD_STRING
|
1998-10-24 14:08:20 -04:00
|
|
|
|
# define WXMENU_LAYOUT_LCLICK 1111
|
|
|
|
|
# define WXMENU_LAYOUT_RCLICK 1112
|
|
|
|
|
# define WXMENU_LAYOUT_DBLCLICK 1113
|
1998-06-29 08:44:36 -04:00
|
|
|
|
#endif
|
|
|
|
|
|
1998-07-12 11:02:44 -04:00
|
|
|
|
#ifdef USE_STD_STRING
|
|
|
|
|
# include <string>
|
|
|
|
|
typedef std::string String;
|
|
|
|
|
# define Str(str)(str.c_str())
|
|
|
|
|
#else
|
|
|
|
|
typedef wxString String;
|
|
|
|
|
# define Str(str) str
|
|
|
|
|
#endif
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1998-10-27 04:55:07 -05:00
|
|
|
|
#define WXLO_DEFAULTFONTSIZE 12
|
|
|
|
|
|
1998-07-27 16:39:50 -04:00
|
|
|
|
/// Types of currently supported layout objects.
|
|
|
|
|
enum wxLayoutObjectType
|
1998-08-12 12:14:15 -04:00
|
|
|
|
{ WXLO_TYPE_INVALID = 0, WXLO_TYPE_TEXT, WXLO_TYPE_CMD, WXLO_TYPE_ICON, WXLO_TYPE_LINEBREAK };
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1998-07-27 16:39:50 -04:00
|
|
|
|
/// Type used for coordinates in drawing.
|
1998-06-29 08:44:36 -04:00
|
|
|
|
typedef long CoordType;
|
|
|
|
|
|
|
|
|
|
class wxLayoutList;
|
|
|
|
|
class wxLayoutObjectBase;
|
|
|
|
|
|
1998-08-12 04:33:34 -04:00
|
|
|
|
class wxDC;
|
|
|
|
|
class wxColour;
|
|
|
|
|
class wxFont;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1998-07-27 16:39:50 -04:00
|
|
|
|
/** The base class defining the interface to each object which can be
|
|
|
|
|
part of the layout. Each object needs to draw itself and calculate
|
|
|
|
|
its size.
|
|
|
|
|
*/
|
1998-06-29 08:44:36 -04:00
|
|
|
|
class wxLayoutObjectBase
|
|
|
|
|
{
|
|
|
|
|
public:
|
1998-10-24 14:08:20 -04:00
|
|
|
|
struct UserData
|
|
|
|
|
{
|
|
|
|
|
virtual ~UserData() { }
|
|
|
|
|
};
|
|
|
|
|
|
1998-07-27 16:39:50 -04:00
|
|
|
|
/// return the type of this object
|
1998-06-29 08:44:36 -04:00
|
|
|
|
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_INVALID; } ;
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/** Calculates the position etc of an object.
|
1998-06-29 08:44:36 -04:00
|
|
|
|
@param dc the wxDC to draw on
|
|
|
|
|
@param position where to draw the top left corner
|
|
|
|
|
@param baseLine the baseline for alignment, from top of box
|
|
|
|
|
*/
|
1998-10-24 14:08:20 -04:00
|
|
|
|
virtual void Layout(wxDC & dc,
|
|
|
|
|
wxPoint position,
|
1998-11-01 16:48:22 -05:00
|
|
|
|
CoordType baseLine)
|
|
|
|
|
{ m_Position = position; }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
|
|
|
|
/** Draws an object.
|
|
|
|
|
@param dc the wxDC to draw on
|
1998-10-25 06:08:43 -05:00
|
|
|
|
@param translation to be added to coordinates
|
1998-10-24 14:08:20 -04:00
|
|
|
|
*/
|
1998-10-25 06:08:43 -05:00
|
|
|
|
virtual void Draw(wxDC & dc, wxPoint const &translate) {}
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/** Calculates and returns the size of the object.
|
1998-07-27 16:39:50 -04:00
|
|
|
|
@param baseLine pointer where to store the baseline position of
|
|
|
|
|
this object (i.e. the height from the top of the box to the
|
|
|
|
|
baseline)
|
|
|
|
|
@return the size of the object's box in pixels
|
|
|
|
|
*/
|
1998-10-24 14:08:20 -04:00
|
|
|
|
virtual wxPoint GetSize(CoordType * baseLine = NULL) const
|
|
|
|
|
{ return wxPoint(0,0); }
|
|
|
|
|
|
|
|
|
|
/** Calculates and returns the position of the object.
|
|
|
|
|
@return the size of the object's box in pixels
|
|
|
|
|
*/
|
|
|
|
|
virtual wxPoint GetPosition(void) const { return m_Position; }
|
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/// returns the number of cursor positions occupied by this object
|
|
|
|
|
virtual CoordType CountPositions(void) const { return 1; }
|
|
|
|
|
|
1998-07-27 16:39:50 -04:00
|
|
|
|
/// constructor
|
1998-06-29 08:44:36 -04:00
|
|
|
|
wxLayoutObjectBase() { m_UserData = NULL; }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// delete the user data
|
1998-11-16 04:30:53 -05:00
|
|
|
|
virtual ~wxLayoutObjectBase() { if(m_UserData) delete m_UserData; }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1998-07-12 11:02:44 -04:00
|
|
|
|
#ifdef WXLAYOUT_DEBUG
|
1998-06-29 08:44:36 -04:00
|
|
|
|
virtual void Debug(void);
|
|
|
|
|
#endif
|
|
|
|
|
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// query whether coordinates have changed since last drawing
|
|
|
|
|
virtual bool IsDirty(void) const { return true; }
|
|
|
|
|
|
1998-07-27 16:39:50 -04:00
|
|
|
|
/** Tells the object about some user data. This data is associated
|
|
|
|
|
with the object and will be deleted at destruction time.
|
|
|
|
|
*/
|
1998-10-24 14:08:20 -04:00
|
|
|
|
void SetUserData(UserData *data) { m_UserData = data; }
|
1998-07-27 16:39:50 -04:00
|
|
|
|
/** Return the user data. */
|
1998-06-29 08:44:36 -04:00
|
|
|
|
void * GetUserData(void) const { return m_UserData; }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
private:
|
|
|
|
|
/// optional data for application's use
|
1998-10-24 14:08:20 -04:00
|
|
|
|
UserData *m_UserData;
|
|
|
|
|
protected:
|
|
|
|
|
wxPoint m_Position;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
};
|
|
|
|
|
|
1998-08-12 04:33:34 -04:00
|
|
|
|
/// Define a list type of wxLayoutObjectBase pointers.
|
|
|
|
|
KBLIST_DEFINE(wxLayoutObjectList, wxLayoutObjectBase);
|
|
|
|
|
|
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/// object for text block
|
|
|
|
|
class wxLayoutObjectText : public wxLayoutObjectBase
|
|
|
|
|
{
|
|
|
|
|
public:
|
1998-10-24 14:08:20 -04:00
|
|
|
|
wxLayoutObjectText(const String &txt);
|
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_TEXT; }
|
1998-10-25 06:08:43 -05:00
|
|
|
|
virtual void Layout(wxDC &dc, wxPoint position, CoordType
|
|
|
|
|
baseLine);
|
|
|
|
|
|
|
|
|
|
virtual void Draw(wxDC &dc, wxPoint const &translate);
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/** This returns the height and in baseLine the position of the
|
|
|
|
|
text's baseline within it's box. This is needed to properly
|
|
|
|
|
align text objects.
|
|
|
|
|
*/
|
1998-10-24 14:08:20 -04:00
|
|
|
|
virtual wxPoint GetSize(CoordType *baseLine = NULL) const;
|
|
|
|
|
|
1998-07-12 11:02:44 -04:00
|
|
|
|
#ifdef WXLAYOUT_DEBUG
|
1998-06-29 08:44:36 -04:00
|
|
|
|
virtual void Debug(void);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
virtual CoordType CountPositions(void) const { return strlen(m_Text.c_str()); }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
virtual bool IsDirty(void) const { return m_IsDirty; }
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
|
|
|
|
// for editing:
|
1998-07-12 11:02:44 -04:00
|
|
|
|
String & GetText(void) { return m_Text; }
|
|
|
|
|
void SetText(String const &text) { m_Text = text; }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
private:
|
1998-07-12 11:02:44 -04:00
|
|
|
|
String m_Text;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/// size of the box containing text
|
|
|
|
|
long m_Width, m_Height;
|
|
|
|
|
/// the position of the baseline counted from the top of the box
|
|
|
|
|
long m_BaseLine;
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// coordinates have changed
|
|
|
|
|
bool m_IsDirty;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// icon/pictures:
|
|
|
|
|
class wxLayoutObjectIcon : public wxLayoutObjectBase
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
wxLayoutObjectIcon(wxIcon *icon);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
wxLayoutObjectIcon(wxIcon const &icon);
|
|
|
|
|
|
|
|
|
|
~wxLayoutObjectIcon() { delete m_Icon; }
|
|
|
|
|
|
|
|
|
|
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_ICON; }
|
|
|
|
|
virtual void Layout(wxDC &dc, wxPoint position, CoordType baseLine);
|
1998-10-25 06:08:43 -05:00
|
|
|
|
virtual void Draw(wxDC &dc, wxPoint const &translate);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
|
|
|
|
virtual wxPoint GetSize(CoordType *baseLine = NULL) const;
|
|
|
|
|
virtual bool IsDirty(void) const { return m_IsDirty; }
|
1998-08-12 04:33:34 -04:00
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
private:
|
1998-08-12 04:33:34 -04:00
|
|
|
|
wxIcon *m_Icon;
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// coordinates have changed
|
|
|
|
|
bool m_IsDirty;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// for export to html:
|
|
|
|
|
struct wxLayoutStyleInfo
|
|
|
|
|
{
|
|
|
|
|
int size, family, style, weight;
|
|
|
|
|
bool underline;
|
|
|
|
|
unsigned fg_red, fg_green, fg_blue;
|
|
|
|
|
unsigned bg_red, bg_green, bg_blue;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// pseudo-object executing a formatting command in Draw()
|
|
|
|
|
class wxLayoutObjectCmd : public wxLayoutObjectBase
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_CMD; }
|
1998-10-25 06:08:43 -05:00
|
|
|
|
virtual void Draw(wxDC &dc, wxPoint const &translate);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
virtual void Layout(wxDC &dc, wxPoint position, CoordType baseLine);
|
1998-06-29 08:44:36 -04:00
|
|
|
|
wxLayoutObjectCmd(int size, int family, int style, int weight,
|
|
|
|
|
bool underline,
|
|
|
|
|
wxColour const *fg, wxColour const *bg);
|
|
|
|
|
~wxLayoutObjectCmd();
|
1998-07-29 06:34:11 -04:00
|
|
|
|
/// caller must free pointer:
|
1998-06-29 08:44:36 -04:00
|
|
|
|
wxLayoutStyleInfo *GetStyle(void) const ;
|
1998-07-29 06:34:11 -04:00
|
|
|
|
/// return the background colour for setting colour of window
|
|
|
|
|
wxColour const *GetBGColour(void) const { return m_ColourBG; }
|
1998-06-29 08:44:36 -04:00
|
|
|
|
private:
|
|
|
|
|
/// the font to use
|
|
|
|
|
wxFont *m_font;
|
|
|
|
|
/// foreground colour
|
|
|
|
|
wxColour const *m_ColourFG;
|
|
|
|
|
/// background colour
|
|
|
|
|
wxColour const *m_ColourBG;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// this object doesn't do anything at all
|
|
|
|
|
class wxLayoutObjectLineBreak : public wxLayoutObjectBase
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_LINEBREAK; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
1998-08-14 04:33:33 -04:00
|
|
|
|
class wxLayoutPrintout;
|
|
|
|
|
|
1998-10-25 06:08:43 -05:00
|
|
|
|
class wxLayoutMargins
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
wxLayoutMargins() { top = left = 0; bottom = right = -1; }
|
|
|
|
|
int top;
|
|
|
|
|
int left;
|
|
|
|
|
int bottom;
|
|
|
|
|
int right;
|
|
|
|
|
};
|
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/**
|
|
|
|
|
This class provides a high level abstraction to the wxFText
|
|
|
|
|
classes.
|
|
|
|
|
It handles most of the character events with its own callback
|
|
|
|
|
functions, providing an editing ability. All events which cannot be
|
|
|
|
|
handled get passed to the parent window's handlers.
|
|
|
|
|
*/
|
|
|
|
|
class wxLayoutList : public wxLayoutObjectList
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
wxLayoutList();
|
|
|
|
|
|
|
|
|
|
/// Destructor.
|
|
|
|
|
~wxLayoutList();
|
|
|
|
|
|
|
|
|
|
/// adds an object:
|
|
|
|
|
void AddObject(wxLayoutObjectBase *obj);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// adds a text object
|
1998-07-12 11:02:44 -04:00
|
|
|
|
void AddText(String const &txt);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// adds a line break
|
1998-06-29 08:44:36 -04:00
|
|
|
|
void LineBreak(void);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// sets font parameters
|
1998-06-29 08:44:36 -04:00
|
|
|
|
void SetFont(int family, int size, int style,
|
|
|
|
|
int weight, int underline,
|
|
|
|
|
wxColour const *fg,
|
|
|
|
|
wxColour const *bg);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// sets font parameters, colours by name
|
1998-06-29 08:44:36 -04:00
|
|
|
|
void SetFont(int family=-1, int size = -1, int style=-1,
|
|
|
|
|
int weight=-1, int underline = -1,
|
1998-10-24 14:08:20 -04:00
|
|
|
|
char const *fg = NULL,
|
|
|
|
|
char const *bg = NULL);
|
1998-10-30 05:14:58 -05:00
|
|
|
|
/// changes to the next larger font size
|
|
|
|
|
inline void SetFontLarger(void)
|
|
|
|
|
{ SetFont(-1,(12*m_FontPtSize)/10); }
|
|
|
|
|
/// changes to the next smaller font size
|
|
|
|
|
inline void SetFontSmaller(void)
|
|
|
|
|
{ SetFont(-1,(10*m_FontPtSize)/12); }
|
|
|
|
|
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// set font family
|
1998-07-12 11:02:44 -04:00
|
|
|
|
inline void SetFontFamily(int family) { SetFont(family); }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// set font size
|
1998-07-12 11:02:44 -04:00
|
|
|
|
inline void SetFontSize(int size) { SetFont(-1,size); }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// set font style
|
1998-07-12 11:02:44 -04:00
|
|
|
|
inline void SetFontStyle(int style) { SetFont(-1,-1,style); }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// set font weight
|
1998-07-12 11:02:44 -04:00
|
|
|
|
inline void SetFontWeight(int weight) { SetFont(-1,-1,-1,weight); }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// toggle underline flag
|
1998-07-12 11:02:44 -04:00
|
|
|
|
inline void SetFontUnderline(bool ul) { SetFont(-1,-1,-1,-1,(int)ul); }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// set font colours by name
|
|
|
|
|
inline void SetFontColour(char const *fg, char const *bg = NULL) { SetFont(-1,-1,-1,-1,-1,fg,bg); }
|
1998-07-12 11:02:44 -04:00
|
|
|
|
|
1998-11-19 15:34:59 -05:00
|
|
|
|
/** Sets the wrap margin in cursor positions.
|
|
|
|
|
@param n the wrap margin, -1 to disable auto wrap
|
|
|
|
|
*/
|
|
|
|
|
void SetWrapMargin(long n = -1);
|
|
|
|
|
|
|
|
|
|
/// Wraps the current line if word wrap is enabled.
|
|
|
|
|
void WrapLine(void);
|
1998-07-12 11:02:44 -04:00
|
|
|
|
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/** Re-layouts the list on a DC.
|
1998-10-25 06:08:43 -05:00
|
|
|
|
@param dc the dc to layout for
|
|
|
|
|
@param margins if not NULL, use these top and left margins
|
1998-06-29 08:44:36 -04:00
|
|
|
|
*/
|
1998-10-25 06:08:43 -05:00
|
|
|
|
void Layout(wxDC &dc, wxLayoutMargins *margins = NULL);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
|
|
|
|
/** Draw the list on a given DC.
|
1998-10-25 06:08:43 -05:00
|
|
|
|
@param dc the dc to layout for
|
|
|
|
|
@param fromLine the first graphics line from where to draw
|
|
|
|
|
@param toLine the last line at which to draw
|
|
|
|
|
@param start if != iterator(NULL) start drawing from here
|
1998-10-24 14:08:20 -04:00
|
|
|
|
*/
|
|
|
|
|
void Draw(wxDC &dc,
|
|
|
|
|
CoordType fromLine = -1,
|
|
|
|
|
CoordType toLine = -1,
|
1998-10-25 06:08:43 -05:00
|
|
|
|
iterator start = iterator(NULL),
|
|
|
|
|
wxPoint const &translate = wxPoint(0,0));
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/** Deletes at least to the end of line and redraws */
|
|
|
|
|
void EraseAndDraw(wxDC &dc, iterator start = iterator(NULL));
|
|
|
|
|
|
|
|
|
|
/** Finds the object occupying a certain screen position.
|
|
|
|
|
@return pointer to wxLayoutObjectBase or NULL if not found
|
|
|
|
|
*/
|
|
|
|
|
wxLayoutObjectBase *Find(wxPoint coords) const;
|
|
|
|
|
|
1998-07-12 11:02:44 -04:00
|
|
|
|
#ifdef WXLAYOUT_DEBUG
|
1998-06-29 08:44:36 -04:00
|
|
|
|
void Debug(void);
|
1998-08-13 06:03:26 -04:00
|
|
|
|
void ShowCurrentObject();
|
1998-06-29 08:44:36 -04:00
|
|
|
|
#endif
|
|
|
|
|
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// dirty?
|
|
|
|
|
bool IsDirty() const { return m_bModified; }
|
|
|
|
|
bool CursorMoved(void) const { return m_CursorMoved; }
|
|
|
|
|
|
|
|
|
|
/// called after the contents is saved, for example
|
|
|
|
|
void ResetDirty() { m_bModified = FALSE; }
|
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/// for access by wxLayoutWindow:
|
|
|
|
|
void GetSize(CoordType *max_x, CoordType *max_y,
|
|
|
|
|
CoordType *lineHeight);
|
|
|
|
|
|
1998-08-14 04:33:33 -04:00
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/**@name Functionality for editing */
|
|
|
|
|
//@{
|
|
|
|
|
/// set list editable or read only
|
1998-08-06 15:23:19 -04:00
|
|
|
|
void SetEditable(bool editable = true) { m_Editable = editable; }
|
|
|
|
|
/// return true if list is editable
|
|
|
|
|
bool IsEditable(void) const { return m_Editable; }
|
1998-08-12 12:14:15 -04:00
|
|
|
|
/// move cursor, returns true if it could move to the desired position
|
|
|
|
|
bool MoveCursor(int dx = 0, int dy = 0);
|
1998-10-30 05:14:58 -05:00
|
|
|
|
void SetCursor(wxPoint const &p) { m_CursorPos = p; }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
void DrawCursor(wxDC &dc, bool erase = false);
|
|
|
|
|
|
|
|
|
|
/// Get current cursor position cursor coords
|
1998-10-30 05:14:58 -05:00
|
|
|
|
wxPoint GetCursor(void) const { return m_CursorPos; }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// Gets graphical coordinates of cursor
|
|
|
|
|
wxPoint GetCursorCoords(void) const { return m_CursorCoords; }
|
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/// delete one or more cursor positions
|
|
|
|
|
void Delete(CoordType count = 1);
|
1998-07-12 11:02:44 -04:00
|
|
|
|
void Insert(String const &text);
|
1998-06-29 08:44:36 -04:00
|
|
|
|
void Insert(wxLayoutObjectBase *obj);
|
1998-10-27 04:55:07 -05:00
|
|
|
|
void Clear(int family = wxROMAN, int size=WXLO_DEFAULTFONTSIZE, int style=wxNORMAL, int weight=wxNORMAL,
|
1998-07-12 11:02:44 -04:00
|
|
|
|
int underline=0, char const *fg="black", char const *bg="white");
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1998-10-25 06:08:43 -05:00
|
|
|
|
/// return a pointer to the default settings (dangerous, why?) FIXME:
|
1998-07-29 09:57:51 -04:00
|
|
|
|
wxLayoutObjectCmd const *GetDefaults(void) const { return m_DefaultSetting ; }
|
|
|
|
|
|
1998-11-19 15:34:59 -05:00
|
|
|
|
/// returns the iterator for the object under the cursor
|
|
|
|
|
wxLayoutObjectList::iterator GetCurrentObject(CoordType *offset =
|
|
|
|
|
NULL)
|
|
|
|
|
{ if(offset) *offset = m_CursorOffset; return m_CursorObject; }
|
|
|
|
|
|
1998-08-12 12:14:15 -04:00
|
|
|
|
// get the length of the line with the object pointed to by i, offs
|
|
|
|
|
// only used to decide whether we are before or after linebreak
|
|
|
|
|
CoordType GetLineLength(wxLayoutObjectList::iterator i,
|
|
|
|
|
CoordType offs = 0);
|
1998-08-14 04:33:33 -04:00
|
|
|
|
wxLayoutPrintout *MakePrintout(wxString const &name);
|
|
|
|
|
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// Return maximum X,Y coordinates
|
|
|
|
|
wxPoint GetSize(void) const { return wxPoint(m_MaxX, m_MaxY); }
|
1998-08-06 15:23:19 -04:00
|
|
|
|
//@}
|
1998-06-29 08:44:36 -04:00
|
|
|
|
protected:
|
|
|
|
|
/// font parameters:
|
|
|
|
|
int m_FontFamily, m_FontStyle, m_FontWeight;
|
|
|
|
|
int m_FontPtSize;
|
|
|
|
|
bool m_FontUnderline;
|
|
|
|
|
/// colours:
|
|
|
|
|
wxColour const * m_ColourFG;
|
|
|
|
|
wxColour const * m_ColourBG;
|
1998-07-12 11:02:44 -04:00
|
|
|
|
/// the default setting:
|
|
|
|
|
wxLayoutObjectCmd *m_DefaultSetting;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
|
|
|
|
/// needs recalculation?
|
|
|
|
|
bool m_dirty;
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// cursor moved
|
|
|
|
|
bool m_CursorMoved;
|
|
|
|
|
|
|
|
|
|
/// needs saving (i.e., was modified?)
|
|
|
|
|
bool m_bModified;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
|
|
|
|
// the currently updated line:
|
|
|
|
|
/// where do we draw next:
|
|
|
|
|
wxPoint m_Position;
|
|
|
|
|
/// the height of the current line:
|
|
|
|
|
CoordType m_LineHeight;
|
|
|
|
|
/// maximum drawn x position so far
|
|
|
|
|
CoordType m_MaxX;
|
|
|
|
|
/// maximum drawn y position:
|
|
|
|
|
CoordType m_MaxY;
|
|
|
|
|
|
|
|
|
|
//---- this is needed for editing:
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// where is the text cursor (column,line):
|
1998-10-30 05:14:58 -05:00
|
|
|
|
wxPoint m_CursorPos;
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// where to draw the cursor
|
|
|
|
|
wxPoint m_CursorCoords;
|
|
|
|
|
/// how large to draw it
|
|
|
|
|
wxPoint m_CursorSize;
|
1998-10-30 05:14:58 -05:00
|
|
|
|
/// object iterator for current cursor position:
|
|
|
|
|
iterator m_CursorObject;
|
|
|
|
|
/// position of cursor within m_CursorObject:
|
|
|
|
|
int m_CursorOffset;
|
|
|
|
|
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// to store content overwritten by cursor
|
|
|
|
|
wxMemoryDC m_CursorMemDC;
|
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/// which is the last line
|
|
|
|
|
CoordType m_MaxLine;
|
|
|
|
|
/// can we edit it?
|
|
|
|
|
bool m_Editable;
|
|
|
|
|
/// find the object to the cursor position and returns the offset
|
|
|
|
|
/// in there
|
1998-10-24 14:08:20 -04:00
|
|
|
|
wxLayoutObjectList::iterator FindObjectCursor(wxPoint *cpos, CoordType *offset = NULL);
|
1998-11-19 15:34:59 -05:00
|
|
|
|
/// get the wrap margin
|
|
|
|
|
inline long GetWrapMargin(void) const { return m_WrapMargin; }
|
|
|
|
|
/// do we do wrapping?
|
|
|
|
|
inline bool DoWordWrap(void) const { return m_WrapMargin != -1; }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
private:
|
|
|
|
|
/// Resets the font settings etc to default values
|
|
|
|
|
void ResetSettings(wxDC &dc);
|
|
|
|
|
/// calculates current cursor coordinates, called in Layout()
|
|
|
|
|
void CalculateCursor(wxDC &dc);
|
|
|
|
|
/// remembers the last cursor position for which FindObjectCursor was called
|
|
|
|
|
wxPoint m_FoundCursor;
|
|
|
|
|
/// remembers the iterator to the object related to m_FoundCursor
|
|
|
|
|
wxLayoutObjectList::iterator m_FoundIterator;
|
1998-11-19 15:34:59 -05:00
|
|
|
|
/// the wrap margin
|
|
|
|
|
long m_WrapMargin;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
};
|
|
|
|
|
|
1998-08-14 04:33:33 -04:00
|
|
|
|
class wxLayoutPrintout: public wxPrintout
|
|
|
|
|
{
|
|
|
|
|
public:
|
1998-10-27 04:55:07 -05:00
|
|
|
|
wxLayoutPrintout(wxLayoutList &llist, wxString const & title =
|
1998-10-30 05:14:58 -05:00
|
|
|
|
"wxLayout Printout");
|
1998-10-24 14:08:20 -04:00
|
|
|
|
bool OnPrintPage(int page);
|
|
|
|
|
bool HasPage(int page);
|
|
|
|
|
bool OnBeginDocument(int startPage, int endPage);
|
1998-08-14 04:33:33 -04:00
|
|
|
|
void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int
|
|
|
|
|
*selPageTo);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
void OnPreparePrinting(void);
|
1998-10-27 04:55:07 -05:00
|
|
|
|
protected:
|
|
|
|
|
virtual void DrawHeader(wxDC &dc, wxPoint topleft, wxPoint bottomright, int pageno);
|
|
|
|
|
|
1998-08-14 04:33:33 -04:00
|
|
|
|
private:
|
|
|
|
|
wxLayoutList *m_llist;
|
1998-10-27 04:55:07 -05:00
|
|
|
|
wxString m_title;
|
1998-10-25 06:08:43 -05:00
|
|
|
|
int m_PageHeight, m_PageWidth;
|
1998-10-27 04:55:07 -05:00
|
|
|
|
// how much we actually print per page
|
|
|
|
|
int m_PrintoutHeight;
|
1998-10-25 06:08:43 -05:00
|
|
|
|
wxLayoutMargins m_Margins;
|
|
|
|
|
int m_NumOfPages;
|
1998-08-14 04:33:33 -04:00
|
|
|
|
};
|
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
#endif // WXLLIST_H
|