QGraphicsView.hs 11.6 KB
Newer Older
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
-- This file is part of Qtah.
--
-- Copyright 2015-2017 Bryan Gardiner <bog@khumba.net>
--
-- This program 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 3 of the License, or
-- (at your option) any later version.
--
-- This program 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/>.

module Graphics.UI.Qtah.Generator.Interface.Widgets.QGraphicsView (
  aModule,
  c_QGraphicsView,
  e_DragMode,
  e_ViewportAnchor,
  e_ViewportUpdateMode,
  e_OptimizationFlag,
  e_CacheModeFlag,
  bs_CacheMode,
  bs_OptimizationFlags
  ) where

import Foreign.Hoppy.Generator.Spec (
  Export (ExportClass, ExportEnum, ExportBitspace),
  addReqIncludes,
  classSetEntityPrefix,
  ident,
  ident1,
  includeStd,
  makeClass,
  mkMethod,
  mkMethod',
  mkConstMethod,
  mkConstMethod',
  mkCtor
  )
Roman 3237465's avatar
Roman 3237465 committed
44 45 46 47 48 49 50 51 52 53 54
import Foreign.Hoppy.Generator.Types (
  objT,
  constT,
  ptrT,
  intT,
  voidT,
  enumT,
  boolT,
  doubleT,
  bitspaceT,
  )
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
import Graphics.UI.Qtah.Generator.Interface.Core.Types hiding (aModule)
import Graphics.UI.Qtah.Generator.Interface.Core.QPoint (c_QPoint)
import Graphics.UI.Qtah.Generator.Interface.Core.QPointF (c_QPointF)
import Graphics.UI.Qtah.Generator.Interface.Core.QRect (c_QRect)
import Graphics.UI.Qtah.Generator.Interface.Core.QRectF (c_QRectF)
import Graphics.UI.Qtah.Generator.Interface.Gui.QBrush (c_QBrush)
import Graphics.UI.Qtah.Generator.Interface.Gui.QPainter (c_QPainter, e_RenderHint, bs_RenderHints)
import Graphics.UI.Qtah.Generator.Interface.Gui.QPolygon (c_QPolygon)
import Graphics.UI.Qtah.Generator.Interface.Gui.QPolygonF (c_QPolygonF)
import Graphics.UI.Qtah.Generator.Interface.Gui.QTransform (c_QTransform)
-- import Graphics.UI.Qtah.Generator.Interface.Gui.QPainter
import Graphics.UI.Qtah.Generator.Interface.Gui.QPainterPath (c_QPainterPath)
import Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractScrollArea (c_QAbstractScrollArea)
import Graphics.UI.Qtah.Generator.Interface.Widgets.QGraphicsItem (c_QGraphicsItem)
import Graphics.UI.Qtah.Generator.Interface.Widgets.QGraphicsScene (c_QGraphicsScene)
70
import Graphics.UI.Qtah.Generator.Interface.Widgets.QWidget (c_QWidget)
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
import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), makeQtModule)
import Graphics.UI.Qtah.Generator.Types

