It has to be improved.
For example, it is not the same behaviour if you change the date using the calendar or directly without using the calendar.
Just click and modify the different gadgets and see what happens.
Code: Select all
; V01 Dec 19, 2012
; Conclusion about the detection of a modification in a gadget.
; DateGadget and ComboBox have not the same behaviour as StringGadget
EnableExplicit
Enumeration
#zero
#windows
#gmouv_detail_date
#gmouv_detail_cpte
#gmouv_detail_lib1
#gmouv_detail_lib2
#gmouv_detail_lib3_num
#gmouv_detail_button
#gmouv_info
EndEnumeration
Enumeration
#mouv_list_col_event
#mouv_list_col_gadget
#mouv_list_col_event_type
#mouv_list_col_before
#mouv_list_col_now
EndEnumeration
#masque_date$ = "%dd/%mm/%yy"
Global Gtitle$ = "GetActiveGadget test"
Declare err(Plib$)
Declare.s Cd_jc(Pconstant)
Declare.s Cd_pb(Pconstant)
;- BEGIN
Define window_width,window_height
Define wmargin_init, wmargin, wlig, width, wheight, width_column
Define wevent, wevent_gadget, wevent_type, wfocus, wfocus_Before
Define wlib$
Define wnow, wnow_before
Define wheight_char, width_char
window_width = 1000
window_height = 700
wmargin_init = 10
wheight_char = 30
width_char = 30
If OpenWindow(#windows,-1,-1,window_width,window_height,Gtitle$) = 0
err("Unable to open Window")
End
EndIf
; ----------------------------------------- date
wmargin = wmargin_init
wlig = 10
width = 150
DateGadget(#gmouv_detail_date, wmargin, wlig, width, wheight_char,#masque_date$)
; ----------------------------------------- ComboBox
wmargin = wmargin + width + width_char
width = 250
ComboBoxGadget(#gmouv_detail_cpte, wmargin, wlig, width, wheight_char,#PB_ComboBox_UpperCase)
AddGadgetItem(#gmouv_detail_cpte,-1,"First account")
AddGadgetItem(#gmouv_detail_cpte,-1,"Second account")
AddGadgetItem(#gmouv_detail_cpte,-1,"Third account")
; ------------------------------------------ String 1
wmargin = wmargin + width + width_char
width = window_width - wmargin - wmargin_init
StringGadget(#gmouv_detail_lib1, wmargin, wlig, width, wheight_char, "")
; ------------------------------------------ String 2
wmargin = wmargin_init
wlig = wlig + 2 * wheight_char
width = window_width - 2 * wmargin
StringGadget(#gmouv_detail_lib2, wmargin, wlig, width, wheight_char, "")
; ------------------------------------------ String 3 numerical
wmargin = wmargin_init
wlig = wlig + 2 * wheight_char
width = window_width - 2 * wmargin
StringGadget(#gmouv_detail_lib3_num, wmargin, wlig, width, wheight_char, "",#PB_String_Numeric)
; ------------------------------------------ Button
wmargin = wmargin_init
wlig = wlig + 2 * wheight_char
width = 10 * width_char
ButtonGadget(#gmouv_detail_button, wmargin, wlig, width, wheight_char, "Button")
; ------------------------------------------ Debug
wmargin = wmargin_init
wlig = wlig + 2 * wheight_char
width = window_width - 2 * wmargin
width_column = width / 5
wheight = window_height - wlig - wheight_char
ListIconGadget(#gmouv_info, wmargin, wlig, width, wheight, "Event", width_column, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(#gmouv_info,#mouv_list_col_Gadget ,"Gadget" , width_column)
AddGadgetColumn(#gmouv_info,#mouv_list_col_event_type ,"Event_type" , width_column)
AddGadgetColumn(#gmouv_info,#mouv_list_col_before ,"Focus_before" , width_column)
AddGadgetColumn(#gmouv_info,#mouv_list_col_now ,"Focus_now" , width_column)
; ---------------------------------------------------------------- CTL
wnow_before = ElapsedMilliseconds()
Repeat
wEvent = WaitWindowEvent()
wfocus = GetActiveGadget()
Select wEvent
Case #PB_Event_Gadget
wevent_gadget = EventGadget()
wevent_type = EventType()
wlib$ = Cd_pb(wevent)
wlib$ = wlib$ + Chr(10) + Cd_jc(wevent_gadget)
wlib$ = wlib$ + Chr(10) + Cd_pb(wevent_type) + " (" + Str(wevent_type) + ")"
wlib$ = wlib$ + Chr(10) + Cd_jc(wfocus_Before)
wlib$ = wlib$ + Chr(10) + Cd_jc(wfocus)
AddGadgetItem(#gmouv_info,0,wlib$)
Case #PB_Event_Repaint
Case #PB_Button_Right
Case 275
Case 160
Case 675
Case 280
Default
wnow = ElapsedMilliseconds()
If wnow - wnow_before > 200
AddGadgetItem(#gmouv_info,0,"-----------------" + FormatDate("%ii:%ss",Date()))
EndIf
wnow_before = wnow
wevent_gadget = EventGadget()
wevent_type = EventType()
wlib$ = Cd_pb(wevent)
wlib$ = wlib$ + Chr(10) + Cd_jc(wevent_gadget)
wlib$ = wlib$ + Chr(10) + Cd_pb(wevent_type) + " (" + Str(wevent_type) + ")"
wlib$ = wlib$ + Chr(10) + Cd_jc(wfocus_Before)
wlib$ = wlib$ + Chr(10) + Cd_jc(wfocus)
AddGadgetItem(#gmouv_info,0, wlib$ )
EndSelect
wfocus_Before = wfocus
Until wEvent = #PB_Event_CloseWindow
; ----------------------------------------------------------------- END
CloseWindow(#windows)
End
; ----------------------------------------------------------------- Procedures
Procedure err(Plib$)
MessageRequester(Gtitle$,Plib$)
EndProcedure
Procedure.s Cd_jc(Pconstant)
Define wout$
Select Pconstant
Case #windows : wout$ = "#windows"
Case #gmouv_detail_date : wout$ = "#gmouv_detail_date"
Case #gmouv_detail_cpte : wout$ = "#gmouv_detail_cpte"
Case #gmouv_detail_lib1 : wout$ = "#gmouv_detail_lib1"
Case #gmouv_detail_lib2 : wout$ = "#gmouv_detail_lib2"
Case #gmouv_detail_lib3_num : wout$ = "#gmouv_detail_lib3_num"
Case #gmouv_detail_button : wout$ = "#gmouv_detail_button"
Case #gmouv_info : wout$ = "#gmouv_info"
Case #mouv_list_col_gadget : wout$ = "#mouv_list_col_gadget"
Case #mouv_list_col_event : wout$ = "#mouv_list_col_event"
Case #mouv_list_col_before : wout$ = "#mouv_list_col_before"
Case #mouv_list_col_now : wout$ = "#mouv_list_col_now"
Case #zero : wout$ = "#zero"
Default : wout$ = Str(Pconstant)
EndSelect
ProcedureReturn wout$
EndProcedure
Procedure.s Cd_pb(Pconstant)
Define wout$
Select Pconstant
Case #PB_EventType_LeftClick : wout$ = "#PB_EventType_LeftClick"
Case #PB_EventType_RightClick : wout$ = "#PB_EventType_RightClick"
Case #PB_EventType_LeftDoubleClick : wout$ = "#PB_EventType_LeftDoubleClick"
Case #PB_EventType_RightDoubleClick : wout$ = "#PB_EventType_RightDoubleClick"
Case #PB_EventType_DownloadStart : wout$ = "#PB_EventType_DownloadStart"
Case #PB_Event_SizeWindow : wout$ = "#PB_Event_SizeWindow"
Case #PB_EventType_DownloadEnd : wout$ = "#PB_EventType_DownloadEnd"
Case #PB_EventType_PopupMenu : wout$ = "#PB_EventType_PopupMenu"
Case #PB_Event_Repaint : wout$ = "#PB_Event_Repaint"
Case #PB_Event_CloseWindow : wout$ = "#PB_Event_CloseWindow"
Case #PB_EventType_Change : wout$ = "#PB_EventType_Change"
Case #PB_Event_Gadget : wout$ = "#PB_Event_Gadget"
Case #PB_Event_Menu : wout$ = "#PB_Event_Menu"
Case #PB_Event_SysTray : wout$ = "#PB_Event_SysTray"
Case #PB_Event_ActivateWindow : wout$ = "#PB_Event_ActivateWindow"
Case #PB_Event_WindowDrop : wout$ = "#PB_Event_WindowDrop"
Case #PB_Event_GadgetDrop : wout$ = "#PB_Event_GadgetDrop"
Case #PB_Event_MinimizeWindow : wout$ = "#PB_Event_MinimizeWindow"
Case #PB_Event_MaximizeWindow : wout$ = "#PB_Event_MaximizeWindow"
Case #PB_Event_RestoreWindow : wout$ = "#PB_Event_RestoreWindow"
Case #PB_Event_Timer : wout$ = "#PB_Event_Timer"
Case #PB_EventType_Focus : wout$ = "#PB_EventType_Focus"
Case #PB_EventType_LostFocus : wout$ = "#PB_EventType_LostFocus"
Case #PB_EventType_DragStart : wout$ = "#PB_EventType_DragStart"
Case #PB_EventType_MouseEnter : wout$ = "#PB_EventType_MouseEnter"
Case #PB_EventType_MouseLeave : wout$ = "#PB_EventType_MouseLeave"
Case #PB_EventType_MouseMove : wout$ = "#PB_EventType_MouseMove"
Case #PB_EventType_LeftButtonDown : wout$ = "#PB_EventType_LeftButtonDown"
Case #PB_EventType_LeftButtonUp : wout$ = "#PB_EventType_LeftButtonUp"
Case #PB_EventType_RightButtonDown : wout$ = "#PB_EventType_RightButtonDown"
Case #PB_EventType_RightButtonUp : wout$ = "#PB_EventType_RightButtonUp"
Case #PB_EventType_MiddleButtonDown : wout$ = "#PB_EventType_MiddleButtonDown"
Case #PB_EventType_MiddleButtonUp : wout$ = "#PB_EventType_MiddleButtonUp"
Case #PB_EventType_MouseWheel : wout$ = "#PB_EventType_MouseWheel"
Case #PB_EventType_KeyDown : wout$ = "#PB_EventType_KeyDown"
Case #PB_EventType_KeyUp : wout$ = "#PB_EventType_KeyUp"
Case #PB_EventType_Input : wout$ = "#PB_EventType_Input"
Case #PB_Button_Left : wout$ = "#PB_Button_Left"
Case #PB_Button_Right : wout$ = "#PB_Button_Right"
Default : wout$ = Str(Pconstant)
EndSelect
ProcedureReturn wout$
EndProcedure