1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _TWAIN_HXX
25 #define _TWAIN_HXX
26 
27 #include <vos/module.hxx>
28 #include <vcl/bitmap.hxx>
29 #include "twain/twain.h"
30 
31 
32 // -----------
33 // - Defines -
34 // -----------
35 
36 #define TWAIN_SELECT			0x00000001UL
37 #define TWAIN_ACQUIRE			0x00000002UL
38 #define TWAIN_TERMINATE			0xFFFFFFFFUL
39 
40 #define TWAIN_EVENT_NONE		0x00000000UL
41 #define TWAIN_EVENT_QUIT		0x00000001UL
42 #define TWAIN_EVENT_SCANNING	0x00000002UL
43 #define TWAIN_EVENT_XFER		0x00000004UL
44 
45 // ------------
46 // - ImpTwain -
47 // ------------
48 
49 class ImpTwain
50 {
51 	TW_IDENTITY					aAppIdent;
52 	TW_IDENTITY					aSrcIdent;
53 	Link						aNotifyLink;
54 	Bitmap						aBitmap;
55 	DSMENTRYPROC				pDSM;
56 	vos:: OModule *	pMod;
57 	sal_uLong						nCurState;
58 
59 	void						ImplCreate();
60 	void						ImplOpenSourceManager();
61 	void						ImplOpenSource();
62 	sal_Bool						ImplEnableSource();
63 	void						ImplXfer();
64 	void						ImplFallback( sal_uLong nEvent );
65 
66 								DECL_LINK( ImplFallbackHdl, void* );
67 								DECL_LINK( ImplDestroyHdl, void* );
68 
69 public:
70 
71 	sal_Bool						ImplHandleMsg( void* pMsg );
72 
73 #ifdef OS2
74 	HAB							hAB;
75 	HWND						hTwainWnd;
76 	long						hTwainHook;
77 #else
78 	HWND						hTwainWnd;
79 	HHOOK						hTwainHook;
80 #endif
81 
82 public:
83 
84 								ImpTwain( const Link& rNotifyLink );
85 								~ImpTwain();
86 
87 	void						Destroy();
88 
89 	sal_Bool						SelectSource();
90 	sal_Bool						InitXfer();
91 	Bitmap						GetXferBitmap();
92 };
93 
94 #endif // _TWAIN_HXX
95