Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
;
; ------------------------------------------------------------
;
;   Tableur DATE by klr 128 fonctionne
;
; ------------------------------------------------------------
;
 
;EnableExplicit
#PB_EventType_Scroll = #PB_EventType_FirstCustomValue + 1
#PB_EventType_Select = #PB_EventType_FirstCustomValue + 2
#PB_EventType_Copy = #PB_EventType_FirstCustomValue + 3
#PB_EventType_Cut = #PB_EventType_FirstCustomValue + 4
#PB_EventType_Paste = #PB_EventType_FirstCustomValue + 5
#PB_EventType_Drag = #PB_EventType_FirstCustomValue + 6
#PB_EventType_DragEnd = #PB_EventType_FirstCustomValue + 7
#PB_EventType_Drop = #PB_EventType_FirstCustomValue + 8
#PB_EventType_TouchStart = #PB_EventType_FirstCustomValue + 9
#PB_EventType_TouchEnd = #PB_EventType_FirstCustomValue + 10
#PB_EventType_TouchCancel = #PB_EventType_FirstCustomValue + 11
#PB_EventType_TouchMove = #PB_EventType_FirstCustomValue + 12
 
Procedure BindGadgetEventEx(gadget, callback, eventtype)
  Protected id.s
  Protected NewMap Events.s()
  Protected eventvalue
  Protected eventname.s
 
  If GadgetType(gadget) = #PB_GadgetType_Canvas
    BindGadgetEvent(gadget, callback, eventtype)
  Else
    Events(Str(#PB_EventType_LeftClick)) = "click"
    Events(Str(#PB_EventType_RightClick)) = "contextmenu"
    Events(Str(#PB_EventType_LeftDoubleClick)) = "dblclick"
    Events(Str(#PB_EventType_Focus)) = "focusin"
    Events(Str(#PB_EventType_LostFocus)) = "focusout"
    Events(Str(#PB_EventType_Change)) = "change"
    Events(Str(#PB_EventType_MouseEnter)) = "mouseenter"
    Events(Str(#PB_EventType_MouseLeave)) = "mouseleave"
    Events(Str(#PB_EventType_MouseMove)) = "mousemove"
    Events(Str(#PB_EventType_Scroll)) = "scroll"
    Events(Str(#PB_EventType_KeyDown)) = "keydown"
    Events(Str(#PB_EventType_KeyUp)) = "keyup"
    Events(Str(#PB_EventType_Select)) = "select"
    Events(Str(#PB_EventType_Copy)) = "copy"
    Events(Str(#PB_EventType_Cut)) = "cut"
    Events(Str(#PB_EventType_Paste)) = "paste"
    Events(Str(#PB_EventType_Drag)) = "drag"
    Events(Str(#PB_EventType_DragEnd)) = "dragend"
    Events(Str(#PB_EventType_Drop)) = "drop"
    Events(Str(#PB_EventType_TouchStart)) = "touchstart"
    Events(Str(#PB_EventType_TouchEnd)) = "touchend"
    Events(Str(#PB_EventType_TouchCancel)) = "touchcancel"
    Events(Str(#PB_EventType_TouchMove)) = "touchmove"
 
    ! var GadgetElement = spider_GadgetID(v_gadget).div;
 
    If eventtype = #PB_All
      ! function ParameterPasser(gadget, eventvalue) {
      !   return function() {
      !     spider.event.eventObject = gadget;
      !     spider.event.eventType = eventvalue;
      !     v_callback();
      !   }
      ! }
      ForEach Events()
        eventvalue = Val(MapKey(Events()))
        eventname = Events()
        ! GadgetElement.addEventListener(v_eventname, ParameterPasser(v_gadget, v_eventvalue));
      Next
    Else
      eventname = Events(Str(eventtype))
      ! GadgetElement.addEventListener(v_eventname, function() {
      !   spider.event.eventObject = v_gadget;
      !   spider.event.eventType = v_eventtype;
      !   v_callback();
      ! });
    EndIf
  EndIf
 
EndProcedure
 
Macro BindGadgetEvent(gadget, callback, eventtype = #PB_All)
  BindGadgetEventEx(gadget, callback, eventtype)
EndMacro
 
;================================================== Beispielcode ==================================================
Global scrollgad2,scrollgad3
 
Procedure Handler()
  Select EventType()
    Case #PB_EventType_LeftClick
      Debug "Gadget: " + Str(EventGadget())
      Debug "#PB_EventType_LeftClick"
    Case #PB_EventType_RightClick
      Debug "Gadget: " + Str(EventGadget())
      Debug "#PB_EventType_RightClick"
    Case #PB_EventType_Focus
      Debug "Gadget: " + Str(EventGadget())
      Debug "#PB_EventType_Focus"
    Case #PB_EventType_LostFocus
      Debug "Gadget: " + Str(EventGadget())
      Debug "#PB_EventType_LostFocus"
    Case #PB_EventType_KeyDown
      Debug "Gadget: " + Str(EventGadget())
      Debug "#PB_EventType_KeyDown"
    Case #PB_EventType_KeyUp
      Debug "Gadget: " + Str(EventGadget())
      Debug "#PB_EventType_KeyUp"
    Case #PB_EventType_Copy
      Debug "Gadget: " + Str(EventGadget())
      Debug "#PB_EventType_Copy"
    Case #PB_EventType_Scroll
;      Debug "Gadget: " + Str(EventGadget())
;      Debug "#PB_EventType_scroll" 
;If EventGadget() = scrollgad2      
;  Debug GetGadgetAttribute(scrollgad2, #PB_ScrollArea_X) 
;    SetGadgetAttribute(scrollgad3, #PB_ScrollArea_X, GetGadgetAttribute(scrollgad2, #PB_ScrollArea_X) )
;  EndIf      
      If EventGadget() = scrollgad3
        ;Debug GetGadgetAttribute(scrollgad3, #PB_ScrollArea_X) 
        SetGadgetAttribute(scrollgad2, #PB_ScrollArea_X, GetGadgetAttribute(scrollgad3, #PB_ScrollArea_X) )
        ;Debug GetGadgetAttribute(scrollgad2, #PB_ScrollArea_X) 
      EndIf
  EndSelect 
EndProcedure
 
 
;ExamineDesktops()
;Debug "Desktop dimension: " + DesktopWidth(0) + " x " + DesktopHeight(0)
 
Dim tableur(34,33) ; Declare a numeric array of 6 elements (0 to 5)
 
nb=210
For k = 1 To 33 ;ArraySize(tableur())
  tableur(0,k) = nb;Random(1000) ; Pick a random number between 0 and 1000 
  nb=nb-2
Next
 
nb2=30;
For k = 1 To 34 ;ArraySize(tableur())
  tableur(k,0) = nb2;Random(1000) ; Pick a random number between 0 and 1000 
  nb2=nb2+3
Next
 
For i = 1 To 34 ;ArraySize(tableur())
  For j = 1 To 33 ;ArraySize(tableur())
  tableur(i,j) = Random(99) ; Pick a random number between 0 and 1000 
  Next
Next
 
;  Procedure GadgetEvent()
;  Select EventType()
;    Case #PB_EventType_LeftClick
;      Debug "Gadget: " + Str(EventGadget())
;      Debug "#PB_EventType_LeftClick"
;    Case #PB_EventType_RightClick
;      Debug "Gadget: " + Str(EventGadget())
;      Debug "#PB_EventType_RightClick"
;    Case #PB_EventType_Focus
;      Debug "Gadget: " + Str(EventGadget())
;      Debug "#PB_EventType_Focus"
;    Case #PB_EventType_LostFocus
;      Debug "Gadget: " + Str(EventGadget())
;      Debug "#PB_EventType_LostFocus"
;    Case #PB_EventType_KeyDown
;      Debug "Gadget: " + Str(EventGadget())
;      Debug "#PB_EventType_KeyDown"
;    Case #PB_EventType_KeyUp
;      Debug "Gadget: " + Str(EventGadget())
;      Debug "#PB_EventType_KeyUp"
;    EndSelect  
;    Events(Str(#PB_EventType_Scroll)) = "scroll"
;    Debug GetGadgetAttribute(scrollgad2, #PB_ScrollArea_X) 
;    Debug "Button " + EventGadget() + " pressed!"
;  EndProcedure
 
If OpenWindow(0, 10, 10, 400+30, 400+30, "tableur")
  scrollgad2 = ScrollAreaGadget(#PB_Any, 10+35, 0, 400-35-25+15, 25+10+20,1230-(10+35), 10+25, 1,#PB_ScrollArea_BorderLess) ; [, ScrollStep [, Flags]])
    ! var GadgetElement = spider_GadgetID(v_scrollgad2).div;
;! GadgetElement.style.overflow = 'hidden';
      ! GadgetElement.style.scrollbarWidth = 'none';
 
      For k = 1 To 7 ;34 ;ArraySize(tableur())
      Select k
        Case 7 : nomj.s= "Dim"
        Case 1 : nomj.s= "Lun"
        Case 2 : nomj.s= "Mar"
        Case 3 : nomj.s= "Mer"
        Case 4 : nomj.s= "Jeu"
        Case 5 : nomj.s= "Ven"
        Case 6 : nomj.s= "Sam"
      EndSelect
        ;Str(tableur(k,0))
    txt1 = TextGadget(#PB_Any, ((k-1) *(34+15)),10, 35+15, 25, nomj , #PB_Text_Border | #PB_Text_VerticalCenter | #PB_Text_Center)
    SetGadgetColor(txt1, #PB_Gadget_BackColor, RGB(0, 0, 255) )
  Next  
  CloseGadgetList()
 
  scrollgad = ScrollAreaGadget(#PB_Any, 0, 10+25, 400, 400-30, 400-20+30, 810,1,#PB_ScrollArea_BorderLess) ; [, ScrollStep [, Flags]])
      ! var GadgetElement = spider_GadgetID(v_scrollgad).div;
;      ! GadgetElement.style.scrollbarWidth = 'none';
 
      Debug "le "+FormatDate("%dd/%mm/%yyyy", Date())
      dd.s= Right(RSet(Str(Day(Date())), 2, "0"), 2)
      mm.s= Right(RSet(Str(Month(Date())), 2, "0"), 2)
      yyyy.s = Str(Year(Date()))
 
      num_semaine.i = DayOfYear(ParseDate("%dd/%mm/%yyyy", "01/"+mm+"/"+yyyy))
      mms.i= DayOfWeek( ParseDate("%dd/%mm/%yyyy", "01/01/"+yyyy) )
      Debug "   ttt "+Str( ((num_semaine+mms)/7) )      
      nbbb.i=((num_semaine+mms)/7)
 
  For k = 1 To 7 ;33 ;ArraySize(tableur())   ;tableur(0,k)
    txt1 = TextGadget(#PB_Any, 10, ((k-1) *(24*2)), 35, 25*2, Str(nbbb) , #PB_Text_Border | #PB_Text_VerticalCenter | #PB_Text_Center)
    SetGadgetColor(txt1, #PB_Gadget_BackColor, RGB(255, 0, 0) )
    nbbb=nbbb+1
  Next
 
 
  scrollgad3 = ScrollAreaGadget(#PB_Any, 10+35, 0, 400-35+30, 850-25,1230-(10+35)+30, 850-20-25, 1,#PB_ScrollArea_BorderLess) ; [, ScrollStep [, Flags]])
      ! var GadgetElement = spider_GadgetID(v_scrollgad3).div;
      ! GadgetElement.style.scrollbarWidth = 'none';
      Debug "mm "+mm+" ,yyyy "+yyyy
      bb.s=Right(RSet(Str(Month(Date())+1), 2, "0"), 2)
      nbj.s=FormatDate("%dd",  ParseDate("%dd/%mm/%yyyy", "01/"+bb+"/"+yyyy)- (60*60*24) )
      Debug "nb de j dans le mois en cours: "+ nbj ;DayOfYear(Date())-1
      jourj.i = DayOfWeek( ParseDate("%dd/%mm/%yyyy", "01/"+mm+"/"+yyyy) )     
      Select jourj
        Case 0 : nomj.s= "Dim"
        Case 1 : nomj.s= "Lun"
        Case 2 : nomj.s= "Mar"
        Case 3 : nomj.s= "Mer"
        Case 4 : nomj.s= "Jeu"
        Case 5 : nomj.s= "Ven"
        Case 6 : nomj.s= "Sam"
      EndSelect
      Debug "nom jour j: "+nomj
 
 
      nbb.i=0
      aa.i=0 ;pour calculer le jour dans le mois actuel
      pp.i=0 ;pr calculer les jour en mm+1
      For j = 1 To 7 ;33 
  For i = 1 To 7 ;34
      nbb=nbb+1
      cnt1= ContainerGadget(#PB_Any, ((i-1) *(34+15)),((j-1) *(24*2)), 33+15, 24*2-1,#PB_Container_Flat)
      If nbb>=jourj And aa < Val(nbj)
        aa=aa+1
        If Day(Date())=aa
          SetGadgetColor(cnt1, #PB_Gadget_BackColor, RGB(0, 255, 0) )         
        EndIf
        txt1 = TextGadget(#PB_Any, -1,-1, 35, 25, Str(aa) , #PB_Text_VerticalCenter | #PB_Text_Center) ;Str(tableur(i,j))
        txt2 = TextGadget(#PB_Any, 15,23, 35, 25, "a"+Str(tableur(i,j)) , #PB_Text_VerticalCenter | #PB_Text_Center)
      Else
        If nbb<jourj
          nbjs.s=FormatDate("%dd",  ParseDate("%dd/%mm/%yyyy", "01/"+mm+"/"+yyyy)- ((60*60*24)*(jourj-aa-1)) )          
          SetGadgetColor(cnt1, #PB_Gadget_BackColor, RGB(192, 192, 192) )         
          txt1 = TextGadget(#PB_Any, -1,-1, 35, 25, nbjs , #PB_Text_VerticalCenter | #PB_Text_Center) ;Str(tableur(i,j))
          txt2 = TextGadget(#PB_Any, 15,23, 35, 25, "a"+Str(tableur(i,j)) , #PB_Text_VerticalCenter | #PB_Text_Center)        
        EndIf
        If aa >= Val(nbj)
          nbjs.s=FormatDate("%dd",  ParseDate("%dd/%mm/%yyyy", "01/"+Str(Val(mm)+1)+"/"+yyyy)+ ((60*60*24)*(pp)) )          
          SetGadgetColor(cnt1, #PB_Gadget_BackColor, RGB(192, 192, 122) )         
          txt1 = TextGadget(#PB_Any, -1,-1, 35, 25, nbjs , #PB_Text_VerticalCenter | #PB_Text_Center) ;Str(tableur(i,j))
          txt2 = TextGadget(#PB_Any, 15,23, 35, 25, "a"+Str(tableur(i,j)) , #PB_Text_VerticalCenter | #PB_Text_Center)        
          pp=pp+1
        EndIf    
      EndIf
      CloseGadgetList()
    Next
  Next
  CloseGadgetList()
  BindGadgetEvent(scrollgad3, @Handler())
  CloseGadgetList()
EndIf