- UNDO!!
- replacement of llist in window
+ - selection highlighting is a bit broken
+Improve speed! (See layout problem below!)
The following two probs can probably be fixed by adding the
RecalculateLayout() method:
- Funny re-layout shows again in sample text.
+Funny re-layout shows again in sample text.
+(Gone after calling layout for all objects before drawing one.)
Printing works again, but layout at begin of new page is corrupted.
void
wxLayoutLine::RecalculatePositions(int recurse, wxLayoutList *llist)
{
+ //FIXME: is this really needed? We run Layout() anyway.
+ // Recursing here, drives computation time up exponentially, as
+ // each line will cause all following lines to be recalculated.
+ return;
+
wxASSERT(recurse >= 0);
wxPoint pos = m_Position;
CoordType height = m_Height;
CoordType firstOffset, lastOffset;
if(to == -1) to = GetLength();
-
+ if(from == to) return;
+
wxLOiterator first = FindObject(from, &firstOffset);
wxLOiterator last = FindObject(to, &lastOffset);
wxLayoutList::Insert(wxLayoutObject *obj)
{
wxASSERT(m_CursorLine);
+ if(! m_CursorLine) m_CursorLine = GetFirstLine();
SetUpdateRect(m_CursorScreenPos);
SetUpdateRect(m_CursorScreenPos+m_CursorSize);
m_CursorLine->Insert(m_CursorPos.x, obj);
struct UserData
{
UserData() { m_refcount = 1; }
- void IncRef(void) { m_refcount++; }
- void DecRef(void) { m_refcount--; if(m_refcount == 0) delete this;}
+ inline void IncRef(void) { m_refcount++; }
+ inline void DecRef(void) { m_refcount--; if(m_refcount == 0) delete this;}
+ inline void SetLabel(const wxString &l) { m_label = l; }
+ inline const wxString & GetLabel(void) const { return m_label; }
private:
int m_refcount;
+ wxString m_label;
protected:
virtual ~UserData() { wxASSERT(m_refcount == 0); }
/// prevents gcc from generating stupid warnings
/** Tells the object about some user data. This data is associated
with the object and will be deleted at destruction time.
+ It is reference counted.
*/
void SetUserData(UserData *data)
{
m_UserData->IncRef();
}
- /** Return the user data. */
- void * GetUserData(void) const { if(m_UserData) m_UserData->IncRef(); return m_UserData; }
+ /** Return the user data.
+ Increments the object's reference count. When no longer needed,
+ caller must call DecRef() on the pointer returned.
+ */
+ UserData * GetUserData(void) const { if(m_UserData) m_UserData->IncRef(); return m_UserData; }
/** Makes a copy of this object.
*/
{ MoveCursorHorizontally(-m_CursorPos.x); }
/// Returns current cursor position.
- wxPoint GetCursorPos(wxDC &dc) const { return m_CursorPos; }
- wxPoint GetCursorPos() const { return m_CursorPos; }
+ const wxPoint &GetCursorPos(wxDC &dc) const { return m_CursorPos; }
+ const wxPoint &GetCursorPos() const { return m_CursorPos; }
//@}
wxHSCROLL | wxVSCROLL | wxBORDER)
{
+ SetStatusBar(NULL); // don't use statusbar
m_Editable = false;
m_doSendEvents = false;
m_ViewStartX = 0; m_ViewStartY = 0;
bool found;
wxLayoutObject *obj = m_llist->FindObjectScreen(dc, findPos,
&cursorPos, &found);
+ wxLayoutObject::UserData *u = obj ? obj->GetUserData() : NULL;
//has the mouse only been moved?
if(eventId == WXLOWIN_MENU_MOUSEMOVE)
{
// found is only true if we are really over an object, not just
// behind it
- if(found && obj && obj->GetUserData() != NULL)
+ if(found && u)
{
if(!m_HandCursor)
SetCursor(wxCURSOR_HAND);
m_HandCursor = TRUE;
+ if(m_StatusBar && m_StatusFieldLabel != -1)
+ {
+ const wxString &label = u->GetLabel();
+ if(label.Length())
+ m_StatusBar->SetStatusText(label,
+ m_StatusFieldLabel);
+ }
}
else
{
if(m_HandCursor)
SetCursor(wxCURSOR_IBEAM);
m_HandCursor = FALSE;
+ if(m_StatusBar && m_StatusFieldLabel != -1)
+ m_StatusBar->SetStatusText("", m_StatusFieldLabel);
}
if(event.LeftIsDown())
{
m_Selecting = false;
DoPaint(FALSE);
}
+ if(u) u->DecRef();
return;
}
ScrollToCursor();
DoPaint(FALSE); // DoPaint suppresses flicker under GTK
}
+
if(!m_doSendEvents) // nothing to do
+ {
+ if(u) u->DecRef();
return;
+ }
// only do the menu if activated, editable and not on a clickable object
if(eventId == WXLOWIN_MENU_RCLICK
&& IsEditable()
- && (! obj || (obj && obj->GetUserData() == NULL))
- )
+ && (! obj || u == NULL))
{
PopupMenu(m_PopupMenu, m_ClickPosition.x, m_ClickPosition.y);
+ if(u) u->DecRef();
return;
}
+
+ if(u) u->DecRef();
// find the object at this position
if(obj)
{
wxLayoutWindow::OnKeyUp(wxKeyEvent& event)
{
if(event.KeyCode() == WXK_SHIFT && m_llist->IsSelecting())
+ {
m_llist->EndSelection();
+ m_Selecting = false;
+ }
event.Skip();
}
ResetDirty();
m_ScrollToCursor = false;
+ if(m_StatusBar && m_StatusFieldCursor != -1)
+ {
+ wxString label;
+ label.Printf(_("L:%d C:%d"), m_llist->GetCursorPos().x+1, m_llist->GetCursorPos().y+1);
+ m_StatusBar->SetStatusText(label, m_StatusFieldCursor);
+ }
}
// change the range and position of scrollbars
bool IsModified(void) const { return m_Modified; }
/// Mark list as modified or unchanged.
void SetModified(bool modified = true) { m_Modified = modified; }
-
+ /** Tell window to update a wxStatusBar with UserData labels and
+ cursor positions.
+ @param bar wxStatusBar pointer
+ @param labelfield field to use in statusbar for URLs/userdata labels, or -1 to disable
+ @param cursorfield field to use for cursor position, or -1 to disable
+ */
+ inline SetStatusBar(class wxStatusBar *bar,
+ int labelfield = -1,
+ int cursorfield = -1)
+ {
+ m_StatusBar = bar; m_StatusFieldLabel = labelfield;
+ m_StatusFieldCursor = cursorfield;
+ }
protected:
/// generic function for mouse events processing
void OnMouse(int eventId, wxMouseEvent& event);
wxMemoryDC *m_memDC;
wxBitmap *m_bitmap;
wxPoint m_bitmapSize;
+ /// A frame's statusbar to update
+ class wxStatusBar *m_StatusBar;
+ /// statusbar field for labels
+ int m_StatusFieldLabel;
+ /// statusbar field for cursor positions
+ int m_StatusFieldCursor;
/// a pointer to a bitmap for the background
wxBitmap *m_BGbitmap;
DECLARE_EVENT_TABLE()