Allow naming of image and provisional setting of DIB bitcount, width, height and resolution.

svn path=/trunk/; revision=21244
This commit is contained in:
Ged Murphy 2006-03-07 17:34:18 +00:00
parent 6754e0b5af
commit 0cfabeb042
7 changed files with 204 additions and 100 deletions

View file

@ -43,7 +43,7 @@ BEGIN
MENUITEM "&Flip...", -1, GRAYED
MENUITEM "&Stretch...", -1, GRAYED
MENUITEM "S&kew...", -1, GRAYED
MENUITEM "&Invert Colors", -1, GRAYED
MENUITEM "&Invert Colors", -1, GRAYED
MENUITEM SEPARATOR
MENUITEM "&Attributes...", -1, GRAYED
END
@ -96,7 +96,7 @@ FONT 8,"MS Sans Serif",0,0
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
BEGIN
LTEXT "Name:", IDC_STATIC, 12, 5, 38, 9
EDITTEXT IDC_IMAGE_NAME_EDIT, 58, 3, 76, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP
EDITTEXT IDC_IMAGE_NAME_EDIT, 58, 3, 94, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP
GROUPBOX "Canvas properties", IDC_STATIC, 4, 22, 148, 98
LTEXT "Image type:", IDC_STATIC, 12, 36, 42, 9
CONTROL "", IDC_IMAGETYPE, "ComboBox", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 35, 88, 54
@ -113,8 +113,8 @@ BEGIN
CONTROL "", IDC_UNIT, "ComboBox", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST, 58, 99, 54, 50
LTEXT "Image size:", IDC_STATIC, 12, 125, 42, 9
LTEXT "", IDC_IMAGE_SIZE, 58, 125, 54, 9
PUSHBUTTON "OK", IDOK, 98, 144, 54, 13
PUSHBUTTON "Cancel", IDCANCEL, 40, 144, 54, 13
PUSHBUTTON "OK", IDOK, 50, 144, 48, 13
PUSHBUTTON "Cancel", IDCANCEL, 102, 144, 48, 13
END
@ -142,43 +142,43 @@ END
STRINGTABLE DISCARDABLE
BEGIN
IDS_APPNAME "ImageSoft"
IDS_LICENSE "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.\r\n\r\nThis 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.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."
IDS_READY " Ready."
IDS_APPNAME "ImageSoft"
IDS_LICENSE "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.\r\n\r\nThis 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.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."
IDS_READY " Ready."
IDS_TOOLBAR_STANDARD "Standard"
IDS_TOOLBAR_TEST "Test"
IDS_IMAGE_NAME "Image %1!u!"
IDS_TOOLBAR_STANDARD "Standard"
IDS_TOOLBAR_TEST "Test"
IDS_IMAGE_NAME "Image %1!u!"
END
/* imageprop.c */
STRINGTABLE DISCARDABLE
BEGIN
IDS_IMAGE_MONOCHROME "Monochrome (1 bit)"
IDS_IMAGE_GREYSCALE "Greyscale (8 bit)"
IDS_IMAGE_PALETTE "Palette or 256 color (8 bit)"
IDS_IMAGE_TRUECOLOR "True color (24 bit)"
IDS_IMAGE_MONOCHROME "Monochrome (1 bit)"
IDS_IMAGE_GREYSCALE "Greyscale (8 bit)"
IDS_IMAGE_PALETTE "Palette or 256 color (8 bit)"
IDS_IMAGE_TRUECOLOR "True color (24 bit)"
IDS_UNIT_CM "Cm"
IDS_UNIT_INCHES "Inches"
IDS_UNIT_PIXELS "Pixels"
IDS_UNIT_DOTSCM "Dots / Cm"
IDS_UNIT_DPI "DPI"
IDS_UNIT_PIXELS "Pixels"
IDS_UNIT_CM "Cm"
IDS_UNIT_INCHES "Inches"
IDS_UNIT_DOTSCM "Dots / Cm"
IDS_UNIT_DPI "DPI"
END
/* Tooltips */
STRINGTABLE DISCARDABLE
BEGIN
IDS_TOOLTIP_NEW "New"
IDS_TOOLTIP_OPEN "Open"
IDS_TOOLTIP_SAVE "Save"
IDS_TOOLTIP_NEW "New"
IDS_TOOLTIP_OPEN "Open"
IDS_TOOLTIP_SAVE "Save"
IDS_TOOLTIP_PRINTPRE "Print preview"
IDS_TOOLTIP_PRINT "Print"
IDS_TOOLTIP_CUT "Cut"
IDS_TOOLTIP_COPY "Copy"
IDS_TOOLTIP_PASTE "Paste"
IDS_TOOLTIP_UNDO "Undo"
IDS_TOOLTIP_REDO "Redo"
IDS_TOOLTIP_PRINT "Print"
IDS_TOOLTIP_CUT "Cut"
IDS_TOOLTIP_COPY "Copy"
IDS_TOOLTIP_PASTE "Paste"
IDS_TOOLTIP_UNDO "Undo"
IDS_TOOLTIP_REDO "Redo"
END
/* Hints */

