// wxListLineData (internal)
//-----------------------------------------------------------------------------
-WX_DECLARE_EXPORTED_LIST(wxListItemData, wxListItemDataList);
+WX_DECLARE_LIST(wxListItemData, wxListItemDataList);
#include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxListItemDataList)
int width);
};
-WX_DECLARE_EXPORTED_OBJARRAY(wxListLineData, wxListLineDataArray);
+WX_DECLARE_OBJARRAY(wxListLineData, wxListLineDataArray);
#include "wx/arrimpl.cpp"
WX_DEFINE_OBJARRAY(wxListLineDataArray)
// it wasn't vetoed, i.e. if we should proceed
bool SendListEvent(wxEventType type, const wxPoint& pos);
- DECLARE_DYNAMIC_CLASS(wxListHeaderWindow)
DECLARE_EVENT_TABLE()
};
wxTextCtrl *GetText() const { return m_text; }
- void AcceptChangesAndFinish();
+ void EndEdit( bool discardChanges );
protected:
void OnChar( wxKeyEvent &event );
void OnKillFocus( wxFocusEvent &event );
bool AcceptChanges();
- void Finish();
+ void Finish( bool setfocus );
private:
wxListMainWindow *m_owner;
wxTextCtrl *m_text;
wxString m_startValue;
size_t m_itemEdited;
- bool m_finished;
bool m_aboutToFinish;
DECLARE_EVENT_TABLE()
// wxListMainWindow (internal)
//-----------------------------------------------------------------------------
-WX_DECLARE_EXPORTED_LIST(wxListHeaderData, wxListHeaderDataList);
+WX_DECLARE_LIST(wxListHeaderData, wxListHeaderDataList);
#include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxListHeaderDataList)
-class wxListMainWindow : public wxScrolledWindow
+class wxListMainWindow : public wxScrolledCanvas
{
public:
wxListMainWindow();
return m_textctrlWrapper ? m_textctrlWrapper->GetText() : NULL;
}
- void FinishEditing(wxTextCtrl *text)
+ void ResetTextControl(wxTextCtrl *text)
{
delete text;
m_textctrlWrapper = NULL;
- SetFocusIgnoringChildren();
}
- // we don't draw anything while we're frozen so we must refresh ourselves
- // when we're thawed to make sure the changes are displayed correctly
- virtual void DoThaw() { Refresh(); }
-
void OnRenameTimer();
bool OnRenameAccept(size_t itemEdit, const wxString& value);
void OnRenameCancelled(size_t itemEdit);
// override base class virtual to reset m_lineHeight when the font changes
virtual bool SetFont(const wxFont& font)
{
- if ( !wxScrolledWindow::SetFont(font) )
+ if ( !wxScrolledCanvas::SetFont(font) )
return false;
m_lineHeight = 0;
wxListTextCtrlWrapper *m_textctrlWrapper;
- DECLARE_DYNAMIC_CLASS(wxListMainWindow)
DECLARE_EVENT_TABLE()
friend class wxGenericListCtrl;
if ( highlighted )
dc->SetBrush( *m_owner->GetHighlightBrush() );
else
- dc->SetBrush(wxBrush(attr->GetBackgroundColour(), wxSOLID));
+ dc->SetBrush(wxBrush(attr->GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
dc->SetPen( *wxTRANSPARENT_PEN );
int xOld = x;
x += width;
+ const int wText = width - 8;
+ wxDCClipper clipper(*dc, xOld, rect.y, wText, rect.height);
+
if ( item->HasImage() )
{
int ix, iy;
}
if ( item->HasText() )
- DrawTextFormatted(dc, item->GetText(), col, xOld, yMid, width - 8);
+ DrawTextFormatted(dc, item->GetText(), col, xOld, yMid, wText);
}
}
// wxListHeaderWindow
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxListHeaderWindow,wxWindow)
-
BEGIN_EVENT_TABLE(wxListHeaderWindow,wxWindow)
EVT_PAINT (wxListHeaderWindow::OnPaint)
EVT_MOUSE_EVENTS (wxListHeaderWindow::OnMouse)
GetClientSize( &w, &h );
m_owner->CalcUnscrolledPosition(w, 0, &w, NULL);
- dc.SetBackgroundMode(wxTRANSPARENT);
+ dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
dc.SetTextForeground(GetForegroundColour());
int x = HEADER_OFFSET_X;
{
m_owner = owner;
m_text = text;
- m_finished = false;
m_aboutToFinish = false;
wxRect rectLabel = owner->GetLineLabelRect(itemEdit);
m_text->PushEventHandler(this);
}
-void wxListTextCtrlWrapper::Finish()
+void wxListTextCtrlWrapper::EndEdit(bool discardChanges)
{
- if ( !m_finished )
+ m_aboutToFinish = true;
+
+ if ( discardChanges )
{
- m_finished = true;
+ m_owner->OnRenameCancelled(m_itemEdited);
- m_text->RemoveEventHandler(this);
- m_owner->FinishEditing(m_text);
+ Finish( true );
+ }
+ else
+ {
+ // Notify the owner about the changes
+ AcceptChanges();
- wxPendingDelete.Append( this );
+ // Even if vetoed, close the control (consistent with MSW)
+ Finish( true );
}
}
+void wxListTextCtrlWrapper::Finish( bool setfocus )
+{
+ m_text->RemoveEventHandler(this);
+ m_owner->ResetTextControl( m_text );
+
+ wxPendingDelete.Append( this );
+
+ if (setfocus)
+ m_owner->SetFocus();
+}
+
bool wxListTextCtrlWrapper::AcceptChanges()
{
const wxString value = m_text->GetValue();
return true;
}
-void wxListTextCtrlWrapper::AcceptChangesAndFinish()
-{
- m_aboutToFinish = true;
-
- // Notify the owner about the changes
- AcceptChanges();
-
- // Even if vetoed, close the control (consistent with MSW)
- Finish();
-}
-
void wxListTextCtrlWrapper::OnChar( wxKeyEvent &event )
{
switch ( event.m_keyCode )
{
case WXK_RETURN:
- AcceptChangesAndFinish();
+ EndEdit( false );
break;
case WXK_ESCAPE:
- m_owner->OnRenameCancelled( m_itemEdited );
- Finish();
+ EndEdit( true );
break;
default:
void wxListTextCtrlWrapper::OnKeyUp( wxKeyEvent &event )
{
- if (m_finished)
+ if (m_aboutToFinish)
{
- event.Skip();
- return;
+ // auto-grow the textctrl:
+ wxSize parentSize = m_owner->GetSize();
+ wxPoint myPos = m_text->GetPosition();
+ wxSize mySize = m_text->GetSize();
+ int sx, sy;
+ m_text->GetTextExtent(m_text->GetValue() + _T("MM"), &sx, &sy);
+ if (myPos.x + sx > parentSize.x)
+ sx = parentSize.x - myPos.x;
+ if (mySize.x > sx)
+ sx = mySize.x;
+ m_text->SetSize(sx, wxDefaultCoord);
}
- // auto-grow the textctrl:
- wxSize parentSize = m_owner->GetSize();
- wxPoint myPos = m_text->GetPosition();
- wxSize mySize = m_text->GetSize();
- int sx, sy;
- m_text->GetTextExtent(m_text->GetValue() + _T("MM"), &sx, &sy);
- if (myPos.x + sx > parentSize.x)
- sx = parentSize.x - myPos.x;
- if (mySize.x > sx)
- sx = mySize.x;
- m_text->SetSize(sx, wxDefaultCoord);
-
event.Skip();
}
void wxListTextCtrlWrapper::OnKillFocus( wxFocusEvent &event )
{
- if ( !m_finished && !m_aboutToFinish )
+ if ( !m_aboutToFinish )
{
if ( !AcceptChanges() )
m_owner->OnRenameCancelled( m_itemEdited );
- Finish();
+ Finish( false );
}
// We must let the native text control handle focus
// wxListMainWindow
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxListMainWindow,wxScrolledWindow)
-
-BEGIN_EVENT_TABLE(wxListMainWindow,wxScrolledWindow)
+BEGIN_EVENT_TABLE(wxListMainWindow,wxScrolledCanvas)
EVT_PAINT (wxListMainWindow::OnPaint)
EVT_MOUSE_EVENTS (wxListMainWindow::OnMouse)
EVT_CHAR (wxListMainWindow::OnChar)
const wxSize& size,
long style,
const wxString &name )
- : wxScrolledWindow( parent, id, pos, size,
+ : wxScrolledCanvas( parent, id, pos, size,
style | wxHSCROLL | wxVSCROLL, name )
{
Init();
(
wxSYS_COLOUR_HIGHLIGHT
),
- wxSOLID
+ wxBRUSHSTYLE_SOLID
);
m_highlightUnfocusedBrush = new wxBrush
(
wxSYS_COLOUR_BTNSHADOW
),
- wxSOLID
+ wxBRUSHSTYLE_SOLID
);
SetScrollbars( 0, 0, 0, 0, 0, 0 );
// done (a Windows requirement).
wxPaintDC dc( this );
- if ( IsEmpty() || IsFrozen() )
+ if ( IsEmpty() )
{
// nothing to draw or not the moment to draw it
return;
if ( HasFlag(wxLC_HRULES) )
{
- wxPen pen(GetRuleColour(), 1, wxSOLID);
+ wxPen pen(GetRuleColour(), 1, wxPENSTYLE_SOLID);
wxSize clientSize = GetClientSize();
size_t i = visibleFrom;
// Draw vertical rules if required
if ( HasFlag(wxLC_VRULES) && !IsEmpty() )
{
- wxPen pen(GetRuleColour(), 1, wxSOLID);
+ wxPen pen(GetRuleColour(), 1, wxPENSTYLE_SOLID);
wxRect firstItemRect, lastItemRect;
GetItemRect(visibleFrom, firstItemRect);
// listctrl because the order of events is different (or something like
// that), so explicitly end the edit if it is active.
if ( event.LeftDown() && m_textctrlWrapper )
- m_textctrlWrapper->AcceptChangesAndFinish();
+ m_textctrlWrapper->EndEdit( false );
#endif // __WXMAC__
if ( event.LeftDown() )
- SetFocusIgnoringChildren();
+ SetFocus();
event.SetEventObject( GetParent() );
if ( GetParent()->GetEventHandler()->ProcessEvent( event) )
ke.SetEventObject( parent );
if (parent->GetEventHandler()->ProcessEvent( ke )) return;
- if (event.GetKeyCode() == WXK_TAB)
- {
- wxNavigationKeyEvent nevent;
- nevent.SetWindowChange( event.ControlDown() );
- nevent.SetDirection( !event.ShiftDown() );
- nevent.SetEventObject( GetParent()->GetParent() );
- nevent.SetCurrentFocus( m_parent );
- if (GetParent()->GetParent()->GetEventHandler()->ProcessEvent( nevent ))
- return;
- }
+ if ( HandleAsNavigationKey(event) )
+ return;
// no item -> nothing to do
if (!HasCurrent())
{
// FIXME
#if ( defined(__WXGTK__) || defined(__WXMAC__) ) && !defined(__WXUNIVERSAL__)
- wxScrolledWindow::OnScroll(event);
+ wxScrolledCanvas::OnScroll(event);
#else
HandleOnScroll( event );
#endif
}
}
-void wxGenericListCtrl::DoFreeze()
-{
- m_mainWin->Freeze();
-}
-
-void wxGenericListCtrl::DoThaw()
-{
- m_mainWin->Thaw();
-}
-
#endif // wxUSE_LISTCTRL