#include "wx/osx/cocoa/dataview.h"
#include "wx/renderer.h"
#include "wx/stopwatch.h"
+#include "wx/dcgraph.h"
// ============================================================================
// Constants used locally
[nativeColumn setMinWidth:column->GetMinWidth()];
[nativeColumn setMaxWidth:column->GetMaxWidth()];
}
- else // column is not resizeable [by user]
+ else // column is not resizable [by user]
{
// if the control doesn't show a header, make the columns resize
// automatically, this is particularly important for the single column
acceptDrop:(id<NSDraggingInfo>)info
item:(id)item childIndex:(NSInteger)index
{
+ wxUnusedVar(outlineView);
+ wxUnusedVar(index);
+
NSArray* supportedTypes(
[NSArray arrayWithObjects:DataViewPboardType,NSStringPboardType,nil]
);
event.SetItem(wxDataViewItemFromItem(item));
event.SetModel(dvc->GetModel());
- BOOL dragSuccessful;
+ BOOL dragSuccessful = false;
if ( [bestType compare:DataViewPboardType] == NSOrderedSame )
{
NSArray* dataArray((NSArray*)
child:(NSInteger)index
ofItem:(id)item
{
+ wxUnusedVar(outlineView);
+
if ((item == currentParentItem) &&
(index < ((NSInteger) [self getChildCount])))
return [self getChild:index];
-(BOOL) outlineView:(NSOutlineView*)outlineView isItemExpandable:(id)item
{
+ wxUnusedVar(outlineView);
+
wxCHECK_MSG( model, 0, "Valid model in data source does not exist." );
return model->IsContainer(wxDataViewItemFromItem(item));
}
-(NSInteger) outlineView:(NSOutlineView*)outlineView numberOfChildrenOfItem:(id)item
{
+ wxUnusedVar(outlineView);
+
NSInteger noOfChildren;
wxDataViewItemArray dataViewChildren;
objectValueForTableColumn:(NSTableColumn*)tableColumn
byItem:(id)item
{
+ wxUnusedVar(outlineView);
+
wxCHECK_MSG( model, nil, "Valid model in data source does not exist." );
wxDataViewColumn* col(static_cast<wxDataViewColumn*>([[tableColumn identifier] pointer]));
forTableColumn:(NSTableColumn*)tableColumn
byItem:(id)item
{
+ wxUnusedVar(outlineView);
+
wxDataViewColumn* col(static_cast<wxDataViewColumn*>([[tableColumn identifier] pointer]));
col->GetRenderer()->
-(void) outlineView:(NSOutlineView*)outlineView sortDescriptorsDidChange:(NSArray*)oldDescriptors
{
+ wxUnusedVar(oldDescriptors);
+
// Warning: the new sort descriptors are guaranteed to be only of type
// NSSortDescriptor! Therefore, the sort descriptors for the data source
// have to be converted.
-(NSDragOperation) outlineView:(NSOutlineView*)outlineView validateDrop:(id<NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
{
+ wxUnusedVar(outlineView);
+ wxUnusedVar(index);
+
NSArray* supportedTypes([NSArray arrayWithObjects:DataViewPboardType,NSStringPboardType,nil]);
NSPasteboard* pasteboard([info draggingPasteboard]);
if (bestType == nil)
return NSDragOperationNone;
- NSDragOperation dragOperation;
+ NSDragOperation dragOperation = NSDragOperationNone;
wxDataViewCtrl* const dvc(implementation->GetDataViewCtrl());
wxCHECK_MSG(dvc, false, "Pointer to data view control not set correctly.");
-(BOOL) outlineView:(NSOutlineView*)outlineView writeItems:(NSArray*)writeItems toPasteboard:(NSPasteboard*)pasteboard
{
+ wxUnusedVar(outlineView);
+
// the pasteboard will be filled up with an array containing the data as
// returned by the events (including the data type) and a concatenation of
// text (string) data; the text data will only be put onto the pasteboard
if ([writeItems count] > 0)
{
bool dataStringAvailable(true); // a flag indicating if for all items a data string is available
- NSMutableArray* dataArray = [[NSMutableArray arrayWithCapacity:[writeItems count]] retain]; // data of all items
+ NSMutableArray* dataArray = [NSMutableArray arrayWithCapacity:[writeItems count]]; // data of all items
wxString dataString; // contains the string data of all items
// send a begin drag event for all selected items and proceed with
wxDataViewCustomRenderer * const renderer = obj->customRenderer;
- wxDC * const dc = renderer->GetDC();
- renderer->WXCallRender(wxFromNSRect(controlView, cellFrame), dc, 0);
- renderer->SetDC(NULL);
+ // if this method is called everything is already setup correctly,
+ CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
+ CGContextSaveGState( context );
+
+ if ( ![controlView isFlipped] )
+ {
+ CGContextTranslateCTM( context, 0, [controlView bounds].size.height );
+ CGContextScaleCTM( context, 1, -1 );
+ }
+
+ wxGCDC dc;
+ wxGraphicsContext* gc = wxGraphicsContext::CreateFromNative(context);
+ dc.SetGraphicsContext(gc);
+
+ int state = 0;
+ if ( [self isHighlighted] )
+ state |= wxDATAVIEW_CELL_SELECTED;
+
+ renderer->WXCallRender(wxFromNSRect(controlView, cellFrame), &dc, state);
+
+ CGContextRestoreGState( context );
}
-(NSRect) imageRectForBounds:(NSRect)cellFrame
//
-(void) actionDoubleClick:(id)sender
{
+ wxUnusedVar(sender);
+
// actually the documentation (NSTableView 2007-10-31) for doubleAction:
// and setDoubleAction: seems to be wrong as this action message is always
// sent whether the cell is editable or not
//
-(NSMenu*) menuForEvent:(NSEvent*)theEvent
{
+ wxUnusedVar(theEvent);
+
// this method does not do any special menu event handling but only sends
// an event message; therefore, the user has full control if a context
// menu should be shown or not
-(BOOL) outlineView:(NSOutlineView*)outlineView shouldCollapseItem:(id)item
{
+ wxUnusedVar(outlineView);
+
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
wxDataViewEvent event(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING,dvc->GetId());
-(BOOL) outlineView:(NSOutlineView*)outlineView shouldExpandItem:(id)item
{
+ wxUnusedVar(outlineView);
+
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
wxDataViewEvent event(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING,dvc->GetId());
-(BOOL) outlineView:(NSOutlineView*)outlineView shouldSelectTableColumn:(NSTableColumn*)tableColumn
{
+ wxUnusedVar(tableColumn);
+ wxUnusedVar(outlineView);
+
return NO;
}
forTableColumn:(NSTableColumn*)tableColumn
item:(id)item
{
+ wxUnusedVar(outlineView);
+
wxDataViewCtrl * const dvc = implementation->GetDataViewCtrl();
wxDataViewModel * const model = dvc->GetModel();
-(void) outlineViewSelectionDidChange:(NSNotification*)notification
{
+ wxUnusedVar(notification);
+
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
wxDataViewEvent event(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED,dvc->GetId());
bool wxCocoaDataViewControl::Reload()
{
[m_DataSource clearBuffers];
+ [m_OutlineView reloadData];
[m_OutlineView scrollColumnToVisible:0];
[m_OutlineView scrollRowToVisible:0];
- [m_OutlineView reloadData];
return true;
}
bool wxCocoaDataViewControl::Update(const wxDataViewColumn *columnPtr)
{
+ wxUnusedVar(columnPtr);
+
return false;
}
[m_OutlineView reloadData];
}
+void wxCocoaDataViewControl::StartEditor( const wxDataViewItem & item, unsigned int column )
+{
+ [m_OutlineView editColumn:column row:[m_OutlineView rowForItem:[m_DataSource getDataViewItemFromBuffer:item]] withEvent:nil select:YES];
+}
+
//
// other methods (inherited from wxDataViewWidgetImpl)
//
cell = [[NSPopUpButtonCell alloc] init];
[cell setControlSize:NSMiniControlSize];
- [cell setFont:[[NSFont fontWithName:[[cell font] fontName] size:[NSFont systemFontSizeForControlSize:NSMiniControlSize]] autorelease]];
+ [cell setFont:[NSFont fontWithName:[[cell font] fontName] size:[NSFont systemFontSizeForControlSize:NSMiniControlSize]]];
for (size_t i=0; i<choices.GetCount(); ++i)
- [cell addItemWithTitle:[[wxCFStringRef(choices[i]).AsNSString() retain] autorelease]];
+ [cell addItemWithTitle:wxCFStringRef(choices[i]).AsNSString()];
SetNativeData(new wxDataViewRendererNativeData(cell));
[cell release];
}
int align)
: wxDataViewRenderer(varianttype,mode,align)
{
+ wxUnusedVar(label);
+
NSLevelIndicatorCell* cell;
cell = [[NSLevelIndicatorCell alloc] initWithLevelIndicatorStyle:NSContinuousCapacityLevelIndicatorStyle];
m_title(title)
{
InitCommon(width, align, flags);
- if (renderer && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
+ if (renderer && !renderer->IsCustomRenderer() &&
+ (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
renderer->SetAlignment(align);
}
m_NativeDataPtr(new wxDataViewColumnNativeData())
{
InitCommon(width, align, flags);
- if (renderer && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
+ if (renderer && !renderer->IsCustomRenderer() &&
+ (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
renderer->SetAlignment(align);
}
{
m_alignment = align;
[[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
- if (m_renderer && (m_renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
+ if (m_renderer && !m_renderer->IsCustomRenderer() &&
+ (m_renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
m_renderer->SetAlignment(align);
}
void wxDataViewColumn::SetReorderable(bool reorderable)
{
+ wxUnusedVar(reorderable);
}
void wxDataViewColumn::SetHidden(bool hidden)
return [m_NativeDataPtr->GetNativeColumnPtr() isHidden];
}
-void wxDataViewColumn::SetResizeable(bool resizeable)
+void wxDataViewColumn::SetResizeable(bool resizable)
{
- wxDataViewColumnBase::SetResizeable(resizeable);
- if (resizeable)
+ wxDataViewColumnBase::SetResizeable(resizable);
+ if (resizable)
[m_NativeDataPtr->GetNativeColumnPtr() setResizingMask:NSTableColumnUserResizingMask];
else
[m_NativeDataPtr->GetNativeColumnPtr() setResizingMask:NSTableColumnNoResizing];