#Include UI.TNT.System // ==================================================== // Een collectie aan gemeenschappelijke UI.TNT routines // ==================================================== GetDefaultFGColor(FormType,FontSelect) Set Font=%Screen.Fonts(FormType,FontSelect) Quit Font.FGColor GetDefaultBGColor(FormType,FontSelect) Set Font=%Screen.Fonts(FormType,FontSelect) Quit Font.BGColor PointInRect(Y, X, lbRect) Quit (Y'<$LI(lbRect,1)) && (X'<$LI(lbRect,2)) && (Y'>$LI(lbRect,3)) && (X'>$LI(lbRect,4)) // Geef een control op en krijg zijn form terug GetParentForm(Control) Quit:(Control="") "" For Quit:(Control.Parent="") Set Control=Control.Parent Quit $S(Control.%IsA("UI.TNT.TForm"):Control,1:"") // Geef een control op en krijg een 'leesbare' naam terug GetDebugControlName(Control) Quit:('$IsObject(Control)) "(nil)" Set Name=Control.%ClassName(1) Set:($L(Name,"UI.TNT.")=2) Name=$P(Name,"UI.TNT.",2) If Control.%IsA("UI.TNT.TControlBasis") Do . Set Name=Control.Name_" ("_Name_")" . For Quit:(Control.Parent="") Set Control=Control.Parent, Name=Control.Name_"."_Name Quit Name // ***************************************************************************************************** // InputBox // ***************************************************************************************************** InputBox(Caption,Message,DefaultValue,Width) #Define cntDefaultWidth 50 ;Message form New MsgForm Set MsgForm=%Application.CreateForm("UI.TNT.TForm","dlgInput"_$TR(Caption," ",""),Caption,1,1,10,30,,$$$ftDialog) New FormWidth Set FormWidth=$G(Width,$$$cntDefaultWidth) Set MsgForm.Width=FormWidth Set MsgForm.Left=(%Screen.Width-FormWidth)\2 ;FormHeight bepalen adhv message New Memo Set Memo=##class(UI.TNT.TMemo).Create(MsgForm,"mmoMsg","",2,2,2,FormWidth-2,2,2) Set Memo.TabStop=0 Set Memo.Text=Message Do Memo.Wrap() ;Indien slechts 1 row, neem dan toch een plaats van hoogte 3 in beslag Set Memo.Height=Memo.Rows New FormHeight Set FormHeight=Memo.Height+5 Set MsgForm.Height=FormHeight Set MsgForm.Top=(%Screen.Height-FormHeight)\2 ;Msg kader New Kader Set Kader=##class(UI.TNT.TKader).Create(MsgForm,"kdrMsg",Caption,1,1,MsgForm.Height,MsgForm.Width,1,1,,) ;Lijn boven buttons New Line Set Line=##class(UI.TNT.TLijn).CreateLijn("H",MsgForm,"lnMsg",FormHeight-2,1,FormWidth,FormHeight-2,,,$LB($LB(1,"ML"),$LB(,"MR"))) ;Creatie van de buttons op de form New Button,BtnCaption Set BtnCaption=$$ButtonToCaption($$$mbCancel) Set Button=##class(UI.TNT.TButton).Create(MsgForm,"Btn"_BtnCaption,BtnCaption,FormHeight-1,FormWidth-12,1,11,5,5,,$LB($$$clUltraLight,$$$clDark),$$$alCenter) Set Button.ModalResult=$$$mrCancel Set BtnCaption=$$ButtonToCaption($$$mbOk) Set Button=##class(UI.TNT.TButton).Create(MsgForm,"Btn"_BtnCaption,BtnCaption,FormHeight-1,FormWidth-24,1,11,4,4,,$LB($$$clUltraLight,$$$clDark),$$$alCenter) Set Button.ModalResult=$$$mrOk New Edit Set Edit=##class(UI.TNT.TEdit).Create(MsgForm,"txtValue","",FormHeight-3,2,1,FormWidth-4,3,3) Set Edit.Caption=DefaultValue New Result Set Result=MsgForm.ShowModal() Set DefaultValue=Edit.Caption Do MsgForm.Destroy() Quit Result // ***************************************************************************************************** // MessageBox // ***************************************************************************************************** MessageBox(Caption,Message,lbButtons,MessageType=$$$mtInformation,DefaultButton=$$$mbCancel) #Define cntMinButtonWidth 10 #Define cntButtonSpace 2 #Define cntMinFormWidth 60 Set lbButtons=$G(lbButtons,$LB($$$mbOk)) ;Message form New MsgForm,Font Set Font=$S(MessageType=$$$mtError:$LB($$$clRed),1:"") Set MsgForm=%Application.CreateForm("UI.TNT.TForm","dlg"_$TR(Caption," ",""),Caption,1,1,10,30,Font,$$$ftDialog) ;Formwidth achterhalen adhv buttons New Loop,BtnWidth,BtnWidthSum,ButtonType,BtnCaption Set BtnWidthSum=0 For Loop=1:1:$LL(lbButtons) Do . Set ButtonType=$LI(lbButtons,Loop) . Set BtnCaption=$$ButtonToCaption(ButtonType) . Set BtnWidth=$L(BtnCaption)+2 . Set:(BtnWidth<$$$cntMinButtonWidth) BtnWidth=$$$cntMinButtonWidth . If Loop=1 Do .. Set BtnWidthSum=BtnWidth . Else Do .. Set BtnWidthSum=BtnWidthSum+$$$cntButtonSpace+BtnWidth New FormWidth Set FormWidth=BtnWidthSum+4 Set:(FormWidth<$$$cntMinFormWidth) FormWidth=$$$cntMinFormWidth Set MsgForm.Width=FormWidth Set MsgForm.Left=(%Screen.Width-FormWidth)\2 New ButtonOffsetLeft Set ButtonOffsetLeft=((FormWidth-BtnWidthSum)\2)+1 ;FormHeight bepalen adhv message New Memo Set Memo=##class(UI.TNT.TMemo).Create(MsgForm,"mmoMsg","",2,2,2,FormWidth-2,2,2) Set Memo.TabStop=0 Set Memo.Enabled=0 Set Memo.Text=Message Do Memo.Wrap() ;Indien slechts 1 row, neem dan toch een plaats van hoogte 3 in beslag If Memo.Rows=1 Do . Set Memo.Height=3 . Set Memo.Top=3 Else Do . Set Memo.Height=Memo.Rows New FormHeight Set FormHeight=Memo.Height+4 Set MsgForm.Height=FormHeight Set MsgForm.Top=(%Screen.Height-FormHeight)\2 ;Msg kader New Kader Set Kader=##class(UI.TNT.TKader).Create(MsgForm,"kdrMsg",Caption,1,1,MsgForm.Height,MsgForm.Width,1,1,,) ;Lijn boven buttons New Line Set Line=##class(UI.TNT.TLijn).CreateLijn("H",MsgForm,"lnMsg",FormHeight-2,1,FormWidth,FormHeight-2,,,$LB($LB(1,"ML"),$LB(,"MR"))) ;Creatie van de buttons op de form New Button,DefButton Set BtnWidthSum=0, DefButton=0 For Loop=1:1:$LL(lbButtons) Do . Set ButtonType=$LI(lbButtons,Loop) . Set BtnCaption=$$ButtonToCaption(ButtonType) . Set BtnWidth=$L(BtnCaption)+2 . Set:(BtnWidth<$$$cntMinButtonWidth) BtnWidth=$$$cntMinButtonWidth . Set Button=##class(UI.TNT.TButton).Create(MsgForm,"Btn"_BtnCaption,BtnCaption,FormHeight-1,ButtonOffsetLeft+BtnWidthSum,1,BtnWidth,(2+Loop),(2+Loop),,$LB($$$clUltraLight,$$$clDark),$$$alCenter) . Set BtnWidthSum=BtnWidthSum+BtnWidth+2 . Set Button.ModalResult=$$ButtonToModalResult(ButtonType) . Set:(ButtonType=DefaultButton) DefButton=Button Set:($IsObject(DefButton)) MsgForm.ActiveControl=DefButton New Result Set Result=MsgForm.ShowModal() Do MsgForm.Destroy() Quit Result ButtonToModalResult(Button) Quit $CASE(Button,$$$mbYes:$$$mrYes,$$$mbNo:$$$mrNo,$$$mbOk:$$$mrOk,$$$mbCancel:$$$mrCancel,$$$mbAbort:$$$mrAbort,$$$mbRetry:$$$mrRetry,$$$mbIgnore:$$$mrIgnore,$$$mbAll:$$$mrAll,$$$mbNoToAll:$$$mrNoToAll,$$$mbYesToAll:$$$mrYesToAll,$$$mbHelp:$$$mrHelp,:Button) ButtonToCaption(Button) Quit $CASE(Button,$$$mbYes:$$$SMsgDlgYes,$$$mbNo:$$$SMsgDlgNo,$$$mbOk:$$$SMsgDlgOk,$$$mbCancel:$$$SMsgDlgCancel,$$$mbAbort:$$$SMsgDlgAbort,$$$mbRetry:$$$SMsgDlgRetry,$$$mbIgnore:$$$SMsgDlgIgnore,$$$mbAll:$$$SMsgDlgAll,$$$mbNoToAll:$$$SMsgDlgNoToAll,$$$mbYesToAll:$$$SMsgDlgYesToAll,$$$mbHelp:$$$SMsgDlgHelp,:Button)