1
1
Fork 0
mirror of https://github.com/FellippeHeitor/InForm.git synced 2024-05-12 06:50:12 +00:00

Integrate MessageBox and friends back into the main source

This commit is contained in:
Samuel Gomes 2024-01-11 07:20:24 +05:30
parent 07a2b55433
commit 6f5546221d
5 changed files with 164 additions and 185 deletions

View file

@ -4931,11 +4931,11 @@ $IF INFORM_UI = UNDEFINED THEN
END IF
DIM EmptyControl AS __UI_ControlTYPE
IF This.Canvas <> 0 THEN _FREEIMAGE This.Canvas: This.Canvas = 0
IF This.HelperCanvas <> 0 THEN _FREEIMAGE This.HelperCanvas: This.HelperCanvas = 0
IF This.ControlIsSelected THEN This.ControlIsSelected = FALSE: __UI_TotalSelectedControls = __UI_TotalSelectedControls - 1
uw& = GetControlDrawOrder(This.ID)
ControlDrawOrder(uw&) = 0
This = EmptyControl
@ -8630,6 +8630,134 @@ $IF INFORM_UI = UNDEFINED THEN
LINE (bX, bY)-STEP(bW, bH), C, BF
END SUB
'---------------------------------------------------------------------------------
FUNCTION MessageBox& (message AS STRING, caption AS STRING, setup AS LONG)
DIM dialogType AS STRING
IF setup AND MsgBox_YesNo THEN
dialogType = "yesno"
ELSEIF setup AND MsgBox_YesNoCancel THEN
dialogType = "yesnocancel"
ELSEIF setup AND MsgBox_OkCancel THEN
dialogType = "okcancel"
ELSEIF setup AND MsgBox_OkOnly THEN
dialogType = "ok"
END IF
DIM iconType AS STRING
IF setup AND MsgBox_Critical THEN
iconType = "error"
ELSEIF setup AND MsgBox_Question THEN
iconType = "question"
ELSEIF setup AND MsgBox_Exclamation THEN
iconType = "warning"
ELSEIF setup AND MsgBox_Information THEN
iconType = "info"
END IF
DIM defaultButton AS LONG
IF setup AND MsgBox_DefaultButton3 THEN
SELECT CASE dialogType
CASE "yesnocancel"
defaultButton = 0
CASE "yesno"
defaultButton = 0
CASE "okcancel"
defaultButton = 0
CASE "ok"
defaultButton = 1
END SELECT
ELSEIF setup AND MsgBox_DefaultButton2 THEN
SELECT CASE dialogType
CASE "yesnocancel"
defaultButton = 2
CASE "yesno"
defaultButton = 0
CASE "okcancel"
defaultButton = 0
CASE "ok"
defaultButton = 1
END SELECT
ELSEIF setup AND MsgBox_DefaultButton1 THEN
SELECT CASE dialogType
CASE "yesnocancel"
defaultButton = 1
CASE "yesno"
defaultButton = 1
CASE "okcancel"
defaultButton = 1
CASE "ok"
defaultButton = 1
END SELECT
END IF
DIM __caption AS STRING: __caption = caption
$IF INFORM_BI = DEFINED THEN
IF LEN(__UI_CurrentTitle) > 0 THEN
__caption = __UI_CurrentTitle
ELSEIF LEN(_TITLE$) > 0 THEN
__caption = _TITLE$
ELSE
__caption = COMMAND$(0)
END IF
$ELSE
IF LEN(_TITLE$) > 0 THEN
__caption = _TITLE$
ELSE
__caption = COMMAND$(0)
END IF
$END IF
_DELAY 0.2 ' delay a bit so that the interface can redraw before the messagebox kicks in
DIM returnValue AS LONG: returnValue = _MESSAGEBOX(__caption, Replace(message, "\n", CHR$(10), FALSE, 0), dialogType, iconType, defaultButton)
SELECT CASE returnValue
CASE 0
SELECT CASE dialogType
CASE "yesnocancel"
MessageBox = MsgBox_Cancel
CASE "yesno"
MessageBox = MsgBox_No
CASE "okcancel"
MessageBox = MsgBox_Cancel
CASE "ok"
MessageBox = MsgBox_Ok
END SELECT
CASE 1
SELECT CASE dialogType
CASE "yesnocancel"
MessageBox = MsgBox_Yes
CASE "yesno"
MessageBox = MsgBox_Yes
CASE "okcancel"
MessageBox = MsgBox_Ok
CASE "ok"
MessageBox = MsgBox_Ok
END SELECT
CASE 2
SELECT CASE dialogType
CASE "yesnocancel"
MessageBox = MsgBox_No
CASE "yesno"
MessageBox = MsgBox_No
CASE "okcancel"
MessageBox = MsgBox_Cancel
CASE "ok"
MessageBox = MsgBox_Ok
END SELECT
END SELECT
END FUNCTION
SUB MessageBox (message AS STRING, caption AS STRING, setup AS LONG)
DIM returnValue AS LONG: returnValue = MessageBox(message, caption, setup)
END SUB
'---------------------------------------------------------------------------------
' Dummy event functions to keep the IDE happy
$IF INFORM_BI = UNDEFINED THEN
@ -8695,6 +8823,5 @@ $IF INFORM_UI = UNDEFINED THEN
'$INCLUDE:'xp.uitheme'
'$INCLUDE:'extensions/HashTable.bas'
'$INCLUDE:'extensions/MessageBox.bas'
$END IF

