summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qguifunctions_wince.cpp
blob: b6f825ba4f6df698f15c66b376cc4d24d7c1f420 (plain)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qguifunctions_wince.h"
#include <shellapi.h>
#include <QtCore/qlibrary.h>

QT_USE_NAMESPACE

struct AygSHINITDLGINFO
{
    DWORD dwMask;
    HWND  hDlg;
    DWORD dwFlags;
};

struct AygSIPINFO
{
    DWORD   cbSize;
    DWORD   fdwFlags;
    RECT    rcVisibleDesktop;
    RECT    rcSipRect;
    DWORD   dwImDataSize;
    void   *pvImData;
};

#ifndef SHIDIF_CANCELBUTTON
#define SHIDIF_CANCELBUTTON 0x0080
#endif

#ifndef SHIDIM_FLAGS
#define SHIDIM_FLAGS 0x0001
#endif

#ifndef SHIDIF_DONEBUTTON
#define SHIDIF_DONEBUTTON 0x0001
#endif
#ifndef SHIDIF_SIZEDLGFULLSCREEN
#define SHIDIF_SIZEDLGFULLSCREEN 0x0004
#endif

#ifndef SHFS_SHOWTASKBAR
#define SHFS_SHOWTASKBAR 0x0001
#endif
#ifndef SHFS_HIDETASKBAR
#define SHFS_HIDETASKBAR 0x0002
#endif
#ifndef SHFS_SHOWSIPBUTTON
#define SHFS_SHOWSIPBUTTON 0x0004
#endif
#ifndef SHFS_HIDESIPBUTTON
#define SHFS_HIDESIPBUTTON 0x0008
#endif
#ifndef SHFS_SHOWSTARTICON
#define SHFS_SHOWSTARTICON 0x0010
#endif
#ifndef SHFS_HIDESTARTICON
#define SHFS_HIDESTARTICON 0x0020
#endif

#ifndef SIPF_OFF
#define SIPF_OFF 0x00000000
#endif
#ifndef SIPF_ON
#define SIPF_ON 0x00000001
#endif

#ifndef SPI_SETSIPINFO
#define SPI_SETSIPINFO 224
#endif
#ifndef SPI_GETSIPINFO
#define SPI_GETSIPINFO 225
#endif

typedef BOOL (*AygInitDialog)(AygSHINITDLGINFO*);
typedef BOOL (*AygFullScreen)(HWND, DWORD);
typedef BOOL (*AygSHSipInfo)(UINT, UINT, PVOID, UINT);

static AygInitDialog ptrAygInitDialog = 0;
static AygFullScreen ptrAygFullScreen = 0;
static AygSHSipInfo  ptrAygSHSipInfo  = 0;
static bool aygResolved = false;

static void resolveAygLibs()
{
    if (!aygResolved) {
        aygResolved = true;
        QLibrary ayglib(QLatin1String("aygshell"));
        if (!ayglib.load())
            return;
        ptrAygInitDialog = (AygInitDialog) ayglib.resolve("SHInitDialog");
        ptrAygFullScreen = (AygFullScreen) ayglib.resolve("SHFullScreen");
        ptrAygSHSipInfo  = (AygSHSipInfo)  ayglib.resolve("SHSipInfo");
    }
}

struct DIBINFO : public BITMAPINFO
{
    RGBQUAD arColors[255];

    operator LPBITMAPINFO() { return (LPBITMAPINFO) this; }
    operator LPBITMAPINFOHEADER() { return &bmiHeader; }
    RGBQUAD* ColorTable() { return bmiColors; }
};

