[VOEditors] Fix for https://github.com/X-Sharp/XSharpPublic/issues/463, now the binary editors retain also IMPLEMENT clauses when updating existing code

#using System.Collections.Generic
#using System.Collections.Generic
#using System.Collections

USING Xide

BEGIN NAMESPACE Xide

CLASS AbstractEditor
	EXPORT aLines AS List<LineObject>
	PROTECT nStart,nEnd AS INT
	PROTECT oCaretPos AS System.Drawing.Point
	PROTECT oBuffer AS EditorBuffer
	CONSTRUCTOR(_oBuffer AS EditorBuffer)
		SELF:oBuffer := _oBuffer
		SELF:oBuffer:FullParse()
		SELF:aLines := SELF:oBuffer:aLines
	RETURN

	METHOD BeginCode() AS VOID
		SELF:nStart := 0
		SELF:nEnd := 0
		IF SELF:oBuffer != NULL
			SELF:oBuffer:BeginAction()
		END IF
	RETURN

	METHOD EndCode() AS VOID
		IF SELF:oBuffer != NULL
			SELF:oBuffer:EndAction()
		END IF
	RETURN

	METHOD ModifiedLine(nLine AS INT) AS VOID
		IF SELF:nStart == 0 .or. SELF:nStart > nLine
			SELF:nStart := nLine
		ENDIF
		IF SELF:nEnd == 0 .or. SELF:nEnd < nLine
			SELF:nEnd := nLine
		ENDIF
	RETURN

	METHOD CheckCreatedCode() AS VOID
		IF SELF:nStart != 0
			SELF:oBuffer:LinesModified(0,0,0)
		ENDIF
		SELF:nStart := 0
		SELF:nEnd := 0
	RETURN

	METHOD AddLine(cLine AS STRING) AS VOID
		SELF:oBuffer:AddLine(cLine)
	RETURN

	METHOD InsertLine(cLine AS STRING , nLine AS INT) AS VOID
		SELF:oBuffer:InsertLine(nLine , cLine)
	RETURN

	METHOD ReplaceLine(cLine AS STRING , nLine AS INT) AS VOID
		SELF:oBuffer:ChangeLine(nLine , cLine)
	RETURN

	METHOD RemoveLine(nLine AS INT) AS VOID
		SELF:oBuffer:DeleteLine(nLine)
	RETURN

	METHOD DeleteAllLines() AS VOID
		SELF:oBuffer:DeleteAllLines()
	RETURN

END CLASS

PARTIAL CLASS CodeGenerator
	PROTECT aLines AS List<LineObject>
	PROTECT nStart,nEnd AS INT
	PROTECT oCaretPos AS System.Drawing.Point
	PROTECT oEditor , oBaseEditor , oDesEditor AS AbstractEditor

	CONSTRUCTOR(oBuffer AS EditorBuffer)
		SELF:aLines := oBuffer:aLines
		SELF:oBaseEditor := AbstractEditor{oBuffer}
	RETURN

	METHOD BeginCode() AS LOGIC
		SELF:oDesEditor := SELF:oBaseEditor
		SELF:oEditor := SELF:oBaseEditor
		SELF:oEditor:BeginCode()
	RETURN FALSE

	METHOD EndCode() AS VOID
		SELF:oEditor:EndCode()
	RETURN

METHOD ModifiedLine(nLine AS INT) AS VOID
	SELF:oEditor:ModifiedLine(nLine)
RETURN

METHOD CheckCreatedCode() AS VOID
	SELF:oEditor:CheckCreatedCode()
RETURN
METHOD GetLine(nLine AS INT) AS LineObject
	RETURN SELF:aLines[nLine - 1]

METHOD EntityExists(eType AS EntityType,cName AS STRING,cClass AS STRING) AS LOGIC
LOCAL nDummy AS INT
SELF:FindEntity(eType,cName,cClass,nDummy)
RETURN nDummy!=0

METHOD EntityExistsAnywhere(eType AS EntityType , cName AS STRING , cClass AS STRING) AS LOGIC
RETURN FALSE

METHOD FindEntity(eType AS EntityType,cName AS STRING,cClass AS STRING,nLine REF Int32) AS LOGIC
LOCAL oLine AS LineObject
LOCAL oEntity AS EntityObject
cName := cName:ToUpper():Trim()
cClass := cClass:ToUpper():Trim()
FOR nLine:=1 UPTO SELF:aLines:Count
	oLine:=SELF:GetLine(nLine)
	IF oLine:lEntity
		oEntity:=oLine:oEntity
		IF oEntity:eType == eType .and. oEntity:cTypedClassName:ToUpper() == cClass
			IF eType == EntityType._Constructor .or. oEntity:cName:ToUpper() == cName
				RETURN FALSE
			ENDIF
		END IF
	END IF
NEXT
nLine:=0
RETURN FALSE

METHOD DeleteEntity(eType AS EntityType,cName AS STRING,cClass AS STRING) AS LOGIC
	LOCAL nLine AS INT
RETURN SELF:DeleteEntity(eType , cName ,cClass , nLine)

METHOD DeleteEntity(eType AS EntityType,cName AS STRING,cClass AS STRING,nLine REF Int32) AS LOGIC
LOCAL oLine AS LineObject
LOCAL lExit AS LOGIC
LOCAL nOldLine AS INT
LOCAL cLine AS STRING
nOldLine := nLine
SELF:FindEntity(eType,cName,cClass,nLine)
IF nLine == 0
	nLine := nOldLine
	RETURN FALSE
ENDIF

DO WHILE nLine!=0
	SELF:RemoveWEDLine(nLine)
	SELF:ModifiedLine(nLine)
	IF nLine<=SELF:aLines:Count
		oLine:=SELF:GetLine(nLine)
		IF oLine:lEntity .or. lExit .or. oLine:IsEndClass
			EXIT
		END IF
		cLine := oLine:LineText:ToUpper()
		IF cLine:Contains("##USER##") .or. cLine:Contains("{{%UC%}}") .or. cLine:Contains("USER CODE STARTS")
			lExit := TRUE
		END IF
	ELSE
		EXIT
	END IF
END DO
SELF:CheckCreatedCode()
RETURN FALSE

METHOD AddInclude(cInclude AS STRING) AS VOID
	LOCAL oLine AS LineObject
	LOCAL nLine AS INT
	LOCAL n AS INT

	nLine := 1

	FOR n := 1 UPTO SELF:aLines:Count
		oLine := SELF:aLines[n - 1]
		DO CASE
		CASE oLine:lEntity
			nLine := n - 1
			EXIT
		CASE oLine:IsInclude .and. oLine:cArgument:ToUpper() == cInclude:ToUpper()
			RETURN
		END CASE
	NEXT
	IF nLine <= 0
		nLine := 1
	ENDIF

	SELF:AddWEDLine("#include " + e"\"" + cInclude + e"\"" , nLine)
	SELF:ModifiedLine(nLine)
RETURN

METHOD RemoveInclude(cInclude AS STRING) AS VOID
	FOR LOCAL nLine := 1 UPTO SELF:aLines:Count
		LOCAL oLine AS LineObject
		oLine := SELF:aLines[nLine - 1]
		DO CASE
		CASE oLine:lEntity
			RETURN
		CASE oLine:IsInclude .and. oLine:cArgument:ToUpper() == cInclude:ToUpper()
			SELF:RemoveWEDLine(nLine)
			SELF:ModifiedLine(nLine)
			RETURN
		END CASE
	NEXT
RETURN

METHOD AddLine(cLine AS STRING) AS VOID
	SELF:oEditor:AddLine(cLine)
	SELF:ModifiedLine(SELF:aLines:Count)
RETURN
METHOD InsertLine(nLine AS INT , cLine AS STRING) AS VOID
	SELF:oEditor:InsertLine(cLine , nLine)
	SELF:ModifiedLine(SELF:aLines:Count)
RETURN

METHOD AddWEDLine(cLine AS STRING,nLine REF Int32) AS LineObject
LOCAL oLine AS LineObject
IF nLine<=SELF:aLines:Count .and. nLine!=0
	SELF:oEditor:InsertLine(cLine , nLine)
	SELF:ModifiedLine(nLine)
ELSE
	SELF:oEditor:AddLine(cLine)
	nLine:=SELF:aLines:Count
	SELF:ModifiedLine(nLine)
END IF
oLine := SELF:GetLine(nLine)
nLine++
RETURN oLine
METHOD ReplaceWEDLine(cLine AS STRING,nLine AS Int32) AS LineObject
	SELF:oEditor:ReplaceLine(cLine , nLine)
	SELF:ModifiedLine(nLine)
RETURN SELF:GetLine(nLine)
METHOD RemoveWEDLine(nLine AS Int32) AS VOID
	SELF:oEditor:RemoveLine(nLine)
RETURN
METHOD Clear() AS VOID
	SELF:oEditor:DeleteAllLines()
RETURN

	STATIC PROTECT cUser := "// {{%UC%}} User code starts here (DO NOT remove this line)  " AS STRING
	STATIC PROTECT cTagU := "" AS STRING

	METHOD GetEntity(eType AS EntityType , cName AS STRING , cClass AS STRING) AS EntityObject
		LOCAL nLine AS INT
		nLine := SELF:FindEntity(eType , cName , cClass)
		IF nLine != 0
			RETURN SELF:GetLine(nLine):oEntity
		END IF
	RETURN NULL

	METHOD FindEntity(eType AS EntityType , cName AS STRING , cClass AS STRING) AS INT
		LOCAL nLine AS INT
		SELF:FindEntity(eType , cName , cClass , nLine)
	RETURN nLine

	METHOD WriteEntity(eType AS EntityType , cName AS STRING , cClass AS STRING , eOptions AS EntityOptions , aEntity AS List<STRING>) AS INT
		LOCAL oLine AS LineObject
		LOCAL nLine AS INT
		LOCAL nTemp AS INT
		LOCAL nFirst AS INT
		LOCAL lIsUser AS LOGIC
		LOCAL lRemoveFields AS LOGIC
		LOCAL n AS INT

		LOCAL cTab , ceTab AS STRING
		cTab := e"\t"
		ceTab := e"\t"

		IF aEntity:Count == 0
			RETURN 0
		END IF

		cClass := cClass:ToUpper()
		nLine := SELF:FindEntity(eType , cName , cClass)

		IF nLine == 0
			IF eType == EntityType._Class
				nLine := SELF:aLines:Count + 1
			ELSEIF eType == EntityType._Constructor
				nLine := SELF:FindEntity(EntityType._Class , cClass , cClass)
				IF nLine == 0
					RETURN 0
				END IF
				DO WHILE TRUE
					nLine ++
					IF nLine > SELF:aLines:Count
						EXIT
					END IF
					oLine := SELF:GetLine(nLine)
					IF oLine:lEntity .or. oLine:IsEndClass
						EXIT
					END IF
				END DO
			ELSE
				nLine := SELF:FindEntity(EntityType._Class , cClass , cClass)
				IF nLine == 0
					RETURN 0
				END IF
				DO WHILE TRUE
					nLine ++
					IF nLine > SELF:aLines:Count
						EXIT
					END IF
					oLine := SELF:GetLine(nLine)
					IF oLine:IsEndClass
						EXIT
					END IF
					IF oLine:lEntity .and. oLine:oEntity:cTypedClassName:ToUpper() != cClass
						EXIT
					END IF
				END DO
			END IF
			nFirst := nLine
		ELSE
			nFirst := nLine
			IF (eOptions & EntityOptions.NotOverwrite) == EntityOptions.NotOverwrite
				RETURN nFirst
			END IF
			oLine := SELF:GetLine(nLine)
			LOCAL oDeclarationLine AS LineObject
			oDeclarationLine := oLine

			DO WHILE oLine:lOutAmpersand .and. (oLine:LineText:Contains("[") .or. oLine:LineText:Contains("]"))
				nLine ++
				oLine := SELF:GetLine(nLine)
			END DO

			IF (eOptions & EntityOptions.ClearOldFields) == EntityOptions.ClearOldFields
				lRemoveFields := FALSE
				nTemp := nLine
				nTemp ++
				DO WHILE nTemp <= SELF:aLines:Count
					oLine := SELF:GetLine(nTemp)
					IF oLine:lEntity
						EXIT
					END IF
					IF oLine:IsDesignerUserStart
						lRemoveFields := TRUE
						EXIT
					ENDIF
					nTemp ++
				END DO
			ELSE
				lRemoveFields := TRUE
			END IF

			IF lRemoveFields
				nTemp := nLine
				nTemp ++
				DO WHILE nTemp <= SELF:aLines:Count
					oLine := SELF:GetLine(nTemp)
					IF oLine:lEntity .or. oLine:IsEndClass
						EXIT
					END IF
					lIsUser := oLine:IsDesignerUserStart
					SELF:RemoveWEDLine(nTemp)
					IF lIsUser
						EXIT
					ENDIF
				END DO
			END IF

			IF SELF:GetLine(nLine):LineText:ToUpper() == aEntity[0]:ToUpper() .or. (eOptions & EntityOptions.KeepFirstLine) == EntityOptions.KeepFirstLine
				nLine ++
			ELSE
				LOCAL cDeclarationLine AS STRING
				cDeclarationLine := aEntity[0]
				IF oDeclarationLine:oEntity != NULL
					IF _AND(oDeclarationLine:oEntity:eModifiers , EntityModifiers._Protected) == EntityModifiers._Protected
						cDeclarationLine := "PROTECTED " + cDeclarationLine
					ENDIF
					IF _AND(oDeclarationLine:oEntity:eModifiers , EntityModifiers._Private) == EntityModifiers._Private
						cDeclarationLine := "PRIVATE " + cDeclarationLine
					ENDIF
					IF _AND(oDeclarationLine:oEntity:eModifiers , EntityModifiers._Partial) == EntityModifiers._Partial
						cDeclarationLine := "PARTIAL " + cDeclarationLine
					ENDIF
					IF _AND(oDeclarationLine:oEntity:eModifiers , EntityModifiers._Internal) == EntityModifiers._Internal
						cDeclarationLine := "INTERNAL " + cDeclarationLine
					ENDIF
					IF .NOT. String.IsNullOrEmpty( oDeclarationLine:oEntity:cImplements:Trim() )
						cDeclarationLine := cDeclarationLine + " IMPLEMENTS " + oDeclarationLine:oEntity:cImplements
					ENDIF
				END IF
				SELF:ReplaceWEDLine(cDeclarationLine , nLine)
				nLine ++
			END IF
			n := 1
		END IF

		DO WHILE n < aEntity:Count
			oLine := SELF:AddWEDLine(aEntity[n] , nLine)
			n ++
		END DO
		IF (eOptions & EntityOptions.AddUser) == EntityOptions.AddUser
			IF eType == EntityType._Class
				oLine := SELF:AddWEDLine(ceTab + cUser + cTagU , nLine)
			ELSE
				oLine := SELF:AddWEDLine(cTab + cUser + cTagU , nLine)
			END IF
		END IF

		IF eType != EntityType._Class
			IF nLine <= SELF:aLines:Count
				oLine := SELF:GetLine(nLine)
				IF oLine:LineText:Trim() != ""
					oLine := SELF:AddWEDLine("" , nLine)
				END IF
			END IF
		END IF

		SELF:CheckCreatedCode()
	RETURN nFirst

	METHOD WriteEndClass(cClass AS STRING) AS VOID
		LOCAL oLine AS LineObject
		LOCAL lFound AS LOGIC
		LOCAL nLine AS INT
		LOCAL n AS INT

		cClass := cClass:ToUpper()
		FOR n := 1 UPTO SELF:aLines:Count
			oLine := SELF:GetLine(n)
			IF lFound
				IF oLine:IsEndClass
					RETURN
				END IF
				IF oLine:lEntity .and. oLine:oEntity:cTypedClassName:ToUpper() != cClass
					EXIT
				END IF
				nLine := n + 1
			ELSE
				IF oLine:lEntity .and. oLine:oEntity:cTypedClassName:ToUpper() == cClass
					lFound := TRUE
					nLine := n + 1
				END IF
			END IF
		NEXT

		IF nLine != 0
			SELF:AddWEDLine("END CLASS" , nLine)
		END IF

	RETURN

	METHOD DeleteLine(nLine AS INT) AS VOID
		SELF:RemoveWEDLine(nLine)
		SELF:ModifiedLine(nLine)
	RETURN

	METHOD DeleteDefines(aDefines AS List<STRING>) AS VOID
		LOCAL oLine AS LineObject
		LOCAL nLine AS INT
		nLine := 1
		DO WHILE nLine <= SELF:aLines:Count
			LOCAL lDeleted := FALSE AS LOGIC
			oLine := SELF:aLines[nLine - 1]
			IF oLine:eType == LineType.Define .and. .not. String.IsNullOrEmpty(oLine:cArgument)
				FOREACH cDefine AS STRING IN aDefines
					IF cDefine:ToUpper() == oLine:cArgument:ToUpper()
						SELF:DeleteLine(nLine)
						lDeleted := TRUE
						EXIT
					END IF
				NEXT
			ELSEIF oLine:oEntity != NULL .and. oLine:oEntity:eType == EntityType._Define
				FOREACH cDefine AS STRING IN aDefines
					IF cDefine:ToUpper() == oLine:oEntity:cName:ToUpper()
						SELF:DeleteLine(nLine)
						lDeleted := TRUE
						EXIT
					END IF
				NEXT
			END IF
			IF .not. lDeleted
				nLine ++
			END IF
		END DO

		SELF:CheckCreatedCode()

	RETURN

	METHOD AddDefine(cDefine AS STRING , cValue AS STRING) AS VOID
		SELF:AddDefine(cDefine , cValue , TRUE)
	RETURN

	METHOD AddDefine(cDefine AS STRING , cValue AS STRING , lAdd AS LOGIC) AS VOID
		LOCAL cLine AS STRING
		cLine := String.Format("#define {0} {1}" , cDefine , cValue)
