X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/476de5ea9a695d360cd0f65761712526dd2178ee..5c14ec264057d86fe60b2bacc09965492652cc0f:/include/wx/generic/private/listctrl.h diff --git a/include/wx/generic/private/listctrl.h b/include/wx/generic/private/listctrl.h index f257fcd7a8..48a1f016b8 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/listctrl.h // Purpose: private definitions of wxListCtrl helpers // Author: Robert Roebling // Vadim Zeitlin (virtual list control support) @@ -275,9 +275,10 @@ public: } // 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, @@ -291,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 @@ -344,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; @@ -400,7 +404,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 ); @@ -432,10 +450,8 @@ public: wxListMainWindow(); wxListMainWindow( wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString &name = wxT("listctrlmainwindow") ); + const wxPoint& pos, + const wxSize& size ); virtual ~wxListMainWindow(); @@ -524,7 +540,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; @@ -545,6 +561,7 @@ public: // 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 ); @@ -558,13 +575,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; @@ -589,11 +605,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; } @@ -627,7 +644,7 @@ 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, wxIntPtr data ); @@ -775,6 +792,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;