home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / c-tools / c_examples / frameiclass / frameiclass.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-03  |  1.9 KB  |  69 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. // FrameIClass.cpp
  3. //
  4. // Deryk Robosson
  5. // June 2, 1996
  6. //////////////////////////////////////////////////////////////////////////////
  7.  
  8. //////////////////////////////////////////////////////////////////////////////
  9. // INCLUDES
  10. #include "aframe:include/FrameIClass.hpp"
  11.  
  12. //////////////////////////////////////////////////////////////////////////////
  13. //
  14.  
  15. AFFrameIClass::AFFrameIClass()
  16. {
  17.     m_Frame=NULL;
  18. }
  19.  
  20. AFFrameIClass::~AFFrameIClass()
  21. {   // Call DestroyObject if it hasn't already
  22.     if(m_Frame != NULL)
  23.         DestroyObject();
  24. }
  25.  
  26. // Remove object from window if it has been added
  27. // and dispose of it
  28. void AFFrameIClass::DestroyObject()
  29. {
  30.     RemoveObject();
  31. }
  32.  
  33. // Add object to a window, with size and position of rect
  34. BOOL AFFrameIClass::Create(AFWindow *window, AFRect *rect, int recessed, int frametype)
  35. {
  36.     if(m_Added)
  37.         RemoveObject();
  38.  
  39.     if(m_Frame=(struct Image*)NewObject((struct IClass*)NULL, (UBYTE*)"frameiclass",
  40.                         IA_FrameType, frametype,
  41.                         IA_Recessed, recessed,
  42.                         IA_Width, rect->Width(),
  43.                         IA_Height, rect->Height(),
  44.                         TAG_DONE)) {
  45.         DrawImage(window->m_pWindow->RPort, m_Frame, rect->TopLeft()->m_x, rect->TopLeft()->m_y);
  46.  
  47.         m_pwindow=window;
  48.         m_Added=TRUE;
  49.         m_Rect.SetRect(rect->TopLeft(),rect->BottomRight());
  50.         return TRUE;
  51.     } else return FALSE;
  52. }
  53.  
  54. void AFFrameIClass::RefreshImage()
  55. {
  56.     BeginRefresh(m_pwindow->m_pWindow);
  57.     DrawImage(m_pwindow->m_pWindow->RPort, m_Frame, m_Rect.TopLeft()->m_x, m_Rect.TopLeft()->m_y);
  58.     EndRefresh(m_pwindow->m_pWindow,TRUE);
  59. }
  60.  
  61. // Remove object from the window to which it was added
  62. void AFFrameIClass::RemoveObject()
  63. {
  64.     if(m_Frame !=NULL) {
  65.         DisposeObject((Object*)m_Frame);
  66.         m_Frame=NULL;
  67.     }
  68. }
  69.