Incorporate document features into shoebox app - macos

I'm working on a shoebox (library style) app for Mac OS X which will incorporate a page view like in Apple's text edit sample code.
Since this is a shoebox app, I cannot simply generate a document-based Xcode project because I want the user to generate a new "canvas" to work on from within the app. Rather than having the user open a new document through an open command they create a new object in the navigation sidebar, or simply open an already created document also from the sidebar. I'm looking at a UI similar to Albums in iPhoto.
Is there an easy way to incorporate the features of document-based applications (i.e. page setup, print setup etc) into a non-document-based app without having to implement each method individually? Would anyone have any suggestions as to how to implement this otherwise?

Related

Is it possible to change a View in MvvMCross without opening a new window?

I'm currently trying to build a simple macos & WPF application with the help of the MvvMCross framework. I'm having some trouble with navigating from one Viewmodel to another. I've got my WPF client currently working as desired, but I can't seem to achieve the same behaviour for my macos client.
Clicking on any navigation button opens a separate window. What I'd like to see is that the content in the current window changes to the content of the view that was navigated towards.
You can find the code over here

Selecting iPhoto images within a cocoa application

I was wondering what the best way of selecting photos from iPhoto within a cocoa application? Right now, the open file dialogue doesn't allow me to go into the iPhoto library. How can I allow the user to go into that folder? IKPictureTaker was one option, but it appears that it allows the selection of one picture at a time. I'd like a user to be able to select 1 picture, or many.
Just use NSOpenPanel and set the allowed file types to the public.image UTI:
[panel setAllowedFileTypes:[NSArray arrayWithObject:#"public.image"]];
This will automatically add a Media section and Photos item to the sidebar in the open panel that allows the user to select from their iPhoto library.
Alternatively, you can use Karelia's open-source iMedia Browser.
There is a private API of Apple that contains exactly the control you want; this control is an ILMediaBrowserView and provides the exact same view than the one in NSOpenDialog.
If you are planning an AppStore release of your app don't use it but it can be useful.
The framework to integrate to your project to get that view is iLifeMediaBrowser.framework in /System/Library/PrivateFrameworks.
Let's all hope Apple brings the same view in the documented IK.

Embedding a .app file in a Cocoa application

Is it possible to "embed" an application (like Preview, Pages etc) into a Cocoa application? I would like to allow a user to view a PDF in my app with options to show/hide annotations, change the zoom level between page width and full page etc.
Is it possible to embed the Preview app within my Cocoa application? Couldn't find anything in the document or on the Internet which would suggest I could, so not sure.
Thanks.
You can embed an other application in the bundle of your application.
You will usually do this to embed an other application you also created, like an helper, or a daemon. It sometimes is helpful, but doesn't seem to be what you want.
If you want to let the user play with a pdf inside your application, read the PDF Kit Programming Guide.
Especially look into the class PDFView. You can drag and drop an instance into your xib, and load content into it with this code (from Apple documentation):
PDFDocument *pdfDoc;
pdfDoc = [[[PDFDocument alloc] initWithURL: [NSURL fileURLWithPath: [self fileName]]] autorelease];
[pdfView setDocument: pdfDoc];
You cannot embed an application into another application. You can bundle it into your bundle, but it remains a separate application that will run separately. (And in the case of Preview, you'd be violating Apple's copyright, plus it'd be pointless since it comes with the OS anyway.)
When you want to do something that another application does, you have several choices:
Use the framework(s) that that application is based on, where applicable. Only works for apps like Preview and TextEdit that are little more than application hosts for OS frameworks. Preview = ImageKit + PDFKit; TextEdit = AppKit text-rendering classes; AppleScript Editor = OSAKit.
Farm out the job to the application. For example, you could generate the PDF as a file somewhere and open it in Preview (the one that came with the OS).
Reinvent the wheel. Can be undesirable for obvious reasons, but can also be preferable if the existing wheel is overkill or not really a good fit for your application.
In this case, I'd go with PDFKit.

Drop down menu like the default iPad application menus

I'm currently working on my first iOS application to run on the iPad, and I've come across a problem. I have been asked to implement menu's similar to the ones in the default applications such as when you click on the "Calendars" button in the top left of the calendars app.
Only issue is, I cant seem to find a standard UI object that looks like these, with the arrow connecting the menu to the button etc. Is this a standard UI component that I should be able to use, or will I have to imitate them by creating a custom object?
Thanks for any help.
That is a UIPopoverController. There isn't an Interface Builder control for this. You need to create one programmatically:
UIPopoverController *popover = [[UIPopoverController alloc]initWithContentViewController:someTableViewController];
See the documentation for more information and sample projects, specifically ToolbarSearch:

Right clicking with a Webkit view

I'm working on a project in Ruby right now that is essentially a web-app. We like the format of web-apps and some of the natural agile advantages we have building for the web. However, we want to be able to package our application and distribute it in a standalone format.
Ideally, we would like to essentially make a .app package for Mac and a .exe for Windows that just opens a Webkit view, connects to our server and renders the HTML we serve it.
Not so hard so far, though this is a little beyond our current expertise (especially the Windows development) but all surmountable.
The issue is that we'd like to enable right-clicking, as you can in the iTunes store (which is a Webkit view that has custom events for right-clicks). We want to give our right-clicks special meaning in our application, too, and have it act context sensitive.
What do we do? Where can we even start?
Do you want to do this from your webapp or from your native app side?
If you're doing this from a Cocoa app, you can just implement the webView:contextMenuItemsForElement:defaultMenuItems: WebUIDelegate method and return an array of custom NSMenuItem's corresponding to your custom actions.
If you want to do this from the web app itself, you can add an event listener for the "contextmenu" event like so:
document.addEventListener("contextmenu", function(event) {
event.preventDefault();
console.log("My spiffy custom right click menu here!");
}, false);
You need to be aware though, that if you use the above code in your webapp, you can't modify the browser's native right click menu, just replace it with your own custom creation.

Resources