1 /******************************************************************************
2 *
3 * Copyright (C) 2004-2007, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * ID: vis.popupmenu 19.07.07 0.0.A.
11 *
12 * Author: Alexander Krivonogov ( gentee )
13 *
14 ******************************************************************************/
15
16 include {
17 "menu.g"
18 }
19
20
21 /* Компонента vPopupMenu, порождена от vCustomMenu, может содержать vMenuItem
22 */
23 type vPopupMenu <inherit = vCustomMainMenu> {
24 evQuery OnBeforeShow
25 }
26
27 /*------------------------------------------------------------------------------
28 Public methods
29 */
30
31 /*Метод vPopupMenu.Show( int x, y )
32 Открыть всплывающе меню
33 x, y - координаты экрана где открыть всплывающее меню
34 */
35 method vPopupMenu.Show( int x y )
36 {
37 evparQuery eq
38 //eq.val = &ctrl
39 .OnBeforeShow.Run( eq, this )
40 if !eq.flgCancel
41 {
42 TrackPopupMenuEx( .phMenu, $TPM_LEFTALIGN | $TPM_TOPALIGN , x, y,
43 .Owner->vForm.hwnd, 0 )
44 }
45 }
46
47 /*Метод vPopupMenu.Show( )
48 Открыть всплывающе меню, меню откроется рядом с курсором мыши
49 */
50 method vPopupMenu.Show( )
51 {
52 POINT p
53 GetCursorPos( p )
54 .Show( p.x, p.y )
55 }
56
57 /*------------------------------------------------------------------------------
58 Virtual methods
59 */
60
61 method vPopupMenu.mSetOwner <alias = vPopupMenu_mSetOwner> ( vComp owner )
62 {
63 if owner && owner.TypeIs( vForm )
64 {
65 this.pOwner = &owner
66 }
67 }
68
69 /*------------------------------------------------------------------------------
70 Registration
71 */
72 method vPopupMenu vPopupMenu.init( )
73 {
74 this.pTypeId = vPopupMenu
75 this.phMenu = CreatePopupMenu()
76 return this
77 }
78
79 func init_vPopupMenu <entry>()
80 {
81 regcomp( vPopupMenu, "vPopupMenu", vCustomMenu, $vComp_last,
82 %{ %{$mSetOwner, vPopupMenu_mSetOwner }
83 },
84 0->collection )
85
86 ifdef $DESIGNING {
87 cm.AddComp( vPopupMenu, 1, "Windows", "popupmenu" )
88
89 cm.AddEvents( vPopupMenu, %{
90 "OnBeforeShow", "evparQuery"
91 })
92 }
93 }
94
95