{-# ANN module "HLint: ignore Use camelCase" #-}

aModule =
  AQtModule $
  makeQtModule ["Widgets", "QGraphicsView"] $
  (QtExport $ ExportClass c_QGraphicsView) :
  map (QtExport . ExportEnum)
    [ e_CacheModeFlag
    , e_DragMode
    , e_OptimizationFlag
    , e_ViewportAnchor
    , e_ViewportUpdateMode
    ] ++
  map (QtExport . ExportBitspace)
    [ bs_CacheMode
    , bs_OptimizationFlags
    ]

c_QGraphicsView =
  addReqIncludes [includeStd "QGraphicsView"] $
  classSetEntityPrefix "" $
  makeClass (ident "QGraphicsView") Nothing [c_QAbstractScrollArea]
  [ mkCtor "new" []
  , mkCtor "newWithScene" [ptrT $ objT c_QGraphicsScene]
98 99
  , mkCtor "newWithParent" [ptrT $ objT c_QWidget]
  , mkCtor "newWithSceneAndParent" [ptrT $ objT c_QGraphicsScene, ptrT $ objT c_QWidget]
100 101 102 103 104 105 106 107
  , mkConstMethod "alignment" [] $ bitspaceT bs_Alignment
  , mkConstMethod "backgroundBrush" [] $ objT c_QBrush
  , mkConstMethod "cacheMode" [] $ bitspaceT bs_CacheMode
  , mkMethod' "centerOn" "centerOnPointF" [objT c_QPointF] voidT
  , mkMethod' "centerOn" "centerOnRaw" [doubleT, doubleT] voidT
  , mkMethod' "centerOn" "centerOnItem" [ptrT $ constT $ objT c_QGraphicsItem] voidT
  , mkConstMethod "dragMode" [] $ enumT e_DragMode
  , mkMethod' "ensureVisible" "ensureVisibleRectF" [objT c_QRectF] voidT
Roman 3237465's avatar
Roman 3237465 committed
108 109 110 111 112 113 114 115 116 117
  , mkMethod' "ensureVisible" "ensureVisibleRaw"
      [doubleT, doubleT, doubleT, doubleT] voidT
  , mkMethod' "ensureVisible" "ensureVisibleItem"
      [ptrT $ constT $ objT c_QGraphicsItem] voidT
  , mkMethod' "ensureVisible" "ensureVisibleRectFAll"
      [objT c_QRectF, intT, intT] voidT
  , mkMethod' "ensureVisible" "ensureVisibleRawAll"
      [doubleT, doubleT, doubleT, doubleT, intT, intT] voidT
  , mkMethod' "ensureVisible" "ensureVisibleItemAll"
      [ptrT $ constT $ objT c_QGraphicsItem, intT, intT] voidT
118 119 120 121
  , mkMethod' "fitInView" "fitInViewRectF" [objT c_QRectF] voidT
  , mkMethod' "fitInView" "fitInViewRect" [doubleT, doubleT, doubleT, doubleT] voidT
  , mkMethod' "fitInView" "fitInViewItem" [ptrT $ constT $ objT c_QGraphicsItem] voidT
  , mkMethod' "fitInView" "fitInViewRectFAll" [objT c_QRectF, enumT e_AspectRatioMode] voidT
Roman 3237465's avatar
Roman 3237465 committed
122 123 124 125
  , mkMethod' "fitInView" "fitInViewRectAll"
      [doubleT, doubleT, doubleT, doubleT, enumT e_AspectRatioMode] voidT
  , mkMethod' "fitInView" "fitInViewItemAll"
      [ptrT $ constT $ objT c_QGraphicsItem, enumT e_AspectRatioMode] voidT
126 127 128 129 130 131 132 133
  , mkConstMethod "foregroundBrush" [] $ objT c_QBrush
  , mkConstMethod "isInteractive" [] boolT
  , mkConstMethod "isTransformed" [] boolT
  , mkConstMethod' "itemAt" "itemAtPoint" [objT c_QPoint] $ ptrT $ objT c_QGraphicsItem
  , mkConstMethod' "itemAt" "itemAtRaw" [intT, intT] $ ptrT $ objT c_QGraphicsItem
  -- TODO mkConstMethod "items" [] $ objT c_QList<QGraphicsItem $ objT c_*>
  -- TODO mkConstMethod "items" [objT c_QPoint] $ objT c_QList<QGraphicsItem $ objT c_*>
  -- TODO mkConstMethod "items" [intT, intT] $ objT c_QList<QGraphicsItem $ objT c_*>
Roman 3237465's avatar
Roman 3237465 committed
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
  -- TODO mkConstMethod "items" [intT, intT, intT, intT, objT c_Qt::ItemSelectionMode] $
  --   objT c_QList<QGraphicsItem $ objT c_*>
  -- TODO mkConstMethod "items" [objT c_QRect, objT c_Qt::ItemSelectionMode] $
  --   objT c_QList<QGraphicsItem $ objT c_*>
  -- TODO mkConstMethod "items" [objT c_QPolygon, objT c_Qt::ItemSelectionMode] $
  --   objT c_QList<QGraphicsItem $ objT c_*>
  -- TODO mkConstMethod "items" [objT c_QPainterPath, objT c_Qt::ItemSelectionMode] $
  --   objT c_QList<QGraphicsItem $ objT c_*>
  , mkConstMethod' "mapFromScene" "mapFromScenePointF"
      [objT c_QPointF] $ objT c_QPoint
  , mkConstMethod' "mapFromScene" "mapFromSceneRectF"
      [objT c_QRectF] $ objT c_QPolygon
  , mkConstMethod' "mapFromScene" "mapFromScenePolygonF"
      [objT c_QPolygonF] $ objT c_QPolygon
  , mkConstMethod' "mapFromScene" "mapFromScenePainterPath"
      [objT c_QPainterPath] $ objT c_QPainterPath
  , mkConstMethod' "mapFromScene" "mapFromScenePointFRaw"
      [doubleT, doubleT] $ objT c_QPoint
  , mkConstMethod' "mapFromScene" "mapFromSceneRectFRaw"
      [doubleT, doubleT, doubleT, doubleT] $ objT c_QPolygon
  , mkConstMethod' "mapToScene" "mapToScenePoint"
      [objT c_QPoint] $ objT c_QPointF
  , mkConstMethod' "mapToScene" "mapToSceneRect"
      [objT c_QRect] $ objT c_QPolygonF
  , mkConstMethod' "mapToScene" "mapToScenePolygon"
      [objT c_QPolygon] $ objT c_QPolygonF
  , mkConstMethod' "mapToScene" "mapToScenePainterPath"
      [objT c_QPainterPath] $ objT c_QPainterPath
  , mkConstMethod' "mapToScene" "mapToScenePointRaw"
      [intT, intT] $ objT c_QPointF
  , mkConstMethod' "mapToScene" "mapToSceneRectRaw"
      [intT, intT, intT, intT] $ objT c_QPolygonF
166 167 168
  -- TODO mkConstMethod "matrix" [] $ objT c_QMatrix
  , mkConstMethod "optimizationFlags" [] $ bitspaceT bs_OptimizationFlags
  , mkMethod "render" [ptrT $ objT c_QPainter] voidT
Roman 3237465's avatar
Roman 3237465 committed
169 170
  , mkMethod' "render" "renderAll"
      [ptrT $ objT c_QPainter, objT c_QRectF, objT c_QRect, enumT e_AspectRatioMode] voidT
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
  , mkConstMethod "renderHints" [] $ bitspaceT bs_RenderHints
  , mkMethod "resetCachedContent" [] voidT
  , mkMethod "resetMatrix" [] voidT
  , mkMethod "resetTransform" [] voidT
  , mkConstMethod "resizeAnchor" [] $ enumT e_ViewportAnchor
  , mkMethod "rotate" [doubleT] voidT
  -- TODO mkConstMethod "rubberBandSelectionMode" [] $ objT c_Qt::ItemSelectionMode
  , mkMethod "scale" [doubleT, doubleT] voidT
  , mkConstMethod "scene" [] $ ptrT $ objT c_QGraphicsScene
  , mkConstMethod "sceneRect" [] $ objT c_QRectF
  , mkMethod "setAlignment" [bitspaceT bs_Alignment] voidT
  , mkMethod "setBackgroundBrush" [objT c_QBrush] voidT
  , mkMethod "setCacheMode" [bitspaceT bs_CacheMode] voidT
  , mkMethod "setDragMode" [enumT e_DragMode] voidT
  , mkMethod "setForegroundBrush" [objT c_QBrush] voidT
  , mkMethod "setInteractive" [boolT] voidT
  -- TODO mkMethod "setMatrix" [objT c_QMatrix] voidT
  -- TODO mkMethod' "setMatrix" "setMatrixAll" [objT c_QMatrix, boolT] voidT
  , mkMethod "setOptimizationFlag" [enumT e_OptimizationFlag] voidT
  , mkMethod' "setOptimizationFlag" "setOptimizationFlagAll" [enumT e_OptimizationFlag, boolT] voidT
  , mkMethod "setOptimizationFlags" [bitspaceT bs_OptimizationFlags] voidT
  , mkMethod "setRenderHint" [enumT e_RenderHint] voidT
  , mkMethod' "setRenderHint" "setRenderHintAll" [enumT e_RenderHint, boolT] voidT
  , mkMethod "setRenderHints" [bitspaceT bs_RenderHints] voidT
  , mkMethod "setResizeAnchor" [enumT e_ViewportAnchor] voidT
  -- TODO mkMethod "setRubberBandSelectionMode" [objT c_Qt::ItemSelectionMode] voidT
  , mkMethod "setScene" [ptrT $ objT c_QGraphicsScene] voidT
Roman 3237465's avatar
Roman 3237465 committed
198
  , mkMethod' "setSceneRect" "setSceneRectF" [objT c_QRectF] voidT
199 200 201 202 203 204 205 206 207 208 209 210 211
  , mkMethod' "setSceneRect" "setSceneRectRaw" [doubleT, doubleT, doubleT, doubleT] voidT
  , mkMethod "setTransform" [objT c_QTransform] voidT
  , mkMethod' "setTransform" "setTransformAll" [objT c_QTransform, boolT] voidT
  , mkMethod "setTransformationAnchor" [enumT e_ViewportAnchor] voidT
  , mkMethod "setViewportUpdateMode" [enumT e_ViewportUpdateMode] voidT
  , mkMethod "shear" [doubleT, doubleT] voidT
  , mkConstMethod "transform" [] $ objT c_QTransform
  , mkConstMethod "transformationAnchor" [] $ enumT e_ViewportAnchor
  , mkMethod "translate" [doubleT, doubleT] voidT
  , mkConstMethod "viewportTransform" [] $ objT c_QTransform
  ]

(e_CacheModeFlag, bs_CacheMode) =
Roman 3237465's avatar
Roman 3237465 committed
212 213
  makeQtEnumBitspace (ident1 "QGraphicsView" "CacheModeFlag") "CacheMode"
    [includeStd "QGraphicsView"]
214 215 216 217 218 219 220 221 222 223 224 225
  [ (0x0, ["cache","none"])
  , (0x1, ["cache","background"])
  ]

e_DragMode =
  makeQtEnum (ident1 "QGraphicsView" "DragMode") [includeStd "QGraphicsView"]
  [ (0, ["no", "drag"])
  , (1, ["scroll", "hand", "drag"])
  , (2, ["rubber", "band", "drag"])
  ]

(e_OptimizationFlag, bs_OptimizationFlags) =
Roman 3237465's avatar
Roman 3237465 committed
226 227
  makeQtEnumBitspace (ident1 "QGraphicsView" "OptimizationFlag") "OptimizationFlags"
    [includeStd "QGraphicsView"]
228 229 230 231 232 233 234
  [ (0x1, ["dont","clip","painter"])
  , (0x2, ["dont","save","painter","state"])
  , (0x4, ["dont","adjust","for","antialiasing"])
  , (0x8, ["indirect","painting"])
  ]

e_ViewportAnchor =
Roman 3237465's avatar
Roman 3237465 committed
235 236
  makeQtEnum (ident1 "QGraphicsView" "ViewportAnchor")
    [includeStd "QGraphicsView"]
237 238 239 240 241 242
  [ (0, ["no", "anchor"])
  , (1, ["anchor", "view", "center"])
  , (2, ["anchor", "under", "mouse"])
  ]

e_ViewportUpdateMode =
Roman 3237465's avatar
Roman 3237465 committed
243 244
  makeQtEnum (ident1 "QGraphicsView" "ViewportUpdateMode")
    [includeStd "QGraphicsView"]
245 246 247 248 249 250 251 252 253 254
  [ (0, ["full","viewport","update"])
  , (1, ["minimal","viewport","update"])
  , (2, ["smart","viewport","update"])
  , (4, ["bounding","rect","viewport","update"])
  , (3, ["no","viewport","update"])
  ]

-- Methods with optional arguments that weren't handled properly in the bindings above
-- (i.e. `foo` + `fooAll`).
{-
Roman 3237465's avatar
Roman 3237465 committed
255 256 257 258 259 260 261 262
QList<QGraphicsItem *>  items
  (int x, int y, int w, int h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const
QList<QGraphicsItem *>  items
  (const QRect & rect, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const
QList<QGraphicsItem *>  items
  (const QPolygon & polygon, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const
QList<QGraphicsItem *>  items
  (const QPainterPath & path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const
263
-}