twain: Add a property sheet UI for scanning.

This commit is contained in:
Aric Stewart 2006-03-22 13:34:22 -06:00 committed by Alexandre Julliard
parent bec4990cab
commit 8358c63e15
11 changed files with 1205 additions and 6 deletions

View file

@ -1 +1,2 @@
Makefile
rsrc.res

View file

@ -3,7 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = twain_32.dll
IMPORTS = user32 gdi32 kernel32 ntdll
IMPORTS = comctl32 user32 gdi32 kernel32 ntdll
EXTRALIBS = @SANELIBS@
EXTRAINCL = @SANEINCL@
@ -13,11 +13,15 @@ C_SRCS = \
ds_ctrl.c \
ds_image.c \
dsm_ctrl.c \
twain32_main.c
twain32_main.c \
ui.c
C_SRCS16 = \
twain16_main.c
RC_SRCS = \
rsrc.rc
SPEC_SRCS16 = twain.spec
@MAKE_DLL_RULES@

View file

@ -647,11 +647,20 @@ TW_UINT16 TWAIN_EnableDSUserInterface (pTW_IDENTITY pOrigin,
{
if (pUserInterface->ShowUI)
{
BOOL rc;
pSource->currentState = 5; /* Transitions to state 5 */
/* FIXME: we should replace xscanimage with our own device UI */
system ("xscanimage");
pSource->currentState = 6;
pSource->pendingEvent.TWMessage = MSG_XFERREADY;
rc = DoScannerUI(pSource);
if (!rc)
{
pSource->pendingEvent.TWMessage = MSG_CLOSEDSREQ;
}
#ifdef HAVE_SANE
else
{
sane_get_parameters (pSource->deviceHandle, &pSource->sane_param);
pSource->sane_param_valid = TRUE;
}
#endif
}
else
{

View file

@ -223,6 +223,12 @@ TW_UINT16 TWAIN_ImageMemXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
/* Transfer an image from the source to the application */
if (pSource->currentState == 6)
{
/* trigger scanning dialog */
pSource->progressWnd = ScanningDialogBox(NULL,0);
ScanningDialogBox(pSource->progressWnd,0);
status = sane_start (pSource->deviceHandle);
if (status != SANE_STATUS_GOOD)
{
@ -295,8 +301,11 @@ TW_UINT16 TWAIN_ImageMemXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
pImageMemXfer->YOffset = 0;
pImageMemXfer->BytesWritten = consumed_len;
ScanningDialogBox(pSource->progressWnd, consumed_len);
if (status == SANE_STATUS_EOF)
{
ScanningDialogBox(pSource->progressWnd, -1);
TRACE("sane_read: %s\n", sane_strstatus (status));
sane_cancel (pSource->deviceHandle);
twRC = TWRC_XFERDONE;
@ -305,6 +314,7 @@ TW_UINT16 TWAIN_ImageMemXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
}
else if (status != SANE_STATUS_EOF)
{
ScanningDialogBox(pSource->progressWnd, -1);
WARN("sane_read: %s\n", sane_strstatus (status));
sane_cancel (pSource->deviceHandle);
pSource->twCC = TWCC_OPERATIONERROR;

View file

@ -304,6 +304,7 @@ TW_UINT16 TWAIN_OpenDS (pTW_IDENTITY pOrigin, TW_MEMREF pData)
newSource = HeapAlloc (GetProcessHeap(), 0, sizeof (activeDS));
if (newSource)
{
newSource->deviceIndex = i;
status = sane_open(device_list[i]->name,&newSource->deviceHandle);
if (status == SANE_STATUS_GOOD)
{

23
dlls/twain/resource.h Normal file
View file

@ -0,0 +1,23 @@
/*
* Twain resource definitions
*
* Copyright 2006 CodeWeavers, Aric Stewart
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define IDD_DIALOG1 0x400
#define IDC_STATIC 0x401

28
dlls/twain/rsrc.rc Normal file
View file

@ -0,0 +1,28 @@
/*
* Top level resource file for Twain
*
* Copyright 2006 CodeWeavers, Aric Stewart
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winnls.h"
#include "resource.h"
#include "twain_En.rc"

View file

@ -39,6 +39,7 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
DSM_currentState = 2;
DSM_instance = hinstDLL;
break;
case DLL_PROCESS_DETACH:

40
dlls/twain/twain_En.rc Normal file
View file

@ -0,0 +1,40 @@
/*
* English resources for Twain
*
* Copyright 2006 CodeWeavers, Aric Stewart
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 186, 46
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | DS_CENTER | DS_SETFOREGROUND
CAPTION "Scanning"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "SCANNING.... Please Wait",IDC_STATIC,53,19,85,8
END
STRINGTABLE DISCARDABLE
{
0 ""
1 "px"
2 "b"
3 "mm"
4 "dpi"
5 "%"
6 "ns"
}

View file

@ -42,11 +42,13 @@ typedef struct tagActiveDS
application */
TW_UINT16 twCC; /* condition code */
HWND hwndOwner; /* window handle of the app */
HWND progressWnd; /* window handle of the scanning window */
#ifdef HAVE_SANE
SANE_Handle deviceHandle; /* device handle */
SANE_Parameters sane_param; /* parameters about the image
transferred */
BOOL sane_param_valid; /* true if valid sane_param*/
INT deviceIndex; /* index of the current device */
#endif
/* Capabiblities */
TW_UINT16 capXferMech; /* ICAP_XFERMECH */
@ -58,6 +60,8 @@ TW_UINT16 DSM_twCC; /* current condition code of Source Manager */
TW_HANDLE DSM_parentHWND; /* window handle of the Source's "parent" */
TW_UINT32 DSM_sourceId; /* source id generator */
TW_UINT16 DSM_currentDevice; /* keep track of device during enumeration */
HINSTANCE DSM_instance;
#ifdef HAVE_SANE
const SANE_Device **device_list;/* a list of all sane devices */
#endif
@ -244,4 +248,8 @@ TW_UINT16 TWAIN_AudioNativeXferGet
TW_UINT16 TWAIN_ICAPXferMech
(activeDS *pSource, pTW_CAPABILITY pCapability, TW_UINT16 action);
/* UI function */
BOOL DoScannerUI(activeDS *pSource);
HWND ScanningDialogBox(HWND dialog, DWORD progress);
#endif

1074
dlls/twain/ui.c Normal file

File diff suppressed because it is too large Load diff