//		cLine := String.Format("DEFINE {0} := {1}" , cDefine , cValue)
		IF lAdd
			SELF:AddLine(cLine)
		ELSE
			SELF:InsertLine(1 , cLine)
		END IF
	RETURN

	METHOD AddDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING>) AS VOID
		SELF:AddDefines(aDefines , aDefineValues , TRUE)
	RETURN

	METHOD AddDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING> , lAdd AS LOGIC) AS VOID
		FOR LOCAL n := 0 AS INT UPTO aDefines:Count - 1
			SELF:AddDefine(aDefines[n] , aDefineValues[n] , lAdd)
		NEXT
	RETURN

	METHOD RemoveDefines(cWindowName as STRING) AS VOID
		LOCAL oLine AS LineObject
		LOCAL nLine AS INT
		nLine := 1
		cWindowName := cWindowName:ToUpper()+"_"
		DO WHILE nLine <= SELF:aLines:Count
			LOCAL lDeleted := FALSE AS LOGIC
			oLine := SELF:aLines[nLine - 1]
			IF oLine:eType == LineType.Define .and. .not. String.IsNullOrEmpty(oLine:cArgument)
				IF oLine:cArgument:ToUpper():StartsWith(cWindowName)
					SELF:DeleteLine(nLine)
					lDeleted := TRUE
				END IF
			ELSEIF oLine:oEntity != NULL .and. oLine:oEntity:eType == EntityType._Define
				IF oLine:oEntity:cName:ToUpper():StartsWith(cWindowName)
					SELF:DeleteLine(nLine)
					lDeleted := TRUE
				END IF
			END IF
			IF .not. lDeleted
				nLine ++
			END IF
		END DO
		SELF:CheckCreatedCode()
		RETURN

	METHOD AddXSharpDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING>) AS VOID
		SELF:AddXSharpDefines(aDefines, aDefineValues, FALSE)

	METHOD AddXSharpDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING>, lStatic AS LOGIC) AS VOID
		LOCAL cLine AS STRING
		LOCAL nLine AS INT
		FOR LOCAL n := 1 AS INT UPTO SELF:aLines:Count
			LOCAL oLine AS LineObject
			oLine := SELF:aLines[n-1]
			nLine := n
			DO CASE
			CASE oLine:oEntity != NULL
				EXIT
//			CASE oLine:IsRegionIn .and. oLine:cArgument:ToUpper() == "DEFINES"
			// grr, I am not setting cArgument for regions
			CASE oLine:IsRegionIn .and. oLine:LineText:ToUpper():Contains("DEFINES")
				nLine ++
				EXIT
			END CASE
		NEXT
		LOCAL cMask AS STRING
		cMask := "DEFINE {0} := {1}"
		IF lStatic
			cMask := "STATIC "+cMask
		ENDIF
		FOR LOCAL n := 0 AS INT UPTO aDefines:Count - 1
			cLine := String.Format(cMask , aDefines[n] , aDefineValues[n])
			SELF:InsertLine(nLine , cLine)
			nLine ++
		NEXT
	RETURN

END CLASS

[Flags];
ENUM EntityOptions
	MEMBER None := 0
	MEMBER AddUser := 1
	MEMBER NotOverwrite := 2
	MEMBER ClearOldFields := 4
	MEMBER KeepFirstLine := 8
END ENUM

END NAMESPACE

#using System.Collections.Generic
#using System.Collections.Generic
#using System.Collections

USING Xide

BEGIN NAMESPACE Xide

CLASS AbstractEditor
	EXPORT aLines AS List<LineObject>
	PROTECT nStart,nEnd AS INT
	PROTECT oCaretPos AS System.Drawing.Point
	PROTECT oBuffer AS EditorBuffer
	CONSTRUCTOR(_oBuffer AS EditorBuffer)
		SELF:oBuffer := _oBuffer
		SELF:oBuffer:FullParse()
		SELF:aLines := SELF:oBuffer:aLines
	RETURN

	METHOD BeginCode() AS VOID
		SELF:nStart := 0
		SELF:nEnd := 0
		IF SELF:oBuffer != NULL
			SELF:oBuffer:BeginAction()
		END IF
	RETURN

	METHOD EndCode() AS VOID
		IF SELF:oBuffer != NULL
			SELF:oBuffer:EndAction()
		END IF
	RETURN

	METHOD ModifiedLine(nLine AS INT) AS VOID
		IF SELF:nStart == 0 .or. SELF:nStart > nLine
			SELF:nStart := nLine
		ENDIF
		IF SELF:nEnd == 0 .or. SELF:nEnd < nLine
			SELF:nEnd := nLine
		ENDIF
	RETURN

	METHOD CheckCreatedCode() AS VOID
		IF SELF:nStart != 0
			SELF:oBuffer:LinesModified(0,0,0)
		ENDIF
		SELF:nStart := 0
		SELF:nEnd := 0
	RETURN

	METHOD AddLine(cLine AS STRING) AS VOID
		SELF:oBuffer:AddLine(cLine)
	RETURN

	METHOD InsertLine(cLine AS STRING , nLine AS INT) AS VOID
		SELF:oBuffer:InsertLine(nLine , cLine)
	RETURN

	METHOD ReplaceLine(cLine AS STRING , nLine AS INT) AS VOID
		SELF:oBuffer:ChangeLine(nLine , cLine)
	RETURN

	METHOD RemoveLine(nLine AS INT) AS VOID
		SELF:oBuffer:DeleteLine(nLine)
	RETURN

	METHOD DeleteAllLines() AS VOID
		SELF:oBuffer:DeleteAllLines()
	RETURN

END CLASS

PARTIAL CLASS CodeGenerator
	PROTECT aLines AS List<LineObject>
	PROTECT nStart,nEnd AS INT
	PROTECT oCaretPos AS System.Drawing.Point
	PROTECT oEditor , oBaseEditor , oDesEditor AS AbstractEditor

	CONSTRUCTOR(oBuffer AS EditorBuffer)
		SELF:aLines := oBuffer:aLines
		SELF:oBaseEditor := AbstractEditor{oBuffer}
	RETURN

	METHOD BeginCode() AS LOGIC
		SELF:oDesEditor := SELF:oBaseEditor
		SELF:oEditor := SELF:oBaseEditor
		SELF:oEditor:BeginCode()
	RETURN FALSE

	METHOD EndCode() AS VOID
		SELF:oEditor:EndCode()
	RETURN

METHOD ModifiedLine(nLine AS INT) AS VOID
	SELF:oEditor:ModifiedLine(nLine)
RETURN

METHOD CheckCreatedCode() AS VOID
	SELF:oEditor:CheckCreatedCode()
RETURN
METHOD GetLine(nLine AS INT) AS LineObject
	RETURN SELF:aLines[nLine - 1]

METHOD EntityExists(eType AS EntityType,cName AS STRING,cClass AS STRING) AS LOGIC
LOCAL nDummy AS INT
SELF:FindEntity(eType,cName,cClass,nDummy)
RETURN nDummy!=0

METHOD EntityExistsAnywhere(eType AS EntityType , cName AS STRING , cClass AS STRING) AS LOGIC
RETURN FALSE

METHOD FindEntity(eType AS EntityType,cName AS STRING,cClass AS STRING,nLine REF Int32) AS LOGIC
LOCAL oLine AS LineObject
LOCAL oEntity AS EntityObject
cName := cName:ToUpper():Trim()
cClass := cClass:ToUpper():Trim()
FOR nLine:=1 UPTO SELF:aLines:Count
	oLine:=SELF:GetLine(nLine)
	IF oLine:lEntity
		oEntity:=oLine:oEntity
		IF oEntity:eType == eType .and. oEntity:cTypedClassName:ToUpper() == cClass
			IF eType == EntityType._Constructor .or. oEntity:cName:ToUpper() == cName
				RETURN FALSE
			ENDIF
		END IF
	END IF
NEXT
nLine:=0
RETURN FALSE

METHOD DeleteEntity(eType AS EntityType,cName AS STRING,cClass AS STRING) AS LOGIC
	LOCAL nLine AS INT
RETURN SELF:DeleteEntity(eType , cName ,cClass , nLine)

METHOD DeleteEntity(eType AS EntityType,cName AS STRING,cClass AS STRING,nLine REF Int32) AS LOGIC
LOCAL oLine AS LineObject
LOCAL lExit AS LOGIC
LOCAL nOldLine AS INT
LOCAL cLine AS STRING
nOldLine := nLine
SELF:FindEntity(eType,cName,cClass,nLine)
IF nLine == 0
	nLine := nOldLine
	RETURN FALSE
ENDIF

DO WHILE nLine!=0
	SELF:RemoveWEDLine(nLine)
	SELF:ModifiedLine(nLine)
	IF nLine<=SELF:aLines:Count
		oLine:=SELF:GetLine(nLine)
		IF oLine:lEntity .or. lExit .or. oLine:IsEndClass
			EXIT
		END IF
		cLine := oLine:LineText:ToUpper()
		IF cLine:Contains("##USER##") .or. cLine:Contains("{{%UC%}}") .or. cLine:Contains("USER CODE STARTS")
			lExit := TRUE
		END IF
	ELSE
		EXIT
	END IF
END DO
SELF:CheckCreatedCode()
RETURN FALSE

METHOD AddInclude(cInclude AS STRING) AS VOID
	LOCAL oLine AS LineObject
	LOCAL nLine AS INT
	LOCAL n AS INT

	nLine := 1

	FOR n := 1 UPTO SELF:aLines:Count
		oLine := SELF:aLines[n - 1]
		DO CASE
		CASE oLine:lEntity
			nLine := n - 1
			EXIT
		CASE oLine:IsInclude .and. oLine:cArgument:ToUpper() == cInclude:ToUpper()
			RETURN
		END CASE
	NEXT
	IF nLine <= 0
		nLine := 1
	ENDIF

	SELF:AddWEDLine("#include " + e"\"" + cInclude + e"\"" , nLine)
	SELF:ModifiedLine(nLine)
RETURN

METHOD RemoveInclude(cInclude AS STRING) AS VOID
	FOR LOCAL nLine := 1 UPTO SELF:aLines:Count
		LOCAL oLine AS LineObject
		oLine := SELF:aLines[nLine - 1]
		DO CASE
		CASE oLine:lEntity
			RETURN
		CASE oLine:IsInclude .and. oLine:cArgument:ToUpper() == cInclude:ToUpper()
			SELF:RemoveWEDLine(nLine)
			SELF:ModifiedLine(nLine)
			RETURN
		END CASE
	NEXT
RETURN

METHOD AddLine(cLine AS STRING) AS VOID
	SELF:oEditor:AddLine(cLine)
	SELF:ModifiedLine(SELF:aLines:Count)
