/* 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" int whichicon, usepng = 0; void pickiconinit(DIALOGREF dp){ char fmt[0x100],s[0x100]; ICONDIRENTRY ide; ICONIMAGE ii; int i,n,bpp; CTLREF menu; GetDlgItemText(dp, CAPTIONITEM, fmt, 0x100); sprintf(s, fmt, 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. %ld x %ld, %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 }