int qt_wince_GetDIBits(HDC /*hdc*/ , HBITMAP hSourceBitmap, uint, uint, LPVOID lpvBits, LPBITMAPINFO, uint)
{
    if (!lpvBits) {
        qWarning("::GetDIBits(), lpvBits NULL");
        return 0;
    }
    BITMAP bm;
    GetObject(hSourceBitmap, sizeof(BITMAP), &bm);
    bm.bmHeight = qAbs(bm.bmHeight);

    HBITMAP hTargetBitmap;
    void *pixels;

    BITMAPINFO dibInfo;
    memset(&dibInfo, 0, sizeof(dibInfo));
    dibInfo.bmiHeader.biBitCount = 32;
    dibInfo.bmiHeader.biClrImportant = 0;
    dibInfo.bmiHeader.biClrUsed = 0;
    dibInfo.bmiHeader.biCompression = BI_RGB;;
    dibInfo.bmiHeader.biHeight = -bm.bmHeight;
    dibInfo.bmiHeader.biWidth = bm.bmWidth;
    dibInfo.bmiHeader.biPlanes = 1;
    dibInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    dibInfo.bmiHeader.biSizeImage = bm.bmWidth * bm.bmHeight * 4;

    HDC displayDC = GetDC(NULL);
    if (!displayDC) {
        qWarning("::GetDIBits(), failed to GetDC");
        return 0;
    }

    int ret = bm.bmHeight;

    hTargetBitmap = CreateDIBSection(displayDC, (const BITMAPINFO*) &dibInfo, DIB_RGB_COLORS,
                                    (void**)&pixels, NULL, 0);
    if (!hTargetBitmap) {
        qWarning("::GetDIBits(), failed to CreateDIBSection");
        return 0;
    }

    HDC hdcSrc = CreateCompatibleDC(displayDC);
    HDC hdcDst = CreateCompatibleDC(displayDC);

    if (!(hdcDst && hdcSrc)) {
        qWarning("::GetDIBits(), failed to CreateCompatibleDC");
        ret = 0;
    }

    HBITMAP hOldBitmap1 = (HBITMAP) SelectObject(hdcSrc, hSourceBitmap);
    HBITMAP hOldBitmap2 = (HBITMAP) SelectObject(hdcDst, hTargetBitmap);

    if (!(hOldBitmap1 && hOldBitmap2)) {
        qWarning("::GetDIBits(), failed to SelectObject for bitmaps");
        ret = 0;
    }

    if (!BitBlt(hdcDst, 0, 0, bm.bmWidth, bm.bmHeight, hdcSrc, 0, 0, SRCCOPY)) {
        qWarning("::GetDIBits(), BitBlt failed");
        ret = 0;
    }

    SelectObject(hdcSrc, hOldBitmap1);
    SelectObject(hdcDst, hOldBitmap2);

    DeleteDC(hdcSrc);
    DeleteDC(hdcDst);

    ReleaseDC(NULL, displayDC);

    memcpy(lpvBits, pixels, dibInfo.bmiHeader.biSizeImage);

    DeleteObject(hTargetBitmap);
    return ret;
}

bool qt_wince_TextOutW(HDC hdc, int x, int y, LPWSTR lpString, UINT c)
{
    return ExtTextOutW(hdc, x, y, 0, NULL, lpString, c, NULL);
}


HINSTANCE qt_wince_ShellExecute(HWND hwnd, LPCTSTR, LPCTSTR file, LPCTSTR params, LPCTSTR dir, int showCmd)
{
    SHELLEXECUTEINFO info;
    info.hwnd = hwnd;
    info.lpVerb = L"Open";
    info.lpFile = file;
    info.lpParameters = params;
    info.lpDirectory = dir;
    info.nShow = showCmd;
    info.cbSize = sizeof(info);
    ShellExecuteEx(&info);
    return info.hInstApp;
}

// Clipboard --------------------------------------------------------
BOOL qt_wince_ChangeClipboardChain( HWND /*hWndRemove*/, HWND /*hWndNewNext*/ )
{
    return FALSE;
}

HWND qt_wince_SetClipboardViewer( HWND /*hWndNewViewer*/ )
{
    return NULL;
}


// Graphics ---------------------------------------------------------
COLORREF qt_wince_PALETTEINDEX( WORD /*wPaletteIndex*/)
{
    return 0;
}