RETURN
METHOD InsertLine(nLine AS INT , cLine AS STRING) AS VOID
	SELF:oEditor:InsertLine(cLine , nLine)
	SELF:ModifiedLine(SELF:aLines:Count)
RETURN

METHOD AddWEDLine(cLine AS STRING,nLine REF Int32) AS LineObject
LOCAL oLine AS LineObject
IF nLine<=SELF:aLines:Count .and. nLine!=0
	SELF:oEditor:InsertLine(cLine , nLine)
	SELF:ModifiedLine(nLine)
ELSE
	SELF:oEditor:AddLine(cLine)
	nLine:=SELF:aLines:Count
	SELF:ModifiedLine(nLine)
END IF
oLine := SELF:GetLine(nLine)
nLine++
RETURN oLine
METHOD ReplaceWEDLine(cLine AS STRING,nLine AS Int32) AS LineObject
	SELF:oEditor:ReplaceLine(cLine , nLine)
	SELF:ModifiedLine(nLine)
RETURN SELF:GetLine(nLine)
METHOD RemoveWEDLine(nLine AS Int32) AS VOID
	SELF:oEditor:RemoveLine(nLine)
RETURN
METHOD Clear() AS VOID
	SELF:oEditor:DeleteAllLines()
RETURN

	STATIC PROTECT cUser := "// {{%UC%}} User code starts here (DO NOT remove this line)  " AS STRING
	STATIC PROTECT cTagU := "" AS STRING

	METHOD GetEntity(eType AS EntityType , cName AS STRING , cClass AS STRING) AS EntityObject
		LOCAL nLine AS INT
		nLine := SELF:FindEntity(eType , cName , cClass)
		IF nLine != 0
			RETURN SELF:GetLine(nLine):oEntity
		END IF
	RETURN NULL

	METHOD FindEntity(eType AS EntityType , cName AS STRING , cClass AS STRING) AS INT
		LOCAL nLine AS INT
		SELF:FindEntity(eType , cName , cClass , nLine)
	RETURN nLine

	METHOD WriteEntity(eType AS EntityType , cName AS STRING , cClass AS STRING , eOptions AS EntityOptions , aEntity AS List<STRING>) AS INT
		LOCAL oLine AS LineObject
		LOCAL nLine AS INT
		LOCAL nTemp AS INT
		LOCAL nFirst AS INT
		LOCAL lIsUser AS LOGIC
		LOCAL lRemoveFields AS LOGIC
		LOCAL n AS INT

		LOCAL cTab , ceTab AS STRING
		cTab := e"\t"
		ceTab := e"\t"

		IF aEntity:Count == 0
			RETURN 0
		END IF

		cClass := cClass:ToUpper()
		nLine := SELF:FindEntity(eType , cName , cClass)

		IF nLine == 0
			IF eType == EntityType._Class
				nLine := SELF:aLines:Count + 1
			ELSEIF eType == EntityType._Constructor
				nLine := SELF:FindEntity(EntityType._Class , cClass , cClass)
				IF nLine == 0
					RETURN 0
				END IF
				DO WHILE TRUE
					nLine ++
					IF nLine > SELF:aLines:Count
						EXIT
					END IF
					oLine := SELF:GetLine(nLine)
					IF oLine:lEntity .or. oLine:IsEndClass
						EXIT
					END IF
				END DO
			ELSE
				nLine := SELF:FindEntity(EntityType._Class , cClass , cClass)
				IF nLine == 0
					RETURN 0
				END IF
				DO WHILE TRUE
					nLine ++
					IF nLine > SELF:aLines:Count
						EXIT
					END IF
					oLine := SELF:GetLine(nLine)
					IF oLine:IsEndClass
						EXIT
					END IF
					IF oLine:lEntity .and. oLine:oEntity:cTypedClassName:ToUpper() != cClass
						EXIT
					END IF
				END DO
			END IF
			nFirst := nLine
		ELSE
			nFirst := nLine
			IF (eOptions & EntityOptions.NotOverwrite) == EntityOptions.NotOverwrite
				RETURN nFirst
			END IF
			oLine := SELF:GetLine(nLine)
			LOCAL oDeclarationLine AS LineObject
			oDeclarationLine := oLine

			DO WHILE oLine:lOutAmpersand .and. (oLine:LineText:Contains("[") .or. oLine:LineText:Contains("]"))
				nLine ++
				oLine := SELF:GetLine(nLine)
			END DO

			IF (eOptions & EntityOptions.ClearOldFields) == EntityOptions.ClearOldFields
				lRemoveFields := FALSE
				nTemp := nLine
				nTemp ++
				DO WHILE nTemp <= SELF:aLines:Count
					oLine := SELF:GetLine(nTemp)
					IF oLine:lEntity
						EXIT
					END IF
					IF oLine:IsDesignerUserStart
						lRemoveFields := TRUE
						EXIT
					ENDIF
					nTemp ++
				END DO
			ELSE
				lRemoveFields := TRUE
			END IF

			IF lRemoveFields
				nTemp := nLine
				nTemp ++
				DO WHILE nTemp <= SELF:aLines:Count
					oLine := SELF:GetLine(nTemp)
					IF oLine:lEntity .or. oLine:IsEndClass
						EXIT
					END IF
					lIsUser := oLine:IsDesignerUserStart
					SELF:RemoveWEDLine(nTemp)
					IF lIsUser
						EXIT
					ENDIF
				END DO
			END IF

			IF SELF:GetLine(nLine):LineText:ToUpper() == aEntity[0]:ToUpper() .or. (eOptions & EntityOptions.KeepFirstLine) == EntityOptions.KeepFirstLine
				nLine ++
			ELSE
				LOCAL cDeclarationLine AS STRING
				cDeclarationLine := aEntity[0]
				IF oDeclarationLine:oEntity != NULL
					IF _AND(oDeclarationLine:oEntity:eModifiers , EntityModifiers._Protected) == EntityModifiers._Protected
						cDeclarationLine := "PROTECTED " + cDeclarationLine
					ENDIF
					IF _AND(oDeclarationLine:oEntity:eModifiers , EntityModifiers._Private) == EntityModifiers._Private
						cDeclarationLine := "PRIVATE " + cDeclarationLine
					ENDIF
					IF _AND(oDeclarationLine:oEntity:eModifiers , EntityModifiers._Partial) == EntityModifiers._Partial
						cDeclarationLine := "PARTIAL " + cDeclarationLine
					ENDIF
					IF _AND(oDeclarationLine:oEntity:eModifiers , EntityModifiers._Internal) == EntityModifiers._Internal
						cDeclarationLine := "INTERNAL " + cDeclarationLine
					ENDIF
				END IF
				SELF:ReplaceWEDLine(cDeclarationLine , nLine)
				nLine ++
			END IF
			n := 1
		END IF

		DO WHILE n < aEntity:Count
			oLine := SELF:AddWEDLine(aEntity[n] , nLine)
			n ++
		END DO
		IF (eOptions & EntityOptions.AddUser) == EntityOptions.AddUser
			IF eType == EntityType._Class
				oLine := SELF:AddWEDLine(ceTab + cUser + cTagU , nLine)
			ELSE
				oLine := SELF:AddWEDLine(cTab + cUser + cTagU , nLine)
			END IF
		END IF

		IF eType != EntityType._Class
			IF nLine <= SELF:aLines:Count
				oLine := SELF:GetLine(nLine)
				IF oLine:LineText:Trim() != ""
					oLine := SELF:AddWEDLine("" , nLine)
				END IF
			END IF
		END IF

		SELF:CheckCreatedCode()
	RETURN nFirst

	METHOD WriteEndClass(cClass AS STRING) AS VOID
		LOCAL oLine AS LineObject
		LOCAL lFound AS LOGIC
		LOCAL nLine AS INT
		LOCAL n AS INT

		cClass := cClass:ToUpper()
		FOR n := 1 UPTO SELF:aLines:Count
			oLine := SELF:GetLine(n)
			IF lFound
				IF oLine:IsEndClass
					RETURN
				END IF
				IF oLine:lEntity .and. oLine:oEntity:cTypedClassName:ToUpper() != cClass
					EXIT
				END IF
				nLine := n + 1
			ELSE
				IF oLine:lEntity .and. oLine:oEntity:cTypedClassName:ToUpper() == cClass
					lFound := TRUE
					nLine := n + 1
				END IF
			END IF
		NEXT

		IF nLine != 0
			SELF:AddWEDLine("END CLASS" , nLine)
		END IF

	RETURN

	METHOD DeleteLine(nLine AS INT) AS VOID
		SELF:RemoveWEDLine(nLine)
		SELF:ModifiedLine(nLine)
	RETURN

	METHOD DeleteDefines(aDefines AS List<STRING>) AS VOID
		LOCAL oLine AS LineObject
		LOCAL nLine AS INT
		nLine := 1
		DO WHILE nLine <= SELF:aLines:Count
			LOCAL lDeleted := FALSE AS LOGIC
			oLine := SELF:aLines[nLine - 1]
			IF oLine:eType == LineType.Define .and. .not. String.IsNullOrEmpty(oLine:cArgument)
				FOREACH cDefine AS STRING IN aDefines
					IF cDefine:ToUpper() == oLine:cArgument:ToUpper()
						SELF:DeleteLine(nLine)
						lDeleted := TRUE
						EXIT
					END IF
				NEXT
			ELSEIF oLine:oEntity != NULL .and. oLine:oEntity:eType == EntityType._Define
				FOREACH cDefine AS STRING IN aDefines
					IF cDefine:ToUpper() == oLine:oEntity:cName:ToUpper()
						SELF:DeleteLine(nLine)
						lDeleted := TRUE
						EXIT
					END IF
				NEXT
			END IF
			IF .not. lDeleted
				nLine ++
			END IF
		END DO

		SELF:CheckCreatedCode()

	RETURN

	METHOD AddDefine(cDefine AS STRING , cValue AS STRING) AS VOID
		SELF:AddDefine(cDefine , cValue , TRUE)
	RETURN

	METHOD AddDefine(cDefine AS STRING , cValue AS STRING , lAdd AS LOGIC) AS VOID
		LOCAL cLine AS STRING
		cLine := String.Format("#define {0} {1}" , cDefine , cValue)
//		cLine := String.Format("DEFINE {0} := {1}" , cDefine , cValue)
		IF lAdd
			SELF:AddLine(cLine)
		ELSE
			SELF:InsertLine(1 , cLine)
		END IF
	RETURN

	METHOD AddDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING>) AS VOID
		SELF:AddDefines(aDefines , aDefineValues , TRUE)
	RETURN

	METHOD AddDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING> , lAdd AS LOGIC) AS VOID
		FOR LOCAL n := 0 AS INT UPTO aDefines:Count - 1
			SELF:AddDefine(aDefines[n] , aDefineValues[n] , lAdd)
		NEXT
	RETURN

	METHOD RemoveDefines(cWindowName as STRING) AS VOID
		LOCAL oLine AS LineObject
		LOCAL nLine AS INT
		nLine := 1
		cWindowName := cWindowName:ToUpper()+"_"
		DO WHILE nLine <= SELF:aLines:Count
			LOCAL lDeleted := FALSE AS LOGIC
			oLine := SELF:aLines[nLine - 1]
			IF oLine:eType == LineType.Define .and. .not. String.IsNullOrEmpty(oLine:cArgument)
				IF oLine:cArgument:ToUpper():StartsWith(cWindowName)
					SELF:DeleteLine(nLine)
					lDeleted := TRUE
				END IF
			ELSEIF oLine:oEntity != NULL .and. oLine:oEntity:eType == EntityType._Define
				IF oLine:oEntity:cName:ToUpper():StartsWith(cWindowName)
					SELF:DeleteLine(nLine)
					lDeleted := TRUE
				END IF
			END IF
			IF .not. lDeleted
				nLine ++
			END IF
		END DO
		SELF:CheckCreatedCode()
		RETURN

	METHOD AddXSharpDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING>) AS VOID
		SELF:AddXSharpDefines(aDefines, aDefineValues, FALSE)

	METHOD AddXSharpDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING>, lStatic AS LOGIC) AS VOID
		LOCAL cLine AS STRING
		LOCAL nLine AS INT
		FOR LOCAL n := 1 AS INT UPTO SELF:aLines:Count
			LOCAL oLine AS LineObject
			oLine := SELF:aLines[n-1]
			nLine := n
			DO CASE
			CASE oLine:oEntity != NULL
				EXIT
//			CASE oLine:IsRegionIn .and. oLine:cArgument:ToUpper() == "DEFINES"
			// grr, I am not setting cArgument for regions
			CASE oLine:IsRegionIn .and. oLine:LineText:ToUpper():Contains("DEFINES")
				nLine ++
				EXIT
			END CASE
		NEXT
		LOCAL cMask AS STRING
		cMask := "DEFINE {0} := {1}"
		IF lStatic
			cMask := "STATIC "+cMask
		ENDIF
		FOR LOCAL n := 0 AS INT UPTO aDefines:Count - 1
			cLine := String.Format(cMask , aDefines[n] , aDefineValues[n])
			SELF:InsertLine(nLine , cLine)
			nLine ++
		NEXT
	RETURN

END CLASS

[Flags];
ENUM EntityOptions
	MEMBER None := 0
	MEMBER AddUser := 1
	MEMBER NotOverwrite := 2
	MEMBER ClearOldFields := 4
	MEMBER KeepFirstLine := 8
END ENUM

END NAMESPACE


[GUI] Fixed typo in PrintingDevice contructor

USING System.Runtime.InteropServices
USING Microsoft.Win32
CLASS PrintingDevice INHERIT VObject
	PROTECT cDriver AS STRING
	PROTECT cDevice AS STRING
	PROTECT cPort AS STRING
	PROTECT hPrinter AS PTR
	PROTECT pDevMode AS _winDEVMODE
	PROTECT lValid AS LOGIC
	PROTECT iSize AS INT

	//PP-030828 Strong typing
METHOD __FillDevMode() AS LOGIC STRICT
	//PP-030828 Strong typing

	IF (pDevMode != NULL_PTR)
		MemFree(pDevMode)
		pDevMode := NULL_PTR
	ENDIF

	IF (hPrinter == NULL_PTR)
		lValid := FALSE
		RETURN FALSE
	ENDIF

	iSize := Win32.DocumentProperties( NULL_PTR, hPrinter, cDevice, NULL_PTR, NULL_PTR, 0)

	IF (iSize <= 0)
		lValid := FALSE
		RETURN FALSE
	ENDIF

	pDevMode := MemAlloc(DWORD(iSize))

	Win32.DocumentProperties(NULL_PTR, hPrinter, cDevice, pDevMode, NULL_PTR, DM_COPY)

	RETURN TRUE

