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