.so 运行时可链接库作为插件;可可能力?

发布于 2024-10-21 07:28:17 字数 685 浏览 2 评论 0原文

我正在为 OSX 图像处理应用程序编写一个插件接口。它的设计理念是插件应该尽可能简单,以便开发人员可以在看到示例代码后几分钟内进入并编写效果。为此,这些示例不需要或使用 XCode;而是使用 XCode。只是海湾合作委员会。一切都进行得非常顺利,我们(一般来说)已经实现了所有的设计目标。我们实际上为插件生成了 UI,这样他们就不必灵活地、以各种方式对插件进行线程和分阶段、管理其存储、在控制面板中的存在和位置等,所有这些都是非常酷的事情。您可以用大约六行 C 代码编写一个完全有效的插件。所以一切都很好。

不过现在,我将目光转向开发人员打开 CoCoa 窗口可能需要的内容,如果他们需要比我们可以为他们生成的更复杂的界面。我发现我对 CoCoa 的内部工作原理了解不够,并且我花了很长时间才找到任何地方解决了这个特定问题,因为 XCode 通常向您隐藏了此类实现细节。所以这里(最后,抱歉)是我的问题:

对于想要打开 CoCoa 窗口的插件,我需要向他们提供什么? CoCoa 服务和资源是否有根句柄?或者他们可以直接链接到他们需要链接的任何内容并打开一个窗口吗?

目前,该插件仅接收指向非常特定的图像数据类型的指针。它们与操作系统没有任何关系。如果可能的话,我想向他们提供他们需要的句柄,以便打开 CoCoa 窗口并让 OSX 以正常方式处理该窗口,无论是什么。或者,如果他们不需要任何东西,我想要一个明确的答案。对该答案的参考会很棒,这样我就可以通过任何方式了解它。

感谢您的任何见解。

I'm writing a plug-in interface for an OSX image processing application. It's designed around the idea that the plug-ins should be as simple as possible, such that a developer can get in there and write an effect within minutes of seeing example code. Towards this end, the examples don't require or use XCode; just gcc. It all works very smoothly, and we have (generally speaking) met all the design goals. We actually generate the UI for the plugins so they don't have to, flexibly and variously thread and phase the plugin, manage its storage, presence and position in control panels, etc., all manner of really cool things. And you can write a fully effective plugin in about six lines of C code. So all is good.

Now, though, I'm turning my eye towards what might be required for a developer to open a CoCoa window if they need a more complex interface than we can generate for them. I find I don't know enough about the internal workings of CoCoa, and I've had a bear of a time finding this particular issue addressed anywhere, because XCode generally hides this sort of implementation detail from you. So here (finally, sorry) is my question:

For a plug-in that wants to open a CoCoa window, what do I need to hand them? Is there a root handle for CoCoa services and resources? Or can they just link with whatever it is they need to link with and open a window?

Right now, the plug-in only receives pointers to very specific image data types. They're in no way associated with the OS. If possible, I'd like to hand them the handle(s) they need in order to open a CoCoa window and have that processed by OSX in the normal way, whatever that might be. Or, if they don't need anything, I'd like a definitive answer. A reference for that answer would be wonderful so I can learn about it either way.

Thanks for any insights.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白云悠悠 2024-10-28 07:28:17

你不需要任何东西。他们必须链接 Cocoa 框架并调用 NSWindow 上的方法。系统会自动处理繁重的工作。

编辑:

如何使用模态窗口:

NSWindow *theWindow; // create this in code, get it from a variable, or load it from a nib
NSInteger result = [[NSApplication sharedApplication] runModalForWindow:theWindow];
if(result == 0) {
    // success, process input from window
} else if(result == NSRunStoppedResponse) {
    // stopped with -stopModal instead of stopModalWithCode:. Possibly success
} else if(result == NSRunAbortedResponse) {
    // stopped with -abortModal, probably an error
}


//This method is the action for a button on the window
- (IBAction)closeModalWindow:(id)sender {
    [[sender window] orderOut:nil];
    [[NSApplication sharedApplication] stopModalWithCode:0]; // The 0 will become the result of the runModalForWindow: method. You can use anything else instead
}

You don't need anything. They will have to link against the Cocoa framework and call methods on NSWindow. The system takes care of the hard work automatically.

Edit:

How to use a modal window:

NSWindow *theWindow; // create this in code, get it from a variable, or load it from a nib
NSInteger result = [[NSApplication sharedApplication] runModalForWindow:theWindow];
if(result == 0) {
    // success, process input from window
} else if(result == NSRunStoppedResponse) {
    // stopped with -stopModal instead of stopModalWithCode:. Possibly success
} else if(result == NSRunAbortedResponse) {
    // stopped with -abortModal, probably an error
}


//This method is the action for a button on the window
- (IBAction)closeModalWindow:(id)sender {
    [[sender window] orderOut:nil];
    [[NSApplication sharedApplication] stopModalWithCode:0]; // The 0 will become the result of the runModalForWindow: method. You can use anything else instead
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文