View file

@ -1,55 +1,69 @@
#include "precomp.h"
static LONG
GetTextFromEdit(HWND hDlg, UINT Res)
{
LONG num = 0;
INT len = GetWindowTextLength(GetDlgItem(hDlg, Res));
TCHAR buf[len+1];
if(len > 0)
{
GetDlgItemText(hDlg, Res, buf, len + 1);
num = _ttol(buf);
}
return num;
}
#include <precomp.h>
static PIMAGE_PROP ImageProp;
static HWND hImageType, hUnitType, hHeightUnit, hWidthUnit, hResUnit;
#ifdef _MSC_VER
#pragma warning(disable : 4100)
#endif
INT_PTR CALLBACK
ImagePropDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
ImagePropDialogProc(HWND hDlg,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
HWND hImagetype;
PIMAGE_PROP ImageProp;
TCHAR buf[25];
ImageProp = HeapAlloc(ProcessHeap,
0,
sizeof(IMAGE_PROP));
if (ImageProp == NULL)
EndDialog(hDlg, 0);
TCHAR buf[35];
switch (message)
{
case WM_INITDIALOG:
hImagetype = GetDlgItem(hDlg, IDC_IMAGETYPE);
ImageProp = HeapAlloc(ProcessHeap,
0,
sizeof(IMAGE_PROP));
if (ImageProp == NULL)
EndDialog(hDlg, 0);
/* get handles to the windows */
hImageType = GetDlgItem(hDlg, IDC_IMAGETYPE);
hUnitType = GetDlgItem(hDlg, IDC_UNIT);
hWidthUnit = GetDlgItem(hDlg, IDC_WIDTH_STAT);
hHeightUnit = GetDlgItem(hDlg, IDC_HEIGHT_STAT);
hResUnit = GetDlgItem(hDlg, IDC_RES_STAT);
/* fill image type combo box */
LoadString(hInstance, IDS_IMAGE_MONOCHROME, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hImagetype, CB_ADDSTRING, 0, (LPARAM)buf);
SendMessage(hImageType, CB_ADDSTRING, 0, (LPARAM)buf);
LoadString(hInstance, IDS_IMAGE_GREYSCALE, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hImagetype, CB_ADDSTRING, 0, (LPARAM)buf);
SendMessage(hImageType, CB_ADDSTRING, 0, (LPARAM)buf);
LoadString(hInstance, IDS_IMAGE_PALETTE, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hImagetype, CB_ADDSTRING, 0, (LPARAM)buf);
SendMessage(hImageType, CB_ADDSTRING, 0, (LPARAM)buf);
LoadString(hInstance, IDS_IMAGE_TRUECOLOR, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hImagetype, CB_ADDSTRING, 0, (LPARAM)buf);
SendMessage(hImageType, CB_ADDSTRING, 0, (LPARAM)buf);
/* default 24bit */
SendMessage(hImageType, CB_SETCURSEL, 3, 0);
SendMessage(hImagetype, CB_SETCURSEL, 3, 0);
/* fill unit combo box */
LoadString(hInstance, IDS_UNIT_PIXELS, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hUnitType, CB_ADDSTRING, 0, (LPARAM)buf);
LoadString(hInstance, IDS_UNIT_CM, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hUnitType, CB_ADDSTRING, 0, (LPARAM)buf);
LoadString(hInstance, IDS_UNIT_INCHES, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hUnitType, CB_ADDSTRING, 0, (LPARAM)buf);
/* default pixels */
SendMessage(hUnitType, CB_SETCURSEL, 0, 0);
/* default pixels */
LoadString(hInstance, IDS_UNIT_PIXELS, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hWidthUnit, WM_SETTEXT, 0, (LPARAM)buf);
SendMessage(hHeightUnit, WM_SETTEXT, 0, (LPARAM)buf);
LoadString(hInstance, IDS_UNIT_DPI, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hResUnit, WM_SETTEXT, 0, (LPARAM)buf);
/* temperary. Default vals should be loaded from registry */
SendDlgItemMessage(hDlg, IDC_WIDTH_EDIT, WM_SETTEXT, 0, (LPARAM)_T("400"));
SendDlgItemMessage(hDlg, IDC_HEIGHT_EDIT, WM_SETTEXT, 0, (LPARAM)_T("300"));
SendDlgItemMessage(hDlg, IDC_RES_EDIT, WM_SETTEXT, 0, (LPARAM)_T("50"));
break;
@ -58,18 +72,63 @@ ImagePropDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
switch(LOWORD(wParam))
{
case IDOK:
{
/* FIXME: default vals should be taken from registry */
ImageProp->Type = SendMessage(GetDlgItem(hDlg, IDC_IMAGETYPE), CB_GETCURSEL, 0, 0);
ImageProp->Resolution = GetTextFromEdit(hDlg, IDC_RES_EDIT);
ImageProp->Width = GetTextFromEdit(hDlg, IDC_WIDTH_EDIT);
ImageProp->Height = GetTextFromEdit(hDlg, IDC_HEIGHT_EDIT);
INT Ret = GetTextFromEdit(ImageProp->lpImageName, hDlg, IDC_IMAGE_NAME_EDIT);
if (Ret == 0)
ImageProp->lpImageName = NULL;
ImageProp->Type = SendMessage(hImageType, CB_GETCURSEL, 0, 0);
ImageProp->Resolution = GetNumFromEdit(hDlg, IDC_RES_EDIT);
ImageProp->Width = GetNumFromEdit(hDlg, IDC_WIDTH_EDIT);
ImageProp->Height = GetNumFromEdit(hDlg, IDC_HEIGHT_EDIT);
ImageProp->Unit = SendMessage(hUnitType, CB_GETCURSEL, 0, 0);
EndDialog(hDlg, (int)ImageProp);
}
break;
case IDCANCEL:
EndDialog(hDlg, 0);
break;
case IDC_UNIT:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
INT unit = SendMessage(hUnitType, CB_GETCURSEL, 0, 0);
switch (unit)
{
case 0:
/* pixels */
LoadString(hInstance, IDS_UNIT_PIXELS, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hWidthUnit, WM_SETTEXT, 0, (LPARAM)buf);
SendMessage(hHeightUnit, WM_SETTEXT, 0, (LPARAM)buf);
LoadString(hInstance, IDS_UNIT_DPI, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hResUnit, WM_SETTEXT, 0, (LPARAM)buf);
break;
case 1:
/* cm */
LoadString(hInstance, IDS_UNIT_CM, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hWidthUnit, WM_SETTEXT, 0, (LPARAM)buf);
SendMessage(hHeightUnit, WM_SETTEXT, 0, (LPARAM)buf);
LoadString(hInstance, IDS_UNIT_DOTSCM, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hResUnit, WM_SETTEXT, 0, (LPARAM)buf);
break;
case 2:
/* inch */
LoadString(hInstance, IDS_UNIT_INCHES, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hWidthUnit, WM_SETTEXT, 0, (LPARAM)buf);
SendMessage(hHeightUnit, WM_SETTEXT, 0, (LPARAM)buf);
LoadString(hInstance, IDS_UNIT_DPI, buf, sizeof(buf) / sizeof(TCHAR));
SendMessage(hResUnit, WM_SETTEXT, 0, (LPARAM)buf);
break;
}
}
break;
}
break;

View file

@ -246,7 +246,6 @@ SetImageEditorEnvironment(PEDIT_WND_INFO Info,
BOOL
CreateImageEditWindow(struct _MAIN_WND_INFO *MainWnd,
LPCTSTR lpCaption,
POPEN_IMAGE_EDIT_INFO OpenInfo)
{
PEDIT_WND_INFO Info;
@ -264,7 +263,7 @@ CreateImageEditWindow(struct _MAIN_WND_INFO *MainWnd,
Info->OpenInfo = OpenInfo;
hWndEditor = CreateMDIWindow(szImageEditWndClass,
lpCaption,
OpenInfo->New.lpImageName,
WS_HSCROLL | WS_VSCROLL,
CW_USEDEFAULT,
CW_USEDEFAULT,

View file

@ -463,20 +463,23 @@ MainWndCommand(PMAIN_WND_INFO Info,
{
OPEN_IMAGE_EDIT_INFO OpenInfo;
PIMAGE_PROP ImageProp = NULL;
LPTSTR lpCaption = NULL;
LoadAndFormatString(hInstance,
IDS_IMAGE_NAME,
&lpCaption,
++Info->ImagesCreated);
ImageProp = (PIMAGE_PROP)DialogBox(hInstance,
MAKEINTRESOURCE(IDD_IMAGE_PROP),
Info->hSelf,
ImagePropDialogProc);
if (ImageProp != 0)
if (ImageProp)
{
/* if an image name isn't provided, load a default name */
if (! ImageProp->lpImageName)
LoadAndFormatString(hInstance,
IDS_IMAGE_NAME,
&OpenInfo.New.lpImageName,
++Info->ImagesCreated);
else
OpenInfo.New.lpImageName = ImageProp->lpImageName;
OpenInfo.CreateNew = TRUE;
OpenInfo.Type = ImageProp->Type;
OpenInfo.Resolution = ImageProp->Resolution;
@ -488,12 +491,9 @@ MainWndCommand(PMAIN_WND_INFO Info,
ImageProp);
CreateImageEditWindow(Info,
lpCaption,
&OpenInfo);
}
if (lpCaption != NULL)
LocalFree((HLOCAL)lpCaption);
break;
}

View file

@ -158,3 +158,42 @@ StatusBarLoadString(IN HWND hStatusBar,
return Ret;
}
INT
GetTextFromEdit(OUT LPTSTR lpString,
IN HWND hDlg,
IN UINT Res)
{
INT len = GetWindowTextLength(GetDlgItem(hDlg, Res));
if(len > 0)
{
GetDlgItemText(hDlg,
Res,
lpString,
len + 1);
}
else
lpString = NULL;
return len;
}
LONG
GetNumFromEdit(IN HWND hDlg,
IN UINT Res)
{
LONG num = 0;
INT len = GetWindowTextLength(GetDlgItem(hDlg, Res));
TCHAR buf[len+1];
if(len > 0)
{
GetDlgItemText(hDlg,
Res,
buf,
len + 1);
num = _ttol(buf);
}
return num;
}

View file

@ -42,8 +42,10 @@ INT_PTR CALLBACK AboutDialogProc(HWND hDlg,
/* imageprop.c */
typedef struct _IMAGE_PROP
{
LPTSTR lpImageName;
/* Canvas properties */
USHORT Type;
USHORT Unit;
LONG Resolution;
/* size of drawing area */
LONG Width;
@ -92,6 +94,7 @@ typedef struct _OPEN_IMAGE_EDIT_INFO
{
LONG Width;
LONG Height;
LPTSTR lpImageName;
} New;
struct
{
@ -127,7 +130,6 @@ typedef struct _EDIT_WND_INFO
BOOL CreateImageEditWindow(struct _MAIN_WND_INFO *MainWnd,
LPCTSTR lpCaption,
POPEN_IMAGE_EDIT_INFO OpenInfo);
VOID SetImageEditorEnvironment(PEDIT_WND_INFO Info,
BOOL Setup);
@ -300,4 +302,11 @@ BOOL StatusBarLoadString(IN HWND hStatusBar,
IN HINSTANCE hInstance,
IN UINT uID);
INT GetTextFromEdit(OUT LPTSTR lpString,
IN HWND hDlg,
IN UINT Res);
LONG GetNumFromEdit(IN HWND hDlg,
IN UINT Res);
#endif /* __IMAGESOFT_PRECOMP_H */

View file

@ -96,26 +96,24 @@
#define IDS_HINT_SYS_NEXT 21007
/* image property dialog */
#define IDD_IMAGE_PROP 4000
#define IDC_IMAGE_NAME_EDIT 4001
#define IDC_IMAGETYPE 4003
#define IDC_WIDTH_EDIT 4004
#define IDC_WIDTH_STAT 4005
#define IDC_HEIGHT_EDIT 4006
#define IDC_HEIGHT_STAT 4007
#define IDC_RES_EDIT 4008
#define IDC_RES_STAT 4009
#define IDC_UNIT 4010
#define IDC_IMAGE_SIZE 4011
#define IDD_IMAGE_PROP 4000
#define IDC_IMAGE_NAME_EDIT 4001
#define IDC_IMAGETYPE 4003
#define IDC_WIDTH_EDIT 4004
#define IDC_WIDTH_STAT 4005
#define IDC_HEIGHT_EDIT 4006
#define IDC_HEIGHT_STAT 4007
#define IDC_RES_EDIT 4008
#define IDC_RES_STAT 4009
#define IDC_UNIT 4010
#define IDC_IMAGE_SIZE 4011
#define IDS_IMAGE_MONOCHROME 4100
#define IDS_IMAGE_GREYSCALE 4101
#define IDS_IMAGE_PALETTE 4102
#define IDS_IMAGE_TRUECOLOR 4103
#define IDS_UNIT_CM 4104
#define IDS_UNIT_INCHES 4105
#define IDS_UNIT_PIXELS 4106
#define IDS_UNIT_DOTSCM 4107
#define IDS_UNIT_DPI 4108
#define IDS_IMAGE_GREYSCALE 4101
#define IDS_IMAGE_PALETTE 4102
#define IDS_IMAGE_TRUECOLOR 4103
#define IDS_UNIT_CM 4104
#define IDS_UNIT_INCHES 4105
#define IDS_UNIT_PIXELS 4106
#define IDS_UNIT_DOTSCM 4107
#define IDS_UNIT_DPI 4108