X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/23f641681ff8f715c49f21ac61b8cd522835a758..362c669367af6c1b024d531c31a76692a6e9ad13:/user/wxLayout/wxllist.h?ds=sidebyside diff --git a/user/wxLayout/wxllist.h b/user/wxLayout/wxllist.h index d7d5d4b497..8959a80e10 100644 --- a/user/wxLayout/wxllist.h +++ b/user/wxLayout/wxllist.h @@ -14,13 +14,18 @@ #include "kbList.h" -#include +#include "wx/wx.h" // skip the following defines if embedded in M application -#ifndef MCONFIG_H -// for testing only: +#ifdef M_BASEDIR +# ifdef DEBUG +//# define WXLAYOUT_DEBUG +# endif +#else + // for testing only: # define WXLAYOUT_DEBUG -# cdefine USE_STD_STRING + // The wxLayout classes can be compiled with std::string instead of wxString + //# define USE_STD_STRING #endif #ifdef USE_STD_STRING @@ -32,20 +37,28 @@ # define Str(str) str #endif -enum wxLayoutObjectType { WXLO_TYPE_INVALID, WXLO_TYPE_TEXT, WXLO_TYPE_CMD, WXLO_TYPE_ICON, WXLO_TYPE_LINEBREAK }; +/// Types of currently supported layout objects. +enum wxLayoutObjectType +{ WXLO_TYPE_INVALID, WXLO_TYPE_TEXT, WXLO_TYPE_CMD, WXLO_TYPE_ICON, WXLO_TYPE_LINEBREAK }; +/// Type used for coordinates in drawing. typedef long CoordType; class wxLayoutList; class wxLayoutObjectBase; -KBLIST_DEFINE(wxLayoutObjectList, wxLayoutObjectBase); -KBLIST_DEFINE(wxLayoutOLinesList, wxLayoutObjectList::iterator); - +class wxDC; +class wxColour; +class wxFont; +/** 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. +*/ class wxLayoutObjectBase { public: + /// return the type of this object virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_INVALID; } ; /** Draws an object. @param dc the wxDC to draw on @@ -56,24 +69,41 @@ public: virtual void Draw(wxDC &dc, wxPoint position, CoordType baseLine, bool draw = true) {}; + /** Calculates and returns the size of the object. May need to be + called twice to work. + @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 + */ virtual wxPoint GetSize(CoordType *baseLine) const { return wxPoint(0,0); }; /// returns the number of cursor positions occupied by this object virtual CoordType CountPositions(void) const { return 1; } + /// constructor wxLayoutObjectBase() { m_UserData = NULL; } + /// note: any user data will be freed at the time the object is deleted virtual ~wxLayoutObjectBase() { if(m_UserData) delete m_UserData; } #ifdef WXLAYOUT_DEBUG virtual void Debug(void); #endif + /** Tells the object about some user data. This data is associated + with the object and will be deleted at destruction time. + */ void SetUserData(void *data) { m_UserData = data; } + /** Return the user data. */ void * GetUserData(void) const { return m_UserData; } private: /// optional data for application's use void * m_UserData; }; +/// Define a list type of wxLayoutObjectBase pointers. +KBLIST_DEFINE(wxLayoutObjectList, wxLayoutObjectBase); + + /// object for text block class wxLayoutObjectText : public wxLayoutObjectBase { @@ -113,8 +143,9 @@ public: bool draw = true); virtual wxPoint GetSize(CoordType *baseLine) const; wxLayoutObjectIcon(wxIcon *icon); + private: - wxIcon * m_Icon; + wxIcon *m_Icon; }; /// for export to html: @@ -137,8 +168,10 @@ public: bool underline, wxColour const *fg, wxColour const *bg); ~wxLayoutObjectCmd(); - // caller must free pointer: + /// caller must free pointer: wxLayoutStyleInfo *GetStyle(void) const ; + /// return the background colour for setting colour of window + wxColour const *GetBGColour(void) const { return m_ColourBG; } private: /// the font to use wxFont *m_font; @@ -213,10 +246,13 @@ public: /**@name Functionality for editing */ //@{ /// set list editable or read only - void SetEditable(bool editable = true) { m_Editable = true; } + void SetEditable(bool editable = true) { m_Editable = editable; } + /// return true if list is editable + bool IsEditable(void) const { return m_Editable; } /// move cursor void MoveCursor(int dx = 0, int dy = 0); void SetCursor(wxPoint const &p) { m_CursorPosition = p; } + wxPoint GetCursor(void) const { return m_CursorPosition; } /// delete one or more cursor positions void Delete(CoordType count = 1); void Insert(String const &text); @@ -224,7 +260,13 @@ public: void Clear(int family = wxROMAN, int size=12, int style=wxNORMAL, int weight=wxNORMAL, int underline=0, char const *fg="black", char const *bg="white"); - //@} + /// return a pointer to the default settings: + wxLayoutObjectCmd const *GetDefaults(void) const { return m_DefaultSetting ; } + + wxLayoutObjectList::iterator FindCurrentObject(CoordType *offset = NULL); + // get the length of the line with the object pointed to by i + CoordType GetLineLength(wxLayoutObjectList::iterator i); +//@} protected: /// font parameters: int m_FontFamily, m_FontStyle, m_FontWeight; @@ -258,10 +300,7 @@ protected: bool m_Editable; /// find the object to the cursor position and returns the offset /// in there - wxLayoutObjectList::iterator FindObjectCursor(wxPoint const &cpos, CoordType *offset = NULL); - wxLayoutObjectList::iterator FindCurrentObject(CoordType *offset = NULL); - // get the length of the line with the object pointed to by i - CoordType GetLineLength(wxLayoutObjectList::iterator i); + wxLayoutObjectList::iterator FindObjectCursor(wxPoint *cpos, CoordType *offset = NULL); };