Module Autolcmx.pkg
1//************************************************************************
2//
3// Confidential Trade Secret.
4// Copyright (c) 1993 2E Software, La Mesa California,
5// as an unpublished work. All rights reserved.
6// Portions copyright (c) 1997 Data Access Corporation, Miami Florida
7// DataFlex is a registered trademark of Data Access Corporation.
8//
9//************************************************************************/
10
11//************************************************************************
12// Autolcmx.Pkg
13// Version: 1.0
14// Copyright (c) 1993 2E Software
15// 05-17-1993 : Created
16//
17// Author: John J. Tuohy
18//
19//************************************************************************
20//
21// This replaces the character based auto_locate message with a GUI
22// version. This is only added to DEO clients (since in windaf we only
23// auto-locate containers.
24//************************************************************************
25// 04/29/96 JJT - Use GUIScreen_Size global function to get screen size
26// 7/13/00 JJT - GUIScreen_Size passes extra parameter to return Workspace area
27//************************************************************************
28Use VDFbase.pkg
29Use Modal_mx.pkg
30Use GlobalFunctionsProcedures.pkg
31Use Winuser.pkg
32Use tWinStructs.pkg
33
34Enumeration_list
35 Define NO_LOCATE
36 Define SMART_LOCATE
37 Define POPUP_LOCATE
38 Define CENTER_ON_SCREEN
39 Define CENTER_ON_PANEL
40 Define CENTER_ON_PARENT
41End_Enumeration_List
42
43{ Visibility=Private MethodType=Property }
44Function Main_Panel_Id for cDesktop Returns Integer
45 Function_Return 0
46End_Function
47
48// character mode sel-list and enclient call this...does nothing
49Class Auto_Locate_Mixin is a Mixin
50 { Visibility=Private }
51 Procedure Define_Auto_Locate
52 End_Procedure
53End_Class
54
55Class dfAuto_Locate_Mixin is a Mixin
56 { Visibility=Private }
57 Procedure Define_dfAuto_Locate
58 //Property Integer Auto_Locate_state FALSE
59 { DesignTime=False }
60 { Category=Behavior }
61 Property Integer Row_Offset 1 // down 1
62 { DesignTime=False }
63 { Category=Behavior }
64 Property Integer Column_Offset 2 // right 2
65
66 { EnumList="No_Locate, Smart_Locate, Popup_Locate, Center_On_Screen, Center_On_Panel, Center_On_Parent" }
67 { Category=Appearance }
68 Property Integer Locate_Mode No_Locate
69 End_Procedure
70
71 { MethodType=Property }
72 { Category=Appearance }
73 { InitialValue=False }
74 { PropertyType=Boolean }
75 Procedure Set Auto_Locate_State Integer iState
76 If iState ;
77 Set Locate_Mode to POPUP_LOCATE
78 Else If (Locate_Mode(Self)=POPUP_LOCATE) ;
79 Set Locate_Mode to NO_LOCATE
80 End_Procedure
81
82 { MethodType=Property }
83 Function Auto_Locate_State Returns Integer
84 Function_Return (Locate_Mode(Self)=POPUP_LOCATE)
85 End_Function // Auto_Locate_State
86
87 { MethodType=Property }
88 Procedure Set Offset_Location Integer Row# Integer Col#
89 Set Row_Offset to Row#
90 Set Column_Offset to Col#
91 End_Procedure // Set Offset_Location
92
93 // Make sure this fits properly for a multi-display. Adjust iCol and iRow as needed
94 { Visibility=Private }
95 Procedure AdjustForMultiDisplay Integer iHeight Integer iWidth Integer ByRef iCol Integer ByRef iRow
96 Integer iScreenHt iScreenWd
97 Boolean bOk
98 Handle hMonitor
99 tWinMonitorInfo MonitorInfo
100
101 Move (MonitorFromPoint(iCol, iRow, MONITOR_DEFAULTONPRIMARY)) to hMonitor
102 If (hMonitor=0) Begin
103 Error DFERR_PROGRAM "Cannot retrieve a monitor handle."
104 Procedure_Return
105 End
106 Move (SizeOfType(tWinMonitorInfo)) to MonitorInfo.cbSize
107 Move (GetMonitorInfo(hMonitor, AddressOf(MonitorInfo))) to bOK
108 If (not(bOK)) Begin
109 Error DFERR_PROGRAM "Cannot retrieve monitor info."
110 Procedure_Return
111 End
112
113 // Get the height & width of the target monitor
114 Move MonitorInfo.rcWork.bottom to iScreenHt // height to the bottom of the monitor's work area
115 Move MonitorInfo.rcWork.right to iScreenWd // width to the right of the monitor's work area
116
117 If (iRow + iHeight > iScreenHt) Begin
118 Move (iScreenHt - iHeight ) to iRow
119 End
120
121 If (iCol + iWidth > iScreenWd) Begin
122 Move (iScreenWd - iWidth ) to iCol
123 End
124
125 // Test that the adjusted Row & column still exists on some monitor....
126 Move (MonitorFromPoint(iCol, iRow, MONITOR_DEFAULTONNULL)) to hMonitor
127
128 If (hMonitor = 0) Begin
129 // If the location is not on any monitor then set the location to 2,2....
130 Move 2 to iCol
131 Move 2 to iRow
132 End
133 End_Procedure
134
135
136 // Procedure Auto_Locate
137 // rewritten for 14.1 to handle multiple monitors
138
139 { Visibility=Private }
140 Procedure Auto_Locate Handle hoInvokingObj
141 Integer iLocation iHeight iWidth iRow iColumn iPhysSize iRowOffset iColOffset
142 If (hoInvokingObj > Desktop) Begin
143 Get Absolute_GUIOrigin of hoInvokingObj to iLocation // location of inv obj
144 Move (Hi(iLocation)) to iRow // row
145 Move (Low(iLocation)) to iColumn // col
146 If (iColumn>32767) Begin
147 Move (iColumn - 65536 ) to iColumn
148 End
149 If (iRow>32767) Begin
150 Move (iRow - 65536 ) to iRow
151 End
152
153 Get Physical_FontSize to iPhysSize // size of the font
154 Get Row_Offset to iRowOffset
155 Get Column_Offset to iColOffset
156 Move (iRow + (iRowOffset * (Hi(iPhysSize)+4)) ) to iRow
157 Move (iColumn + (iColOffset * (Low(iPhysSize)+4)) ) to iColumn
158
159 Get GuiWindowSize to iLocation
160 Move (Hi(iLocation)) to iHeight
161 Move (Low(iLocation)) to iWidth
162
163 Send AdjustForMultiDisplay iHeight iWidth (&iColumn) (&iRow)
164 Set GuiLocation to iRow iColumn
165 Send Adjust_Logicals
166 End
167 End_Procedure
168
169 // Locate Panel on Screen/df desktop/current panel
170 // rewritten for 14.1 to handle multiple monitors
171 { Visibility=Private }
172 Procedure Locate_Panel
173 Handle hoTarget hoFocus
174 Integer iSize iLocation
175 Integer iScreenHt iScreenWd iScreenRow iScreenCol
176 Integer iHeight iWidth iRow iCol
177 Integer eLocateMode
178 Boolean bModal
179
180 Get Locate_Mode to eLocateMode
181 Get Focus of Desktop to hoFocus
182
183 If (eLocateMode=SMART_LOCATE) Begin
184 Get GuiLocation to iLocation
185 Get Modal_State to bModal
186 If (bModal and hoFocus>Desktop and hoFocus<>Self) Begin
187 Move POPUP_LOCATE to eLocateMode
188 End
189 Else If (iLocation<>0) Begin
190 Procedure_Return
191 End
192 Else Begin
193 Delegate Get Main_Panel_Id to hoTarget
194 Move (If(hoTarget>Desktop, CENTER_ON_PANEL, CENTER_ON_SCREEN)) to eLocateMode
195 End
196 End
197
198 If (eLocateMode=POPUP_LOCATE) Begin
199 If (hoFocus>Desktop and hoFocus<>Self) Begin
200 Send Auto_Locate hoFocus
201 End
202 Procedure_Return
203 End
204
205
206 // this was changed for 12.1 to work better when the panel is not nested in another panel
207 // If center on parent, it will check if the parent is the desktop - if so, it will try center on panel
208 // If center on panel is not in a panel, it will try to center in the main panel. If
209 // there is no main panel, it will center on screen.
210
211 // if center on parent, use the parent. If there is no parent, try center on panel
212 If (eLocateMode=CENTER_ON_PARENT) Begin
213 Get Parent to hoTarget
214 If (hoTarget<=Desktop) Begin
215 Move CENTER_ON_PANEL to eLocateMode
216 End
217 End
218
219 If (eLocateMode=CENTER_ON_PANEL) Begin
220 Delegate Get Main_Panel_ID to hoTarget
221 // if this does not have a panel, attempt to center on main panel
222 If (hoTarget=0) Begin
223 Get Main_Window of Desktop to hoTarget
224 End
225 End
226
227 // only do this if the object exists and is not the desktop
228 If (hoTarget and hoTarget>Desktop) Begin
229 Get Absolute_GUIOrigin of hoTarget to iLocation
230 Get GuiClientSize of hoTarget to iSize
231 End
232 Else Begin
233 // this is the center on the primary screen and is our fallback position if
234 // the other modes don't work right
235 Get GuiScreen_Size 1 to iSize
236 Move 0 to iLocation
237 End
238
239 // this is the origin row and column of "the containing" object
240 Move (Hi(iLocation)) to iScreenRow
241 Move (Low(iLocation)) to iScreenCol
242 If (iScreenCol > 32767) Begin
243 Move (iScreenCol - 65536 ) to iScreenCol
244 End
245 If (iScreenRow > 32767) Begin
246 Move (iScreenRow - 65536 ) to iScreenRow
247 End
248
249 // this is the height and width of the "containing" object or screen
250 Move (Hi(iSize)) to iScreenHt
251 Move (Low(iSize)) to iScreenWd
252
253 // this is the height and width of the actual object we are locating
254 Get GuiWindowSize to iSize
255 Move (hi(iSize)) to iHeight
256 Move (low(iSize)) to iWidth
257 // ideal location should be in the center
258 Move ( (iScreenHt - iHeight)/2 + iScreenRow) to iRow
259 Move ( (iScreenWd - iWidth)/2 + iScreenCol) to iCol
260
261 // now adjust it to fit
262 Send AdjustForMultiDisplay iHeight iWidth (&iCol) (&iRow)
263
264 Set GuiLocation to iRow iCol
265 Send Adjust_Logicals
266 End_Procedure // Locate_Panel
267
268
269 { Visibility=Private }
270 Procedure Page_Object Integer iState
271 Integer Mode
272 If ( iState and Locate_Mode(Self)<>NO_LOCATE ) ;
273 Send Locate_Panel
274 Forward Send Page_Object iState
275 End_Procedure
276
277End_Class
278
279