ACCESS Copies

	IF (pDevMode != NULL_PTR)
		RETURN pDevMode:dmCopies
	ENDIF
	RETURN 0

ASSIGN Copies(nCopies)

	IF (pDevMode == NULL_PTR)
		RETURN 0
	ENDIF

	pDevMode:dmCopies := nCopies
	SELF:UpdateDevMode()

	RETURN

METHOD Destroy()

	IF (hPrinter != NULL_PTR)
		Win32.ClosePrinter( hPrinter)
	ENDIF

	IF (pDevMode != NULL_PTR)
		MemFree(pDevMode)
	ENDIF

	IF !InCollect()
		//PP-030505
		lValid := FALSE

		//PP-040418 Issue 12733
		UnregisterAxit(SELF)
		hPrinter := NULL_PTR
		pDevMode := NULL_PTR
	ENDIF

	RETURN  SELF

ACCESS Device

	RETURN cDevice

METHOD DeviceCapabilities(wCapability)
	LOCAL pWord				AS WORD PTR
	LOCAL pDWord			AS DWORD PTR
	LOCAL pLong				AS LONGINT PTR
	LOCAL pByte				AS BYTE PTR
	LOCAL dwReturn			AS DWORD
	LOCAL dwTotal			AS DWORD
	LOCAL aReturn := {}	AS ARRAY
	LOCAL uReturn 			AS USUAL
	LOCAL i, dwTrail, dwStart 	AS DWORD
	LOCAL nElementSize	AS DWORD
	LOCAL bSave				AS BYTE
	LOCAL pszData			AS PSZ

	// For DC_COPIES, DC_DRIVER, DC_DUPLEX, DC_EXTRA, DC_FIELDS, DC_MAXSIZE, DC_MINSIZE
	// DC_SIZE, DC_ORIENTATION, DC_TRUETYPE and DC_VERSION dwReturn is the value for the capabilty.
	// For all others capabalities it is the size of the buffer needed to hold the value.
	// A second call is then required.

	dwReturn := Win32.DeviceCapabilities(cDevice, cPort, WORD(wCapability),NULL, pDevMode)

	IF (dwReturn == 0xFFFFFFFF)					// unsupported capability
		uReturn := dwReturn

	ELSEIF (wCapability == DC_MAXEXTENT)	.OR. (wCapability == DC_MINEXTENT)
	   AAdd(aReturn, LoWord(dwReturn))
	   AAdd(aReturn, HiWord(dwReturn))
	   uReturn := aReturn

	ELSEIF (wCapability == DC_BINS) .OR. (wCapability == DC_PAPERS)
		// array of words
		pWord := MemAlloc(dwReturn* _SIZEOF(WORD))
		Win32.DeviceCapabilities( cDevice, cPort, WORD(wCapability),pWord, pDevMode)

		FOR i := 1 TO dwReturn
			AAdd(aReturn, pWord[i])
		NEXT

		uReturn := aReturn
		MemFree(pWord)

	ELSEIF  wCapability == DC_BINNAMES .OR. wCapability == DC_FILEDEPENDENCIES ;
		.OR. wCapability == DC_PAPERNAMES .OR. wCapability == DC_MEDIATYPENAMES ;
		.OR. wCapability == DC_PERSONALITY
		// Array of PSZs.
		// Set element size
		nElementSize := 0
  		IF wCapability == DC_BINNAMES
  			nElementSize := CCHBINNAME 	// 24

  		ELSEIF  wCapability == DC_FILEDEPENDENCIES ;
  			.OR. wCapability == DC_PAPERNAMES;
  			.OR. wCapability == DC_MEDIATYPENAMES
  			nElementSize := CCHPAPERNAME	// 64

  		ELSEIF wCapability == DC_PERSONALITY
  			nElementSize := 32

  		ELSE
  			// What did I miss ?

  		ENDIF
  		IF nElementSize > 0
			// array of nElementSize byte "c" strings
			dwTotal := dwReturn * nElementSize
			pByte := MemAlloc(dwTotal+1)
			Win32.DeviceCapabilities(cDevice, cPort, WORD(wCapability),pByte, pDevMode)

			FOR i := 1 TO dwTotal STEP nElementSize
				// If the Element = nElementSize characters we have no 0 terminator !
				// So make sure we set one
				dwStart := i
				dwTrail := dwStart + nElementSize
	         bSave   := pByte[dwTrail]
				pByte[dwTrail] := 0
				pszData := pByte + dwStart -1
				AAdd(aReturn, Trim(Psz2String(pszData)))
				pByte[dwTrail] := bSave
			NEXT
			MemFree(pByte)
  		ENDIF
		uReturn := aReturn

	ELSEIF wCapability == DC_ENUMRESOLUTIONS
		// array of pairs of long ints
		pLong := MemAlloc(dwReturn * 2 * _SIZEOF(LONGINT))
		Win32.DeviceCapabilities(cDevice, cPort, WORD(wCapability),pLong, pDevMode)

		FOR i := 1 TO dwReturn
			AAdd(aReturn, { pLong[i*2-1], pLong[i*2]})
		NEXT

		uReturn := aReturn
		MemFree(pLong)

	ELSEIF wCapability == DC_MEDIATYPES .OR. wCapability == DC_NUP
		// array of DWORDS
		pDWord := MemAlloc(dwReturn * _SIZEOF(DWORD))
		Win32.DeviceCapabilities(cDevice, cPort, WORD(wCapability),pDWord, pDevMode)

		FOR i := 1 TO dwReturn
			AAdd(aReturn, pDWord[i])
		NEXT

		uReturn := aReturn
		MemFree(pDWord)

	ELSEIF (wCapability == DC_PAPERSIZE)
		// array of pairs of Longs
		pLong  := MemAlloc(dwReturn*2 * _SIZEOF(LONGINT))

		Win32.DeviceCapabilities(cDevice, cPort, WORD(wCapability),pLong, pDevMode)

		FOR i := 1 TO dwReturn
			AAdd(aReturn, { pLong[i*2-1], pLong[i*2]})
		NEXT

		uReturn := aReturn
		MemFree(pLong)
	ELSE	// dwReturn is desired value
		uReturn := dwReturn

	ENDIF

	RETURN uReturn

ACCESS Driver

	RETURN cDriver

METHOD GetDevMode()

	RETURN pDevMode

