Initial commit of native OS X list ctrl support. Compile tested on Win, Mac, FC4/GTK2. Tested samples on Win and OS X. Also, support for co-existance of native and generic list ctrl on OS X.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41257 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Ollivier
2006-09-17 01:20:08 +00:00
parent e96bbb453c
commit e2bc1d6981
12 changed files with 626 additions and 726 deletions

View File

@@ -606,6 +606,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
src/common/imagxpm.cpp
src/common/layout.cpp
src/common/lboxcmn.cpp
src/common/listctrlcmn.cpp
src/common/matrix.cpp
src/common/menucmn.cpp
src/common/nbkbase.cpp
@@ -2072,6 +2073,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
src/mac/carbon/icon.cpp
src/mac/carbon/imaglist.cpp
src/mac/carbon/listbox.cpp
src/mac/carbon/listctrl_mac.cpp
src/mac/carbon/mdi.cpp
src/mac/carbon/menu.cpp
src/mac/carbon/menuitem.cpp

View File

@@ -31,6 +31,13 @@
class WXDLLEXPORT wxDropTarget;
#endif
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
extern WXDLLEXPORT_DATA(const wxChar) wxGenericListCtrlNameStr[];
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
@@ -38,8 +45,10 @@ class WXDLLEXPORT wxDropTarget;
class WXDLLEXPORT wxListItem;
class WXDLLEXPORT wxListEvent;
#if !defined(__WXMSW__) || defined(__WXUNIVERSAL__)
#if (!defined(__WXMSW__) || defined(__WXUNIVERSAL__))
#ifndef __WXMAC__
class WXDLLEXPORT wxListCtrl;
#endif
#define wxImageListType wxImageList
#else
#define wxImageListType wxGenericImageList
@@ -51,7 +60,6 @@ class WXDLLEXPORT wxListCtrl;
class WXDLLEXPORT wxListHeaderData;
class WXDLLEXPORT wxListItemData;
class WXDLLEXPORT wxListLineData;
class WXDLLEXPORT wxListHeaderWindow;
class WXDLLEXPORT wxListMainWindow;
@@ -66,6 +74,7 @@ class WXDLLEXPORT wxListTextCtrl;
class WXDLLEXPORT wxGenericListCtrl: public wxControl
{
public:
wxGenericListCtrl();
wxGenericListCtrl( wxWindow *parent,
wxWindowID winid = wxID_ANY,
@@ -73,7 +82,7 @@ public:
const wxSize &size = wxDefaultSize,
long style = wxLC_ICON,
const wxValidator& validator = wxDefaultValidator,
const wxString &name = wxListCtrlNameStr)
const wxString &name = wxGenericListCtrlNameStr)
{
Create(parent, winid, pos, size, style, validator, name);
}
@@ -85,7 +94,7 @@ public:
const wxSize &size = wxDefaultSize,
long style = wxLC_ICON,
const wxValidator& validator = wxDefaultValidator,
const wxString &name = wxListCtrlNameStr);
const wxString &name = wxGenericListCtrlNameStr);
bool GetColumn( int col, wxListItem& item ) const;
bool SetColumn( int col, wxListItem& item );
@@ -273,7 +282,7 @@ private:
DECLARE_DYNAMIC_CLASS(wxGenericListCtrl)
};
#if !defined(__WXMSW__) || defined(__WXUNIVERSAL__)
#if (!defined(__WXMSW__) || defined(__WXUNIVERSAL__)) && !defined(__WXMAC__)
/*
* wxListCtrl has to be a real class or we have problems with
* the run-time information.
@@ -295,6 +304,7 @@ public:
: wxGenericListCtrl(parent, winid, pos, size, style, validator, name)
{
}
};
#endif // !__WXMSW__ || __WXUNIVERSAL__

View File

@@ -27,11 +27,12 @@ extern WXDLLEXPORT_DATA(const wxChar) wxListCtrlNameStr[];
// ----------------------------------------------------------------------------
// include the wxListCtrl class declaration
// ----------------------------------------------------------------------------
#include "wx/generic/listctrl.h"
#if defined(__WIN32__) && !defined(__WXUNIVERSAL__)
#include "wx/msw/listctrl.h"
#else
#include "wx/generic/listctrl.h"
#elif defined(__WXMAC__)
#include "wx/mac/carbon/listctrl.h"
#endif
// ----------------------------------------------------------------------------

View File

@@ -21,32 +21,8 @@
// forward decl for GetSelections()
class wxArrayInt;
// exposed for subclasses like wxCheckListBox
class wxMacListControl
{
public:
virtual void MacDelete( unsigned int n ) = 0;
virtual void MacInsert( unsigned int n, const wxString& item ) = 0;
virtual void MacInsert( unsigned int n, const wxArrayString& items ) = 0;
// returns index of newly created line
virtual int MacAppend( const wxString& item ) = 0;
virtual void MacSetString( unsigned int n, const wxString& item ) = 0;
virtual void MacClear() = 0;
virtual void MacDeselectAll() = 0;
virtual void MacSetSelection( unsigned int n, bool select ) = 0;
virtual int MacGetSelection() const = 0;
virtual int MacGetSelections( wxArrayInt& aSelections ) const = 0;
virtual bool MacIsSelected( unsigned int n ) const = 0;
virtual void MacScrollTo( unsigned int n ) = 0;
virtual wxString MacGetString( unsigned int n) const = 0;
virtual unsigned int MacGetCount() const = 0;
virtual void MacSetClientData( unsigned int n, void * data) = 0;
virtual void * MacGetClientData( unsigned int) const = 0;
virtual ~wxMacListControl() { }
};
// forward decl for wxMacListControl data type.
class wxMacListControl;
// List box item

View File

@@ -15,147 +15,9 @@
#include "wx/control.h"
#include "wx/event.h"
#include "wx/imaglist.h"
#include "wx/generic/listctrl.h"
/*
The wxListCtrl can show lists of items in four different modes:
wxLC_LIST: multicolumn list view, with optional small icons (icons could be
optional for some platforms). Columns are computed automatically,
i.e. you don't set columns as in wxLC_REPORT. In other words,
the list wraps, unlike a wxListBox.
wxLC_REPORT: single or multicolumn report view (with optional header)
wxLC_ICON: large icon view, with optional labels
wxLC_SMALL_ICON: small icon view, with optional labels
You can change the style dynamically, either with SetSingleStyle or
SetWindowStyleFlag.
Further window styles:
wxLC_ALIGN_TOP icons align to the top (default)
wxLC_ALIGN_LEFT icons align to the left
wxLC_AUTOARRANGE icons arrange themselves
wxLC_USER_TEXT the app provides label text on demand, except for column headers
wxLC_EDIT_LABELS labels are editable: app will be notified.
wxLC_NO_HEADER no header in report mode
wxLC_NO_SORT_HEADER can't click on header
wxLC_SINGLE_SEL single selection
wxLC_SORT_ASCENDING sort ascending (must still supply a comparison callback in SortItems)
wxLC_SORT_DESCENDING sort descending (ditto)
Items are referred to by their index (position in the list starting from zero).
Label text is supplied via insertion/setting functions and is stored by the
control, unless the wxLC_USER_TEXT style has been specified, in which case
the app will be notified when text is required (see sample).
Images are dealt with by (optionally) associating 3 image lists with the control.
Zero-based indexes into these image lists indicate which image is to be used for
which item. Each image in an image list can contain a mask, and can be made out
of either a bitmap, two bitmaps or an icon. See ImagList.h for more details.
Notifications are passed via the wxWidgets 2.0 event system.
See the sample wxListCtrl app for API usage.
*/
// Mask flags to tell app/GUI what fields of wxListItem are valid
#define wxLIST_MASK_STATE 0x0001
#define wxLIST_MASK_TEXT 0x0002
#define wxLIST_MASK_IMAGE 0x0004
#define wxLIST_MASK_DATA 0x0008
#define wxLIST_SET_ITEM 0x0010
#define wxLIST_MASK_WIDTH 0x0020
#define wxLIST_MASK_FORMAT 0x0040
// State flags for indicating the state of an item
#define wxLIST_STATE_DONTCARE 0x0000
#define wxLIST_STATE_DROPHILITED 0x0001
#define wxLIST_STATE_FOCUSED 0x0002
#define wxLIST_STATE_SELECTED 0x0004
#define wxLIST_STATE_CUT 0x0008
// Hit test flags, used in HitTest
#define wxLIST_HITTEST_ABOVE 0x0001 // Above the client area.
#define wxLIST_HITTEST_BELOW 0x0002 // Below the client area.
#define wxLIST_HITTEST_NOWHERE 0x0004 // In the client area but below the last item.
#define wxLIST_HITTEST_ONITEMICON 0x0020 // On the bitmap associated with an item.
#define wxLIST_HITTEST_ONITEMLABEL 0x0080 // On the label (string) associated with an item.
#define wxLIST_HITTEST_ONITEMRIGHT 0x0100 // In the area to the right of an item.
#define wxLIST_HITTEST_ONITEMSTATEICON 0x0200 // On the state icon for a tree view item that is in a user-defined state.
#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)
// Flags for GetNextItem
enum {
wxLIST_NEXT_ABOVE, // Searches for an item above the specified item
wxLIST_NEXT_ALL, // Searches for subsequent item by index
wxLIST_NEXT_BELOW, // Searches for an item below the specified item
wxLIST_NEXT_LEFT, // Searches for an item to the left of the specified item
wxLIST_NEXT_RIGHT, // Searches for an item to the right of the specified item
};
// Alignment flags for Arrange
enum {
wxLIST_ALIGN_DEFAULT,
wxLIST_ALIGN_LEFT,
wxLIST_ALIGN_TOP,
wxLIST_ALIGN_SNAP_TO_GRID
};
// Column format
enum {
wxLIST_FORMAT_LEFT,
wxLIST_FORMAT_RIGHT,
wxLIST_FORMAT_CENTRE,
wxLIST_FORMAT_CENTER = wxLIST_FORMAT_CENTRE
};
// Autosize values for SetColumnWidth
enum {
wxLIST_AUTOSIZE = -1,
wxLIST_AUTOSIZE_USEHEADER = -2
};
// Flag values for GetItemRect
enum {
wxLIST_RECT_BOUNDS,
wxLIST_RECT_ICON,
wxLIST_RECT_LABEL
};
// Flag values for FindItem
enum {
wxLIST_FIND_UP,
wxLIST_FIND_DOWN,
wxLIST_FIND_LEFT,
wxLIST_FIND_RIGHT
};
// wxListItem: data representing an item, or report field.
// It also doubles up to represent entire column information
// when inserting or setting a column.
class WXDLLEXPORT wxListItem: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxListItem)
public:
long m_mask; // Indicates what fields are valid
long m_itemId; // The zero-based item position
int m_col; // Zero-based column, if in report mode
long m_state; // The state of the item
long m_stateMask; // Which flags of m_state are valid (uses same flags)
wxString m_text; // The label/header text
int m_image; // The zero-based index into an image list
long m_data; // App-defined data
// For columns only
int m_format; // left, right, centre
int m_width; // width of column
wxListItem();
};
class wxMacDataBrowserListCtrlControl;
// type of compare function for wxListCtrl sort operation
typedef int (*wxListCtrlCompare)(long item1, long item2, long sortData);
@@ -168,19 +30,30 @@ class WXDLLEXPORT wxListCtrl: public wxControl
* Public interface
*/
wxListCtrl();
wxListCtrl() { Init(); }
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 = wxListCtrlNameStr)
{
Create(parent, id, pos, size, style, validator, name);
}
virtual ~wxListCtrl();
wxListCtrl(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxLC_ICON,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListCtrlNameStr)
{
Init();
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 = wxListCtrlNameStr);
Create(parent, id, pos, size, style, validator, name);
}
virtual ~wxListCtrl();
bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxLC_ICON,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListCtrlNameStr);
// Attributes
////////////////////////////////////////////////////////////////////////////
@@ -189,6 +62,7 @@ class WXDLLEXPORT wxListCtrl: public wxControl
bool GetColumn(int col, wxListItem& item) const;
// Sets information about this column
// TODO: NOT const to be compatible with wxGenericListCtrl API
bool SetColumn(int col, wxListItem& item) ;
// Gets the column width
@@ -221,8 +95,10 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// Sets the item state
bool SetItemState(long item, long state, long stateMask) ;
void AssignImageList(wxImageList *imageList, int which);
// Sets the item image
bool SetItemImage(long item, int image, int selImage) ;
bool SetItemImage(long item, int image, int selImage = -1) ;
bool SetItemColumnImage(long item, long column, int image);
// Gets the item text
@@ -230,6 +106,15 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// Sets the item text
void SetItemText(long item, const wxString& str) ;
void SetItemTextColour(long item, const wxColour& colour) ;
wxColour GetItemTextColour(long item) const;
void SetItemBackgroundColour(long item, const wxColour& colour) ;
wxColour GetItemBackgroundColour(long item) const;
void SetItemFont( long item, const wxFont &f);
wxFont GetItemFont( long item ) const;
// Gets the item data
long GetItemData(long item) const ;
@@ -252,13 +137,12 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// Gets the number of columns in the list control
int GetColumnCount() const;
// Retrieves the spacing between icons in pixels.
// If isSmall is true, gets the spacing for the small icon
// view, otherwise the large icon view.
int GetItemSpacing(bool isSmall) const;
wxSize GetItemSpacing() const;
// Gets the number of selected items in the list control
int GetSelectedItemCount() const;
wxRect GetViewRect() const;
// Gets the text colour of the listview
wxColour GetTextColour() const;
@@ -270,6 +154,8 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// list or report view
long GetTopItem() const ;
bool IsVirtual() const { return HasFlag(wxLC_VIRTUAL); }
// Add or remove a single window style
void SetSingleStyle(long style, bool add = true) ;
@@ -344,7 +230,8 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// Determines which item (if any) is at the specified point,
// giving details in 'flags' (see wxLIST_HITTEST_... flags above)
long HitTest(const wxPoint& point, int& flags);
// Request the subitem number as well at the given coordinate.
long HitTest(const wxPoint& point, int& flags, long* ptrSubItem = NULL) const;
// Inserts an item, returning the index of the new item if successful,
// -1 otherwise.
@@ -387,6 +274,29 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// data is arbitrary data to be passed to the sort function.
bool SortItems(wxListCtrlCompare fn, long data);
wxMacListControl* GetPeer() const;
// these functions are only used for virtual list view controls, i.e. the
// ones with wxLC_VIRTUAL style
void SetItemCount(long count);
void RefreshItem(long item);
void RefreshItems(long itemFrom, long itemTo);
// return the text for the given column of the given item
virtual wxString OnGetItemText(long item, long column) const;
// return the icon for the given item. In report view, OnGetItemImage will
// only be called for the first column. See OnGetItemColumnImage for
// details.
virtual int OnGetItemImage(long item) const;
// return the icon for the given item and column.
virtual int OnGetItemColumnImage(long item, long column) const;
// return the attribute for the item (may return NULL if none)
virtual wxListItemAttr *OnGetItemAttr(long item) const;
/* Why should we need this function? Leave for now.
* We might need it because item data may have changed,
* but the display needs refreshing (in string callback mode)
@@ -398,10 +308,26 @@ class WXDLLEXPORT wxListCtrl: public wxControl
void Command(wxCommandEvent& event) { ProcessCommand(event); };
protected:
// overrides needed for pimpl approach
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
// common part of all ctors
void Init();
wxGenericListCtrl* m_genericImpl; // allow use of the generic impl.
wxMacDataBrowserListCtrlControl* m_dbImpl;
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)
// keep track of whether or not we should delete the image list ourselves.
bool m_ownsImageListNormal,
m_ownsImageListSmall,
m_ownsImageListState;
long m_baseStyle; // Basic Windows style flags, for recreation purposes
wxStringList m_stringPool; // Pool of 3 strings to satisfy Windows callback
@@ -409,40 +335,10 @@ protected:
int m_colCount; // Windows doesn't have GetColumnCount so must
// keep track of inserted/deleted columns
};
class WXDLLEXPORT wxListEvent: public wxCommandEvent
{
DECLARE_DYNAMIC_CLASS(wxListEvent)
public:
wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
int m_code;
long m_itemIndex;
long m_oldItemIndex;
int m_col;
bool m_cancelled;
wxPoint m_pointDrag;
wxListItem m_item;
int m_count; // for virtual lists, store item count
};
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
// _WX_LISTCTRL_H_

View File

@@ -671,6 +671,8 @@ public :
OSStatus AddColumn( DataBrowserListViewColumnDesc *columnDesc,
DataBrowserTableViewColumnIndex position );
OSStatus RemoveColumn( DataBrowserTableViewColumnIndex position );
OSStatus AutoSizeColumns();
@@ -721,6 +723,8 @@ public :
OSStatus GetColumnCount( UInt32* numColumns) const;
OSStatus GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id );
OSStatus GetColumnPosition( DataBrowserPropertyID column, UInt32 *position) const;
OSStatus SetColumnPosition( DataBrowserPropertyID column, UInt32 position);
@@ -787,9 +791,48 @@ protected :
// forward decl
class wxMacDataItemBrowserControl;
class wxMacListBoxItem;
const short kTextColumnId = 1024;
const short kNumericOrderColumnId = 1025;
// for multi-column controls, we will use this + the column ID to identify the
// column. We don't use kTextColumnId there, and ideally the two should merge.
const short kMinColumnId = 1050;
// base API for high-level databrowser operations
class wxMacListControl
{
public:
virtual void MacDelete( unsigned int n ) = 0;
virtual void MacInsert( unsigned int n, const wxString& item, int column = -1 ) = 0;
virtual void MacInsert( unsigned int n, const wxArrayString& items, int column = -1 ) = 0;
// returns index of newly created line
virtual int MacAppend( const wxString& item ) = 0;
virtual void MacSetString( unsigned int n, const wxString& item ) = 0;
virtual void MacClear() = 0;
virtual void MacDeselectAll() = 0;
virtual void MacSetSelection( unsigned int n, bool select, bool multi ) = 0;
virtual int MacGetSelection() const = 0;
virtual int MacGetSelections( wxArrayInt& aSelections ) const = 0;
virtual bool MacIsSelected( unsigned int n ) const = 0;
virtual void MacScrollTo( unsigned int n ) = 0;
virtual wxString MacGetString( unsigned int n) const = 0;
virtual unsigned int MacGetCount() const = 0;
virtual void MacSetClientData( unsigned int n, void * data) = 0;
virtual void * MacGetClientData( unsigned int) const = 0;
virtual ~wxMacListControl() { }
};
// base class for databrowser items
enum DataItemType {
DataItem_Text
};
class wxMacDataItem
{
public :
@@ -809,6 +852,32 @@ public :
virtual void Notification(wxMacDataItemBrowserControl *owner ,
DataBrowserItemNotification message,
DataBrowserItemDataRef itemData ) const;
void SetLabel( const wxString& str);
const wxString& GetLabel() const;
void SetOrder( SInt32 order );
SInt32 GetOrder() const;
void SetData( void* data);
void* GetData() const;
void SetColumn( short col );
short GetColumn();
protected :
wxString m_label;
wxMacCFStringHolder m_cfLabel;
void * m_data;
SInt32 m_order;
short m_colId;
};
enum ListSortOrder {
SortOrder_None,
SortOrder_Text_Ascending,
SortOrder_Text_Descending
};
typedef wxMacDataItem* wxMacDataItemPtr;
@@ -816,14 +885,20 @@ const wxMacDataItemPtr wxMacDataBrowserRootContainer = NULL;
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr, wxArrayMacDataItemPtr, class WXDLLIMPEXP_CORE);
class wxMacDataItemBrowserControl : public wxMacDataBrowserControl
class wxMacDataItemBrowserControl : public wxMacDataBrowserControl, public wxMacListControl
{
public :
wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style);
// create a list item (can be a subclass of wxMacListBoxItem)
virtual wxMacDataItem* CreateItem();
unsigned int GetItemCount(const wxMacDataItem* container, bool recurse , DataBrowserItemState state) const;
void GetItems(const wxMacDataItem* container, bool recurse ,
DataBrowserItemState state, wxArrayMacDataItemPtr &items ) const;
unsigned int GetSelectedItemCount( const wxMacDataItem* container, bool recurse ) const;
unsigned int GetLineFromItem(const wxMacDataItem *item) const;
wxMacDataItem * GetItemFromLine(unsigned int n) const;
@@ -833,6 +908,12 @@ public :
void UpdateItems(const wxMacDataItem *container, wxArrayMacDataItemPtr &items,
DataBrowserPropertyID property) const;
void InsertColumn(int colId, DataBrowserPropertyType colType,
const wxString& title, SInt16 just = teFlushDefault, int minWidth = -1, int maxWidth = -1);
int GetColumnWidth(int colId);
void SetColumnWidth(int colId, int width);
void AddItem(wxMacDataItem *container, wxMacDataItem *item);
void AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items );
@@ -870,8 +951,49 @@ public :
bool IsSelectionSuppressed() const { return m_suppressSelection; }
bool SuppressSelection( bool suppress );
// wxMacListControl Methods
// add and remove
virtual void MacDelete( unsigned int n );
virtual void MacInsert( unsigned int n, const wxString& item, int column = -1 );
virtual void MacInsert( unsigned int n, const wxArrayString& items, int column = -1 );
virtual int MacAppend( const wxString& item );
virtual void MacClear();
// selecting
virtual void MacDeselectAll();
virtual void MacSetSelection( unsigned int n, bool select, bool multi = false );
virtual int MacGetSelection() const;
virtual int MacGetSelections( wxArrayInt& aSelections ) const;
virtual bool MacIsSelected( unsigned int n ) const;
// display
virtual void MacScrollTo( unsigned int n );
// accessing content
virtual void MacSetString( unsigned int n, const wxString& item );
virtual void MacSetClientData( unsigned int n, void * data);
virtual wxString MacGetString( unsigned int n) const;
virtual void * MacGetClientData( unsigned int) const;
virtual unsigned int MacGetCount() const;
// client data
virtual wxClientDataType GetClientDataType() const;
virtual void SetClientDataType(wxClientDataType clientDataItemsType);
protected:
ListSortOrder m_sortOrder;
wxClientDataType m_clientDataItemsType;
// ID aware base methods, should be 'final' ie not changed in subclasses
virtual Boolean CompareItems(DataBrowserItemID itemOneID,
@@ -888,6 +1010,7 @@ protected:
DataBrowserItemNotification message,
DataBrowserItemDataRef itemData);
private :
bool m_suppressSelection;
@@ -908,7 +1031,7 @@ private :
// ============================================================================
// platform listbox implementation
// ============================================================================
//
// exposed for reuse in wxCheckListBox
class wxMacListBoxItem : public wxMacDataItem
@@ -918,84 +1041,21 @@ public :
virtual ~wxMacListBoxItem();
void SetLabel( const wxString& str);
const wxString& GetLabel() const;
virtual bool IsLessThan(wxMacDataItemBrowserControl *owner ,
const wxMacDataItem* rhs,
DataBrowserPropertyID sortProperty) const;
virtual OSStatus GetSetData( wxMacDataItemBrowserControl *owner ,
DataBrowserPropertyID property,
DataBrowserItemDataRef itemData,
bool changeValue );
virtual void Notification(wxMacDataItemBrowserControl *owner ,
DataBrowserItemNotification message,
DataBrowserItemDataRef itemData ) const;
void SetOrder( SInt32 order );
SInt32 GetOrder() const;
void SetData( void* data);
void* GetData() const;
private :
wxString m_label;
wxMacCFStringHolder m_cfLabel;
void * m_data;
SInt32 m_order;
};
class wxMacDataBrowserListControl : public wxMacDataItemBrowserControl , public wxMacListControl
class wxMacDataBrowserListControl : public wxMacDataItemBrowserControl
{
public:
wxMacDataBrowserListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style );
wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style );
virtual ~wxMacDataBrowserListControl();
// create a list item (can be a subclass of wxMacListBoxItem)
virtual wxMacListBoxItem* CreateItem();
// add and remove
void MacDelete( unsigned int n );
void MacInsert( unsigned int n, const wxString& item );
void MacInsert( unsigned int n, const wxArrayString& items );
int MacAppend( const wxString& item );
void MacClear();
// selecting
void MacDeselectAll();
void MacSetSelection( unsigned int n, bool select );
int MacGetSelection() const;
int MacGetSelections( wxArrayInt& aSelections ) const;
bool MacIsSelected( unsigned int n ) const;
// display
void MacScrollTo( unsigned int n );
// accessing content
void MacSetString( unsigned int n, const wxString& item );
void MacSetClientData( unsigned int n, void * data);
wxString MacGetString( unsigned int n) const;
void * MacGetClientData( unsigned int) const;
unsigned int MacGetCount() const;
// client data
wxClientDataType GetClientDataType() const;
void SetClientDataType(wxClientDataType clientDataItemsType);
// pointing back
wxListBox * GetPeer() const;
private :
bool m_stringSorted;
wxClientDataType m_clientDataItemsType;
wxWindow * GetPeer() const;
};
// ============================================================================

View File

@@ -26,16 +26,14 @@
// under Win32 we always use the native version and also may use the generic
// one, however some things should be done only if we use only the generic
// version
#if defined(__WIN32__) && !defined(__WXUNIVERSAL__)
#if (defined(__WIN32__) && !defined(__WXUNIVERSAL__)) || defined(__WXMAC__)
#define HAVE_NATIVE_LISTCTRL
#endif
// if we have the native control, wx/listctrl.h declares it and not this one
#ifdef HAVE_NATIVE_LISTCTRL
#include "wx/generic/listctrl.h"
#else // !HAVE_NATIVE_LISTCTRL
#include "wx/listctrl.h"
#include "wx/listctrl.h"
#ifndef HAVE_NATIVE_LISTCTRL
// if we have a native version, its implementation file does all this
IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxListView, wxListCtrl)
@@ -66,35 +64,6 @@
#define _USE_VISATTR 0
// ----------------------------------------------------------------------------
// events
// ----------------------------------------------------------------------------
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)
#if WXWIN_COMPATIBILITY_2_4
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO)
#endif
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_DRAGGING)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_END_DRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_FOCUSED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------

View File

@@ -175,7 +175,7 @@ void wxListBox::DoSetSelection(int n, bool select)
if ( n == wxNOT_FOUND )
GetPeer()->MacDeselectAll();
else
GetPeer()->MacSetSelection( n, select );
GetPeer()->MacSetSelection( n, select, HasMultipleSelection() );
}
bool wxListBox::IsSelected(int n) const
@@ -440,113 +440,15 @@ int wxListBox::DoListHitTest(const wxPoint& inpoint) const
// data browser based implementation
// ============================================================================
const short kTextColumnId = 1024;
const short kNumericOrderColumnId = 1025;
wxMacListBoxItem::wxMacListBoxItem()
:wxMacDataItem()
{
m_data = NULL;
m_order = 0;
}
wxMacListBoxItem::~wxMacListBoxItem()
{
}
void wxMacListBoxItem::SetOrder( SInt32 order )
{
m_order = order;
}
SInt32 wxMacListBoxItem::GetOrder() const
{
return m_order;
}
void wxMacListBoxItem::SetData( void* data)
{
m_data = data;
}
void* wxMacListBoxItem::GetData() const
{
return m_data;
}
void wxMacListBoxItem::SetLabel( const wxString& str)
{
m_label = str;
m_cfLabel.Assign( str , wxLocale::GetSystemEncoding());
}
const wxString& wxMacListBoxItem::GetLabel() const
{
return m_label;
}
bool wxMacListBoxItem::IsLessThan(wxMacDataItemBrowserControl *owner ,
const wxMacDataItem* rhs,
DataBrowserPropertyID sortProperty) const
{
const wxMacListBoxItem* otherItem = dynamic_cast<const wxMacListBoxItem*>(rhs);
bool retval = false;
switch (sortProperty)
{
case kTextColumnId:
retval = m_label.CmpNoCase( otherItem->m_label) < 0;
break;
case kNumericOrderColumnId:
retval = m_order < otherItem->m_order;
break;
default:
break;
};
return retval;
}
OSStatus wxMacListBoxItem::GetSetData( wxMacDataItemBrowserControl *owner ,
DataBrowserPropertyID property,
DataBrowserItemDataRef itemData,
bool changeValue )
{
OSStatus err = errDataBrowserPropertyNotSupported;
wxListBox *list = wxDynamicCast( owner->GetPeer() , wxListBox );
wxCHECK_MSG( list != NULL , errDataBrowserPropertyNotSupported , wxT("Listbox expected"));
if ( !changeValue )
{
switch (property)
{
case kTextColumnId:
err = ::SetDataBrowserItemDataText( itemData, m_cfLabel );
err = noErr;
break;
case kNumericOrderColumnId:
err = ::SetDataBrowserItemDataValue( itemData, m_order );
err = noErr;
break;
default:
break;
}
}
else
{
switch (property)
{
// no editable props here
default:
break;
}
}
return err;
}
void wxMacListBoxItem::Notification(wxMacDataItemBrowserControl *owner ,
DataBrowserItemNotification message,
DataBrowserItemDataRef itemData ) const
@@ -608,12 +510,13 @@ void wxMacListBoxItem::Notification(wxMacDataItemBrowserControl *owner ,
}
}
wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style)
wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style)
: wxMacDataItemBrowserControl( peer, pos, size, style )
{
OSStatus err = noErr;
m_clientDataItemsType = wxClientData_None;
m_stringSorted = style & wxLB_SORT;
if ( style & wxLB_SORT )
m_sortOrder = SortOrder_Text_Ascending;
DataBrowserSelectionFlags options = kDataBrowserDragSelect;
if ( style & wxLB_MULTIPLE )
@@ -668,7 +571,7 @@ wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer, const
verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
SetDataBrowserSortProperty( m_controlRef , kTextColumnId);
if ( m_stringSorted )
if ( m_sortOrder == SortOrder_Text_Ascending )
{
SetDataBrowserSortProperty( m_controlRef , kTextColumnId);
SetDataBrowserSortOrder( m_controlRef , kDataBrowserOrderIncreasing);
@@ -694,217 +597,9 @@ wxMacDataBrowserListControl::~wxMacDataBrowserListControl()
{
}
wxMacListBoxItem* wxMacDataBrowserListControl::CreateItem()
wxWindow * wxMacDataBrowserListControl::GetPeer() const
{
return new wxMacListBoxItem();
}
wxListBox * wxMacDataBrowserListControl::GetPeer() const
{
return wxDynamicCast( wxMacControl::GetPeer() , wxListBox );
}
wxClientDataType wxMacDataBrowserListControl::GetClientDataType() const
{
return m_clientDataItemsType;
}
void wxMacDataBrowserListControl::SetClientDataType(wxClientDataType clientDataItemsType)
{
m_clientDataItemsType = clientDataItemsType;
}
unsigned int wxMacDataBrowserListControl::MacGetCount() const
{
return GetItemCount(wxMacDataBrowserRootContainer,false,kDataBrowserItemAnyState);
}
void wxMacDataBrowserListControl::MacDelete( unsigned int n )
{
wxMacListBoxItem* item = (wxMacListBoxItem*)GetItemFromLine( n );
RemoveItem( wxMacDataBrowserRootContainer, item );
}
void wxMacDataBrowserListControl::MacInsert( unsigned int n, const wxString& text)
{
wxMacListBoxItem* newItem = CreateItem();
newItem->SetLabel( text );
if ( !m_stringSorted )
{
// increase the order of the lines to be shifted
unsigned int lines = MacGetCount();
for ( unsigned int i = n; i < lines; ++i)
{
wxMacListBoxItem* iter = (wxMacListBoxItem*) GetItemFromLine(i);
iter->SetOrder( iter->GetOrder() + 1 );
}
SInt32 frontLineOrder = 0;
if ( n > 0 )
{
wxMacListBoxItem* iter = (wxMacListBoxItem*) GetItemFromLine(n-1);
frontLineOrder = iter->GetOrder();
}
newItem->SetOrder( frontLineOrder + 1 );
}
AddItem( wxMacDataBrowserRootContainer, newItem );
}
void wxMacDataBrowserListControl::MacInsert( unsigned int n, const wxArrayString& items)
{
size_t itemsCount = items.GetCount();
if ( itemsCount == 0 )
return;
SInt32 frontLineOrder = 0;
if ( !m_stringSorted )
{
// increase the order of the lines to be shifted
unsigned int lines = MacGetCount();
for ( unsigned int i = n; i < lines; ++i)
{
wxMacListBoxItem* iter = (wxMacListBoxItem*) GetItemFromLine(i);
iter->SetOrder( iter->GetOrder() + itemsCount );
}
if ( n > 0 )
{
wxMacListBoxItem* iter = (wxMacListBoxItem*) GetItemFromLine(n-1);
frontLineOrder = iter->GetOrder();
}
}
wxArrayMacDataItemPtr ids;
ids.SetCount( itemsCount );
for ( unsigned int i = 0; i < itemsCount; ++i )
{
wxMacListBoxItem* item = CreateItem();
item->SetLabel( items[i]);
if ( !m_stringSorted )
item->SetOrder( frontLineOrder + 1 + i );
ids[i] = item;
}
AddItems( wxMacDataBrowserRootContainer, ids );
}
int wxMacDataBrowserListControl::MacAppend( const wxString& text)
{
wxMacListBoxItem* item = CreateItem();
item->SetLabel( text );
if ( !m_stringSorted )
{
unsigned int lines = MacGetCount();
if ( lines == 0 )
item->SetOrder( 1 );
else
{
wxMacListBoxItem* frontItem = (wxMacListBoxItem*) GetItemFromLine(lines-1);
item->SetOrder( frontItem->GetOrder() + 1 );
}
}
AddItem( wxMacDataBrowserRootContainer, item );
return GetLineFromItem(item);
}
void wxMacDataBrowserListControl::MacClear()
{
wxMacDataItemBrowserSelectionSuppressor suppressor(this);
RemoveAllItems(wxMacDataBrowserRootContainer);
}
void wxMacDataBrowserListControl::MacDeselectAll()
{
wxMacDataItemBrowserSelectionSuppressor suppressor(this);
SetSelectedAllItems( kDataBrowserItemsRemove );
}
void wxMacDataBrowserListControl::MacSetSelection( unsigned int n, bool select )
{
wxMacListBoxItem* item = (wxMacListBoxItem*) GetItemFromLine(n);
wxMacDataItemBrowserSelectionSuppressor suppressor(this);
if ( IsItemSelected( item ) != select )
{
if ( select )
SetSelectedItem( item, GetPeer()->HasMultipleSelection() ? kDataBrowserItemsAdd : kDataBrowserItemsAssign );
else
SetSelectedItem( item, kDataBrowserItemsRemove );
}
MacScrollTo( n );
}
bool wxMacDataBrowserListControl::MacIsSelected( unsigned int n ) const
{
wxMacListBoxItem* item = (wxMacListBoxItem*) GetItemFromLine(n);
return IsItemSelected( item );
}
int wxMacDataBrowserListControl::MacGetSelection() const
{
wxMacDataItemPtr first, last;
GetSelectionAnchor( &first, &last );
if ( first != NULL )
{
return GetLineFromItem( first );
}
return -1;
}
int wxMacDataBrowserListControl::MacGetSelections( wxArrayInt& aSelections ) const
{
aSelections.Empty();
wxArrayMacDataItemPtr selectedItems;
GetItems( wxMacDataBrowserRootContainer, false , kDataBrowserItemIsSelected, selectedItems);
int count = selectedItems.GetCount();
for ( int i = 0; i < count; ++i)
{
aSelections.Add(GetLineFromItem(selectedItems[i]));
}
return count;
}
void wxMacDataBrowserListControl::MacSetString( unsigned int n, const wxString& text )
{
// as we don't store the strings we only have to issue a redraw
wxMacListBoxItem* item = (wxMacListBoxItem*) GetItemFromLine( n);
item->SetLabel( text );
UpdateItem( wxMacDataBrowserRootContainer, item , kTextColumnId );
}
wxString wxMacDataBrowserListControl::MacGetString( unsigned int n ) const
{
wxMacListBoxItem * item = (wxMacListBoxItem*) GetItemFromLine( n );
return item->GetLabel();
}
void wxMacDataBrowserListControl::MacSetClientData( unsigned int n, void * data)
{
wxMacListBoxItem* item = (wxMacListBoxItem*) GetItemFromLine( n);
item->SetData( data );
// not displayed, therefore no Update infos to DataBrowser
}
void * wxMacDataBrowserListControl::MacGetClientData( unsigned int n) const
{
wxMacListBoxItem * item = (wxMacListBoxItem*) GetItemFromLine( n );
return item->GetData();
}
void wxMacDataBrowserListControl::MacScrollTo( unsigned int n )
{
RevealItem( GetItemFromLine( n) , kDataBrowserRevealWithoutSelecting );
return wxDynamicCast( wxMacControl::GetPeer() , wxWindow );
}
#if 0

View File

@@ -1274,7 +1274,6 @@ pascal OSStatus wxMacDataBrowserControl::DataBrowserGetSetItemDataProc(
Boolean changeValue )
{
OSStatus err = errDataBrowserPropertyNotSupported;
wxMacDataBrowserControl* ctl = dynamic_cast<wxMacDataBrowserControl*>( wxMacControl::GetReferenceFromNativeControl( browser ) );
if ( ctl != 0 )
{
@@ -1360,6 +1359,17 @@ OSStatus wxMacDataBrowserControl::AddColumn( DataBrowserListViewColumnDesc *colu
return AddDataBrowserListViewColumn( m_controlRef, columnDesc, position );
}
OSStatus wxMacDataBrowserControl::GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id ){
return GetDataBrowserTableViewColumnProperty( m_controlRef, position, id );
}
OSStatus wxMacDataBrowserControl::RemoveColumn( DataBrowserTableViewColumnIndex position )
{
DataBrowserTableViewColumnID id;
GetColumnIDFromIndex( position, &id );
return RemoveDataBrowserTableViewColumn( m_controlRef, id );
}
OSStatus wxMacDataBrowserControl::AutoSizeColumns()
{
return AutoSizeDataBrowserListViewColumns(m_controlRef);
@@ -1579,25 +1589,103 @@ OSStatus wxMacDataBrowserControl::SetDisclosureColumn( DataBrowserPropertyID pro
wxMacDataItem::wxMacDataItem()
{
m_data = NULL;
m_order = 0;
m_colId = kTextColumnId; // for compat with existing wx*ListBox impls.
}
wxMacDataItem::~wxMacDataItem()
{
}
bool wxMacDataItem::IsLessThan(wxMacDataItemBrowserControl *owner ,
const wxMacDataItem*,
DataBrowserPropertyID property) const
void wxMacDataItem::SetOrder( SInt32 order )
{
return false;
m_order = order;
}
OSStatus wxMacDataItem::GetSetData(wxMacDataItemBrowserControl *owner ,
SInt32 wxMacDataItem::GetOrder() const
{
return m_order;
}
void wxMacDataItem::SetData( void* data)
{
m_data = data;
}
void* wxMacDataItem::GetData() const
{
return m_data;
}
short wxMacDataItem::GetColumn()
{
return m_colId;
}
void wxMacDataItem::SetColumn( short col )
{
m_colId = col;
}
void wxMacDataItem::SetLabel( const wxString& str)
{
m_label = str;
m_cfLabel.Assign( str , wxLocale::GetSystemEncoding());
}
const wxString& wxMacDataItem::GetLabel() const
{
return m_label;
}
bool wxMacDataItem::IsLessThan(wxMacDataItemBrowserControl *owner ,
const wxMacDataItem* rhs,
DataBrowserPropertyID sortProperty) const
{
const wxMacDataItem* otherItem = dynamic_cast<const wxMacDataItem*>(rhs);
bool retval = false;
if ( sortProperty == m_colId ){
retval = m_label.CmpNoCase( otherItem->m_label) < 0;
}
else if ( sortProperty == kNumericOrderColumnId )
retval = m_order < otherItem->m_order;
return retval;
}
OSStatus wxMacDataItem::GetSetData( wxMacDataItemBrowserControl *owner ,
DataBrowserPropertyID property,
DataBrowserItemDataRef itemData,
bool changeValue )
{
return errDataBrowserPropertyNotSupported;
OSStatus err = errDataBrowserPropertyNotSupported;
if ( !changeValue )
{
if ( property == m_colId ){
err = ::SetDataBrowserItemDataText( itemData, m_cfLabel );
err = noErr;
}
else if ( property == kNumericOrderColumnId ){
err = ::SetDataBrowserItemDataValue( itemData, m_order );
err = noErr;
}
else{
}
}
else
{
switch (property)
{
// no editable props here
default:
break;
}
}
return err;
}
void wxMacDataItem::Notification(wxMacDataItemBrowserControl *owner ,
@@ -1611,6 +1699,13 @@ wxMacDataItemBrowserControl::wxMacDataItemBrowserControl( wxWindow* peer , const
wxMacDataBrowserControl( peer, pos, size, style )
{
m_suppressSelection = false;
m_sortOrder = SortOrder_None;
m_clientDataItemsType = wxClientData_None;
}
wxMacDataItem* wxMacDataItemBrowserControl::CreateItem()
{
return new wxMacDataItem();
}
wxMacDataItemBrowserSelectionSuppressor::wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser)
@@ -1676,8 +1771,10 @@ OSStatus wxMacDataItemBrowserControl::GetSetItemData(
// right now default behaviour on these
break;
default :
if ( item != NULL )
if ( item != NULL ){
err = item->GetSetData( this, property , itemData , changeValue );
}
break;
}
@@ -1711,6 +1808,13 @@ unsigned int wxMacDataItemBrowserControl::GetItemCount(const wxMacDataItem* cont
return numItems;
}
unsigned int wxMacDataItemBrowserControl::GetSelectedItemCount( const wxMacDataItem* container,
bool recurse ) const
{
return GetItemCount( container, recurse, kDataBrowserItemIsSelected );
}
void wxMacDataItemBrowserControl::GetItems(const wxMacDataItem* container,
bool recurse , DataBrowserItemState state, wxArrayMacDataItemPtr &items) const
{
@@ -1765,6 +1869,68 @@ void wxMacDataItemBrowserControl::UpdateItems(const wxMacDataItem *container,
delete [] items;
}
void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyType colType,
const wxString& title, SInt16 just, int minWidth, int maxWidth)
{
DataBrowserListViewColumnDesc columnDesc;
columnDesc.headerBtnDesc.titleOffset = 0;
columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
columnDesc.headerBtnDesc.btnFontStyle.flags =
kControlUseFontMask | kControlUseJustMask;
columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlContentTextOnly;
columnDesc.headerBtnDesc.btnFontStyle.just = just;
columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
columnDesc.headerBtnDesc.btnFontStyle.style = normal;
// TODO: Why is m_font not defined when we enter wxLC_LIST mode, but is
// defined for other modes?
wxFontEncoding enc;
if ( m_font.Ok() )
enc = m_font.GetEncoding();
else
enc = wxLocale::GetSystemEncoding();
wxMacCFStringHolder cfTitle;
cfTitle.Assign( title, enc );
columnDesc.headerBtnDesc.titleString = cfTitle;
int colMinWidth = 0;
if (minWidth != -1)
colMinWidth = minWidth;
columnDesc.headerBtnDesc.minimumWidth = colMinWidth;
int colMaxWidth = 500;
if (maxWidth != -1)
colMaxWidth = maxWidth;
columnDesc.headerBtnDesc.maximumWidth = colMaxWidth;
columnDesc.propertyDesc.propertyID = (kMinColumnId + colId);
columnDesc.propertyDesc.propertyType = colType;
columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewDefaultColumnFlags | kDataBrowserListViewNoGapForIconInHeaderButton;
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
#endif
verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
}
void wxMacDataItemBrowserControl::SetColumnWidth(int colId, int width)
{
DataBrowserPropertyID id;
GetColumnIDFromIndex(colId, &id);
verify_noerr( wxMacDataBrowserControl::SetColumnWidth(id, width));
}
int wxMacDataItemBrowserControl::GetColumnWidth(int colId)
{
DataBrowserPropertyID id;
GetColumnIDFromIndex(colId, &id);
UInt16 result;
verify_noerr( wxMacDataBrowserControl::GetColumnWidth(id, &result));
return result;
}
void wxMacDataItemBrowserControl::AddItem(wxMacDataItem *container, wxMacDataItem *item)
{
verify_noerr( wxMacDataBrowserControl::AddItems( (DataBrowserItemID)container, 1,
@@ -1845,6 +2011,213 @@ void wxMacDataItemBrowserControl::GetSelectionAnchor( wxMacDataItemPtr* first ,
verify_noerr(wxMacDataBrowserControl::GetSelectionAnchor( (DataBrowserItemID*) first, (DataBrowserItemID*) last) );
}
wxClientDataType wxMacDataItemBrowserControl::GetClientDataType() const
{
return m_clientDataItemsType;
}
void wxMacDataItemBrowserControl::SetClientDataType(wxClientDataType clientDataItemsType)
{
m_clientDataItemsType = clientDataItemsType;
}
unsigned int wxMacDataItemBrowserControl::MacGetCount() const
{
return GetItemCount(wxMacDataBrowserRootContainer,false,kDataBrowserItemAnyState);
}
void wxMacDataItemBrowserControl::MacDelete( unsigned int n )
{
wxMacDataItem* item = (wxMacDataItem*)GetItemFromLine( n );
RemoveItem( wxMacDataBrowserRootContainer, item );
}
void wxMacDataItemBrowserControl::MacInsert( unsigned int n, const wxString& text, int column )
{
wxMacDataItem* newItem = CreateItem();
newItem->SetLabel( text );
if ( column != -1 )
newItem->SetColumn( kMinColumnId + column );
if ( m_sortOrder == SortOrder_None )
{
// increase the order of the lines to be shifted
unsigned int lines = MacGetCount();
for ( unsigned int i = n; i < lines; ++i)
{
wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(i);
iter->SetOrder( iter->GetOrder() + 1 );
}
SInt32 frontLineOrder = 0;
if ( n > 0 )
{
wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(n-1);
frontLineOrder = iter->GetOrder();
}
newItem->SetOrder( frontLineOrder + 1 );
}
AddItem( wxMacDataBrowserRootContainer, newItem );
}
void wxMacDataItemBrowserControl::MacInsert( unsigned int n, const wxArrayString& items, int column )
{
size_t itemsCount = items.GetCount();
if ( itemsCount == 0 )
return;
SInt32 frontLineOrder = 0;
if ( m_sortOrder == SortOrder_None )
{
// increase the order of the lines to be shifted
unsigned int lines = MacGetCount();
for ( unsigned int i = n; i < lines; ++i)
{
wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(i);
iter->SetOrder( iter->GetOrder() + itemsCount );
}
if ( n > 0 )
{
wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(n-1);
frontLineOrder = iter->GetOrder();
}
}
wxArrayMacDataItemPtr ids;
ids.SetCount( itemsCount );
for ( unsigned int i = 0; i < itemsCount; ++i )
{
wxMacDataItem* item = CreateItem();
item->SetLabel( items[i]);
if ( column != -1 )
item->SetColumn( kMinColumnId + column );
if ( m_sortOrder == SortOrder_None )
item->SetOrder( frontLineOrder + 1 + i );
ids[i] = item;
}
AddItems( wxMacDataBrowserRootContainer, ids );
}
int wxMacDataItemBrowserControl::MacAppend( const wxString& text)
{
wxMacDataItem* item = CreateItem();
item->SetLabel( text );
if ( m_sortOrder == SortOrder_None )
{
unsigned int lines = MacGetCount();
if ( lines == 0 )
item->SetOrder( 1 );
else
{
wxMacDataItem* frontItem = (wxMacDataItem*) GetItemFromLine(lines-1);
item->SetOrder( frontItem->GetOrder() + 1 );
}
}
AddItem( wxMacDataBrowserRootContainer, item );
return GetLineFromItem(item);
}
void wxMacDataItemBrowserControl::MacClear()
{
wxMacDataItemBrowserSelectionSuppressor suppressor(this);
RemoveAllItems(wxMacDataBrowserRootContainer);
}
void wxMacDataItemBrowserControl::MacDeselectAll()
{
wxMacDataItemBrowserSelectionSuppressor suppressor(this);
SetSelectedAllItems( kDataBrowserItemsRemove );
}
void wxMacDataItemBrowserControl::MacSetSelection( unsigned int n, bool select, bool multi )
{
wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine(n);
wxMacDataItemBrowserSelectionSuppressor suppressor(this);
if ( IsItemSelected( item ) != select )
{
if ( select )
SetSelectedItem( item, multi ? kDataBrowserItemsAdd : kDataBrowserItemsAssign );
else
SetSelectedItem( item, kDataBrowserItemsRemove );
}
MacScrollTo( n );
}
bool wxMacDataItemBrowserControl::MacIsSelected( unsigned int n ) const
{
wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine(n);
return IsItemSelected( item );
}
int wxMacDataItemBrowserControl::MacGetSelection() const
{
wxMacDataItemPtr first, last;
GetSelectionAnchor( &first, &last );
if ( first != NULL )
{
return GetLineFromItem( first );
}
return -1;
}
int wxMacDataItemBrowserControl::MacGetSelections( wxArrayInt& aSelections ) const
{
aSelections.Empty();
wxArrayMacDataItemPtr selectedItems;
GetItems( wxMacDataBrowserRootContainer, false , kDataBrowserItemIsSelected, selectedItems);
int count = selectedItems.GetCount();
for ( int i = 0; i < count; ++i)
{
aSelections.Add(GetLineFromItem(selectedItems[i]));
}
return count;
}
void wxMacDataItemBrowserControl::MacSetString( unsigned int n, const wxString& text )
{
// as we don't store the strings we only have to issue a redraw
wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine( n);
item->SetLabel( text );
UpdateItem( wxMacDataBrowserRootContainer, item , kTextColumnId );
}
wxString wxMacDataItemBrowserControl::MacGetString( unsigned int n ) const
{
wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
return item->GetLabel();
}
void wxMacDataItemBrowserControl::MacSetClientData( unsigned int n, void * data)
{
wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine( n);
item->SetData( data );
// not displayed, therefore no Update infos to DataBrowser
}
void * wxMacDataItemBrowserControl::MacGetClientData( unsigned int n) const
{
wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
return item->GetData();
}
void wxMacDataItemBrowserControl::MacScrollTo( unsigned int n )
{
RevealItem( GetItemFromLine( n) , kDataBrowserRevealWithoutSelecting );
}
//

View File

@@ -216,35 +216,6 @@ static wxListItemAttr *wxGetInternalDataAttr(const wxListCtrl *ctl, long itemId)
static void wxDeleteInternalData(wxListCtrl* ctl, long itemId);
// ----------------------------------------------------------------------------
// events
// ----------------------------------------------------------------------------
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)
#if WXWIN_COMPATIBILITY_2_4
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO)
#endif
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_DRAGGING)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_END_DRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_FOCUSED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
#if wxUSE_EXTENDED_RTTI
WX_DEFINE_FLAGS( wxListCtrlStyle )

View File

@@ -774,32 +774,6 @@ void ConvertToOS2ListCol (
pField->offStruct = 0;
} // end of ConvertToOS2ListCol
// ----------------------------------------------------------------------------
// events
// ----------------------------------------------------------------------------
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_DRAGGING)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_END_DRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_FOCUSED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxListView, wxListCtrl)

View File

@@ -38,33 +38,6 @@
#include "wx/imaglist.h"
#include "wx/listctrl.h"
// ----------------------------------------------------------------------------
// events
// ----------------------------------------------------------------------------
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_DRAGGING)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_END_DRAG)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_FOCUSED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
#if wxUSE_EXTENDED_RTTI
WX_DEFINE_FLAGS( wxListCtrlStyle )