Problems with dialog library

Just starting out? Need help? Post your questions and find answers here.
nsstudios
Enthusiast
Enthusiast
Posts: 127
Joined: Wed Aug 28, 2019 1:01 pm

Problems with dialog library

Post by nsstudios »

Hi all,

I have a few problems with the dialog library; I hope you can help me.
1. Handling list icon columns.
I see nothing about it either on forum or in the help file, but looking at the PB ide, I see it does:

Code: Select all

              <listicon id="#GADGET_Preferences_ShortcutList" flags="#PB_ListIcon_FullRowSelect">
                <column width="200" lang="Shortcuts:Action" />
                <column width="90" lang="Shortcuts:Shortcut" />
              </listicon>
Does PB ide use an improved version of dialog library, or what's up with that?
What is the easiest way to create a listicon with multiple columns that would automatically resize themselves just like the gadget would?

2. Calling RefreshDialog reverts the window state, e.g., maximized.

Unless I don't understand how that function works, you're meant to call refresh dialog if the window changes, e.g., moved, resized, minimized, maximized, etc., but when I do that, and my window was maximized beforehand, it reverts that.

Code: Select all

EnableExplicit
#xml$="<window id='0' name='test' text='test' flags='#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget' minwidth='auto' minheight='auto' maxwidth='auto' maxheight='auto'><hbox><vbox><button id='0' name='test' text='test'/></vbox></hbox></window>"
ParseXML(0, #xml$)
Define err.s=XMLError(0)
If err<>""
MessageRequester(err, ""+XMLErrorLine(0)+", "+XMLErrorPosition(0))
End
EndIf
CreateDialog(0)
OpenXMLDialog(0, 0, "test")
err=DialogError(0)
If err<>""
MessageRequester("error", err)
End
EndIf
; try to maximize the window, and it will automatically revert the maximized state thanks to RefreshDialog()

Repeat
Define e=WaitWindowEvent()
Select e
Case #PB_Event_SizeWindow, #PB_Event_MoveWindow, #PB_Event_MinimizeWindow, #PB_Event_MaximizeWindow, #PB_Event_RestoreWindow
Debug "before: "+GetWindowState(0)
RefreshDialog(0)
Debug "After: "+GetWindowState(0)
EndSelect
Until e=#PB_Event_CloseWindow
I would really appreciate any help.
Thanks.
Cyllceaux
Enthusiast
Enthusiast
Posts: 273
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: Problems with dialog library

Post by Cyllceaux »

Hey there...

To point 1. Dialog Manager only creates "default" gadgets. Like what you can do wit the init commands from PB. (e.g. StringGadget(...), ListIconGadget(...),...) and some BindEvents (on left click, ...) but nothing more. You have to do it by yourself.

To point 2.
RefreshDialog makes a reinit. PB can decide the natural size of a gadget. For example the TextGadget will be this width to show his complete text. If you change the text per code, the size does not change automatically. So you have to reinit the dialog. The problem is, the state of some Gadgets and Windows will be lost, cause they are not "saved". Text, State, Attribute, Columns and Items will be saved and are used at the reinit.
nsstudios
Enthusiast
Enthusiast
Posts: 127
Joined: Wed Aug 28, 2019 1:01 pm

Re: Problems with dialog library

Post by nsstudios »

Thank you for the clarification. I was hoping there would be a workaround...
Cyllceaux
Enthusiast
Enthusiast
Posts: 273
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: Problems with dialog library

Post by Cyllceaux »

there are a lot of workarounds.

I wrote a code generator to make this.

My generator creates inits they look like this:

viewtopic.php?p=557340#p557340

Code: Select all

XIncludeFile "dialog.pb"

Declare closeMainDialog()
Declare openMain(*data=0,*parent=0)
;{ Own_DeclareMainDialog Declare
	
;} Own_DeclareMainDialog Declare

EnableExplicit




Structure strMainDialog Extends strDialog
	_btnNeuerTermin.i
	_btnNeueNotiz.i
	_btnNeueAufgabe.i
	_btnNeuerKontakt.i
	_panel.i
	_lstTermine.i
	_lstNotizen.i
	_txtNeueNotiz.i
	_lstAufgaben.i
	_txtNeueAufgabe.i
	_lstKontakte.i
	_txtDashboardNeueAufgabe.i

	*data


	;{ Own_strMainDialog
	; TODO strMainDialog
		
	;} Own_strMainDialog
EndStructure

Runtime Enumeration _gadget

	;{ Own_MainGadget
	; TODO MainGadget
		
	;} Own_MainGadget
EndEnumeration

Runtime Enumeration _men

	;{ Own_MainMenu
	; TODO MainMenu
		
	;} Own_MainMenu
EndEnumeration


Declare neuerTermin()
Declare neueNotiz()
Declare neueAufgabe()
Declare neuerKontakt()
Declare filterTermine()
Declare filterTermineHeute()
Declare filterTermineWoche()
Declare filterTermineMonat()
Declare filterTermineJahr()
Declare filterNotizen()
Declare filterAufgaben()
Declare filterKontakte()
Declare filterDashboard()

;{ Own_MainDialog Declare
	Declare neueAufgabeHinzufuegen()
	Declare neueNotizHinzufuegen()
	Declare neueAufgabeHinzufuegenDashboard()
	
;} Own_MainDialog Declare

Runtime Procedure closeMainDialog()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_closeMainDialog
	; TODO closeMainDialog
		
	;} Own_closeMainDialog
	With *dialog
				ListIcon::UnDefineListCallback(*dialog\_lstNotizen)
		ListIcon::UnDefineListCallback(*dialog\_lstTermine)
		ListIcon::UnDefineListCallback(*dialog\_lstAufgaben)
		ListIcon::UnDefineListCallback(*dialog\_lstKontakte)

		CloseWindow(\window)
		FreeDialog(\dialog)
	EndWith
	FreeStructure(*dialog)