CONSTRUCTOR(uName)
	LOCAL cTemp     AS STRING

	SUPER()

	IF IsNil(uName)
        LOCAL oKey AS  RegistryKey
        LOCAL cSKey AS STRING
        oKey := Registry.CurrentUser:OpenSubKey( "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices")
        IF okey != NULL_OBJECT
            FOREACH csubKeyName AS STRING IN okey:GetSubKeyNames()
                cSKey := csubKeyName
            NEXT
            cTemp  := (STRING) Registry.GetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\" + cSKey ,"Device","")
        ENDIF
        IF Empty(cTemp)
            cTemp := (STRING) Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device","")
        ENDIF
	ELSE
		IF !IsString(uName)
			WCError{#Init,#PrintingDevice,__WCSTypeError,uName,1}:Throw()
		ENDIF
		cTemp:=uName
	ENDIF

    LOCAL sParts AS STRING[]
    sParts := cTemp:Split(",":ToCharArray())
    SELF:cDevice := sParts[1]
    IF sParts:Length > 1
        SELF:cDriver := sParts[2]
    ENDIF
    IF sParts:Length > 2
        SELF:cPort := sParts[3]
    ENDIF
	lValid := Win32.OpenPrinter( SELF:cDevice, REF hPrinter, NULL_PTR)
	isize := _SIZEOF(_winDEVMODE)

	SELF:__FillDevMode()

	RETURN

METHOD IsValid()

	RETURN lValid

ACCESS Orientation

	IF (pDevMode != NULL_PTR)
		RETURN pDevMode:dmOrientation
	ENDIF
	RETURN 0

ASSIGN Orientation(nOrientation)

	IF (pDevMode == NULL_PTR)
		RETURN 0
	ENDIF

	pDevMode:dmOrientation := nOrientation
	SELF:UpdateDevMode()

	RETURN

ACCESS PaperHeight

	IF (pDevMode != NULL_PTR)
		RETURN pDevMode:dmPaperLength
	ENDIF
	RETURN 0

ASSIGN PaperHeight(nHeight)

	IF (pDevMode == NULL_PTR)
		RETURN 0
	ENDIF

	pDevMode:dmPaperLength := nHeight
	SELF:UpdateDevMode()

	RETURN

ACCESS PaperSize

	IF (pDevMode != NULL_PTR)
		RETURN pDevMode:dmPaperSize
	ENDIF
	RETURN 0

ASSIGN PaperSize(nSize)

	IF (pDevMode == NULL_PTR)
		RETURN 0
	ENDIF

	pDevMode:dmPaperSize := nSize
	SELF:UpdateDevMode()

	RETURN

ACCESS PaperWidth

	IF (pDevMode != NULL_PTR)
		RETURN pDevMode:dmPaperWidth
	ENDIF
	RETURN 0

ASSIGN PaperWidth(nWidth)

	IF (pDevMode == NULL_PTR)
		RETURN 0
	ENDIF

	pDevMode:dmPaperWidth := nWidth
	SELF:UpdateDevMode()

	RETURN

ACCESS Port

	RETURN cPort

METHOD SetUp()
	LOCAL pd 			IS _WinPrintDlg
	LOCAL struDevN 	AS _windevNames
	LOCAL lRetVal 		AS LOGIC
	LOCAL ptrHandle 	AS PTR
	LOCAL ptrString 	AS PTR
	LOCAL hDevMode 	AS PTR
	LOCAL pTemp 		AS PTR
	LOCAL pDVTemp 		AS _winDEVMODE

 	ptrHandle := GetActiveWindow()
	lRetVal := TRUE
	pd:lStructSize := _SIZEOF(_winPRINTDLG)

	IF (ptrHandle != NULL_PTR)
		pd:hwndOwner := ptrHandle
	ELSE
		pd:hwndOwner := NULL_PTR
	ENDIF

	hDevMode := GlobalAlloc(GHND, DWORD(iSize))
	IF (hDevMode != NULL_PTR) .AND. (pDevMode != NULL_PTR)
		pTemp := GlobalLock(hDevMode)
		MemCopy(pTemp, pDevMode, DWORD(iSize))
		GlobalUnlock(hDevMode)
	ENDIF

	pd:hDevMode := hDevMode
	pd:hDevNames := NULL_PTR
	pd:nFromPage := 0
	pd:nToPage := 0
	pd:nMinPage := 0
	pd:nMaxPage := 0
	pd:nCopies := 0
	pd:hInstance := _GetInst()
	pd:Flags := _OR(PD_USEDEVMODECOPIES, PD_COLLATE, PD_SELECTION, PD_PRINTSETUP)
	pd:lpfnSetupHook := NULL_PTR
	pd:lpSetupTemplateName := NULL_PTR
	pd:lpfnPrintHook := NULL_PTR
	pd:lpPrintTemplateName := NULL_PTR

	IF !PrintDlg( @pd)
		//PP-030505 Bug:122
		lValid := FALSE
		lRetVal := FALSE
	ELSE
		//PP-030505 Bug:122
		lValid := TRUE
		//Liuho01 05-30-96
		//Get the Devive name, Driver name, and port name which user selected
		struDevN := GlobalLock(pd:hDevNames)
		ptrString := PTR(_CAST,(DWORD(_CAST,struDevN) + struDevN:wDriverOffset ))
		cDriver := Psz2String(ptrString)
		ptrString := PTR(_CAST,(DWORD(_CAST,struDevN) + struDevN:wDeviceOffset ))
		cDevice := Psz2String(ptrString)
		ptrString := PTR(_CAST,(DWORD(_CAST,struDevN) + struDevN:wOutPutOffset ))
		cPort := Psz2String(ptrString)
		GlobalUnlock(pd:hDevNames)
		GlobalFree(pd:hDevNames)
		//Liuho01 05-30-96
		//Get the information about the printer envirenment which user select.

		pDVTemp := GlobalLock(pd:hDevMode)
		iSize := pDVTemp:dmSize + pDVTemp:dmDriverExtra
		IF (pDevMode == NULL_PTR)
			pDevMode := MemAlloc(DWORD(iSize))
		ELSE
			pDevMode := MemRealloc(pDevMode, DWORD(iSize))
		ENDIF
		MemCopy(pDevMode, pDVTemp, DWORD(iSize))
		GlobalUnlock(pd:hDevMode)
		GlobalFree(pd:hDevMode)
	ENDIF

	RETURN lRetVal

METHOD UpdateDevMode()
	LOCAL iRes AS INT

	IF (pDevMode == NULL_PTR)
		RETURN FALSE
	ENDIF

	iRes := Win32.DocumentProperties(NULL_PTR, hPrinter, cDevice, NULL_PTR, pDevMode, DM_MODIFY)

	RETURN (iRes >= 0)

END CLASS

FUNCTION __LoadWinSpoolDLL()
RETURN TRUE

INTERNAL STATIC CLASS Win32
    [DllImport("WinSpool.drv", SetLastError := TRUE, EntryPoint := "ClosePrinter", CharSet := CharSet.Ansi)];
    STATIC EXTERN METHOD ClosePrinter(hPrinter AS PTR) AS LOGIC STRICT

    [DllImport("WinSpool.drv", SetLastError := TRUE, EntryPoint := "DeviceCapabilitiesA", CharSet := CharSet.Ansi)];
    STATIC EXTERN METHOD DeviceCapabilities(lpszDevice AS STRING, lpszPort AS STRING, wCapability AS WORD, lpszOutput AS PTR,;   // 070625 changed param 4 type from PSZ to PTR
	pDevMode AS PTR) AS DWORD STRICT

    [DllImport("WinSpool.drv", SetLastError := TRUE, EntryPoint := "DocumentPropertiesA", CharSet := CharSet.Ansi)];
    STATIC EXTERN METHOD DocumentProperties(hWnd AS PTR, pPrinter AS PTR, pDevicename AS STRING, pDevModeOutput AS _winDEVMODE,;
	pDevModeInput AS _winDEVMODE, fMode AS DWORD) AS LONGINT STRICT

    [DllImport("WinSpool.drv", SetLastError := TRUE, EntryPoint := "OpenPrinterA", CharSet := CharSet.Ansi)];
    STATIC EXTERN METHOD OpenPrinter(pPrinterName AS STRING, phPrinter REF PTR, pDefault AS _winPRINTER_DEFAULTS) AS LOGIC STRICT
END CLASS

#region defines
DEFINE CAPABILITY_NOT_AVAILABLE := 0xFFFFFFFF
DEFINE CCHBINNAME := 24
DEFINE CCHPAPERNAME := 64
#endregion

USING System.Runtime.InteropServices
USING Microsoft.Win32
CLASS PrintingDevice INHERIT VObject
	PROTECT cDriver AS STRING
	PROTECT cDevice AS STRING
	PROTECT cPort AS STRING
	PROTECT hPrinter AS PTR
	PROTECT pDevMode AS _winDEVMODE
	PROTECT lValid AS LOGIC
	PROTECT iSize AS INT

	//PP-030828 Strong typing
METHOD __FillDevMode() AS LOGIC STRICT
	//PP-030828 Strong typing

	IF (pDevMode != NULL_PTR)
		MemFree(pDevMode)
		pDevMode := NULL_PTR
	ENDIF

	IF (hPrinter == NULL_PTR)
		lValid := FALSE
		RETURN FALSE
	ENDIF

	iSize := Win32.DocumentProperties( NULL_PTR, hPrinter, cDevice, NULL_PTR, NULL_PTR, 0)

	IF (iSize <= 0)
		lValid := FALSE
		RETURN FALSE
	ENDIF

	pDevMode := MemAlloc(DWORD(iSize))

	Win32.DocumentProperties(NULL_PTR, hPrinter, cDevice, pDevMode, NULL_PTR, DM_COPY)

	RETURN TRUE

ACCESS Copies

	IF (pDevMode != NULL_PTR)
		RETURN pDevMode:dmCopies
	ENDIF
	RETURN 0

ASSIGN Copies(nCopies)

	IF (pDevMode == NULL_PTR)
		RETURN 0
	ENDIF

	pDevMode:dmCopies := nCopies
	SELF:UpdateDevMode()

	RETURN

METHOD Destroy()

	IF (hPrinter != NULL_PTR)
		Win32.ClosePrinter( hPrinter)
	ENDIF

	IF (pDevMode != NULL_PTR)
		MemFree(pDevMode)
	ENDIF

	IF !InCollect()
		//PP-030505
		lValid := FALSE

		//PP-040418 Issue 12733
		UnregisterAxit(SELF)
		hPrinter := NULL_PTR
		pDevMode := NULL_PTR
	ENDIF

	RETURN  SELF

ACCESS Device

	RETURN cDevice

METHOD DeviceCapabilities(wCapability)
	LOCAL pWord				AS WORD PTR
	LOCAL pDWord			AS DWORD PTR
	LOCAL pLong				AS LONGINT PTR
	LOCAL pByte				AS BYTE PTR
	LOCAL dwReturn			AS DWORD
	LOCAL dwTotal			AS DWORD
	LOCAL aReturn := {}	AS ARRAY
	LOCAL uReturn 			AS USUAL
	LOCAL i, dwTrail, dwStart 	AS DWORD
	LOCAL nElementSize	AS DWORD
	LOCAL bSave				AS BYTE
	LOCAL pszData			AS PSZ

	// For DC_COPIES, DC_DRIVER, DC_DUPLEX, DC_EXTRA, DC_FIELDS, DC_MAXSIZE, DC_MINSIZE
	// DC_SIZE, DC_ORIENTATION, DC_TRUETYPE and DC_VERSION dwReturn is the value for the capabilty.
	// For all others capabalities it is the size of the buffer needed to hold the value.
	// A second call is then required.

	dwReturn := Win32.DeviceCapabilities(cDevice, cPort, WORD(wCapability),NULL, pDevMode)

	IF (dwReturn == 0xFFFFFFFF)					// unsupported capability
		uReturn := dwReturn

	ELSEIF (wCapability == DC_MAXEXTENT)	.OR. (wCapability == DC_MINEXTENT)
	   AAdd(aReturn, LoWord(dwReturn))
	   AAdd(aReturn, HiWord(dwReturn))
	   uReturn := aReturn

	ELSEIF (wCapability == DC_BINS) .OR. (wCapability == DC_PAPERS)
		// array of words
		pWord := MemAlloc(dwReturn* _SIZEOF(WORD))
		Win32.DeviceCapabilities( cDevice, cPort, WORD(wCapability),pWord, pDevMode)

		FOR i := 1 TO dwReturn
			AAdd(aReturn, pWord[i])
		NEXT

		uReturn := aReturn
		MemFree(pWord)

	ELSEIF  wCapability == DC_BINNAMES .OR. wCapability == DC_FILEDEPENDENCIES ;
		.OR. wCapability == DC_PAPERNAMES .OR. wCapability == DC_MEDIATYPENAMES ;
		.OR. wCapability == DC_PERSONALITY
		// Array of PSZs.
		// Set element size
		nElementSize := 0
  		IF wCapability == DC_BINNAMES
  			nElementSize := CCHBINNAME 	// 24

  		ELSEIF  wCapability == DC_FILEDEPENDENCIES ;
  			.OR. wCapability == DC_PAPERNAMES;
  			.OR. wCapability == DC_MEDIATYPENAMES
  			nElementSize := CCHPAPERNAME	// 64

  		ELSEIF wCapability == DC_PERSONALITY
  			nElementSize := 32

  		ELSE
  			// What did I miss ?

  		ENDIF
  		IF nElementSize > 0
			// array of nElementSize byte "c" strings
			dwTotal := dwReturn * nElementSize
			pByte := MemAlloc(dwTotal+1)
			Win32.DeviceCapabilities(cDevice, cPort, WORD(wCapability),pByte, pDevMode)

			FOR i := 1 TO dwTotal STEP nElementSize
				// If the Element = nElementSize characters we have no 0 terminator !
				// So make sure we set one
				dwStart := i
				dwTrail := dwStart + nElementSize
	         bSave   := pByte[dwTrail]
				pByte[dwTrail] := 0
				pszData := pByte + dwStart -1
				AAdd(aReturn, Trim(Psz2String(pszData)))
				pByte[dwTrail] := bSave
			NEXT
			MemFree(pByte)
  		ENDIF
		uReturn := aReturn

	ELSEIF wCapability == DC_ENUMRESOLUTIONS
		// array of pairs of long ints
		pLong := MemAlloc(dwReturn * 2 * _SIZEOF(LONGINT))
		Win32.DeviceCapabilities(cDevice, cPort, WORD(wCapability),pLong, pDevMode)

		FOR i := 1 TO dwReturn
			AAdd(aReturn, { pLong[i*2-1], pLong[i*2]})
		NEXT

		uReturn := aReturn
		MemFree(pLong)

	ELSEIF wCapability == DC_MEDIATYPES .OR. wCapability == DC_NUP
		// array of DWORDS
		pDWord := MemAlloc(dwReturn * _SIZEOF(DWORD))
		Win32.DeviceCapabilities(cDevice, cPort, WORD(wCapability),pDWord, pDevMode)

		FOR i := 1 TO dwReturn
			AAdd(aReturn, pDWord[i])
		NEXT

		uReturn := aReturn
		MemFree(pDWord)

	ELSEIF (wCapability == DC_PAPERSIZE)
		// array of pairs of Longs
		pLong  := MemAlloc(dwReturn*2 * _SIZEOF(LONGINT))

		Win32.DeviceCapabilities(cDevice, cPort, WORD(wCapability),pLong, pDevMode)

		FOR i := 1 TO dwReturn
			AAdd(aReturn, { pLong[i*2-1], pLong[i*2]})
		NEXT

		uReturn := aReturn
		MemFree(pLong)
	ELSE	// dwReturn is desired value
		uReturn := dwReturn

	ENDIF

	RETURN uReturn

ACCESS Driver

	RETURN cDriver

METHOD GetDevMode()

	RETURN pDevMode

CONSTRUCTOR(uName)
	LOCAL cTemp     AS STRING

	SUPER()

	IF IsNil(uName)
        LOCAL oKey AS  RegistryKey
        LOCAL cSKey AS STRING
        oKey := Registry.CurrentUser:OpenSubKey( "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices")
        IF okey != NULL_OBJECT
            FOREACH csubKeyName AS STRING IN okey:GetSubKeyNames()
                cSKey := csubKeyName
            NEXT
            cTemp  := (STRING) Registry.GetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\" + cSKey ,"Device","")
        ENDIF
        IF Empty(cDevice)
            cTemp := (STRING) Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device","")
        ENDIF
	ELSE
		IF !IsString(uName)
			WCError{#Init,#PrintingDevice,__WCSTypeError,uName,1}:Throw()
		ENDIF
		cTemp:=uName
	ENDIF

    LOCAL sParts AS STRING[]
    sParts := cTemp:Split(",":ToCharArray())
    SELF:cDevice := sParts[1]
    IF sParts:Length > 1
        SELF:cDriver := sParts[2]
    ENDIF
    IF sParts:Length > 2
        SELF:cPort := sParts[3]
    ENDIF
	lValid := Win32.OpenPrinter( SELF:cDevice, REF hPrinter, NULL_PTR)
	isize := _SIZEOF(_winDEVMODE)

	SELF:__FillDevMode()

	RETURN

METHOD IsValid()

	RETURN lValid

ACCESS Orientation

	IF (pDevMode != NULL_PTR)
		RETURN pDevMode:dmOrientation
	ENDIF
	RETURN 0

ASSIGN Orientation(nOrientation)

	IF (pDevMode == NULL_PTR)
		RETURN 0
	ENDIF

	pDevMode:dmOrientation := nOrientation
	SELF:UpdateDevMode()

	RETURN

ACCESS PaperHeight

	IF (pDevMode != NULL_PTR)
		RETURN pDevMode:dmPaperLength
	ENDIF
	RETURN 0

ASSIGN PaperHeight(nHeight)

	IF (pDevMode == NULL_PTR)
		RETURN 0
	ENDIF

	pDevMode:dmPaperLength := nHeight
	SELF:UpdateDevMode()

	RETURN

ACCESS PaperSize

	IF (pDevMode != NULL_PTR)
		RETURN pDevMode:dmPaperSize
	ENDIF
	RETURN 0

ASSIGN PaperSize(nSize)

	IF (pDevMode == NULL_PTR)
		RETURN 0
	ENDIF

	pDevMode:dmPaperSize := nSize
	SELF:UpdateDevMode()

	RETURN

ACCESS PaperWidth

	IF (pDevMode != NULL_PTR)
		RETURN pDevMode:dmPaperWidth
	ENDIF
	RETURN 0

ASSIGN PaperWidth(nWidth)

	IF (pDevMode == NULL_PTR)
		RETURN 0
	ENDIF

	pDevMode:dmPaperWidth := nWidth
	SELF:UpdateDevMode()

	RETURN

ACCESS Port

	RETURN cPort

METHOD SetUp()
	LOCAL pd 			IS _WinPrintDlg
	LOCAL struDevN 	AS _windevNames
	LOCAL lRetVal 		AS LOGIC
	LOCAL ptrHandle 	AS PTR
	LOCAL ptrString 	AS PTR
	LOCAL hDevMode 	AS PTR
	LOCAL pTemp 		AS PTR
	LOCAL pDVTemp 		AS _winDEVMODE

 	ptrHandle := GetActiveWindow()
	lRetVal := TRUE
	pd:lStructSize := _SIZEOF(_winPRINTDLG)

	IF (ptrHandle != NULL_PTR)
		pd:hwndOwner := ptrHandle
	ELSE
		pd:hwndOwner := NULL_PTR
	ENDIF

	hDevMode := GlobalAlloc(GHND, DWORD(iSize))
	IF (hDevMode != NULL_PTR) .AND. (pDevMode != NULL_PTR)
		pTemp := GlobalLock(hDevMode)
		MemCopy(pTemp, pDevMode, DWORD(iSize))
		GlobalUnlock(hDevMode)
	ENDIF

	pd:hDevMode := hDevMode
	pd:hDevNames := NULL_PTR
	pd:nFromPage := 0
	pd:nToPage := 0
	pd:nMinPage := 0
	pd:nMaxPage := 0
	pd:nCopies := 0
	pd:hInstance := _GetInst()
	pd:Flags := _OR(PD_USEDEVMODECOPIES, PD_COLLATE, PD_SELECTION, PD_PRINTSETUP)
	pd:lpfnSetupHook := NULL_PTR
	pd:lpSetupTemplateName := NULL_PTR
	pd:lpfnPrintHook := NULL_PTR
	pd:lpPrintTemplateName := NULL_PTR

	IF !PrintDlg( @pd)
		//PP-030505 Bug:122
		lValid := FALSE
		lRetVal := FALSE
	ELSE
		//PP-030505 Bug:122
		lValid := TRUE
		//Liuho01 05-30-96
		//Get the Devive name, Driver name, and port name which user selected
		struDevN := GlobalLock(pd:hDevNames)
		ptrString := PTR(_CAST,(DWORD(_CAST,struDevN) + struDevN:wDriverOffset ))
		cDriver := Psz2String(ptrString)
		ptrString := PTR(_CAST,(DWORD(_CAST,struDevN) + struDevN:wDeviceOffset ))
		cDevice := Psz2String(ptrString)
		ptrString := PTR(_CAST,(DWORD(_CAST,struDevN) + struDevN:wOutPutOffset ))
		cPort := Psz2String(ptrString)
		GlobalUnlock(pd:hDevNames)
		GlobalFree(pd:hDevNames)
		//Liuho01 05-30-96
		//Get the information about the printer envirenment which user select.

		pDVTemp := GlobalLock(pd:hDevMode)
		iSize := pDVTemp:dmSize + pDVTemp:dmDriverExtra
		IF (pDevMode == NULL_PTR)
			pDevMode := MemAlloc(DWORD(iSize))
		ELSE
			pDevMode := MemRealloc(pDevMode, DWORD(iSize))
		ENDIF
		MemCopy(pDevMode, pDVTemp, DWORD(iSize))
		GlobalUnlock(pd:hDevMode)
		GlobalFree(pd:hDevMode)
	ENDIF

	RETURN lRetVal

METHOD UpdateDevMode()
	LOCAL iRes AS INT

	IF (pDevMode == NULL_PTR)
		RETURN FALSE
	ENDIF

	iRes := Win32.DocumentProperties(NULL_PTR, hPrinter, cDevice, NULL_PTR, pDevMode, DM_MODIFY)

	RETURN (iRes >= 0)

END CLASS

FUNCTION __LoadWinSpoolDLL()
RETURN TRUE

INTERNAL STATIC CLASS Win32
    [DllImport("WinSpool.drv", SetLastError := TRUE, EntryPoint := "ClosePrinter", CharSet := CharSet.Ansi)];
    STATIC EXTERN METHOD ClosePrinter(hPrinter AS PTR) AS LOGIC STRICT

    [DllImport("WinSpool.drv", SetLastError := TRUE, EntryPoint := "DeviceCapabilitiesA", CharSet := CharSet.Ansi)];
    STATIC EXTERN METHOD DeviceCapabilities(lpszDevice AS STRING, lpszPort AS STRING, wCapability AS WORD, lpszOutput AS PTR,;   // 070625 changed param 4 type from PSZ to PTR
	pDevMode AS PTR) AS DWORD STRICT

    [DllImport("WinSpool.drv", SetLastError := TRUE, EntryPoint := "DocumentPropertiesA", CharSet := CharSet.Ansi)];
    STATIC EXTERN METHOD DocumentProperties(hWnd AS PTR, pPrinter AS PTR, pDevicename AS STRING, pDevModeOutput AS _winDEVMODE,;
	pDevModeInput AS _winDEVMODE, fMode AS DWORD) AS LONGINT STRICT

    [DllImport("WinSpool.drv", SetLastError := TRUE, EntryPoint := "OpenPrinterA", CharSet := CharSet.Ansi)];
    STATIC EXTERN METHOD OpenPrinter(pPrinterName AS STRING, phPrinter REF PTR, pDefault AS _winPRINTER_DEFAULTS) AS LOGIC STRICT
END CLASS

#region defines
DEFINE CAPABILITY_NOT_AVAILABLE := 0xFFFFFFFF
DEFINE CCHBINNAME := 24
DEFINE CCHPAPERNAME := 64
#endregion


QAction: class updated - methods new1, new2 and new3 removed - methods setShortcuts1 and setShortcuts2 removed - formatting

/*

  Qt5xHb - bibliotecas de ligao entre Harbour/xHarbour e Qt Framework 5

  Copyright (C) 2012-2017 Marcos Antonio Gambeta <marcosgambeta@uol.com.br>

*/

#include "hbclass.ch"
#include "qt5xhb_clsid.ch"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QACTIONGROUP
REQUEST QGRAPHICSWIDGET
REQUEST QWIDGET
REQUEST QVARIANT
REQUEST QFONT
REQUEST QICON
REQUEST QMENU
REQUEST QKEYSEQUENCE
#endif

CLASS QAction INHERIT QObject

   DATA class_id INIT Class_Id_QAction
   DATA class_flags INIT 1
   DATA self_destruction INIT .F.

   METHOD new
   METHOD delete
   METHOD actionGroup
   METHOD activate
   METHOD associatedGraphicsWidgets
   METHOD associatedWidgets
   METHOD autoRepeat
   METHOD data
   METHOD font
   METHOD icon
   METHOD iconText
   METHOD isCheckable
   METHOD isChecked
   METHOD isEnabled
   METHOD isIconVisibleInMenu
   METHOD isSeparator
   METHOD isVisible
   METHOD menu
   METHOD menuRole
   METHOD parentWidget
   METHOD priority
   METHOD setActionGroup
   METHOD setAutoRepeat
   METHOD setCheckable
   METHOD setData
   METHOD setFont
   METHOD setIcon
   METHOD setIconText
   METHOD setIconVisibleInMenu
   METHOD setMenu
   METHOD setMenuRole
   METHOD setPriority
   METHOD setSeparator
   METHOD setShortcut
   METHOD setShortcutContext
   METHOD setShortcuts
   METHOD setStatusTip
   METHOD setText
   METHOD setToolTip
   METHOD setWhatsThis
   METHOD shortcut
   METHOD shortcutContext
   METHOD shortcuts
   METHOD showStatusText
   METHOD statusTip
   METHOD text
   METHOD toolTip
   METHOD whatsThis
   METHOD hover
   METHOD setChecked
   METHOD setDisabled
   METHOD setEnabled
   METHOD setVisible
   METHOD toggle
   METHOD trigger
   METHOD onChanged
   METHOD onHovered
   METHOD onToggled
   METHOD onTriggered
   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject () CLASS QAction
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#include <QAction>
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_clsid.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#include <QAction>
#endif

/*
QAction ( QObject * parent )
*/
void QAction_new1 ()
{
  QObject * par1 = (QObject *) _qt5xhb_itemGetPtr(1);
  QAction * o = new QAction ( par1 );
  _qt5xhb_storePointerAndFlag( o, false );
}

/*
QAction ( const QString & text, QObject * parent )
*/
void QAction_new2 ()
{
  QString par1 = QLatin1String( hb_parc(1) );
  QObject * par2 = (QObject *) _qt5xhb_itemGetPtr(2);
  QAction * o = new QAction ( par1, par2 );
  _qt5xhb_storePointerAndFlag( o, false );
}

/*
QAction ( const QIcon & icon, const QString & text, QObject * parent )
*/
void QAction_new3 ()
{
  QIcon par1 = ISOBJECT(1)? *(QIcon *) _qt5xhb_itemGetPtr(1) : QIcon(hb_parc(1));
  QString par2 = QLatin1String( hb_parc(2) );
  QObject * par3 = (QObject *) _qt5xhb_itemGetPtr(3);
  QAction * o = new QAction ( par1, par2, par3 );
  _qt5xhb_storePointerAndFlag( o, false );
}

//[1]QAction ( QObject * parent )
//[2]QAction ( const QString & text, QObject * parent )
//[3]QAction ( const QIcon & icon, const QString & text, QObject * parent )

HB_FUNC_STATIC( QACTION_NEW )
{
  if( ISNUMPAR(1) && ISQOBJECT(1) )
  {
    QAction_new1();
  }
  else if( ISNUMPAR(2) && ISCHAR(1) && ISQOBJECT(2) )
  {
    QAction_new2();
  }
  else if( ISNUMPAR(3) && (ISQICON(1)||ISCHAR(1)) && ISCHAR(2) && ISQOBJECT(3) )
  {
    QAction_new3();
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

HB_FUNC_STATIC( QACTION_DELETE )
{
  QAction * obj = (QAction *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );

  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
QActionGroup * actionGroup () const
*/
HB_FUNC_STATIC( QACTION_ACTIONGROUP )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QActionGroup * ptr = obj->actionGroup (  );
    _qt5xhb_createReturnClass ( ptr, "QACTIONGROUP" );
  }
}

/*
void activate ( ActionEvent event )
*/
HB_FUNC_STATIC( QACTION_ACTIVATE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    int par1 = hb_parni(1);
    obj->activate (  (QAction::ActionEvent) par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
QList<QGraphicsWidget *> associatedGraphicsWidgets () const
*/
HB_FUNC_STATIC( QACTION_ASSOCIATEDGRAPHICSWIDGETS )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QList<QGraphicsWidget *> list = obj->associatedGraphicsWidgets (  );
    PHB_DYNS pDynSym;
    #ifdef __XHARBOUR__
    pDynSym = hb_dynsymFind( "QGRAPHICSWIDGET" );
    #else
    pDynSym = hb_dynsymFindName( "QGRAPHICSWIDGET" );
    #endif
    PHB_ITEM pArray;
    pArray = hb_itemArrayNew(0);
    int i;
    for(i=0;i<list.count();i++)
    {
      if( pDynSym )
      {
        #ifdef __XHARBOUR__
        hb_vmPushSymbol( pDynSym->pSymbol );
        #else
        hb_vmPushDynSym( pDynSym );
        #endif
        hb_vmPushNil();
        hb_vmDo( 0 );
        PHB_ITEM pObject = hb_itemNew( NULL );
        hb_itemCopy( pObject, hb_stackReturnItem() );
        PHB_ITEM pItem = hb_itemNew( NULL );
        hb_itemPutPtr( pItem, (QGraphicsWidget *) list[i] );
        hb_objSendMsg( pObject, "_POINTER", 1, pItem );
        hb_arrayAddForward( pArray, pObject );
        hb_itemRelease( pObject );
        hb_itemRelease( pItem );
      }
    }
    hb_itemReturnRelease(pArray);
  }
}

/*
QList<QWidget *> associatedWidgets () const
*/
HB_FUNC_STATIC( QACTION_ASSOCIATEDWIDGETS )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QList<QWidget *> list = obj->associatedWidgets (  );
    PHB_DYNS pDynSym;
    #ifdef __XHARBOUR__
    pDynSym = hb_dynsymFind( "QWIDGET" );
    #else
    pDynSym = hb_dynsymFindName( "QWIDGET" );
    #endif
    PHB_ITEM pArray;
    pArray = hb_itemArrayNew(0);
    int i;
    for(i=0;i<list.count();i++)
    {
      if( pDynSym )
      {
        #ifdef __XHARBOUR__
        hb_vmPushSymbol( pDynSym->pSymbol );
        #else
        hb_vmPushDynSym( pDynSym );
        #endif
        hb_vmPushNil();
        hb_vmDo( 0 );
        PHB_ITEM pObject = hb_itemNew( NULL );
        hb_itemCopy( pObject, hb_stackReturnItem() );
        PHB_ITEM pItem = hb_itemNew( NULL );
        hb_itemPutPtr( pItem, (QWidget *) list[i] );
        hb_objSendMsg( pObject, "_POINTER", 1, pItem );
        hb_arrayAddForward( pArray, pObject );
        hb_itemRelease( pObject );
        hb_itemRelease( pItem );
      }
    }
    hb_itemReturnRelease(pArray);
  }
}

/*
bool autoRepeat () const
*/
HB_FUNC_STATIC( QACTION_AUTOREPEAT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retl( obj->autoRepeat (  ) );
  }
}

