Xcode wxDVC 渲染器编译失败

Xcode compilation failure for wxDVC renderer

全部,

#ifdef __WXOSX__
#include "wx/toplevel.h"
#include "wx/font.h"
#include "wx/settings.h"
#include "wx/utils.h"
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
#include "wx/osx/cocoa/dataview.h"
#include "wx/renderer.h"
#include "wx/stopwatch.h"
#include "wx/dcgraph.h"
#endif

class SortColumnRenderer
    : public wxDataViewRenderer
{
public:
    explicit SortColumnRenderer(
        wxCheckBoxState state = wxCHK_CHECKED,
        wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
        int align = wxDVR_DEFAULT_ALIGNMENT)
    : wxDataViewRenderer( GetDefaultType(), mode, mode ), m_checkedState(state)
    {
        m_allow3rdStateForUser = false;
        m_value = "Ascending";
        NSButtonCell* cell;
        cell = [[NSButtonCell alloc] init];
        [cell setAlignment:ConvertToNativeHorizontalTextAlignment(GetAlignment())];
        [cell setButtonType: NSSwitchButton];
        [cell setImagePosition:NSImageLeft];
        [cell setAllowsMixedState:YES];
        SetNativeData(new wxDataViewRendererNativeData( cell ) );
        [cell release];
    };
};

上面的代码产生了很多错误,例如:

Expected unqualified-id NSObjCRuntime.h

来自#include "wx/osx/cocoa/dataview.h"。

如果我注释掉包含的内容,我会得到:

Unknown type name 'NSButtonCell'; did you mean 'NSButton'?

尝试导入 AppKit/NSButtonCell.h,导致与上述相同的一组错误:Expected unqualified-id....

我正在尝试模仿 wxCheckIconTextRenderer 中的代码,但没有图标部分。

有人有想法吗?

TIA!

您需要使用 Objective-C 编译代码,即如果您不想显式使用 -x 编译器选项,请将其放在扩展名为 .mm 的文件中。