InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IWidgetUtils.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: lance bushore
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // ADOBE CONFIDENTIAL
24 //
25 //========================================================================================
26 
27 #ifndef __IWidgetUtils__
28 #define __IWidgetUtils__
29 
30 #include "widgetid.h"
31 #include "IPMUnknown.h"
32 #include "PMPoint.h"
33 #include "PMRect.h"
34 #include "InterfaceFontInfo.h"
35 #include "IEvent.h"
36 #include "Utils.h"
37 #include "IInterfaceColors.h"
38 #include "IDResourceShell.h"
39 
40 class IControlView;
41 class IDialog;
43 class IEventHandler;
44 class IGraphicsContext;
45 class IGraphicsPort;
46 class IPanelControlData;
47 class IPMFont;
48 class IUIColorSpec;
49 class IEventHandler;
50 class IKeyFocusHandler;
51 class IWindow;
52 
53 #ifdef WASM
54 #include "WasmDrawbot.h"
55 #else
56 #include "DVAForwardDeclarations.h"
57 #endif
58 
60 {
61 public:
62  RoundedRectAppearance (const IControlView* controlView, PMReal radius, PMReal lineWidth, RealAGMColor strokeColor,
63  RealAGMColor fillColor, bool16 isRolledOverButton, RealAGMColor upperStrokeColor,
64  RealAGMColor lowerStrokeColor, PMReal inset = 1.0, bool16 isMoveReqd = kTrue) :
65  fControlView(controlView),
66  fRadius(radius),
67  fLineWidth(lineWidth),
68  fStrokeColor(strokeColor),
69  fFillColor(fillColor),
70  fIsRolledOverButton(isRolledOverButton),
71  fUpperStrokeColor(upperStrokeColor),
72  fLowerStrokeColor(lowerStrokeColor),
73  fInset(inset),
74  fIsMoveReqd(isMoveReqd)
75  {
76  ASSERT(controlView);
77  }
78 
79  RoundedRectAppearance (const IControlView* controlView, PMReal radius, PMReal lineWidth, int32 strokeColorIndex,
80  int32 fillColorIndex, bool16 isRolledOverButton, int32 upperStrokeColorIndex,
81  int32 lowerStrokeColorIndex, PMReal inset = 1.0, bool16 isMoveReqd = kTrue) :
82  fControlView(controlView),
83  fRadius(radius),
84  fLineWidth(lineWidth),
85  fIsRolledOverButton(isRolledOverButton),
86  fInset(inset),
87  fIsMoveReqd(isMoveReqd)
88  {
89  ASSERT(controlView);
90 
91  RealAGMColor color;
92 
93  InterfacePtr<IInterfaceColors> colors(GetExecutionContextSession(), UseDefaultIID());
94 
95  colors->GetRealAGMColor(strokeColorIndex, fStrokeColor);
96  colors->GetRealAGMColor(fillColorIndex, fFillColor);
97  colors->GetRealAGMColor(lowerStrokeColorIndex, fLowerStrokeColor);
98  colors->GetRealAGMColor(upperStrokeColorIndex, fUpperStrokeColor);
99  }
100 
101  const IControlView* fControlView;
102  PMReal fInset;
103  PMReal fRadius;
104  PMReal fLineWidth;
105  RealAGMColor fStrokeColor;
106  RealAGMColor fFillColor;
107  bool16 fIsRolledOverButton;
108  RealAGMColor fUpperStrokeColor;
109  RealAGMColor fLowerStrokeColor;
110  bool16 fIsMoveReqd;
111 };
112 
117 typedef enum {
118  kCanDraw,
119  kCanDrawLocaleText,
120  kCannotDraw,
121  kDrawWithStandardFont
122 } DrawStatus;
123 
124 class IWidgetUtils : public IPMUnknown
125 {
126 public:
127  enum { kDefaultIID = IID_IWIDGETUTILS };
133  virtual SysPoint ConvertPointToLocalWindow(const PMPoint& mouseLocationInParentWindowCoords, IControlView* destinationView) = 0;
134 
141  virtual IPMUnknown* QueryRelatedWidget(const IPMUnknown* widget, const WidgetID& widgetId, const PMIID& iid) = 0;
142 
148  virtual const InterfaceFontInfo GetAppropriateFontForWidget(const IControlView* widget) = 0;
149 
154  virtual const IUIColorSpec* QueryColorSpecForWidget(const IPMUnknown* widget) = 0;
155 
161  virtual void GrayOutFrameContents (IGraphicsPort *gc, PMRect frame, PMReal transparency) = 0;
162 
170  virtual void DrawPaletteFill(const IControlView* widget, dvaui::drawbot::Drawbot * pDrawbot, const PMRect *rectToFill = nil) = 0;
171 
177  virtual void DrawPaletteFill (const IControlView* widget,IGraphicsPort * port, const PMRect* rectToFill = nil) = 0;
178 
179  // moved from GridPanelUtils.h
180  virtual void GridPanel_PositionWidgets(IPanelControlData* panel, int32 first, int32 last) = 0;
181 
182  virtual void DeleteWidgetAndChildren(IControlView* widgetToDelete) = 0;
183 
188  virtual void StripUserDecimal(PMString* string) = 0;
189 
194  virtual void FormatUserDecimal(PMString* string) = 0;
195 
199  virtual void StripAccelerators(PMString &rawString) = 0;
200 
206  virtual void GetFormattedString(const PMReal& value, const bool16& bHorizontal, PMString& outString) = 0;
207 
214  virtual void GetFormattedScalingString(const PMReal& value, PMString& outString, const bool16 bFormatWithParens) = 0;
215 
216 #ifdef MACINTOSH
217  virtual void BringFinderToFront(void) = 0;
218  virtual void SynchDocumentProxyIcons(bool16 forceValidation = kFalse) = 0;
219 #endif
220 
221  virtual PMReal GetViewYPosition(IGraphicsContext* gc, const InterfaceFontInfo &fontInfo, const PMReal &height) = 0;
222 
227  virtual void SimulateClick(IEventHandler* targetEH) = 0;
228 
234  virtual void CombineRegions(IControlView* widget, SysWireframe& theRgn) const = 0;
235 
241  virtual void DrawFocusRect(IControlView* view, const PMRect& r, bool16 flushDrawing) = 0;
242 
250 #define kDefaultHiliteThickness 2.0
251  virtual bool16 DrawHiliteRect(IControlView* view, const PMRect& r, bool16 flushDrawing = kTrue, PMReal hiliteThickness = kDefaultHiliteThickness) = 0;
252 
260  virtual bool16 DrawHilitePath(IControlView* view, const PMPointList& pts, bool16 flushDrawing = kTrue, PMReal hiliteThickness = kDefaultHiliteThickness) = 0;
261 
269  virtual bool16 DrawHilitePath(IControlView* view, const PMPointListCollection& subPaths, bool16 flushDrawing = kTrue, PMReal hiliteThickness = kDefaultHiliteThickness) = 0;
270 
277  virtual bool16 DrawHilitePath(IControlView* view, SysWireframe hilitePath, bool16 flushDrawing = kTrue, PMReal hiliteThickness = kDefaultHiliteThickness) = 0;
278 
285  virtual bool16 FillHiliteRect(IControlView* view, const PMRect& r, bool16 flushDrawing = kTrue) = 0;
286 
293  virtual bool16 FillHilitePath(IControlView* view, const PMPointListCollection& subPaths, bool16 flushDrawing = kTrue) = 0;
294 
295 
300  virtual void SetTextHighlightColor(IGraphicsPort *gPort, const IControlView *view) = 0;
301 
306  virtual bool16 IsWidgetInPalette(const IControlView* iWidget) = 0;
307 
316  virtual bool16 CopyBitsToView(IControlView* view, const Int32Rect& dstBounds, IDVPlatformOffscreen* srcOffscreen, const Int32Rect& srcBounds,
317  const PMMatrix& clip2destMatrix = PMMatrix(), const SysRgn clipRgn = nil) = 0;
318 
323  virtual PMReal GetViewScaleFactorReal(const IControlView* view) = 0;
324 
330  virtual void DrawRoundedRect(dvaui::drawbot::Drawbot *drawBotP, const RoundedRectAppearance& roundedRectAppearance) = 0;
331 
337  virtual void DrawLeftRoundedRect(dvaui::drawbot::Drawbot *drawBotP, const RoundedRectAppearance& roundedRectAppearance) = 0;
338 
344  virtual void DrawRightRoundedRect(dvaui::drawbot::Drawbot *drawBotP, const RoundedRectAppearance& roundedRectAppearance) = 0;
345 
353  virtual bool16 IsClusterControllableChildWidget(IControlView* widget, bool16& isSelected, bool16 checkParentToBeCluster = kFalse) = 0;
354 
361  virtual IPMUnknown* QueryDescendentWidgetOfType(IPMUnknown* widget, PMIID interfaceID) = 0;
362 
375  virtual IDialog* CreateContextUI(const RsrcSpec& rSpec,
376  const PMRect& globalAnchorRect,
377  const ClassID& popupWindowClass = kPopupWindowBoss,
378  bool16 preferredtoBeDrawnOnLeft = kFalse,
379  bool16 invokedFromPalette = kFalse,
380  bool16 okToCacheDialog = kFalse,
381  bool16 openImmediately = kTrue) = 0;
382 
394  virtual IDialog* CreateContextUI_Generic(const RsrcSpec& rSpec, const PMRect& globalAnchorRect, const ClassID& popupWindowClass = kPopupWindowBoss,
395  bool16 preferredtoBeDrawnOnLeft = kFalse, bool16 invokedFromPalette = kFalse, bool16 okToCacheDialog = kFalse, bool16 openImmediately = kTrue) = 0;
396 
405  virtual void RepositionAndShowContextUIPopup(IWindow* popupWindow,
406  bool16 showWindow = kTrue,
407  const PMRect& globalAnchorRect = kZeroRect,
408  bool16 inFront = kTrue) = 0;
409 
410  /*
411  Gets the effective icon rsrcID after adding the appropriate offset if applicable
412  @param uiScale The scale factor in which to load the icon.
413  @param baseRsrcID The base icon rsrcID to which offset is added.
414  @return The effective rsrcID after adding the offset depending upon the scaleFactor.
415  */
416  virtual RsrcID GetEffectiveIconRsrcID(float uiSCale, RsrcID baseRsrcID) = 0;
417 
418  /*
419  Fallback logic which decides which icon is loaded based on various factors.
420  @param pluginID The plugin of the resource being considered.
421  @param rsrcType The type of the resource , whether it is kPNGArtRsrcType etc.
422  @param rscID The base rscID for the icon.
423  @param iconRsrcID The rsrcID for which the try is made to load the icon before invoking fallback logic.
424  @param iconScale The desired scaleFactor in which the icon is tried to be loaded.
425  @param loadedIconScale The actual scaleFactor for which the icon is loaded after executing the fallback logic.
426  @return The icon resource is returned.
427  */
428  virtual IDResource SetIconDimensions(PluginID pluginID, RsrcType rsrcType, RsrcID rscID, RsrcID iconRsrcID, float iconScale, float* loadedIconScale) = 0;
429 
435  virtual void DrawTopRoundedRect(dvaui::drawbot::Drawbot *drawBotP, const RoundedRectAppearance& roundedRectAppearance) = 0;
436 
443  virtual DrawStatus CanDrawSampleText(IPMFont* font, PMString &stringToDraw, float fontSize) = 0;
444 
451  virtual DrawStatus CanTQDrawSampleText(std::string fontName, PMString &stringToDraw, float fontSize) = 0;
452 
459  virtual std::string GetImageName(PluginID pluginID, RsrcType rsrcType, RsrcID iconRsrcID) = 0;
460 
461  /*
462  Fallback logic which decides which icon is loaded based on various factors.
463  @param pluginID The plugin of the resource being considered.
464  @param iconRsrcID The icon resource ID for the icon.
465  @param outRsrcType The type of the resource , whether it is kPNGArtRsrcType etc.
466  @param outImageName The image name of the icon set by the function
467  @param iconScale The desired scaleFactor in which the icon is tried to be loaded.
468  @param loadedIconScale The actual scaleFactor for which the icon is loaded after executing the fallback logic.
469  @param isDark Whether dark icon should be loaded.
470  @return The icon resource is returned.
471  */
472  virtual IDResource LoadIconResource(PluginID pluginID, RsrcID iconRsrcID, RsrcType &outRsrcType, std::string &outImageName, float iconScale, float &loadedIconScale, bool16 isDark=kFalse) = 0;
473 
477  virtual float GetBoundingBoxScaleFactor() = 0;
478 
485  virtual PMReal GetEffectiveScaleFactor(const IControlView* view) = 0;
486 };
487 
488 #endif // __IWidgetUtils__