1: #include "protheus.ch"
2: #include "dbtree.ch"
3:
4: #xtranslate USER PROCEDURE <p> => PROCEDURE U_<p>
5:
6: #xcommand DEFINE TExTree [<oTree>];
7: [ FROM <nTop>, <nLeft> TO <nBottom>, <nRight> ] ;
8: [ <dlg:OF,DIALOG> <oWnd> ] ;
9: [ ON CHANGE <uChange> ] ;
10: [ ON RIGHT CLICK <uRClick> ] ;
11: [ <lCargo: CARGO> ] ;
12: [ <lDisable: DISABLE> ] ;
13: => ;
14: <oTree> := TExTree():New(<nTop>,<nLeft>,<nBottom>,<nRight>,<oWnd>,<{uChange}>,<{uRClick}>,<.lCargo.>,<.lDisable.>)
15:
16: USER PROCEDURE MyTree()
17:
18: Local oDlg
19: Local oTExdbTree
20:
21: PUBLIC __TTSINUSE := .T. //(Para uso no IDE RecLock precisa disso)
22: PUBLIC __TTSPUSH := Array(0) //(Para uso no IDE RecLock precisa disso)
23: PUBLIC __cLogSiga := "" //(Para uso no IDE GravaLog em RecLock precisa disso)
24:
25: // Cria um diálogo
26: DEFINE DIALOG oDlg TITLE "Teste de DBTree" FROM 10,10 TO 400,700 COLOR CLR_BLACK,CLR_WHITE PIXEL
27:
28: // Cria o DbTree no diálogo, ocupando o tamanho total do mesmo
29: DEFINE TExTree oTExdbTree FROM 00,00 TO oDlg:nHeight,oDlg:nWidth OF oDlg CARGO
30:
31: DBADDTREE oTExdbTree PROMPT "Menu 001" RESOURCE "BMPTABLE" CARGO "#0001"
32: DBADDITEM oTExdbTree PROMPT "Item 001" RESOURCE "BMPSXG" CARGO "#0002"
33: DBENDTREE oTExdbTree
34:
35: DBADDITEM oTExdbTree PROMPT "Item 002" RESOURCE "BMPTRG" CARGO "#0003"
36: DBADDITEM oTExdbTree PROMPT "Item 003" RESOURCE "BMPCONS" CARGO "#0004"
37: DBADDITEM oTExdbTree PROMPT "Item 004" RESOURCE "BMPPARAM" CARGO "#0005"
38: DBADDTREE oTExdbTree PROMPT "Menu 002" OPENED RESOURCE "BMPTABLE" CARGO "#0006"
39: DBADDITEM oTExdbTree PROMPT "Item 005" RESOURCE "BMPSXG" CARGO "#0007"
40: DBADDTREE oTExdbTree PROMPT "Menu 003" OPENED RESOURCE "BMPTABLE" CARGO "#0008"
41: DBADDITEM oTExdbTree PROMPT "Item 006" RESOURCE "BMPSXG" CARGO "#0009"
42: DBADDTREE oTExdbTree PROMPT "Menu 004" OPENED RESOURCE "BMPTABLE" CARGO "#0010"
43: DBADDITEM oTExdbTree PROMPT "Item 007" RESOURCE "BMPSXG" CARGO "#0011"
44: DBENDTREE oTExdbTree
45: DBADDITEM oTExdbTree PROMPT "Item 008" RESOURCE "BMPSXG" CARGO "#0012"
46: DBENDTREE oTExdbTree
47: DBENDTREE oTExdbTree
48: DBADDITEM oTExdbTree PROMPT "Item 009" RESOURCE "BMPSXB" CARGO "#0013"
49:
50: oTExdbTree:odbTree:bRClicked := { || oTExdbTree:DelItem() }
51:
52: ACTIVATE DIALOG oDlg CENTER ON INIT ShowNodeTree(@oTExdbTree)
53:
54: Return
55:
56: Static Function ShowNodeTree(oTExdbTree)
57:
58: Local cCargo
59:
60: IF TreeSeek( @oTExdbTree , "#0013" , "T_CARGO" , @cCargo )
61: MsgInfo( "Seek: " + cCargo + CRLF + "GetCargo: " + oTExdbTree:GetCargo() )
62: EndIF
63:
64: Return( TreeSeek( @oTExdbTree , "#0013" , "T_CARGO" , @cCargo ) )
65:
66: Static Function TreeSeek( odbTree , cKeySeek , cIndexKey , cCargo )
67:
68: Local aIndexes := Array(0)
69:
70: Local cAliasTree := odbTree:cArqTree
71: Local cKey := ""
72:
73: Local lFound := .F.
74:
75: Local nOrder
76:
77: (cAliasTree)->(aEval(Array(10),{|x,y|cKey:=IndexKey(y),IF(!Empty(cKey),aAdd(aIndexes,{y,cKey}),NIL)}))
78:
79: DEFAULT cIndexKey := "T_CARGO"
80: cIndexKey := Upper( AllTrim( cIndexKey ) )
81:
82: nOrder := aScan( aIndexes , { |aBag| aBag[2] == cIndexKey } )
83: IF ( nOrder == 0 )
84: cIndexKey := "T_CARGO"
85: nOrder := aScan( aIndexes , { |aBag| aBag[2] == cIndexKey } )
86: EndIF
87:
88: (cAliasTree)->( dbSetOrder( aIndexes[nOrder][1] ) )
89: lFound := ( cAliasTree )->( dbSeek( cKeySeek , .F. ) )
90:
91: IF ( lFound )
92: lFound := odbTree:TreeSeek( ( cAliasTree )->T_CARGO )
93: IF ( lFound )
94: cCargo := odbTree:GetCargo(( cAliasTree )->T_IDCODE)
95: EndIF
96: EndIF
97:
98: Return( lFound )
99:
100: /***************************************************************
101: ****************************************************************
102: Classe TExTree
103: Arvore Estendida para tratar o avanço entre os nós filhos e
104: relacionar um nó filho com o nó pai
105: Criada por: Renato de Bianchi feat. Marinaldo de Jesus
106: Em: 25/04/2012
107: ****************************************************************
108: ***************************************************************/
109: user function TExTree
110: return
111:
112: Class TExTree from DbTree
113:
114: DATA oDbTree
115:
116: //DBTREE
117: DATA ABMPS
118: DATA ACORNER
119: DATA ANODES
120: DATA ANODESTOSEND
121: DATA AONPAGE
122: DATA ARECT
123: DATA ATREESOPEN
124: DATA BINIT
125: DATA CARQTREE
126: DATA CSTRPAINT
127: DATA CTREEATU
128: DATA LACTIVATED
129: DATA LCARGO
130: DATA LDISABLEPAINT
131: DATA LENABLE
132: DATA LERASE
133: DATA LFIRST
134: DATA LLOSTFOCUS
135: DATA LPAINTING
136: DATA LPROCESS
137: DATA LREFRESHING
138: DATA LVALIDLOST
139: DATA NCODEATU
140: DATA NCOLPAINT
141: DATA NFOCUS
142: DATA NLASTFOCUS
143: DATA NLASTINC
144: DATA NLEN
145: DATA NLINESPAGE
146: DATA NMAXCOLS
147: DATA NOPENED
148: DATA NTOTAL
149:
150: //TTREE
151: DATA BVALIDNODES
152: DATA CURRENTNODEID
153:
154: //TCONTROL
155: DATA ALIGN
156: DATA BCHANGE
157: DATA BEND
158: DATA BSETGET
159: DATA CDEFAULTACT
160: DATA CSX1HLP
161: DATA CVARIABLE
162: DATA HPARENT
163: DATA L3DLOOK
164: DATA LFOCUSONFIRST
165: DATA LMODIFIED
166: DATA LOUTGET
167: DATA LREADONLY
168: DATA LVISIBLECONTROL
169: DATA OJUMP
170:
171: //TSRVOBJECT
172: DATA ACONTROLS
173: DATA BGOTFOCUS
174: DATA BHELP
175: DATA BKEYDOWN
176: DATA BLBUTTONUP
177: DATA BLCLICKED
178: DATA BLDBLCLICK
179: DATA BLOSTFOCUS
180: DATA BMOVED
181: DATA BPAINTED
182: DATA BRABSCLICKED
183: DATA BRCLICKED
184: DATA BRESIZED
185: DATA BVALID
186: DATA BWHEN
187: DATA CARGO
188: DATA CCAPTION
189: DATA CMSG
190: DATA CNAME
191: DATA CREADVAR
192: DATA CTITLE
193: DATA CTOOLTIP
194: DATA HWND
195: DATA LACTIVE
196: DATA LCANGOTFOCUS
197: DATA LSHOWHINT
198: DATA LVALIDATING
199: DATA LVISIBLE
200: DATA NBOTTOM
201: DATA NCLIENTHEIGHT
202: DATA NCLIENTWIDTH
203: DATA NCLRPANE
204: DATA NCLRTEXT
205: DATA NHEIGHT
206: DATA NLASTKEY
207: DATA NLEFT
208: DATA NRIGHT
209: DATA NSTYLE
210: DATA NTOP
211: DATA NWIDTH
212: DATA OCURSOR
213: DATA OFONT
214: DATA OPARENT
215: DATA OWND
216: DATA TAGGROUP
217:
218: method TExTreeUpd()
219:
220: //Metodos sobrescritos
221: method ADDITEM(CPROMPT,CCARGO,CRES1,CRES2,CFILE1,CFILE2,NTIPO)
222: method ADDTREE(CPROMPT,LOPENED,CRES1,CRES2,CFILE1,CFILE2,CCARGO)
223: method ADDTREEITEM(CPROMPT,CRES1,CFILE1,CCARGO)
224: method BUILDTRB(NLENTXT,NLENCARGO)
225: method CHANGEBMP(CRES1,CRES2,CFILE1,CFILE2,CCARGO)
226: method CHANGEPROMPT(CNEWPROMPT,CCARGO)
227: method DEFAULT()
228: method DELETEALL(CPAI)
229: method DELITEM()
230: method DISPLAY()
231: method ENDTREE()
232: method FINDLASTSUN(NRECNO,NMAX)
233: method GETCARGO(CKEY)
234: method GETPROMPT(LCOMESPACO)
235: method ISEMPTY()
236: method NEW(NTOP,NLEFT,NBOTTOM,NRIGHT,OWND,UCHANGE,URCLICK,LCARGO,LDISABLE,OFONT)
237: method NIVEL()
238: method PTEND()
239: method PTREFRESH()
240: method PTSRVUPDATEPOSITION()
241: method PTUPDATENODES(CLEVEL)
242: method PTVALID(CNODEATU_ID,CNODEGO_ID)
243: method RESET()
244: method SETDISABLE()
245: method SETENABLE()
246: method TOTAL()
247: method TREESEEK(CCHAVE)
248:
249: endClass
250:
251: method ADDITEM(CPROMPT,CCARGO,CRES1,CRES2,CFILE1,CFILE2,NTIPO) class TExTree
252: Local uRet := Self:odbTree:AddItem(CPROMPT,CCARGO,CRES1,CRES2,CFILE1,CFILE2,NTIPO)
253: ::TExTreeUpd()
254: return(uRet)
255:
256: method ADDTREE(CPROMPT,LOPENED,CRES1,CRES2,CFILE1,CFILE2,CCARGO) class TExTree
257: Local uRet := Self:odbTree:AddTree(CPROMPT,LOPENED,CRES1,CRES2,CFILE1,CFILE2,CCARGO)
258: ::TExTreeUpd()
259: return(uRet)
260: method ADDTREEITEM(CPROMPT,CRES1,CFILE1,CCARGO) class TExTree
261: Local uRet := Self:odbTree:AddTreeItem(CPROMPT,CRES1,CFILE1,CCARGO)
262: ::TExTreeUpd()
263: return(uRet)
264:
265: method BUILDTRB(NLENTXT,NLENCARGO) class TExTree
266: Local uRet := Self:odbTree:BUILDTRB(NLENTXT,NLENCARGO)
267: ::TExTreeUpd()
268: return(uRet)
269:
270: method CHANGEBMP(CRES1,CRES2,CFILE1,CFILE2,CCARGO) class TExTree
271: Local uRet := Self:odbTree:CHANGEBMP(CRES1,CRES2,CFILE1,CFILE2,CCARGO)
272: ::TExTreeUpd()
273: return(uRet)
274:
275: method CHANGEPROMPT(CNEWPROMPT,CCARGO) class TExTree
276: Local uRet := Self:odbTree:CHANGEPROMPT(CNEWPROMPT,CCARGO)
277: ::TExTreeUpd()
278: return(uRet)
279:
280: method DEFAULT() class TExTree
281: Local uRet := Self:odbTree:DEFAULT()
282: ::TExTreeUpd()
283: return(uRet)
284:
285: method DELETEALL(CPAI) class TExTree
286: Local uRet := Self:odbTree:DELETEALL(CPAI)
287: ::TExTreeUpd()
288: return(uRet)
289:
290: method DELITEM() class TExTree
291: Local uRet := Self:odbTree:DelItem()
292: ::TExTreeUpd()
293: return(uRet)
294:
295: method DISPLAY() class TExTree
296: Local uRet := Self:odbTree:DISPLAY()
297: ::TExTreeUpd()
298: return(uRet)
299:
300: method ENDTREE() class TExTree
301: Local uRet := Self:odbTree:ENDTREE()
302: ::TExTreeUpd()
303: return(uRet)
304:
305: method FINDLASTSUN(NRECNO,NMAX) class TExTree
306: Local uRet := Self:odbTree:FINDLASTSUN(NRECNO,NMAX)
307: ::TExTreeUpd()
308: return(uRet)
309:
310: method GETCARGO(CKEY) class TExTree
311: Local uRet := Self:odbTree:GETCARGO(CKEY)
312: ::TExTreeUpd()
313: return(uRet)
314:
315: method GETPROMPT(LCOMESPACO) class TExTree
316: Local uRet := Self:odbTree:GETPROMPT(LCOMESPACO)
317: ::TExTreeUpd()
318: return(uRet)
319:
320: method ISEMPTY() class TExTree
321: Local uRet := Self:odbTree:ISEMPTY()
322: ::TExTreeUpd()
323: return(uRet)
324:
325: method NEW(NTOP,NLEFT,NBOTTOM,NRIGHT,OWND,UCHANGE,URCLICK,LCARGO,LDISABLE,OFONT) class TExTree
326: DEFINE DBTREE ::oDbTree FROM nTop,nLeft TO nRight,nBottom OF oWnd CARGO
327: Self := ::TExTreeUpd()
328: return(Self)
329:
330: method NIVEL() class TExTree
331: Local uRet := Self:odbTree:NIVEL()
332: ::TExTreeUpd()
333: return(uRet)
334:
335: method PTEND() class TExTree
336: Local uRet := Self:odbTree:PTEND()
337: ::TExTreeUpd()
338: return(uRet)
339:
340: method PTREFRESH() class TExTree
341: Local uRet := Self:odbTree:PTREFRESH()
342: ::TExTreeUpd()
343: return(uRet)
344:
345: method PTSRVUPDATEPOSITION() class TExTree
346: Local uRet := Self:odbTree:PTSRVUPDATEPOSITION()
347: ::TExTreeUpd()
348: return(uRet)
349:
350: method PTUPDATENODES(CLEVEL) class TExTree
351: Local uRet := Self:odbTree:PTUPDATENODES(CLEVEL)
352: ::TExTreeUpd()
353: return(uRet)
354:
355: method PTVALID(CNODEATU_ID,CNODEGO_ID) class TExTree
356: Local uRet := Self:odbTree:PTVALID(CNODEATU_ID,CNODEGO_ID)
357: ::TExTreeUpd()
358: return(uRet)
359:
360: method RESET() class TExTree
361: Local uRet := Self:odbTree:RESET()
362: ::TExTreeUpd()
363: return(uRet)
364:
365: method SETDISABLE() class TExTree
366: Local uRet := Self:odbTree:SETDISABLE()
367: ::TExTreeUpd()
368: return(uRet)
369:
370: method SETENABLE() class TExTree
371: Local uRet := Self:odbTree:SETENABLE()
372: ::TExTreeUpd()
373: return(uRet)
374:
375: method TOTAL() class TExTree
376:
377: Local uRet := Self:odbTree:TOTAL()
378: ::TExTreeUpd()
379: return(uRet)
380:
381: method TREESEEK(CCHAVE) class TExTree
382: Local uRet := Self:odbTree:TreeSeek(cChave)
383: ::TExTreeUpd()
384: Return(uRet)
385:
386: method TExTreeUpd() class TExTree
387: //DBTREE
388: Self:ABMPS := Self:oDbTree:ABMPS
389: Self:ACORNER := Self:oDbTree:ACORNER
390: Self:ANODES := Self:oDbTree:ANODES
391: Self:ANODESTOSEND := Self:oDbTree:ANODESTOSEND
392: Self:AONPAGE := Self:oDbTree:AONPAGE
393: Self:ARECT := Self:oDbTree:ARECT
394: Self:ATREESOPEN := Self:oDbTree:ATREESOPEN
395: Self:BINIT := Self:oDbTree:BINIT
396: Self:CARQTREE := Self:oDbTree:CARQTREE
397: Self:CSTRPAINT := Self:oDbTree:CSTRPAINT
398: Self:CTREEATU := Self:oDbTree:CTREEATU
399: Self:LACTIVATED := Self:oDbTree:LACTIVATED
400: Self:LCARGO := Self:oDbTree:LCARGO
401: Self:LDISABLEPAINT := Self:oDbTree:LDISABLEPAINT
402: Self:LENABLE := Self:oDbTree:LENABLE
403: Self:LERASE := Self:oDbTree:LERASE
404: Self:LFIRST := Self:oDbTree:LFIRST
405: Self:LLOSTFOCUS := Self:oDbTree:LLOSTFOCUS
406: Self:LPAINTING := Self:oDbTree:LPAINTING
407: Self:LPROCESS := Self:oDbTree:LPROCESS
408: Self:LREFRESHING := Self:oDbTree:LREFRESHING
409: Self:LVALIDLOST := Self:oDbTree:LVALIDLOST
410: Self:NCODEATU := Self:oDbTree:NCODEATU
411: Self:NCOLPAINT := Self:oDbTree:NCOLPAINT
412: Self:NFOCUS := Self:oDbTree:NFOCUS
413: Self:NLASTFOCUS := Self:oDbTree:NLASTFOCUS
414: Self:NLASTINC := Self:oDbTree:NLASTINC
415: Self:NLEN := Self:oDbTree:NLEN
416: Self:NLINESPAGE := Self:oDbTree:NLINESPAGE
417: Self:NMAXCOLS := Self:oDbTree:NMAXCOLS
418: Self:NOPENED := Self:oDbTree:NOPENED
419: Self:NTOTAL := Self:oDbTree:NTOTAL
420:
421: //TTREE
422: Self:BVALIDNODES := Self:oDbTree:BVALIDNODES
423: Self:CURRENTNODEID := Self:oDbTree:CURRENTNODEID
424:
425: //TCONTROL
426: Self:ALIGN := Self:oDbTree:ALIGN
427: Self:BCHANGE := Self:oDbTree:BCHANGE
428: Self:BEND := Self:oDbTree:BEND
429: Self:BSETGET := Self:oDbTree:BSETGET
430: Self:CDEFAULTACT := Self:oDbTree:CDEFAULTACT
431: Self:CSX1HLP := Self:oDbTree:CSX1HLP
432: Self:CVARIABLE := Self:oDbTree:CVARIABLE
433: Self:HPARENT := Self:oDbTree:HPARENT
434: Self:L3DLOOK := Self:oDbTree:L3DLOOK
435: Self:LFOCUSONFIRST := Self:oDbTree:LFOCUSONFIRST
436: Self:LMODIFIED := Self:oDbTree:LMODIFIED
437: Self:LOUTGET := Self:oDbTree:LOUTGET
438: Self:LREADONLY := Self:oDbTree:LREADONLY
439: Self:LVISIBLECONTROL := Self:oDbTree:LVISIBLECONTROL
440: Self:OJUMP := Self:oDbTree:OJUMP
441:
442: //TSRVOBJECT
443: Self:ACONTROLS := Self:oDbTree:ACONTROLS
444: Self:BGOTFOCUS := Self:oDbTree:BGOTFOCUS
445: Self:BHELP := Self:oDbTree:BHELP
446: Self:BKEYDOWN := Self:oDbTree:BKEYDOWN
447: Self:BLBUTTONUP := Self:oDbTree:BLBUTTONUP
448: Self:BLCLICKED := Self:oDbTree:BLCLICKED
449: Self:BLDBLCLICK := Self:oDbTree:BLDBLCLICK
450: Self:BLOSTFOCUS := Self:oDbTree:BLOSTFOCUS
451: Self:BMOVED := Self:oDbTree:BMOVED
452: Self:BPAINTED := Self:oDbTree:BPAINTED
453: Self:BRABSCLICKED := Self:oDbTree:BRABSCLICKED
454: Self:BRCLICKED := Self:oDbTree:BRCLICKED
455: Self:BRESIZED := Self:oDbTree:BRESIZED
456: Self:BVALID := Self:oDbTree:BVALID
457: Self:BWHEN := Self:oDbTree:BWHEN
458: Self:CARGO := Self:oDbTree:CARGO
459: Self:CCAPTION := Self:oDbTree:CCAPTION
460: Self:CMSG := Self:oDbTree:CMSG
461: Self:CNAME := Self:oDbTree:CNAME
462: Self:CREADVAR := Self:oDbTree:CREADVAR
463: Self:CTITLE := Self:oDbTree:CTITLE
464: Self:CTOOLTIP := Self:oDbTree:CTOOLTIP
465: Self:HWND := Self:oDbTree:HWND
466: Self:LACTIVE := Self:oDbTree:LACTIVE
467: Self:LCANGOTFOCUS := Self:oDbTree:LCANGOTFOCUS
468: Self:LSHOWHINT := Self:oDbTree:LSHOWHINT
469: Self:LVALIDATING := Self:oDbTree:LVALIDATING
470: Self:LVISIBLE := Self:oDbTree:LVISIBLE
471: Self:NBOTTOM := Self:oDbTree:NBOTTOM
472: Self:NCLIENTHEIGHT := Self:oDbTree:NCLIENTHEIGHT
473: Self:NCLIENTWIDTH := Self:oDbTree:NCLIENTWIDTH
474: Self:NCLRPANE := Self:oDbTree:NCLRPANE
475: Self:NCLRTEXT := Self:oDbTree:NCLRTEXT
476: Self:NHEIGHT := Self:oDbTree:NHEIGHT
477: Self:NLASTKEY := Self:oDbTree:NLASTKEY
478: Self:NLEFT := Self:oDbTree:NLEFT
479: Self:NRIGHT := Self:oDbTree:NRIGHT
480: Self:NSTYLE := Self:oDbTree:NSTYLE
481: Self:NTOP := Self:oDbTree:NTOP
482: Self:NWIDTH := Self:oDbTree:NWIDTH
483: Self:OCURSOR := Self:oDbTree:OCURSOR
484: Self:OFONT := Self:oDbTree:OFONT
485: Self:OPARENT := Self:oDbTree:OPARENT
486: Self:OWND := Self:oDbTree:OWND
487: Self:TAGGROUP := Self:oDbTree:TAGGROUP
488:
489: Return( self )
Comentários
Postar um comentário