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

  1. //////////////////////////////////////////////////////////////////////////////
  2. // screen.cpp
  3. //
  4. // Jeffry A Worth
  5. // December 19, 1995
  6. //////////////////////////////////////////////////////////////////////////////
  7.  
  8. //////////////////////////////////////////////////////////////////////////////
  9. // INCLUDES
  10. #include <string.h>
  11. #include "aframe:include/screen.hpp"
  12.  
  13. //////////////////////////////////////////////////////////////////////////////
  14. //
  15.  
  16. AFScreen::AFScreen()
  17. {
  18.   m_pScreen = NULL;
  19.   return;
  20. }
  21.  
  22. AFScreen::~AFScreen()
  23. {
  24.   DestroyObject();
  25. }
  26.  
  27. BOOL AFScreen::Create(AFAmigaApp* app, AFRect* rect)
  28. {
  29.   return Create(app,rect,"",4,NULL);
  30. }
  31.  
  32. BOOL AFScreen::Create(AFAmigaApp* app, AFRect* rect, char *szTitle,
  33.                       int depth, long displayid)
  34. {
  35.  
  36.   // Remember the Application for later
  37.   m_papp = app;
  38.  
  39.   // Create a string for the Window Title
  40.   m_sztitle = new char[strlen(szTitle)+1];
  41.   if(m_sztitle) strcpy(m_sztitle,szTitle);
  42.  
  43.   if(displayid==NULL)
  44.     displayid=HIRESLACE_KEY;
  45.  
  46.   // Open the Window the intuition way
  47.   if(m_pScreen = OpenScreenTags(NULL,
  48.     SA_Left,    rect->TopLeft()->m_x,
  49.     SA_Top,        rect->TopLeft()->m_y,
  50.     SA_Width,    rect->Width(),
  51.     SA_Height,    rect->Height(),
  52.     SA_Depth,    depth,
  53.     SA_Title,    m_sztitle,
  54.     SA_DisplayID,    displayid,
  55.     TAG_END)) {
  56.  
  57.     // Fill the textattr structure
  58.     //::AskFont(m_pWindow->RPort,&m_textattr);
  59.  
  60.     // Add window's sigbit to Application
  61.     //app->m_SigBits |= 1<<(m_pWindow->UserPort->mp_SigBit);
  62.  
  63.     // Add window to the system window node list
  64.     //app->m_pwindows = new AFNode((void*)this,app->m_pwindows);
  65.  
  66.     // Call OnCreate Method
  67.     OnCreate();
  68.  
  69.     // Create was successful
  70.     return TRUE;
  71.   }
  72.   return FALSE;
  73. }
  74.  
  75. void AFScreen::DestroyObject()
  76. {
  77.   if(m_pScreen) {
  78.     CloseScreen(m_pScreen),m_pScreen=NULL;
  79.     PostNCDestroy();
  80.   }
  81.   if(m_sztitle) delete m_sztitle;
  82. }
  83.  
  84. ULONG AFScreen::GetDisplayID()  // returns screen DisplayID
  85. {
  86.   return ::GetVPModeID(&(m_pScreen->ViewPort));
  87. }
  88.