Added initial OS X implementation of the wxDataViewCtrl
in its current tabular form. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46344 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
306
include/wx/mac/carbon/databrow.h
Normal file
306
include/wx/mac/carbon/databrow.h
Normal file
@@ -0,0 +1,306 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: include/mac/carbon/databrow.h
|
||||
// Purpose: Classes and functions for the Carbon data browser
|
||||
// Author:
|
||||
// Modified by:
|
||||
// Created: 2007-05-18
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c)
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DATABROW_H_
|
||||
#define _WX_DATABROW_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#ifdef __DARWIN__
|
||||
# include <Carbon/Carbon.h>
|
||||
#else
|
||||
# include <Debugging.h>
|
||||
# include <Appearance.h>
|
||||
# include <Controls.h>
|
||||
# include <ControlDefinitions.h>
|
||||
# include <LowMem.h>
|
||||
# include <Gestalt.h>
|
||||
# include <CoreServices.h>
|
||||
#endif
|
||||
|
||||
#if UNIVERSAL_INTERFACES_VERSION < 0x0342
|
||||
#error "please update to Apple's latest universal headers from http://developer.apple.com/sdk/"
|
||||
#endif
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_3
|
||||
#define MAC_OS_X_VERSION_10_3 1030
|
||||
#endif
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_4
|
||||
#define MAC_OS_X_VERSION_10_4 1040
|
||||
#endif
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_5
|
||||
#define MAC_OS_X_VERSION_10_5 1050
|
||||
#endif
|
||||
|
||||
#ifdef __WXMAC_CARBON__
|
||||
# include "wx/mac/corefoundation/cfstring.h"
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
|
||||
typedef UInt32 URefCon;
|
||||
typedef SInt32 SRefCon;
|
||||
#endif
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
#include "wx/hashmap.h"
|
||||
|
||||
#include "wx/mac/private.h"
|
||||
|
||||
WX_DEFINE_ARRAY_SIZE_T(size_t,wxArrayDataBrowserItemID);
|
||||
|
||||
// ============================================================================
|
||||
// DataBrowser Wrapper
|
||||
// ============================================================================
|
||||
//
|
||||
// basing on DataBrowserItemIDs
|
||||
//
|
||||
|
||||
// data browser's property IDs have a reserved ID range from 0 - 1023
|
||||
// therefore, the first usable property ID is 'kMinPropertyID'
|
||||
DataBrowserPropertyID const kMinPropertyID = 1024;
|
||||
|
||||
class wxMacDataBrowserTableViewControl : public wxMacControl
|
||||
{
|
||||
public:
|
||||
//
|
||||
// constructors / destructor
|
||||
//
|
||||
wxMacDataBrowserTableViewControl(wxWindow* peer, const wxPoint& pos, const wxSize& size, long style);
|
||||
wxMacDataBrowserTableViewControl(void)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// callback handling
|
||||
//
|
||||
OSStatus SetCallbacks (DataBrowserCallbacks const* callbacks);
|
||||
OSStatus SetCustomCallbacks(DataBrowserCustomCallbacks const* customCallbacks);
|
||||
|
||||
//
|
||||
// header handling
|
||||
//
|
||||
OSStatus GetHeaderDesc(DataBrowserPropertyID property, DataBrowserListViewHeaderDesc* desc) const;
|
||||
|
||||
OSStatus SetHeaderDesc(DataBrowserPropertyID property, DataBrowserListViewHeaderDesc* desc);
|
||||
|
||||
//
|
||||
// layout handling
|
||||
//
|
||||
OSStatus AutoSizeColumns();
|
||||
|
||||
OSStatus EnableCellSizeModification(bool enableHeight=true, bool enableWidth=true); // enables or disables the column width and row height modification (default: false)
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
OSStatus GetAttributes (OptionBits* attributes);
|
||||
#endif
|
||||
OSStatus GetColumnWidth (DataBrowserPropertyID column, UInt16 *width ) const; // returns the column width in pixels
|
||||
OSStatus GetDefaultColumnWidth(UInt16 *width ) const; // returns the default column width in pixels
|
||||
OSStatus GetDefaultRowHeight (UInt16 * height ) const;
|
||||
OSStatus GetHeaderButtonHeight(UInt16 *height );
|
||||
OSStatus GetRowHeight (DataBrowserItemID item , UInt16 *height) const;
|
||||
OSStatus GetScrollPosition (UInt32* top, UInt32 *left) const;
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
OSStatus SetAttributes (OptionBits attributes);
|
||||
#endif
|
||||
OSStatus SetColumnWidth(DataBrowserPropertyID column, UInt16 width); // sets the column width in pixels
|
||||
OSStatus SetDefaultColumnWidth( UInt16 width );
|
||||
OSStatus SetDefaultRowHeight( UInt16 height );
|
||||
OSStatus SetHasScrollBars( bool horiz, bool vert );
|
||||
OSStatus SetHeaderButtonHeight( UInt16 height );
|
||||
OSStatus SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle );
|
||||
OSStatus SetRowHeight( DataBrowserItemID item , UInt16 height);
|
||||
OSStatus SetScrollPosition( UInt32 top , UInt32 left );
|
||||
|
||||
//
|
||||
// column handling
|
||||
//
|
||||
OSStatus GetColumnCount (UInt32* numColumns) const;
|
||||
OSStatus GetColumnID (DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id);
|
||||
OSStatus GetFreePropertyID(DataBrowserPropertyID* id) const; // this method returns a property id that is valid and currently not used; if it cannot be found 'errDataBrowerPropertyNotSupported' is returned
|
||||
OSStatus GetPropertyColumn(DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex* index) const;
|
||||
OSStatus GetPropertyFlags (DataBrowserPropertyID propertyID, DataBrowserPropertyFlags *flags ) const;
|
||||
|
||||
OSStatus IsUsedPropertyID(DataBrowserPropertyID propertyID) const; // checks if passed property id is used by the control; no error is returned if the id exists
|
||||
|
||||
OSStatus RemoveColumn(DataBrowserTableViewColumnIndex position);
|
||||
|
||||
OSStatus SetColumnPosition (DataBrowserPropertyID column, DataBrowserTableViewColumnIndex position);
|
||||
OSStatus SetDisclosureColumn(DataBrowserPropertyID property, Boolean expandableRows );
|
||||
OSStatus SetPropertyFlags (DataBrowserPropertyID property, DataBrowserPropertyFlags flags );
|
||||
|
||||
//
|
||||
// item handling
|
||||
//
|
||||
OSStatus AddItem(DataBrowserItemID container, DataBrowserItemID const* itemID) // adds a single item
|
||||
{
|
||||
return this->AddItems(container,1,itemID,kDataBrowserItemNoProperty);
|
||||
}
|
||||
OSStatus AddItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty); // adds items to the data browser
|
||||
|
||||
OSStatus GetFreeItemID(DataBrowserItemID* id) const; // this method returns an item id that is valid and currently not used; if it cannot be found 'errDataBrowserItemNotAdded' is returned
|
||||
OSStatus GetItemCount (ItemCount* numItems) const
|
||||
{
|
||||
return this->GetItemCount(kDataBrowserNoItem,true,kDataBrowserItemAnyState,numItems);
|
||||
}
|
||||
OSStatus GetItemCount (DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, ItemCount* numItems) const;
|
||||
OSStatus GetItemID (DataBrowserTableViewRowIndex row, DataBrowserItemID * item) const;
|
||||
OSStatus GetItems (DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, Handle items) const;
|
||||
OSStatus GetItemRow (DataBrowserItemID item, DataBrowserTableViewRowIndex* row) const;
|
||||
|
||||
OSStatus IsUsedItemID(DataBrowserItemID itemID) const; // checks if the passed id is in use
|
||||
|
||||
OSStatus RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const;
|
||||
|
||||
OSStatus RemoveItem(DataBrowserItemID container, DataBrowserItemID const* itemID) // removes a single item
|
||||
{
|
||||
return this->RemoveItems(container,1,itemID,kDataBrowserItemNoProperty);
|
||||
}
|
||||
OSStatus RemoveItems(void) // removes all items
|
||||
{
|
||||
return this->RemoveItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty);
|
||||
}
|
||||
OSStatus RemoveItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty);
|
||||
|
||||
OSStatus UpdateItems(void) // updates all items
|
||||
{
|
||||
return this->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,kDataBrowserNoItem);
|
||||
}
|
||||
OSStatus UpdateItems(DataBrowserItemID const* item) // updates all columns of item
|
||||
{
|
||||
return this->UpdateItems(kDataBrowserNoItem,1,item,kDataBrowserItemNoProperty,kDataBrowserNoItem);
|
||||
}
|
||||
OSStatus UpdateItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty, DataBrowserPropertyID propertyID) const;
|
||||
|
||||
//
|
||||
// item selection
|
||||
//
|
||||
size_t GetSelectedItemIDs(wxArrayDataBrowserItemID& itemIDs) const; // returns the number of selected item and the item IDs in the array
|
||||
OSStatus GetSelectionAnchor(DataBrowserItemID *first, DataBrowserItemID *last) const;
|
||||
OSStatus GetSelectionFlags (DataBrowserSelectionFlags* flags) const;
|
||||
|
||||
bool IsItemSelected(DataBrowserItemID item) const;
|
||||
|
||||
OSStatus SetSelectionFlags(DataBrowserSelectionFlags flags);
|
||||
OSStatus SetSelectedItems (UInt32 numItems, DataBrowserItemID const* itemIDs, DataBrowserSetOption operation);
|
||||
|
||||
//
|
||||
// item sorting
|
||||
//
|
||||
OSStatus GetSortOrder (DataBrowserSortOrder* order) const;
|
||||
OSStatus GetSortProperty(DataBrowserPropertyID* column) const;
|
||||
|
||||
OSStatus SetSortOrder (DataBrowserSortOrder order);
|
||||
OSStatus SetSortProperty(DataBrowserPropertyID column);
|
||||
|
||||
protected :
|
||||
//
|
||||
// callback functions
|
||||
//
|
||||
static pascal Boolean DataBrowserCompareProc (ControlRef browser, DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty);
|
||||
static pascal void DataBrowserDrawItemProc (ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice);
|
||||
static pascal OSStatus DataBrowserGetSetItemDataProc (ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean getValue);
|
||||
static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData);
|
||||
|
||||
virtual Boolean DataBrowserCompareProc (DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty) = 0;
|
||||
virtual void DataBrowserDrawItemProc (DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice) = 0;
|
||||
virtual OSStatus DataBrowserGetSetItemDataProc (DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean getValue) = 0;
|
||||
virtual void DataBrowserItemNotificationProc(DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData) = 0;
|
||||
private:
|
||||
//
|
||||
// wxWidget internal stuff
|
||||
//
|
||||
DECLARE_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl)
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// Databrowser class for the list view control
|
||||
// ============================================================================
|
||||
//
|
||||
class wxMacDataBrowserListViewControl : public wxMacDataBrowserTableViewControl
|
||||
{
|
||||
public:
|
||||
//
|
||||
// constructors / destructor
|
||||
//
|
||||
wxMacDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style) : wxMacDataBrowserTableViewControl(peer,pos,size,style)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// column handling
|
||||
//
|
||||
OSStatus AddColumn(DataBrowserListViewColumnDesc *columnDesc, DataBrowserTableViewColumnIndex position);
|
||||
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// Databrowser class for the data view list control model
|
||||
// ============================================================================
|
||||
//
|
||||
|
||||
//
|
||||
// Hash maps used by the data browser for the data view model
|
||||
//
|
||||
WX_DECLARE_HASH_MAP(DataBrowserItemID,unsigned long,wxIntegerHash,wxIntegerEqual,ItemIDRowNumberHashMap); // stores for each item ID the model's row number
|
||||
|
||||
class wxMacDataViewDataBrowserListViewControl : public wxMacDataBrowserListViewControl
|
||||
{
|
||||
public:
|
||||
//
|
||||
// constructors / destructor
|
||||
wxMacDataViewDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style);
|
||||
|
||||
//
|
||||
// item ID and model matching
|
||||
//
|
||||
void ClearItemIDRowPairs(void); // removes all ID row pairs
|
||||
|
||||
bool DeleteItemIDRowPair(DataBrowserItemID itemID); // if the id has been removed, 'true' is returned, 'false' is returned if the id did not exist or another error occurred
|
||||
|
||||
bool GetRowIndex(unsigned long& rowIndex, DataBrowserItemID itemID) const; // returns 'true' and the rowIndex if the id has been found in the map, otherwise 'false' is returned and rowIndex remains untouched
|
||||
|
||||
bool InsertItemIDRowPair(DataBrowserItemID itemID, unsigned long rowIndex); // the pair will only be inserted if the item ID does not exist before the call
|
||||
|
||||
void RenumberItemIDRowIndices (unsigned int* newIndices); // for each item ID - row index pair the row index is changed
|
||||
void RenumberItemIDRowIndicesDeletion (unsigned long decreaseFromIndex); // decreases all row indices by one that are equal or larger than 'decreaseFromIndex'
|
||||
void RenumberItemIDRowIndicesInsertion(unsigned long increaseFromIndex); // increases all row indices by one that are equal or larger than 'increaseFromIndex'
|
||||
|
||||
void ReverseRowIndexNumbering(void); // reverses the order of the indices
|
||||
|
||||
protected:
|
||||
//
|
||||
// callback functions (inherited from wxMacDataBrowserTableViewControl)
|
||||
//
|
||||
virtual Boolean DataBrowserCompareProc (DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty);
|
||||
virtual void DataBrowserDrawItemProc (DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice);
|
||||
virtual void DataBrowserItemNotificationProc(DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData);
|
||||
virtual OSStatus DataBrowserGetSetItemDataProc (DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean getValue);
|
||||
|
||||
private:
|
||||
//
|
||||
// variables
|
||||
//
|
||||
ItemIDRowNumberHashMap m_itemIDRowNumberMap; // contains for each data browser ID the corresponding line number in the model
|
||||
};
|
||||
|
||||
typedef wxMacDataViewDataBrowserListViewControl* wxMacDataViewDataBrowserListViewControlPointer;
|
||||
|
||||
|
||||
#endif // WX_GUI
|
||||
|
||||
#endif // _WX_DATABROW_H_
|
555
include/wx/mac/carbon/dataview.h
Normal file
555
include/wx/mac/carbon/dataview.h
Normal file
@@ -0,0 +1,555 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/mac/carbon/dataview.h
|
||||
// Purpose: wxDataViewCtrl native implementation header
|
||||
// Author:
|
||||
// Id: $Id$
|
||||
// Copyright: (c) 2007
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __MACCARBONDATAVIEWCTRL_H__
|
||||
#define __MACCARBONDATAVIEWCTRL_H__
|
||||
|
||||
#include <Carbon/carbon.h>
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/object.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/control.h"
|
||||
#include "wx/scrolwin.h"
|
||||
#include "wx/icon.h"
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// classes
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewCtrl;
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewRenderer
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase
|
||||
{
|
||||
public:
|
||||
//
|
||||
// constructors / destructor
|
||||
//
|
||||
wxDataViewRenderer(wxString const& varianttype, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
|
||||
|
||||
//
|
||||
// inherited methods from wxDataViewRendererBase
|
||||
//
|
||||
virtual int GetAlignment(void) const
|
||||
{
|
||||
return this->m_alignment;
|
||||
}
|
||||
virtual wxDataViewCellMode GetMode(void) const
|
||||
{
|
||||
return this->m_mode;
|
||||
}
|
||||
virtual bool GetValue(wxVariant& value) const
|
||||
{
|
||||
value = this->m_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void SetAlignment(int WXUNUSED(align)) // is always identical to the header alignment
|
||||
{
|
||||
}
|
||||
virtual void SetMode(wxDataViewCellMode mode);
|
||||
virtual bool SetValue(wxVariant const& newValue)
|
||||
{
|
||||
this->m_value = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
DataBrowserItemDataRef GetDataReference(void) const
|
||||
{
|
||||
return this->m_dataReference;
|
||||
}
|
||||
wxVariant const& GetValue(void) const
|
||||
{
|
||||
return this->m_value;
|
||||
}
|
||||
|
||||
virtual DataBrowserPropertyType GetPropertyType(void) const = 0;
|
||||
|
||||
virtual bool Render(void) = 0; // a call to the appropriate data browser function filling the data reference with the stored datum;
|
||||
// returns 'true' if the data value could be rendered, 'false' otherwise
|
||||
|
||||
void SetDataReference(DataBrowserItemDataRef const& newDataReference)
|
||||
{
|
||||
this->m_dataReference = newDataReference;
|
||||
}
|
||||
|
||||
private:
|
||||
//
|
||||
// variables
|
||||
//
|
||||
DataBrowserItemDataRef m_dataReference; // data reference of the data browser; the data will be assigned to this reference during rendering
|
||||
|
||||
int m_alignment; // contains the alignment flags
|
||||
|
||||
wxDataViewCellMode m_mode; // storing the mode that determines how the cell is going to be shown
|
||||
|
||||
wxVariant m_value; // value that is going to be rendered
|
||||
|
||||
//
|
||||
// wxWidget internal stuff
|
||||
//
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewCustomRenderer
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
|
||||
{
|
||||
public:
|
||||
//
|
||||
// constructors / destructor
|
||||
//
|
||||
wxDataViewCustomRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
|
||||
|
||||
virtual ~wxDataViewCustomRenderer(void);
|
||||
|
||||
//
|
||||
// methods handling render space
|
||||
//
|
||||
virtual wxSize GetSize() const = 0;
|
||||
|
||||
//
|
||||
// methods handling user actions
|
||||
//
|
||||
virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
|
||||
|
||||
virtual bool Activate(wxRect WXUNUSED(cell), wxDataViewListModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool LeftClick(wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), wxDataViewListModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool RightClick(wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), wxDataViewListModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool StartDrag(wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), wxDataViewListModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// in-place editing
|
||||
//
|
||||
virtual void CancelEditing()
|
||||
{
|
||||
}
|
||||
|
||||
virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent), wxRect WXUNUSED(labelRect), const wxVariant& WXUNUSED(value))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual bool FinishEditing()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
wxControl* GetEditorCtrl(void) const
|
||||
{
|
||||
return this->m_editorCtrlPtr;
|
||||
}
|
||||
virtual bool GetValueFromEditorCtrl(wxControl* WXUNUSED(editor), wxVariant& WXUNUSED(value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool HasEditorCtrl(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool StartEditing(unsigned int WXUNUSED(row), wxRect WXUNUSED(labelRect))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// device context handling
|
||||
//
|
||||
virtual wxDC* GetDC(void); // creates a device context and keeps it
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
virtual bool Render(void); // declared in wxDataViewRenderer but will not be used here, therefore calling this function will
|
||||
// return 'false' without having done anything
|
||||
|
||||
virtual DataBrowserPropertyType GetPropertyType(void) const
|
||||
{
|
||||
return kDataBrowserCustomType;
|
||||
}
|
||||
|
||||
void SetDC(wxDC* newDCPtr); // this method takes ownership of the pointer
|
||||
|
||||
protected:
|
||||
private:
|
||||
//
|
||||
// variables
|
||||
//
|
||||
wxControl* m_editorCtrlPtr; // pointer to an in-place editor control
|
||||
|
||||
wxDC* m_DCPtr;
|
||||
|
||||
//
|
||||
// wxWidget internal stuff
|
||||
//
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewTextRenderer
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
|
||||
{
|
||||
public:
|
||||
//
|
||||
// constructors / destructor
|
||||
//
|
||||
wxDataViewTextRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
|
||||
|
||||
//
|
||||
// inherited functions from wxDataViewRenderer
|
||||
//
|
||||
virtual bool Render(void);
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
virtual DataBrowserPropertyType GetPropertyType(void) const
|
||||
{
|
||||
return kDataBrowserTextType;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewBitmapRenderer
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
|
||||
{
|
||||
public:
|
||||
//
|
||||
// constructors / destructor
|
||||
//
|
||||
wxDataViewBitmapRenderer(wxString const& varianttype=wxT("wxBitmap"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
|
||||
|
||||
//
|
||||
// inherited functions from wxDataViewRenderer
|
||||
//
|
||||
virtual bool Render(void);
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
virtual DataBrowserPropertyType GetPropertyType(void) const
|
||||
{
|
||||
return kDataBrowserIconType;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewToggleRenderer
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
|
||||
{
|
||||
public:
|
||||
wxDataViewToggleRenderer(wxString const& varianttype = wxT("bool"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
|
||||
|
||||
//
|
||||
// inherited functions from wxDataViewRenderer
|
||||
//
|
||||
virtual bool Render(void);
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
virtual DataBrowserPropertyType GetPropertyType(void) const
|
||||
{
|
||||
return kDataBrowserCheckboxType;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewProgressRenderer
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
|
||||
{
|
||||
public:
|
||||
wxDataViewProgressRenderer(wxString const& label = wxEmptyString, wxString const& varianttype=wxT("long"),
|
||||
wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
|
||||
|
||||
//
|
||||
// inherited functions from wxDataViewRenderer
|
||||
//
|
||||
virtual bool Render(void);
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
virtual DataBrowserPropertyType GetPropertyType(void) const
|
||||
{
|
||||
return kDataBrowserProgressBarType;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewDateRenderer
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer
|
||||
{
|
||||
public:
|
||||
wxDataViewDateRenderer(wxString const& varianttype=wxT("datetime"), wxDataViewCellMode mode=wxDATAVIEW_CELL_ACTIVATABLE, int align=wxDVR_DEFAULT_ALIGNMENT);
|
||||
|
||||
//
|
||||
// inherited functions from wxDataViewRenderer
|
||||
//
|
||||
virtual bool Render(void);
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
virtual DataBrowserPropertyType GetPropertyType(void) const
|
||||
{
|
||||
return kDataBrowserDateTimeType;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewColumn
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
|
||||
{
|
||||
public:
|
||||
//
|
||||
// constructors / destructor
|
||||
//
|
||||
wxDataViewColumn(wxString const& title, wxDataViewRenderer* renderer, unsigned int model_column, int width=80, wxAlignment align=wxALIGN_CENTER,
|
||||
int flags=wxDATAVIEW_COL_RESIZABLE);
|
||||
wxDataViewColumn(wxBitmap const& bitmap, wxDataViewRenderer* renderer, unsigned int model_column, int width=80, wxAlignment align=wxALIGN_CENTER,
|
||||
int flags=wxDATAVIEW_COL_RESIZABLE);
|
||||
|
||||
//
|
||||
// inherited methods from wxDataViewColumnBase
|
||||
//
|
||||
virtual wxAlignment GetAlignment(void) const
|
||||
{
|
||||
return this->m_alignment;
|
||||
}
|
||||
virtual int GetFlags(void) const
|
||||
{
|
||||
return this->m_flags;
|
||||
}
|
||||
virtual int GetMaxWidth(void) const
|
||||
{
|
||||
return this->m_maxWidth;
|
||||
}
|
||||
virtual int GetMinWidth(void) const
|
||||
{
|
||||
return this->m_minWidth;
|
||||
}
|
||||
virtual wxString GetTitle(void) const
|
||||
{
|
||||
return this->m_title;
|
||||
}
|
||||
virtual int GetWidth(void) const
|
||||
{
|
||||
return this->m_width;
|
||||
}
|
||||
|
||||
virtual bool IsHidden(void) const
|
||||
{
|
||||
return false; // not implemented
|
||||
}
|
||||
virtual bool IsResizeable(void) const
|
||||
{
|
||||
return ((this->m_flags & wxDATAVIEW_COL_RESIZABLE) != 0);
|
||||
}
|
||||
virtual bool IsSortable(void) const
|
||||
{
|
||||
return ((this->m_flags & wxDATAVIEW_COL_SORTABLE) != 0);
|
||||
}
|
||||
virtual bool IsSortOrderAscending(void) const
|
||||
{
|
||||
return this->m_ascending;
|
||||
}
|
||||
|
||||
virtual void SetAlignment(wxAlignment align);
|
||||
virtual void SetBitmap (wxBitmap const& bitmap);
|
||||
virtual void SetFlags (int flags);
|
||||
virtual void SetHidden(bool WXUNUSED(hidden))
|
||||
{
|
||||
}
|
||||
virtual void SetMaxWidth (int maxWidth);
|
||||
virtual void SetMinWidth (int minWidth);
|
||||
virtual void SetResizeable(bool resizeable);
|
||||
virtual void SetSortable (bool sortable);
|
||||
virtual void SetSortOrder (bool ascending);
|
||||
virtual void SetTitle (wxString const& title);
|
||||
virtual void SetWidth (int width);
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
DataBrowserPropertyID GetPropertyID(void) const
|
||||
{
|
||||
return this->m_propertyID;
|
||||
}
|
||||
|
||||
void SetPropertyID(DataBrowserPropertyID newID)
|
||||
{
|
||||
this->m_propertyID = newID;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
//
|
||||
// variables
|
||||
//
|
||||
bool m_ascending; // sorting order
|
||||
|
||||
DataBrowserPropertyID m_propertyID; // each column is identified by its unique property ID (NOT by the column index)
|
||||
|
||||
int m_flags; // flags for the column
|
||||
int m_maxWidth; // maximum width for the column
|
||||
int m_minWidth; // minimum width for the column
|
||||
int m_width; // column width
|
||||
|
||||
wxAlignment m_alignment; // column header alignment
|
||||
|
||||
wxString m_title; // column title
|
||||
|
||||
// wxWidget internal stuff:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewCtrl
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase
|
||||
{
|
||||
public:
|
||||
// Constructors / destructor:
|
||||
wxDataViewCtrl()
|
||||
{
|
||||
this->Init();
|
||||
}
|
||||
wxDataViewCtrl(wxWindow *parent, wxWindowID id, wxPoint const& pos = wxDefaultPosition, wxSize const& size = wxDefaultSize, long style = 0,
|
||||
wxValidator const& validator = wxDefaultValidator)
|
||||
{
|
||||
this->Init();
|
||||
this->Create(parent, id, pos, size, style, validator );
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent, wxWindowID id, wxPoint const& pos=wxDefaultPosition, wxSize const& size=wxDefaultSize, long style=0,
|
||||
wxValidator const& validator=wxDefaultValidator);
|
||||
|
||||
virtual bool AppendColumn(wxDataViewColumn* columnPtr);
|
||||
|
||||
virtual bool AssociateModel(wxDataViewListModel* model);
|
||||
|
||||
virtual void SetSelection( int row ); // -1 for unselect
|
||||
virtual void SetSelectionRange( unsigned int from, unsigned int to );
|
||||
virtual void SetSelections( const wxArrayInt& aSelections);
|
||||
virtual void Unselect( unsigned int row );
|
||||
|
||||
virtual bool IsSelected( unsigned int row ) const;
|
||||
virtual int GetSelection() const;
|
||||
virtual int GetSelections(wxArrayInt& aSelections) const;
|
||||
|
||||
virtual wxControl* GetMainWindow(void) // should disappear as it is not of any use for the native implementation
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
|
||||
// with CG, we need to get the context from an kEventControlDraw event
|
||||
// unfortunately, the DataBrowser callbacks don't provide the context
|
||||
// and we need it, so we need to set/remove it before and after draw
|
||||
// events so we can access it in the callbacks.
|
||||
void MacSetDrawingContext(void* context)
|
||||
{
|
||||
this->m_cgContext = context;
|
||||
}
|
||||
void* MacGetDrawingContext(void) const
|
||||
{
|
||||
return this->m_cgContext;
|
||||
}
|
||||
|
||||
// reverts the sorting order of the hash map if wxDataViewColumn data and control data do not match;
|
||||
// wxDataViewColumn data will NOT be updated
|
||||
void ReverseSorting(DataBrowserPropertyID columnID);
|
||||
|
||||
protected:
|
||||
// event handling:
|
||||
void OnSize(wxSizeEvent &event);
|
||||
|
||||
private:
|
||||
// initializing of local variables:
|
||||
void Init(void);
|
||||
|
||||
///
|
||||
// variables
|
||||
//
|
||||
|
||||
wxDataViewListModelNotifier* m_NotifierPtr; // the notifier is NOT owned by this class but by the associated model
|
||||
|
||||
void* m_cgContext; // pointer to core graphics context
|
||||
|
||||
// wxWidget internal stuff:
|
||||
DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
|
||||
DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
#endif // __MACDATAVIEWCTRL_H__
|
5
include/wx/mac/dataview.h
Normal file
5
include/wx/mac/dataview.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#ifdef __WXMAC_CLASSIC__
|
||||
# error "Native wxDataViewCtrl for classis environment not defined. Please use generic control."
|
||||
#else
|
||||
# include "wx/mac/carbon/dataview.h"
|
||||
#endif
|
Reference in New Issue
Block a user