home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / Blitting Class Library / Secure Macintosh Ports / SecureWindowRef.cp < prev    next >
Encoding:
Text File  |  1995-10-20  |  1.4 KB  |  60 lines  |  [TEXT/CWIE]

  1. // SecureWindowRef.cp, the SecureWindowRef class, useful for generating windows
  2. //    for those who do not use a framework to make windows for them.
  3.  
  4. // copyright © 1995, Macneil Shonle. All rights reserved.
  5.  
  6. #ifndef __SECUREWINDOWREF__
  7. #include <SecureWindowRef.h>
  8. #endif
  9.  
  10. // constructs the window from the parameters
  11. //    may throw: invalidargument
  12. SecureWindowRef::SecureWindowRef(const Rect& bounds, short theProc, ConstStr255Param title,
  13.     Boolean goAwayFlag, Boolean visible, WindowRef behind, long refCon, void *wStorage)
  14.     throw(invalidargument)
  15.     : window(::NewCWindow(wStorage, &bounds, title, visible, theProc, behind,
  16.         goAwayFlag, refCon))
  17. {
  18.     if (window == nil)
  19.         throw invalidargument("NewCWindow failed", "SecureWindowRef::SecureWindowRef");
  20. }
  21.  
  22. SecureWindowRef::~SecureWindowRef()
  23. {
  24.     ::DisposeWindow(window);
  25. }
  26.  
  27. Rect& SecureWindowRef::portRect() const
  28. {
  29.     return window->portRect;
  30. }
  31.  
  32. BitMapPtr SecureWindowRef::bitMap() const
  33. {
  34.     return &GrafPtr(window)->portBits;
  35. }
  36.  
  37. short SecureWindowRef::width() const
  38. {
  39.     return window->portRect.right - window->portRect.left;
  40. }
  41.  
  42. short SecureWindowRef::height() const
  43. {
  44.     return window->portRect.bottom - window->portRect.top;
  45. }
  46.  
  47. CGrafPtr SecureWindowRef::getMacPort() const
  48. {
  49.     return CGrafPtr(window);
  50. }
  51.  
  52. GDHandle SecureWindowRef::getMacGD() const
  53. {
  54.     return ::GetMainDevice();
  55. }
  56.  
  57. SecureWindowRef::operator WindowRef() const
  58. {
  59.     return window;
  60. }