1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
/* ============================================================
*
* This file is a part of kdegraphics
*
* Date : 2009-05-12
* Description : Twain interface
*
* Copyright (C) 2002-2003 Stephan Stapel <stephan dot stapel at web dot de>
* Copyright (C) 2008-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2009,2017 by Kare Sars <kare dot sars at iki dot fi>
*
* 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) version 3, or any
* later version accepted by the membership of KDE e.V. (or its
* successor approved by the membership of KDE e.V.), which shall
* act as a proxy defined in Section 6 of version 3 of the license.
*
* 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 program. If not, see <http://www.gnu.org/licenses/>.
*
* ============================================================ */
#ifndef TWAINIFACE_H
#define TWAINIFACE_H
#include "twain.h"
// Windows includes
#include <windows.h>
#include <QWidget>
namespace KSaneIface
{
class KSaneWidgetPrivate : public QWidget
{
Q_OBJECT
public:
KSaneWidgetPrivate();
~KSaneWidgetPrivate();
/**
* Hook-in. See class documentation for details!
* @result One should return false to get the message being
* processed by the application (should return false by default!)
*/
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
void CloseDSM();
QString SelectSource();
bool OpenSource(const QString &device);
public Q_SLOTS:
bool OpenDialog();
bool ReOpenDialog();
Q_SIGNALS:
void ImageReady(QByteArray &data, int width, int height, int bytes_per_line, int format);
private:
bool InitTwain();
void ReleaseTwain();
bool ProcessMessage(MSG msg);
bool SetImageCount(TW_INT16 nCount = 1);
bool DSIsOpen() const;
bool CallTwainProc(pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
TW_UINT32 DG, TW_UINT16 DAT, TW_UINT16 MSG,
TW_MEMREF pData);
bool EnableSource(bool showUI);
void CloseDS();
bool GetCapability(TW_CAPABILITY &twCap, TW_UINT16 cap, TW_UINT16 conType = TWON_DONTCARE16);
bool GetCapability(TW_UINT16 cap, TW_UINT32 &value);
bool SetCapability(TW_UINT16 cap, TW_UINT16 value, bool sign = false);
bool SetCapability(TW_CAPABILITY &twCap);
bool GetImageInfo(TW_IMAGEINFO &info);
void TranslateMessage(TW_EVENT &twEvent);
void TransferImage();
bool EndTransfer();
void CancelTransfer();
bool GetImage(TW_IMAGEINFO &info);
void ImageData(TW_MEMREF pdata, TW_IMAGEINFO &info);
protected:
bool m_bDSMOpen;
bool m_bDSOpen;
bool m_bSourceEnabled;
bool m_bModalUI;
int m_nImageCount;
HINSTANCE m_hTwainDLL;
DSMENTRYPROC m_pDSMProc;
TW_IDENTITY m_AppId;
TW_IDENTITY m_Source;
TW_STATUS m_Status;
TW_INT16 m_returnCode;
HWND m_hMessageWnd;
};
}
#endif /* TWAINIFACE_H */
|