/* This file is part of icoformat, a Windows Icon (ICO) File Format plugin for Adobe Photoshop Copyright (C) 2002-2010 Toby Thain, toby@telegraphics.com.au This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Loosely based on Dissolve sample plugin, CS5 SDK #ifdef __x86_64__ #import "IcoChooseMemberController.h" #include "../icoformat.h" #include "../ui.h" @implementation IcoChooseMemberController - (id) init { self = [super init]; // initialize NSApplication, using an entry point that is specific to // bundles this is a no-op for Cocoa apps, but is required by Carbon apps //NSApplicationLoad(); if (![NSBundle loadNibNamed:@"IcoChooseMember" owner:self]) NSLog(@"failed to load ChooseMember xib"); return self; } - (int) showWindow { const char *fmt; char s[0x100]; ICONDIRENTRY ide; ICONIMAGE ii; int i, n, bpp; // set up the dialog contents [promptField setStringValue: [NSString stringWithFormat:@"The ICO file contains %d icons.", iconcount]]; [membersPopup removeAllItems]; for(i = 0; i < iconcount && !getimageinfo(file, &ide, &ii, i, &fmt); ++i){ bpp = ii.icHeader.biPlanes*ii.icHeader.biBitCount; n = sprintf(s, "%d. %d x %d, %d bits/pixel ", i+1, ii.icHeader.biWidth, ii.icHeader.biHeight/2, bpp); if(bpp <= 8) sprintf(s+n, "(%d colours) ", 1 << ii.icHeader.biBitCount); strcat(s, fmt); [membersPopup addItemWithTitle:[NSString stringWithCString:s]]; } [membersPopup selectItemAtIndex:whichicon]; //[pickIconWindow makeKeyAndOrderFront:nil]; int b = [[NSApplication sharedApplication] runModalForWindow:pickIconWindow]; [pickIconWindow orderOut:self]; return b; } - (IBAction)pickMember:(id)sender { whichicon = [membersPopup indexOfSelectedItem]; } - (IBAction)okAction:(id)sender { [[NSApplication sharedApplication] stopModalWithCode:1]; } - (IBAction)cancelAction:(id)sender { [[NSApplication sharedApplication] stopModalWithCode:0]; } @end static IcoChooseMemberController *gController = NULL; Boolean pickicondialog(FormatRecordPtr pb){ if(!gController) gController = [[IcoChooseMemberController alloc] init]; return [gController showWindow]; } #endif