-- This file is part of Qtah.
--
-- Copyright 2015-2021 The Qtah Authors.
--
-- 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.QTextEdit (
  aModule,
  ) where

import Foreign.Hoppy.Generator.Spec (
  addReqIncludes,
  classSetEntityPrefix,
  ident,
  ident1,
  includeStd,
  makeClass,
  mkBoolIsProp,
  mkConstMethod,
  mkConstMethod',
  mkCtor,
  mkMethod,
  mkMethod',
  mkProp,
  np,
  )
import Foreign.Hoppy.Generator.Types (boolT, enumT, intT, objT, ptrT, voidT)
import Graphics.UI.Qtah.Generator.Flags (flagsT)
import Graphics.UI.Qtah.Generator.Interface.Core.QPoint (c_QPoint)
import Graphics.UI.Qtah.Generator.Interface.Core.QRect (c_QRect)
import Graphics.UI.Qtah.Generator.Interface.Core.QString (c_QString)
import Graphics.UI.Qtah.Generator.Interface.Core.Types (fl_Alignment, qreal)
import Graphics.UI.Qtah.Generator.Interface.Gui.QColor (c_QColor)
import Graphics.UI.Qtah.Generator.Interface.Gui.QFont (c_QFont)
import Graphics.UI.Qtah.Generator.Interface.Internal.Listener (
  listener,
  listenerBool,
  )
import Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractScrollArea (c_QAbstractScrollArea)
import Graphics.UI.Qtah.Generator.Interface.Widgets.QMenu (c_QMenu)
import Graphics.UI.Qtah.Generator.Interface.Widgets.QWidget (c_QWidget)
import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), makeQtModule)
import Graphics.UI.Qtah.Generator.Types

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

aModule :: AModule
aModule =
  QtModule -> AModule
AQtModule (QtModule -> AModule) -> QtModule -> AModule
forall a b. (a -> b) -> a -> b
$
  [String] -> [QtExport] -> QtModule
makeQtModule [String
"Widgets", String
"QTextEdit"] ([QtExport] -> QtModule) -> [QtExport] -> QtModule
forall a b. (a -> b) -> a -> b
$
  [ Class -> [Signal] -> QtExport
QtExportClassAndSignals Class
c_QTextEdit [Signal]
signals
  , CppEnum -> QtExport
forall a. Exportable a => a -> QtExport
qtExport CppEnum
e_LineWrapMode
  , CppEnum -> QtExport
forall a. Exportable a => a -> QtExport
qtExport CppEnum
e_AutoFormattingFlag
  , Flags -> QtExport
forall a. Exportable a => a -> QtExport
qtExport Flags
fl_AutoFormatting
  ]

(Class
c_QTextEdit, [Signal]
signals) =
  [SignalGen] -> Class -> (Class, [Signal])
makeQtClassAndSignals [SignalGen]
signalGens (Class -> (Class, [Signal])) -> Class -> (Class, [Signal])
forall a b. (a -> b) -> a -> b
$
  [Include] -> Class -> Class
forall a. HasReqs a => [Include] -> a -> a
addReqIncludes [String -> Include
includeStd String
"QTextEdit"] (Class -> Class) -> Class -> Class
forall a b. (a -> b) -> a -> b
$
  String -> Class -> Class
classSetEntityPrefix String
"" (Class -> Class) -> Class -> Class
forall a b. (a -> b) -> a -> b
$
  Identifier -> Maybe ExtName -> [Class] -> [ClassEntity] -> Class
