/*
    This file is part of TIFFlib Format, a File Format plugin for Adobe Photoshop
    Copyright (C) 2005-7 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
*/

/* Win32 user interface routines for cross-platform plugin */

#include <windows.h>

#include "tifflibplugin.h"
#include "version.h"

BOOL CALLBACK dlgproc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);

extern HANDLE hDllInstance;

void DoAbout(AboutRecordPtr pb){
	PlatformData *p = (PlatformData*)pb->platformData;

	MessageBox((HWND)p->hwnd, "TIFFlib Format, version " VERSION_STR "\n"
		"Copyright 2005-7 Toby Thain <toby@telegraphics.com.au>.\n\n"
		"http://www.telegraphics.com.au/sw/\n\n"
		"Please contact the author with any bug reports, suggestions or comments.\n\n"
		"Uses libtiff: http://libtiff.maptools.org/\n"
		"(C) 1988-1997 Sam Leffler\n"
		"(C) 1991-1997 Silicon Graphics, Inc.\n\n"
		"Uses zlib: http://www.zlib.net/\n"
		"(C) 1995-2004 Jean-loup Gailly & Mark Adler.\n\n"
		"Uses the Independent JPEG Group's software: http://www.ijg.org/",
	"About TIFFlib Format", MB_APPLMODAL|MB_ICONINFORMATION|MB_OK);
}

BOOL CALLBACK compdlgproc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam){
	int item, cmd;

	switch(wMsg){
	case WM_INITDIALOG:
		centre_window(hDlg);
		compdlg_init(hDlg);
		break;
	case WM_COMMAND:
  		item = LOWORD(wParam);
		cmd = HIWORD(wParam);
		if(cmd == BN_CLICKED && !compdlg_item(hDlg, item))
			EndDialog(hDlg, item);
		break;
	default:
		return false;
	}

	return true;
}

Boolean compdlg(){
	PlatformData *p = (PlatformData*)gpb->platformData;
	
	return DialogBoxParam(hDllInstance, MAKEINTRESOURCE(ID_COMPDLG),
						  (HWND)p->hwnd, compdlgproc, 0) == IDOK;
}