/*
QVariant data () const
*/
HB_FUNC_STATIC( QACTION_DATA )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QVariant * ptr = new QVariant( obj->data (  ) );
    _qt5xhb_createReturnClass ( ptr, "QVARIANT", true );
  }
}

/*
QFont font () const
*/
HB_FUNC_STATIC( QACTION_FONT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QFont * ptr = new QFont( obj->font (  ) );
    _qt5xhb_createReturnClass ( ptr, "QFONT", true );
  }
}

/*
QIcon icon () const
*/
HB_FUNC_STATIC( QACTION_ICON )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QIcon * ptr = new QIcon( obj->icon (  ) );
    _qt5xhb_createReturnClass ( ptr, "QICON", true );
  }
}

/*
QString iconText () const
*/
HB_FUNC_STATIC( QACTION_ICONTEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retc( (const char *) obj->iconText (  ).toLatin1().data() );
  }
}

/*
bool isCheckable () const
*/
HB_FUNC_STATIC( QACTION_ISCHECKABLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retl( obj->isCheckable (  ) );
  }
}

/*
bool isChecked () const
*/
HB_FUNC_STATIC( QACTION_ISCHECKED )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retl( obj->isChecked (  ) );
  }
}

/*
bool isEnabled () const
*/
HB_FUNC_STATIC( QACTION_ISENABLED )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retl( obj->isEnabled (  ) );
  }
}

/*
bool isIconVisibleInMenu () const
*/
HB_FUNC_STATIC( QACTION_ISICONVISIBLEINMENU )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retl( obj->isIconVisibleInMenu (  ) );
  }
}

/*
bool isSeparator () const
*/
HB_FUNC_STATIC( QACTION_ISSEPARATOR )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retl( obj->isSeparator (  ) );
  }
}

/*
bool isVisible () const
*/
HB_FUNC_STATIC( QACTION_ISVISIBLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retl( obj->isVisible (  ) );
  }
}

/*
QMenu * menu () const
*/
HB_FUNC_STATIC( QACTION_MENU )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QMenu * ptr = obj->menu (  );
    _qt5xhb_createReturnClass ( ptr, "QMENU" );
  }
}

/*
MenuRole menuRole () const
*/
HB_FUNC_STATIC( QACTION_MENUROLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retni( obj->menuRole (  ) );
  }
}

/*
QWidget * parentWidget () const
*/
HB_FUNC_STATIC( QACTION_PARENTWIDGET )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QWidget * ptr = obj->parentWidget (  );
    _qt5xhb_createReturnQWidgetClass ( ptr, "QWIDGET" );
  }
}

/*
Priority priority () const
*/
HB_FUNC_STATIC( QACTION_PRIORITY )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retni( obj->priority (  ) );
  }
}

