New Dialog!

BlitzMax Forums/BlitzMax GUI Programming/New Dialog!

Ked, great work.
I just changed your Reminder to manage better the text height (on MacOS the last line in your original example is cut off).


Strict
'Import maxgui.maxgui
Import maxgui.drivers

'CREATED BY KEDRIC SIDDONS'
'COPYRIGHT 2008 KEDRIC SIDDONS'

Type TReminderDialog
	Global _window:TGadget
	Global _imgpanel:TGadget
	Global _infolabel:TGadget
	Global _okbutton:TGadget
	
	Function Create(parent:TGadget,remindertxt:String,image:TPixmap=Null)
		If GadgetClass(parent)<>GADGET_WINDOW
			RuntimeError "TReminderDialog: Parent needs to be a window!"
			End
		EndIf
		
		
		Local hpa:Int=150
		Local ac$
		
		For Local c:Int=0 Until Len(remindertxt)
			ac=remindertxt[c]
	
			If ac=10 Or ac=13 hpa:+10			
		Next
		
		
		DisableGadget parent
		_window=CreateWindow("Reminder",0,0,300,hpa,parent,WINDOW_TITLEBAR|WINDOW_CENTER|WINDOW_CLIENTCOORDS)
		_imgpanel=CreatePanel(10,10,64,64,_window)
		If image<>Null
			SetPanelPixmap _imgpanel,image,PANELPIXMAP_FIT
		EndIf
		_infolabel=CreateLabel(remindertxt,84,10,ClientWidth(_window)-(84+10),ClientHeight(_window)-(24+10+10),_window)
		_okbutton=CreateButton("OK",ClientWidth(_window)-(70+10),ClientHeight(_window)-(24+10),70,24,_window)
		
		Repeat
			WaitEvent()
			Select EventID()
				Case EVENT_WINDOWCLOSE
					Select EventSource()
						Case _window
							EnableGadget parent
							FreeGadget _window
							Exit
					EndSelect
					
				Case EVENT_GADGETACTION
					Select EventSource()
						Case _okbutton
							EnableGadget parent
							FreeGadget _window
							Exit
					EndSelect
			EndSelect
		Forever
	EndFunction
EndType

Rem
bbdoc: Creates a reminder dialog.
EndRem
Function Reminder(parent:TGadget,remindertxt:String,image:TPixmap=Null)
	TReminderDialog.Create(parent,remindertxt,image)
EndFunction

'EXAMPLE'
Local window:TGadget=CreateWindow("Dialog",50,50,640,480,Desktop(),1+2)
Local button:TGadget=CreateButton("Dialog",10,10,80,24,window)
Local image:TPixmap=LoadPixmap("F:\Blitzmax.png")

Repeat
	WaitEvent()
	Select EventID()
		Case event_windowclose
			Select EventSource()
				Case window
					End
			EndSelect
		
		Case event_gadgetaction
			Select EventSource()
				Case button
					Reminder(window,"Hey!~nThis is to remind you that this "+..
					"magnificent piece of work is fantastic and that you should "+..
					"always use it.~n~nThank you for your time.",image)
			EndSelect
	EndSelect
Forever