X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fe71f65c0fec58e34fbc7c4ece402313bf48e220..483249fc1a9ab952054af5efa616ff9fb4151c9e:/include/wx/msw/listctrl.h diff --git a/include/wx/msw/listctrl.h b/include/wx/msw/listctrl.h index c92ba10e5f..0c59d4bb6d 100644 --- a/include/wx/msw/listctrl.h +++ b/include/wx/msw/listctrl.h @@ -5,12 +5,12 @@ // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Copyright: (c) Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef __LISTCTRLH__ -#define __LISTCTRLH__ +#ifndef _WX_LISTCTRL_H_ +#define _WX_LISTCTRL_H_ #ifdef __GNUG__ #pragma interface "listctrl.h" @@ -69,8 +69,6 @@ - in Win95, you can be called back to supply other information besides text, such as state information. This saves no memory and is probably superfluous to requirements. - - discover why SetWindowLong doesn't properly change the - style, requiring RecreateWindow instead. - testing of whole API, extending current sample. @@ -103,7 +101,7 @@ #define wxLIST_HITTEST_TOLEFT 0x0400 // To the left of the client area. #define wxLIST_HITTEST_TORIGHT 0x0800 // To the right of the client area. -#define wxLIST_HITTEST_ONITEM (wxLIST_HITTEST_ONITEMICON | wxLIST_HITTEST_ONITEMLABEL wxLIST_HITTEST_ONITEMSTATEICON) +#define wxLIST_HITTEST_ONITEM (wxLIST_HITTEST_ONITEMICON | wxLIST_HITTEST_ONITEMLABEL | wxLIST_HITTEST_ONITEMSTATEICON) // Flags for GetNextItem enum { @@ -171,11 +169,11 @@ public: int m_format; // left, right, centre int m_width; // width of column - wxListItem(void); + wxListItem(); }; // type of compare function for wxListCtrl sort operation -typedef int (*wxListCtrlCompare)(const long item1, const long item2, long sortData); +typedef int (CALLBACK *wxListCtrlCompare)(long item1, long item2, long sortData); class WXDLLEXPORT wxListCtrl: public wxControl { @@ -185,18 +183,18 @@ class WXDLLEXPORT wxListCtrl: public wxControl * Public interface */ - wxListCtrl(void); + wxListCtrl(); - inline wxListCtrl(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - const long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, + inline wxListCtrl(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl") { Create(parent, id, pos, size, style, validator, name); } - ~wxListCtrl(void); + ~wxListCtrl(); - bool Create(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - const long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, const wxString& name = "wxListCtrl"); + bool Create(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, const wxString& name = "wxListCtrl"); // Attributes @@ -204,28 +202,28 @@ class WXDLLEXPORT wxListCtrl: public wxControl // Sets the background colour (GetBackgroundColour already implicit in // wxWindow class) - void SetBackgroundColour(const wxColour& col); + bool SetBackgroundColour(const wxColour& col); // Gets information about this column - bool GetColumn(const int col, wxListItem& item) const; + bool GetColumn(int col, wxListItem& item) const; // Sets information about this column - bool SetColumn(const int col, wxListItem& item) ; + bool SetColumn(int col, wxListItem& item) ; // Gets the column width - int GetColumnWidth(const int col) const; + int GetColumnWidth(int col) const; // Sets the column width - bool SetColumnWidth(const int col, const int width) ; + bool SetColumnWidth(int col, int width) ; // Gets the number of items that can fit vertically in the // visible area of the list control (list or report view) // or the total number of items in the list control (icon // or small icon view) - int GetCountPerPage(void) const; + int GetCountPerPage() const; // Gets the edit control for editing labels. - wxTextCtrl& GetEditControl(void) const; + wxTextCtrl* GetEditControl() const; // Gets information about the item bool GetItem(wxListItem& info) const ; @@ -234,43 +232,43 @@ class WXDLLEXPORT wxListCtrl: public wxControl bool SetItem(wxListItem& info) ; // Sets a string field at a particular column - long SetItem(const long index, const int col, const wxString& label, const int imageId = -1); + long SetItem(long index, int col, const wxString& label, int imageId = -1); // Gets the item state - int GetItemState(const long item, const long stateMask) const ; + int GetItemState(long item, long stateMask) const ; // Sets the item state - bool SetItemState(const long item, const long state, const long stateMask) ; + bool SetItemState(long item, long state, long stateMask) ; // Sets the item image - bool SetItemImage(const long item, const int image, const int selImage) ; + bool SetItemImage(long item, int image, int selImage) ; // Gets the item text - wxString GetItemText(const long item) const ; + wxString GetItemText(long item) const ; // Sets the item text - void SetItemText(const long item, const wxString& str) ; + void SetItemText(long item, const wxString& str) ; // Gets the item data - long GetItemData(const long item) const ; + long GetItemData(long item) const ; // Sets the item data - bool SetItemData(const long item, long data) ; + bool SetItemData(long item, long data) ; // Gets the item rectangle - bool GetItemRect(const long item, wxRectangle& rect, const int code = wxLIST_RECT_BOUNDS) const ; + bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ; // Gets the item position - bool GetItemPosition(const long item, wxPoint& pos) const ; + bool GetItemPosition(long item, wxPoint& pos) const ; // Sets the item position - bool SetItemPosition(const long item, const wxPoint& pos) ; + bool SetItemPosition(long item, const wxPoint& pos) ; // Gets the number of items in the list control - int GetItemCount(void) const; + int GetItemCount() const; // Gets the number of columns in the list control - int GetColumnCount(void) const; + int GetColumnCount() const { return m_colCount; } // Retrieves the spacing between icons in pixels. // If small is TRUE, gets the spacing for the small icon @@ -278,38 +276,38 @@ class WXDLLEXPORT wxListCtrl: public wxControl int GetItemSpacing(bool isSmall) const; // Gets the number of selected items in the list control - int GetSelectedItemCount(void) const; + int GetSelectedItemCount() const; // Gets the text colour of the listview - wxColour GetTextColour(void) const; + wxColour GetTextColour() const; // Sets the text colour of the listview void SetTextColour(const wxColour& col); // Gets the index of the topmost visible item when in // list or report view - long GetTopItem(void) const ; + long GetTopItem() const ; // Add or remove a single window style - void SetSingleStyle(const long style, const bool add = TRUE) ; + void SetSingleStyle(long style, bool add = TRUE) ; // Set the whole window style - void SetWindowStyleFlag(const long style) ; + void SetWindowStyleFlag(long style) ; // Searches for an item, starting from 'item'. // item can be -1 to find the first item that matches the // specified flags. // Returns the item or -1 if unsuccessful. - long GetNextItem(const long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ; + long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ; // Implementation: converts wxWindows style to MSW style. // Can be a single style flag or a bit list. // oldStyle is 'normalised' so that it doesn't contain // conflicting styles. - long ConvertToMSWStyle(long& oldStyle, const long style) const; + long ConvertToMSWStyle(long& oldStyle, long style) const; // Gets one of the three image lists - wxImageList *GetImageList(const int which) const ; + wxImageList *GetImageList(int which) const ; // Sets the image list // N.B. There's a quirk in the Win95 list view implementation. @@ -318,46 +316,49 @@ class WXDLLEXPORT wxListCtrl: public wxControl // haven't specified wxLIST_MASK_IMAGE when inserting. // So you have to set a NULL small-icon image list to be sure that // the wxLC_LIST mode works without icons. Of course, you may want icons... - void SetImageList(wxImageList *imageList, const int which) ; + void SetImageList(wxImageList *imageList, int which) ; // Operations //////////////////////////////////////////////////////////////////////////// // Arranges the items - bool Arrange(const int flag = wxLIST_ALIGN_DEFAULT); + bool Arrange(int flag = wxLIST_ALIGN_DEFAULT); // Deletes an item - bool DeleteItem(const long item); + bool DeleteItem(long item); // Deletes all items - bool DeleteAllItems(void) ; + bool DeleteAllItems() ; // Deletes a column - bool DeleteColumn(const int col); + bool DeleteColumn(int col); // Deletes all columns - bool DeleteAllColumns(void); + bool DeleteAllColumns(); // Clears items, and columns if there are any. - void ClearAll(void); + void ClearAll(); - // Edits a label - wxTextCtrl& Edit(const long item) ; + // Edit the label + wxTextCtrl* EditLabel(long item, wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl)); + + // End label editing, optionally cancelling the edit + bool EndEditLabel(bool cancel); // Ensures this item is visible - bool EnsureVisible(const long item) ; + bool EnsureVisible(long item) ; // Find an item whose label matches this string, starting from the item after 'start' // or the beginning if 'start' is -1. - long FindItem(const long start, const wxString& str, const bool partial = FALSE); + long FindItem(long start, const wxString& str, bool partial = FALSE); // Find an item whose data matches this data, starting from the item after 'start' // or the beginning if 'start' is -1. - long FindItem(const long start, const long data); + long FindItem(long start, long data); // Find an item nearest this position in the specified direction, starting from // the item after 'start' or the beginning if 'start' is -1. - long FindItem(const long start, const wxPoint& pt, const int direction); + long FindItem(long start, const wxPoint& pt, int direction); // Determines which item (if any) is at the specified point, // giving details in 'flags' (see wxLIST_HITTEST_... flags above) @@ -370,26 +371,26 @@ class WXDLLEXPORT wxListCtrl: public wxControl long InsertItem(wxListItem& info); // Insert a string item - long InsertItem(const long index, const wxString& label); + long InsertItem(long index, const wxString& label); // Insert an image item - long InsertItem(const long index, const int imageIndex); + long InsertItem(long index, int imageIndex); // Insert an image/string item - long InsertItem(const long index, const wxString& label, const int imageIndex); + long InsertItem(long index, const wxString& label, int imageIndex); // For list view mode (only), inserts a column. - long InsertColumn(const long col, wxListItem& info); + long InsertColumn(long col, wxListItem& info); - long InsertColumn(const long col, const wxString& heading, const int format = wxLIST_FORMAT_LEFT, - const int width = -1); + long InsertColumn(long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT, + int width = -1); // Scrolls the list control. If in icon, small icon or report view mode, // x specifies the number of pixels to scroll. If in list view mode, x // specifies the number of columns to scroll. // If in icon, small icon or list view mode, y specifies the number of pixels // to scroll. If in report view mode, y specifies the number of lines to scroll. - bool ScrollList(const int dx, const int dy); + bool ScrollList(int dx, int dy); // Sort items. @@ -404,29 +405,19 @@ class WXDLLEXPORT wxListCtrl: public wxControl // data is arbitrary data to be passed to the sort function. bool SortItems(wxListCtrlCompare fn, long data); -/* Why should we need this function? Leave for now. - * WE NEED IT because item data may have changed, - * but the display needs refreshing (in string callback mode) - // Updates an item. If the list control has the wxLI_AUTO_ARRANGE style, - // the items will be rearranged. - bool Update(const long item); -*/ - - void Command(wxCommandEvent& event) { ProcessCommand(event); }; - // IMPLEMENTATION - bool MSWCommand(const WXUINT param, const WXWORD id); - bool MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam); + virtual bool MSWCommand(WXUINT param, WXWORD id); + virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); - // Recreate window - seems to be necessary when changing a style. - void RecreateWindow(void); + // bring the control in sync with current m_windowStyle value + void UpdateStyle(); // Add to pool: necessary because Windows needs to have a string // still exist across 3 callbacks. - char *AddPool(const wxString& str); + wxChar *AddPool(const wxString& str); protected: - wxTextCtrl m_textCtrl; // The control used for editing a label + wxTextCtrl* m_textCtrl; // The control used for editing a label wxImageList * m_imageListNormal; // The image list for normal icons wxImageList * m_imageListSmall; // The image list for small icons wxImageList * m_imageListState; // The image list state icons (not implemented yet) @@ -437,40 +428,9 @@ protected: int m_colCount; // Windows doesn't have GetColumnCount so must // keep track of inserted/deleted columns +private: + bool DoCreateControl(int x, int y, int w, int h); }; -class WXDLLEXPORT wxListEvent: public wxCommandEvent -{ - DECLARE_DYNAMIC_CLASS(wxListEvent) - - public: - wxListEvent(WXTYPE commandType = 0, int id = 0); - - int m_code; - long m_itemIndex; - long m_oldItemIndex; - int m_col; - bool m_cancelled; - wxPoint m_pointDrag; - - wxListItem m_item; -}; - -typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&); - -#define EVT_LIST_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, -#define EVT_LIST_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, -#define EVT_LIST_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, -#define EVT_LIST_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, -#define EVT_LIST_DELETE_ITEM(id, fn) { wxEVT_COMMAND_LIST_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, -#define EVT_LIST_DELETE_ALL_ITEMS(id, fn) { wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, -#define EVT_LIST_GET_INFO(id, fn) { wxEVT_COMMAND_LIST_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, -#define EVT_LIST_SET_INFO(id, fn) { wxEVT_COMMAND_LIST_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, -#define EVT_LIST_ITEM_SELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, -#define EVT_LIST_ITEM_DESELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, -#define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, -#define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, -#define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, - #endif - // __LISTCTRLH__ + // _WX_LISTCTRL_H_