View file

@ -14,7 +14,6 @@ $IF INFORMCOMMON_BI = UNDEFINED THEN
'$INCLUDE:'InFormVersion.bi'
'$INCLUDE:'extensions/HashTable.bi'
'$INCLUDE:'extensions/MessageBox.bi'
CONST FALSE%% = 0%%, TRUE%% = NOT FALSE
@ -83,6 +82,39 @@ $IF INFORMCOMMON_BI = UNDEFINED THEN
CONST __UI_CantResizeH%% = 2%%
CONST __UI_CantResize%% = 3%%
'Messagebox constants
CONST MsgBox_OkOnly& = 1&
CONST MsgBox_OkCancel& = 2&
CONST MsgBox_AbortRetryIgnore& = 4&
CONST MsgBox_YesNoCancel& = 8&
CONST MsgBox_YesNo& = 16&
CONST MsgBox_RetryCancel& = 32&
CONST MsgBox_CancelTryAgainContinue& = 64&
CONST MsgBox_Critical& = 128&
CONST MsgBox_Question& = 256&
CONST MsgBox_Exclamation& = 512&
CONST MsgBox_Information& = 1024&
CONST MsgBox_DefaultButton1& = 2048&
CONST MsgBox_DefaultButton2& = 4096&
CONST MsgBox_DefaultButton3& = 8192&
CONST MsgBox_Defaultbutton4& = 16384&
CONST MsgBox_AppModal& = 32768&
CONST MsgBox_SystemModal& = 65536&
CONST MsgBox_SetForeground& = 131072&
CONST MsgBox_Ok& = 1&
CONST MsgBox_Yes& = 2&
CONST MsgBox_No& = 3&
CONST MsgBox_Cancel& = 4&
CONST MsgBox_Abort& = 5&
CONST MsgBox_Retry& = 6&
CONST MsgBox_Ignore& = 7&
CONST MsgBox_TryAgain& = 8&
CONST MsgBox_Continue& = 9&
DECLARE LIBRARY
FUNCTION __UI_GetPID ALIAS getpid
END DECLARE

View file

@ -579,7 +579,7 @@ SUB __UI_Click (id AS LONG)
SaveForm TRUE, Control(SaveFrmOnlyCB).Value
END IF
CASE HelpMenuAbout
MessageBox "InForm GUI engine for QB64-PE" + CHR$(13) + "Copyright (c) 2024 Samuel Gomes - @a740g" + CHR$(13) + "Copyright (c) 2023 George McGinn - gbytes58@gmail.com" + CHR$(13) + "Copyright (c) 2022 Fellippe Heitor - @FellippeHeitor" + STRING$(2, 13) + UiEditorTitle$ + " v" + __UI_Version + STRING$(2, 13) + "https://github.com/a740g/InForm-PE", UiEditorTitle$ + " - About", MsgBox_Information
MessageBox "InForm GUI engine for QB64-PE\n\nCopyright (c) 2024 Samuel Gomes - @a740g\nCopyright (c) 2023 George McGinn - gbytes58@gmail.com\nCopyright (c) 2022 Fellippe Heitor - @FellippeHeitor\n\n" + UiEditorTitle$ + " v" + __UI_Version + "\n\nhttps://github.com/a740g/InForm-PE", UiEditorTitle$ + " - About", MsgBox_Information
CASE HelpMenuHelp
MessageBox "Design a form and export the resulting code to generate an event-driven QB64-PE program.", UiEditorTitle$ + " - What's all this?", MsgBox_Information
CASE FileMenuExit

View file

