heightOld = m_Height;
#endif // 0
+#ifdef __WXDEBUG__
+ CoordType a,b,c,d,e,f;
+ dc.GetTextExtent("test ", &a, &b, &c);
+ dc.GetTextExtent("test", &d, &e, &f);
+ wxASSERT(a != d);
+ wxASSERT(b == e);
+ wxASSERT(c == f);
+ dc.GetTextExtent(" ", &d, &e, &f);
+ wxASSERT(a > 0);
+#endif
dc.GetTextExtent(m_Text, &m_Width, &m_Height, &descent);
#if 0
wxLayoutObjectIcon::wxLayoutObjectIcon(wxBitmap *icon)
{
m_Icon = icon;
+ if(! m_Icon)
+#if wxICON_IS_BITMAP
+ m_Icon = new wxIcon;
+#else
+ m_Icon = new wxBitmap;
+#endif
}
void
m_StyleInfo = new wxLayoutStyleInfo(family, size,style,weight,underline,fg,bg);
}
+wxLayoutObjectCmd::wxLayoutObjectCmd(const wxLayoutStyleInfo &si)
+
+{
+ m_StyleInfo = new wxLayoutStyleInfo;
+ *m_StyleInfo = si;
+}
+
wxLayoutObject *
wxLayoutObjectCmd::Copy(void)
{
wxLayoutObjectCmd *obj = new wxLayoutObjectCmd(
- m_StyleInfo->size,
m_StyleInfo->family,
+ m_StyleInfo->size,
m_StyleInfo->style,
m_StyleInfo->weight,
m_StyleInfo->underline,
wxLayoutObjectCmd::Write(wxString &ostr)
{
ostr << WXLO_TYPE_CMD << '\n'
- << m_StyleInfo->size << '\n'
<< m_StyleInfo->family << '\n'
+ << m_StyleInfo->size << '\n'
<< m_StyleInfo->style << '\n'
<< m_StyleInfo->weight << '\n'
<< m_StyleInfo->underline << '\n'
wxString tmp;
ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->size);
- ReadString(tmp, istr);
sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->family);
ReadString(tmp, istr);
+ sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->size);
+ ReadString(tmp, istr);
sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->style);
ReadString(tmp, istr);
sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->weight);
{
// this might be the case if the cursor is at the end of the
// line or on a command object:
- if(cursorSize->y < WXLO_MINIMUM_CURSOR_WIDTH)
+ if(cursorSize->x < WXLO_MINIMUM_CURSOR_WIDTH)
{
CoordType width, height, descent;
dc.GetTextExtent(WXLO_CURSORCHAR, &width, &height, &descent);
m_CursorStyleInfo = m_DefaultStyleInfo;
}
+void
+wxLayoutList::Read(wxString &istr)
+{
+ /* In order to handle input of formatted string "nicely", we need
+ to restore our current font settings after the string. So first
+ of all, we create a StyleInfo structure with our current
+ settings. */
+ wxLayoutStyleInfo current_si = GetStyleInfo();
+
+ while(istr.Length())
+ {
+ wxLayoutObject *obj = wxLayoutObject::Read(istr);
+ if(obj)
+ Insert(obj);
+ }
+ /* Now we use the current_si to restore our last font settings: */
+ Insert(new wxLayoutObjectCmd(current_si));
+}
+
+
void
wxLayoutList::SetFont(int family, int size, int style, int weight,
int underline, wxColour *fg,
m_CursorLine = m_CursorLine->Break(m_CursorPos.x, this);
if(m_CursorLine->GetPreviousLine() == NULL)
m_FirstLine = m_CursorLine;
- if(m_CursorPos.x > 0)
- m_CursorPos.y++;
+ m_CursorPos.y++;
m_CursorPos.x = 0;
// The following code will produce a height which is guaranteed to
cursorPos->y = line->GetLineNumber();
bool foundinline = true;
+ long cx = 0;
+
// Now, find the object in the line:
- wxLOiterator i = line->FindObjectScreen(dc, this,
+ wxLOiterator i;
+
+ if (cursorPos)
+ {
+ i = line->FindObjectScreen(dc, this,
pos.x,
- cursorPos ? &cursorPos->x : NULL,
+ &cx,
+ &foundinline);
+ cursorPos->x = cx;
+ }
+ else
+ i = line->FindObjectScreen(dc, this,
+ pos.x,
+ NULL,
&foundinline);
if ( found )
*found = didFind && foundinline;
#ifdef WXLAYOUT_USE_CARET
m_caret->Move(coords);
#else // !WXLAYOUT_USE_CARET
+
+ wxASSERT(m_CursorSize.x >= WXLO_MINIMUM_CURSOR_WIDTH);
dc.SetBrush(*wxWHITE_BRUSH);
//FIXME: wxGTK XOR is borken at the moment!!!dc.SetLogicalFunction(wxXOR);
dc.SetPen(wxPen(*wxBLACK,1,wxSOLID));
wxASSERT(m_Selection.m_valid == false);
WXLO_DEBUG(("Continuing selection at %ld/%ld", cpos.x, cpos.y));
- m_Selection.m_ScreenB = spos;
- m_Selection.m_CursorB = cpos;}
+ m_Selection.m_ScreenB = spos;
+ m_Selection.m_CursorB = cpos;
+}
void
wxLayoutList::EndSelection(const wxPoint& cposOrig, const wxPoint& spos)
{
wxPoint cpos(cposOrig);
- if(cpos.x == -1)
- cpos = m_CursorPos;
- ContinueSelection(cpos);
+ if(cpos.x == -1) cpos = m_CursorPos;
+ ContinueSelection(cpos, spos);
WXLO_DEBUG(("Ending selection at %ld/%ld", cpos.x, cpos.y));
// we always want m_CursorA <= m_CursorB!
if( m_Selection.m_CursorA > m_Selection.m_CursorB )
exp->content.object->Write(string);
delete exp;
}
-
- wxlo->SetData(string.c_str(), string.Length()+1);
+ wxlo->SetLayoutData(string);
}
return llist;
}
if(si.m_fg_valid)
{
m_CurrentStyleInfo.m_fg = si.m_fg;
+ m_CurrentStyleInfo.m_fg_valid = true;
dc.SetTextForeground(m_CurrentStyleInfo.m_fg);
}
if(si.m_bg_valid)
{
m_CurrentStyleInfo.m_bg = si.m_bg;
+ m_CurrentStyleInfo.m_bg_valid = true;
dc.SetTextBackground(m_CurrentStyleInfo.m_bg);
}
}