EndProcedure


Procedure openMain(*data=0,*parent.strDialog=0)
	Protected dialog=CreateDialog(#PB_Any)
	Protected pid=0
	If *parent
		pid=WindowID(*parent\window)
	EndIf
	If OpenXMLDialog(dialog,dialogXML,"Main",0,0,0,0,pid)
		Protected *dialog.strMainDialog=AllocateStructure(strMainDialog)
		initDialog(strMainDialog)


		BindEvent(#PB_Event_CloseWindow,@closeMainDialog(),*dialog\window)
		
		*dialog\_btnNeuerTermin=DialogGadget(dialog,"btnNeuerTermin")
		*dialog\_btnNeueNotiz=DialogGadget(dialog,"btnNeueNotiz")
		*dialog\_btnNeueAufgabe=DialogGadget(dialog,"btnNeueAufgabe")
		*dialog\_btnNeuerKontakt=DialogGadget(dialog,"btnNeuerKontakt")
		*dialog\_panel=DialogGadget(dialog,"panel")
		*dialog\_lstTermine=DialogGadget(dialog,"lstTermine")
		*dialog\_lstNotizen=DialogGadget(dialog,"lstNotizen")
		*dialog\_txtNeueNotiz=DialogGadget(dialog,"txtNeueNotiz")
		*dialog\_lstAufgaben=DialogGadget(dialog,"lstAufgaben")
		*dialog\_txtNeueAufgabe=DialogGadget(dialog,"txtNeueAufgabe")
		*dialog\_lstKontakte=DialogGadget(dialog,"lstKontakte")
		*dialog\_txtDashboardNeueAufgabe=DialogGadget(dialog,"txtDashboardNeueAufgabe")

		GadgetToolTip(*dialog\_btnNeueNotiz,"Neue Notiz")
		GadgetToolTip(*dialog\_btnNeuerTermin,"Neuer Termin")
		GadgetToolTip(*dialog\_btnNeuerKontakt,"Neuer Kontakt")
		GadgetToolTip(*dialog\_btnNeueAufgabe,"Neue Aufgabe")

		SetGadgetAttribute(*dialog\_btnNeueNotiz,#PB_Button_Image,ImageID(img_note))
		SetGadgetAttribute(*dialog\_btnNeuerTermin,#PB_Button_Image,ImageID(img_appointment_calendar))
		SetGadgetAttribute(*dialog\_btnNeuerKontakt,#PB_Button_Image,ImageID(img_editor))
		SetGadgetAttribute(*dialog\_btnNeueAufgabe,#PB_Button_Image,ImageID(img_tasks))

		SetGadgetAttribute(*dialog\_lstNotizen,#PB_ListIcon_DisplayMode,#PB_ListIcon_LargeIcon)
		UseModule ListIcon
			DefineListCallback(*dialog\_lstNotizen,#False,0,0)
		UnuseModule ListIcon
		UseModule ListIcon
			DefineListCallback(*dialog\_lstTermine,#False,0,0)
		UnuseModule ListIcon
		UseModule ListIcon
			DefineListCallback(*dialog\_lstAufgaben,#False,0,0)
		UnuseModule ListIcon
		UseModule ListIcon
			DefineListCallback(*dialog\_lstKontakte,#False,0,0)
		UnuseModule ListIcon

		SetGadgetAttribute(*dialog\_lstNotizen,#PB_ListIcon_DisplayMode,#PB_ListIcon_LargeIcon)

		
		;{ Own_openMain
			StringGadget::RegisterStringGadget(*dialog\_txtNeueAufgabe,"Neue Aufgabe...",@neueAufgabeHinzufuegen())
			StringGadget::RegisterStringGadget(*dialog\_txtDashboardNeueAufgabe,"Neue Aufgabe...",@neueAufgabeHinzufuegenDashboard())
			StringGadget::RegisterStringGadget(*dialog\_txtNeueNotiz,"Neue Notiz...",@neueNotizHinzufuegen())
			
		;} Own_openMain
		
		RefreshDialog(*dialog\dialog)
		ProcedureReturn *dialog
	Else
		MessageRequester("Dialog Fehler",DialogError(dialog),#PB_MessageRequester_Error)
		ProcedureReturn #False
	EndIf
EndProcedure


Runtime Procedure neuerTermin()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_neuerTermin()
	;TODO neuerTermin()
	;} Own_neuerTermin()
EndProcedure

Runtime Procedure neueNotiz()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_neueNotiz()
	openNotiz()
	;} Own_neueNotiz()
EndProcedure

Runtime Procedure neueAufgabe()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_neueAufgabe()
	;TODO neueAufgabe()
	;} Own_neueAufgabe()
EndProcedure

Runtime Procedure neuerKontakt()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_neuerKontakt()
	;TODO neuerKontakt()
	;} Own_neuerKontakt()
EndProcedure

Runtime Procedure filterTermine()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_filterTermine()
	;TODO filterTermine()
	;} Own_filterTermine()
EndProcedure

Runtime Procedure filterTermineHeute()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_filterTermineHeute()
	;TODO filterTermineHeute()
	;} Own_filterTermineHeute()
EndProcedure

Runtime Procedure filterTermineWoche()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_filterTermineWoche()
	;TODO filterTermineWoche()
	;} Own_filterTermineWoche()
EndProcedure

Runtime Procedure filterTermineMonat()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_filterTermineMonat()
	;TODO filterTermineMonat()
	;} Own_filterTermineMonat()
EndProcedure

Runtime Procedure filterTermineJahr()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_filterTermineJahr()
	;TODO filterTermineJahr()
	;} Own_filterTermineJahr()
EndProcedure

Runtime Procedure filterNotizen()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_filterNotizen()
	;TODO filterNotizen()
	;} Own_filterNotizen()
EndProcedure

Runtime Procedure filterAufgaben()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_filterAufgaben()
	;TODO filterAufgaben()
	;} Own_filterAufgaben()
EndProcedure

Runtime Procedure filterKontakte()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_filterKontakte()
	;TODO filterKontakte()
	;} Own_filterKontakte()
EndProcedure

Runtime Procedure filterDashboard()
	Protected *dialog.strMainDialog=GetWindowData(EventWindow())
	;{ Own_filterDashboard()
	;TODO filterDashboard()
	;} Own_filterDashboard()
EndProcedure


;{ Own_MainDialog Impl
	
	Procedure neueAufgabeHinzufuegen()
		Protected *dialog.strMainDialog=GetWindowData(EventWindow())
		Debug GetGadgetText(*dialog\_txtNeueAufgabe)
	EndProcedure
	
	Procedure neueAufgabeHinzufuegenDashboard()
		Protected *dialog.strMainDialog=GetWindowData(EventWindow())
		Debug GetGadgetText(*dialog\_txtDashboardNeueAufgabe)
	EndProcedure
	
	Procedure neueNotizHinzufuegen()
		Protected *dialog.strMainDialog=GetWindowData(EventWindow())
		Debug GetGadgetText(*dialog\_txtNeueNotiz)
	EndProcedure
	
;} Own_MainDialog Impl
Post Reply