Module cSigCJShortcutBar.pkg
1//==============================================================================
2// Project : SigCj - VDF Classes for Codejock
3// File : cSigCJShortcutBar.pkg
4// Description : VDF Class for Codejock control
5//
6// Revision : $Rev: 624 $
7// $Date: 2010-02-26 15:56:09 -0500 (Fri, 26 Feb 2010) $
8// $Author: martin $ Martin Pincott
9//
10// Requirements : Visual DataFlex 12.1+
11// Codejock SuitePro - Version 12.0.0+
12//
13// Copyright : (c) 2008 VDF SIG UK
14// Visual DataFlex Special Interest Group UK.
15// http://www.vdfsig.co.uk/
16// dev@vdfsig.co.uk
17//
18// This file is part of SigCj.
19//
20// SigCj is free software: you can redistribute it and/or modify
21// it under the terms of the GNU Lesser General Public License
22// as published by the Free Software Foundation, either version
23// 2.1 of the License, or (at your option) any later version.
24//
25// SigCj is distributed in the hope that it will be useful, but
26// WITHOUT ANY WARRANTY; without even the implied warranty of
27// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28// GNU Lesser General Public License for more details.
29//
30// If you have the complete SigCj workspace then a copy of the
31// GNU Lesser General Public License is in the Docs folder. If
32// not, see <http://www.gnu.org/licenses/>.
33//
34//==============================================================================
35
36Use SigCjW_ShortcutBar.pkg
37Use SigCjW_Controls.pkg //this should be cSigCjpUSH...
38Use cSigCJMethods_Mixin.pkg
39
40Handle ghoSigCj_ShortcutBar
41
42Enum_List
43 Define eSCB_Button_Up for 1
44 Define eSCB_Button_Down for 2
45End_Enum_List
46
47Define eSCB_Item_Offset for 42 //50
48
49Struct tdBarId
50 Integer iID
51 Handle hoBar
52 Variant vSC_Bar
53End_Struct
54
55//=============================================================================
56
57Class cSigCjShortcutBar_Item_Button is a cSigCjComPushButton //SHOULD BE THE sigcj control
58
59 Procedure Construct_Object
60 Forward Send Construct_Object
61
62 Property Handle phMsg
63 Property Handle phObj
64
65 Set peAnchors to anLeftRight
66 End_Procedure
67
68 //-------------------------------------------------------------------------
69
70 Procedure OnCreate
71 Forward Send OnCreate
72 Set size to 40 88
73 Set ComFlatStyle to True
74 Set ComMultiLine to True
75 Set ComTextImageRelation to OLExtpImageAboveText
76 End_Procedure
77
78 //-------------------------------------------------------------------------
79
80 Procedure OnComClick
81 Handle hMsg hObj
82
83 Get phMsg to hMsg
84 Get phObj to hObj
85
86 Send hMsg of hObj
87 End_Procedure
88
89End_Class
90
91//=============================================================================
92
93Class cSigCjShortcutBar_Scroll_Button is a Button
94
95 Procedure Construct_Object
96 Forward Send Construct_Object
97
98 Property Integer piDirection
99
100 Set Size to 10 10
101 Send Page_Object True
102 Set Visible_State to False
103 Set Enabled_State to False
104 End_Procedure
105
106 //-------------------------------------------------------------------------
107
108 Procedure OnClick
109 Integer iDirection
110
111 Get piDirection to iDirection
112 If (iDirection = eSCB_Button_Up) Send Scroll_Up //Understood by parent
113 If (iDirection = eSCB_Button_Down) Send Scroll_Down //Understood by parent
114 End_Procedure
115
116End_Class
117
118//=============================================================================
119
120Class cSigCJ_ShortcutBar_Client is a Container3d
121
122 Procedure Construct_Object
123 Forward Send Construct_Object
124
125 Property Integer piNextLocation 5 //Location (height) of next item
126 Property Handle phoButtonUp //Scroll Up button object
127 Property Handle phoButtonDown //Scroll Down button object
128 Property Integer piTopItem 1 //Number of item at top of client area
129 Property Handle[] phoItems
130
131 Set Visible_State to False
132 Set Color to clWhite
133 Set Border_Style to Border_None
134 End_Procedure
135
136 //-------------------------------------------------------------------------
137
138 Procedure Show_Button Integer iButton Boolean bVisible
139 Handle hoButton
140
141 If (iButton = eSCB_Button_Up) Get phoButtonUp to hoButton
142 If (iButton = eSCB_Button_Down) Get phoButtonDown to hoButton
143 If (hoButton <> 0) Begin
144 Set Visible_State of hoButton to bVisible
145 Set Enabled_State of hoButton to bVisible
146 End
147 End_Procedure
148
149 //-------------------------------------------------------------------------
150
151 Procedure Scroll_Up
152 Integer iTopItem iItem iMax iXY iHeight
153 Handle[] hoItems
154
155 //Move items
156 Get phoItems to hoItems
157 Move (SizeOfArray(hoItems)) to iMax
158 While (iItem < iMax)
159
160 Get Location of hoItems[iItem] to iXY
161 Set Location of hoItems[iItem] to (hi(iXY) + eSCB_Item_Offset) (Low(iXY))
162 Increment iItem
163 Loop
164
165 //Sortout Up button
166 Get piTopItem to iTopItem
167 Set piTopItem to (iTopItem - 1)
168 If (iTopItem = 2) Send Show_Button eSCB_Button_Up False
169
170 //Sortout Down button
171 Get ComClientHeight to iHeight
172 Get Location of hoItems[(iMax -1)] to iXY
173 Send Show_Button eSCB_Button_Down ((hi(iXY) + eSCB_Item_Offset) > iHeight)
174 End_Procedure
175
176 //-------------------------------------------------------------------------
177
178 Procedure Scroll_Down
179 Integer iTopItem iItem iXY iHeight
180 Handle[] hoItems
181
182 //Move items
183 Get phoItems to hoItems
184 Move (SizeOfArray(hoItems)) to iItem
185 While (iItem > 0)
186 Decrement iItem
187
188 Get Location of hoItems[iItem] to iXY
189 Set Location of hoItems[iItem] to (hi(iXY) - eSCB_Item_Offset) (Low(iXY))
190 Loop
191
192 //Sortout Up button
193 Get piTopItem to iTopItem
194 Set piTopItem to (iTopItem + 1)
195 If (iTopItem = 1) Send Show_Button eSCB_Button_Up True
196
197 //Sortout Down button
198 Get ComClientHeight to iHeight
199 Move (SizeOfArray(hoItems)-1) to iItem
200 Get Location of hoItems[iItem] to iXY
201 Send Show_Button eSCB_Button_Down ((hi(iXY) + eSCB_Item_Offset) > iHeight)
202 End_Procedure
203
204 //-------------------------------------------------------------------------
205
206 Procedure Add_Scroll_Buttons
207 Handle hoButton
208 Integer iWidth iHeight
209
210 Get ComClientWidth to iWidth
211 Get ComClientHeight to iHeight
212
213 //---------------------------------------------------------------------
214 //Up Button
215 Get Create U_cSigCjShortcutBar_Scroll_Button to hoButton
216 Set piDirection of hoButton to eSCB_Button_Up
217 Set phoButtonUp to hoButton
218 Set Bitmap of hoButton to "Scroll_Up.bmp"
219 Set Border_Style to Border_None
220
221 //---------------------------------------------------------------------
222 //Down Button
223 Get Create U_cSigCjShortcutBar_Scroll_Button to hoButton
224 Set piDirection of hoButton to eSCB_Button_Down
225 Set phoButtonDown to hoButton
226 Set Bitmap of hoButton to "Scroll_Down.bmp"
227 Set Border_Style to Border_None
228 End_Procedure
229
230 //-------------------------------------------------------------------------
231
232 Procedure Add_Item String sText Variant vImage String sMsg String sObj
233 Handle hoItem
234 Integer iLocation iItemCount iWork
235 Handle[] hoItems
236
237 Get piNextLocation to iLocation
238
239 Get Create U_cSigCjShortcutBar_Item_Button to hoItem
240 Send CreateComObject of hoItem
241
242 Set Location of hoItem to iLocation 2
243 Set ComCaption of hoItem to sText
244 Set phMsg of hoItem to sMsg
245 Set phObj of hoItem to sObj
246
247 If (not(IsNullComObject(vImage))) Set ComIcon of hoItem to vImage
248 Send Page_Object of hoItem True
249
250 Set piNextLocation to (iLocation + eSCB_Item_Offset)
251 Get phoItems to hoItems
252 Move (SizeOfArray(hoItems)) to iItemCount
253 Move hoItem to hoItems[iItemCount]
254 Set phoItems to hoItems
255
256 End_Procedure
257
258 //-------------------------------------------------------------------------
259
260 Procedure Position_Buttons
261 Handle hoButton
262 Integer iWidth iHeight iTopItem iItemCount
263 Handle[] hoItems
264
265 Get ComClientWidth to iWidth
266 Get ComClientHeight to iHeight
267
268 Get piTopItem to iTopItem
269 Get phoItems to hoItems
270
271 //---------------------------------------------------------------------
272 //Up Button
273 Get phoButtonUp to hoButton
274 If (hoButton > 0) Begin
275 Set Location of hoButton to 1 (iWidth - 11)
276 Send Show_Button eSCB_Button_Up (iTopItem > 1)
277 End
278
279 //---------------------------------------------------------------------
280 //Down Button
281 Get phoButtonDown to hoButton
282 If (hoButton > 0) Begin
283 Set Location of hoButton to (iHeight - 11) (iWidth - 11)
284 Send Show_Button eSCB_Button_Down (SizeOfArray(hoItems) > (iHeight / (eSCB_Item_Offset + 5) ))
285 End
286 End_Procedure
287
288 //-------------------------------------------------------------------------
289
290 Procedure Color_Bar Integer iColor
291 Integer iItem iMax
292 Handle[] hoItems
293
294 //Move items
295 Get phoItems to hoItems
296 Move (SizeOfArray(hoItems)) to iMax
297 While (iItem < iMax)
298 Set ComBackColor of hoItems[iItem] to iColor
299 Increment iItem
300 Loop
301
302 Set Color to iColor
303 End_Procedure
304
305 //-------------------------------------------------------------------------
306
307End_Class
308
309//==============================================================================
310
311Class cSigCjShortCutBar is a cSigCjComShortcutBar
312
313 Procedure Construct_Object
314 Forward Send Construct_Object
315
316 Property tdBarId[] ptBarIDs
317 Property Handle phoSC_Bar (Create(Self, U_cSigCjComShortcutBarItem))
318
319 Move Self to ghoSigCj_ShortcutBar
320 End_Procedure
321
322 //-------------------------------------------------------------------------
323
324 Procedure OnCreate
325 Handle hoImages
326 Variant vImages
327 Integer iMsg iLoop iMax
328 String sMsg
329 tdBarId[] tBarIDs
330
331 Forward Send OnCreate
332
333 //Link to global settings image manager
334 Get ComIcons of ghoSigCjGlobalSetting to vImages
335 Set ComIcons to vImages
336
337 Set ComExpandedLinesCount to 3
338
339 // Call setup method
340 Send Setup_ShortcutBar
341
342 //Now add the scroll buttons. They are Added after the Item Buttons so
343 //that they appear on top of thge Item Buttons.
344 Get ptBarIDs to tBarIDs
345 Move (SizeOfArray(tBarIDs)-1) to iMax
346 For iLoop from 0 to iMax
347 Send Add_Scroll_Buttons of tBarIDs[iLoop].hoBar
348 Loop
349 End_Procedure
350
351 //Dummy Hook
352 Procedure Setup_ShortcutBar
353 End_Procedure
354
355 //-------------------------------------------------------------------------
356
357 Procedure Show_Bar Integer iBar
358 Handle hoSC_Bar
359 tdBarId[] tBarIDs
360
361 Get ptBarIDs to tBarIDs
362 Set ComSelected to tBarIDs[(iBar-1)].vSC_Bar
363 End_Procedure
364
365 //-------------------------------------------------------------------------
366
367 Function Find_Bar Integer iID Returns Handle
368 Handle hoBar
369 Integer iLoop iMax
370 tdBarId[] tBarIDs
371
372 Move 0 to hoBar
373 Get ptBarIDs to tBarIDs
374 Move (SizeOfArray(tBarIDs)-1) to iMax
375
376 For iLoop from 0 to iMax
377 If (tBarIDs[iLoop].iID = iID) Begin
378 Move tBarIDs[iLoop].hoBar to hoBar
379 Move iMax to iLoop //bomb the loop as we have found it!
380 End
381 Loop
382
383 Function_Return hoBar
384 End_Function
385
386 //-------------------------------------------------------------------------
387
388 Procedure Add_Bar Integer iID String sText String sImage
389 Handle hWnd hoBar_Client hoSC_Bar
390 Integer iImage iSize
391 Variant vSC_Bar
392 tdBarId[] tBarIDs
393
394 Get Create U_cSigCJ_ShortcutBar_Client to hoBar_Client
395 Send Page_Object of hoBar_Client True
396
397 Get Window_Handle of hoBar_Client to hWnd
398 Get ComAddItem iID sText hWnd to vSC_Bar
399 Get phoSC_Bar to hoSC_Bar
400 Set pvComObject of hoSC_Bar to vSC_Bar
401
402 Get AddImage of ghoSigCjGlobalSetting sImage 0 OLExtpImageNormal to iImage
403 Set ComIconId of hoSC_Bar to iImage
404
405 //Register bar (id / handle)
406 Get ptBarIDs to tBarIDs
407 Move (SizeOfArray(tBarIDs)) to iSize
408 Move iID to tBarIDs[iSize].iID
409 Move hoBar_Client to tBarIDs[iSize].hoBar
410 Move vSC_Bar to tBarIDs[iSize].vSC_Bar
411 Set ptBarIDs to tBarIDs
412 End_Procedure
413
414 //-------------------------------------------------------------------------
415
416 Procedure Add_Item Integer iBar String sText String sImage String sMsg String sObj
417 Handle hoBar
418 Integer iImage
419 Variant vImage
420
421 Get Find_Bar iBar to hoBar
422 If (hoBar = 0) Begin
423 Error 5001 "Application Error - Invalid Shortcut Bar ID"
424 Abort
425 End
426 Else Begin
427 Get AddImage of ghoSigCjGlobalSetting sImage 0 OLExtpImageNormal to iImage
428 Get ImageFromId of ghoSigCjGlobalSetting iImage to vImage
429 Send Add_Item of hoBar sText vImage sMsg sObj
430 End
431 End_Procedure
432
433 //-------------------------------------------------------------------------
434
435 Procedure OnComClientSizeChanged
436 Integer iLoop iMax
437 tdBarId[] tBarIDs
438
439 Get ptBarIDs to tBarIDs
440 Move (SizeOfArray(tBarIDs)-1) to iMax
441 For iLoop from 0 to iMax
442 Send Position_Buttons of tBarIDs[iLoop].hoBar
443 Loop
444 End_Procedure
445
446End_Class
447
448//==============================================================================
449//End of Package - cSigCJShortcutBar.pkg
450//==============================================================================
451