/*
void setActionGroup ( QActionGroup * group )
*/
HB_FUNC_STATIC( QACTION_SETACTIONGROUP )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QActionGroup * par1 = (QActionGroup *) _qt5xhb_itemGetPtr(1);
    obj->setActionGroup ( par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setAutoRepeat ( bool )
*/
HB_FUNC_STATIC( QACTION_SETAUTOREPEAT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->setAutoRepeat ( (bool) hb_parl(1) );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setCheckable ( bool )
*/
HB_FUNC_STATIC( QACTION_SETCHECKABLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->setCheckable ( (bool) hb_parl(1) );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setData ( const QVariant & userData )
*/
HB_FUNC_STATIC( QACTION_SETDATA )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QVariant * par1 = (QVariant *) _qt5xhb_itemGetPtr(1);
    obj->setData ( *par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setFont ( const QFont & font )
*/
HB_FUNC_STATIC( QACTION_SETFONT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QFont * par1 = (QFont *) _qt5xhb_itemGetPtr(1);
    obj->setFont ( *par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setIcon ( const QIcon & icon )
*/
HB_FUNC_STATIC( QACTION_SETICON )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QIcon par1 = ISOBJECT(1)? *(QIcon *) _qt5xhb_itemGetPtr(1) : QIcon(hb_parc(1));
    obj->setIcon ( par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setIconText ( const QString & text )
*/
HB_FUNC_STATIC( QACTION_SETICONTEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    obj->setIconText ( par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setIconVisibleInMenu ( bool visible )
*/
HB_FUNC_STATIC( QACTION_SETICONVISIBLEINMENU )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->setIconVisibleInMenu ( (bool) hb_parl(1) );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setMenu ( QMenu * menu )
*/
HB_FUNC_STATIC( QACTION_SETMENU )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QMenu * par1 = (QMenu *) _qt5xhb_itemGetPtr(1);
    obj->setMenu ( par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setMenuRole ( MenuRole menuRole )
*/
HB_FUNC_STATIC( QACTION_SETMENUROLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    int par1 = hb_parni(1);
    obj->setMenuRole (  (QAction::MenuRole) par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setPriority ( Priority priority )
*/
HB_FUNC_STATIC( QACTION_SETPRIORITY )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    int par1 = hb_parni(1);
    obj->setPriority (  (QAction::Priority) par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setSeparator ( bool b )
*/
HB_FUNC_STATIC( QACTION_SETSEPARATOR )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->setSeparator ( (bool) hb_parl(1) );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setShortcut ( const QKeySequence & shortcut )
*/
HB_FUNC_STATIC( QACTION_SETSHORTCUT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QKeySequence * par1 = (QKeySequence *) _qt5xhb_itemGetPtr(1);
    obj->setShortcut ( *par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setShortcutContext ( Qt::ShortcutContext context )
*/
HB_FUNC_STATIC( QACTION_SETSHORTCUTCONTEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    int par1 = hb_parni(1);
    obj->setShortcutContext (  (Qt::ShortcutContext) par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setShortcuts ( const QList<QKeySequence> & shortcuts )
*/
void QAction_setShortcuts1 ()
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QList<QKeySequence> par1;
    PHB_ITEM aList1 = hb_param(1, HB_IT_ARRAY);
    int i1;
    int nLen1 = hb_arrayLen(aList1);
    for (i1=0;i1<nLen1;i1++)
    {
      par1 << *(QKeySequence *) hb_itemGetPtr( hb_objSendMsg( hb_arrayGetItemPtr( aList1, i1+1 ), "POINTER", 0 ) );
    }
    obj->setShortcuts ( par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setShortcuts ( QKeySequence::StandardKey key )
*/
void QAction_setShortcuts2 ()
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    int par1 = hb_parni(1);
    obj->setShortcuts (  (QKeySequence::StandardKey) par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void setShortcuts ( const QList<QKeySequence> & shortcuts )
//[2]void setShortcuts ( QKeySequence::StandardKey key )

HB_FUNC_STATIC( QACTION_SETSHORTCUTS )
{
  if( ISNUMPAR(1) && ISARRAY(1) )
  {
    QAction_setShortcuts1();
  }
  else if( ISNUMPAR(1) && ISNUM(1) )
  {
    QAction_setShortcuts2();
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

/*
void setStatusTip ( const QString & statusTip )
*/
HB_FUNC_STATIC( QACTION_SETSTATUSTIP )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    obj->setStatusTip ( par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setText ( const QString & text )
*/
HB_FUNC_STATIC( QACTION_SETTEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    obj->setText ( par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setToolTip ( const QString & tip )
*/
HB_FUNC_STATIC( QACTION_SETTOOLTIP )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    obj->setToolTip ( par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setWhatsThis ( const QString & what )
*/
HB_FUNC_STATIC( QACTION_SETWHATSTHIS )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    obj->setWhatsThis ( par1 );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
QKeySequence shortcut () const
*/
HB_FUNC_STATIC( QACTION_SHORTCUT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QKeySequence * ptr = new QKeySequence( obj->shortcut (  ) );
    _qt5xhb_createReturnClass ( ptr, "QKEYSEQUENCE", true );
  }
}

/*
Qt::ShortcutContext shortcutContext () const
*/
HB_FUNC_STATIC( QACTION_SHORTCUTCONTEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retni( obj->shortcutContext (  ) );
  }
}

/*
QList<QKeySequence> shortcuts () const
*/
HB_FUNC_STATIC( QACTION_SHORTCUTS )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QList<QKeySequence> list = obj->shortcuts (  );
    PHB_DYNS pDynSym;
    #ifdef __XHARBOUR__
    pDynSym = hb_dynsymFind( "QKEYSEQUENCE" );
    #else
    pDynSym = hb_dynsymFindName( "QKEYSEQUENCE" );
    #endif
    PHB_ITEM pArray;
    pArray = hb_itemArrayNew(0);
    int i;
    for(i=0;i<list.count();i++)
    {
      if( pDynSym )
      {
        #ifdef __XHARBOUR__
        hb_vmPushSymbol( pDynSym->pSymbol );
        #else
        hb_vmPushDynSym( pDynSym );
        #endif
        hb_vmPushNil();
        hb_vmDo( 0 );
        PHB_ITEM pObject = hb_itemNew( NULL );
        hb_itemCopy( pObject, hb_stackReturnItem() );
        PHB_ITEM pItem = hb_itemNew( NULL );
        hb_itemPutPtr( pItem, (QKeySequence *) new QKeySequence ( list[i] ) );
        hb_objSendMsg( pObject, "_POINTER", 1, pItem );
        hb_itemRelease( pItem );
        PHB_ITEM pDestroy = hb_itemNew( NULL );
        hb_itemPutL( pDestroy, true );
        hb_objSendMsg( pObject, "_SELF_DESTRUCTION", 1, pDestroy );
        hb_itemRelease( pDestroy );
        hb_arrayAddForward( pArray, pObject );
        hb_itemRelease( pObject );
      }
    }
    hb_itemReturnRelease(pArray);
  }
}

/*
bool showStatusText ( QWidget * widget = 0 )
*/
HB_FUNC_STATIC( QACTION_SHOWSTATUSTEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QWidget * par1 = (QWidget *) _qt5xhb_itemGetPtr(1);
    hb_retl( obj->showStatusText ( par1 ) );
  }
}

/*
QString statusTip () const
*/
HB_FUNC_STATIC( QACTION_STATUSTIP )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retc( (const char *) obj->statusTip (  ).toLatin1().data() );
  }
}

/*
QString text () const
*/
HB_FUNC_STATIC( QACTION_TEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retc( (const char *) obj->text (  ).toLatin1().data() );
  }
}

/*
QString toolTip () const
*/
HB_FUNC_STATIC( QACTION_TOOLTIP )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retc( (const char *) obj->toolTip (  ).toLatin1().data() );
  }
}

/*
QString whatsThis () const
*/
HB_FUNC_STATIC( QACTION_WHATSTHIS )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retc( (const char *) obj->whatsThis (  ).toLatin1().data() );
  }
}

/*
void hover ()
*/
HB_FUNC_STATIC( QACTION_HOVER )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->hover (  );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setChecked ( bool )
*/
HB_FUNC_STATIC( QACTION_SETCHECKED )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->setChecked ( (bool) hb_parl(1) );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setDisabled ( bool b )
*/
HB_FUNC_STATIC( QACTION_SETDISABLED )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->setDisabled ( (bool) hb_parl(1) );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setEnabled ( bool )
*/
HB_FUNC_STATIC( QACTION_SETENABLED )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->setEnabled ( (bool) hb_parl(1) );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setVisible ( bool )
*/
HB_FUNC_STATIC( QACTION_SETVISIBLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->setVisible ( (bool) hb_parl(1) );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void toggle ()
*/
HB_FUNC_STATIC( QACTION_TOGGLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->toggle (  );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void trigger ()
*/
HB_FUNC_STATIC( QACTION_TRIGGER )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->trigger (  );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

#pragma ENDDUMP

/*

  Qt5xHb - bibliotecas de ligao entre Harbour/xHarbour e Qt Framework 5

  Copyright (C) 2012-2017 Marcos Antonio Gambeta <marcosgambeta@uol.com.br>

*/

#include "hbclass.ch"
#include "qt5xhb_clsid.ch"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QACTIONGROUP
REQUEST QGRAPHICSWIDGET
REQUEST QWIDGET
REQUEST QVARIANT
REQUEST QFONT
REQUEST QICON
REQUEST QMENU
REQUEST QKEYSEQUENCE
#endif

CLASS QAction INHERIT QObject

   DATA class_id INIT Class_Id_QAction
   DATA class_flags INIT 1
   DATA self_destruction INIT .F.

   METHOD new1
   METHOD new2
   METHOD new3
   METHOD new
   METHOD delete
   METHOD actionGroup
   METHOD activate
   METHOD associatedGraphicsWidgets
   METHOD associatedWidgets
   METHOD autoRepeat
   METHOD data
   METHOD font
   METHOD icon
   METHOD iconText
   METHOD isCheckable
   METHOD isChecked
   METHOD isEnabled
   METHOD isIconVisibleInMenu
   METHOD isSeparator
   METHOD isVisible
   METHOD menu
   METHOD menuRole
   METHOD parentWidget
   METHOD priority
   METHOD setActionGroup
   METHOD setAutoRepeat
   METHOD setCheckable
   METHOD setData
   METHOD setFont
   METHOD setIcon
   METHOD setIconText
   METHOD setIconVisibleInMenu
   METHOD setMenu
   METHOD setMenuRole
   METHOD setPriority
   METHOD setSeparator
   METHOD setShortcut
   METHOD setShortcutContext
   METHOD setShortcuts1
   METHOD setShortcuts2
   METHOD setShortCuts
   METHOD setStatusTip
   METHOD setText
   METHOD setToolTip
   METHOD setWhatsThis
   METHOD shortcut
   METHOD shortcutContext
   METHOD shortcuts
   METHOD showStatusText
   METHOD statusTip
   METHOD text
   METHOD toolTip
   METHOD whatsThis
   METHOD hover
   METHOD setChecked
   METHOD setDisabled
   METHOD setEnabled
   METHOD setVisible
   METHOD toggle
   METHOD trigger
   METHOD onChanged
   METHOD onHovered
   METHOD onToggled
   METHOD onTriggered
   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject () CLASS QAction
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#include <QAction>
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_clsid.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#include <QAction>
#endif

/*
QAction ( QObject * parent )
*/
HB_FUNC_STATIC( QACTION_NEW1 )
{
  QObject * par1 = (QObject *) _qt5xhb_itemGetPtr(1);
  QAction * o = new QAction ( par1 );
  _qt5xhb_storePointerAndFlag( o, false );
}

/*
QAction ( const QString & text, QObject * parent )
*/
HB_FUNC_STATIC( QACTION_NEW2 )
{
  QString par1 = QLatin1String( hb_parc(1) );
  QObject * par2 = (QObject *) _qt5xhb_itemGetPtr(2);
  QAction * o = new QAction ( par1, par2 );
  _qt5xhb_storePointerAndFlag( o, false );
}

/*
QAction ( const QIcon & icon, const QString & text, QObject * parent )
*/
HB_FUNC_STATIC( QACTION_NEW3 )
{
  QIcon par1 = ISOBJECT(1)? *(QIcon *) _qt5xhb_itemGetPtr(1) : QIcon(hb_parc(1));
  QString par2 = QLatin1String( hb_parc(2) );
  QObject * par3 = (QObject *) _qt5xhb_itemGetPtr(3);
  QAction * o = new QAction ( par1, par2, par3 );
  _qt5xhb_storePointerAndFlag( o, false );
}

//[1]QAction ( QObject * parent )
//[2]QAction ( const QString & text, QObject * parent )
//[3]QAction ( const QIcon & icon, const QString & text, QObject * parent )

HB_FUNC_STATIC( QACTION_NEW )
{
  if( ISNUMPAR(1) && ISQOBJECT(1) )
  {
    HB_FUNC_EXEC( QACTION_NEW1 );
  }
  else if( ISNUMPAR(2) && ISCHAR(1) && ISQOBJECT(2) )
  {
    HB_FUNC_EXEC( QACTION_NEW2 );
  }
  else if( ISNUMPAR(3) && (ISQICON(1)||ISCHAR(1)) && ISCHAR(2) && ISQOBJECT(3) )
  {
    HB_FUNC_EXEC( QACTION_NEW3 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

HB_FUNC_STATIC( QACTION_DELETE )
{
  QAction * obj = (QAction *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QActionGroup * actionGroup () const
*/
HB_FUNC_STATIC( QACTION_ACTIONGROUP )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QActionGroup * ptr = obj->actionGroup (  );
    _qt5xhb_createReturnClass ( ptr, "QACTIONGROUP" );
  }
}

/*
void activate ( ActionEvent event )
*/
HB_FUNC_STATIC( QACTION_ACTIVATE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = hb_parni(1);
    obj->activate (  (QAction::ActionEvent) par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QList<QGraphicsWidget *> associatedGraphicsWidgets () const
*/
HB_FUNC_STATIC( QACTION_ASSOCIATEDGRAPHICSWIDGETS )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QList<QGraphicsWidget *> list = obj->associatedGraphicsWidgets (  );
    PHB_DYNS pDynSym;
    #ifdef __XHARBOUR__
    pDynSym = hb_dynsymFind( "QGRAPHICSWIDGET" );
    #else
    pDynSym = hb_dynsymFindName( "QGRAPHICSWIDGET" );
    #endif
    PHB_ITEM pArray;
    pArray = hb_itemArrayNew(0);
    int i;
    for(i=0;i<list.count();i++)
    {
      if( pDynSym )
      {
        #ifdef __XHARBOUR__
        hb_vmPushSymbol( pDynSym->pSymbol );
        #else
        hb_vmPushDynSym( pDynSym );
        #endif
        hb_vmPushNil();
        hb_vmDo( 0 );
        PHB_ITEM pObject = hb_itemNew( NULL );
        hb_itemCopy( pObject, hb_stackReturnItem() );
        PHB_ITEM pItem = hb_itemNew( NULL );
        hb_itemPutPtr( pItem, (QGraphicsWidget *) list[i] );
        hb_objSendMsg( pObject, "_POINTER", 1, pItem );
        hb_arrayAddForward( pArray, pObject );
        hb_itemRelease( pObject );
        hb_itemRelease( pItem );
      }
    }
    hb_itemReturnRelease(pArray);
  }
}

/*
QList<QWidget *> associatedWidgets () const
*/
HB_FUNC_STATIC( QACTION_ASSOCIATEDWIDGETS )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QList<QWidget *> list = obj->associatedWidgets (  );
    PHB_DYNS pDynSym;
    #ifdef __XHARBOUR__
    pDynSym = hb_dynsymFind( "QWIDGET" );
    #else
    pDynSym = hb_dynsymFindName( "QWIDGET" );
    #endif
    PHB_ITEM pArray;
    pArray = hb_itemArrayNew(0);
    int i;
    for(i=0;i<list.count();i++)
    {
      if( pDynSym )
      {
        #ifdef __XHARBOUR__
        hb_vmPushSymbol( pDynSym->pSymbol );
        #else
        hb_vmPushDynSym( pDynSym );
        #endif
        hb_vmPushNil();
        hb_vmDo( 0 );
        PHB_ITEM pObject = hb_itemNew( NULL );
        hb_itemCopy( pObject, hb_stackReturnItem() );
        PHB_ITEM pItem = hb_itemNew( NULL );
        hb_itemPutPtr( pItem, (QWidget *) list[i] );
        hb_objSendMsg( pObject, "_POINTER", 1, pItem );
        hb_arrayAddForward( pArray, pObject );
        hb_itemRelease( pObject );
        hb_itemRelease( pItem );
      }
    }
    hb_itemReturnRelease(pArray);
  }
}

/*
bool autoRepeat () const
*/
HB_FUNC_STATIC( QACTION_AUTOREPEAT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->autoRepeat (  ) );
  }
}

/*
QVariant data () const
*/
HB_FUNC_STATIC( QACTION_DATA )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QVariant * ptr = new QVariant( obj->data (  ) );
    _qt5xhb_createReturnClass ( ptr, "QVARIANT", true );
  }
}

/*
QFont font () const
*/
HB_FUNC_STATIC( QACTION_FONT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QFont * ptr = new QFont( obj->font (  ) );
    _qt5xhb_createReturnClass ( ptr, "QFONT", true );
  }
}

/*
QIcon icon () const
*/
HB_FUNC_STATIC( QACTION_ICON )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QIcon * ptr = new QIcon( obj->icon (  ) );
    _qt5xhb_createReturnClass ( ptr, "QICON", true );
  }
}

/*
QString iconText () const
*/
HB_FUNC_STATIC( QACTION_ICONTEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retc( (const char *) obj->iconText (  ).toLatin1().data() );
  }
}

/*
bool isCheckable () const
*/
HB_FUNC_STATIC( QACTION_ISCHECKABLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->isCheckable (  ) );
  }
}

/*
bool isChecked () const
*/
HB_FUNC_STATIC( QACTION_ISCHECKED )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->isChecked (  ) );
  }
}

/*
bool isEnabled () const
*/
HB_FUNC_STATIC( QACTION_ISENABLED )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->isEnabled (  ) );
  }
}

