#include "cp.h"

int OpenGTXScreen()
{
int check;
struct EasyStruct ES = {
     sizeof(struct EasyStruct),
     0,
     "OpenGTXScreen()",
     "%s",
     "GoodBye!"
    };

    check =  SetupScreen();

    if ( check ) {

          CloseDownScreen();

          switch ( check ) {
               case 1:
                    EasyRequest (NULL,&ES,NULL,"Could not open or lock the screen");
                    return(1);
               case 2:
                    EasyRequest (NULL,&ES,NULL,"Could not get the screens' visual info");
                    return(2);
               case 3:
                    EasyRequest (NULL,&ES,NULL,"Could not setup the GETFILE boopsi class");
                    return(3);
               case 4:
                    EasyRequest (NULL,&ES,NULL,"Could not get a GETFILE boopsi object");
                    return(4);
               case 5:
                    EasyRequest (NULL,&ES,NULL,"Could not open the font");
                    return(5);
               default:
                    EasyRequest (NULL,&ES,NULL,"Unknown error in SetupScreen");
                    return(20);
          }
     }
}


int ( *OpenWinX )( void );

int OpenGTXWindow( int ( *OpenWinX )( void ))
{
int check;
struct EasyStruct ES = {
     sizeof(struct EasyStruct),
     0,
     "OpenGTXWindow()",
     "%s",
     "GoodBye!"
    };

     check =  OpenWinX();

     if ( check ) {

          ClosePlotWindowWindow();

          switch ( check ) {
               case 1:
                    EasyRequest (NULL,&ES,NULL,"Could not create a gadget context");
                    return(1);
               case 2:
                    EasyRequest (NULL,&ES,NULL,"Error during the gadget creation");
                    return(2);
               case 3:
                    EasyRequest (NULL,&ES,NULL,"Could not create the menus");
                    return(3);
               case 4:
                    EasyRequest (NULL,&ES,NULL,"Could not open the window");
                    return(4);
               default:
                    EasyRequest (NULL,&ES,NULL,"Unknown error in OpenProjectWindow");
                    return(20);
          }
     }
     return(0);
}

struct TextFont *OpencPFont()
{
struct TextFont *FontPtr;

     FontPtr = ( struct TextFont *)OpenDiskFont( cPFont );

     if( FontPtr == NULL )
       {
          cPFont->ta_Name = "topaz.font";
          cPFont->ta_YSize = 8;
          FontPtr = ( struct TextFont *)OpenDiskFont( cPFont );
       }

     return( FontPtr );
}