BOOL qt_wince_TextOut( HDC hdc, int nXStart, int nYStart, LPCTSTR lpString, int cbString )
{
    return ExtTextOut( hdc, nXStart, nYStart - 16, 0, NULL, lpString, cbString, NULL );
}

// Internal Qt -----------------------------------------------------
bool qt_wince_is_platform(const QString &platformString) {
    TCHAR tszPlatform[64];
    if (SystemParametersInfo(SPI_GETPLATFORMTYPE,
                             sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0))
      if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform))
            return true;
    return false;
}

bool qt_wince_is_pocket_pc() {
    return qt_wince_is_platform(QString::fromLatin1("PocketPC"));
}

bool qt_wince_is_smartphone() {
       return qt_wince_is_platform(QString::fromLatin1("Smartphone"));
}
bool qt_wince_is_mobile() {
     return (qt_wince_is_smartphone() || qt_wince_is_pocket_pc());
}

bool qt_wince_is_high_dpi() {
    if (!qt_wince_is_pocket_pc())
        return false;
    HDC deviceContext = GetDC(0);
    int dpi = GetDeviceCaps(deviceContext, LOGPIXELSX);
    ReleaseDC(0, deviceContext);
    if ((dpi < 1000) && (dpi > 0))
        return dpi > 96;
    else
        return false;
}

void qt_wince_maximize(QWidget *widget)
{
    HWND hwnd = widget->winId();
    if (qt_wince_is_mobile()) {
        AygSHINITDLGINFO shidi;
        shidi.dwMask = SHIDIM_FLAGS;
        shidi.hDlg = hwnd;
        shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;
        if (widget->windowFlags() & Qt::WindowCancelButtonHint)
            shidi.dwFlags |= SHIDIF_CANCELBUTTON;
        if (widget->windowFlags() & Qt::WindowOkButtonHint)
            shidi.dwFlags |= SHIDIF_DONEBUTTON;
        resolveAygLibs();
        if (ptrAygInitDialog)
            ptrAygInitDialog(&shidi);
    } else {
        RECT r;
        SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
        MoveWindow(hwnd, r.top, r.left, r.right - r.left, r.bottom - r.top, true);
        SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong (hwnd, GWL_EXSTYLE) | WS_EX_NODRAG);
    }
}

void qt_wince_minimize(HWND hwnd) {

    uint exstyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
    uint style = GetWindowLongW(hwnd, GWL_STYLE);
    RECT rect;
    RECT crect = {0,0,0,0};
    GetWindowRect(hwnd, &rect);
    AdjustWindowRectEx(&crect, style & ~WS_OVERLAPPED, FALSE, exstyle);
    MoveWindow(hwnd, rect.left - crect.left, rect.top - crect.top, 0, 0, true);
    SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong (hwnd, GWL_EXSTYLE) | WS_EX_NODRAG);
    ShowWindow(hwnd, SW_HIDE);
}


void qt_wince_hide_taskbar(HWND hwnd) {
    if (ptrAygFullScreen)
        ptrAygFullScreen(hwnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON);
}

void qt_wince_full_screen(HWND hwnd, bool fullScreen, UINT swpf) {
    resolveAygLibs();
    if (fullScreen) {
        QRect r = qApp->desktop()->screenGeometry(QWidget::find(hwnd));
        SetWindowPos(hwnd, HWND_TOP, r.left(), r.top(), r.width(), r.height(), swpf);
        if (ptrAygFullScreen)
            ptrAygFullScreen(hwnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON);
        if (!qt_wince_is_mobile()) {
            HWND handle = FindWindow(L"HHTaskBar", L"");
            if (handle) {
                ShowWindow(handle, 0);
                EnableWindow(handle, false);
            }
        }
    } else {
        if (ptrAygFullScreen)
            ptrAygFullScreen(hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON | SHFS_SHOWSTARTICON);
        SetWindowPos(hwnd, 0, 0, 0, 0, 0, swpf);
        if (!qt_wince_is_mobile()) {
            HWND handle = FindWindow(L"HHTaskBar", L"");
            if (handle) {
                ShowWindow(handle, 1);
                EnableWindow(handle, true);
            }
        }
    }
}