@ -1,137 +0,0 @@
'-----------------------------------------------------------------------------------------------------------------------
' InForm MessageBox compatibility functions. These basically emulates the legacy InForm MessageBox routines
' Copyright (c) 2024 Samuel Gomes
' Copyright (c) 2022 Fellippe Heitor
'-----------------------------------------------------------------------------------------------------------------------
$IF MESSAGEBOX_BAS = UNDEFINED THEN
$LET MESSAGEBOX_BAS = TRUE
'$INCLUDE:'MessageBox.bi'
FUNCTION MessageBox& (message AS STRING, caption AS STRING, setup AS LONG)
DIM dialogType AS STRING
IF setup AND MsgBox_YesNo THEN
dialogType = "yesno"
ELSEIF setup AND MsgBox_YesNoCancel THEN
dialogType = "yesnocancel"
ELSEIF setup AND MsgBox_OkCancel THEN
dialogType = "okcancel"
ELSEIF setup AND MsgBox_OkOnly THEN
dialogType = "ok"
END IF
DIM iconType AS STRING
IF setup AND MsgBox_Critical THEN
iconType = "error"
ELSEIF setup AND MsgBox_Question THEN
iconType = "question"
ELSEIF setup AND MsgBox_Exclamation THEN
iconType = "warning"
ELSEIF setup AND MsgBox_Information THEN
iconType = "info"
END IF
DIM defaultButton AS LONG
IF setup AND MsgBox_DefaultButton3 THEN
SELECT CASE dialogType
CASE "yesnocancel"
defaultButton = 0
CASE "yesno"
defaultButton = 0
CASE "okcancel"
defaultButton = 0
CASE "ok"
defaultButton = 1
END SELECT
ELSEIF setup AND MsgBox_DefaultButton2 THEN
SELECT CASE dialogType
CASE "yesnocancel"
defaultButton = 2
CASE "yesno"
defaultButton = 0
CASE "okcancel"
defaultButton = 0
CASE "ok"
defaultButton = 1
END SELECT
ELSEIF setup AND MsgBox_DefaultButton1 THEN
SELECT CASE dialogType
CASE "yesnocancel"
defaultButton = 1
CASE "yesno"
defaultButton = 1
CASE "okcancel"
defaultButton = 1
CASE "ok"
defaultButton = 1
END SELECT
END IF
DIM __caption AS STRING: __caption = caption
$IF INFORM_BI = DEFINED THEN
IF LEN(__UI_CurrentTitle) > 0 THEN
__caption = __UI_CurrentTitle
ELSEIF LEN(_TITLE$) > 0 THEN
__caption = _TITLE$
ELSE
__caption = COMMAND$(0)
END IF
$ELSE
IF LEN(_TITLE$) > 0 THEN
__caption = _TITLE$
ELSE
__caption = COMMAND$(0)
END IF
$END IF
_DELAY 0.2 ' delay a bit so that the interface can redraw before the messagebox kicks in
DIM returnValue AS LONG: returnValue = _MESSAGEBOX(__caption, message, dialogType, iconType, defaultButton)
SELECT CASE returnValue
CASE 0
SELECT CASE dialogType
CASE "yesnocancel"
MessageBox = MsgBox_Cancel
CASE "yesno"
MessageBox = MsgBox_No
CASE "okcancel"
MessageBox = MsgBox_Cancel
CASE "ok"
MessageBox = MsgBox_Ok
END SELECT
CASE 1
SELECT CASE dialogType
CASE "yesnocancel"
MessageBox = MsgBox_Yes
CASE "yesno"
MessageBox = MsgBox_Yes
CASE "okcancel"
MessageBox = MsgBox_Ok
CASE "ok"
MessageBox = MsgBox_Ok
END SELECT
CASE 2
SELECT CASE dialogType
CASE "yesnocancel"
MessageBox = MsgBox_No
CASE "yesno"
MessageBox = MsgBox_No
CASE "okcancel"
MessageBox = MsgBox_Cancel
CASE "ok"
MessageBox = MsgBox_Ok
END SELECT
END SELECT
END FUNCTION
SUB MessageBox (message AS STRING, caption AS STRING, setup AS LONG)
DIM returnValue AS LONG: returnValue = MessageBox(message, caption, setup)
END SUB
$END IF

View file

@ -1,43 +0,0 @@
'-----------------------------------------------------------------------------------------------------------------------
' InForm MessageBox compatibility functions. These basically emulates the legacy InForm MessageBox routines
' Copyright (c) 2024 Samuel Gomes
' Copyright (c) 2022 Fellippe Heitor
'-----------------------------------------------------------------------------------------------------------------------
$IF MESSAGEBOX_BI = UNDEFINED THEN
$LET MESSAGEBOX_BI = TRUE
'Messagebox constants
CONST MsgBox_OkOnly& = 1&
CONST MsgBox_OkCancel& = 2&
CONST MsgBox_AbortRetryIgnore& = 4&
CONST MsgBox_YesNoCancel& = 8&
CONST MsgBox_YesNo& = 16&
CONST MsgBox_RetryCancel& = 32&
CONST MsgBox_CancelTryAgainContinue& = 64&
CONST MsgBox_Critical& = 128&
CONST MsgBox_Question& = 256&
CONST MsgBox_Exclamation& = 512&
CONST MsgBox_Information& = 1024&
CONST MsgBox_DefaultButton1& = 2048&
CONST MsgBox_DefaultButton2& = 4096&
CONST MsgBox_DefaultButton3& = 8192&
CONST MsgBox_Defaultbutton4& = 16384&
CONST MsgBox_AppModal& = 32768&
CONST MsgBox_SystemModal& = 65536&
CONST MsgBox_SetForeground& = 131072&
CONST MsgBox_Ok& = 1&
CONST MsgBox_Yes& = 2&
CONST MsgBox_No& = 3&
CONST MsgBox_Cancel& = 4&
CONST MsgBox_Abort& = 5&
CONST MsgBox_Retry& = 6&
CONST MsgBox_Ignore& = 7&
CONST MsgBox_TryAgain& = 8&
CONST MsgBox_Continue& = 9&
$END IF