The new layout mechanism is better than the old one. :-)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2458 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,36 +20,14 @@ Adding many lines makes it terribly slow.
|
|||||||
|
|
||||||
Printing produces empty pages only.
|
Printing produces empty pages only.
|
||||||
|
|
||||||
Formatting of first text in message in M is broken.
|
|
||||||
Large images in last line don't get displayed properly.
|
|
||||||
Taking last line's height as default for next is rubbish,
|
|
||||||
use "default height" and adjust as necessary.
|
|
||||||
|
|
||||||
Selections:
|
Selections:
|
||||||
- moving in negative direction doesn't work
|
- moving in negative direction doesn't work
|
||||||
- selection state not properly reset, only works once
|
- selection state not properly reset, only works once
|
||||||
- selecting non-text objects is strange
|
- selecting non-text objects is strange
|
||||||
|
|
||||||
wxllist::GetSize() requires extra Layout() call, which should not be
|
- Changing default settings in Clear() or changing/inserting/deleting
|
||||||
necessary. Find out why this is so.
|
a wxLayoutObject needs to update the m_StyleInfo in all lines, only
|
||||||
YES, it is necessary, because the normal drawing only happens within
|
then can we start using that one.
|
||||||
the visible window.
|
|
||||||
I must find a way to re-Layout() objects. This is only required after
|
|
||||||
their sizes change:
|
|
||||||
- Just mark them as dirty:
|
|
||||||
- mark current line as dirty when editing it (so width gets recalculated)
|
|
||||||
- mark all following lines as dirty when changing font settings
|
|
||||||
- Let Layout() work only on the dirty lines.
|
|
||||||
!!! GOOD: this can also be used to recalculate the wxLayoutObjectCmds'
|
|
||||||
fonts! :-)
|
|
||||||
|
|
||||||
- cursor screen positioning ignores font sizes once again :-(
|
|
||||||
--> UpdateCursorScreenPos() cannot work as it ignores previous font formatting commands.
|
|
||||||
Either draw cursor when drawing text, or wait for new wxLayoutObjectCmd to be fully
|
|
||||||
implemented.
|
|
||||||
|
|
||||||
RECENTLY FIXED (?)
|
|
||||||
- delete in empty line doesn't work
|
|
||||||
|
|
||||||
- update rectangle (needs support in wxllist and wxWindows)
|
- update rectangle (needs support in wxllist and wxWindows)
|
||||||
--> needs a bit of fixing still
|
--> needs a bit of fixing still
|
||||||
@@ -57,12 +35,8 @@ RECENTLY FIXED (?)
|
|||||||
offset handling seems a bit dodgy, white shadow to top/left of cursor
|
offset handling seems a bit dodgy, white shadow to top/left of cursor
|
||||||
|
|
||||||
- replacement of llist in window
|
- replacement of llist in window
|
||||||
- undo
|
|
||||||
- UNDO
|
- UNDO
|
||||||
- DragNDrop
|
- DragNDrop
|
||||||
|
|
||||||
- More optimisations:
|
- Update docs, do full rtf/html editing.
|
||||||
- let each line have a pointer to the last layoutcommand and let that
|
- Verify html export.
|
||||||
one only store the settings that changed, then we no longer need to
|
|
||||||
recalculate all the lines
|
|
||||||
|
|
||||||
|
@@ -400,7 +400,6 @@ wxLayoutLine::wxLayoutLine(wxLayoutLine *prev, wxLayoutList *llist)
|
|||||||
m_LineNumber = m_Previous->GetLineNumber()+1;
|
m_LineNumber = m_Previous->GetLineNumber()+1;
|
||||||
m_Next = m_Previous->GetNextLine();
|
m_Next = m_Previous->GetNextLine();
|
||||||
m_Previous->m_Next = this;
|
m_Previous->m_Next = this;
|
||||||
m_Height = m_Previous->GetHeight();
|
|
||||||
}
|
}
|
||||||
if(m_Next)
|
if(m_Next)
|
||||||
{
|
{
|
||||||
@@ -491,12 +490,10 @@ wxLayoutLine::FindObjectScreen(wxDC &dc,
|
|||||||
|
|
||||||
for(i = m_ObjectList.begin(); i != NULLIT; i++)
|
for(i = m_ObjectList.begin(); i != NULLIT; i++)
|
||||||
{
|
{
|
||||||
//FIXME! (**i).Layout(dc, NULL);
|
|
||||||
width = (**i).GetWidth();
|
width = (**i).GetWidth();
|
||||||
if( x <= xpos && xpos <= x + width )
|
if( x <= xpos && xpos <= x + width )
|
||||||
{
|
{
|
||||||
*cxpos = cx + (**i).GetOffsetScreen(dc, xpos-x);
|
*cxpos = cx + (**i).GetOffsetScreen(dc, xpos-x);
|
||||||
// WXLO_DEBUG(("wxLayoutLine::FindObjectScreen: cursor xpos = %ld", *cxpos));
|
|
||||||
if(found) *found = true;
|
if(found) *found = true;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -546,6 +543,8 @@ wxLayoutLine::Insert(CoordType xpos, wxLayoutObject *obj)
|
|||||||
{
|
{
|
||||||
wxASSERT(xpos >= 0);
|
wxASSERT(xpos >= 0);
|
||||||
wxASSERT(obj != NULL);
|
wxASSERT(obj != NULL);
|
||||||
|
//FIXME: this could be optimised, for now be prudent:
|
||||||
|
m_Dirty = true;
|
||||||
CoordType offset;
|
CoordType offset;
|
||||||
wxLOiterator i = FindObject(xpos, &offset);
|
wxLOiterator i = FindObject(xpos, &offset);
|
||||||
if(i == NULLIT)
|
if(i == NULLIT)
|
||||||
@@ -600,6 +599,8 @@ bool
|
|||||||
wxLayoutLine::Insert(CoordType xpos, wxString text)
|
wxLayoutLine::Insert(CoordType xpos, wxString text)
|
||||||
{
|
{
|
||||||
wxASSERT(xpos >= 0);
|
wxASSERT(xpos >= 0);
|
||||||
|
//FIXME: this could be optimised, for now be prudent:
|
||||||
|
m_Dirty = true;
|
||||||
CoordType offset;
|
CoordType offset;
|
||||||
wxLOiterator i = FindObject(xpos, &offset);
|
wxLOiterator i = FindObject(xpos, &offset);
|
||||||
if(i != NULLIT && (**i).GetType() == WXLO_TYPE_TEXT)
|
if(i != NULLIT && (**i).GetType() == WXLO_TYPE_TEXT)
|
||||||
@@ -621,6 +622,8 @@ wxLayoutLine::Delete(CoordType xpos, CoordType npos)
|
|||||||
|
|
||||||
wxASSERT(xpos >= 0);
|
wxASSERT(xpos >= 0);
|
||||||
wxASSERT(npos >= 0);
|
wxASSERT(npos >= 0);
|
||||||
|
//FIXME: this could be optimised, for now be prudent:
|
||||||
|
m_Dirty = true;
|
||||||
wxLOiterator i = FindObject(xpos, &offset);
|
wxLOiterator i = FindObject(xpos, &offset);
|
||||||
while(npos > 0)
|
while(npos > 0)
|
||||||
{
|
{
|
||||||
@@ -674,6 +677,8 @@ wxLayoutLine::DeleteWord(CoordType xpos)
|
|||||||
{
|
{
|
||||||
wxASSERT(xpos >= 0);
|
wxASSERT(xpos >= 0);
|
||||||
CoordType offset;
|
CoordType offset;
|
||||||
|
//FIXME: this could be optimised, for now be prudent:
|
||||||
|
m_Dirty = true;
|
||||||
|
|
||||||
wxLOiterator i = FindObject(xpos, &offset);
|
wxLOiterator i = FindObject(xpos, &offset);
|
||||||
|
|
||||||
@@ -804,6 +809,8 @@ wxLayoutLine::Layout(wxDC &dc,
|
|||||||
wxPoint size;
|
wxPoint size;
|
||||||
bool cursorFound = false;
|
bool cursorFound = false;
|
||||||
|
|
||||||
|
m_Dirty = false;
|
||||||
|
|
||||||
if(cursorPos)
|
if(cursorPos)
|
||||||
{
|
{
|
||||||
*cursorPos = m_Position;
|
*cursorPos = m_Position;
|
||||||
@@ -869,18 +876,10 @@ wxLayoutLine::Layout(wxDC &dc,
|
|||||||
|
|
||||||
if(m_Height == 0)
|
if(m_Height == 0)
|
||||||
{
|
{
|
||||||
if(GetPreviousLine()) // empty line
|
CoordType width, height, descent;
|
||||||
{
|
dc.GetTextExtent(WXLO_CURSORCHAR, &width, &height, &descent);
|
||||||
m_Height = GetPreviousLine()->GetHeight();
|
m_Height = height;
|
||||||
m_BaseLine = GetPreviousLine()->m_BaseLine;
|
m_BaseLine = m_Height - descent;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CoordType width, height, descent;
|
|
||||||
dc.GetTextExtent(WXLO_CURSORCHAR, &width, &height, &descent);
|
|
||||||
m_Height = height;
|
|
||||||
m_BaseLine = m_Height - descent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -911,6 +910,8 @@ wxLayoutLine *
|
|||||||
wxLayoutLine::Break(CoordType xpos, wxLayoutList *llist)
|
wxLayoutLine::Break(CoordType xpos, wxLayoutList *llist)
|
||||||
{
|
{
|
||||||
wxASSERT(xpos >= 0);
|
wxASSERT(xpos >= 0);
|
||||||
|
//FIXME: this could be optimised, for now be prudent:
|
||||||
|
m_Dirty = true;
|
||||||
|
|
||||||
if(xpos == 0)
|
if(xpos == 0)
|
||||||
{ // insert an empty line before this one
|
{ // insert an empty line before this one
|
||||||
@@ -971,6 +972,8 @@ wxLayoutLine::MergeNextLine(wxLayoutList *llist)
|
|||||||
wxASSERT(GetNextLine());
|
wxASSERT(GetNextLine());
|
||||||
wxLayoutObjectList &list = GetNextLine()->m_ObjectList;
|
wxLayoutObjectList &list = GetNextLine()->m_ObjectList;
|
||||||
wxLOiterator i;
|
wxLOiterator i;
|
||||||
|
//FIXME: this could be optimised, for now be prudent:
|
||||||
|
m_Dirty = true;
|
||||||
|
|
||||||
for(i = list.begin(); i != list.end();)
|
for(i = list.begin(); i != list.end();)
|
||||||
{
|
{
|
||||||
@@ -1530,23 +1533,34 @@ wxLayoutList::GetCursorScreenPos(wxDC &dc)
|
|||||||
return m_CursorScreenPos;
|
return m_CursorScreenPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Is called before each Draw(). Now, it will re-layout all lines which
|
||||||
|
have changed.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
wxLayoutList::Layout(wxDC &dc, CoordType bottom)
|
wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll)
|
||||||
{
|
{
|
||||||
wxLayoutLine *line = m_FirstLine;
|
wxLayoutLine *line = m_FirstLine;
|
||||||
|
|
||||||
// first, make sure everything is calculated - this might not be
|
// first, make sure everything is calculated - this might not be
|
||||||
// needed, optimise it later
|
// needed, optimise it later
|
||||||
ApplyStyle(&m_DefaultSetting, dc);
|
//FIXME This doesn't work yet, needs updating afterr default
|
||||||
|
//settings for list or a wxLayoutObjectCmd have changed:
|
||||||
|
// ApplyStyle(&m_DefaultSetting, dc);
|
||||||
while(line)
|
while(line)
|
||||||
{
|
{
|
||||||
line->GetStyleInfo() = m_CurrentSetting;
|
if(forceAll || line->IsDirty())
|
||||||
if(line == m_CursorLine)
|
{
|
||||||
line->Layout(dc, this, (wxPoint *)&m_CursorScreenPos, (wxPoint *)&m_CursorSize, m_CursorPos.x);
|
line->GetStyleInfo() = m_CurrentSetting;
|
||||||
else
|
if(line == m_CursorLine)
|
||||||
line->Layout(dc, this);
|
line->Layout(dc, this, (wxPoint *)&m_CursorScreenPos,
|
||||||
// little condition to speed up redrawing:
|
(wxPoint *)&m_CursorSize, m_CursorPos.x);
|
||||||
if(bottom != -1 && line->GetPosition().y > bottom) break;
|
else
|
||||||
|
line->Layout(dc, this);
|
||||||
|
line->RecalculatePosition(this);
|
||||||
|
// little condition to speed up redrawing:
|
||||||
|
if(bottom != -1 && line->GetPosition().y > bottom) break;
|
||||||
|
}
|
||||||
line = line->GetNextLine();
|
line = line->GetNextLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1569,8 +1583,9 @@ wxLayoutList::Draw(wxDC &dc,
|
|||||||
{
|
{
|
||||||
wxLayoutLine *line = m_FirstLine;
|
wxLayoutLine *line = m_FirstLine;
|
||||||
|
|
||||||
|
Layout(dc);
|
||||||
ApplyStyle(&m_DefaultSetting, dc);
|
ApplyStyle(&m_DefaultSetting, dc);
|
||||||
wxBrush brush(m_DefaultSetting.m_bg, wxSOLID);
|
wxBrush brush(m_CurrentSetting.m_bg, wxSOLID);
|
||||||
dc.SetBrush(brush);
|
dc.SetBrush(brush);
|
||||||
|
|
||||||
while(line)
|
while(line)
|
||||||
|
@@ -603,7 +603,9 @@ public:
|
|||||||
void Debug(void);
|
void Debug(void);
|
||||||
#endif
|
#endif
|
||||||
wxLayoutStyleInfo &GetStyleInfo() { return m_StyleInfo; }
|
wxLayoutStyleInfo &GetStyleInfo() { return m_StyleInfo; }
|
||||||
|
|
||||||
|
/// Returns dirty state
|
||||||
|
bool IsDirty(void) const { return m_Dirty; }
|
||||||
private:
|
private:
|
||||||
/// Destructor is private. Use DeleteLine() to remove it.
|
/// Destructor is private. Use DeleteLine() to remove it.
|
||||||
~wxLayoutLine();
|
~wxLayoutLine();
|
||||||
@@ -848,8 +850,9 @@ public:
|
|||||||
actually draw it.
|
actually draw it.
|
||||||
@param dc the wxDC to draw on
|
@param dc the wxDC to draw on
|
||||||
@param bottom optional y coordinate where to stop calculating
|
@param bottom optional y coordinate where to stop calculating
|
||||||
|
@param forceAll force re-layout of all lines
|
||||||
*/
|
*/
|
||||||
void Layout(wxDC &dc, CoordType bottom = -1);
|
void Layout(wxDC &dc, CoordType bottom = -1, bool forceAll = false);
|
||||||
|
|
||||||
/** Calculates new sizes for everything in the list, like Layout()
|
/** Calculates new sizes for everything in the list, like Layout()
|
||||||
but this is needed after the list got changed.
|
but this is needed after the list got changed.
|
||||||
|
Reference in New Issue
Block a user