HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_HelpManager.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_HelpManager.h
7  *
8  * COMMENTS:
9  * This class allows any code in Houdini to load a help file or display
10  * arbitrary text in a help pane.
11  *
12  * Note that UTgetHelpManager() will return null in applications that
13  * don't support help panes.
14  */
15 
16 #ifndef __UT_HelpManager_h__
17 #define __UT_HelpManager_h__
18 
19 #include "UT_API.h"
20 #include "UT_Assert.h"
21 #include "UT_NonCopyable.h"
22 #include "UT_StringArray.h"
23 #include "UT_StringHolder.h"
24 #include <SYS/SYS_Types.h>
25 
26 class UT_String;
27 class OP_Operator;
28 class OP_Node;
29 class OP_GalleryEntry;
30 class BM_State;
31 class SHLF_Tool;
32 class PRM_Parm;
33 class PRM_ScriptParm;
34 class PYP_Interface;
35 
36 // The help URL protocols used by the help system.
37 #define UT_OP_PROTOCOL_PREFIX "operator:"
38 #define UT_PROP_PROTOCOL_PREFIX "prop:"
39 #define UT_GALLERY_PROTOCOL_PREFIX "gallery:"
40 #define UT_PARM_PROTOCOL_PREFIX "parm:"
41 #define UT_DOC_PROTOCOL_PREFIX "doc:"
42 
43 
45 {
46 public:
48  virtual ~UT_HelpManager();
49 
51 
52  // openContents() will display the help contents page.
53  virtual void openContents() = 0;
54 
55  // openStartup() brings up the special welcome/essential skills page
56  // of help upon startup:
57  virtual void openStartup() = 0;
58 
59  // openFile() and displayData() are the main methods of the help manager
60  // to display help. They will ensure a help browser pane exists and
61  // they will open a text/html file or display text/html data. Note
62  // that both of these methods call clearDesiredHelpLocation() when
63  // they finish. setBaseURI() will set the URI used to resolve links
64  // to other files when html data is passed in with displayData().
65  virtual void openFile(const char *path) = 0;
66  virtual void openURL(const char *url) = 0;
67  virtual void openHelpPath(const char *help_path) = 0;
68  virtual void displayData(const char *data, bool is_html) = 0;
69 
70  /// Obtains a tool tip from the help page pointed to by the URL.
71  virtual bool getTooltip( const char * url, UT_String & tooltip ) =0;
72 
73  /// Obtains a tool tip for the specified parameter.
74  virtual bool getTooltip(
75  const PRM_Parm *parm, UT_String &tooltip)
76  = 0;
77 
78  /// Open the requested tooltip in a popup window.
79  /// You can either pass the tooltip's help URL, the tooltip's help text,
80  /// or both.
81  ///
82  /// x,y,w,h represents the native screen position and size of the
83  /// source feel that the tooltip is for. If there is no source feel,
84  /// then pass in (0,0,0,0) for x,y,w,h.
85  ///
86  /// You can optionally pass in additional information to appear
87  /// in the tooltip -- help title, hotkey symbol, resolved hotkey string.
88  virtual void openTooltipWindow(
89  const char *url, const char *help,
90  int x, int y, int w, int h,
91  const char *title=nullptr,
92  const char *hotkey_symbol=nullptr,
93  const char *hotkey_str=nullptr,
94  bool use_fixed_font=false) const = 0;
95 
96  /// Close all tooltip popup windows.
97  /// Do nothing if there are no open tooltip popup windows.
98  virtual void closeAllTooltipWindows() const = 0;
99 
100  /// Obtains a plain text version of the help page pointed to by the URL
101  /// (e.g. 'vex:attrib').
102  virtual bool getTextHelp(const char *url, UT_String &text_help) = 0;
103 
104  /// Return the text help for the given hscript command.
105  virtual UT_StringHolder getCommandHelp(const char *command) = 0;
106 
107  /// Return the text help for the given hscript expression command.
108  virtual UT_StringHolder getExprCommandHelp(const char *command) = 0;
109 
110  /// Return an array of hscript commands whose text help contain
111  /// a match for the given keyword.
112  virtual UT_StringArray getCommandsForHelpKeyword(const char *keyword) = 0;
113 
114  /// Return an array of hscript expression commands whose text help
115  /// conotain a match for the given keyword.
116  virtual UT_StringArray getExprCommandsForHelpKeyword(
117  const char *keyword) = 0;
118 
119  /// Obtains a tool tip conained by the full help text. The url serves
120  /// as a caching key.
121  virtual bool getParsedTooltip( const char * url_key,
122  const char * full_help,
123  UT_String & tooltip) = 0;
124 
125  // These methods help pop up a helpcard for a specific operator,
126  // state, or tool. The help text associated with the entity can come
127  // from the central help server, or if no such help exists from the
128  // URL provided by the entity or from the text internally defined by the op
129  // (HDA/HDK) or the tool, or from a file on disk associated with the
130  // operator or state.
131  virtual void openHelpCard( OP_Node * node ) = 0;
132  virtual void openHelpCard(
133  OP_Operator * op, const char *node_path=nullptr ) = 0;
134  virtual void openHelpCard( BM_State * state ) = 0;
135  virtual void openHelpCard( SHLF_Tool * tool ) = 0;
136  virtual void openHelpCard( const PYP_Interface * interface ) = 0;
137  virtual void openHelpCard( OP_GalleryEntry * entry ) = 0;
138  virtual void openHelpCard( const PRM_ScriptParm * prop ) = 0;
139 
140  // Obtains a URL that points to the help server web page for the given
141  // operator, state, tool, or topic id.
142  virtual void getHelpCardURL( OP_Operator * op, UT_String & str ) =0;
143  virtual void getHelpCardURL( BM_State * state, UT_String & url ) =0;
144  virtual void getHelpCardURL( SHLF_Tool * tool, UT_String & url ) =0;
145  virtual void getHelpCardURL( const PYP_Interface * interface,
146  UT_String & url ) = 0;
147  virtual void getHelpCardURL( OP_GalleryEntry * entry,
148  UT_String & url ) = 0;
149  virtual void getHelpCardURL( const PRM_ScriptParm * prop,
150  UT_String & url ) = 0;
151  virtual void getHelpCardURL( const char *help_topic_id,
152  UT_String & url ) = 0;
153  virtual void getHelpCardURL( const PRM_Parm * parm,
154  UT_String &url) = 0;
155 
156  virtual void setBaseURI(const char *base_uri) = 0;
157  virtual const UT_String &getBaseURI() const = 0;
158 
159  // Returns true if the help manager is using an external help server.
160  // Returns false otherwise.
161  virtual bool getUseExternalHelp() const = 0;
162 
163  // Sets whether the help manager should use an external help server or not.
164  virtual void setUseExternalHelp(bool use_external) = 0;
165 
166  /// Sets the address the server should bind to.
167  virtual void setHelpAddress(const char* address) = 0;
168  virtual const UT_StringHolder& getHelpAddress() const = 0;
169 
170  /// Whether the help server should use ipv6 or not.
171  virtual void setUseIPv6(bool use_ipv6) = 0;
172  virtual bool getUseIPv6() const = 0;
173 
174  // Returns the base url for the external help server.
175  // Returns "" if no external help server is used.
176  virtual const UT_String &getExternalHelpURL() const = 0;
177 
178  // Sets the url to the external help server.
179  virtual void setExternalHelpURL(const char *ext_help_url) = 0;
180 
181  // Returns the base URL for all of Houdini's help.
182  virtual const UT_String &getHelpBaseURL() = 0;
183 
184  // Returns the url for the help startup page.
185  virtual const UT_String &getStartupURL() = 0;
186 
187  // By setting the desired help location, any calls to openFile() or
188  // displayData() that need to create a floating pane will create it
189  // near the specified location. Typically, the location is the mouse
190  // location when the help button was pressed. Call
191  // clearDesiredHelpLocation() after the call to openFile() or displayData().
192  void setDesiredHelpLocation(fpreal x, fpreal y);
193  void clearDesiredHelpLocation();
194 
195  // When the help is displayed in a floating pane, the floating pane gets
196  // a unique id. When there is no floating help pane, the floating help
197  // pane id is 0. This help pane id lets the op help buttons decide
198  // whether to display the help for an op or close the floating help pane.
199  void setFloatingHelpPaneId(int pane_id)
200  { myFloatingHelpPaneId = pane_id; }
202  { return myFloatingHelpPaneId; }
203  virtual void closeFloatingPane() = 0;
204 
205  // Does this platform support html help? This method is static so it
206  // can be called from a non-graphical program, since UTsetHelpManager()
207  // may not have been called.
208  static bool platformSupportsHtmlHelp();
209 
210  /// Concatenates the operator table name, operator type name, some
211  /// extra information into a help URL.
212  static void constructOpBasedURL( const char *protocol,
213  const char *optable, const char *optype,
214  const char *extra, UT_String &url);
215 
216  /// Parses the help URL into the operator table name, operator type name,
217  /// extra info string, given the url and the required protocol prefix.
218  /// Returns true on success, and false otherwise.
219  static bool parseOpBasedURL( const char * url,
220  const char *protocol,
221  UT_String &optable, UT_String &optype,
222  UT_String &extra );
223 
224  // These methods are used by UTgetHelpManager() and UTsetHelpManager().
225  // You should never have to call them directly.
226  static UT_HelpManager *getHelpManager() { return ourHelpManager; }
227  static void setHelpManager(UT_HelpManager *help_manager);
228 
229 protected:
230  // This method is used by subclasses to determine if and where to position
231  // the help location.
232  bool getDesiredHelpLocation(float &x, float &y);
233 
234 private:
235  static UT_HelpManager *ourHelpManager;
236 
237  float myDesiredHelpLocationX;
238  float myDesiredHelpLocationY;
239  int myFloatingHelpPaneId;
240 };
241 
242 static inline UT_HelpManager *UTgetHelpManager()
243 { return UT_HelpManager::getHelpManager(); }
244 
245 static inline void UTsetHelpManager(UT_HelpManager *help_manager)
246 { UT_HelpManager::setHelpManager(help_manager); }
247 
248 #endif
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
void setFloatingHelpPaneId(int pane_id)
#define UT_API
Definition: UT_API.h:14
GLint y
Definition: glcorearb.h:103
std::string help(const App *app, const Error &e)
Printout the full help string on error (if this fn is set, the old default for CLI11) ...
Definition: CLI11.h:8978
static UT_HelpManager * getHelpManager()
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
GLint GLenum GLint x
Definition: glcorearb.h:409
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
fpreal64 fpreal
Definition: SYS_Types.h:283
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
int getFloatingHelpPaneId() const
state
Definition: core.h:2289
static void setHelpManager(UT_HelpManager *help_manager)
Definition: format.h:1821