1998-06-29 08:44:36 -04:00
|
|
|
|
/*-*- c++ -*-********************************************************
|
|
|
|
|
* wxLayoutList.h - a formatted text rendering engine for wxWindows *
|
|
|
|
|
* *
|
1999-03-07 16:38:50 -05:00
|
|
|
|
* (C) 1999 by Karsten Ball<EFBFBD>der (Ballueder@usa.net) *
|
1998-06-29 08:44:36 -04:00
|
|
|
|
* *
|
|
|
|
|
* $Id$
|
|
|
|
|
*******************************************************************/
|
1999-02-08 10:20:38 -05:00
|
|
|
|
|
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
#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
|
1999-03-07 16:38:50 -05:00
|
|
|
|
#ifndef M_BASEDIR
|
1998-10-24 14:08:20 -04:00
|
|
|
|
# define WXMENU_LAYOUT_LCLICK 1111
|
1999-03-07 16:38:50 -05:00
|
|
|
|
# define WXMENU_LAYOUT_RCLICK 1112
|
1998-10-24 14:08:20 -04:00
|
|
|
|
# define WXMENU_LAYOUT_DBLCLICK 1113
|
1998-06-29 08:44:36 -04:00
|
|
|
|
#endif
|
|
|
|
|
|
1999-05-11 16:43:12 -04:00
|
|
|
|
// do not enable debug mode within Mahogany
|
|
|
|
|
#if defined(__WXDEBUG__) && ! defined(M_BASEDIR)
|
1999-03-07 16:38:50 -05:00
|
|
|
|
# define WXLAYOUT_DEBUG
|
1998-07-12 11:02:44 -04:00
|
|
|
|
#endif
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1999-03-14 11:04:57 -05:00
|
|
|
|
#ifdef WXLAYOUT_DEBUG
|
|
|
|
|
# define WXLO_TRACE(x) wxLogDebug(x)
|
|
|
|
|
#else
|
|
|
|
|
# define WXLO_TRACE(x)
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-05-12 18:14:51 -04:00
|
|
|
|
#define WXLO_DEBUG_URECT 0
|
1999-03-14 11:04:57 -05:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
#ifndef WXLO_DEFAULTFONTSIZE
|
|
|
|
|
# define WXLO_DEFAULTFONTSIZE 12
|
|
|
|
|
#endif
|
1998-10-27 04:55:07 -05:00
|
|
|
|
|
1999-03-14 11:04:57 -05:00
|
|
|
|
|
1998-07-27 16:39:50 -04:00
|
|
|
|
/// Types of currently supported layout objects.
|
|
|
|
|
enum wxLayoutObjectType
|
1999-03-07 16:38:50 -05:00
|
|
|
|
{
|
|
|
|
|
/// illegal object type, should never appear
|
|
|
|
|
WXLO_TYPE_INVALID = 0,
|
|
|
|
|
/// text object, containing normal text
|
|
|
|
|
WXLO_TYPE_TEXT,
|
|
|
|
|
/// command object, containing font or colour changes
|
|
|
|
|
WXLO_TYPE_CMD,
|
|
|
|
|
/// icon object, any kind of image
|
|
|
|
|
WXLO_TYPE_ICON
|
|
|
|
|
};
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// Type used for coordinates in drawing. Must be signed.
|
1998-06-29 08:44:36 -04:00
|
|
|
|
typedef long CoordType;
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
// Forward declarations.
|
1998-06-29 08:44:36 -04:00
|
|
|
|
class wxLayoutList;
|
1999-03-07 16:38:50 -05:00
|
|
|
|
class wxLayoutObject;
|
1998-08-12 04:33:34 -04:00
|
|
|
|
class wxDC;
|
|
|
|
|
class wxColour;
|
|
|
|
|
class wxFont;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
|
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
|
|
|
|
|
|
The wxLayout objects which make up the lines.
|
|
|
|
|
|
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
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.
|
|
|
|
|
*/
|
1999-03-07 16:38:50 -05:00
|
|
|
|
class wxLayoutObject
|
1998-06-29 08:44:36 -04:00
|
|
|
|
{
|
|
|
|
|
public:
|
1999-03-14 16:22:10 -05:00
|
|
|
|
/** This structure can be used to contain data associated with the
|
|
|
|
|
object.
|
|
|
|
|
It is refcounted, so the caller has to do a DecRef() on it
|
|
|
|
|
instead of a delete.
|
|
|
|
|
*/
|
1998-10-24 14:08:20 -04:00
|
|
|
|
struct UserData
|
|
|
|
|
{
|
1999-03-14 16:22:10 -05:00
|
|
|
|
UserData() { m_refcount = 1; }
|
|
|
|
|
void IncRef(void) { m_refcount++; }
|
|
|
|
|
void DecRef(void) { m_refcount--; if(m_refcount == 0) delete this;}
|
|
|
|
|
private:
|
|
|
|
|
int m_refcount;
|
|
|
|
|
protected:
|
|
|
|
|
virtual ~UserData() { wxASSERT(m_refcount == 0); }
|
|
|
|
|
/// prevents gcc from generating stupid warnings
|
|
|
|
|
friend class dummy_UserData;
|
1998-10-24 14:08:20 -04:00
|
|
|
|
};
|
|
|
|
|
|
1998-07-27 16:39:50 -04:00
|
|
|
|
/// return the type of this object
|
1999-03-07 16:38:50 -05:00
|
|
|
|
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_INVALID; }
|
|
|
|
|
/** Calculates the size of an object.
|
1998-06-29 08:44:36 -04:00
|
|
|
|
@param dc the wxDC to draw on
|
1999-05-12 18:14:51 -04:00
|
|
|
|
@param llist the wxLayoutList
|
1998-06-29 08:44:36 -04:00
|
|
|
|
*/
|
1999-05-12 18:14:51 -04:00
|
|
|
|
virtual void Layout(wxDC &dc, class wxLayoutList *llist) = 0;
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
|
|
|
|
/** Draws an object.
|
|
|
|
|
@param dc the wxDC to draw on
|
1999-03-07 16:38:50 -05:00
|
|
|
|
@param coords where to draw the baseline of the object.
|
1999-05-09 13:28:58 -04:00
|
|
|
|
@param wxllist pointer to wxLayoutList
|
1999-05-09 11:24:57 -04:00
|
|
|
|
@param begin if !=-1, from which position on to highlight it
|
|
|
|
|
@param end if begin !=-1, how many positions to highlight it
|
1998-10-24 14:08:20 -04:00
|
|
|
|
*/
|
1999-05-09 11:24:57 -04:00
|
|
|
|
virtual void Draw(wxDC & /* dc */,
|
|
|
|
|
wxPoint const & /* coords */,
|
1999-05-09 13:28:58 -04:00
|
|
|
|
class wxLayoutList *wxllist,
|
1999-05-09 11:24:57 -04:00
|
|
|
|
CoordType begin = -1,
|
|
|
|
|
CoordType end = -1) { }
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/** Calculates and returns the size of the object.
|
1999-03-07 16:38:50 -05:00
|
|
|
|
@param top where to store height above baseline
|
|
|
|
|
@param bottom where to store height below baseline
|
1998-07-27 16:39:50 -04:00
|
|
|
|
@return the size of the object's box in pixels
|
|
|
|
|
*/
|
1999-03-07 16:38:50 -05:00
|
|
|
|
virtual wxPoint GetSize(CoordType * top, CoordType *bottom) const
|
|
|
|
|
{ *top = 0; *bottom = 0; return wxPoint(0,0); }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// Return just the width of the object on the screen.
|
|
|
|
|
virtual CoordType GetWidth(void) const { return 0; }
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/// returns the number of cursor positions occupied by this object
|
1999-03-07 16:38:50 -05:00
|
|
|
|
virtual CoordType GetLength(void) const { return 1; }
|
1999-03-14 11:04:57 -05:00
|
|
|
|
/** Returns the cursor offset relating to the screen x position
|
|
|
|
|
relative to begin of object.
|
|
|
|
|
@param dc the wxDC to use for calculations
|
|
|
|
|
@param xpos relative x position from head of object
|
|
|
|
|
@return cursor coordinate offset
|
|
|
|
|
*/
|
|
|
|
|
virtual CoordType GetOffsetScreen(wxDC &dc, CoordType xpos) const { return 0; }
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1998-07-27 16:39:50 -04:00
|
|
|
|
/// constructor
|
1999-03-07 16:38:50 -05:00
|
|
|
|
wxLayoutObject() { m_UserData = NULL; }
|
1998-10-24 14:08:20 -04:00
|
|
|
|
/// delete the user data
|
1999-03-14 16:22:10 -05:00
|
|
|
|
virtual ~wxLayoutObject() { if(m_UserData) m_UserData->DecRef(); }
|
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-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.
|
|
|
|
|
*/
|
1999-03-14 16:22:10 -05:00
|
|
|
|
void SetUserData(UserData *data)
|
|
|
|
|
{
|
|
|
|
|
if(m_UserData)
|
|
|
|
|
m_UserData->DecRef();
|
|
|
|
|
m_UserData = data;
|
|
|
|
|
m_UserData->IncRef();
|
|
|
|
|
}
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1999-03-14 16:22:10 -05:00
|
|
|
|
/** Return the user data. */
|
|
|
|
|
void * GetUserData(void) const { if(m_UserData) m_UserData->IncRef(); return m_UserData; }
|
|
|
|
|
|
|
|
|
|
/** Makes a copy of this object.
|
|
|
|
|
*/
|
|
|
|
|
virtual wxLayoutObject *Copy(void) = 0;
|
1999-03-29 04:56:44 -05:00
|
|
|
|
protected:
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/// optional data for application's use
|
1998-10-24 14:08:20 -04:00
|
|
|
|
UserData *m_UserData;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
};
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// Define a list type of wxLayoutObject pointers.
|
|
|
|
|
KBLIST_DEFINE(wxLayoutObjectList, wxLayoutObject);
|
1998-08-12 04:33:34 -04:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// An illegal iterator to save typing.
|
|
|
|
|
#define NULLIT (wxLayoutObjectList::iterator(NULL))
|
|
|
|
|
/// The iterator type.
|
|
|
|
|
#define wxLOiterator wxLayoutObjectList::iterator
|
1998-08-12 04:33:34 -04:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
|
|
|
|
|
|
wxLayoutObjectText
|
|
|
|
|
|
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
/** This class implements a wxLayoutObject holding plain text.
|
|
|
|
|
*/
|
|
|
|
|
class wxLayoutObjectText : public wxLayoutObject
|
1998-06-29 08:44:36 -04:00
|
|
|
|
{
|
|
|
|
|
public:
|
1999-03-07 16:38:50 -05:00
|
|
|
|
wxLayoutObjectText(const wxString &txt);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_TEXT; }
|
1999-05-12 18:14:51 -04:00
|
|
|
|
virtual void Layout(wxDC &dc, class wxLayoutList *llist);
|
1999-05-09 11:24:57 -04:00
|
|
|
|
virtual void Draw(wxDC &dc, wxPoint const &coords,
|
1999-05-09 13:28:58 -04:00
|
|
|
|
class wxLayoutList *wxllist,
|
1999-05-09 11:24:57 -04:00
|
|
|
|
CoordType begin = -1,
|
|
|
|
|
CoordType end = -1);
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** Calculates and returns the size of the object.
|
|
|
|
|
@param top where to store height above baseline
|
|
|
|
|
@param bottom where to store height below baseline
|
|
|
|
|
@return the size of the object's box in pixels
|
1998-06-29 08:44:36 -04:00
|
|
|
|
*/
|
1999-03-07 16:38:50 -05:00
|
|
|
|
virtual wxPoint GetSize(CoordType * top, CoordType *bottom) const;
|
|
|
|
|
/// Return just the width of the object on the screen.
|
|
|
|
|
virtual CoordType GetWidth(void) const { return m_Width; }
|
1999-03-14 11:04:57 -05:00
|
|
|
|
/** Returns the cursor offset relating to the screen x position
|
|
|
|
|
relative to begin of object.
|
|
|
|
|
@param dc the wxDC to use for calculations
|
|
|
|
|
@param xpos relative x position from head of object
|
|
|
|
|
@return cursor coordinate offset
|
|
|
|
|
*/
|
|
|
|
|
virtual CoordType GetOffsetScreen(wxDC &dc, CoordType xpos) const;
|
|
|
|
|
|
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
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
virtual CoordType GetLength(void) const { return strlen(m_Text.c_str()); }
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
|
|
|
|
// for editing:
|
1999-03-07 16:38:50 -05:00
|
|
|
|
wxString & GetText(void) { return m_Text; }
|
|
|
|
|
void SetText(wxString const &text) { m_Text = text; }
|
1999-03-14 16:22:10 -05:00
|
|
|
|
/** Makes a copy of this object.
|
|
|
|
|
*/
|
|
|
|
|
virtual wxLayoutObject *Copy(void);
|
1998-06-29 08:44:36 -04:00
|
|
|
|
private:
|
1999-03-07 16:38:50 -05:00
|
|
|
|
wxString m_Text;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
/// size of the box containing text
|
|
|
|
|
long m_Width, m_Height;
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// Height above baseline.
|
|
|
|
|
long m_Top;
|
|
|
|
|
/// Height below baseline.
|
|
|
|
|
long m_Bottom;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
};
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
|
|
|
|
|
|
wxLayoutObjectIcon
|
|
|
|
|
|
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
/** This class implements a wxLayoutObject holding a graphic.
|
|
|
|
|
*/
|
|
|
|
|
class wxLayoutObjectIcon : public wxLayoutObject
|
1998-06-29 08:44:36 -04:00
|
|
|
|
{
|
|
|
|
|
public:
|
1999-03-07 16:38:50 -05:00
|
|
|
|
wxLayoutObjectIcon(wxBitmap *icon);
|
|
|
|
|
wxLayoutObjectIcon(wxBitmap const &icon);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
|
|
|
|
~wxLayoutObjectIcon() { delete m_Icon; }
|
|
|
|
|
|
|
|
|
|
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_ICON; }
|
1999-05-12 18:14:51 -04:00
|
|
|
|
virtual void Layout(wxDC &dc, class wxLayoutList *llist);
|
1999-05-09 11:24:57 -04:00
|
|
|
|
virtual void Draw(wxDC &dc, wxPoint const &coords,
|
1999-05-09 13:28:58 -04:00
|
|
|
|
class wxLayoutList *wxllist,
|
1999-05-09 11:24:57 -04:00
|
|
|
|
CoordType begin = -1,
|
|
|
|
|
CoordType end = -1);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** Calculates and returns the size of the object.
|
|
|
|
|
@param top where to store height above baseline
|
|
|
|
|
@param bottom where to store height below baseline
|
|
|
|
|
@return the size of the object's box in pixels
|
|
|
|
|
*/
|
|
|
|
|
virtual wxPoint GetSize(CoordType * top, CoordType *bottom) const;
|
|
|
|
|
/// Return just the width of the object on the screen.
|
|
|
|
|
virtual CoordType GetWidth(void) const { return m_Icon->GetWidth(); }
|
1999-03-14 16:22:10 -05:00
|
|
|
|
// return a pointer to the icon
|
|
|
|
|
wxBitmap *GetIcon(void) const { return m_Icon; }
|
|
|
|
|
/** Makes a copy of this object.
|
|
|
|
|
*/
|
|
|
|
|
virtual wxLayoutObject *Copy(void);
|
1998-06-29 08:44:36 -04:00
|
|
|
|
private:
|
1999-03-07 16:38:50 -05:00
|
|
|
|
wxBitmap *m_Icon;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
};
|
|
|
|
|
|
1999-05-12 18:14:51 -04:00
|
|
|
|
/** This structure holds all formatting information. Members which are
|
|
|
|
|
undefined (for a CmdObject this means: no change), are set to -1.
|
|
|
|
|
*/
|
1998-06-29 08:44:36 -04:00
|
|
|
|
struct wxLayoutStyleInfo
|
|
|
|
|
{
|
1999-05-12 18:14:51 -04:00
|
|
|
|
wxLayoutStyleInfo(int ifamily = -1,
|
|
|
|
|
int isize = -1,
|
|
|
|
|
int istyle = -1,
|
|
|
|
|
int iweight = -1,
|
|
|
|
|
int iul = -1,
|
|
|
|
|
wxColour *fg = NULL,
|
|
|
|
|
wxColour *bg = NULL);
|
|
|
|
|
wxColour * GetBGColour() const
|
1999-03-07 16:38:50 -05:00
|
|
|
|
{
|
1999-05-12 18:14:51 -04:00
|
|
|
|
return fg_valid ? new
|
|
|
|
|
wxColour(bg_red,bg_green,bg_blue)
|
|
|
|
|
: wxWHITE;
|
1999-03-07 16:38:50 -05:00
|
|
|
|
}
|
1999-05-12 18:14:51 -04:00
|
|
|
|
wxFont *GetFont(wxLayoutStyleInfo *);
|
|
|
|
|
/// Font change parameters.
|
|
|
|
|
int size, family, style, weight, underline;
|
|
|
|
|
/// Is foreground colour valid to bet set?
|
|
|
|
|
bool fg_valid;
|
|
|
|
|
/// Is background colour valid to bet set?
|
|
|
|
|
bool bg_valid;
|
|
|
|
|
/// Foreground colour RGB values.
|
1998-06-29 08:44:36 -04:00
|
|
|
|
unsigned fg_red, fg_green, fg_blue;
|
1999-05-12 18:14:51 -04:00
|
|
|
|
/// Background colour RGB values.
|
1998-06-29 08:44:36 -04:00
|
|
|
|
unsigned bg_red, bg_green, bg_blue;
|
|
|
|
|
};
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
|
|
|
|
|
|
wxLayoutObjectCmd
|
|
|
|
|
|
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
/** This class implements a wxLayoutObject holding style change commands.
|
|
|
|
|
*/
|
|
|
|
|
class wxLayoutObjectCmd : public wxLayoutObject
|
1998-06-29 08:44:36 -04:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_CMD; }
|
1999-05-12 18:14:51 -04:00
|
|
|
|
virtual void Layout(wxDC &dc, class wxLayoutList *llist);
|
1999-05-09 11:24:57 -04:00
|
|
|
|
virtual void Draw(wxDC &dc, wxPoint const &coords,
|
1999-05-09 13:28:58 -04:00
|
|
|
|
class wxLayoutList *wxllist,
|
1999-05-09 11:24:57 -04:00
|
|
|
|
CoordType begin = -1,
|
|
|
|
|
CoordType end = -1);
|
1999-05-12 18:14:51 -04:00
|
|
|
|
wxLayoutObjectCmd(int size = -1,
|
|
|
|
|
int family = -1,
|
|
|
|
|
int style = -1,
|
|
|
|
|
int weight = -1,
|
|
|
|
|
int underline = -1,
|
|
|
|
|
wxColour *fg = NULL,
|
|
|
|
|
wxColour *bg = NULL);
|
1998-06-29 08:44:36 -04:00
|
|
|
|
~wxLayoutObjectCmd();
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** Stores the current style in the styleinfo structure */
|
1999-05-12 18:14:51 -04:00
|
|
|
|
wxLayoutStyleInfo * GetStyle(void) const;
|
1999-03-14 16:22:10 -05:00
|
|
|
|
/** Makes a copy of this object.
|
|
|
|
|
*/
|
|
|
|
|
virtual wxLayoutObject *Copy(void);
|
1998-06-29 08:44:36 -04:00
|
|
|
|
private:
|
|
|
|
|
/// the font to use
|
|
|
|
|
wxFont *m_font;
|
1999-05-12 18:14:51 -04:00
|
|
|
|
wxLayoutStyleInfo *m_StyleInfo;
|
1998-06-29 08:44:36 -04:00
|
|
|
|
};
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
The wxLayoutLine object
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
1998-08-14 04:33:33 -04:00
|
|
|
|
|
1999-04-12 16:06:46 -04:00
|
|
|
|
/// forward declaration
|
|
|
|
|
class wxLayoutList;
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** This class represents a single line of objects to be displayed.
|
|
|
|
|
It knows its height and total size and whether it needs to be
|
|
|
|
|
redrawn or not.
|
|
|
|
|
It has pointers to its first and next line so it can automatically
|
|
|
|
|
update them as needed.
|
|
|
|
|
*/
|
|
|
|
|
class wxLayoutLine
|
1998-10-25 06:08:43 -05:00
|
|
|
|
{
|
|
|
|
|
public:
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** Constructor.
|
|
|
|
|
@param prev pointer to previous line or NULL
|
|
|
|
|
@param next pointer to following line or NULL
|
1999-04-12 16:06:46 -04:00
|
|
|
|
@param llist pointer to layout list
|
1999-03-07 16:38:50 -05:00
|
|
|
|
*/
|
1999-04-12 16:06:46 -04:00
|
|
|
|
wxLayoutLine(wxLayoutLine *prev, wxLayoutList *llist);
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** This function inserts a new object at cursor position xpos.
|
|
|
|
|
@param xpos where to insert new object
|
|
|
|
|
@param obj the object to insert
|
|
|
|
|
@return true if that xpos existed and the object was inserted
|
|
|
|
|
*/
|
|
|
|
|
bool Insert(CoordType xpos, wxLayoutObject *obj);
|
|
|
|
|
|
|
|
|
|
/** This function inserts text at cursor position xpos.
|
|
|
|
|
@param xpos where to insert
|
|
|
|
|
@param text the text to insert
|
|
|
|
|
@return true if that xpos existed and the object was inserted
|
|
|
|
|
*/
|
|
|
|
|
bool Insert(CoordType xpos, wxString text);
|
|
|
|
|
|
|
|
|
|
/** This function appends an object to the line.
|
|
|
|
|
@param obj the object to insert
|
|
|
|
|
*/
|
|
|
|
|
void Append(wxLayoutObject * obj)
|
|
|
|
|
{
|
|
|
|
|
wxASSERT(obj);
|
|
|
|
|
m_ObjectList.push_back(obj);
|
|
|
|
|
m_Length += obj->GetLength();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** This function appens the next line to this, i.e. joins the two
|
|
|
|
|
lines into one.
|
|
|
|
|
*/
|
1999-04-12 16:06:46 -04:00
|
|
|
|
void MergeNextLine(wxLayoutList *llist);
|
1999-03-07 16:38:50 -05:00
|
|
|
|
|
|
|
|
|
/** This function deletes npos cursor positions from position xpos.
|
|
|
|
|
@param xpos where to delete
|
|
|
|
|
@param npos how many positions
|
|
|
|
|
@return number of positions still to be deleted
|
|
|
|
|
*/
|
|
|
|
|
CoordType Delete(CoordType xpos, CoordType npos);
|
|
|
|
|
|
|
|
|
|
/** This function breaks the line at a given cursor position.
|
|
|
|
|
@param xpos where to break it
|
|
|
|
|
@return pointer to the new line object replacing the old one
|
|
|
|
|
*/
|
1999-04-12 16:06:46 -04:00
|
|
|
|
wxLayoutLine *Break(CoordType xpos, wxLayoutList *llist);
|
1999-03-07 16:38:50 -05:00
|
|
|
|
|
|
|
|
|
/** Deletes the next word from this position, including leading
|
|
|
|
|
whitespace.
|
|
|
|
|
This function does not delete over font changes, i.e. a word
|
|
|
|
|
with formatting instructions in the middle of it is treated as
|
|
|
|
|
two (three actually!) words. In fact, if the cursor is on a non-text object, that
|
|
|
|
|
one is treated as a word.
|
|
|
|
|
@param xpos from where to delete
|
|
|
|
|
@return true if a word was deleted
|
|
|
|
|
*/
|
|
|
|
|
bool DeleteWord(CoordType npos);
|
1999-03-14 11:04:57 -05:00
|
|
|
|
|
|
|
|
|
/** Finds a suitable position left to the given column to break the
|
|
|
|
|
line.
|
|
|
|
|
@param column we want to break the line to the left of this
|
|
|
|
|
@return column for breaking line or -1 if no suitable location found
|
|
|
|
|
*/
|
|
|
|
|
CoordType GetWrapPosition(CoordType column);
|
1999-03-07 16:38:50 -05:00
|
|
|
|
|
|
|
|
|
/** Finds the object which covers the cursor position xpos in this
|
|
|
|
|
line.
|
|
|
|
|
@param xpos the column number
|
|
|
|
|
@param offset where to store the difference between xpos and
|
|
|
|
|
the object's head
|
|
|
|
|
@return iterator to the object or NULLIT
|
|
|
|
|
*/
|
|
|
|
|
wxLayoutObjectList::iterator FindObject(CoordType xpos, CoordType
|
|
|
|
|
*offset) const ;
|
|
|
|
|
|
1999-03-14 11:04:57 -05:00
|
|
|
|
/** Finds the object which covers the screen position xpos in this
|
|
|
|
|
line.
|
|
|
|
|
@param dc the wxDC to use for calculations
|
|
|
|
|
@param xpos the screen x coordinate
|
|
|
|
|
@param offset where to store the difference between xpos and
|
|
|
|
|
the object's head
|
|
|
|
|
@return iterator to the object or NULLIT
|
|
|
|
|
*/
|
|
|
|
|
wxLayoutObjectList::iterator FindObjectScreen(wxDC &dc,
|
|
|
|
|
CoordType xpos,
|
1999-05-08 14:01:24 -04:00
|
|
|
|
CoordType *offset,
|
|
|
|
|
bool *found = NULL) const ;
|
1999-03-14 11:04:57 -05:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** Get the first object in the list. This is used by the wxlparser
|
|
|
|
|
functions to export the list.
|
|
|
|
|
@return iterator to the first object
|
|
|
|
|
*/
|
|
|
|
|
wxLayoutObjectList::iterator GetFirstObject(void)
|
|
|
|
|
{
|
|
|
|
|
return m_ObjectList.begin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Deletes this line, returns pointer to next line.
|
|
|
|
|
@param update If true, update all following lines.
|
|
|
|
|
*/
|
1999-04-12 16:06:46 -04:00
|
|
|
|
wxLayoutLine *DeleteLine(bool update, wxLayoutList *llist);
|
1999-03-07 16:38:50 -05:00
|
|
|
|
|
|
|
|
|
/**@name Cursor Management */
|
|
|
|
|
//@{
|
|
|
|
|
/** Return the line number of this line.
|
|
|
|
|
@return the line number
|
|
|
|
|
*/
|
1999-05-09 11:24:57 -04:00
|
|
|
|
inline CoordType GetLineNumber(void) const { return m_LineNumber; }
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** Return the length of the line.
|
|
|
|
|
@return line lenght in cursor positions
|
|
|
|
|
*/
|
1999-05-09 11:24:57 -04:00
|
|
|
|
inline CoordType GetLength(void) const { return m_Length; }
|
1999-03-07 16:38:50 -05:00
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
/**@name Drawing and Layout */
|
|
|
|
|
//@{
|
|
|
|
|
/** Draws the line on a wxDC.
|
|
|
|
|
@param dc the wxDC to draw on
|
1999-04-12 16:06:46 -04:00
|
|
|
|
@param llist the wxLayoutList
|
1999-03-07 16:38:50 -05:00
|
|
|
|
@param offset an optional offset to shift printout
|
|
|
|
|
*/
|
1999-04-12 16:06:46 -04:00
|
|
|
|
void Draw(wxDC &dc,
|
|
|
|
|
wxLayoutList *llist,
|
|
|
|
|
const wxPoint &offset = wxPoint(0,0)) const;
|
1999-03-07 16:38:50 -05:00
|
|
|
|
|
|
|
|
|
/** Recalculates the positions of objects and the height of the
|
|
|
|
|
line.
|
|
|
|
|
@param dc the wxDC to draw on
|
1999-04-12 16:06:46 -04:00
|
|
|
|
@param llist th e wxLayoutList
|
1999-03-07 16:38:50 -05:00
|
|
|
|
@param cursorPos if not NULL, set cursor screen position in there
|
|
|
|
|
@param cursorSize if not cursorPos != NULL, set cursor size in there
|
|
|
|
|
@param cx if cursorPos != NULL, the cursor x position
|
|
|
|
|
*/
|
|
|
|
|
void Layout(wxDC &dc,
|
1999-04-12 16:06:46 -04:00
|
|
|
|
wxLayoutList *llist,
|
1999-03-07 16:38:50 -05:00
|
|
|
|
wxPoint *cursorPos = NULL,
|
|
|
|
|
wxPoint *cursorSize = NULL,
|
|
|
|
|
int cx = 0);
|
|
|
|
|
/** This function finds an object belonging to a given cursor
|
|
|
|
|
position. It assumes that Layout() has been called before.
|
1999-03-14 11:04:57 -05:00
|
|
|
|
@param dc the wxDC to use for calculations
|
1999-03-07 16:38:50 -05:00
|
|
|
|
@param xpos screen x position
|
1999-05-08 14:01:24 -04:00
|
|
|
|
@param found if non-NULL set to false if we return the last
|
|
|
|
|
object before the cursor, to true if we really have an object
|
|
|
|
|
for that position
|
1999-03-07 16:38:50 -05:00
|
|
|
|
@return pointer to the object
|
|
|
|
|
*/
|
1999-05-08 14:01:24 -04:00
|
|
|
|
wxLayoutObject * FindObjectScreen(wxDC &dc, CoordType xpos, bool
|
|
|
|
|
*found = NULL);
|
1999-03-07 16:38:50 -05:00
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
/**@name List traversal */
|
|
|
|
|
//@{
|
|
|
|
|
/// Returns pointer to next line.
|
|
|
|
|
wxLayoutLine *GetNextLine(void) const { return m_Next; }
|
|
|
|
|
/// Returns pointer to previous line.
|
|
|
|
|
wxLayoutLine *GetPreviousLine(void) const { return m_Previous; }
|
|
|
|
|
/// Sets the link to the next line.
|
|
|
|
|
void SetNext(wxLayoutLine *next)
|
|
|
|
|
{ m_Next = next; if(next) next->m_Previous = this; }
|
|
|
|
|
/// Sets the link to the previous line.
|
|
|
|
|
void SetPrevious(wxLayoutLine *previous)
|
|
|
|
|
{ m_Previous = previous; if(previous) previous->m_Next = this; }
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
/// Returns the position of this line on the canvas.
|
|
|
|
|
wxPoint GetPosition(void) const { return m_Position; }
|
|
|
|
|
/// Returns the height of this line.
|
|
|
|
|
CoordType GetHeight(void) const { return m_Height; }
|
|
|
|
|
/// Returns the width of this line.
|
|
|
|
|
CoordType GetWidth(void) const { return m_Width; }
|
|
|
|
|
/** This will recalculate the position and size of this line.
|
|
|
|
|
If called recursively it will abort if the position of an
|
|
|
|
|
object is unchanged, assuming that none of the following
|
|
|
|
|
objects need to move.
|
|
|
|
|
@param recurse if greater 0 then it will be used as the
|
|
|
|
|
minimum(!) recursion level, continue with all lines till the end of
|
|
|
|
|
the list or until the coordinates no longer changed.
|
|
|
|
|
*/
|
1999-04-12 16:06:46 -04:00
|
|
|
|
void RecalculatePositions(int recurse, wxLayoutList *llist);
|
1999-03-14 11:04:57 -05:00
|
|
|
|
/// Recalculates the position of this line on the canvas.
|
1999-04-12 16:06:46 -04:00
|
|
|
|
wxPoint RecalculatePosition(wxLayoutList *llist);
|
1999-05-08 14:01:24 -04:00
|
|
|
|
|
1999-05-11 16:43:12 -04:00
|
|
|
|
/** Copies the contents of this line to another wxLayoutList
|
|
|
|
|
@param llist the wxLayoutList destination
|
|
|
|
|
@param from x cursor coordinate where to start
|
|
|
|
|
@param to x cursor coordinate where to stop, -1 for end of line
|
|
|
|
|
*/
|
|
|
|
|
void Copy(wxLayoutList *llist,
|
|
|
|
|
CoordType from = 0,
|
|
|
|
|
CoordType to = -1);
|
|
|
|
|
|
1999-05-08 14:01:24 -04:00
|
|
|
|
#ifdef WXLAYOUT_DEBUG
|
|
|
|
|
void Debug(void);
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
private:
|
|
|
|
|
/// Destructor is private. Use DeleteLine() to remove it.
|
|
|
|
|
~wxLayoutLine();
|
|
|
|
|
|
|
|
|
|
/**@name Functions to let the lines synchronise with each other. */
|
|
|
|
|
//@{
|
|
|
|
|
/** Sets the height of this line. Will mark following lines as
|
|
|
|
|
dirty.
|
|
|
|
|
@param height new height
|
|
|
|
|
*/
|
1999-04-12 16:06:46 -04:00
|
|
|
|
void SetHeight(CoordType height, wxLayoutList *llist)
|
|
|
|
|
{ m_Height = height; RecalculatePositions(true, llist); }
|
1999-03-07 16:38:50 -05:00
|
|
|
|
|
|
|
|
|
/** Moves the linenumbers one on, because a line has been inserted
|
|
|
|
|
or deleted.
|
|
|
|
|
@param delta either +1 or -1
|
|
|
|
|
*/
|
|
|
|
|
void MoveLines(int delta)
|
|
|
|
|
{
|
|
|
|
|
m_LineNumber += delta;
|
|
|
|
|
if(m_Next) m_Next->MoveLines(delta);
|
|
|
|
|
}
|
|
|
|
|
//@}
|
|
|
|
|
private:
|
|
|
|
|
/// The line number.
|
|
|
|
|
CoordType m_LineNumber;
|
|
|
|
|
/// The line length in cursor positions.
|
|
|
|
|
CoordType m_Length;
|
|
|
|
|
/// The total height of the line.
|
|
|
|
|
CoordType m_Height;
|
|
|
|
|
/// The total width of the line on screen.
|
|
|
|
|
CoordType m_Width;
|
|
|
|
|
/// The baseline for drawing objects
|
|
|
|
|
CoordType m_BaseLine;
|
|
|
|
|
/// The position on the canvas.
|
|
|
|
|
wxPoint m_Position;
|
|
|
|
|
/// The list of objects
|
|
|
|
|
wxLayoutObjectList m_ObjectList;
|
|
|
|
|
/// Have we been changed since the last layout?
|
|
|
|
|
bool m_Dirty;
|
|
|
|
|
/// Pointer to previous line if it exists.
|
|
|
|
|
wxLayoutLine *m_Previous;
|
|
|
|
|
/// Pointer to next line if it exists.
|
|
|
|
|
wxLayoutLine *m_Next;
|
|
|
|
|
/// Just to suppress gcc compiler warnings.
|
|
|
|
|
friend class dummy;
|
1999-04-12 16:06:46 -04:00
|
|
|
|
private:
|
|
|
|
|
wxLayoutLine(const wxLayoutLine &);
|
1998-10-25 06:08:43 -05:00
|
|
|
|
};
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
|
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
|
|
|
|
|
|
The wxLayoutList object
|
|
|
|
|
|
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
/** The wxLayoutList is a list of wxLayoutLine objects. It provides a
|
|
|
|
|
higher level of abstraction for the text and can generally be considered
|
|
|
|
|
as representing "the text".
|
|
|
|
|
*/
|
|
|
|
|
class wxLayoutList
|
1998-06-29 08:44:36 -04:00
|
|
|
|
{
|
|
|
|
|
public:
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// Constructor.
|
1998-06-29 08:44:36 -04:00
|
|
|
|
wxLayoutList();
|
|
|
|
|
/// Destructor.
|
|
|
|
|
~wxLayoutList();
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// Clear the list.
|
|
|
|
|
void Clear(int family = wxROMAN,
|
|
|
|
|
int size=WXLO_DEFAULTFONTSIZE,
|
|
|
|
|
int style=wxNORMAL,
|
|
|
|
|
int weight=wxNORMAL,
|
|
|
|
|
int underline=0,
|
1999-04-12 16:06:46 -04:00
|
|
|
|
wxColour *fg=NULL,
|
|
|
|
|
wxColour *bg=NULL);
|
1999-03-14 16:22:10 -05:00
|
|
|
|
/// Empty: clear the list but leave font settings.
|
|
|
|
|
void Empty(void);
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/**@name Cursor Management */
|
|
|
|
|
//@{
|
|
|
|
|
/** Set new cursor position.
|
|
|
|
|
@param p new position
|
|
|
|
|
@return bool if it could be set
|
|
|
|
|
*/
|
|
|
|
|
bool MoveCursorTo(wxPoint const &p);
|
|
|
|
|
/** Move cursor up or down.
|
|
|
|
|
@param n
|
|
|
|
|
@return bool if it could be moved
|
|
|
|
|
*/
|
|
|
|
|
bool MoveCursorVertically(int n);
|
|
|
|
|
/** Move cursor left or right.
|
|
|
|
|
@param n
|
|
|
|
|
@return bool if it could be moved
|
|
|
|
|
*/
|
|
|
|
|
bool MoveCursorHorizontally(int n);
|
|
|
|
|
|
|
|
|
|
/// Move cursor to end of line.
|
|
|
|
|
void MoveCursorToEndOfLine(void)
|
|
|
|
|
{
|
|
|
|
|
wxASSERT(m_CursorLine);
|
|
|
|
|
MoveCursorHorizontally(m_CursorLine->GetLength()-m_CursorPos.x);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Move cursor to begin of line.
|
|
|
|
|
void MoveCursorToBeginOfLine(void)
|
|
|
|
|
{ MoveCursorHorizontally(-m_CursorPos.x); }
|
|
|
|
|
|
|
|
|
|
/// Returns current cursor position.
|
1999-04-12 16:06:46 -04:00
|
|
|
|
wxPoint GetCursorPos(wxDC &dc) const { return m_CursorPos; }
|
1999-03-07 16:38:50 -05:00
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
/**@name Editing functions.
|
|
|
|
|
All of these functions return true on success and false on
|
|
|
|
|
failure. */
|
|
|
|
|
//@{
|
|
|
|
|
/// Insert text at current cursor position.
|
|
|
|
|
bool Insert(wxString const &text);
|
|
|
|
|
/// Insert some other object at current cursor position.
|
|
|
|
|
bool Insert(wxLayoutObject *obj);
|
|
|
|
|
/// Inserts a linebreak at current cursor position.
|
|
|
|
|
bool LineBreak(void);
|
1999-03-14 11:04:57 -05:00
|
|
|
|
/** Wraps the current line. Searches to the left of the cursor to
|
|
|
|
|
break the line. Does nothing if the cursor position is before
|
|
|
|
|
the break position parameter.
|
|
|
|
|
@param column the break position for the line, maximum length
|
|
|
|
|
@return true if line got broken
|
|
|
|
|
*/
|
|
|
|
|
bool WrapLine(CoordType column);
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** This function deletes npos cursor positions.
|
|
|
|
|
@param npos how many positions
|
|
|
|
|
@return true if everything got deleted
|
|
|
|
|
*/
|
|
|
|
|
bool Delete(CoordType npos);
|
|
|
|
|
|
|
|
|
|
/** Delete the next n lines.
|
|
|
|
|
@param n how many lines to delete
|
|
|
|
|
@return how many it could not delete
|
|
|
|
|
*/
|
|
|
|
|
int DeleteLines(int n);
|
|
|
|
|
|
|
|
|
|
/// Delete to end of line.
|
|
|
|
|
void DeleteToEndOfLine(void)
|
|
|
|
|
{
|
|
|
|
|
wxASSERT(m_CursorLine);
|
|
|
|
|
Delete(m_CursorLine->GetLength()-m_CursorPos.x);
|
|
|
|
|
}
|
|
|
|
|
/// Delete to begin of line.
|
|
|
|
|
void DeleteToBeginOfLine(void)
|
|
|
|
|
{
|
|
|
|
|
wxASSERT(m_CursorLine);
|
|
|
|
|
CoordType n = m_CursorPos.x;
|
|
|
|
|
#ifdef WXLAYOUT_DEBUG
|
|
|
|
|
wxASSERT(MoveCursorHorizontally(-n));
|
|
|
|
|
#else
|
|
|
|
|
MoveCursorHorizontally(-n);
|
|
|
|
|
#endif
|
|
|
|
|
Delete(n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Delete the next word.
|
|
|
|
|
*/
|
|
|
|
|
void DeleteWord(void)
|
|
|
|
|
{
|
|
|
|
|
wxASSERT(m_CursorLine);
|
|
|
|
|
m_CursorLine->DeleteWord(m_CursorPos.x);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
/**@name Formatting options */
|
|
|
|
|
//@{
|
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,
|
1999-04-12 16:06:46 -04:00
|
|
|
|
wxColour *fg,
|
|
|
|
|
wxColour *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
|
1999-05-11 16:43:12 -04:00
|
|
|
|
inline void SetFontColour(char const *fg, char const *bg = NULL)
|
|
|
|
|
{ SetFont(-1,-1,-1,-1,-1,fg,bg); }
|
1999-05-10 06:44:09 -04:00
|
|
|
|
/// set font colours by colour
|
1999-05-11 16:43:12 -04:00
|
|
|
|
inline void SetFontColour(wxColour *fg, wxColour *bg = NULL)
|
|
|
|
|
{ SetFont(-1,-1,-1,-1,-1,fg,bg); }
|
|
|
|
|
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/**
|
|
|
|
|
Returns a pointer to the default settings.
|
|
|
|
|
This is only valid temporarily and should not be stored
|
|
|
|
|
anywhere.
|
|
|
|
|
@return the default settings of the list
|
1998-11-19 15:34:59 -05:00
|
|
|
|
*/
|
1999-05-12 18:14:51 -04:00
|
|
|
|
wxLayoutStyleInfo *GetDefaults(void) { return m_DefaultSetting ; }
|
1999-03-07 16:38:50 -05:00
|
|
|
|
//@}
|
1998-11-19 15:34:59 -05:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/**@name Drawing */
|
|
|
|
|
//@{
|
|
|
|
|
/** Draws the complete list on a wxDC.
|
|
|
|
|
@param dc the wxDC to draw on
|
|
|
|
|
@param offset an optional offset to shift printout
|
|
|
|
|
@param top optional y coordinate where to start drawing
|
|
|
|
|
@param bottom optional y coordinate where to stop drawing
|
1998-10-24 14:08:20 -04:00
|
|
|
|
*/
|
1999-05-08 14:01:24 -04:00
|
|
|
|
void Draw(wxDC &dc,
|
|
|
|
|
const wxPoint &offset = wxPoint(0,0),
|
1999-04-12 16:06:46 -04:00
|
|
|
|
CoordType top = -1, CoordType bottom = -1);
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** Calculates new layout for the list, like Draw() but does not
|
|
|
|
|
actually draw it.
|
|
|
|
|
@param dc the wxDC to draw on
|
|
|
|
|
@param bottom optional y coordinate where to stop calculating
|
|
|
|
|
*/
|
1999-04-12 16:06:46 -04:00
|
|
|
|
void Layout(wxDC &dc, CoordType bottom = -1);
|
1999-03-14 11:04:57 -05:00
|
|
|
|
|
|
|
|
|
/** Calculates new sizes for everything in the list, like Layout()
|
|
|
|
|
but this is needed after the list got changed.
|
|
|
|
|
@param dc the wxDC to draw on
|
|
|
|
|
@param bottom optional y coordinate where to stop calculating
|
|
|
|
|
*/
|
1999-04-12 16:06:46 -04:00
|
|
|
|
void Recalculate(wxDC &dc, CoordType bottom = -1);
|
1999-03-14 11:04:57 -05:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** Returns the size of the list in screen coordinates.
|
|
|
|
|
The return value only makes sense after the list has been
|
|
|
|
|
drawn.
|
|
|
|
|
@return a wxPoint holding the maximal x/y coordinates used for
|
|
|
|
|
drawing
|
|
|
|
|
*/
|
|
|
|
|
wxPoint GetSize(void) const;
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** Returns the cursor position on the screen.
|
|
|
|
|
@return cursor position in pixels
|
|
|
|
|
*/
|
1999-04-12 16:06:46 -04:00
|
|
|
|
wxPoint GetCursorScreenPos(wxDC &dc);
|
1999-03-07 16:38:50 -05:00
|
|
|
|
|
|
|
|
|
/** Draws the cursor.
|
|
|
|
|
@param active If true, draw a bold cursor to mark window as
|
|
|
|
|
active.
|
|
|
|
|
@param translate optional translation of cursor coords on screen
|
|
|
|
|
*/
|
|
|
|
|
void DrawCursor(wxDC &dc,
|
|
|
|
|
bool active = true,
|
|
|
|
|
const wxPoint & translate = wxPoint(0,0));
|
|
|
|
|
|
1999-03-14 11:04:57 -05:00
|
|
|
|
/** This function finds an object belonging to a given screen
|
1999-03-07 16:38:50 -05:00
|
|
|
|
position. It assumes that Layout() has been called before.
|
|
|
|
|
@param pos screen position
|
1999-03-14 11:04:57 -05:00
|
|
|
|
@param cursorPos if non NULL, store cursor position in there
|
1999-05-08 14:01:24 -04:00
|
|
|
|
@param found if used, set this to true if we really found an
|
|
|
|
|
object, to false if we had to take the object near to it
|
1999-03-07 16:38:50 -05:00
|
|
|
|
@return pointer to the object
|
|
|
|
|
*/
|
1999-03-14 11:04:57 -05:00
|
|
|
|
wxLayoutObject * FindObjectScreen(wxDC &dc,
|
|
|
|
|
wxPoint const pos,
|
1999-05-08 14:01:24 -04:00
|
|
|
|
wxPoint *cursorPos = NULL,
|
|
|
|
|
bool *found = NULL);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1999-05-08 14:01:24 -04:00
|
|
|
|
/** Called by the objects to update the update rectangle.
|
|
|
|
|
@param x horizontal coordinate to include in rectangle
|
|
|
|
|
@param y vertical coordinate to include in rectangle
|
|
|
|
|
*/
|
|
|
|
|
void SetUpdateRect(CoordType x, CoordType y);
|
1999-03-29 04:56:44 -05:00
|
|
|
|
/** Called by the objects to update the update rectangle.
|
|
|
|
|
@param p a point to include in it
|
|
|
|
|
*/
|
1999-05-08 14:01:24 -04:00
|
|
|
|
inline void SetUpdateRect(const wxPoint &p)
|
|
|
|
|
{ SetUpdateRect(p.x,p.y); }
|
1999-03-29 04:56:44 -05:00
|
|
|
|
/// Invalidates the update rectangle.
|
|
|
|
|
void InvalidateUpdateRect(void) { m_UpdateRectValid = false; }
|
|
|
|
|
/// Returns the update rectangle.
|
|
|
|
|
const wxRect *GetUpdateRect(void) const { return &m_UpdateRect; }
|
1999-03-07 16:38:50 -05:00
|
|
|
|
//@}
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/**@name For exporting one object after another. */
|
1998-06-29 08:44:36 -04:00
|
|
|
|
//@{
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** Returns a pointer to the first line in the list. */
|
|
|
|
|
wxLayoutLine *GetFirstLine(void)
|
|
|
|
|
{
|
|
|
|
|
wxASSERT(m_FirstLine);
|
|
|
|
|
return m_FirstLine;
|
|
|
|
|
}
|
|
|
|
|
//@}
|
1999-04-12 16:06:46 -04:00
|
|
|
|
|
1999-05-08 14:01:24 -04:00
|
|
|
|
/// Begin selecting text.
|
1999-04-12 16:06:46 -04:00
|
|
|
|
void StartSelection(void);
|
1999-05-09 13:28:58 -04:00
|
|
|
|
// Continue selecting text
|
|
|
|
|
void ContinueSelection(void);
|
1999-05-08 14:01:24 -04:00
|
|
|
|
/// End selecting text.
|
1999-04-12 16:06:46 -04:00
|
|
|
|
void EndSelection(void);
|
1999-05-08 14:01:24 -04:00
|
|
|
|
/// Are we still selecting text?
|
|
|
|
|
bool IsSelecting(void);
|
1999-04-12 16:06:46 -04:00
|
|
|
|
bool IsSelected(const wxPoint &cursor);
|
|
|
|
|
|
1999-05-11 16:43:12 -04:00
|
|
|
|
/// Return the selection as a wxLayoutList:
|
|
|
|
|
wxLayoutList *GetSelection(void);
|
1999-05-12 18:14:51 -04:00
|
|
|
|
/// Delete selected bit
|
|
|
|
|
void DeleteSelection(void);
|
1999-05-11 16:43:12 -04:00
|
|
|
|
|
|
|
|
|
wxLayoutList *Copy(const wxPoint &from = wxPoint(0,0),
|
|
|
|
|
const wxPoint &to = wxPoint(-1,-1));
|
|
|
|
|
|
1999-05-09 13:28:58 -04:00
|
|
|
|
/// starts highlighting of text for selections
|
|
|
|
|
void StartHighlighting(wxDC &dc);
|
|
|
|
|
/// ends highlighting of text for selections
|
|
|
|
|
void EndHighlighting(wxDC &dc);
|
|
|
|
|
|
1999-05-09 11:24:57 -04:00
|
|
|
|
/** Tests whether this layout line is selected and needs
|
|
|
|
|
highlighting.
|
|
|
|
|
@param line to test for
|
|
|
|
|
@param from set to first cursorpos to be highlighted (for returncode == -1)
|
|
|
|
|
@param to set to last cursorpos to be highlighted (for returncode == -1)
|
|
|
|
|
@return 0 = not selected, 1 = fully selected, -1 = partially
|
|
|
|
|
selected
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
int IsSelected(const wxLayoutLine *line, CoordType *from, CoordType *to);
|
1999-05-12 18:14:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ApplyStyle(wxLayoutStyleInfo *si, wxDC &dc);
|
1999-05-08 14:01:24 -04:00
|
|
|
|
#ifdef WXLAYOUT_DEBUG
|
|
|
|
|
void Debug(void);
|
|
|
|
|
#endif
|
1999-03-07 16:38:50 -05:00
|
|
|
|
private:
|
|
|
|
|
/// Clear the list.
|
|
|
|
|
void InternalClear(void);
|
1999-04-12 16:06:46 -04:00
|
|
|
|
/** Calculates the cursor position on the screen.
|
|
|
|
|
*/
|
|
|
|
|
void UpdateCursorScreenPos(wxDC &dc);
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// The list of lines.
|
|
|
|
|
wxLayoutLine *m_FirstLine;
|
1999-03-29 04:56:44 -05:00
|
|
|
|
/// The update rectangle which needs to be refreshed:
|
|
|
|
|
wxRect m_UpdateRect;
|
|
|
|
|
/// Is the update rectangle valid?
|
|
|
|
|
bool m_UpdateRectValid;
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/**@name Cursor Management */
|
|
|
|
|
//@{
|
|
|
|
|
/// Where the text cursor (column,line) is.
|
|
|
|
|
wxPoint m_CursorPos;
|
|
|
|
|
/// The size of the cursor.
|
|
|
|
|
wxPoint m_CursorSize;
|
|
|
|
|
/// Where the cursor should be drawn.
|
|
|
|
|
wxPoint m_CursorScreenPos;
|
|
|
|
|
/// The line where the cursor is.
|
|
|
|
|
wxLayoutLine *m_CursorLine;
|
|
|
|
|
//@}
|
1998-07-29 09:57:51 -04:00
|
|
|
|
|
1999-04-12 16:06:46 -04:00
|
|
|
|
/// A structure for the selection.
|
1999-04-13 18:24:24 -04:00
|
|
|
|
struct Selection
|
1999-04-12 16:06:46 -04:00
|
|
|
|
{
|
1999-05-10 07:51:04 -04:00
|
|
|
|
Selection() { m_valid = false; m_selecting = false; }
|
1999-04-12 16:06:46 -04:00
|
|
|
|
bool m_valid;
|
1999-05-08 14:01:24 -04:00
|
|
|
|
bool m_selecting;
|
1999-04-12 16:06:46 -04:00
|
|
|
|
wxPoint m_CursorA, m_CursorB;
|
1999-04-13 18:24:24 -04:00
|
|
|
|
} m_Selection;
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** @name Font parameters. */
|
|
|
|
|
//@{
|
1998-06-29 08:44:36 -04:00
|
|
|
|
int m_FontFamily, m_FontStyle, m_FontWeight;
|
|
|
|
|
int m_FontPtSize;
|
|
|
|
|
bool m_FontUnderline;
|
|
|
|
|
/// colours:
|
1999-04-12 16:06:46 -04:00
|
|
|
|
wxColour m_ColourFG;
|
|
|
|
|
wxColour m_ColourBG;
|
1998-07-12 11:02:44 -04:00
|
|
|
|
/// the default setting:
|
1999-05-12 18:14:51 -04:00
|
|
|
|
wxLayoutStyleInfo *m_DefaultSetting;
|
|
|
|
|
/// the current setting:
|
|
|
|
|
wxLayoutStyleInfo m_CurrentSetting;
|
1999-03-07 16:38:50 -05:00
|
|
|
|
//@}
|
|
|
|
|
};
|
1998-10-24 14:08:20 -04:00
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
|
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
|
|
|
|
|
|
The wxLayoutPrintout object for printing within the wxWindows print
|
|
|
|
|
framework.
|
|
|
|
|
|
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
/** This class implements a wxPrintout for printing a wxLayoutList within
|
|
|
|
|
the wxWindows printing framework.
|
|
|
|
|
*/
|
1998-08-14 04:33:33 -04:00
|
|
|
|
class wxLayoutPrintout: public wxPrintout
|
|
|
|
|
{
|
1999-03-07 16:38:50 -05:00
|
|
|
|
public:
|
|
|
|
|
/** Constructor.
|
|
|
|
|
@param llist pointer to the wxLayoutList to be printed
|
|
|
|
|
@param title title for PS file or windows
|
|
|
|
|
*/
|
|
|
|
|
wxLayoutPrintout(wxLayoutList *llist,
|
|
|
|
|
wxString const & title =
|
1998-10-30 05:14:58 -05:00
|
|
|
|
"wxLayout Printout");
|
1999-05-08 14:01:24 -04:00
|
|
|
|
/// Destructor.
|
|
|
|
|
~wxLayoutPrintout();
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** Function which prints the n-th page.
|
|
|
|
|
@param page the page number to print
|
|
|
|
|
@return bool true if we are not at end of document yet
|
|
|
|
|
*/
|
1998-10-24 14:08:20 -04:00
|
|
|
|
bool OnPrintPage(int page);
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** Checks whether page exists in document.
|
|
|
|
|
@param page number of page
|
|
|
|
|
@return true if page exists
|
|
|
|
|
*/
|
1998-10-24 14:08:20 -04:00
|
|
|
|
bool HasPage(int page);
|
1999-03-07 16:38:50 -05:00
|
|
|
|
|
|
|
|
|
/** Gets called from wxWindows to find out which pages are existing.
|
|
|
|
|
I'm not totally sure about the parameters though.
|
|
|
|
|
@param minPage the first page in the document
|
|
|
|
|
@param maxPage the last page in the document
|
|
|
|
|
@param selPageFrom the first page to be printed
|
|
|
|
|
@param selPageTo the last page to be printed
|
|
|
|
|
*/
|
|
|
|
|
void GetPageInfo(int *minPage, int *maxPage,
|
|
|
|
|
int *selPageFrom, int *selPageTo);
|
1998-10-27 04:55:07 -05:00
|
|
|
|
protected:
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/** This little function scales the DC so that the printout has
|
|
|
|
|
roughly the same size as the output on screen.
|
|
|
|
|
@param dc the wxDC to scale
|
|
|
|
|
@return the scale that was applied
|
|
|
|
|
*/
|
|
|
|
|
float ScaleDC(wxDC *dc);
|
|
|
|
|
|
|
|
|
|
/* no longer used
|
|
|
|
|
virtual void DrawHeader(wxDC &dc, wxPoint topleft, wxPoint bottomright, int pageno);
|
|
|
|
|
*/
|
1998-08-14 04:33:33 -04:00
|
|
|
|
private:
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// The list to print.
|
1998-08-14 04:33:33 -04:00
|
|
|
|
wxLayoutList *m_llist;
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// Title for PS file or window.
|
1998-10-27 04:55:07 -05:00
|
|
|
|
wxString m_title;
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// The real paper size.
|
1998-10-25 06:08:43 -05:00
|
|
|
|
int m_PageHeight, m_PageWidth;
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// How much we actually print per page.
|
1998-10-27 04:55:07 -05:00
|
|
|
|
int m_PrintoutHeight;
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// How many pages we need to print.
|
1998-10-25 06:08:43 -05:00
|
|
|
|
int m_NumOfPages;
|
1999-03-07 16:38:50 -05:00
|
|
|
|
/// Top left corner where we start printing.
|
|
|
|
|
wxPoint m_Offset;
|
1998-08-14 04:33:33 -04:00
|
|
|
|
};
|
|
|
|
|
|
1999-03-07 16:38:50 -05:00
|
|
|
|
|
1998-06-29 08:44:36 -04:00
|
|
|
|
#endif // WXLLIST_H
|