/*
bool isIconVisibleInMenu () const
*/
HB_FUNC_STATIC( QACTION_ISICONVISIBLEINMENU )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->isIconVisibleInMenu (  ) );
  }
}

/*
bool isSeparator () const
*/
HB_FUNC_STATIC( QACTION_ISSEPARATOR )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->isSeparator (  ) );
  }
}

/*
bool isVisible () const
*/
HB_FUNC_STATIC( QACTION_ISVISIBLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->isVisible (  ) );
  }
}

/*
QMenu * menu () const
*/
HB_FUNC_STATIC( QACTION_MENU )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QMenu * ptr = obj->menu (  );
    _qt5xhb_createReturnClass ( ptr, "QMENU" );
  }
}

/*
MenuRole menuRole () const
*/
HB_FUNC_STATIC( QACTION_MENUROLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->menuRole (  ) );
  }
}

/*
QWidget * parentWidget () const
*/
HB_FUNC_STATIC( QACTION_PARENTWIDGET )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWidget * ptr = obj->parentWidget (  );
    _qt5xhb_createReturnQWidgetClass ( ptr, "QWIDGET" );
  }
}

/*
Priority priority () const
*/
HB_FUNC_STATIC( QACTION_PRIORITY )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->priority (  ) );
  }
}

/*
void setActionGroup ( QActionGroup * group )
*/
HB_FUNC_STATIC( QACTION_SETACTIONGROUP )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QActionGroup * par1 = (QActionGroup *) _qt5xhb_itemGetPtr(1);
    obj->setActionGroup ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setAutoRepeat ( bool )
*/
HB_FUNC_STATIC( QACTION_SETAUTOREPEAT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setAutoRepeat ( (bool) hb_parl(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setCheckable ( bool )
*/
HB_FUNC_STATIC( QACTION_SETCHECKABLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setCheckable ( (bool) hb_parl(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setData ( const QVariant & userData )
*/
HB_FUNC_STATIC( QACTION_SETDATA )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QVariant * par1 = (QVariant *) _qt5xhb_itemGetPtr(1);
    obj->setData ( *par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setFont ( const QFont & font )
*/
HB_FUNC_STATIC( QACTION_SETFONT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QFont * par1 = (QFont *) _qt5xhb_itemGetPtr(1);
    obj->setFont ( *par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setIcon ( const QIcon & icon )
*/
HB_FUNC_STATIC( QACTION_SETICON )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QIcon par1 = ISOBJECT(1)? *(QIcon *) _qt5xhb_itemGetPtr(1) : QIcon(hb_parc(1));
    obj->setIcon ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setIconText ( const QString & text )
*/
HB_FUNC_STATIC( QACTION_SETICONTEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    obj->setIconText ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setIconVisibleInMenu ( bool visible )
*/
HB_FUNC_STATIC( QACTION_SETICONVISIBLEINMENU )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setIconVisibleInMenu ( (bool) hb_parl(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setMenu ( QMenu * menu )
*/
HB_FUNC_STATIC( QACTION_SETMENU )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QMenu * par1 = (QMenu *) _qt5xhb_itemGetPtr(1);
    obj->setMenu ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setMenuRole ( MenuRole menuRole )
*/
HB_FUNC_STATIC( QACTION_SETMENUROLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = hb_parni(1);
    obj->setMenuRole (  (QAction::MenuRole) par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setPriority ( Priority priority )
*/
HB_FUNC_STATIC( QACTION_SETPRIORITY )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = hb_parni(1);
    obj->setPriority (  (QAction::Priority) par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setSeparator ( bool b )
*/
HB_FUNC_STATIC( QACTION_SETSEPARATOR )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setSeparator ( (bool) hb_parl(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setShortcut ( const QKeySequence & shortcut )
*/
HB_FUNC_STATIC( QACTION_SETSHORTCUT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QKeySequence * par1 = (QKeySequence *) _qt5xhb_itemGetPtr(1);
    obj->setShortcut ( *par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setShortcutContext ( Qt::ShortcutContext context )
*/
HB_FUNC_STATIC( QACTION_SETSHORTCUTCONTEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = hb_parni(1);
    obj->setShortcutContext (  (Qt::ShortcutContext) par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setShortcuts ( const QList<QKeySequence> & shortcuts )
*/
HB_FUNC_STATIC( QACTION_SETSHORTCUTS1 )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QList<QKeySequence> par1;
    PHB_ITEM aList1 = hb_param(1, HB_IT_ARRAY);
    int i1;
    int nLen1 = hb_arrayLen(aList1);
    for (i1=0;i1<nLen1;i1++)
    {
      par1 << *(QKeySequence *) hb_itemGetPtr( hb_objSendMsg( hb_arrayGetItemPtr( aList1, i1+1 ), "POINTER", 0 ) );
    }
    obj->setShortcuts ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setShortcuts ( QKeySequence::StandardKey key )
*/
HB_FUNC_STATIC( QACTION_SETSHORTCUTS2 )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = hb_parni(1);
    obj->setShortcuts (  (QKeySequence::StandardKey) par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void setShortcuts ( const QList<QKeySequence> & shortcuts )
//[2]void setShortcuts ( QKeySequence::StandardKey key )

HB_FUNC_STATIC( QACTION_SETSHORTCUTS )
{
  if( ISNUMPAR(1) && ISARRAY(1) )
  {
    HB_FUNC_EXEC( QACTION_SETSHORTCUTS1 );
  }
  else if( ISNUMPAR(1) && ISNUM(1) )
  {
    HB_FUNC_EXEC( QACTION_SETSHORTCUTS2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

/*
void setStatusTip ( const QString & statusTip )
*/
HB_FUNC_STATIC( QACTION_SETSTATUSTIP )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    obj->setStatusTip ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setText ( const QString & text )
*/
HB_FUNC_STATIC( QACTION_SETTEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    obj->setText ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setToolTip ( const QString & tip )
*/
HB_FUNC_STATIC( QACTION_SETTOOLTIP )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    obj->setToolTip ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setWhatsThis ( const QString & what )
*/
HB_FUNC_STATIC( QACTION_SETWHATSTHIS )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    obj->setWhatsThis ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QKeySequence shortcut () const
*/
HB_FUNC_STATIC( QACTION_SHORTCUT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QKeySequence * ptr = new QKeySequence( obj->shortcut (  ) );
    _qt5xhb_createReturnClass ( ptr, "QKEYSEQUENCE", true );
  }
}

/*
Qt::ShortcutContext shortcutContext () const
*/
HB_FUNC_STATIC( QACTION_SHORTCUTCONTEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->shortcutContext (  ) );
  }
}

/*
QList<QKeySequence> shortcuts () const
*/
HB_FUNC_STATIC( QACTION_SHORTCUTS )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QList<QKeySequence> list = obj->shortcuts (  );
    PHB_DYNS pDynSym;
    #ifdef __XHARBOUR__
    pDynSym = hb_dynsymFind( "QKEYSEQUENCE" );
    #else
    pDynSym = hb_dynsymFindName( "QKEYSEQUENCE" );
    #endif
    PHB_ITEM pArray;
    pArray = hb_itemArrayNew(0);
    int i;
    for(i=0;i<list.count();i++)
    {
      if( pDynSym )
      {
        #ifdef __XHARBOUR__
        hb_vmPushSymbol( pDynSym->pSymbol );
        #else
        hb_vmPushDynSym( pDynSym );
        #endif
        hb_vmPushNil();
        hb_vmDo( 0 );
        PHB_ITEM pObject = hb_itemNew( NULL );
        hb_itemCopy( pObject, hb_stackReturnItem() );
        PHB_ITEM pItem = hb_itemNew( NULL );
        hb_itemPutPtr( pItem, (QKeySequence *) new QKeySequence ( list[i] ) );
        hb_objSendMsg( pObject, "_POINTER", 1, pItem );
        hb_itemRelease( pItem );
        PHB_ITEM pDestroy = hb_itemNew( NULL );
        hb_itemPutL( pDestroy, true );
        hb_objSendMsg( pObject, "_SELF_DESTRUCTION", 1, pDestroy );
        hb_itemRelease( pDestroy );
        hb_arrayAddForward( pArray, pObject );
        hb_itemRelease( pObject );
      }
    }
    hb_itemReturnRelease(pArray);
  }
}

/*
bool showStatusText ( QWidget * widget = 0 )
*/
HB_FUNC_STATIC( QACTION_SHOWSTATUSTEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWidget * par1 = (QWidget *) _qt5xhb_itemGetPtr(1);
    hb_retl( obj->showStatusText ( par1 ) );
  }
}

/*
QString statusTip () const
*/
HB_FUNC_STATIC( QACTION_STATUSTIP )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retc( (const char *) obj->statusTip (  ).toLatin1().data() );
  }
}

/*
QString text () const
*/
HB_FUNC_STATIC( QACTION_TEXT )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retc( (const char *) obj->text (  ).toLatin1().data() );
  }
}

/*
QString toolTip () const
*/
HB_FUNC_STATIC( QACTION_TOOLTIP )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retc( (const char *) obj->toolTip (  ).toLatin1().data() );
  }
}

/*
QString whatsThis () const
*/
HB_FUNC_STATIC( QACTION_WHATSTHIS )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retc( (const char *) obj->whatsThis (  ).toLatin1().data() );
  }
}

/*
void hover ()
*/
HB_FUNC_STATIC( QACTION_HOVER )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->hover (  );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setChecked ( bool )
*/
HB_FUNC_STATIC( QACTION_SETCHECKED )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setChecked ( (bool) hb_parl(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setDisabled ( bool b )
*/
HB_FUNC_STATIC( QACTION_SETDISABLED )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setDisabled ( (bool) hb_parl(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setEnabled ( bool )
*/
HB_FUNC_STATIC( QACTION_SETENABLED )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setEnabled ( (bool) hb_parl(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setVisible ( bool )
*/
HB_FUNC_STATIC( QACTION_SETVISIBLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setVisible ( (bool) hb_parl(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void toggle ()
*/
HB_FUNC_STATIC( QACTION_TOGGLE )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->toggle (  );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void trigger ()
*/
HB_FUNC_STATIC( QACTION_TRIGGER )
{
  QAction * obj = (QAction *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->trigger (  );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

#pragma ENDDUMP


type variables

type variables

-- parametric HOAS (PHOAS) representation of terms
-- advocated by Chipala and B. Oliveira
--

data Ptm :: * ~> * ~> * ~> * where
  Var :: a -> Ptm a t l
  Lam :: (a -> Ptm a t l) -> Ptm a t l
  Lev :: (l -> Ptm a t l) -> Ptm a t l
  App :: Ptm a t l -> Ptm a t l -> Ptm a t l
  Star :: l -> Ptm a t l
  Forall :: (t -> Ptm a t l) -> Ptm a t l

data Tm = Tm (forall a t l . Ptm a t (Nat' l))

-- illegal
--
##test "not parametric"
 ill = Tm (Lam (\a -> a + 2))

##test "not parametric: expr var in level context"
 ill = Tm (Lev (\a -> App (Var a) (Var a)))

-- this is parametric
--
leg = Tm (Lam (\a -> App (Var a) (Var a)))

-- parametric HOAS (PHOAS) representation of terms
-- advocated by Chipala and B. Oliveira
--

data Ptm :: * ~> * ~> * where
  Var :: a -> Ptm a l
  Lam :: (a -> Ptm a l) -> Ptm a l
  Lev :: (l -> Ptm a l) -> Ptm a l
  App :: Ptm a l -> Ptm a l -> Ptm a l
  Star :: l -> Ptm a l

data Tm = Tm (forall a l . Ptm a (Nat' l))

-- illegal
--
##test "not parametric"
 ill = Tm (Lam (\a -> a + 2))

##test "not parametric: expr var in level context"
 ill = Tm (Lev (\a -> App (Var a) (Var a)))

-- this is parametric
--
leg = Tm (Lam (\a -> App (Var a) (Var a)))