src/video/qtopia/SDL_QWin.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 29 May 2006 04:04:35 +0000
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
permissions -rw-r--r--
more tweaking indent options
slouken@371
     1
/*
slouken@371
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@371
     4
slouken@371
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@371
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@371
     9
slouken@371
    10
    This library is distributed in the hope that it will be useful,
slouken@371
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@371
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@371
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@371
    18
slouken@371
    19
    Sam Lantinga
slouken@371
    20
    slouken@libsdl.org
slouken@371
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@371
    23
slouken@371
    24
#ifndef _SDL_QWin_h
slouken@371
    25
#define _SDL_QWin_h
slouken@1330
    26
slouken@371
    27
#include <stdio.h>
slouken@371
    28
slouken@371
    29
#include <qimage.h>
slouken@371
    30
#include <qpixmap.h>
slouken@371
    31
#include <qwidget.h>
slouken@371
    32
#include <qpainter.h>
slouken@371
    33
#include <qdirectpainter_qws.h>
slouken@371
    34
slouken@371
    35
#include "SDL_events.h"
slouken@371
    36
slouken@1662
    37
extern "C"
slouken@1662
    38
{
slouken@1361
    39
#include "../../events/SDL_events_c.h"
slouken@371
    40
};
slouken@371
    41
slouken@1662
    42
typedef enum
slouken@1662
    43
{
slouken@1662
    44
    SDL_QT_NO_ROTATION = 0,
slouken@1662
    45
    SDL_QT_ROTATION_90,
slouken@1662
    46
    SDL_QT_ROTATION_270
slouken@481
    47
} screenRotationT;
slouken@481
    48
slouken@481
    49
extern screenRotationT screenRotation;
slouken@481
    50
slouken@1662
    51
class SDL_QWin:public QWidget
slouken@371
    52
{
slouken@1668
    53
    void QueueKey(QKeyEvent * e, int pressed);
slouken@1662
    54
  public:
slouken@1668
    55
      SDL_QWin(const QSize & size);
slouken@1668
    56
      virtual ~ SDL_QWin();
slouken@1668
    57
    virtual bool shown(void)
slouken@1662
    58
    {
slouken@1668
    59
        return isVisible();
slouken@1662
    60
    }
slouken@1662
    61
    /* If called, the next resize event will not be forwarded to SDL. */
slouken@1668
    62
    virtual void inhibitResize(void)
slouken@1662
    63
    {
slouken@1662
    64
        my_inhibit_resize = true;
slouken@1662
    65
    }
slouken@1668
    66
    void setImage(QImage * image);
slouken@1668
    67
    void setOffset(int x, int y)
slouken@1662
    68
    {
slouken@1668
    69
        my_offset = QPoint(x, y);
slouken@1662
    70
    }
slouken@1668
    71
    void GetXYOffset(int &x, int &y)
slouken@1662
    72
    {
slouken@1668
    73
        x = my_offset.x();
slouken@1668
    74
        y = my_offset.y();
slouken@1662
    75
    }
slouken@1668
    76
    QImage *image(void)
slouken@1662
    77
    {
slouken@1662
    78
        return my_image;
slouken@1662
    79
    }
slouken@371
    80
slouken@1668
    81
    void setWFlags(WFlags flags)
slouken@1662
    82
    {
slouken@1668
    83
        QWidget::setWFlags(flags);
slouken@1662
    84
        my_flags = flags;
slouken@1662
    85
    }
slouken@1668
    86
    const QPoint & mousePos() const
slouken@1662
    87
    {
slouken@1662
    88
        return my_mouse_pos;
slouken@1662
    89
    }
slouken@1668
    90
    void setMousePos(const QPoint & newpos);
slouken@1668
    91
    void setFullscreen(bool);
slouken@1662
    92
slouken@1668
    93
    bool lockScreen(bool force = false);
slouken@1668
    94
    void unlockScreen();
slouken@1668
    95
    void repaintRect(const QRect & rect);
slouken@1662
    96
  protected:
slouken@1662
    97
    /* Handle resizing of the window */
slouken@1668
    98
    virtual void resizeEvent(QResizeEvent * e);
slouken@1668
    99
    void focusInEvent(QFocusEvent *);
slouken@1668
   100
    void focusOutEvent(QFocusEvent *);
slouken@1668
   101
    void closeEvent(QCloseEvent * e);
slouken@1668
   102
    void mouseMoveEvent(QMouseEvent * e);
slouken@1668
   103
    void mousePressEvent(QMouseEvent * e);
slouken@1668
   104
    void mouseReleaseEvent(QMouseEvent * e);
slouken@1668
   105
    void paintEvent(QPaintEvent * ev);
slouken@1668
   106
    void keyPressEvent(QKeyEvent * e)
slouken@1662
   107
    {
slouken@1668
   108
        QueueKey(e, 1);
slouken@1662
   109
    }
slouken@1668
   110
    void keyReleaseEvent(QKeyEvent * e)
slouken@1662
   111
    {
slouken@1668
   112
        QueueKey(e, 0);
slouken@1662
   113
    }
slouken@1662
   114
  private:
slouken@1668
   115
    bool repaintRotation0(const QRect & rect);
slouken@1668
   116
    bool repaintRotation1(const QRect & rect);
slouken@1668
   117
    bool repaintRotation3(const QRect & rect);
slouken@1668
   118
    void enableFullscreen();
slouken@1662
   119
    QDirectPainter *my_painter;
slouken@1662
   120
    QImage *my_image;
slouken@1662
   121
    bool my_inhibit_resize;
slouken@1662
   122
    QPoint my_offset;
slouken@1662
   123
    QPoint my_mouse_pos;
slouken@1662
   124
    WFlags my_flags;
slouken@1662
   125
    WFlags my_has_fullscreen;
slouken@1662
   126
    unsigned int my_locked;
slouken@371
   127
};
slouken@371
   128
slouken@371
   129
#endif /* _SDL_QWin_h */
slouken@1662
   130
/* vi: set ts=4 sw=4 expandtab: */