00001 // $Id: ctrlhelp.h 1282 2006-06-09 09:46:49Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 00099 // Code to modify the behaviour of controls on Camelot bars so that they respond 00100 // to help messages and can be dragged about etc. 00101 00102 #ifndef INC_CTRLHELP 00103 #define INC_CTRLHELP 00104 00105 //#include "monotime.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00106 00107 class OpDescriptor; 00108 class ControlTable; 00109 class BarTable; 00110 class BubbleHelpWnd; 00111 00112 #define COMMIT 2 00113 00114 /******************************************************************************************** 00115 00116 > class ControlHelpInfo 00117 00118 Author: Tim_Browse (Xara Group Ltd) <camelotdev@xara.com> 00119 Created: 10/05/94 00120 Purpose: Used to specify details of a control that is to be added to the list of 00121 sub-classed controls. The fields are: 00122 MonoOn 00123 pOpDesc - pointer to the OpDescriptor for this control. 00124 If this field is non-NULL, then all the ID fields are ignored. 00125 Id this field is NULL, then the ID fields are used to define the 00126 bubble help text and status bar text to be displayed for this 00127 control. 00128 BubbleID - ID of the string resource to be used for bubble help. 00129 StatusID - ID of the string resource to be used for status bar text. 00130 ModuleID - defines where to find the above resources. 00131 Parent - internal use; any value you put in here will be ignored. 00132 MonoOff 00133 SeeAlso: ControlHelper::NotifyControlCreated 00134 00135 ********************************************************************************************/ 00136 00137 class ControlHelpInfo 00138 { 00139 public: 00140 OpDescriptor* pOpDesc; 00141 UINT32 BubbleID; 00142 UINT32 StatusID; 00143 UINT32 ModuleID; 00144 wxWindow* Parent; 00145 }; 00146 00147 /******************************************************************************************** 00148 00149 < BubbleHelpCallback 00150 00151 Author: Tim_Browse (Xara Group Ltd) <camelotdev@xara.com> 00152 Comment: This is a function that is called by the bubble help system when providing 00153 'ad-hoc' bubble help on a window, i.e. not on 'real' controls, but on 00154 GUI elements which may be just rendered, e.g. the colour bar uses this 00155 facility. 00156 You pass a function of this type into ControlHelper::DoBubbleHelpOn(), and 00157 this function is called back when the bubble help needs to be displayed. 00158 You should return a pointer to the bubble help text to display. 00159 00160 MonoOn 00161 typedef TCHAR *(*BubbleHelpCallback)(wxWindow*, UINT32, void*); 00162 MonoOff 00163 00164 The parameters provide context information for the callback as there is 00165 usually a delay between calling DoBubbleHelpOn(), and the callback being 00166 called (because there is a short time delay before bubble help appears). 00167 00168 Inputs: wxWindow* - the handle of the window that bubble help is being provided on. 00169 UINT32 - the 'psuedo-ID' you passed in to DoBubbleHelpOn() which indicates 00170 which GUI element in the window that bubble help is being provided 00171 for. This number is determined by you - it means nothing to the 00172 bubble help system, apart from when it does an equality check to 00173 see if the user has moved onto another GUI element in your window. 00174 void* - an arbitrary piece of data associated with you system which may 00175 provide more assistance in working out the context of the call. 00176 This data is the data you pass in to DoBubbleHelpOn. 00177 00178 SeeAlso: ControlHelper::DoBubbleHelpOn 00179 00180 ********************************************************************************************/ 00181 00182 00183 /******************************************************************************************** 00184 00185 > class ControlHelper : public SimpleCCObject 00186 00187 Author: Tim_Browse (Xara Group Ltd) <camelotdev@xara.com> 00188 Created: 01/07/94 00189 Purpose: Provide a system for subclassing controls on Camelot bars which offers 00190 various facilities such as bubble help/status bar text and commit handling. 00191 To use this system you use the Notifyxxx() functions to keep the class up 00192 to date with which bars/controls exist. This module will subclass these 00193 controls and do some preprocessing of Windows messages in order to do 00194 bubble help/commit handling etc. 00195 You can 'fake' bubble help on a window that doesn't really have controls 00196 in it, by using the 'ad-hoc' bubble help function, DoBubbleHelpOn(). 00197 SeeAlso: ControlHelpInfo; 00198 ControlHelper::NotifyBarCreated; ControlHelper::NotifyBarDeleted; 00199 ControlHelper::NotifyBarChanged; 00200 ControlHelper::NotifyControlCreated; ControlHelper::NotifyControlDeleted 00201 ControlHelper::DoBubbleHelpOn 00202 00203 ********************************************************************************************/ 00204 00205 class ControlHelper : public SimpleCCObject 00206 { 00207 public: 00208 // Interface for use by the routines that manage bars + child controls. 00209 static BOOL Init(); 00210 static void DeInit(); 00211 00212 static BOOL NotifyBarCreated(wxWindow*); 00213 static BOOL NotifyBarDeleted(wxWindow*); 00214 static BOOL NotifyBarChanged(wxWindow* Old, wxWindow* New); 00215 static BOOL NotifyControlCreated(wxWindow*, ControlHelpInfo*); 00216 static BOOL NotifyControlCreated(wxWindow*, OpDescriptor*); 00217 static BOOL NotifyControlDeleted(wxWindow*); 00218 00219 // Allow the control Bubble help to be changed on the fly 00220 static BOOL NotifyControlChanged(wxWindow*, ControlHelpInfo*); 00221 00222 typedef TCHAR *(*BubbleHelpCallback)(wxWindow*, UINT32, void*); 00223 00224 static void DoBubbleHelpOn(wxWindow*, UINT32, BubbleHelpCallback, void*); 00225 00226 static void ServiceBubbleHelp(); 00227 static void BubbleHelpDisable(); 00228 00229 static void InformModalDialogOpened(); 00230 static void InformModalDialogClosed(); 00231 static BOOL GetStatusLineText(String_256* ptext, wxWindow* window); 00232 00233 static BOOL IsUserInterfaceCaptured(); 00234 00235 private: 00236 static void BubbleHelpKill(); 00237 00238 static BOOL AddControl(wxWindow*, ControlHelpInfo *); 00239 static ControlTable *Controls; 00240 static BarTable *Bars; 00241 static BubbleHelpWnd *BubbleWnd; 00242 00243 static LRESULT CALLBACK MyWndProc(wxWindow*, UINT32, WPARAM, LPARAM); 00244 static MonotonicTime PendingTimer; 00245 static POINT LastPos; 00246 static wxWindow* LastControl; 00247 static BOOL ControlHasFocus; 00248 00249 static wxWindow* AdHocWindow; 00250 static UINT32 AdHocControl; 00251 static BOOL AdHocControlIsDifferent; 00252 static void *AdHocReference; 00253 static BubbleHelpCallback AdHocCallback; 00254 00255 typedef enum 00256 { 00257 00258 STATE_DEAD, // No bubble help is displayed - cursor is not over a 00259 // a bar or a control. 00260 00261 STATE_ACTIVE, // Bubble help is displayed - cursor is over a control. 00262 00263 STATE_INITIAL_PENDING, // Waiting to show bubble help for the first time - the 00264 // cursor is over a control. 00265 00266 STATE_UPDATE_PENDING, // Waiting to display help for a different control - i.e. 00267 // the user has moved from one control to another, 00268 // possible via a bar (STATE_DISABLED). 00269 00270 STATE_INITIAL_DISABLED, // Pointer is over bar, but no help has yet been displayed 00271 // during this session. 00272 00273 STATE_DISABLED // Pointer over bar, and bubble help has been displayed 00274 // during this session. 00275 00276 } BubbleState; 00277 00278 static BubbleState BubbleHelpState; 00279 00280 // Number of modal dialogs open (that are NOT managed by the kernel dialog manager) 00281 static INT32 ModalDialogs; 00282 00283 // State control functions 00284 PORTNOTE( "dialog", "Remove function that needs WNDPROC" ) 00285 #if 0 00286 static void BubbleHelpStateMachine(POINT Pos, wxWindow* ThisControl, WNDPROC WndProc); 00287 #endif 00288 static void SetState(BubbleState NewState, wxWindow* Window = NULL); 00289 static void DeadHandler(); 00290 static void ActiveHandler(wxWindow* Window); 00291 static void InitialPendingHandler(); 00292 static void InitialDisabledHandler(); 00293 static void UpdatePendingHandler(); 00294 static void DisabledHandler(); 00295 }; 00296 00297 00298 00299 /******************************************************************************************** 00300 00301 > class ControlEntry 00302 00303 Author: Tim_Browse (Xara Group Ltd) <camelotdev@xara.com> 00304 Created: 26/04/94 00305 Purpose: Contains the information for a particular control. 00306 The data members are: 00307 MonoOn 00308 wxWindow* Window - the handle of the control. 00309 OpDescriptor *pOpDesc - pointer to the OpDescriptor associated with this 00310 control. 00311 WNDPROC WndProc - pointer to the normal WndProc for the subclassed control. 00312 MonoOff 00313 SeeAlso: ControlTable; ControlHelper 00314 00315 ********************************************************************************************/ 00316 00317 class ControlEntry 00318 { 00319 public: 00320 wxWindow* Window; // Handle of the control being sublassed (may be a subwindow of 00321 // a control). 00322 wxWindow* Parent; // Not necessarily the immediate parent - just the handle of the 00323 // parent control, or none if this *is* the parent control. 00324 OpDescriptor *pOpDesc; // The OpDescriptor for this control, or NULL if there isn't one. 00325 UINT32 BubbleID; // String resource ID for bubble help. 00326 UINT32 StatusID; // String resource ID for status bar text. 00327 UINT32 ModuleID; // Module ID to be used when loading bubble help/status 00328 // bar string resources. 00329 PORTNOTE( "dialog", "Remove WNDPROC usage" ) 00330 #if 0 00331 WNDPROC WndProc; // Normal WndProc for this control. 00332 #endif 00333 00334 BOOL AddCommitHandling; // This flag is set to TRUE if the control is an edit or a combo 00335 // it is used in the subclass procedure to determine if we 00336 // should respond to Enter and Tab keys being pressed 00337 // - Added by Simon (08/06/94) 00338 BOOL ControlStatusLineText(String_256* text); 00339 }; 00340 00341 00342 /******************************************************************************************** 00343 00344 > class ControlTable : public SimpleCCObject 00345 00346 Author: Tim_Browse (Xara Group Ltd) <camelotdev@xara.com> 00347 Created: 26/04/94 00348 Purpose: Stores/manipulates an array of ControlEntry objects, in order to keep 00349 track of all the controls we have currently subclassed. 00350 SeeAlso: ControlEntry; ControlHelper 00351 00352 ********************************************************************************************/ 00353 00354 class ControlTable : public SimpleCCObject 00355 { 00356 public: 00357 ControlTable(); 00358 ~ControlTable(); 00359 BOOL Init(); 00360 00361 PORTNOTE( "dialog", "Remove function that needs WNDPROC" ) 00362 #if 0 00363 BOOL AddControl(wxWindow*, ControlHelpInfo*, WNDPROC); 00364 WNDPROC DeleteControl(wxWindow* Window, wxWindow* *RealWindow); 00365 #endif 00366 ControlEntry *FindControl(wxWindow* Window); 00367 BOOL ChangeControl(wxWindow*, ControlHelpInfo*); 00368 00369 private: 00370 INT32 FindControlIndex(wxWindow* Window, BOOL IgnoreChildren = TRUE); 00371 00372 enum 00373 { 00374 NotFound = -1, 00375 EmptySlot = 0, 00376 Granularity = 30, 00377 InitialSize = 100 00378 }; 00379 00380 ControlEntry *Table; 00381 INT32 TableSize; 00382 00383 // State information - used when scanning the table for controls. 00384 wxWindow* LastWindow; 00385 INT32 LastIndex; 00386 }; 00387 00388 #endif 00389