src/video/qtopia/SDL_QWin.h
author Ozkan Sezer <sezeroz@gmail.com>
Sun, 14 Oct 2018 15:25:04 +0300
branchSDL-1.2
changeset 12325 c4f2eeda176f
parent 6137 4720145f848b
permissions -rw-r--r--
remove symlink for libSDL-1.0.so.0 from the rpm spec file.

also fix a changelog date.
slouken@371
     1
/*
slouken@371
     2
    SDL - Simple DirectMedia Layer
slouken@6137
     3
    Copyright (C) 1997-2012 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@371
    37
extern "C" {
slouken@1361
    38
#include "../../events/SDL_events_c.h"
slouken@371
    39
};
slouken@371
    40
slouken@481
    41
typedef enum { 
slouken@481
    42
    SDL_QT_NO_ROTATION = 0, 
slouken@481
    43
    SDL_QT_ROTATION_90, 
slouken@481
    44
    SDL_QT_ROTATION_270 
slouken@481
    45
} screenRotationT;
slouken@481
    46
slouken@481
    47
extern screenRotationT screenRotation;
slouken@481
    48
slouken@371
    49
class SDL_QWin : public QWidget
slouken@371
    50
{
slouken@371
    51
  void QueueKey(QKeyEvent *e, int pressed);
slouken@371
    52
 public:
slouken@371
    53
  SDL_QWin(const QSize& size);
slouken@371
    54
  virtual ~SDL_QWin();
slouken@371
    55
  virtual bool shown(void) {
slouken@371
    56
    return isVisible();
slouken@371
    57
  }
slouken@371
    58
  /* If called, the next resize event will not be forwarded to SDL. */
slouken@371
    59
  virtual void inhibitResize(void) {
slouken@371
    60
    my_inhibit_resize = true;
slouken@371
    61
  }
slouken@371
    62
  void setImage(QImage *image);
slouken@371
    63
  void setOffset(int x, int y) {
slouken@371
    64
    my_offset = QPoint(x, y);
slouken@371
    65
  }
slouken@371
    66
  void GetXYOffset(int &x, int &y) {
slouken@371
    67
    x = my_offset.x();
slouken@371
    68
    y = my_offset.y();
slouken@371
    69
  }
slouken@567
    70
  QImage *image(void) { return my_image; }
slouken@371
    71
  
slouken@371
    72
  void setWFlags(WFlags flags) {
slouken@371
    73
    QWidget::setWFlags(flags);
slouken@371
    74
    my_flags = flags;
slouken@371
    75
  }
slouken@371
    76
  const QPoint& mousePos() const { return my_mouse_pos; }
slouken@379
    77
  void setMousePos(const QPoint& newpos);
slouken@371
    78
  void setFullscreen(bool);
slouken@371
    79
slouken@567
    80
  bool lockScreen(bool force=false);
slouken@567
    81
  void unlockScreen();
slouken@371
    82
  void repaintRect(const QRect& rect);
slouken@371
    83
 protected:
slouken@371
    84
  /* Handle resizing of the window */
slouken@371
    85
  virtual void resizeEvent(QResizeEvent *e);
slouken@371
    86
  void focusInEvent(QFocusEvent *);
slouken@371
    87
  void focusOutEvent(QFocusEvent *);
slouken@371
    88
  void closeEvent(QCloseEvent *e);
slouken@371
    89
  void mouseMoveEvent(QMouseEvent *e);
slouken@371
    90
  void mousePressEvent(QMouseEvent *e);
slouken@371
    91
  void mouseReleaseEvent(QMouseEvent *e);
slouken@371
    92
  void paintEvent(QPaintEvent *ev);
slouken@567
    93
  void keyPressEvent(QKeyEvent *e)   { QueueKey(e, 1); }
slouken@567
    94
  void keyReleaseEvent(QKeyEvent *e) { QueueKey(e, 0); }
slouken@371
    95
 private:
slouken@567
    96
  bool repaintRotation0(const QRect& rect);
slouken@567
    97
  bool repaintRotation1(const QRect& rect);
slouken@567
    98
  bool repaintRotation3(const QRect& rect);
slouken@371
    99
  void enableFullscreen();
slouken@371
   100
  QDirectPainter *my_painter;
slouken@371
   101
  QImage *my_image;
slouken@371
   102
  bool my_inhibit_resize;
slouken@371
   103
  QPoint my_offset;
slouken@371
   104
  QPoint my_mouse_pos;
slouken@371
   105
  WFlags my_flags;
slouken@371
   106
  WFlags my_has_fullscreen;
slouken@371
   107
  unsigned int my_locked;
slouken@371
   108
};
slouken@371
   109
slouken@371
   110
#endif /* _SDL_QWin_h */