/* 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 */ /* This is PLATFORM INDEPENDENT user interface code - dialog logic */ #include "icoformat.h" #include "ico_io.h" #include "ui.h" #include "ui_defs.h" int whichicon, usepng; Boolean warntype(FormatRecordPtr pb, int t){ char s[0x100]; sprintf(s, "This does not appear to be an icon or cursor file (idType=%d).", t); return warndlg(s); } Boolean warnformat(FormatRecordPtr pb, char *type){ char s[0x100]; sprintf(s, "This looks like a %s file that has been improperly renamed to ICO. \ Try renaming with the correct file extension.", type); return warndlg(s); } #if ! __x86_64__ void pickiconinit(DIALOGREF dp){ const char *fmt; char s[0x100], t[0x100]; ICONDIRENTRY ide; ICONIMAGE ii; int i,n,bpp; CTLREF menu; GetDlgItemText(dp, CAPTIONITEM, t, 0x100); sprintf(s, t, myp2cstr(name), iconcount); myc2pstr((char*)name); SetDlgItemText(dp, CAPTIONITEM, s); menu = GETDLGCTLREF(dp, ICONMENUITEM); #ifdef MAC_ENV SetControlMaximum(menu, iconcount); #endif 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); MENUADDCSTR(menu,s); } SETMENUCURSEL(menu,0); } Boolean pickiconitem(DIALOGREF dp, int item){ switch(item){ case IDOK: whichicon = GETMENUCURSEL( GETDLGCTLREF(dp, ICONMENUITEM) ); case IDCANCEL: return false; // end dialog } return true; // keep going } void formatinit(DIALOGREF dp){ CHECKDLGBUTTON(dp, STANDARDITEM, !usepng); CHECKDLGBUTTON(dp, PNGITEM, usepng); } Boolean formatitem(DIALOGREF dp, int item){ switch(item){ case IDOK: case IDCANCEL: return false; // end dialog case STANDARDITEM: case PNGITEM: CHECKDLGBUTTON(dp, STANDARDITEM, item == STANDARDITEM); CHECKDLGBUTTON(dp, PNGITEM, usepng = (item == PNGITEM)); } return true; // keep going } #endif