From: Vadim Zeitlin Date: Mon, 12 Oct 2009 17:30:41 +0000 (+0000) Subject: No real changes, just clean up wxCustomRendererObject in Cocoa wxDVC. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a8afd748c7dce4b4eb0106923558c272cfa89e9e?ds=inline No real changes, just clean up wxCustomRendererObject in Cocoa wxDVC. The variables tableColumn and item are unneeded in this class so remove them. Use static_cast<>s instead of C casts. Avoid repeating oneVeryLongVariableName->anotherEvenLongerVariableName-> somethingElse->andSoOn multiple times, temporary variables are allowed in C++. Also don't call wxDataViewCustomRenderer::GetSize() twice unnecessarily. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62389 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index 4693000067..15a786ec09 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -37,18 +37,14 @@ @interface wxCustomRendererObject : NSObject { @public - NSTableColumn* tableColumn; // not owned by the class - wxDataViewCustomRenderer* customRenderer; // not owned by the class - - wxPointerObject* item; // not owned by the class } // // initialization // -(id) init; - -(id) initWithRenderer:(wxDataViewCustomRenderer*)initRenderer item:(wxPointerObject*)initItem column:(NSTableColumn*)initTableColumn; + -(id) initWithRenderer:(wxDataViewCustomRenderer*)renderer; @end @@ -62,20 +58,16 @@ if (self != nil) { customRenderer = NULL; - item = NULL; - tableColumn = NULL; } return self; } --(id) initWithRenderer:(wxDataViewCustomRenderer*)initRenderer item:(wxPointerObject*)initItem column:(NSTableColumn*)initTableColumn +-(id) initWithRenderer:(wxDataViewCustomRenderer*)renderer { self = [super init]; if (self != nil) { - customRenderer = initRenderer; - item = initItem; - tableColumn = initTableColumn; + customRenderer = renderer; } return self; } @@ -84,11 +76,8 @@ { wxCustomRendererObject* copy; - copy = [[[self class] allocWithZone:zone] init]; copy->customRenderer = customRenderer; - copy->item = item; - copy->tableColumn = tableColumn; return copy; } @@ -981,16 +970,17 @@ wxWidgetImplType* CreateDataView(wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(pare // ============================================================================ // wxCustomCell // ============================================================================ + @implementation wxCustomCell -// -// other methods -// + -(NSSize) cellSize { - wxCustomRendererObject* customRendererObject(((wxCustomRendererObject*)[self objectValue])); + wxCustomRendererObject * const + obj = static_cast([self objectValue]); - return NSMakeSize(customRendererObject->customRenderer->GetSize().GetWidth(),customRendererObject->customRenderer->GetSize().GetHeight()); + const wxSize size = obj->customRenderer->GetSize(); + return NSMakeSize(size.x, size.y); } // @@ -998,32 +988,18 @@ wxWidgetImplType* CreateDataView(wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(pare // -(void) drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { - wxCustomRendererObject* customRendererObject(((wxCustomRendererObject*)[self objectValue])); - - - // draw its own background: - [[self backgroundColor] set]; - NSRectFill(cellFrame); - - (void) (customRendererObject->customRenderer->Render(wxFromNSRect(controlView,cellFrame),customRendererObject->customRenderer->GetDC(),0)); - customRendererObject->customRenderer->SetDC(NULL); -} - -#if 0 //TODO FIXME: MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 --(NSUInteger) hitTestForEvent:(NSEvent*)event inRect:(NSRect)cellFrame ofView:(NSView*)controlView -{ - NSPoint point = [controlView convertPoint:[event locationInWindow] fromView:nil]; - - wxCustomRendererObject* customRendererObject((wxCustomRendererObject*)[self objectValue]); - + wxCustomRendererObject * const + obj = static_cast([self objectValue]); + wxDataViewCustomRenderer * const renderer = obj->customRenderer; + // draw its own background: + [[self backgroundColor] set]; + NSRectFill(cellFrame); - customRendererObject->customRenderer->LeftClick(wxFromNSPoint(controlView,point),wxFromNSRect(controlView,cellFrame), - customRendererObject->GetOwner()->GetOwner(),wxDataViewItem([customRendererObject->item pointer]), - [m_OutlineView columnWithIdentifier:[customRendererObject->GetColumnPtr() identifier]]); - return NSCellHitContentArea; + // TODO: attributes support + renderer->Render(wxFromNSRect(controlView, cellFrame), renderer->GetDC(), 0); + renderer->SetDC(NULL); } -#endif -(NSRect) imageRectForBounds:(NSRect)cellFrame { @@ -2156,9 +2132,7 @@ wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const& varianttype, bool wxDataViewCustomRenderer::MacRender() { - [GetNativeData()->GetItemCell() setObjectValue:[[[wxCustomRendererObject alloc] initWithRenderer:this - item:GetNativeData()->GetItem() - column:GetNativeData()->GetColumnPtr()] autorelease]]; + [GetNativeData()->GetItemCell() setObjectValue:[[[wxCustomRendererObject alloc] initWithRenderer:this] autorelease]]; return true; }