makeClass (String -> Identifier
ident String
"QTextEdit") Maybe ExtName
forall a. Maybe a
Nothing [Class
c_QAbstractScrollArea]
  [ String -> [Parameter] -> ClassEntity
forall p. IsParameter p => String -> [p] -> ClassEntity
mkCtor String
"new" [Parameter]
np
  , String -> [Type] -> ClassEntity
forall p. IsParameter p => String -> [p] -> ClassEntity
mkCtor String
"newWithParent" [Type -> Type
ptrT (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QWidget]
  , String -> [Type] -> ClassEntity
forall p. IsParameter p => String -> [p] -> ClassEntity
mkCtor String
"newWithText" [Class -> Type
objT Class
c_QString]
  , String -> [Type] -> ClassEntity
forall p. IsParameter p => String -> [p] -> ClassEntity
mkCtor String
"newWithTextAndParent" [Class -> Type
objT Class
c_QString, Type -> Type
ptrT (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QWidget]
  , String -> Type -> ClassEntity
mkProp String
"acceptRichText" Type
boolT
  , String -> Type -> ClassEntity
mkProp String
"alignment" (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Flags -> Type
flagsT Flags
fl_Alignment
  , String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"anchorAt" [Class -> Type
objT Class
c_QPoint] (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QString
  , String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"append" [Class -> Type
objT Class
c_QString] Type
voidT
  , String -> Type -> ClassEntity
mkProp String
"autoFormatting" (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Flags -> Type
flagsT Flags
fl_AutoFormatting
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"canPaste" [Parameter]
np Type
boolT
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"clear" [Parameter]
np Type
voidT
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"copy" [Parameter]
np Type
voidT
  , String -> String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> String -> [p] -> Type -> ClassEntity
mkMethod' String
"createStandardContextMenu" String
"createStandardContextMenu" [Parameter]
np (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Type -> Type
ptrT (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QMenu
  , String -> String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> String -> [p] -> Type -> ClassEntity
mkMethod' String
"createStandardContextMenu" String
"createStandardContextMenuAt" [Class -> Type
objT Class
c_QPoint] (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$
    Type -> Type
ptrT (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QMenu
    -- TODO currentCharFormat
  , String -> Type -> ClassEntity
mkProp String
"currentFont" (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QFont
    -- TODO cursorForPosition
  , String -> String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> String -> [p] -> Type -> ClassEntity
mkConstMethod' String
"cursorRect" String
"cursorRect" [Parameter]
np (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QRect
    -- TODO cursorRect(const QTextCursor&)
  , String -> Type -> ClassEntity
mkProp String
"cursorWidth" Type
intT
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"cut" [Parameter]
np Type
voidT
    -- TODO document
  , String -> Type -> ClassEntity
mkProp String
"documentTitle" (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QString
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"ensureCursorVisible" [Parameter]
np Type
voidT
    -- TODO extraSelections
  , String -> String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> String -> [p] -> Type -> ClassEntity
mkMethod' String
"find" String
"find" [Class -> Type
objT Class
c_QString] Type
boolT
    -- TODO find with FindFlags
  , String -> Type -> ClassEntity
mkProp String
"fontFamily" (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QString
  , String -> Type -> ClassEntity
mkProp String
"fontItalic" Type
boolT
  , String -> Type -> ClassEntity
mkProp String
"fontPointSize" Type
qreal
  , String -> Type -> ClassEntity
mkProp String
"fontUnderline" Type
boolT
  , String -> Type -> ClassEntity
mkProp String
"fontWeight" Type
intT
  , String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"insertHtml" [Class -> Type
objT Class
c_QString] Type
voidT
  , String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"insertPlainText" [Class -> Type
objT Class
c_QString] Type
voidT
  , String -> Type -> ClassEntity
mkProp String
"lineWrapColumnOrWidth" Type
intT
  , String -> Type -> ClassEntity
mkProp String
"lineWrapMode" (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ CppEnum -> Type
enumT CppEnum
e_LineWrapMode
    -- TODO loadResource
    -- TODO mergeCurrentCharFormat
    -- TODO moveCursor
  , String -> Type -> ClassEntity
mkProp String
"overwriteMode" Type
boolT
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"paste" [Parameter]
np Type
voidT
    -- TODO print
  , String -> ClassEntity
mkBoolIsProp String
"readOnly"
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"redo" [Parameter]
np Type
voidT
  , String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"scrollToAnchor" [Class -> Type
objT Class
c_QString] Type
voidT
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"selectAll" [Parameter]
np Type
voidT
  , String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"setHtml" [Class -> Type
objT Class
c_QString] Type
voidT
  , String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"setPlainText" [Class -> Type
objT Class
c_QString] Type
voidT
  , String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"setText" [Class -> Type
objT Class
c_QString] Type
voidT
  , String -> Type -> ClassEntity
mkProp String
"tabChangesFocus" Type
boolT
  , String -> Type -> ClassEntity
mkProp String
"tabStopWidth" Type
intT
  , String -> Type -> ClassEntity
mkProp String
"textBackgroundColor" (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QColor
  , String -> Type -> ClassEntity
mkProp String
"textColor" (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QColor
    -- TODO textCursor
    -- TODO textInteractionFlags
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"toHtml" [Parameter]
np (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QString
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"toPlainText" [Parameter]
np (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QString
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"undo" [Parameter]
np Type
voidT
  , String -> ClassEntity
mkBoolIsProp String
"undoRedoEnabled"
    -- TODO wordWrapMode
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"zoomIn" [Parameter]
np Type
voidT
  , String -> String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> String -> [p] -> Type -> ClassEntity
mkMethod' String
"zoomIn" String
"zoomInPoints" [Type
intT] Type
voidT
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"zoomOut" [Parameter]
np Type
voidT
  , String -> String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> String -> [p] -> Type -> ClassEntity
mkMethod' String
"zoomOut" String
"zoomOutPoints" [Type
intT] Type
voidT
  ]

signalGens :: [SignalGen]
signalGens :: [SignalGen]
signalGens =
  [ String -> ListenerInfo -> SignalGen
makeSignal String
"copyAvailable" ListenerInfo
listenerBool
    -- TODO currentCharFormatChanged
  , String -> ListenerInfo -> SignalGen
makeSignal String
"cursorPositionChanged" ListenerInfo
listener
  , String -> ListenerInfo -> SignalGen
makeSignal String
"redoAvailable" ListenerInfo
listenerBool
  , String -> ListenerInfo -> SignalGen
makeSignal String
"selectionChanged" ListenerInfo
listener
  , String -> ListenerInfo -> SignalGen
makeSignal String
"textChanged" ListenerInfo
listener
  , String -> ListenerInfo -> SignalGen
makeSignal String
"undoAvailable" ListenerInfo
listenerBool
  ]

e_LineWrapMode :: CppEnum
e_LineWrapMode =
  Identifier -> [Include] -> [String] -> CppEnum
makeQtEnum (String -> String -> Identifier
ident1 String
"QTextEdit" String
"LineWrapMode") [String -> Include
includeStd String
"QTextEdit"]
  [ String
"NoWrap"
  , String
"WidgetWidth"
  , String
"FixedPixelWidth"
  , String
"FixedColumnWidth"
  ]

(CppEnum
e_AutoFormattingFlag, Flags
fl_AutoFormatting) =
  Identifier -> String -> [Include] -> [String] -> (CppEnum, Flags)
makeQtEnumAndFlags (String -> String -> Identifier
ident1 String
"QTextEdit" String
"AutoFormattingFlag") String
"AutoFormatting" [String -> Include
includeStd String
"QTextEdit"]
  [ String
"AutoNone"
  , String
"AutoBulletList"
  , String
"AutoAll"
  ]