1 type evparQueryCreate <inherit=eventpos>
2 {
3 uint Owner
4 uint TypeId
5 uint NewComp
6 }
7
8 type evQueryCreate <inherit=evEvent>
9 {
10 }
11
12
13 method evQueryCreate evQueryCreate.init
14 {
15 this.eventtypeid = evparQueryCreate
16 return this
17 }
18
19
20 type vVEEdit <inherit=vCtrl>
21 {
22 uint winn //Текущий выбранный элемент
23 uint winparent
24 uint VEPanel //Главная панель
25 uint VisPanel
26
27 uint typ
28 uint oper
29
30 //RECT currt
31 //uint mouseleft
32 //uint mousetop
33
34 RECT rectold
35 uint offx, offy
36 uint wdown
37 uint pen, brush, brushgr
38 POINT discr
39 uint flgadd
40
41 /*vPanel panNoVis
42 vPanel panVis*/
43
44 evEvent onSelect
45 evEvent onDelete
46 evEvent onstartchange
47 evQueryCreate onQueryCreate
48
49 }
50
51 type vVEPanel <inherit=vPanel>
52 {
53 vScrollBox VisPanel
54 vListView NoVisList
55 vPanel TopPanel
56 vVEEdit WE
57 uint pSelected
58 uint flgDesChanged
59
60 evEvent onSelect
61 evQueryCreate onQueryCreate
62 evValUint OnDblClick
63 }
64 extern
65 {
66 property vComp vVEPanel.Selected()
67 property vVEPanel.Selected( vComp newcomp )
68 method vVEPanel.DblClick()
69 }
70
71 type vVEFrame <inherit=vCtrl>
72 {
73 uint WE
74 }
75
76 include {
77 "funcs.g"
78 }
79
80 extern
81 {
82 method vVEEdit.releasecapture()
83 }
84
85 define {
86 OPERMOVE = 0x1 //Перемещение
87 OPERSIZE = 0x2 //Изменение размеров
88 OPERNEW = 0x4 //Новый компонент
89 OPERFIRST = 0x10000
90 OPERCHANGE = 0x20000
91
92
93 }
94
95 method RECT.set( int x, y )
96 {
97 this.left = this.right = x
98 this.top = this.bottom = y
99 }
100
101 method RECT.reframe( uint wnd, RECT rnew )
102 {
103 uint hdc
104 subfunc frame ( RECT r )
105 {
106 MoveToEx( hdc, r.left, r.top, 0->POINT )
107 LineTo( hdc, r.right - 1, r.top )
108 LineTo( hdc, r.right - 1, r.bottom - 1 )
109 LineTo( hdc, r.left, r.bottom - 1)
110 LineTo( hdc, r.left, r.top )
111 }
112 hdc = GetDC( 0 )
113 SetROP2( hdc, $R2_NOT )
114 frame( this )
115 frame( rnew )
116 this = rnew
117 ReleaseDC( 0, hdc )
118 }
119
120 method RECT.frame_del( uint wnd )
121 {
122 RECT rectnew
123 rectnew.set( -0, -0 )
124 this.reframe( wnd, rectnew )
125 }
126
127 method RECT.frame_sel( uint wnd, x, y )
128 {
129 RECT rectnew
130
131 rectnew.left = this.left
132 rectnew.top = this.top
133 rectnew.right = x
134 rectnew.bottom = y
135 this.reframe( wnd, rectnew )
136 }
137
138 method RECT.frame_move( uint wnd int x, y )
139 {
140 RECT rectnew
141 rectnew.left = x
142 rectnew.top = y
143 rectnew.right = x + this.right - this.left
144 rectnew.bottom = y + this.bottom - this.top
145 this.reframe( wnd, rectnew )
146 }
147
148 method vVirtCtrl.GetRect( RECT r )
149 {
150 if this.TypeIs( vCtrl )
151 {
152 GetWindowRect( this->vCtrl.hwnd, r )
153 }
154 else
155 {
156 GetWindowRect( this.Owner->vCtrl.hwnd, r )
157 RECT rr
158 this.Owner->vCtrl.WinMsg( $WM_NCCALCSIZE, 0, &rr )
159 r.left += this.Left + rr.left
160 r.top += this.Top + rr.top
161 r.right = r.left + this.Width
162 r.bottom = r.top + this.Height
163 }
164 }
165
166 method vVEEdit.green()
167 {
168 if this.winn
169 {
170 RECT r,a
171
172 //GetWindowRect( this.winn->vCtrl.hwnd, r )
173 this.winn->vVirtCtrl.GetRect( r )
174
175 POINT p
176 p.x = r.left
177 p.y = r.top
178 ScreenToClient( this.hwnd, p)
179 r.left = p.x
180 r.top = p.y
181 p.x = r.right
182 p.y = r.bottom
183 ScreenToClient( this.hwnd, p)
184 r.right = p.x
185 r.bottom = p.y
186 this.wdown->vCtrl.loc.left = r.left - 2
187 this.wdown->vCtrl.loc.top = r.top - 2
188 //print( "SETRGN \n" )
189
190 //this.Owner->vScrollBox.AutoScroll = 0
191 //.VisPanel->vScrollBox.AutoScroll = 0
192 setrgn( this.wdown->vCtrl.hwnd, r )
193 //this.Owner->vScrollBox.AutoScroll = 1
194 //.VisPanel->vScrollBox.AutoScroll = 1
195 }
196 }
197
198 method vVEEdit.refresh()
199 {
200 }
201
202 method vVEEdit.select( vComp w )
203 {
204 //print( "x2 \(&this) \(this.wdown) \( &w )\n" )
205 if this.winn = &w
206 {
207 this.winparent = GetParent( w->vCtrl.hwnd )
208 this.wdown->vCtrl.Visible = 1
209 this.green()
210 SetWindowPos( this.wdown->vCtrl.hwnd, 0, 0, 0, 0, 0, $SWP_NOACTIVATE | $SWP_NOMOVE | $SWP_NOSIZE )
211 }
212 else
213 {
214 // print( "x3 \(&this) \(this.wdown)\n" )
215 this.wdown->vCtrl.Visible = 0
216 }
217 /* print( "select zzz1 \(&w) \(w.p_designing)\n" )
218 if w && this.winn != &w && w.p_designing
219 {
220 if this.winn : this.refresh()
221 this.winn = &w
222 //this.refresh()
223 if w.TypeIs( vCtrl )
224 {
225 this.winparent = GetParent( w->vCtrl.hwnd )
226 this.wdown->vCtrl.Visible = 1
227 this.green()
228 SetWindowPos( this.wdown->vCtrl.hwnd, 0, 0, 0, 0, 0, $SWP_NOACTIVATE | $SWP_NOMOVE | $SWP_NOSIZE )
229
230 //this.wdown->vCtrl.Visible = 1
231 }
232 else
233 {
234 this.wdown->vCtrl.Visible = 0
235 }
236 }
237 this.onSelect.run()
238 */
239 //->func(this.form)
240 //InvalidateRect( this.wdown->vCtrl.hwnd, 0->RECT, 1 )
241 }
242
243 method vVEEdit.nextobj( uint flgreserve )
244 {
245 uint ctrl = this.winn
246 uint level
247 do
248 {
249 if flgreserve
250 {
251 ctrl = this.winn->vForm.form->vForm.PrevCtrl( ctrl, &level, 0 )
252 }
253 else: ctrl = this.winn->vForm.form->vForm.NextCtrl( ctrl, &level, 0)
254 }
255 while !ctrl || !ctrl->vCtrl.p_designing
256 //this.select( ctrl->vCtrl )
257 .VEPanel->vVEPanel.Selected = ctrl->vComp
258 }
259
260 func int align( int val, off, discr )
261 {
262 int tail
263 if tail = val % discr
264 {
265 if tail < 0 : tail = discr + tail
266 if off < 0 || ( !off && tail < discr / 2 )
267 {
268 val -= tail
269 }
270 else
271 {
272 val += discr - tail
273 }
274 }
275 else
276 {
277 val += off * discr
278 }
279 return val
280 }
281
282 method int vVEEdit.alignx( int val, off )
283 {
284 return align( val, off, .discr.x )
285 }
286
287 method int vVEEdit.aligny( int val, off )
288 {
289 return align( val, off, .discr.y )
290 }
291
292
293 //method uint vVEFrame.mKey <alias=vVEFrame_mKey>( eventkey evk )
294 method uint vVEEdit.mKey <alias=vVEEdit_mKey>( evparKey evk )
295 {
296 uint WE as this//.WE->vVEEdit
297 if evk.evktype == $evkDown && WE.winn
298 {
299 if this.oper
300 {
301 if evk.key == $VK_ESCAPE
302 {
303 this.oper = 0
304 //Удаление остаточной рамки
305 //this.framehide()
306 //this.releasecapture()
307 ReleaseCapture()
308 }
309 return 0
310 }
311 switch evk.key
312 {
313 case $VK_TAB
314 {
315 if evk.mstate & $mstCtrl
316 {
317 evk.mstate &= ~$mstCtrl
318 }
319 else
320 {
321 WE.nextobj( evk.mstate & $mstShift )
322 return 0
323 }
324 }
325 case $VK_LEFT//Влево
326 {
327 if evk.mstate & $mstShift
328 {
329 if evk.mstate & $mstAlt : WE.winn->vVirtCtrl.Width = WE.winn->vVirtCtrl.Width - 1
330 else : WE.winn->vVirtCtrl.Width = .alignx( WE.winn->vVirtCtrl.Width, -1 )
331 }
332 else
333 {
334 if evk.mstate & $mstAlt : WE.winn->vVirtCtrl.Left = WE.winn->vVirtCtrl.Left - 1
335 else : WE.winn->vVirtCtrl.Left = .alignx( WE.winn->vVirtCtrl.Left, -1 )
336 }
337 return 0
338 }
339 case $VK_UP//0x26//Вверх
340 {
341 if evk.mstate & $mstShift
342 {
343 if evk.mstate & $mstAlt : WE.winn->vVirtCtrl.Height = WE.winn->vVirtCtrl.Height - 1
344 else : WE.winn->vVirtCtrl.Height = .aligny( WE.winn->vVirtCtrl.Height, -1 )
345 }
346 else
347 {
348 if evk.mstate & $mstAlt : WE.winn->vVirtCtrl.Top = WE.winn->vVirtCtrl.Top - 1
349 else : WE.winn->vVirtCtrl.Top = .aligny( WE.winn->vVirtCtrl.Top, -1 )
350 }
351 return 0
352 }
353 case $VK_RIGHT//0x27//Вправо
354 {
355 if evk.mstate & $mstShift
356 {
357 if evk.mstate & $mstAlt : WE.winn->vVirtCtrl.Width = WE.winn->vVirtCtrl.Width + 1
358 else : WE.winn->vVirtCtrl.Width = .alignx( WE.winn->vVirtCtrl.Width, 1 )
359 }
360 else
361 {
362 if evk.mstate & $mstAlt : WE.winn->vVirtCtrl.Left = WE.winn->vVirtCtrl.Left + 1
363 else : WE.winn->vVirtCtrl.Left = .alignx( WE.winn->vVirtCtrl.Left, 1 )
364 }
365 return 0
366 }
367 case $VK_DOWN//0x28//Вниз
368 {
369 if evk.mstate & $mstShift
370 {
371 if evk.mstate & $mstAlt : WE.winn->vVirtCtrl.Height = WE.winn->vVirtCtrl.Height + 1
372 else : WE.winn->vVirtCtrl.Height = .aligny( WE.winn->vVirtCtrl.Height, 1 )
373 }
374 else
375 {
376 if evk.mstate & $mstAlt : WE.winn->vVirtCtrl.Top = WE.winn->vVirtCtrl.Top + 1
377 else : WE.winn->vVirtCtrl.Top = .aligny( WE.winn->vVirtCtrl.Top, 1 )
378 }
379 return 0
380 }
381 case $VK_DELETE//0x2E//Удаление
382 {
383 if !WE.winn->vVirtCtrl.TypeIs( vForm )
384 {
385 uint owner as WE.winn->vCtrl.Owner
386 uint delobj as WE.winn->vVirtCtrl
387 .VEPanel->vVEPanel.Selected = owner
388 //WE.winn->vCtrl.DestroyComp()
389 delobj.DestroyComp()
390
391
392 /*uint ctrl = WE.winn
393 WE.nextobj( 0 )
394 ctrl->vCtrl.delcomp()//delete()
395 WE.ondelete.run()*/
396 //delcompdes( ctrl->vCtrl )
397 }
398 }
399 }
400 }
401 return 0
402 }
403
404 method vVEEdit.move( RECT rnew )
405 {
406 this.refresh()
407 POINT offp
408
409 offp.x = rnew.left
410 offp.y = rnew.top
411 ScreenToClient( this.winparent, offp )
412 //print( "+++++++++++++++off \(offp.Left) \(offp.Top) \n" )
413 //Сдвиг окна
414 //MoveWindow( this.winn->vCtrl.hwnd, offp.Left, offp.Top,/*rnew.left + offp.Left, rnew.top + offp.Top,*/ rnew.right - rnew.left, rnew.bottom - rnew.top, 1 )
415 /*this.winn->vCtrl.Left = offp.Left
416 this.winn->vCtrl.Top = offp.Top
417 this.winn->vCtrl.Width = rnew.right - rnew.left
418 this.winn->vCtrl.Height = rnew.bottom - rnew.top*/
419 eventpos ep
420 ep.loc.left = offp.x
421 ep.loc.top = offp.y
422 ep.loc.width = rnew.right - rnew.left
423 ep.loc.height = rnew.bottom - rnew.top
424 if this.winn->vComp.pOwner && this.winn->vComp.TypeIs( vCtrl)
425 {
426 //ep.loc.left += this.winn->vCtrl.pOwner->vCtrl.clloc.left
427 //ep.loc.top += this.winn->vCtrl.pOwner->vCtrl.clloc.top
428 if this.winn->vCtrl.pAlign & ( $alhRight | $alhLeftRight )
429 {
430 this.winn->vCtrl.pRight = this.winn->vCtrl.Owner->vCtrl.clloc.width - ep.loc.left - ep.loc.width
431 }
432 if this.winn->vCtrl.pAlign & ( $alvBottom | $alvTopBottom )
433 {
434 this.winn->vCtrl.pBottom = this.winn->vCtrl.Owner->vCtrl.clloc.height - ep.loc.top - ep.loc.height
435 }
436 }
437 //this.wdown->vCtrl.Visible = 0
438 ep.code = $e_poschanging
439 ep.move = 1
440 this.winn->vVirtCtrl.Virtual( $mPosChanging, &ep )
441 //this.refresh()
442 //this.green()
443 //this.wdown->vCtrl.Visible = 1
444 this.onSelect.run()//->func(this.form)
445
446 }
447
448 method vVEEdit.framenew( POINT pnt )
449 {
450 RECT rectnew//, rectold
451 this.typ = 3
452 this.rectold.set( -0, -0 )
453 ScreenToClient( this.winparent, pnt )
454 pnt.x = .alignx( pnt.x, 0 )
455 pnt.y = .aligny( pnt.y, 0 )
456 //print( "new \(pnt.x) \(pnt.y)\n" )
457 ClientToScreen( this.winparent, pnt )
458 this.offx = pnt.x
459 this.offy = pnt.y
460 rectnew.left = pnt.x
461 rectnew.top = pnt.y
462 rectnew.right = pnt.x
463 rectnew.bottom = pnt.y
464 this.rectold.reframe( this.hwnd, rectnew )
465 }
466
467 method vVEEdit.frameshow( uint typ )
468 {
469 RECT rectnew//, rectold
470 this.typ = typ
471 //GetWindowRect( this.winn->vCtrl.hwnd, rectnew )
472 this.winn->vVirtCtrl.GetRect( rectnew )
473 this.rectold.set( -0, -0 )
474 this.rectold.reframe( this.hwnd, rectnew )
475 }
476
477 method vVEEdit.framehide()
478 {
479 RECT rectnew
480 //RECT rectold
481 //RECT rect
482 //Удаление остаточной рамки
483 //rect = rectold
484 rectnew.set( -0, -0 )
485 this.rectold.reframe( this.hwnd, rectnew )
486 }
487
488 method vVEEdit.framemove( POINT pnt )
489 {
490 //print( "framemove \n" )
491 pnt.x -= this.offx
492 pnt.y -= this.offy
493 ScreenToClient( this.winparent, pnt )
494 pnt.x = .alignx( pnt.x, 0 )
495 pnt.y = .aligny( pnt.y, 0 )
496 ClientToScreen( this.winparent, pnt )
497 this.rectold.frame_move( this.hwnd, pnt.x, pnt.y )
498 }
499
500 method vVEEdit.framesize( POINT pnt )
501 {
502 //print( "X \(this.typ)\n" )
503 RECT rectnew
504 int tmp
505 rectnew = this.rectold
506 ScreenToClient( this.winparent, pnt )
507 pnt.x = .alignx( pnt.x, 0 )
508 pnt.y = .aligny( pnt.y, 0 )
509 ClientToScreen( this.winparent, pnt )
510 switch this.typ
511 {
512 case 1
513 {
514 rectnew.left = this.offx
515 rectnew.right = pnt.x
516 }
517 case 2
518 {
519 rectnew.top = this.offy
520 rectnew.bottom = pnt.y
521 }
522 case 3
523 {
524 rectnew.left = this.offx
525 rectnew.right = pnt.x
526 rectnew.top = this.offy
527 rectnew.bottom = pnt.y
528 }
529 }
530 if rectnew.left > rectnew.right
531 {
532 tmp = rectnew.left
533 rectnew.left = rectnew.right
534 rectnew.right = tmp
535 }
536 if rectnew.top > rectnew.bottom
537 {
538 tmp = rectnew.top
539 rectnew.top = rectnew.bottom
540 rectnew.bottom = tmp
541 }
542 this.rectold.reframe( this.hwnd, rectnew )
543 }
544 method vVEEdit.setcapture()
545 {
546 RECT rt
547 uint wparent = this.winparent//GetParent( this.winn )
548 if !wparent : wparent = GetDesktopWindow()
549 GetWindowRect( wparent, rt )
550 ClipCursor( rt )
551 //SetWindowPos( wup, 0, 0, 0, 0, 0, $SWP_NOMOVE | $SWP_NOSIZE )
552 SetCapture( this.hwnd )
553 InvalidateRect( this.wdown->vCtrl.hwnd, 0->RECT, 1 )
554 //UpdateWindow( this.wdown->vCtrl.hwnd )
555 //SetForegroundWindow( this.hwnd )
556 }
557 method vVEEdit.releasecapture()
558 {
559 this.oper = 0
560 //Удаление остаточной рамки
561 this.framehide()
562 ClipCursor( 0->RECT )
563 //SetBackgroundWindow( this.hwnd )
564 //SetForegroundWindow( this.hwnd )
565 //UpdateWindow( this.wdown->vCtrl.hwnd )
566 this.wdown->vCtrl.Visible = 0
567
568 this.wdown->vCtrl.Visible = 1
569
570 InvalidateRect( this.wdown->vCtrl.hwnd, 0->RECT, 1 )
571 UpdateWindow( this.wdown->vCtrl.hwnd )
572
573 }
574
575 method vVEEdit.startmove( POINT pnt )
576 {
577 this.oper = $OPERMOVE
578 this.setcapture()
579 //print( "Start\n")
580 //print( "s1\n" )
581 this.frameshow( 0 )
582 //print( "s2\n" )
583 this.offx = pnt.x - this.rectold.left
584 this.offy = pnt.y - this.rectold.top
585 this.onstartchange.run()
586 //print( "Start 2\n")
587 }
588
589 method vVEEdit.stop( uint flgsave )
590 {
591 if this.oper
592 {
593 RECT rect
594 uint curoper = this.oper
595 rect = this.rectold
596 //this.releasecapture()
597 ReleaseCapture()
598 if flgsave && ( curoper & $OPERCHANGE )
599 {
600 if ( curoper & ( $OPERMOVE | $OPERSIZE ))
601 {
602 //rect.left -= this.Owner->vCtrl.clloc.left
603 //rect.top -= this.Owner->vCtrl.clloc.top
604 this.move( rect )
605 //this.releasecapture()
606 }
607 elif curoper & $OPERNEW
608 {
609 // this.releasecapture()
610 /*eventuint eu
611 loc r
612 eu.value = &r
613 r.Left = rect.left
614 r.Top = rect.right
615 this.onnew.run( eu )*/
616 POINT offp
617
618 if this.winn->vComp.TypeIs( vCtrl )
619 {
620 offp.x = rect.left
621 offp.y = rect.top
622 ScreenToClient( this.winn->vCtrl.hwnd /*parent*/, offp )
623 }
624 //Сдвиг окна
625 //MoveWindow( this.winn->vCtrl.hwnd, offp.Left, offp.Top,/*rnew.left + offp.Left, rnew.top + offp.Top,*/ rnew.right - rnew.left, rnew.bottom - rnew.top, 1 )
626 /*this.winn->vCtrl.Left = offp.Left
627 this.winn->vCtrl.Top = offp.Top
628 this.winn->vCtrl.Width = rnew.right - rnew.left
629 this.winn->vCtrl.Height = rnew.bottom - rnew.top*/
630 evparQueryCreate ep
631 ep.loc.left = offp.x
632 ep.loc.top = offp.y
633 ep.loc.width = rect.right - rect.left
634 ep.loc.height = rect.bottom - rect.top
635 ep.Owner = .winn
636 //print( " N1\n" )
637 this.onQueryCreate.run( ep )
638 //print( " N2\n" )
639 //print( "N\n" )
640 if ep.NewComp
641 {
642 //print( " N3\n" )
643 //print( "NEW 11\n" )
644 //.select( ep.NewComp->vComp )
645 .VEPanel->vVEPanel.Selected = ep.NewComp->vComp
646 }
647 }
648 }
649
650 }
651 }
652
653
654
655 /*------------------------------------------------------------------------------
656 Windows Mesages Methods
657 */
658 method uint vVEEdit.wmlbuttondown <alias=vVEEdit_wmlbuttondown>(winmsgmouse wmsg)
659 {
660 //print( "EditBtn\n" )
661 POINT pnt
662 SetFocus( this.hwnd )
663 uint ww
664 //Определение координат
665 //mousetopoint( lpar, pnt )
666 pnt.x = wmsg.x
667 pnt.y = wmsg.y
668 ClientToScreen( this.hwnd, pnt )
669 //ScreenToClient( wnd, pnt )
670 //print( "mousepoint \(pnt.Left ) \(pnt.Top)\n" );
671 ww = gettopwindow( /*this.Owner->vCtrl.hwnd*/.VisPanel->vScrollBox.hwnd, pnt )
672 //print( "top=\(ww) \(this.p_owner->vCtrl.hwnd)\n" )
673 //Захват окна
674 if ww && ww != /*this.Owner->vCtrl.hwnd*/.VisPanel->vScrollBox.hwnd
675 {
676
677 uint ctrl as getctrl( ww )
678 if &ctrl
679 {
680 //pnt.x -= ctrl.loc.left
681 //pnt.y -= ctrl.loc.top
682 POINT virtpnt = pnt
683 ScreenToClient( ctrl.hwnd, virtpnt )
684 int i
685 for i = *ctrl.Comps-1, i >= 0, i--
686 {
687 if ctrl.Comps[i]->vComp.TypeIs( vVirtCtrl ) &&
688 !ctrl.Comps[i]->vComp.TypeIs( vCtrl )
689 {
690 ctrl.Comps[i]->vVirtCtrl.Virtual( $mPosUpdate )
691
692 RECT r
693 r.left = ctrl.Comps[i]->vVirtCtrl.loc.left
694 r.top = ctrl.Comps[i]->vVirtCtrl.loc.top
695 r.right = ctrl.Comps[i]->vVirtCtrl.loc.left + ctrl.Comps[i]->vVirtCtrl.loc.width
696 r.bottom = ctrl.Comps[i]->vVirtCtrl.loc.top + ctrl.Comps[i]->vVirtCtrl.loc.height
697 if PtInRect( r, virtpnt.x, virtpnt.y )
698 {
699 //print( "LOC ------------------- \n" )
700 ctrl as ctrl.Comps[i]->vVirtCtrl
701 break
702 }
703 }
704 }
705
706 //Sleep( 1000 )
707 //this.select( ctrl )
708 .VEPanel->vVEPanel.Selected = ctrl
709 //Sleep( 1000 )
710 /*POINT pnts
711 //mousetopoint( lpar, pnt )
712 winmsgmouse wm
713 pnts.Left = wmsg.Left//em.Left
714 pnts.Top = wmsg.Top//em.Top
715 ClientToScreen( this.hwnd, pnts )
716 //ScreenToClient( this.hwnd, pnts )
717 wm.Left = pnts.Left
718 wm.Top = pnts.Top
719 wm.wpar = wmsg.wpar
720 ctrl.WinMsg( $WM_NCLBUTTONDOWN, wm.wpar, wm->winmsg.lpar )*/
721 if this.flgadd
722 {
723 //this.startmove( pnt )
724 this.oper = $OPERNEW | $OPERCHANGE
725 this.setcapture()
726 POINT pnt
727 if this.winn->vComp.TypeIs( vCtrl )
728 {
729 this.winparent = this.winn->vCtrl.hwnd
730 }
731 else
732 {
733 this.winparent = this.winn->vVirtCtrl.Owner->vCtrl.hwnd
734 }
735 //mousetopoint( lpar, pnt )
736 pnt.x = wmsg.x//em.Left
737 pnt.y = wmsg.y//em.Top
738 ClientToScreen( this.hwnd, pnt )
739 this.framenew( pnt )
740 this.framesize( pnt )
741 }
742 else
743 {
744 //this.mouseleft = wmsg.x
745 //this.mouseright = wmsg.y
746 this.startmove( pnt )
747 }
748 }
749 }
750 //print( "EditBtn 2\n" )
751 return 0
752 }
753
754 method uint vVEEdit.wmmousemove <alias=vVEEdit_wmmousemove>(winmsgmouse wmsg)
755 {
756 //if this.oper & $OPERCHANGE
757 //print("MOUSEMOVE \(this.oper)\n" )
758 if this.oper
759 {
760 if !( this.oper & $OPERFIRST ) //Первый move откидываем т.к. он генерируется SetCapture
761 {
762 this.oper |= $OPERFIRST
763 return 0
764 }
765 this.oper |= $OPERCHANGE
766 // case 1 : frame_sel( wnd, int( ( &lpar )->short ), int( ( &lpar + 2 )->short) )
767 POINT pnt
768 //mousetopoint( lpar, pnt )
769 pnt.x = wmsg.x
770 pnt.y = wmsg.y
771 ClientToScreen( this.hwnd, pnt )
772 if this.oper & $OPERMOVE : this.framemove( pnt )
773 elif this.oper & $OPERSIZE : this.framesize( pnt )
774 elif this.oper & $OPERNEW : this.framesize( pnt )
775 }
776 return 0
777 }
778 method uint vVEEdit.wmlbottonup <alias=vVEEdit_wmlbuttonup>(winmsg wmsg)
779 {
780 //print( "edit.up\n" )
781 this.stop( 1 )
782 return 0
783 }
784
785 method uint vVEEdit.wmcapturechanged <alias=vVEEdit_wmcapturechanged>( winmsg wmsg )
786 {
787 //print( "RELEASE++++++++\n" )
788 this.releasecapture()
789 wmsg.flags = 1
790 return 0
791 }
792
793 method uint vVEFrame.wmmousemove <alias=vVEFrame_wmmousemove>(winmsgmouse wmsg)
794 {
795 uint we as this.WE->vVEEdit//this.Owner->vVEEdit
796
797 if !we.oper
798 {
799 POINT pnt
800 uint t
801 //Определение координат
802 //mousetopoint( lpar, pnt )
803 pnt.x = wmsg.x
804 pnt.y = wmsg.y
805 //ClientToScreen( wnd, pnt )
806 t = getcursorsize( this.hwnd, pnt )
807 if t
808 {
809 SetCursor( LoadCursor( 0, $IDC_SIZENWSE + ( t - 1 )%4 ) )
810 }
811 else : SetCursor( LoadCursor( 0, $IDC_ARROW ) )
812 }
813 return 0
814 }
815
816 method uint vVEFrame.wmlbuttondown <alias=vVEFrame_wmlbuttondown>(winmsgmouse wmsg)
817 {
818 //print( "FrameBtn\n" )
819 uint we as this.WE->vVEEdit//this.Owner->vVEEdit
820 POINT pnt
821 uint t
822 uint typ
823 //Определение координат
824 pnt.x = wmsg.x
825 pnt.y = wmsg.y
826 t = getcursorsize( this.hwnd, pnt )
827 if t
828 {
829
830 RECT r
831 //GetWindowRect( we.winn->vCtrl.hwnd, r )
832 we.winn->vVirtCtrl.GetRect( r )
833 arr art of uint
834 arr arx of uint
835 arr ary of uint
836 art = %{ 0, 3, 3, 1, 2, 3, 3, 1, 2 }
837 arx = %{ 0, 1, 0, 1,-1, 0, 1, 0,-1 }
838 ary = %{ 0, 1, 1,-1, 1, 0, 0,-1, 0 }
839 we.offx = ?( arx[t], r.right, r.left )
840 we.offy = ?( ary[t], r.bottom, r.top )
841 typ = art[t]
842 // print( "t \(t) \(typ) \(art[0]) \(art[1]) \(art[2])\n" )
843
844 we.oper = $OPERSIZE
845 we.setcapture()
846
847 SetCursor( LoadCursor( 0, $IDC_SIZENWSE + ( t - 1 )%4 ) )
848 we.frameshow( typ )
849 }
850 else
851 {
852 ClientToScreen( this.hwnd, pnt )
853 we.startmove( pnt )
854 }
855 return 0
856 }
857
858 method uint vVEEdit.wmlbuttondblclk <alias=vVEEdit_wmlbuttondblclk>(winmsgmouse wmsg)
859 {
860 .VEPanel->vVEPanel.DblClick()
861 return 0
862 }
863
864 method uint vVEFrame.wmpaint <alias=vVEFrame_wmpaint>(winmsg wmsg)
865 {
866 uint we as this.WE->vVEEdit//as this.Owner->vVEEdit
867 //print( "paint frame\n" )
868 uint hdc
869 PAINTSTRUCT lp
870 uint r = CreateRectRgn( 0, 0, 1, 1 )
871 GetWindowRgn( this.hwnd, r )
872 InvalidateRgn( this.hwnd, r, 0 )
873 //RECT r
874 //GetWindowRect( this.hwnd, r )
875 //InvalidateRect( this.hwnd, r, 0 )
876 hdc = BeginPaint( this.hwnd, lp )
877 FillRgn( hdc, r, ?( we.oper, we.brushgr, we.brush ) )
878 EndPaint( this.hwnd, lp )
879 DeleteObject( r )
880 wmsg.flags = 1
881 return 0
882 }
883
884 /*method uint vVEEdit.wmpaint <alias=vVEEdit_wmpaint>(winmsg wmsg)
885 {
886 PAINTSTRUCT lp
887 uint hdc
888 hdc = BeginPaint( this.hwnd, lp )
889 print( "paint\n" )
890 EndPaint( this.hwnd, lp )
891 wmsg.flags = 1
892 return 1
893 }*/
894 /*------------------------------------------------------------------------------
895 Virtual Methods
896 */
897
898 method vVEFrame vVEFrame.mCreateWin <alias=vVEFrame_mCreateWin>()
899 {
900 //uint we as this.Owner->vVEEdit
901
902 //gclass_register( "GWDown", 0, 0, 0, we.brush, gwapp,
903 // &gw_app, &gwapp_setnotify, &gwapp_getnotify )
904 //this.loc.left = -1
905 //this.loc.top = -1
906 //this.Owner->vCtrl.CreateWin( "GVForm".ustr(), 0, $WS_OVERLAPPED | $WS_CLIPSIBLINGS | $WS_CHILD | $WS_VISIBLE )
907 /*this.hwnd = CreateWindowEx( //$WS_EX_TRANSPARENT
908 0, "STATIC".ustr().ptr(), "w".ustr().ptr(),
909 // $WS_OVERLAPPED
910 $WS_CLIPSIBLINGS | $WS_CLIPCHILDREN | $WS_CHILD | $WS_VISIBLE,
911 -1, -1, 1, 1, this.Owner->vCtrl.Owner->vCtrl.hwnd, 0, 0, &this )*/
912 //this.CreateWin( "STATIC".ustr(), /*$WS_EX_TRANSPARENT*/0,/* $WS_CHILD |*/ $WS_VISIBLE | $WS_CLIPCHILDREN | $WS_CLIPSIBLINGS | $WS_OVERLAPPED )
913 this.CreateWin( "GVTr".ustr(), 0, $WS_CHILD | $WS_VISIBLE | $WS_CLIPCHILDREN | $WS_CLIPSIBLINGS | $WS_OVERLAPPED )
914 this.prevwndproc = -1
915 this->vCtrl.mCreateWin()
916 //this.prevwndproc = 0
917 this.VertAlign = $alvTop
918 this.HorzAlign = $alhLeft
919
920
921
922 return this
923 }
924
925 method vVEEdit vVEEdit.mCreateWin <alias=vVEEdit_mCreateWin>()
926 {
927
928 this.discr.x = 5
929 this.discr.y = 5
930 this.brush = CreateSolidBrush( GetSysColor( 13))//0xFF00 )//COLOR_HIGHLIGHT
931 this.brushgr = CreateSolidBrush( GetSysColor( 16) )//0x666666 ) //COLOR_BTNSHADOW
932 this.pen = CreatePen( $PS_INSIDEFRAME | $PS_SOLID, 1, 0xFF00 )
933
934 //gclass_register( "GWUp", 0, 0, 0, 0, gwapp,
935 // &gw_app, &gwapp_setnotify, &gwapp_getnotify )
936
937 this.CreateWin( "GVTr".ustr(), $WS_EX_TRANSPARENT, $WS_TABSTOP | $WS_VISIBLE | $WS_CHILD /*| $WS_CLIPSIBLINGS*/ )
938 this.prevwndproc = -1
939 this->vCtrl.mCreateWin()
940 //this.prevwndproc = 0
941 //this.Caption = "wup".ustr()
942 /*this.hwnd = CreateWindowEx( $WS_EX_TRANSPARENT , "GVUp".ustr().ptr(), "wup".ustr().ptr(),
943 $WS_TABSTOP | $WS_VISIBLE | $WS_CHILD ,
944 0, 0, 300, 300, this.p_owner->vCtrl.hwnd, 0, 0, &this )*/
945 //win_customproc( this.hwnd, &upproc )
946 SetParent( this.hwnd, this.Owner->vCtrl.hwnd )
947
948 //this.wdown = &newcomp( vVEFrame, this )
949 this.wdown = &this.Owner.CreateComp( vVEFrame )
950 this.wdown->vVEFrame.WE = &this
951 //this.wdown = &this.CreateComp( vVEFrame )
952 //SetParent( this.wdown->vVEFrame.hwnd, this.Owner->vCtrl.hwnd )
953 //SetWindowPos( this.wdown->vVEFrame.hwnd, 0, 0, 0, 0, 0, $SWP_NOACTIVATE | $SWP_NOMOVE | $SWP_NOSIZE )
954 this.VertAlign = $alvClient
955 this.HorzAlign = $alhClient
956 /*
957 .panVis.Owner = this
958 .panVis.VertAlign = $alvTopBottom
959 .panVis.Top = 0
960 .panVis.Bottom = 100
961 .panVis.HorzAlign = $alhClient
962
963 .panNoVis.Owner = this
964 .panNoVis.Height = .panVis.Bottom
965 .panNoVis.Bottom = 0
966 .panNoVis.VertAlign = $alvBottom
967 .panNoVis.HorzAlign = $alhClient
968 */
969 //gui_showapp( wup, $SW_MAXIMIZE, 0 )
970 //DeleteObject( brush )
971 //DeleteObject( pen )
972 //gui_deinit()
973 return this
974 }
975
976
977 property vComp vVEPanel.Selected()
978 {
979 return .pSelected->vComp
980 }
981
982 property vVEPanel.Selected( vComp newcomp )
983 {
984 uint curcomp as newcomp
985 while !curcomp.p_designing
986 {
987 curcomp as curcomp.Owner
988 if &curcomp == &this : return
989 }
990 if curcomp.p_designing
991 {
992 //print( "VE Selected \(&newcomp) \(&.WE)\n" )
993 if .pSelected != &curcomp
994 {
995 if curcomp
996 {
997 //.pSelected != &newcomp
998 //print( "VE Selected 1\(&newcomp)\n" )
999 .pSelected = &curcomp
1000 //this.refresh()
1001 if curcomp.TypeIs( vVirtCtrl )
1002 {
1003 .NoVisList.Selected = 0->LVItem
1004 .WE.select( curcomp )
1005 }
1006 else
1007 {
1008 //print( "z1\n")
1009 .WE.select( 0->vComp )
1010 //print( "z2\n")
1011 foreach item, .NoVisList.Root
1012 {
1013 //print( "z3\n")
1014 if item->LVItem.Tag == &curcomp
1015 {
1016 //print( "z4\n")
1017 .NoVisList.Selected = item->LVItem
1018 break
1019 }
1020 }
1021 }
1022 }
1023 else
1024 {
1025 .WE.select( 0->vComp )
1026 }
1027 }
1028 this.onSelect.run()
1029 }
1030 }
1031
1032 method vVEPanel.WESelect <alias=vVEPanel_WESelect> ( evparEvent ev )
1033 {
1034 this.onSelect.run()
1035 //.Selected = .WE.winn->vComp
1036 }
1037
1038 method vVEPanel.WEQueryCreate <alias=vVEPanel_WEQueryCreate> ( evparQueryCreate evpQ )
1039 {
1040 .onQueryCreate.run( evpQ )
1041 }
1042
1043
1044
1045 method vVEPanel.BeforeScroll <alias=vVEPanel_BeforeScroll> ( evparQuery pQ )
1046 {
1047 .WE.Visible =0
1048 }
1049
1050 method vVEPanel.AfterScroll <alias=vVEPanel_AfterScroll> ( evparEvent ev )
1051 {
1052 .WE.Visible =1
1053 }
1054
1055
1056 method vVEPanel.NoVisList_Select <alias=vVEPanel_NoVisList_Select> ( /* vComp sender,*/ evparTVAfter ea )
1057 {
1058 uint comp as ea.CurItem->LVItem.Tag->vComp
1059 if &comp
1060 {
1061 //.VEPanel.WE.select( comp )
1062 //print( "SELECT \( ea.CurItem->LVItem.Tag ) \(ea.CurItem->LVItem.Tag->vComp.Name)\n")
1063 this.Selected = comp
1064 }
1065 }
1066
1067 /*method vVEPanel.NoVisList_Focus <alias=vVEPanel_NoVisList_Focus> (eventuint ev)
1068 {
1069 if ev.val
1070 {
1071 if &this.NoVisList.Selected()
1072 {
1073 uint comp as this.NoVisList.Selected.Tag->vComp
1074 if &comp
1075 {
1076 //.VEPanel.WE.select( comp )
1077 this.Selected = comp
1078 }
1079 }
1080 }
1081 }
1082 */
1083 method vVEPanel.DblClick()
1084 {
1085 evparValUint eu
1086 eu.val = &.Selected()
1087 .OnDblClick.run( eu )
1088 }
1089
1090 method vVEPanel.Mouse <alias=vVEPanel_Mouse> (/*vComp sender,*/evparMouse evm)
1091 {
1092 if evm.evmtype == $evmLDbl && &.Selected()
1093 {
1094 .DblClick()
1095 }
1096 }
1097
1098 method vVEPanel.NoVisList_Key <alias=vVEPanel_NoVisList_Key> (/*vComp sender,*/evparKey evk)
1099 {
1100 if evk.evktype == $evkDown && evk.key = $VK_DELETE && &.NoVisList.Selected()
1101 {
1102 uint owner as .Selected.Owner
1103 uint curcomp as .Selected
1104 .NoVisList.Selected.Del()
1105 if ( !&.NoVisList.Selected() )
1106 {
1107 .Selected = owner
1108 }
1109 curcomp.DestroyComp()
1110 }
1111 }
1112
1113 method vVEPanel.Update()
1114 {
1115 .NoVisList.Clear()
1116 foreach comp, .VisPanel.Comps[0]->vForm.Comps
1117 {
1118 comp as vComp
1119 if !comp.TypeIs( vCtrl )
1120 {
1121 .NoVisList.Append( comp->vComp.Name.ustr(), &comp )
1122 }
1123 }
1124
1125 }
1126
1127 method vVEPanel.mDesChanging <alias=vVEPanel_mDesChanging>( vCtrl ctrl )
1128 {
1129 if this.WE.winn
1130 {
1131 //print( "desChanging \(&ctrl) \(ctrl.TypeName) \(ctrl.Name)\n" )
1132 this.WE.wdown->vCtrl.Visible = 0
1133 UpdateWindow( this.WE.wdown->vCtrl.hwnd )
1134 if this.WE.winn->vComp.TypeIs( vCtrl )
1135 {
1136 UpdateWindow( this.WE.winn->vCtrl.hwnd )
1137 }
1138 else
1139 {
1140 UpdateWindow( this.WE.winn->vVirtCtrl.Owner->vCtrl.hwnd )
1141 }
1142 }
1143 }
1144
1145 method vVEPanel.mDesChanged <alias=vVEPanel_mDesChanged>( vCtrl ctrl )
1146 {
1147
1148 if ctrl.TypeIs( vForm ) && !.flgDesChanged
1149 {
1150 .flgDesChanged = 1
1151 //print( "old \(ctrl.HorzAlign) \(ctrl.VertAlign) \(this.VisPanel.Width) \(this.VisPanel.HorzRange) \(this.VisPanel.VertRange)\n" )
1152 if ctrl.HorzAlign == $alhLeft
1153 {
1154 this.VisPanel.HorzRange = ctrl.Width//this.WE.winn->vCtrl.Width
1155 }
1156 else : this.VisPanel.HorzRange = 0
1157
1158 if ctrl.VertAlign == $alvTop
1159 {
1160 this.VisPanel.VertRange = ctrl.Height//this.WE.winn->vCtrl.Height
1161 }
1162 else : this.VisPanel.VertRange = 0
1163 //print( "new \(this.VisPanel.HorzRange) \(this.VisPanel.VertRange)\n" )
1164 .flgDesChanged = 0
1165 }
1166 if this.WE.winn
1167 {
1168 //print( "desChanged\n" )
1169 this.WE.green()
1170 this.WE.wdown->vCtrl.Visible = 1
1171 //UpdateWindow( this.winn->vCtrl.hwnd )
1172 //WE.Visible = 1
1173 //WE.SetFocus()
1174 if &ctrl == &this.WE.winn//Selected()
1175 {
1176 this.WE.onSelect.run()
1177 }
1178 }
1179
1180 }
1181
1182 method vVEPanel vVEPanel.mCreateWin <alias=vVEPanel_mCreateWin>()
1183 {
1184 this->vPanel.mCreateWin()
1185
1186 with .NoVisList
1187 {
1188
1189 .Owner = this
1190 .Height = 100
1191 .Top = this.Height - .Height
1192 .HorzAlign = $alhClient
1193 .VertAlign = $alvBottom
1194 .ShowSelection = 1
1195 .OnAfterSelect.Set( this, vVEPanel_NoVisList_Select )
1196 //.onfocus.set( this, vVEPanel_NoVisList_Focus )
1197 .OnMouse.Set( this, vVEPanel_Mouse )
1198 .OnKey.Set( this, vVEPanel_NoVisList_Key )
1199 }
1200 /*with .TopPanel
1201 {
1202 .Owner = this
1203 .Top = 0
1204 .HorzAlign = $alhClient
1205 .VertAlign = $alvTopBottom
1206 .Bottom = this.NoVisList.Height
1207 }*/
1208 with .VisPanel
1209 {
1210 .Owner = this//.TopPanel
1211 //.Top = 0
1212 //.Name = "xxxxxxxx\n"
1213 .AutoScroll = 0//1
1214 .HorzAlign = $alhClient
1215 .VertAlign = $alvTopBottom
1216 .Bottom = this.NoVisList.Height
1217
1218 .OnBeforeScroll.Set( this, vVEPanel_BeforeScroll )
1219 .OnAfterScroll.Set( this, vVEPanel_AfterScroll )
1220 }
1221
1222 .WE.VEPanel = &this
1223 .WE.VisPanel = &.VisPanel
1224 .WE.Owner = .VisPanel
1225
1226 .WE.onSelect.Set( this, vVEPanel_WESelect )
1227 .WE.onQueryCreate.Set( this, vVEPanel_WEQueryCreate )
1228 .WE.OnMouse.Set( this, vVEPanel_Mouse )
1229 return this
1230 }
1231
1232 /*------------------------------------------------------------------------------
1233 Registration
1234 */
1235 method vVEFrame vVEFrame.init()
1236 {
1237 this.pTypeId = vVEFrame
1238 return this
1239 }
1240
1241 method vVEEdit vVEEdit.init()
1242 {
1243 this.pTypeId = vVEEdit
1244 this.pCanContain = 1
1245 this.pTabStop = 1
1246 return this
1247 }
1248
1249 method vVEPanel vVEPanel.init()
1250 {
1251 this.pTypeId = vVEPanel
1252 this.pCanContain = 1
1253 this.pTabStop = 1
1254 return this
1255 }
1256
1257 func init_vVEEdit <entry>()
1258 {
1259 WNDCLASSEX visclass
1260 ustr classname = "GVTr"
1261 with visclass
1262 {
1263 .cbSize = sizeof( WNDCLASSEX )
1264 .style = $CS_HREDRAW | $CS_VREDRAW | $CS_DBLCLKS
1265 .lpfnWndProc = callback( &myproc, 4 )
1266 .cbClsExtra = 0
1267 .cbWndExtra = 0
1268 .hInstance = GetModuleHandle( 0 )
1269 .hIcon = 0
1270 .hCursor = LoadCursor( 0, $IDC_ARROW )
1271 .hbrBackground = 0
1272 .lpszMenuName = 0
1273 .lpszClassName = classname.ptr()
1274 .hIconSm = 0
1275 }
1276 uint hclass = RegisterClassEx( &visclass )
1277
1278 regcomp( vVEEdit, "vVEEdit", vCtrl, $vCtrl_last,
1279 %{ %{$mCreateWin, vVEEdit_mCreateWin},
1280 %{$mKey, vVEEdit_mKey}
1281 },
1282 %{ %{$WM_LBUTTONDOWN, vVEEdit_wmlbuttondown},
1283 %{$WM_LBUTTONUP, vVEEdit_wmlbuttonup},
1284 %{$WM_MOUSEMOVE , vVEEdit_wmmousemove},
1285 %{$WM_LBUTTONDBLCLK, vVEEdit_wmlbuttondblclk},
1286 //%{$WM_MBUTTONDBLCLK, vVEEdit_wmlbuttondblclk},
1287 %{$WM_CAPTURECHANGED, vVEEdit_wmcapturechanged} /*,
1288 %{$WM_PAINT , vVEEdit_wmpaint} */
1289 })
1290
1291 regcomp( vVEFrame, "vVEFrame", vCtrl, $vCtrl_last,
1292 %{ %{$mCreateWin, vVEFrame_mCreateWin}/*,
1293 %{$mKey, vVEFrame_mKey}*/},
1294 %{ %{$WM_LBUTTONDOWN, vVEFrame_wmlbuttondown},
1295 %{$WM_MOUSEMOVE , vVEFrame_wmmousemove},
1296 %{$WM_PAINT , vVEFrame_wmpaint}
1297
1298 })
1299
1300 regcomp( vVEPanel, "vVEPanel", vPanel, $vCtrl_last,
1301 %{ %{$mCreateWin, vVEPanel_mCreateWin},
1302 %{$mDesChanging, vVEPanel_mDesChanging },
1303 %{$mDesChanged, vVEPanel_mDesChanged }},
1304 0->collection )
1305
1306 }