/****************************************************************** * * * Nest version 2 - 3D Wasp Nest Simulator * * Copyright (C) 1997 Sylvain GUERIN * * LIASC, ENST Bretagne & Santa Fe Institute * * * ****************************************************************** E-mail: Sylvain.Guerin@enst-bretagne.fr or: Sylvain Guerin 13 rue des Monts Lorgeaux, 51460 L'EPINE, FRANCE ****************************************************************** This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ****************************************************************** Name : TitleInt.c Component : title interface Fonctionality : contains methods refering to the title interface ******************************************************************/ #include "TitleInt.h" #include "config.h" #ifdef XPM_INC_X11 # include #else # include #endif #include "WaspIcon.xpm" #include "WaspIconBW.xpm" #define TITLE_WIDTH 550 #define TITLE_HEIGHT 440 TitleInterface::TitleInterface (Display* aDisplay, unsigned int displayWidth, unsigned int displayHeight) : Interface ((int)((displayWidth-TITLE_WIDTH)/2), (int)((displayHeight-TITLE_HEIGHT)/2), TITLE_WIDTH, TITLE_HEIGHT, 1, VERSION, "Nest2", aDisplay) { initialize (); } TitleInterface::TitleInterface (unsigned int displayWidth, unsigned int displayHeight) : Interface ((int)((displayWidth-TITLE_WIDTH)/2), (int)((displayHeight-TITLE_HEIGHT)/2), TITLE_WIDTH, TITLE_HEIGHT, 1, VERSION, "Nest2") { initialize (); } TitleInterface::~TitleInterface () { XFreePixmap (display, waspPixmap); delete iconWindow; delete continueButton; delete licenceButton; delete warrantyButton; delete title1; delete title2; delete title3; delete title4; delete notice1; delete notice2; delete notice3; delete notice4; if (isGNULicenceInterfaceLaunched) { delete licenceInterface; } } void TitleInterface::initialize () { char temp[256]; iconWindow = new GraphicWindow (this, (int)((TITLE_WIDTH-PIXMAP_WIDTH)/2), 25, PIXMAP_WIDTH, PIXMAP_HEIGHT, enabled, ExposureMask, LightGrey); licenceButton = new Button (this, (int)((TITLE_WIDTH-110)/2)-130, TITLE_HEIGHT-50, 110, 25, "Licence", centerJustified, enabled); warrantyButton = new Button (this, (int)((TITLE_WIDTH-110)/2), TITLE_HEIGHT-50, 110, 25, "Warranty", centerJustified, enabled); continueButton = new Button (this, (int)((TITLE_WIDTH-110)/2)+130, TITLE_HEIGHT-50, 110, 25, "Continue", centerJustified, enabled); strcpy (temp, VERSION); title1 = new TextWidget (this, (int)((TITLE_WIDTH-strlen(temp)*9)/2), 155, temp); title1->setBoldDisplay (); strcpy (temp, "3D Wasp Nest Simulator"); title2 = new TextWidget (this, (int)((TITLE_WIDTH-strlen(temp)*9)/2), 175, temp); title2->setBoldDisplay (); strcpy (temp, "Copyright (C) 1997, Sylvain GUERIN"); title3 = new TextWidget (this, (int)((TITLE_WIDTH-strlen(temp)*9)/2), 195, temp); title3->setBoldDisplay (); strcpy (temp, "LIASC ENST Bretagne & Santa Fe Institute"); title4 = new TextWidget (this, (int)((TITLE_WIDTH-strlen(temp)*9)/2), 215, temp); title4->setBoldDisplay (); strcpy (temp, "Nest comes with ABSOLUTELY NO WARRANTY; for details"); notice1 = new TextWidget (this, (int)((TITLE_WIDTH-strlen(temp)*9)/2), 260, temp); strcpy (temp, "press button 'Warranty'. This is free software, and"); notice2 = new TextWidget (this, (int)((TITLE_WIDTH-strlen(temp)*9)/2), 280, temp); strcpy (temp, "you are welcome to redistribute it under certain"); notice3 = new TextWidget (this, (int)((TITLE_WIDTH-strlen(temp)*9)/2), 300, temp); strcpy (temp, "conditions; press button 'Licence' for details."); notice4 = new TextWidget (this, (int)((TITLE_WIDTH-strlen(temp)*9)/2), 320, temp); isGNULicenceInterfaceLaunched = 0; loadPixmap (); } void TitleInterface::manageWindow () { XEvent report; int end=0; while (!end) { XNextEvent (display, &report); if (manageInterface (report) == endInterface) { end = 1; } } } actionType TitleInterface::manageInterface (XEvent report) { if (continueButton->manageEvent (report) == buttonPressed) { return endInterface; } if (warrantyButton->manageEvent (report) == buttonPressed) { if (!isGNULicenceInterfaceLaunched) { licenceInterface = new GNULicenceInterface (10, 50, display, DATAPATH, GNU_LICENCE_FILE); isGNULicenceInterfaceLaunched = 1; } licenceInterface->goToLine (257); } if (licenceButton->manageEvent (report) == buttonPressed) { if (!isGNULicenceInterfaceLaunched) { licenceInterface = new GNULicenceInterface (10, 50, display, DATAPATH, GNU_LICENCE_FILE); isGNULicenceInterfaceLaunched = 1; } licenceInterface->goToLine (0); } if (iconWindow->manageEvent (report) == mustBeRefreshed) { displayIcon (); } title1->manageEvent (report); title2->manageEvent (report); title3->manageEvent (report); title4->manageEvent (report); notice1->manageEvent (report); notice2->manageEvent (report); notice3->manageEvent (report); notice4->manageEvent (report); if (isGNULicenceInterfaceLaunched) { if (licenceInterface->manageInterface (report) == endInterface) { isGNULicenceInterfaceLaunched = 0; delete licenceInterface; } } return noAction; } void TitleInterface::refresh () { if (iconWindow->shouldBeRefreshed ()) displayIcon (); licenceButton->refresh (); warrantyButton->refresh (); continueButton->refresh (); title1->refresh (); title2->refresh (); title3->refresh (); title4->refresh (); notice1->refresh (); notice2->refresh (); notice3->refresh (); notice4->refresh (); if (isGNULicenceInterfaceLaunched) { licenceInterface->refresh (); } } /* methode de chargement de l'icone de la guepe */ void TitleInterface::loadPixmap () { XpmAttributes xpma; xpma.valuemask = XpmExactColors; if (defaultDepth == 1) { if (XpmCreatePixmapFromData (display, iconWindow->win, WaspIconBW, &waspPixmap, NULL, &xpma) != 0) printf ("ERROR >> unable to create WaspIcon\n"); } else { if (XpmCreatePixmapFromData (display, iconWindow->win, WaspIcon, &waspPixmap, NULL, &xpma) != 0) printf ("ERROR >> unable to create WaspIcon\n"); } XpmFreeAttributes (&xpma); } void TitleInterface::displayIcon () { XCopyArea (display, waspPixmap, iconWindow->win, *gc, 0, 0, PIXMAP_WIDTH, PIXMAP_HEIGHT , 0, 0); } /* ----------------------------------------------------------- */ GNULicenceInterface::GNULicenceInterface (int x0, int y0, Display* aDisplay, char* pathName, char* fileName) : Interface (x0, y0, 740, 580, 1, "GNU General Public License", "License", aDisplay) { closeButton = new Button (this, 630, 10, 100, 25, "Close", centerJustified, enabled); fileViewer = new FileViewer (this, 10, 50, 720, 520, enabled, Grey, pathName, fileName, "GNU GENERAL PUBLIC LICENSE"); } GNULicenceInterface::~GNULicenceInterface () { delete closeButton; delete fileViewer; } actionType GNULicenceInterface::manageInterface (XEvent report) { if (closeButton->manageEvent (report) == buttonPressed) { return endInterface; } fileViewer->manageEvent (report); return noAction; } void GNULicenceInterface::refresh () { closeButton->refresh (); fileViewer->refresh (); } void GNULicenceInterface::goToLine (int line) { fileViewer->goToLine (line); }