Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1224 lines
27 KiB

  1. //
  2. // GROBJ.CPP
  3. // Graphic Object Classes
  4. //
  5. // Copyright Microsoft 1998-
  6. //
  7. #ifndef __GROBJ_HPP_
  8. #define __GROBJ_HPP_
  9. #define HIT_WINDOW 1
  10. #define MAKE_HIT_RECT(r, p ) \
  11. ::SetRect(&r, p.x-HIT_WINDOW, p.y-HIT_WINDOW, p.x+HIT_WINDOW, p.y+HIT_WINDOW);
  12. //
  13. // Marker definitions
  14. //
  15. #define NO_HANDLE -1
  16. #define TOP_LEFT 0
  17. #define TOP_MIDDLE 1
  18. #define TOP_RIGHT 2
  19. #define RIGHT_MIDDLE 3
  20. #define BOTTOM_RIGHT 4
  21. #define BOTTOM_MIDDLE 5
  22. #define BOTTOM_LEFT 6
  23. #define LEFT_MIDDLE 7
  24. //
  25. // Definitions for text objects
  26. //
  27. #define LAST_LINE -1
  28. #define LAST_CHAR -2
  29. //
  30. // Maximum number of points in a freehand object - determined by the fact
  31. // that pointCount is held in a TSHR_UINT16 in WB_GRAPHIC_FREEHAND (awbdef.h)
  32. //
  33. #define MAX_FREEHAND_POINTS 65535
  34. BOOL EllipseHit(LPCRECT lpEllipseRect, BOOL bBorderHit, UINT uPenWidth, LPCRECT lpHitRect );
  35. // Class to simulate CMapPtrToPtr but based on a linked list instead of the order-jumbling
  36. // hashing method. This is the major cause of bug 354. I'm doing this instead of just replacing
  37. // CMapPtrToPtr because it is used in a zillion places and I want to minimize changes to the
  38. // multi-object select logic so that I don't break it.
  39. class CPtrToPtrList : public COBLIST
  40. {
  41. public:
  42. CPtrToPtrList( void );
  43. ~CPtrToPtrList(void);
  44. void SetAt( void *key, void *newValue );
  45. BOOL RemoveKey( void *key );
  46. void RemoveAll( void );
  47. void GetNextAssoc( POSITION &rNextPosition, void *&rKey, void *&rValue ) ;
  48. BOOL Lookup( void *key, void *&rValue );
  49. protected:
  50. struct stPtrPair
  51. {
  52. void *pMainThing;
  53. void *pRelatedThing;
  54. };
  55. stPtrPair *FindMainThingPair( void *pMainThing, POSITION *pPos );
  56. };
  57. //
  58. //
  59. // Class: DCWbGraphic
  60. //
  61. // Purpose: Base graphic object class
  62. //
  63. //
  64. class WbDrawingArea;
  65. enum
  66. {
  67. enumGraphicMarker,
  68. enumGraphicFreeHand,
  69. enumGraphicFilledRectangle,
  70. enumGraphicFilledEllipse,
  71. enumGraphicText,
  72. enumGraphicDIB,
  73. enumGraphicPointer,
  74. enumNoGraphicTool
  75. };
  76. class DCWbGraphic
  77. {
  78. public:
  79. //
  80. // Static graphic construction routines - return a pointer to a graphic
  81. // of the relevant type given a page and graphic handle or a pointer to
  82. // a flat graphic representation.
  83. //
  84. static DCWbGraphic* ConstructGraphic(WB_PAGE_HANDLE hPage,
  85. WB_GRAPHIC_HANDLE hGraphic);
  86. static DCWbGraphic* ConstructGraphic(PWB_GRAPHIC pHeader);
  87. static DCWbGraphic* ConstructGraphic(WB_PAGE_HANDLE hPage,
  88. WB_GRAPHIC_HANDLE hGraphic,
  89. PWB_GRAPHIC pHeader);
  90. static DCWbGraphic* CopyGraphic(PWB_GRAPHIC pHeader);
  91. //
  92. // Constructor.
  93. //
  94. DCWbGraphic(PWB_GRAPHIC pHeader = NULL);
  95. DCWbGraphic(WB_PAGE_HANDLE hPage, WB_GRAPHIC_HANDLE _hGraphic);
  96. virtual ~DCWbGraphic( void );
  97. virtual UINT IsGraphicTool(void) = 0;
  98. //
  99. // Get/set the bounding rectangle of the graphic object (in logical
  100. // co-ordinates).
  101. //
  102. virtual void GetBoundsRect(LPRECT lprc) { *lprc = m_boundsRect; }
  103. virtual void SetBoundsRect(LPCRECT lprc);
  104. //
  105. // Get the size of the object
  106. //
  107. virtual int Width(void) { return(m_boundsRect.right - m_boundsRect.left); }
  108. virtual int Height(void) { return(m_boundsRect.bottom - m_boundsRect.top); }
  109. //
  110. // Get/set the defining rectangle of the graphic - this is only set up
  111. // for some object types e.g. rectangles and ellipses.
  112. //
  113. virtual LPCRECT GetRect(void) const { return(&m_rect); }
  114. virtual void SetRect(LPCRECT lprc);
  115. virtual void SetRectPts(POINT ptStart, POINT ptEnd);
  116. //
  117. // Get/set the color the object will be drawn in
  118. //
  119. virtual void SetColor(COLORREF clr);
  120. virtual COLORREF GetColor(void) //CHANGED BY RAND for PALETTERGB
  121. { return( SET_PALETTERGB(m_clrPenColor ) ); }
  122. //
  123. // Get/set the width of the pen used to draw the object
  124. //
  125. virtual void SetPenWidth(UINT uiWidth);
  126. virtual UINT GetPenWidth(void) { return m_uiPenWidth; }
  127. //
  128. // Get/set the raster op to be used to draw the object
  129. //
  130. virtual void SetROP(int iPenROP);
  131. virtual int GetROP(void) { return m_iPenROP; }
  132. //
  133. // Get/set the pen style
  134. //
  135. virtual void SetPenStyle(int iPenStyle);
  136. virtual int GetPenStyle(void) { return m_iPenStyle; }
  137. //
  138. // Translates the graphic object by the x and y values of the point
  139. // parameter.
  140. //
  141. virtual void MoveBy(int cx, int cy);
  142. //
  143. // Set the top left corner of the object's bounding rectangle to the
  144. // point specified as parameter.
  145. //
  146. virtual void MoveTo(int x, int y);
  147. //
  148. // Return the top left corner of the objects bounding rectangle.
  149. //
  150. virtual void GetPosition(LPPOINT lpt);
  151. //
  152. // Return TRUE if the specified point is inside the bounding rectangle
  153. // of the graphic object.
  154. //
  155. virtual BOOL PointInBounds(POINT pt);
  156. //
  157. // Draw the graphic object into the device context specified.
  158. //
  159. virtual void Draw(HDC hDC)
  160. {return;}
  161. virtual void Draw(HDC hDC, WbDrawingArea * pDrawingArea)
  162. { Draw(hDC); }
  163. virtual void Draw(HDC hDC, BOOL thumbNail)
  164. { Draw(hDC); }
  165. //
  166. // Return the page of the graphic object
  167. //
  168. virtual WB_PAGE_HANDLE Page(void) const { return m_hPage; }
  169. //
  170. // Return the handle of the graphic object
  171. //
  172. virtual WB_GRAPHIC_HANDLE Handle(void) const { return m_hGraphic; }
  173. virtual void ZapHandle(void) {m_hGraphic = NULL;}
  174. //
  175. // Return TRUE if the graphic is topmost on its page
  176. //
  177. virtual BOOL IsTopmost(void);
  178. //
  179. // Update the external version of the graphic
  180. //
  181. virtual void ForceReplace(void);
  182. virtual void Replace(void);
  183. virtual void ForceUpdate(void);
  184. virtual void Update(void);
  185. virtual void Delete(void);
  186. //
  187. // Confirm an update or delete of the graphic
  188. //
  189. virtual void ReplaceConfirm(void);
  190. virtual void UpdateConfirm(void);
  191. virtual void DeleteConfirm(void);
  192. virtual BOOL CheckReallyHit(LPCRECT pRectHit)
  193. {
  194. RECT rcT;
  195. return(!IntersectRect(&rcT, &m_boundsRect, pRectHit));
  196. }
  197. //
  198. // Lock and unlock the graphic - the lock or unlock will only take
  199. // effect the next time the graphic is updated or replaced.
  200. //
  201. void Lock(void);
  202. void Unlock(void);
  203. BOOL Locked(void) { return (m_uiLockState == WB_GRAPHIC_LOCK_REMOTE); }
  204. BOOL GotLock(void) { return (m_uiLockState == WB_GRAPHIC_LOCK_LOCAL); }
  205. void ClearLockFlag(void) {m_uiLockState = WB_GRAPHIC_LOCK_NONE;}
  206. UINT GetLockState( void )
  207. {return( m_uiLockState );}
  208. void SetLockState( UINT uLock )
  209. {m_uiLockState = uLock;}
  210. //
  211. // Add this graphic to the specified page. This member must only be
  212. // called if the graphic does not yet belong to a page (i.e. if
  213. // hGraphic is NULL).
  214. //
  215. virtual void AddToPageLast(WB_PAGE_HANDLE hPage);
  216. //
  217. // Return a copy of the graphic - this is a complete copy with all
  218. // data read into internal memory.
  219. //
  220. virtual DCWbGraphic* Copy(void) const;
  221. //
  222. // Return TRUE if the graphic has changed since it was last read/written
  223. // from external storage.
  224. //
  225. virtual BOOL Changed(void) const { return m_bChanged; }
  226. //
  227. // Get/set the type of tool which drew the graphic, or at least one
  228. // which can be used to manipulate it.
  229. //
  230. void GraphicTool(int toolType)
  231. { m_toolType = toolType; m_bChanged = TRUE; }
  232. int GraphicTool(void) { return m_toolType; }
  233. //
  234. // Return the length of the external representation of the object
  235. //
  236. DWORD ExternalLength(void)
  237. {return(m_dwExternalLength );}
  238. protected:
  239. //
  240. // Initialize the member variables
  241. //
  242. virtual void Initialize(void);
  243. //
  244. // Bounding rectangle calculation
  245. //
  246. virtual void CalculateBoundsRect(void) { m_boundsRect = m_rect; }
  247. //
  248. // Ensure that a rectangle has top left to the left of and above bottom
  249. // right.
  250. //
  251. void NormalizeRect(LPRECT lprc);
  252. //
  253. // Type of the graphic (used in the external representation)
  254. //
  255. virtual UINT Type(void) const { return 0; }
  256. //
  257. // Length of the external representation of the graphic
  258. //
  259. virtual DWORD CalculateExternalLength(void)
  260. { return sizeof(WB_GRAPHIC); }
  261. //
  262. // Convert between internal and external representations
  263. //
  264. virtual void ReadExternal(void);
  265. virtual void ReadHeader(PWB_GRAPHIC pHeader);
  266. virtual void ReadExtra(PWB_GRAPHIC) {}
  267. virtual void CopyExtra(PWB_GRAPHIC) {}
  268. virtual void WriteExternal(PWB_GRAPHIC pHeader);
  269. virtual void WriteHeader(PWB_GRAPHIC pHeader);
  270. virtual void WriteExtra(PWB_GRAPHIC) {}
  271. //
  272. // Page on which this object belongs
  273. //
  274. WB_PAGE_HANDLE m_hPage;
  275. //
  276. // Whiteboard Core handle for the object
  277. //
  278. WB_GRAPHIC_HANDLE m_hGraphic;
  279. //
  280. // Flag indicating whether the graphic has changed since it was last
  281. // read from external storage.
  282. //
  283. BOOL m_bChanged;
  284. //
  285. // Graphic header details
  286. //
  287. DWORD m_dwExternalLength; // Length of the object
  288. RECT m_boundsRect; // Bounding
  289. RECT m_rect; // Defining
  290. COLORREF m_clrPenColor; // Color of pen as RGB
  291. UINT m_uiPenWidth; // Width in logical units
  292. int m_iPenROP; // Raster operation to be used for drawing
  293. int m_iPenStyle; // Pen style to be used for drawing
  294. UINT m_uiLockState; // Lock indicator
  295. int m_toolType; // Type of tool used to create the graphic
  296. };
  297. //
  298. //
  299. // Class: DCWbGraphicMarker
  300. //
  301. // Purpose: Class representing an object marker. This is a set of eight
  302. // handles drawn at intervals round the objects bounding rectangle.
  303. //
  304. // This is an internal object only - it is never passed to the
  305. // Whiteboard Core DLL.
  306. //
  307. //
  308. class DCWbGraphicMarker : public DCWbGraphic
  309. {
  310. friend class DCWbGraphicSelectTrackingRectangle;
  311. public:
  312. //
  313. // Constructors
  314. //
  315. DCWbGraphicMarker(void);
  316. ~DCWbGraphicMarker(void);
  317. UINT IsGraphicTool(void) { return enumGraphicMarker;}
  318. // Rect that bounds all objs in RectList
  319. virtual void GetBoundsRect(LPRECT lprc);
  320. // Deletes all marker rects in RectList
  321. void DeleteAllMarkers( DCWbGraphic *pLastSelectedGraphic,
  322. BOOL bLockLastSelectedGraphic = FALSE );
  323. // Deletes one marker
  324. void DeleteMarker( DCWbGraphic *pGraphic );
  325. // Sees if obj is already in marker
  326. DCWbGraphic *HasAMarker( DCWbGraphic *pGraphic );
  327. // Gets last marker
  328. DCWbGraphic *LastMarker( void );
  329. // Gets number of markers in marker list
  330. int GetNumMarkers( void );
  331. // Moves all selected objects by offset
  332. virtual void MoveBy(int cx, int cy);
  333. // Updates selected remote objects
  334. void Update( void );
  335. // Checks for point hitting any marker obj
  336. BOOL PointInBounds(POINT pt);
  337. // Changes color for selection
  338. void SetColor(COLORREF color);
  339. // Changes width of selection
  340. void SetPenWidth(UINT uiWidth);
  341. // Changes font of selection (text objs only)
  342. void SetSelectionFont(HFONT hFont);
  343. //Deletes all objs in selection
  344. void DeleteSelection( void );
  345. //Brings all objs in selection to top
  346. void BringToTopSelection( void );
  347. //Sends all objs to bottom
  348. void SendToBackSelection( void );
  349. //Renders marker objects to a multi-obj format and copies to the
  350. // clipboard
  351. BOOL RenderPrivateMarkerFormat( void );
  352. //Pastes multi-obj clipboard data
  353. void Paste( HANDLE handle );
  354. //
  355. // Set the object defining rectangle - this is only set up for some
  356. // object types e.g. rectangles and ellipses.
  357. //
  358. BOOL SetRect(LPCRECT lprc, DCWbGraphic *pGraphic, BOOL bRedraw,
  359. BOOL bLockObject = TRUE );
  360. //
  361. // Return an indication of which handle the specified point lies in.
  362. //
  363. int PointInMarker(POINT pt);
  364. //
  365. // Draw the marker
  366. //
  367. void Draw(HDC hDC, BOOL bDrawObjects = FALSE );
  368. void Undraw(HDC hDC, WbDrawingArea * pDrawingArea);
  369. void DrawRect( HDC hDC, LPCRECT pMarkerRect,
  370. BOOL bDrawObject, DCWbGraphic *pGraphic );
  371. void UndrawRect(HDC hDC, WbDrawingArea * pDrawingArea,
  372. LPCRECT pMarkerRect );
  373. //
  374. // Override the base graphic object functions that are not appropriate
  375. // for this graphic type. This prevents updates being made for changes
  376. // to pen attributes (for instance).
  377. //
  378. void Present( BOOL bOn )
  379. {m_bMarkerPresent = bOn;}
  380. protected:
  381. //
  382. // Bounding rectangle calculation
  383. //
  384. void CalculateBoundsRect(void);
  385. //
  386. // Marker rectangle calculation
  387. //
  388. void CalculateMarkerRectangles(void);
  389. //
  390. // Marker rectangle
  391. //
  392. RECT m_markerRect;
  393. CPtrToPtrList MarkerList; // keys are DCWbGraphic pointers,
  394. // values are LPRECT pointers.
  395. BOOL m_bMarkerPresent;
  396. void UndrawMarker(LPCRECT pMarkerREct);
  397. //
  398. // Brush used to draw the marker rectangle
  399. //
  400. HBRUSH m_hMarkerBrush;
  401. };
  402. //
  403. //
  404. // Class: DCWbGraphicLine
  405. //
  406. // Purpose: Class representing straight line
  407. //
  408. //
  409. class DCWbGraphicLine : public DCWbGraphic
  410. {
  411. public:
  412. //
  413. // Constructors
  414. //
  415. DCWbGraphicLine(void) { }
  416. DCWbGraphicLine(PWB_GRAPHIC pHeader)
  417. : DCWbGraphic(pHeader) { }
  418. DCWbGraphicLine(WB_PAGE_HANDLE hPage, WB_GRAPHIC_HANDLE hGraphic)
  419. : DCWbGraphic(hPage, hGraphic) { }
  420. ~DCWbGraphicLine(void);
  421. //
  422. // Set the object start and end points
  423. //
  424. void SetStart(POINT ptStart);
  425. void SetEnd(POINT ptEnd);
  426. UINT IsGraphicTool(void) {return enumNoGraphicTool;}
  427. //
  428. // Draw the object
  429. //
  430. void Draw(HDC hDC);
  431. //
  432. // Translate the graphic object by the x and y values of the point
  433. // parameter.
  434. //
  435. virtual void MoveBy(int cx, int cy);
  436. //
  437. // Override the base graphic object functions that are not appropriate
  438. // for this graphic type. This prevents updates being made for changes
  439. // to pen attributes (for instance).
  440. //
  441. virtual BOOL CheckReallyHit( LPCRECT pRectHit );
  442. protected:
  443. //
  444. // Type of the graphic (used for writing to external memory)
  445. //
  446. virtual UINT Type(void) const { return TYPE_GRAPHIC_LINE; }
  447. //
  448. // Bounding rectangle calculation
  449. //
  450. void CalculateBoundsRect(void);
  451. };
  452. //
  453. //
  454. // Class: DCWbGraphicTrackingLine
  455. //
  456. // Purpose: Class representing an XORed straight line (for rubber banding)
  457. //
  458. // This is an internal object only - it is never passed to the
  459. // Whiteboard Core DLL.
  460. //
  461. //
  462. class DCWbGraphicTrackingLine : public DCWbGraphicLine
  463. {
  464. public:
  465. //
  466. // Constructor
  467. //
  468. DCWbGraphicTrackingLine(void) { SetROP(R2_NOTXORPEN); };
  469. };
  470. //
  471. //
  472. // Class: DCWbGraphicFreehand
  473. //
  474. // Purpose: Class representing multiple line segments
  475. //
  476. //
  477. class DCDWordArray
  478. {
  479. public:
  480. DCDWordArray(void);
  481. ~DCDWordArray(void);
  482. void Add(POINT point);
  483. BOOL ReallocateArray(void);
  484. POINT* GetBuffer(void) { return m_pData; }
  485. void SetSize(UINT size);
  486. UINT GetSize(void);
  487. POINT* operator[](UINT index){return &(m_pData[index]);}
  488. private:
  489. POINT* m_pData;
  490. UINT m_Size;
  491. UINT m_MaxSize;
  492. };
  493. /////////////
  494. class DCWbGraphicFreehand : public DCWbGraphic
  495. {
  496. public:
  497. //
  498. // Constructors
  499. //
  500. DCWbGraphicFreehand(void);
  501. DCWbGraphicFreehand(PWB_GRAPHIC pHeader);
  502. DCWbGraphicFreehand(WB_PAGE_HANDLE hPage, WB_GRAPHIC_HANDLE hGraphic);
  503. ~DCWbGraphicFreehand(void);
  504. UINT IsGraphicTool(void) { return enumGraphicFreeHand;}
  505. //
  506. // Add a point to the list, returning success
  507. //
  508. BOOL AddPoint(POINT pt);
  509. //
  510. // Translate the graphic object by the x and y values of the point
  511. // parameter.
  512. //
  513. virtual void MoveBy(int cx, int cy);
  514. //
  515. // Draw the object
  516. //
  517. void Draw(HDC hDC);
  518. virtual BOOL CheckReallyHit( LPCRECT pRectHit );
  519. protected:
  520. //
  521. // Type of the graphic (used for writing to external memory)
  522. //
  523. virtual UINT Type(void) const { return TYPE_GRAPHIC_FREEHAND; }
  524. //
  525. // Length of the external representation of the graphic
  526. //
  527. virtual DWORD CalculateExternalLength(void);
  528. //
  529. // Convert between internal and external representations
  530. //
  531. void WriteExtra(PWB_GRAPHIC pHeader);
  532. void ReadExtra(PWB_GRAPHIC pHeader);
  533. //
  534. // Bounding rectangle calculation
  535. //
  536. void CalculateBoundsRect(void);
  537. void AddPointToBounds(int x, int y);
  538. //
  539. // Array holding point information
  540. //
  541. DCDWordArray points; //CHANGED BY RAND
  542. //
  543. // Spline curve smoothing drawing functions
  544. //
  545. void DrawUnsmoothed(HDC hDC);
  546. };
  547. //
  548. //
  549. // Class: DCWbGraphicRectangle
  550. //
  551. // Purpose: Class representing a rectangle
  552. //
  553. //
  554. class DCWbGraphicRectangle : public DCWbGraphic
  555. {
  556. public:
  557. //
  558. // Constructors
  559. //
  560. DCWbGraphicRectangle(void) { }
  561. DCWbGraphicRectangle(PWB_GRAPHIC pHeader)
  562. : DCWbGraphic(pHeader) { }
  563. DCWbGraphicRectangle(WB_PAGE_HANDLE hPage, WB_GRAPHIC_HANDLE hGraphic)
  564. : DCWbGraphic(hPage, hGraphic) { }
  565. ~DCWbGraphicRectangle(void);
  566. UINT IsGraphicTool(void) {return enumNoGraphicTool;}
  567. //
  568. // Set the defining rectangle
  569. //
  570. void SetRect(LPCRECT lprc);
  571. //
  572. // Draw the object
  573. //
  574. void Draw(HDC hDC);
  575. //
  576. // Translate the graphic object by the x and y values of the point
  577. // parameter.
  578. //
  579. virtual void MoveBy(int cx, int cy);
  580. //
  581. // Override the base graphic object functions that are not appropriate
  582. // for this graphic type. This prevents updates being made for changes
  583. // to pen attributes (for instance).
  584. //
  585. virtual BOOL CheckReallyHit( LPCRECT pRectHit );
  586. protected:
  587. //
  588. // Type of the graphic (used for writing to external memory)
  589. //
  590. virtual UINT Type(void) const { return TYPE_GRAPHIC_RECTANGLE; }
  591. //
  592. // Bounding rectangle calculation
  593. //
  594. void CalculateBoundsRect(void);
  595. };
  596. //
  597. //
  598. // Class: DCWbGraphicTrackingRectangle
  599. //
  600. // Purpose: Class representing an XORed rectangle (for rubber banding)
  601. //
  602. // This is an internal object only - it is never passed to the
  603. // Whiteboard Core DLL.
  604. //
  605. //
  606. class DCWbGraphicTrackingRectangle : public DCWbGraphicRectangle
  607. {
  608. public:
  609. //
  610. // Constructor
  611. //
  612. DCWbGraphicTrackingRectangle(void) { SetROP(R2_NOTXORPEN); };
  613. };
  614. class DCWbGraphicSelectTrackingRectangle : public DCWbGraphicRectangle
  615. {
  616. public:
  617. //
  618. // Constructor
  619. //
  620. DCWbGraphicSelectTrackingRectangle(void)
  621. {SetROP(R2_NOTXORPEN); m_Offset.cx = 0; m_Offset.cy = 0; }
  622. void Draw( HDC hDC);
  623. virtual void MoveBy(int cx, int cy);
  624. protected:
  625. SIZE m_Offset;
  626. };
  627. //
  628. //
  629. // Class: DCWbGraphicFilledRectangle
  630. //
  631. // Purpose: Class representing a filled rectangle
  632. //
  633. //
  634. class DCWbGraphicFilledRectangle : public DCWbGraphicRectangle
  635. {
  636. public:
  637. //
  638. // Constructors
  639. //
  640. DCWbGraphicFilledRectangle(void) { }
  641. DCWbGraphicFilledRectangle(PWB_GRAPHIC pHeader)
  642. : DCWbGraphicRectangle(pHeader) { }
  643. DCWbGraphicFilledRectangle(WB_PAGE_HANDLE hPage,
  644. WB_GRAPHIC_HANDLE hGraphic)
  645. : DCWbGraphicRectangle(hPage, hGraphic) { }
  646. ~DCWbGraphicFilledRectangle(void);
  647. UINT IsGraphicTool(void) { return enumGraphicFilledRectangle;}
  648. //
  649. // Draw the object
  650. //
  651. void Draw(HDC hDC);
  652. //
  653. // Override the base graphic object functions that are not appropriate
  654. // for this graphic type. This prevents updates being made for changes
  655. // to pen attributes (for instance).
  656. //
  657. virtual BOOL CheckReallyHit( LPCRECT pRectHit );
  658. protected:
  659. //
  660. // Type of the graphic (used for writing to external memory)
  661. //
  662. virtual UINT Type(void) const { return TYPE_GRAPHIC_FILLED_RECTANGLE; }
  663. //
  664. // Bounding rectangle calculation
  665. //
  666. void CalculateBoundsRect(void);
  667. };
  668. //
  669. //
  670. // Class: DCWbGraphicEllipse
  671. //
  672. // Purpose: Class representing an ellipse
  673. //
  674. //
  675. class DCWbGraphicEllipse : public DCWbGraphic
  676. {
  677. public:
  678. //
  679. // Constructor
  680. //
  681. DCWbGraphicEllipse(void) { }
  682. DCWbGraphicEllipse(PWB_GRAPHIC pHeader)
  683. : DCWbGraphic(pHeader) { }
  684. DCWbGraphicEllipse(WB_PAGE_HANDLE hPage, WB_GRAPHIC_HANDLE hGraphic)
  685. : DCWbGraphic(hPage, hGraphic) { }
  686. ~DCWbGraphicEllipse(void);
  687. UINT IsGraphicTool(void) {return enumNoGraphicTool;}
  688. //
  689. // Set the defining rectangle
  690. //
  691. void SetRect(LPCRECT lprc);
  692. //
  693. // Draw the object
  694. //
  695. void Draw(HDC hDC);
  696. //
  697. // Translate the graphic object by the x and y values of the point
  698. // parameter.
  699. //
  700. virtual void MoveBy(int cx, int cy);
  701. //
  702. // Override the base graphic object functions that are not appropriate
  703. // for this graphic type. This prevents updates being made for changes
  704. // to pen attributes (for instance).
  705. //
  706. virtual BOOL CheckReallyHit(LPCRECT pRectHit );
  707. protected:
  708. //
  709. // Type of the graphic (used for writing to external memory)
  710. //
  711. virtual UINT Type(void) const { return TYPE_GRAPHIC_ELLIPSE; }
  712. //
  713. // Bounding rectangle calculation
  714. //
  715. void CalculateBoundsRect(void);
  716. };
  717. //
  718. //
  719. // Class: DCWbGraphicTrackingEllipse
  720. //
  721. // Purpose: Class representing an XORed ellipse (for rubber banding)
  722. //
  723. // This is an internal object only - it is never passed to the
  724. // Whiteboard Core DLL.
  725. //
  726. //
  727. class DCWbGraphicTrackingEllipse : public DCWbGraphicEllipse
  728. {
  729. public:
  730. //
  731. // Constructors
  732. //
  733. DCWbGraphicTrackingEllipse(void) { SetROP(R2_NOTXORPEN); };
  734. };
  735. //
  736. //
  737. // Class: DCWbGraphicFilledEllipse
  738. //
  739. // Purpose: Class representing a filled ellipse
  740. //
  741. //
  742. class DCWbGraphicFilledEllipse : public DCWbGraphicEllipse
  743. {
  744. public:
  745. //
  746. // Constructor
  747. //
  748. DCWbGraphicFilledEllipse(void) { }
  749. DCWbGraphicFilledEllipse(PWB_GRAPHIC pHeader)
  750. : DCWbGraphicEllipse(pHeader) { }
  751. DCWbGraphicFilledEllipse(WB_PAGE_HANDLE hPage,
  752. WB_GRAPHIC_HANDLE hGraphic)
  753. : DCWbGraphicEllipse(hPage, hGraphic) { }
  754. ~DCWbGraphicFilledEllipse(void);
  755. UINT IsGraphicTool(void) { return enumGraphicFilledEllipse;}
  756. //
  757. // Draw the object
  758. //
  759. void Draw(HDC hDC);
  760. virtual BOOL CheckReallyHit(LPCRECT pRectHit );
  761. protected:
  762. //
  763. // Type of the graphic (used for writing to external memory)
  764. //
  765. virtual UINT Type(void) const { return TYPE_GRAPHIC_FILLED_ELLIPSE; }
  766. //
  767. // Bounding rectangle calculation
  768. //
  769. void CalculateBoundsRect(void);
  770. };
  771. //
  772. //
  773. // Class: DCWbGraphicText
  774. //
  775. // Purpose: Class representing a text object
  776. //
  777. //
  778. class DCWbGraphicText : public DCWbGraphic
  779. {
  780. // Friend declaration for text editing
  781. friend class WbTextEditor;
  782. // Friend declaration for copying to the clipboard
  783. friend class WbMainWindow;
  784. public:
  785. //
  786. // Constructors
  787. //
  788. DCWbGraphicText(void);
  789. DCWbGraphicText(PWB_GRAPHIC pHeader);
  790. DCWbGraphicText(WB_PAGE_HANDLE hPage, WB_GRAPHIC_HANDLE hGraphic);
  791. //
  792. // Destructor
  793. //
  794. ~DCWbGraphicText(void);
  795. UINT IsGraphicTool(void) { return enumGraphicText;}
  796. //
  797. // Set the text of the object
  798. //
  799. virtual void SetText(TCHAR * strText);
  800. virtual void SetText(const StrArray& strTextArray);
  801. //
  802. // Get/Set the font for drawing the text
  803. //
  804. virtual void SetFont(HFONT hFont);
  805. virtual void SetFont(LOGFONT *pLogFont, BOOL bReCalc=TRUE );
  806. virtual HFONT GetFont(void) {return m_hFont;};
  807. //
  808. // Draw - draw the object
  809. //
  810. void Draw(HDC hDC) { Draw(hDC, FALSE); };
  811. void Draw(HDC hDC, BOOL thumbNail);
  812. //
  813. // InvalidateMetrics - flag metrics need to be reread
  814. //
  815. void InvalidateMetrics(void);
  816. //
  817. // Override the base graphic object functions that are not appropriate
  818. // for this graphic type. This prevents updates being made for changes
  819. // to pen attributes (for instance).
  820. //
  821. void SetPenWidth(UINT) { };
  822. void SetROP(int) { };
  823. void SetPenStyle(int) { };
  824. virtual BOOL CheckReallyHit( LPCRECT pRectHit );
  825. virtual void GetPosition(LPPOINT lppt); // added for bug 469
  826. protected:
  827. //
  828. // Type of the graphic (used for writing to external memory)
  829. //
  830. virtual UINT Type(void) const { return TYPE_GRAPHIC_TEXT; }
  831. //
  832. // Bounding rectangle calculation
  833. //
  834. void CalculateBoundsRect(void);
  835. //
  836. // Length of the external representation of the graphic
  837. //
  838. virtual DWORD CalculateExternalLength(void);
  839. //
  840. // Convert between internal and external representations
  841. //
  842. void WriteExtra(PWB_GRAPHIC pHeader);
  843. void ReadExtra(PWB_GRAPHIC pHeader);
  844. //
  845. // Calculate the rectangle of a portion of a single line of text
  846. //
  847. ABC GetTextABC( LPCTSTR strText,
  848. int iStartX,
  849. int iStopX);
  850. void GetTextRectangle(int iStartY,
  851. int iStartX,
  852. int iStopX,
  853. LPRECT lprc);
  854. void CalculateRect(int iStartX,
  855. int iStartY,
  856. int iStopX,
  857. int iStopY,
  858. LPRECT lprc);
  859. //
  860. // Array for storing text
  861. //
  862. StrArray strTextArray;
  863. //
  864. // Font details
  865. //
  866. HFONT m_hFont;
  867. HFONT m_hFontThumb;
  868. BOOL m_bFirstSetFontCall;
  869. LONG m_nKerningOffset; // added for bug 469
  870. public:
  871. TEXTMETRIC m_textMetrics;
  872. };
  873. //
  874. //
  875. // Class: DCWbGraphicDIB
  876. //
  877. // Purpose: Class representing a drawn DI bitmap object
  878. //
  879. //
  880. typedef struct tagHOLD_DATA
  881. {
  882. PWB_GRAPHIC pHeader;
  883. LPBITMAPINFOHEADER lpbi;
  884. }
  885. HOLD_DATA;
  886. class DCWbGraphicDIB : public DCWbGraphic
  887. {
  888. public:
  889. //
  890. // Constructors
  891. //
  892. DCWbGraphicDIB(void);
  893. DCWbGraphicDIB(PWB_GRAPHIC pHeader);
  894. DCWbGraphicDIB(WB_PAGE_HANDLE hPage, WB_GRAPHIC_HANDLE _hGraphic);
  895. UINT IsGraphicTool(void) { return enumGraphicDIB; }
  896. //
  897. // Destructor
  898. //
  899. ~DCWbGraphicDIB(void);
  900. //
  901. // Set the contents of the bitmap
  902. //
  903. void SetImage(LPBITMAPINFOHEADER lpbi);
  904. //
  905. // Set the contents of the bitmap from the screen
  906. //
  907. void FromScreenArea(LPCRECT lprcScreen);
  908. //
  909. // Draw the object
  910. //
  911. void Draw(HDC hDC);
  912. //
  913. // Delete the image currently held internally (if any)
  914. //
  915. void DeleteImage(void);
  916. //
  917. // Override the base graphic object functions that are not appropriate
  918. // for this graphic type. This prevents updates being made for changes
  919. // to pen attributes (for instance).
  920. //
  921. void SetPenWidth(UINT) { };
  922. void SetColor(COLORREF) { };
  923. void SetROP(int) { };
  924. void SetPenStyle(int) { };
  925. virtual BOOL CheckReallyHit( LPCRECT pRectHit );
  926. protected:
  927. //
  928. // Type of the graphic (used for writing to external memory)
  929. //
  930. virtual UINT Type(void) const { return TYPE_GRAPHIC_DIB; }
  931. //
  932. // Bounding rectangle calculation
  933. //
  934. void CalculateBoundsRect(void);
  935. //
  936. // Length of the external representation of the graphic
  937. //
  938. virtual DWORD CalculateExternalLength(void);
  939. //
  940. // Convert between internal and external representations
  941. //
  942. void WriteExtra(PWB_GRAPHIC pHeader);
  943. void CopyExtra(PWB_GRAPHIC pHeader);
  944. //
  945. // Get the DIB data
  946. //
  947. BOOL GetDIBData(HOLD_DATA& hold);
  948. void ReleaseDIBData(HOLD_DATA& hold);
  949. // Pointer to the DIB bits
  950. LPBITMAPINFOHEADER m_lpbiImage;
  951. };
  952. class ObjectTrashCan : public DCWbGraphic
  953. {
  954. public:
  955. ~ObjectTrashCan(void);
  956. UINT IsGraphicTool(void) {return enumNoGraphicTool;}
  957. BOOL GotTrash( void );
  958. void CollectTrash( DCWbGraphic *pGObj );
  959. void SelectTrash( void );
  960. void EmptyTrash( void );
  961. void BurnTrash( void );
  962. virtual void AddToPageLast(WB_PAGE_HANDLE hPage);
  963. protected:
  964. COBLIST Trash;
  965. };
  966. #endif // __GROBJ_HPP_