X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ad486020870c946fd553535041f8ea707efe656c..0555b2a0a3c509687e7fc5aeb160f5171b7e6311:/include/wx/generic/private/listctrl.h diff --git a/include/wx/generic/private/listctrl.h b/include/wx/generic/private/listctrl.h index 243b7ee36d..2267ca3dd7 100644 --- a/include/wx/generic/private/listctrl.h +++ b/include/wx/generic/private/listctrl.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: listctrl.h +// Name: wx/generic/private/listctrl.h // Purpose: private definitions of wxListCtrl helpers // Author: Robert Roebling // Vadim Zeitlin (virtual list control support) @@ -17,6 +17,8 @@ #include "wx/listctrl.h" #include "wx/selstore.h" +#include "wx/timer.h" +#include "wx/settings.h" // ============================================================================ // private classes @@ -67,7 +69,7 @@ public: { wxString s = GetText(); if ( s.empty() ) - s = _T('H'); + s = wxT('H'); return s; } @@ -186,7 +188,7 @@ public: void ExtendWidth(wxCoord w) { wxASSERT_MSG( m_rectAll.width <= w, - _T("width can only be increased") ); + wxT("width can only be increased") ); m_rectAll.width = w; m_rectLabel.x = m_rectAll.x + (w - m_rectLabel.width) / 2; @@ -211,6 +213,21 @@ public: delete m_gi; } + // called by the owner when it toggles report view + void SetReportView(bool inReportView) + { + // we only need m_gi when we're not in report view so update as needed + if ( inReportView ) + { + delete m_gi; + m_gi = NULL; + } + else + { + m_gi = new GeometryInfo; + } + } + // are we in report mode? inline bool InReportView() const; @@ -252,15 +269,16 @@ public: bool IsHighlighted() const { - wxASSERT_MSG( !IsVirtual(), _T("unexpected call to IsHighlighted") ); + wxASSERT_MSG( !IsVirtual(), wxT("unexpected call to IsHighlighted") ); return m_highlighted; } // draw the line on the given DC in icon/list mode - void Draw( wxDC *dc ); + void Draw( wxDC *dc, bool current ); - // the same in report mode + // the same in report mode: it needs more parameters as we don't store + // everything in the item in report mode void DrawInReportMode( wxDC *dc, const wxRect& rect, const wxRect& rectHL, @@ -274,11 +292,12 @@ private: // get the mode (i.e. style) of the list control inline int GetMode() const; - // prepare the DC for drawing with these item's attributes, return true if - // we need to draw the items background to highlight it, false otherwise - bool SetAttributes(wxDC *dc, - const wxListItemAttr *attr, - bool highlight); + // Apply this item attributes to the given DC: set the text font and colour + // and also erase the background appropriately. + void ApplyAttributes(wxDC *dc, + const wxRect& rectHL, + bool highlighted, + bool current); // draw the text on the DC with the correct justification; also add an // ellipsis if the text is too large to fit in the current width @@ -327,12 +346,14 @@ public: virtual ~wxListHeaderWindow(); + // We never need focus as we don't have any keyboard interface. + virtual bool AcceptsFocus() const { return false; } + void DrawCurrent(); void AdjustDC( wxDC& dc ); void OnPaint( wxPaintEvent &event ); void OnMouse( wxMouseEvent &event ); - void OnSetFocus( wxFocusEvent &event ); // needs refresh bool m_dirty; @@ -369,6 +390,27 @@ public: void Notify(); }; +//----------------------------------------------------------------------------- +// wxListFindTimer (internal) +//----------------------------------------------------------------------------- + +class wxListFindTimer: public wxTimer +{ +public: + // reset the current prefix after half a second of inactivity + enum { DELAY = 500 }; + + wxListFindTimer( wxListMainWindow *owner ) + : m_owner(owner) + { + } + + virtual void Notify(); + +private: + wxListMainWindow *m_owner; +}; + //----------------------------------------------------------------------------- // wxListTextCtrlWrapper: wraps a wxTextCtrl to make it work for inline editing //----------------------------------------------------------------------------- @@ -383,7 +425,21 @@ public: wxTextCtrl *GetText() const { return m_text; } - void EndEdit( bool discardChanges ); + // Check if the given key event should stop editing and return true if it + // does or false otherwise. + bool CheckForEndEditKey(const wxKeyEvent& event); + + // Different reasons for calling EndEdit(): + // + // It was called because: + enum EndReason + { + End_Accept, // user has accepted the changes. + End_Discard, // user has cancelled editing. + End_Destroy // the entire control is being destroyed. + }; + + void EndEdit(EndReason reason); protected: void OnChar( wxKeyEvent &event ); @@ -415,13 +471,15 @@ public: wxListMainWindow(); wxListMainWindow( wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString &name = _T("listctrlmainwindow") ); + const wxPoint& pos, + const wxSize& size ); virtual ~wxListMainWindow(); + // called by the main control when its mode changes + void SetReportView(bool inReportView); + + // helper to simplify testing for wxLC_XXX flags bool HasFlag(int flag) const { return m_parent->HasFlag(flag); } // return true if this is a virtual list control @@ -503,7 +561,7 @@ public: // start editing the label of the given item wxTextCtrl *EditLabel(long item, - wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl)); + wxClassInfo* textControlClass = wxCLASSINFO(wxTextCtrl)); wxTextCtrl *GetEditControl() const { return m_textctrlWrapper ? m_textctrlWrapper->GetText() : NULL; @@ -519,11 +577,17 @@ public: bool OnRenameAccept(size_t itemEdit, const wxString& value); void OnRenameCancelled(size_t itemEdit); + void OnFindTimer(); + // set whether or not to ring the find bell + // (does nothing on MSW - bell is always rung) + void EnableBellOnNoMatch( bool on ); + void OnMouse( wxMouseEvent &event ); // called to switch the selection from the current item to newCurrent, void OnArrowChar( size_t newCurrent, const wxKeyEvent& event ); + void OnCharHook( wxKeyEvent &event ); void OnChar( wxKeyEvent &event ); void OnKeyDown( wxKeyEvent &event ); void OnKeyUp( wxKeyEvent &event ); @@ -537,13 +601,12 @@ public: void DrawImage( int index, wxDC *dc, int x, int y ); void GetImageSize( int index, int &width, int &height ) const; - int GetTextLength( const wxString &s ) const; void SetImageList( wxImageList *imageList, int which ); void SetItemSpacing( int spacing, bool isSmall = false ); int GetItemSpacing( bool isSmall = false ); - void SetColumn( int col, wxListItem &item ); + void SetColumn( int col, const wxListItem &item ); void SetColumnWidth( int col, int width ); void GetColumn( int col, wxListItem &item ) const; int GetColumnWidth( int col ) const; @@ -568,11 +631,12 @@ public: bool GetItemPosition( long item, wxPoint& pos ) const; int GetSelectedItemCount() const; - wxString GetItemText(long item) const + wxString GetItemText(long item, int col = 0) const { wxListItem info; info.m_mask = wxLIST_MASK_TEXT; info.m_itemId = item; + info.m_col = col; GetItem( info ); return info.m_text; } @@ -606,9 +670,9 @@ public: long FindItem( const wxPoint& pt ); long HitTest( int x, int y, int &flags ) const; void InsertItem( wxListItem &item ); - void InsertColumn( long col, wxListItem &item ); + long InsertColumn( long col, const wxListItem &item ); int GetItemWidthWithImage(wxListItem * item); - void SortItems( wxListCtrlCompare fn, long data ); + void SortItems( wxListCtrlCompare fn, wxIntPtr data ); size_t GetItemCount() const; bool IsEmpty() const { return GetItemCount() == 0; } @@ -691,6 +755,15 @@ protected: bool m_lastOnSame; wxTimer *m_renameTimer; + + // incremental search data + wxString m_findPrefix; + wxTimer *m_findTimer; + // This flag is set to 0 if the bell is disabled, 1 if it is enabled and -1 + // if it is globally enabled but has been temporarily disabled because we + // had already beeped for this particular search. + int m_findBell; + bool m_isCreated; int m_dragCount; wxPoint m_dragStart; @@ -717,7 +790,7 @@ protected: // get the line data for the given index wxListLineData *GetLine(size_t n) const { - wxASSERT_MSG( n != (size_t)-1, _T("invalid line index") ); + wxASSERT_MSG( n != (size_t)-1, wxT("invalid line index") ); if ( IsVirtual() ) { @@ -741,6 +814,9 @@ protected: // force us to recalculate the range of visible lines void ResetVisibleLinesRange() { m_lineFrom = (size_t)-1; } + // find the first item starting with the given prefix after the given item + size_t PrefixFindItem(size_t item, const wxString& prefix) const; + // get the colour to be used for drawing the rules wxColour GetRuleColour() const { @@ -754,6 +830,10 @@ private: // delete all items but don't refresh: called from dtor void DoDeleteAllItems(); + // Compute the minimal width needed to fully display the column header. + int ComputeMinHeaderWidth(const wxListHeaderData* header) const; + + // the height of one line using the current font wxCoord m_lineHeight;