void qt_wince_show_SIP(bool show)
{
    resolveAygLibs();
    if (!ptrAygSHSipInfo)
        return;

    AygSIPINFO si;
    memset(&si, 0, sizeof(si));
    si.cbSize = sizeof(si);
    ptrAygSHSipInfo(SPI_GETSIPINFO, 0, &si, 0);
    si.cbSize = sizeof(si);
    si.fdwFlags = (show ? SIPF_ON : SIPF_OFF);
    ptrAygSHSipInfo(SPI_SETSIPINFO, 0, &si, 0);
}
dgp_revise_parsedvarnametype'>plain -rw-r--r--bn_mp_exch.c766logstatsplain -rw-r--r--bn_mp_expt_d.c1276logstatsplain -rw-r--r--bn_mp_exptmod.c2787logstatsplain -rw-r--r--bn_mp_exptmod_fast.c7990logstatsplain -rw-r--r--bn_mp_exteuclid.c3111logstatsplain -rw-r--r--bn_mp_fread.c1441logstatsplain -rw-r--r--bn_mp_fwrite.c1112logstatsplain -rw-r--r--bn_mp_gcd.c2513logstatsplain -rw-r--r--bn_mp_get_int.c1117logstatsplain -rw-r--r--bn_mp_grow.c1458logstatsplain -rw-r--r--bn_mp_init.c1058logstatsplain -rw-r--r--bn_mp_init_copy.c759logstatsplain -rw-r--r--bn_mp_init_multi.c1702logstatsplain -rw-r--r--bn_mp_init_set.c750logstatsplain -rw-r--r--bn_mp_init_set_int.c760logstatsplain -rw-r--r--bn_mp_init_size.c1073logstatsplain -rw-r--r--bn_mp_invmod.c1003logstatsplain -rw-r--r--bn_mp_invmod_slow.c4044logstatsplain -rw-r--r--bn_mp_is_square.c3114logstatsplain -rw-r--r--bn_mp_jacobi.c2249logstatsplain -rw-r--r--bn_mp_karatsuba_mul.c4765logstatsplain -rw-r--r--bn_mp_karatsuba_sqr.c2965logstatsplain -rw-r--r--bn_mp_lcm.c1446logstatsplain -rw-r--r--bn_mp_lshd.c1529logstatsplain -rw-r--r--bn_mp_mod.c974logstatsplain -rw-r--r--bn_mp_mod_2d.c1372logstatsplain -rw-r--r--bn_mp_mod_d.c658logstatsplain -rw-r--r--bn_mp_montgomery_calc_normalization.c1477logstatsplain -rw-r--r--bn_mp_montgomery_reduce.c3005logstatsplain -rw-r--r--bn_mp_montgomery_setup.c1517logstatsplain -rw-r--r--bn_mp_mul.c1716logstatsplain -rw-r--r--bn_mp_mul_2.c1855logstatsplain -rw-r--r--bn_mp_mul_2d.c1915logstatsplain -rw-r--r--bn_mp_mul_d.c1762logstatsplain -rw-r--r--bn_mp_mulmod.c894logstatsplain -rw-r--r--bn_mp_n_root.c2866logstatsplain -rw-r--r--bn_mp_neg.c880logstatsplain -rw-r--r--bn_mp_or.c1069logstatsplain -rw-r--r--bn_mp_prime_fermat.c1415logstatsplain -rw-r--r--bn_mp_prime_is_divisible.c1152logstatsplain -rw-r--r--bn_mp_prime_is_prime.c1820logstatsplain -rw-r--r--bn_mp_prime_miller_rabin.c2341logstatsplain -rw-r--r--bn_mp_prime_next_prime.c4672logstatsplain -rw-r--r--bn_mp_prime_rabin_miller_trials.c1171logstatsplain -rw-r--r--bn_mp_prime_random_ex.c3632logstatsplain -rw-r--r--bn_mp_radix_size.c1828logstatsplain -rw-r--r--bn_mp_radix_smap.c703logstatsplain -rw-r--r--bn_mp_rand.c1149logstatsplain -rw-r--r--bn_mp_read_radix.c2093logstatsplain -rw-r--r--bn_mp_read_signed_bin.c1012logstatsplain -rw-r--r--bn_mp_read_unsigned_bin.c1256logstatsplain -rw-r--r--bn_mp_reduce.c2321logstatsplain -rw-r--r--bn_mp_reduce_2k.c1278logstatsplain -rw-r--r--bn_mp_reduce_2k_l.c1325logstatsplain -rw-r--r--bn_mp_reduce_2k_setup.c1046logstatsplain -rw-r--r--bn_mp_reduce_2k_setup_l.c969logstatsplain -rw-r--r--bn_mp_reduce_is_2k.c1208logstatsplain -rw-r--r--bn_mp_reduce_is_2k_l.c1067logstatsplain -rw-r--r--bn_mp_reduce_setup.c889logstatsplain -rw-r--r--bn_mp_rshd.c1562logstatsplain -rw-r--r--bn_mp_set.c707logstatsplain -rw-r--r--bn_mp_set_int.c1108logstatsplain -rw-r--r--bn_mp_shrink.c904logstatsplain -rw-r--r--bn_mp_signed_bin_size.c701logstatsplain -rw-r--r--bn_mp_sqr.c1293logstatsplain -rw-r--r--bn_mp_sqrmod.c879logstatsplain -rw-r--r--bn_mp_sqrt.c3093logstatsplain -rw-r--r--bn_mp_sub.c1603logstatsplain -rw-r--r--bn_mp_sub_d.c2038logstatsplain -rw-r--r--bn_mp_submod.c895logstatsplain -rw-r--r--bn_mp_to_signed_bin.c843logstatsplain -rw-r--r--bn_mp_to_signed_bin_n.c854logstatsplain -rw-r--r--bn_mp_to_unsigned_bin.c1131logstatsplain -rw-r--r--bn_mp_to_unsigned_bin_n.c866logstatsplain -rw-r--r--bn_mp_toom_mul.c7022logstatsplain -rw-r--r--bn_mp_toom_sqr.c5283logstatsplain -rw-r--r--bn_mp_toradix.c1641logstatsplain -rw-r--r--bn_mp_toradix_n.c1981logstatsplain -rw-r--r--bn_mp_unsigned_bin_size.c753logstatsplain -rw-r--r--bn_mp_xor.c1073logstatsplain -rw-r--r--bn_mp_zero.c756logstatsplain -rw-r--r--bn_prime_tab.c2745logstatsplain -rw-r--r--bn_reverse.c820logstatsplain -rw-r--r--bn_s_mp_add.c2343logstatsplain -rw-r--r--bn_s_mp_exptmod.c6017logstatsplain -rw-r--r--bn_s_mp_mul_digs.c2399logstatsplain -rw-r--r--bn_s_mp_mul_high_digs.c2110logstatsplain -rw-r--r--bn_s_mp_sqr.c2267logstatsplain -rw-r--r--bn_s_mp_sub.c2128logstatsplain -rw-r--r--bncore.c1230logstatsplain -rw-r--r--booker.pl7912logstatsplain -rw-r--r--callgraph.txt409058logstatsplain -rw-r--r--changes.txt24739logstatsplain d---------demo70logstatsplain -rw-r--r--dep.pl3042logstatsplain d---------etc561logstatsplain -rw-r--r--gen.pl586logstatsplain d---------logs672logstatsplain