-- 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.QDialogButtonBox (
  aModule,
  c_QDialogButtonBox,
  e_ButtonLayout,
  e_ButtonRole,
  e_StandardButton,
  fl_StandardButtons,
  ) where

import Foreign.Hoppy.Generator.Spec (
  addReqIncludes,
  classSetEntityPrefix,
  ident,
  ident1,
  includeStd,
  makeClass,
  mkConstMethod,
  mkCtor,
  mkMethod,
  mkMethod',
  mkProp,
  np,
  )
import Foreign.Hoppy.Generator.Types (boolT, enumT, objT, ptrT, voidT)
import Graphics.UI.Qtah.Generator.Flags (flagsT)
import Graphics.UI.Qtah.Generator.Interface.Core.QList (c_QListQAbstractButton)
import Graphics.UI.Qtah.Generator.Interface.Core.QString (c_QString)
import Graphics.UI.Qtah.Generator.Interface.Core.Types (e_Orientation)
import Graphics.UI.Qtah.Generator.Interface.Internal.Listener (
  listener,
  listenerPtrQAbstractButton,
  )
import Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractButton (c_QAbstractButton)
import Graphics.UI.Qtah.Generator.Interface.Widgets.QPushButton (c_QPushButton)
import Graphics.UI.Qtah.Generator.Interface.Widgets.QWidget (c_QWidget)
import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), makeQtModuleWithMinVersion)
import Graphics.UI.Qtah.Generator.Types

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

minVersion :: [Int]
minVersion = [Int
4, Int
2]

aModule :: AModule
aModule =
  QtModule -> AModule
AQtModule (QtModule -> AModule) -> QtModule -> AModule
forall a b. (a -> b) -> a -> b
$
  [String] -> [Int] -> [QtExport] -> QtModule
makeQtModuleWithMinVersion [String
"Widgets", String
"QDialogButtonBox"] [Int]
minVersion
  [ Class -> [Signal] -> QtExport
QtExportClassAndSignals Class
c_QDialogButtonBox [Signal]
signals
  , CppEnum -> QtExport
forall a. Exportable a => a -> QtExport
qtExport CppEnum
e_ButtonLayout
  , CppEnum -> QtExport
forall a. Exportable a => a -> QtExport
qtExport CppEnum
e_ButtonRole
  , CppEnum -> QtExport
forall a. Exportable a => a -> QtExport
qtExport CppEnum
e_StandardButton
  , Flags -> QtExport
forall a. Exportable a => a -> QtExport
qtExport Flags
fl_StandardButtons
  ]

(Class
c_QDialogButtonBox, [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
"QDialogButtonBox"] (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
"QDialogButtonBox") Maybe ExtName
forall a. Maybe a
Nothing [Class
c_QWidget]
  [ 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]
    -- TODO Other ctors? v v
  --, mkCtor "newWithOrientation" [enumT e_Orientation]
  --, mkCtor "newWithOrientationAndParent" [enumT e_Orientation, ptrT $ objT c_QWidget]
  --, mkCtor "newWithButtons" np
  --, mkCtor "newWithParent" [ptrT $ objT c_QWidget]
  --, mkCtor "new" np
  --, mkCtor "newWithParent" [ptrT $ objT c_QWidget]
  , String -> String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> String -> [p] -> Type -> ClassEntity
mkMethod' String
"addButton" String
"addButton" [Type -> Type
ptrT (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QAbstractButton, CppEnum -> Type
enumT CppEnum
e_ButtonRole] Type
voidT
  , String -> String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> String -> [p] -> Type -> ClassEntity
mkMethod' String
"addButton" String
"addButtonWithText"
    [Class -> Type
objT Class
c_QString, CppEnum -> Type
enumT CppEnum
e_ButtonRole] (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_QPushButton
  , String -> String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> String -> [p] -> Type -> ClassEntity
mkMethod' String
"addButton" String
"addStandardButton" [CppEnum -> Type
enumT CppEnum
e_StandardButton] (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_QPushButton
  , String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"button" [CppEnum -> Type
enumT CppEnum
e_StandardButton] (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_QPushButton
  , String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"buttonRole" [Type -> Type
ptrT (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QAbstractButton] (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ CppEnum -> Type
enumT CppEnum
e_ButtonRole
  , String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"buttons" [Parameter]
np (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QListQAbstractButton
  , String -> Type -> ClassEntity
mkProp String
"centerButtons" 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 -> Type -> ClassEntity
mkProp String
"orientation" (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ CppEnum -> Type
enumT CppEnum
e_Orientation
  , String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"removeButton" [Type -> Type
ptrT (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QAbstractButton] Type
voidT
  , String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"standardButton" [Type -> Type
ptrT (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QAbstractButton] (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ CppEnum -> Type
enumT CppEnum
e_StandardButton
  , String -> Type -> ClassEntity
mkProp String
"standardButtons" (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Flags -> Type
flagsT Flags
fl_StandardButtons
  ]

signalGens :: [SignalGen]
signalGens :: [SignalGen]
signalGens =
  [ String -> ListenerInfo -> SignalGen
makeSignal String
"accepted" ListenerInfo
listener
  , String -> ListenerInfo -> SignalGen
makeSignal String
"clicked" ListenerInfo
listenerPtrQAbstractButton
  , String -> ListenerInfo -> SignalGen
makeSignal String
"helpRequested" ListenerInfo
listener
  , String -> ListenerInfo -> SignalGen
makeSignal String
"rejected" ListenerInfo
listener
  ]

e_ButtonLayout :: CppEnum
e_ButtonLayout =
  Identifier -> [Include] -> [String] -> CppEnum
makeQtEnum (String -> String -> Identifier
ident1 String
"QDialogButtonBox" String
"ButtonLayout") [String -> Include
includeStd String
"QDialogButtonBox"]
  [ String
"WinLayout"
  , String
"MacLayout"
  , String
"KdeLayout"
  , String
"GnomeLayout"
  ]

e_ButtonRole :: CppEnum
e_ButtonRole =
  Identifier -> [Include] -> [String] -> CppEnum
makeQtEnum (String -> String -> Identifier
ident1 String
"QDialogButtonBox" String
"ButtonRole") [String -> Include
includeStd String
"QDialogButtonBox"]
  [ String
"InvalidRole"
  , String
"AcceptRole"
  , String
"RejectRole"
  , String
"DestructiveRole"
  , String
"ActionRole"
  , String
"HelpRole"
  , String
"YesRole"
  , String
"NoRole"
  , String
"ResetRole"
  , String
"ApplyRole"
  ]

(CppEnum
e_StandardButton, Flags
fl_StandardButtons) =
  Identifier -> String -> [Include] -> [String] -> (CppEnum, Flags)
makeQtEnumAndFlags (String -> String -> Identifier
ident1 String
"QDialogButtonBox" String
"StandardButton") String
"StandardButtons"
  [String -> Include
includeStd String
"QDialogButtonBox"]
  [ String
"Ok"
  , String
"Open"
  , String
"Save"
  , String
"Cancel"
  , String
"Close"
  , String
"Discard"
  , String
"Apply"
  , String
"Reset"
  , String
"RestoreDefaults"
  , String
"Help"
  , String
"SaveAll"
  , String
"Yes"
  , String
"YesToAll"
  , String
"No"
  , String
"NoToAll"
  , String
"Abort"
  , String
"Retry"
  , String
"Ignore"
  , String
"NoButton"
  ]