No changes, just attempts to make the code more readable.
Reformat/reindent, use more wx coding style, wrap some extremely long lines. Use shorter and less Carbon-ish variable names. Clarify some comments. Also use static_cast<> because there is no need to use reinterpret_cast<> when a static_cast<> will do. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62435 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -12,11 +12,7 @@
|
|||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#ifdef __OBJC__
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/osx/core/dataview.h"
|
#include "wx/osx/core/dataview.h"
|
||||||
#include "wx/osx/private.h"
|
#include "wx/osx/private.h"
|
||||||
@@ -24,231 +20,217 @@
|
|||||||
// Forward declaration
|
// Forward declaration
|
||||||
class wxCocoaDataViewControl;
|
class wxCocoaDataViewControl;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Dramatis personae:
|
||||||
|
|
||||||
|
[vertical arrows indicate inheritance, horizontal -- aggregation]
|
||||||
|
|
||||||
|
|
||||||
|
wxWindow ---> wxWidgetCocoaImpl wxDataViewWidgetImpl NSOutlineView
|
||||||
|
| \ / |
|
||||||
|
| \ / |
|
||||||
|
| \ / |
|
||||||
|
v \/ \/ v
|
||||||
|
wxDataViewCtrl -------> wxCocoaDataViewControl <-------> wxCocoaOutlineView
|
||||||
|
|
||||||
|
|
||||||
|
The right most classes are Objective-C only and can't be used from (pure)
|
||||||
|
C++ code.
|
||||||
|
*/
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxPointerObject
|
// wxPointerObject: simply stores a pointer, without taking its ownership
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
//
|
|
||||||
// This is a helper class to store a pointer in an object. This object just
|
// Two pointer objects are equal if the containing pointers are equal. This
|
||||||
// stores the pointer but does not take any ownership.
|
|
||||||
// To pointer objects are equal if the containing pointers are equal. This
|
|
||||||
// means also that the hash value of a pointer object depends only on the
|
// means also that the hash value of a pointer object depends only on the
|
||||||
// stored pointer.
|
// stored pointer.
|
||||||
//
|
|
||||||
@interface wxPointerObject : NSObject
|
@interface wxPointerObject : NSObject
|
||||||
{
|
{
|
||||||
void* pointer;
|
void* pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
-(id) initWithPointer:(void*)initPointer;
|
||||||
// object initialization
|
|
||||||
//
|
|
||||||
-(id) initWithPointer:(void*)initPointer;
|
|
||||||
|
|
||||||
//
|
|
||||||
// access to pointer
|
|
||||||
//
|
|
||||||
-(void*) pointer;
|
|
||||||
-(void) setPointer:(void*)newPointer;
|
|
||||||
|
|
||||||
|
-(void*) pointer;
|
||||||
|
-(void) setPointer:(void*)newPointer;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxSortDescriptorObject
|
// wxSortDescriptorObject: helper class to use native sorting facilities
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
//
|
|
||||||
// This is a helper class to use native sorting facilities.
|
|
||||||
//
|
|
||||||
@interface wxSortDescriptorObject : NSSortDescriptor<NSCopying>
|
@interface wxSortDescriptorObject : NSSortDescriptor<NSCopying>
|
||||||
{
|
{
|
||||||
wxDataViewColumn* columnPtr; // pointer to the sorting column
|
wxDataViewColumn* columnPtr; // pointer to the sorting column
|
||||||
|
|
||||||
wxDataViewModel* modelPtr; // pointer to model
|
wxDataViewModel* modelPtr; // pointer to model
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
-(id)
|
||||||
// initialization
|
initWithModelPtr:(wxDataViewModel*)initModelPtr
|
||||||
//
|
sortingColumnPtr:(wxDataViewColumn*)initColumnPtr
|
||||||
-(id) initWithModelPtr:(wxDataViewModel*)initModelPtr sortingColumnPtr:(wxDataViewColumn*)initColumnPtr ascending:(BOOL)sortAscending;
|
ascending:(BOOL)sortAscending;
|
||||||
|
|
||||||
//
|
-(wxDataViewColumn*) columnPtr;
|
||||||
// access to variables
|
-(wxDataViewModel*) modelPtr;
|
||||||
//
|
|
||||||
-(wxDataViewColumn*) columnPtr;
|
|
||||||
-(wxDataViewModel*) modelPtr;
|
|
||||||
|
|
||||||
-(void) setColumnPtr:(wxDataViewColumn*)newColumnPtr;
|
|
||||||
-(void) setModelPtr:(wxDataViewModel*)newModelPtr;
|
|
||||||
|
|
||||||
|
-(void) setColumnPtr:(wxDataViewColumn*)newColumnPtr;
|
||||||
|
-(void) setModelPtr:(wxDataViewModel*)newModelPtr;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxDataViewColumnNativeData
|
// wxDataViewColumnNativeData: extra data for wxDataViewColumn
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
class wxDataViewColumnNativeData
|
class wxDataViewColumnNativeData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//
|
wxDataViewColumnNativeData() : m_NativeColumnPtr(NULL)
|
||||||
// constructors / destructor
|
{
|
||||||
//
|
}
|
||||||
wxDataViewColumnNativeData(void) : m_NativeColumnPtr(NULL)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
wxDataViewColumnNativeData(NSTableColumn* initNativeColumnPtr) : m_NativeColumnPtr(initNativeColumnPtr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
wxDataViewColumnNativeData(NSTableColumn* initNativeColumnPtr)
|
||||||
// data access methods
|
: m_NativeColumnPtr(initNativeColumnPtr)
|
||||||
//
|
{
|
||||||
NSTableColumn* GetNativeColumnPtr() const
|
}
|
||||||
{
|
|
||||||
return m_NativeColumnPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetNativeColumnPtr(NSTableColumn* newNativeColumnPtr)
|
NSTableColumn* GetNativeColumnPtr() const
|
||||||
{
|
{
|
||||||
m_NativeColumnPtr = newNativeColumnPtr;
|
return m_NativeColumnPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetNativeColumnPtr(NSTableColumn* newNativeColumnPtr)
|
||||||
|
{
|
||||||
|
m_NativeColumnPtr = newNativeColumnPtr;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
|
||||||
private:
|
private:
|
||||||
//
|
// not owned by us
|
||||||
// variables
|
NSTableColumn* m_NativeColumnPtr;
|
||||||
//
|
|
||||||
NSTableColumn* m_NativeColumnPtr; // this class does not take over ownership of the pointer nor retains it
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxDataViewRendererNativeData
|
// wxDataViewRendererNativeData: extra data for wxDataViewRenderer
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
class wxDataViewRendererNativeData
|
class wxDataViewRendererNativeData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//
|
wxDataViewRendererNativeData()
|
||||||
// constructors / destructor
|
: m_Object(NULL), m_ColumnCell(NULL)
|
||||||
//
|
{
|
||||||
wxDataViewRendererNativeData(void) : m_Object(NULL), m_ColumnCell(NULL)
|
Init();
|
||||||
{
|
}
|
||||||
Init();
|
|
||||||
}
|
|
||||||
wxDataViewRendererNativeData(NSCell* initColumnCell) : m_Object(NULL), m_ColumnCell([initColumnCell retain])
|
|
||||||
{
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
wxDataViewRendererNativeData(NSCell* initColumnCell, id initObject) : m_Object([initObject retain]), m_ColumnCell([initColumnCell retain])
|
|
||||||
{
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
~wxDataViewRendererNativeData()
|
wxDataViewRendererNativeData(NSCell* initColumnCell)
|
||||||
{
|
: m_Object(NULL), m_ColumnCell([initColumnCell retain])
|
||||||
[m_ColumnCell release];
|
{
|
||||||
[m_Object release];
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
[m_origFont release];
|
wxDataViewRendererNativeData(NSCell* initColumnCell, id initObject)
|
||||||
[m_origTextColour release];
|
: m_Object([initObject retain]), m_ColumnCell([initColumnCell retain])
|
||||||
}
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
~wxDataViewRendererNativeData()
|
||||||
// data access methods
|
{
|
||||||
//
|
[m_ColumnCell release];
|
||||||
NSCell* GetColumnCell() const
|
[m_Object release];
|
||||||
{
|
|
||||||
return m_ColumnCell;
|
|
||||||
}
|
|
||||||
NSTableColumn* GetColumnPtr() const
|
|
||||||
{
|
|
||||||
return m_TableColumnPtr;
|
|
||||||
}
|
|
||||||
id GetItem() const
|
|
||||||
{
|
|
||||||
return m_Item;
|
|
||||||
}
|
|
||||||
NSCell* GetItemCell() const
|
|
||||||
{
|
|
||||||
return m_ItemCell;
|
|
||||||
}
|
|
||||||
id GetObject() const
|
|
||||||
{
|
|
||||||
return m_Object;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetColumnCell(NSCell* newCell)
|
[m_origFont release];
|
||||||
{
|
[m_origTextColour release];
|
||||||
[newCell retain];
|
}
|
||||||
[m_ColumnCell release];
|
|
||||||
m_ColumnCell = newCell;
|
|
||||||
}
|
|
||||||
void SetColumnPtr(NSTableColumn* newColumnPtr)
|
|
||||||
{
|
|
||||||
m_TableColumnPtr = newColumnPtr;
|
|
||||||
}
|
|
||||||
void SetItem(id newItem)
|
|
||||||
{
|
|
||||||
m_Item = newItem;
|
|
||||||
}
|
|
||||||
void SetItemCell(NSCell* newCell)
|
|
||||||
{
|
|
||||||
m_ItemCell = newCell;
|
|
||||||
}
|
|
||||||
void SetObject(id newObject)
|
|
||||||
{
|
|
||||||
[newObject retain];
|
|
||||||
[m_Object release];
|
|
||||||
m_Object = newObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The original cell font and text colour stored here are NULL by default and
|
NSCell* GetColumnCell() const { return m_ColumnCell; }
|
||||||
// are only initialized to the values retrieved from the cell when we change
|
NSTableColumn* GetColumnPtr() const { return m_TableColumnPtr; }
|
||||||
// them from wxCocoaOutlineView:willDisplayCell:forTableColumn:item: which
|
id GetItem() const { return m_Item; }
|
||||||
// calls our SaveOriginalXXX() methods before changing the cell attributes.
|
NSCell* GetItemCell() const { return m_ItemCell; }
|
||||||
//
|
id GetObject() const { return m_Object; }
|
||||||
// This allows us to avoid doing anything for the columns without any
|
|
||||||
// attributes but still be able to restore the correct attributes for the
|
|
||||||
// ones that do.
|
|
||||||
NSFont *GetOriginalFont() const { return m_origFont; }
|
|
||||||
NSColor *GetOriginalTextColour() const { return m_origTextColour; }
|
|
||||||
|
|
||||||
void SaveOriginalFont(NSFont *font)
|
void SetColumnCell(NSCell* newCell)
|
||||||
{
|
{
|
||||||
m_origFont = [font retain];
|
[newCell retain];
|
||||||
}
|
[m_ColumnCell release];
|
||||||
|
m_ColumnCell = newCell;
|
||||||
|
}
|
||||||
|
void SetColumnPtr(NSTableColumn* newColumnPtr)
|
||||||
|
{
|
||||||
|
m_TableColumnPtr = newColumnPtr;
|
||||||
|
}
|
||||||
|
void SetItem(id newItem)
|
||||||
|
{
|
||||||
|
m_Item = newItem;
|
||||||
|
}
|
||||||
|
void SetItemCell(NSCell* newCell)
|
||||||
|
{
|
||||||
|
m_ItemCell = newCell;
|
||||||
|
}
|
||||||
|
void SetObject(id newObject)
|
||||||
|
{
|
||||||
|
[newObject retain];
|
||||||
|
[m_Object release];
|
||||||
|
m_Object = newObject;
|
||||||
|
}
|
||||||
|
|
||||||
void SaveOriginalTextColour(NSColor *textColour)
|
// The original cell font and text colour stored here are NULL by default
|
||||||
{
|
// and are only initialized to the values retrieved from the cell when we
|
||||||
m_origTextColour = [textColour retain];
|
// change them from wxCocoaOutlineView:willDisplayCell:forTableColumn:item:
|
||||||
}
|
// which calls our SaveOriginalXXX() methods before changing the cell
|
||||||
|
// attributes.
|
||||||
|
//
|
||||||
|
// This allows us to avoid doing anything for the columns without any
|
||||||
|
// attributes but still be able to restore the correct attributes for the
|
||||||
|
// ones that do.
|
||||||
|
NSFont *GetOriginalFont() const { return m_origFont; }
|
||||||
|
NSColor *GetOriginalTextColour() const { return m_origTextColour; }
|
||||||
|
|
||||||
// The ellipsization mode which we need to set for each cell being rendered.
|
void SaveOriginalFont(NSFont *font)
|
||||||
void SetEllipsizeMode(wxEllipsizeMode mode) { m_ellipsizeMode = mode; }
|
{
|
||||||
wxEllipsizeMode GetEllipsizeMode() const { return m_ellipsizeMode; }
|
m_origFont = [font retain];
|
||||||
|
}
|
||||||
|
|
||||||
// Set the line break mode for the given cell using our m_ellipsizeMode
|
void SaveOriginalTextColour(NSColor *textColour)
|
||||||
void ApplyLineBreakMode(NSCell *cell);
|
{
|
||||||
|
m_origTextColour = [textColour retain];
|
||||||
|
}
|
||||||
|
|
||||||
|
// The ellipsization mode which we need to set for each cell being rendered.
|
||||||
|
void SetEllipsizeMode(wxEllipsizeMode mode) { m_ellipsizeMode = mode; }
|
||||||
|
wxEllipsizeMode GetEllipsizeMode() const { return m_ellipsizeMode; }
|
||||||
|
|
||||||
|
// Set the line break mode for the given cell using our m_ellipsizeMode
|
||||||
|
void ApplyLineBreakMode(NSCell *cell);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
id m_Item; // item NOT owned by renderer
|
id m_Item; // item NOT owned by renderer
|
||||||
id m_Object; // object that can be used by renderer for storing special data (owned by renderer)
|
|
||||||
|
|
||||||
NSCell* m_ColumnCell; // column's cell is owned by renderer
|
// object that can be used by renderer for storing special data (owned by
|
||||||
NSCell* m_ItemCell; // item's cell is NOT owned by renderer
|
// renderer)
|
||||||
|
id m_Object;
|
||||||
|
|
||||||
NSTableColumn* m_TableColumnPtr; // column NOT owned by renderer
|
NSCell* m_ColumnCell; // column's cell is owned by renderer
|
||||||
|
NSCell* m_ItemCell; // item's cell is NOT owned by renderer
|
||||||
|
|
||||||
// we own those if they're non-NULL
|
NSTableColumn* m_TableColumnPtr; // column NOT owned by renderer
|
||||||
NSFont *m_origFont;
|
|
||||||
NSColor *m_origTextColour;
|
|
||||||
|
|
||||||
wxEllipsizeMode m_ellipsizeMode;
|
// we own those if they're non-NULL
|
||||||
|
NSFont *m_origFont;
|
||||||
|
NSColor *m_origTextColour;
|
||||||
|
|
||||||
|
wxEllipsizeMode m_ellipsizeMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxCocoaOutlineDataSource
|
// wxCocoaOutlineDataSource
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
//
|
|
||||||
// This class implements the data source delegate for the outline view.
|
// This class implements the data source delegate for the outline view.
|
||||||
// As only an informal protocol exists this class inherits from NSObject only.
|
// As only an informal protocol exists this class inherits from NSObject only.
|
||||||
//
|
//
|
||||||
@@ -270,92 +252,105 @@ private:
|
|||||||
//
|
//
|
||||||
@interface wxCocoaOutlineDataSource : NSObject
|
@interface wxCocoaOutlineDataSource : NSObject
|
||||||
{
|
{
|
||||||
NSArray* sortDescriptors; // descriptors specifying the sorting (currently the array only holds one object only)
|
// descriptors specifying the sorting (currently the array only holds one
|
||||||
|
// object only)
|
||||||
|
NSArray* sortDescriptors;
|
||||||
|
|
||||||
NSMutableArray* children; // buffered children
|
NSMutableArray* children; // buffered children
|
||||||
|
|
||||||
NSMutableSet* items; // stores all items that are in use by the control
|
NSMutableSet* items; // stores all items that are in use by the control
|
||||||
|
|
||||||
wxCocoaDataViewControl* implementation;
|
wxCocoaDataViewControl* implementation;
|
||||||
|
|
||||||
wxDataViewModel* model;
|
wxDataViewModel* model;
|
||||||
|
|
||||||
wxPointerObject* currentParentItem; // parent of the buffered children; the object is owned
|
// parent of the buffered children; the object is owned
|
||||||
|
wxPointerObject* currentParentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// methods of informal protocol:
|
||||||
// methods of informal protocol:
|
-(BOOL)
|
||||||
//
|
outlineView:(NSOutlineView*)outlineView
|
||||||
-(BOOL) outlineView:(NSOutlineView*)outlineView acceptDrop:(id<NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index;
|
acceptDrop:(id<NSDraggingInfo>)info
|
||||||
-(id) outlineView:(NSOutlineView*)outlineView child:(NSInteger)index ofItem:(id)item;
|
item:(id)item
|
||||||
-(id) outlineView:(NSOutlineView*)outlineView objectValueForTableColumn:(NSTableColumn*)tableColumn byItem:(id)item;
|
childIndex:(NSInteger)index;
|
||||||
-(BOOL) outlineView:(NSOutlineView*)outlineView isItemExpandable:(id)item;
|
|
||||||
-(NSInteger) outlineView:(NSOutlineView*)outlineView numberOfChildrenOfItem:(id)item;
|
|
||||||
-(NSDragOperation) outlineView:(NSOutlineView*)outlineView validateDrop:(id<NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index;
|
|
||||||
-(BOOL) outlineView:(NSOutlineView*)outlineView writeItems:(NSArray*)items toPasteboard:(NSPasteboard*)pasteboard;
|
|
||||||
|
|
||||||
//
|
-(id)
|
||||||
// buffer for items handling
|
outlineView:(NSOutlineView*)outlineView
|
||||||
//
|
child:(NSInteger)index
|
||||||
-(void) addToBuffer:(wxPointerObject*)item;
|
ofItem:(id)item;
|
||||||
-(void) clearBuffer;
|
|
||||||
-(wxPointerObject*) getDataViewItemFromBuffer:(wxDataViewItem const&)item; // returns the item in the buffer that has got the same pointer as "item",
|
|
||||||
-(wxPointerObject*) getItemFromBuffer:(wxPointerObject*)item; // if such an item does not exist nil is returned
|
|
||||||
-(BOOL) isInBuffer:(wxPointerObject*)item;
|
|
||||||
-(void) removeFromBuffer:(wxPointerObject*)item;
|
|
||||||
|
|
||||||
//
|
-(id)
|
||||||
// buffered children handling
|
outlineView:(NSOutlineView*)outlineView
|
||||||
//
|
objectValueForTableColumn:(NSTableColumn*)tableColumn
|
||||||
-(void) appendChild:(wxPointerObject*)item;
|
byItem:(id)item;
|
||||||
-(void) clearChildren;
|
|
||||||
-(wxPointerObject*) getChild:(NSUInteger)index;
|
|
||||||
-(NSUInteger) getChildCount;
|
|
||||||
-(void) removeChild:(NSUInteger)index;
|
|
||||||
|
|
||||||
//
|
-(BOOL)
|
||||||
// buffer handling
|
outlineView:(NSOutlineView*)outlineView
|
||||||
//
|
isItemExpandable:(id)item;
|
||||||
-(void) clearBuffers;
|
|
||||||
|
|
||||||
//
|
-(NSInteger)
|
||||||
// sorting
|
outlineView:(NSOutlineView*)outlineView
|
||||||
//
|
numberOfChildrenOfItem:(id)item;
|
||||||
-(NSArray*) sortDescriptors;
|
|
||||||
-(void) setSortDescriptors:(NSArray*)newSortDescriptors;
|
|
||||||
|
|
||||||
//
|
-(NSDragOperation)
|
||||||
// access to wxWidget's variables
|
outlineView:(NSOutlineView*)outlineView
|
||||||
//
|
validateDrop:(id<NSDraggingInfo>)info
|
||||||
-(wxPointerObject*) currentParentItem;
|
proposedItem:(id)item
|
||||||
-(wxCocoaDataViewControl*) implementation;
|
proposedChildIndex:(NSInteger)index;
|
||||||
-(wxDataViewModel*) model;
|
|
||||||
-(void) setCurrentParentItem:(wxPointerObject*)newCurrentParentItem;
|
|
||||||
-(void) setImplementation:(wxCocoaDataViewControl*)newImplementation;
|
|
||||||
-(void) setModel:(wxDataViewModel*)newModel;
|
|
||||||
|
|
||||||
//
|
-(BOOL)
|
||||||
// other methods
|
outlineView:(NSOutlineView*)outlineView
|
||||||
//
|
writeItems:(NSArray*)items
|
||||||
-(void) bufferItem:(wxPointerObject*)parentItem withChildren:(wxDataViewItemArray*)dataViewChildrenPtr;
|
toPasteboard:(NSPasteboard*)pasteboard;
|
||||||
|
|
||||||
|
// buffer for items handling
|
||||||
|
-(void) addToBuffer:(wxPointerObject*)item;
|
||||||
|
-(void) clearBuffer;
|
||||||
|
// returns the item in the buffer that has got the same pointer as "item",
|
||||||
|
// if such an item does not exist nil is returned
|
||||||
|
-(wxPointerObject*) getDataViewItemFromBuffer:(const wxDataViewItem&)item;
|
||||||
|
-(wxPointerObject*) getItemFromBuffer:(wxPointerObject*)item;
|
||||||
|
-(BOOL) isInBuffer:(wxPointerObject*)item;
|
||||||
|
-(void) removeFromBuffer:(wxPointerObject*)item;
|
||||||
|
|
||||||
|
// buffered children handling
|
||||||
|
-(void) appendChild:(wxPointerObject*)item;
|
||||||
|
-(void) clearChildren;
|
||||||
|
-(wxPointerObject*) getChild:(NSUInteger)index;
|
||||||
|
-(NSUInteger) getChildCount;
|
||||||
|
-(void) removeChild:(NSUInteger)index;
|
||||||
|
|
||||||
|
// buffer handling
|
||||||
|
-(void) clearBuffers;
|
||||||
|
|
||||||
|
// sorting
|
||||||
|
-(NSArray*) sortDescriptors;
|
||||||
|
-(void) setSortDescriptors:(NSArray*)newSortDescriptors;
|
||||||
|
|
||||||
|
// access to wxWidgets variables
|
||||||
|
-(wxPointerObject*) currentParentItem;
|
||||||
|
-(wxCocoaDataViewControl*) implementation;
|
||||||
|
-(wxDataViewModel*) model;
|
||||||
|
-(void) setCurrentParentItem:(wxPointerObject*)newCurrentParentItem;
|
||||||
|
-(void) setImplementation:(wxCocoaDataViewControl*)newImplementation;
|
||||||
|
-(void) setModel:(wxDataViewModel*)newModel;
|
||||||
|
|
||||||
|
// other methods
|
||||||
|
-(void)
|
||||||
|
bufferItem:(wxPointerObject*)parentItem
|
||||||
|
withChildren:(wxDataViewItemArray*)dataViewChildrenPtr;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxCustomCell
|
// wxCustomCell: used for custom renderers
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
//
|
|
||||||
// This is a cell that is used for custom renderers.
|
|
||||||
//
|
|
||||||
@interface wxCustomCell : NSTextFieldCell
|
@interface wxCustomCell : NSTextFieldCell
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
-(NSSize) cellSize;
|
||||||
// other methods
|
|
||||||
//
|
|
||||||
-(NSSize) cellSize;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -376,161 +371,137 @@ private:
|
|||||||
@interface wxImageTextCell : NSTextFieldCell
|
@interface wxImageTextCell : NSTextFieldCell
|
||||||
{
|
{
|
||||||
@private
|
@private
|
||||||
CGFloat xImageShift; // shift for the image in x-direction from border
|
CGFloat xImageShift; // shift for the image in x-direction from border
|
||||||
CGFloat spaceImageText; // space between image and text ("belongs" to the image)
|
CGFloat spaceImageText; // space between image and text
|
||||||
|
|
||||||
NSImage* image; // the image itself
|
NSImage* image; // the image itself
|
||||||
|
|
||||||
NSSize imageSize; // largest size of the image; default size is (16, 16)
|
NSSize imageSize; // largest size of the image; default size is (16, 16)
|
||||||
|
|
||||||
NSTextAlignment cellAlignment; // the text alignment is used to align the whole
|
// the text alignment is used to align the whole cell (image and text)
|
||||||
// cell (image and text)
|
NSTextAlignment cellAlignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
-(NSTextAlignment) alignment;
|
||||||
// alignment
|
-(void) setAlignment:(NSTextAlignment)newAlignment;
|
||||||
//
|
|
||||||
-(NSTextAlignment) alignment;
|
|
||||||
-(void) setAlignment:(NSTextAlignment)newAlignment;
|
|
||||||
|
|
||||||
//
|
-(NSImage*) image;
|
||||||
// image access
|
-(void) setImage:(NSImage*)newImage;
|
||||||
//
|
|
||||||
-(NSImage*) image;
|
|
||||||
-(void) setImage:(NSImage*)newImage;
|
|
||||||
|
|
||||||
//
|
-(NSSize) imageSize;
|
||||||
// size access
|
-(void) setImageSize:(NSSize) newImageSize;
|
||||||
//
|
|
||||||
-(NSSize) imageSize;
|
|
||||||
-(void) setImageSize:(NSSize) newImageSize;
|
|
||||||
|
|
||||||
//
|
|
||||||
// other methods
|
|
||||||
//
|
|
||||||
-(NSSize) cellSize;
|
|
||||||
|
|
||||||
|
-(NSSize) cellSize;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxCocoaOutlineView
|
// wxCocoaOutlineView
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
@interface wxCocoaOutlineView : NSOutlineView
|
@interface wxCocoaOutlineView : NSOutlineView
|
||||||
{
|
{
|
||||||
@private
|
@private
|
||||||
// column and row of the cell being edited or -1 if none
|
// column and row of the cell being edited or -1 if none
|
||||||
int currentlyEditedColumn,
|
int currentlyEditedColumn,
|
||||||
currentlyEditedRow;
|
currentlyEditedRow;
|
||||||
|
|
||||||
wxCocoaDataViewControl* implementation;
|
wxCocoaDataViewControl* implementation;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
-(wxCocoaDataViewControl*) implementation;
|
||||||
// access to wxWidget's implementation
|
-(void) setImplementation:(wxCocoaDataViewControl*) newImplementation;
|
||||||
//
|
|
||||||
-(wxCocoaDataViewControl*) implementation;
|
|
||||||
-(void) setImplementation:(wxCocoaDataViewControl*) newImplementation;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxCocoaDataViewControl
|
// wxCocoaDataViewControl
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
//
|
|
||||||
// This is the internal interface class between wxDataViewCtrl (wxWidget) and
|
// This is the internal interface class between wxDataViewCtrl (wxWidget) and
|
||||||
// the native source view (Mac OS X cocoa).
|
// the native source view (Mac OS X cocoa).
|
||||||
//
|
class wxCocoaDataViewControl : public wxWidgetCocoaImpl,
|
||||||
class wxCocoaDataViewControl : public wxWidgetCocoaImpl, public wxDataViewWidgetImpl
|
public wxDataViewWidgetImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//
|
// constructors / destructor
|
||||||
// constructors / destructor
|
wxCocoaDataViewControl(wxWindow* peer,
|
||||||
//
|
const wxPoint& pos,
|
||||||
wxCocoaDataViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style);
|
const wxSize& size,
|
||||||
~wxCocoaDataViewControl();
|
long style);
|
||||||
|
virtual ~wxCocoaDataViewControl();
|
||||||
|
|
||||||
//
|
wxDataViewCtrl* GetDataViewCtrl() const
|
||||||
// column related methods (inherited from wxDataViewWidgetImpl)
|
{
|
||||||
//
|
return static_cast<wxDataViewCtrl*>(GetWXPeer());
|
||||||
virtual bool ClearColumns ();
|
}
|
||||||
virtual bool DeleteColumn (wxDataViewColumn* columnPtr);
|
|
||||||
virtual void DoSetExpanderColumn(wxDataViewColumn const* columnPtr);
|
|
||||||
virtual wxDataViewColumn* GetColumn (unsigned int pos) const;
|
|
||||||
virtual int GetColumnPosition (wxDataViewColumn const* columnPtr) const;
|
|
||||||
virtual bool InsertColumn (unsigned int pos, wxDataViewColumn* columnPtr);
|
|
||||||
|
|
||||||
//
|
// column related methods (inherited from wxDataViewWidgetImpl)
|
||||||
// item related methods (inherited from wxDataViewWidgetImpl)
|
virtual bool ClearColumns();
|
||||||
//
|
virtual bool DeleteColumn(wxDataViewColumn* columnPtr);
|
||||||
virtual bool Add (wxDataViewItem const& parent, wxDataViewItem const& item);
|
virtual void DoSetExpanderColumn(wxDataViewColumn const* columnPtr);
|
||||||
virtual bool Add (wxDataViewItem const& parent, wxDataViewItemArray const& items);
|
virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
|
||||||
virtual void Collapse (wxDataViewItem const& item);
|
virtual int GetColumnPosition(wxDataViewColumn const* columnPtr) const;
|
||||||
virtual void EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr);
|
virtual bool InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr);
|
||||||
virtual void Expand (wxDataViewItem const& item);
|
|
||||||
virtual unsigned int GetCount () const;
|
|
||||||
virtual wxRect GetRectangle (wxDataViewItem const& item, wxDataViewColumn const* columnPtr);
|
|
||||||
virtual bool IsExpanded (wxDataViewItem const& item) const;
|
|
||||||
virtual bool Reload ();
|
|
||||||
virtual bool Remove (wxDataViewItem const& parent, wxDataViewItem const& item);
|
|
||||||
virtual bool Remove (wxDataViewItem const& parent, wxDataViewItemArray const& item);
|
|
||||||
virtual bool Update (wxDataViewColumn const* columnPtr);
|
|
||||||
virtual bool Update (wxDataViewItem const& parent, wxDataViewItem const& item);
|
|
||||||
virtual bool Update (wxDataViewItem const& parent, wxDataViewItemArray const& items);
|
|
||||||
|
|
||||||
//
|
// item related methods (inherited from wxDataViewWidgetImpl)
|
||||||
// model related methods
|
virtual bool Add(const wxDataViewItem& parent, const wxDataViewItem& item);
|
||||||
//
|
virtual bool Add(const wxDataViewItem& parent,
|
||||||
virtual bool AssociateModel(wxDataViewModel* model); // informs the native control that a model is present
|
const wxDataViewItemArray& items);
|
||||||
|
virtual void Collapse(const wxDataViewItem& item);
|
||||||
|
virtual void EnsureVisible(const wxDataViewItem& item,
|
||||||
|
wxDataViewColumn const* columnPtr);
|
||||||
|
virtual void Expand(const wxDataViewItem& item);
|
||||||
|
virtual unsigned int GetCount() const;
|
||||||
|
virtual wxRect GetRectangle(const wxDataViewItem& item,
|
||||||
|
wxDataViewColumn const* columnPtr);
|
||||||
|
virtual bool IsExpanded(const wxDataViewItem& item) const;
|
||||||
|
virtual bool Reload();
|
||||||
|
virtual bool Remove(const wxDataViewItem& parent,
|
||||||
|
const wxDataViewItem& item);
|
||||||
|
virtual bool Remove(const wxDataViewItem& parent,
|
||||||
|
const wxDataViewItemArray& item);
|
||||||
|
virtual bool Update(const wxDataViewColumn* columnPtr);
|
||||||
|
virtual bool Update(const wxDataViewItem& parent,
|
||||||
|
const wxDataViewItem& item);
|
||||||
|
virtual bool Update(const wxDataViewItem& parent,
|
||||||
|
const wxDataViewItemArray& items);
|
||||||
|
|
||||||
//
|
// model related methods
|
||||||
// selection related methods (inherited from wxDataViewWidgetImpl)
|
virtual bool AssociateModel(wxDataViewModel* model);
|
||||||
//
|
|
||||||
virtual int GetSelections(wxDataViewItemArray& sel) const;
|
|
||||||
virtual bool IsSelected (wxDataViewItem const& item) const;
|
|
||||||
virtual void Select (wxDataViewItem const& item);
|
|
||||||
virtual void SelectAll ();
|
|
||||||
virtual void Unselect (wxDataViewItem const& item);
|
|
||||||
virtual void UnselectAll ();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// sorting related methods
|
// selection related methods (inherited from wxDataViewWidgetImpl)
|
||||||
//
|
//
|
||||||
virtual wxDataViewColumn* GetSortingColumn () const;
|
virtual int GetSelections(wxDataViewItemArray& sel) const;
|
||||||
virtual void Resort ();
|
virtual bool IsSelected(const wxDataViewItem& item) const;
|
||||||
|
virtual void Select(const wxDataViewItem& item);
|
||||||
|
virtual void SelectAll();
|
||||||
|
virtual void Unselect(const wxDataViewItem& item);
|
||||||
|
virtual void UnselectAll();
|
||||||
|
|
||||||
//
|
//
|
||||||
// other methods (inherited from wxDataViewWidgetImpl)
|
// sorting related methods
|
||||||
//
|
//
|
||||||
virtual void DoSetIndent (int indent);
|
virtual wxDataViewColumn* GetSortingColumn () const;
|
||||||
virtual void HitTest (wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const;
|
virtual void Resort();
|
||||||
virtual void SetRowHeight(wxDataViewItem const& item, unsigned int height);
|
|
||||||
virtual void OnSize ();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// other methods
|
// other methods (inherited from wxDataViewWidgetImpl)
|
||||||
//
|
//
|
||||||
wxDataViewCtrl* GetDataViewCtrl() const
|
virtual void DoSetIndent(int indent);
|
||||||
{
|
virtual void HitTest(const wxPoint& point,
|
||||||
return dynamic_cast<wxDataViewCtrl*>(GetWXPeer());
|
wxDataViewItem& item,
|
||||||
}
|
wxDataViewColumn*& columnPtr) const;
|
||||||
|
virtual void SetRowHeight(const wxDataViewItem& item, unsigned int height);
|
||||||
|
virtual void OnSize();
|
||||||
|
|
||||||
|
// drag & drop helper methods
|
||||||
|
wxDataFormat GetDnDDataFormat(wxDataObjectComposite* dataObjects);
|
||||||
|
wxDataObjectComposite* GetDnDDataObjects(NSData* dataObject) const;
|
||||||
|
|
||||||
//
|
|
||||||
// drag & drop helper methods
|
|
||||||
//
|
|
||||||
wxDataFormat GetDnDDataFormat(wxDataObjectComposite* dataObjects);
|
|
||||||
wxDataObjectComposite* GetDnDDataObjects(NSData* dataObject) const; // create the data objects from the native dragged object
|
|
||||||
protected:
|
|
||||||
private:
|
private:
|
||||||
//
|
wxCocoaOutlineDataSource* m_DataSource;
|
||||||
// variables
|
|
||||||
//
|
|
||||||
wxCocoaOutlineDataSource* m_DataSource;
|
|
||||||
|
|
||||||
wxCocoaOutlineView* m_OutlineView;
|
wxCocoaOutlineView* m_OutlineView;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef wxCocoaDataViewControl* wxCocoaDataViewControlPointer;
|
|
||||||
|
|
||||||
|
|
||||||
#endif // wxUSE_GUI
|
|
||||||
#endif // _WX_DATAVIEWCTRL_COCOOA_H_
|
#endif // _WX_DATAVIEWCTRL_COCOOA_H_
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user