#endif
#include "wxllist.h"
-#include "iostream"
+#include "iostream.h"
#include <wx/dc.h>
#include <wx/postscrp.h>
#define BASELINESTRETCH 12
-#define VAR(x) cerr << #x"=" << x << endl;
-#define DBG_POINT(p) cerr << #p << ": " << p.x << ',' << p.y << endl
-#define TRACE(f) cerr << #f":" << endl;
-
#ifdef WXLAYOUT_DEBUG
static const char *_t[] = { "invalid", "text", "cmd", "icon",
"linebreak"};
cerr << _t[GetType()] << ": size=" << GetSize(&bl).x << ","
<< GetSize(&bl).y << " bl=" << bl;
}
+
+# define VAR(x) cerr << #x"=" << x << endl;
+# define DBG_POINT(p) cerr << #p << ": " << p.x << ',' << p.y << endl
+# define TRACE(f) cerr << #f":" << endl;
+#else
+# define VAR(x)
+# define DBG_POINT(p)
+# define TRACE(f)
#endif
//-------------------------- wxLayoutObjectText
// setting up the default:
dc.SetTextForeground( *wxBLACK );
+ dc.SetTextBackground( *wxWHITE );
+ dc.SetBackgroundMode( wxSOLID ); // to enable setting of text background
dc.SetFont( *wxNORMAL_FONT );
+
+ //FIXME: who frees the brush, how long does it need to exist?
if(m_DefaultSetting)
m_DefaultSetting->Draw(dc,wxPoint(0,0),0,true);
-
+
// we calculate everything for drawing a line, then rewind to the
// begin of line and actually draw it
i = begin();
dc.GetTextExtent(Str(str), &width,&height, &descent);
VAR(height);
VAR(width); VAR(descent);
+ if(width < 1) width = 1;
dc.DrawLine(position.x+width,
position.y+(baseLineSkip-height),
position.x+width, position.y+baseLineSkip);
// calculate next object's position:
position.x += size.x;
+ if(position.x > m_MaxX)
+ m_MaxX = position.x;
// do we need to increase the line's height?
if(size.y > baseLineSkip)
draw = false;
}
- if(position.x+size.x > m_MaxX)
- m_MaxX = position.x+size.x;
// is it a linebreak?
if(type == WXLO_TYPE_LINEBREAK || i == tail())
{
/******************** editing stuff ********************/
+// don't change this, I know how to optimise this and will do it real
+// soon (KB)
+
wxLayoutObjectList::iterator
wxLayoutList::FindObjectCursor(wxPoint const &cpos, CoordType *offset)
{
width = 0;
if((*i)->GetType() == WXLO_TYPE_LINEBREAK)
{
- if(cpos.y == cursor.y)
+ if(cpos.y == cursor.y && i != begin())
{
--i;
- if(offset)
- *offset = (*i)->CountPositions();
+ if(offset) *offset = i != end() ? (*i)->CountPositions() : 0;
return i;
}
cursor.x = 0; cursor.y ++;
if(offs == len)
{
i++;
- if((*i)->GetType() == WXLO_TYPE_TEXT)
+ if(i != end() && (*i)->GetType() == WXLO_TYPE_TEXT)
{
offs = 0; // delete from begin of next string
tobj = (wxLayoutObjectText *)*i;
m_ColourFG = wxTheColourDatabase->FindColour(fg);
m_ColourBG = wxTheColourDatabase->FindColour(bg);
+ if(! m_ColourFG) m_ColourFG = wxBLACK;
+ if(! m_ColourBG) m_ColourBG = wxWHITE;
+
m_Position = wxPoint(0,0);
m_CursorPosition = wxPoint(0,0);
m_MaxLine = 0;
m_LineHeight = (BASELINESTRETCH*m_FontPtSize)/10;
m_MaxX = 0; m_MaxY = 0;
+
if(m_DefaultSetting)
delete m_DefaultSetting;
m_DefaultSetting = new