/****************************************************************** * * * 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 : graphical.h Component : graphical interface Fonctionality : contains specifications refering to the graphical interface (Xlib) ******************************************************************/ #ifndef __graphical_H #define __graphical_H #include #include #include #include #include #include #include #include #define BRS 20 /* Roundsize for button displaying */ #define RS 30 /* Roundsize for RoundPanel */ #define maxEnum 30 /* maximum items number in enumerations */ #define maxTextInputLinks 30 /* maximum TextInput for a GraphicElement */ class GraphicElement; class Interface; class GraphicWidget; class Button; class DialogBox; class InfoBox; class ArrayWindow; class MenuEnum; class RightArrow; class LeftArrow; class UpArrow; class DownArrow; class TextWidget; class TextInput; class InputDialogBox; class FileViewer; class Enumeration; class TextInputLinks; enum displayModeType { colorMode, blackAndWhiteMode }; enum buttonStateType { pressed, notPressed }; enum fonctionStateType { enabled, disabled }; enum pressFunctionType { normal, continuePressing }; enum justifType { centerJustified, leftJustified }; #define COLOR_NUMBER 18 enum colorType { Black, Grey, LightGrey, LightBlue, Red2, Blue, Red, Red3, Gold, GoldenRod, DarkGoldenRod, Yellow, Red4, Green, HardGrey, White, HardBlue, MediumBlue }; enum actionType { noAction, buttonPressed, endOfPression, mustBeRefreshed, endInterface, endInterfaceAndSave, upKeyPressed, downKeyPressed, button1Pressed, button2Pressed, button3Pressed, selectionChanged, doubleClick, returnPressed, simpleSignal }; enum ArrayContentType { CharType, DoubleType, IntType, LongType, EnumType }; /* ----------------------------------------------------------------- Cette classe permet de creer des relations entre les differents objets TextInput (objets de saisie de texte) ----------------------------------------------------------------- */ class TextInputLinks { public: TextInputLinks (); ~TextInputLinks (); void addLink (TextInput* aLink); TextInput* getLink (int linkNumber); TextInput* getCurrentLink (); void print (); int number; /* number of TextInput widgets */ int isEdited; /* specify if a TextInput is currently edited */ int current; /* specify which TextInput is currently edited */ protected: TextInput* textInput[maxTextInputLinks]; }; /* ----------------------------------------------------------------- Cette classe est la classe a la racine de tous les elements graphiques. Elle contients differentes informations utiles partout. ----------------------------------------------------------------- */ class GraphicElement { public: GraphicElement (); GraphicElement (GraphicElement* aGraphicElement); ~GraphicElement (); Display *display; unsigned long* color; GC* gc; XFontStruct *fontInfo; Window win; displayModeType displayMode; XEvent report; colorType borderColor, backgroundColor; TextInputLinks textInputLinks; GraphicElement* previous; void printLinks (); }; /* ----------------------------------------------------------------- La classe Interface est la classe de base d'une interface-utilisateur. Pour generer une Interface, il suffit de creer une classe dérivant de cette classe, et d'y placer tous les objets desires. ----------------------------------------------------------------- */ class Interface : public GraphicElement { public: Interface (int x0, int y0, int aWidth, int aHeight, int constSize, char* windowLabel, char* iconLabel); Interface (int x0, int y0, int aWidth, int aHeight, int constSize, char* windowLabel, char* iconLabel, Display* aDisplay); /* Si on a jamais ouvert de display, alors faire constructeur sans display sinon on fait le constructeur avec display Si constSize = 1, alors on ne peut modifier dynamiquement la taille de la fenetre, si c'est 0, on peut le faire */ virtual ~Interface (); virtual void refresh () = 0; void resizeWindow (); unsigned int displayDialogBox (Interface* toBeRefreshedInterface, char* DBWLabel, char* DBILabel, char* aText, char* choice1); unsigned int displayDialogBox (Interface* toBeRefreshedInterface, char* DBWLabel, char* DBILabel, char* aText, char* choice1, char* choice2); unsigned int displayDialogBox (Interface* toBeRefreshedInterface, char* DBWLabel, char* DBILabel, char* aText, char* choice1, char* choice2, char* choice3); unsigned int displayDialogBox (Interface* toBeRefreshedInterface, char* DBWLabel, char* DBILabel, char* aText, char* choice1, char* choice2, char* choice3, char* choice4); void displayInfoBox (Interface* toBeRefreshedInterface, int x0, int y0, char* IBWLabel, char* IBILabel, char* aText); void displayInfoBox (Interface* toBeRefreshedInterface, char* IBWLabel, char* IBILabel, char* aText); void displayAbortableInfoBox (Interface* toBeRefreshedInterface, int x0, int y0, char* IBWLabel, char* IBILabel, char* aText); void displayAbortableInfoBox (Interface* toBeRefreshedInterface, char* IBWLabel, char* IBILabel, char* aText); void freeInfoBox (); unsigned int displayInputBox (Interface* toBeRefreshedInterface, char* IBWLabel, char* IBILabel, int inputNb, int maxCol); void addIntInput (char* aLabel, unsigned int aMaxWidth, int* returnedInt); void addLongInput (char* aLabel, unsigned int aMaxWidth, long* returnedLong); void addDoubleInput (char* aLabel, unsigned int aMaxWidth, double* returnedDouble); void addCharInput (char* aLabel, unsigned int aMaxWidth, char* returnedChar); void addEnumInput (char* aLabel, unsigned int aMaxWidth, Enumeration* anEnumeration); void addIntInput (char* aLabel, unsigned int aMaxWidth, int* returnedInt, fonctionStateType aFonctionState); void addLongInput (char* aLabel, unsigned int aMaxWidth, long* returnedLong, fonctionStateType aFonctionState); void addDoubleInput (char* aLabel, unsigned int aMaxWidth, double* returnedDouble, fonctionStateType aFonctionState); void addCharInput (char* aLabel, unsigned int aMaxWidth, char* returnedChar, fonctionStateType aFonctionState); void addEnumInput (char* aLabel, unsigned int aMaxWidth, Enumeration* anEnumeration, fonctionStateType aFonctionState); unsigned int manageInputBox (); InfoBox* anInfoBox; protected: int dialogBoxLaunched; int inputBoxLaunched; int displayMustBeFreed; char* windowName; char* iconName; char* displayName; XIconSize *sizeList; GC mainGC; XGCValues values; int screenNum; unsigned int width, height; int x, y; unsigned int borderWidth; unsigned int displayWidth, displayHeight; unsigned int iconWidth, iconHeight; unsigned int defaultDepth; Visual *defaultVisual; XTextProperty windowNameX, iconNameX; Pixmap iconPixmap; XSizeHints sizeHints; XWMHints wmHints; XClassHint* classHints; Colormap defaultCmap; InputDialogBox* anInputBox; void initializeInterface (int x0, int y0, int aWidth, int aHeight, int constSize, char* windowLabel, char* iconLabel); void getColor (); void getGC (); void loadFont (); }; /* ----------------------------------------------------------------- La classe GraphicWidget est la classe de base de tous les objets graphiques que l'on peut placer dans une interface. ----------------------------------------------------------------- */ class GraphicWidget : public GraphicElement { public: fonctionStateType fonctionState; /* enabled, disabled */ GraphicWidget (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, unsigned int aHeight, unsigned int aBorderWidth, colorType aBorderColor, colorType aBackgroundColor, long anEventMask, fonctionStateType aFonctionState ); virtual ~GraphicWidget (); virtual actionType manageEvent (XEvent anEvent) = 0; void refresh (); unsigned int x, y; unsigned int width, height; unsigned int borderWidth; long eventMask; }; /* --------------------------------------------------------------------- La classe Button permet de creer des boutons, on s'en doutait un peu. --------------------------------------------------------------------- */ class Button : public GraphicWidget { public: buttonStateType buttonState; /* pressed, notPressed */ Button (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, unsigned int aHeight, char* aButtonText, justifType aJustif, fonctionStateType aFonctionState); virtual ~Button (); actionType manageEvent (XEvent anEvent); void enable (); void disable (); protected: char buttonText[30]; justifType justif ; /* centerJustified, leftJustified*/ void manageRefreshEvent (); actionType manageButtonPressEvent (); virtual actionType manageButtonReleaseEvent (); void refreshButton (); void drawButton (colorType colorbg, colorType colorhg, colorType colorbd); }; /* --------------------------------------------------------------------- La classe SwapButton permet de creer des boutons `bascules' ---------------------------------------------------------------------*/ class SwapButton : public Button { public: SwapButton (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, unsigned int aHeight, char* aButtonText, char* aSwappedButtonText, justifType aJustif, fonctionStateType aFonctionState); int isSwapped (); protected: int isswapped ; char swappedButtonText[30]; char notSwappedButtonText[30]; virtual actionType manageButtonReleaseEvent (); }; /* --------------------------------------------------------------------- La classe ArrayContent permet la gestion des donnees utiles a la gestion d'une instance de la classe ArrayWindows. --------------------------------------------------------------------- */ class ArrayContent /* this class is used for memorizing datas for ArrayWindows */ { public: ArrayContent (unsigned int aMaxColumnsNumber, unsigned int aMaxLinesNumber); ~ArrayContent (); void addColumn (char* aTitle, ArrayContentType aType, unsigned int aSize); /* it's not possible to add a column if there are already lines created */ int addLine (); /* return nb of created line, -1 when failure */ void removeLine (unsigned int line); void addData (unsigned int line, unsigned int column, char* aContent); void addData (unsigned int line, unsigned int column, double aContent); void addData (unsigned int line, unsigned int column, int aContent); unsigned int getLinesNumber (); unsigned int getColumnsNumber (); char* getColumnTitle (unsigned int column); char* getCharContent (unsigned int line, unsigned int column); double getDoubleContent (unsigned int line, unsigned int column); int getIntContent (unsigned int line, unsigned int column); ArrayContentType getColumnType (unsigned int column); unsigned int getColumnSize (unsigned int column); void print (); /* only for debugging */ private: unsigned int maxColumnsNumber, maxLinesNumber; unsigned int columnsNumber, linesNumber; char** columnTitle; ArrayContentType* columnType; unsigned int* columnSize; char*** content; /* line, column, and text */ }; /* --------------------------------------------------------------------- La classe MenuEnum permet la gestion des donnees utiles a la gestion d'une instance de la classe Menu. --------------------------------------------------------------------- */ class MenuEnum { public: MenuEnum (); ~MenuEnum (); void addContent (char* aContent); unsigned int getNumber (); unsigned int getMaxLenght (); char* getContent (unsigned int index); void print (); private: unsigned int maxLenght; unsigned int number; char choice[20][30]; /* max: 20 contents of 30 characters*/ }; /* --------------------------------------------------------------------- La classe MenuEnum permet la gestion de menus deroulants (pas implante). --------------------------------------------------------------------- */ class Menu : public GraphicWidget { public: Menu (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, unsigned int aHeight, char* aMenuTitle, MenuEnum aMenuEnum, fonctionStateType aFonctionState); virtual ~Menu (); // actionType manageEvent (XEvent anEvent, int* result); protected: char menuTitle[30]; void refresh (); }; /* --------------------------------------------------------------------- La classe GraphButton permet de creer des boutons avec du graphisme dedans, c'est bien cool. --------------------------------------------------------------------- */ class GraphButton : public GraphicWidget { public: buttonStateType buttonState; /* pressed, notPressed */ GraphButton (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, unsigned int aHeight, fonctionStateType aFonctionState); GraphButton (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, unsigned int aHeight, fonctionStateType aFonctionState, pressFunctionType aPressFunction); virtual ~GraphButton (); actionType manageEvent (XEvent anEvent); virtual void refreshGraphButton () = 0; protected: int pressAgain; pressFunctionType pressFunction; void manageRefreshEvent (); actionType manageButtonPressEvent (); actionType manageButtonReleaseEvent (); }; /* --------------------------------------------------------------------- La classe LeftArrow permet de creer des boutons avec une fleche vers la gauche. --------------------------------------------------------------------- */ class LeftArrow : public GraphButton { public: LeftArrow (GraphicElement* anElement, int x0, int y0, fonctionStateType aFonctionState); LeftArrow (GraphicElement* anElement, int x0, int y0, fonctionStateType aFonctionState, pressFunctionType aPressFunction); virtual ~LeftArrow (); void refreshGraphButton (); }; /* --------------------------------------------------------------------- La classe RightArrow permet de creer des boutons avec une fleche vers la droite. --------------------------------------------------------------------- */ class RightArrow : public GraphButton { public: RightArrow (GraphicElement* anElement, int x0, int y0, fonctionStateType aFonctionState); RightArrow (GraphicElement* anElement, int x0, int y0, fonctionStateType aFonctionState, pressFunctionType aPressFunction); virtual ~RightArrow (); void refreshGraphButton (); }; /* --------------------------------------------------------------------- La classe UpArrow permet de creer des boutons avec une fleche vers le haut. --------------------------------------------------------------------- */ class UpArrow : public GraphButton { public: UpArrow (GraphicElement* anElement, int x0, int y0, fonctionStateType aFonctionState); UpArrow (GraphicElement* anElement, int x0, int y0, fonctionStateType aFonctionState, pressFunctionType aPressFunction); virtual ~UpArrow (); void refreshGraphButton (); }; /* --------------------------------------------------------------------- La classe DownArrow permet de creer des boutons avec une fleche vers le bas. --------------------------------------------------------------------- */ class DownArrow : public GraphButton { public: DownArrow (GraphicElement* anElement, int x0, int y0, fonctionStateType aFonctionState); DownArrow (GraphicElement* anElement, int x0, int y0, fonctionStateType aFonctionState, pressFunctionType aPressFunction); virtual ~DownArrow (); void refreshGraphButton (); }; /* --------------------------------------------------------------------- La classe DownSquare permet de creer des boutons carres avec un moins --------------------------------------------------------------------- */ class DownSquare : public GraphButton { public: DownSquare (GraphicElement* anElement, int x0, int y0, fonctionStateType aFonctionState); DownSquare (GraphicElement* anElement, int x0, int y0, fonctionStateType aFonctionState, pressFunctionType aPressFunction); virtual ~DownSquare (); void refreshGraphButton (); }; /* --------------------------------------------------------------------- La classe DownSquare permet de creer des boutons carres avec un plus. --------------------------------------------------------------------- */ class UpSquare : public GraphButton { public: UpSquare (GraphicElement* anElement, int x0, int y0, fonctionStateType aFonctionState); UpSquare (GraphicElement* anElement, int x0, int y0, fonctionStateType aFonctionState, pressFunctionType aPressFunction); virtual ~UpSquare (); void refreshGraphButton (); }; /* --------------------------------------------------------------------- La classe PassiveWidget est la classe de base de tous les objets graphiques qui n'ont pas de comportement interactif. --------------------------------------------------------------------- */ class PassiveWidget : public GraphicWidget { public: PassiveWidget (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, unsigned int aHeight); virtual ~PassiveWidget (); actionType manageEvent (XEvent anEvent); virtual void refreshWidget () = 0; protected: void manageRefreshEvent (); }; /* --------------------------------------------------------------------- La classe HorizontalBar permet de creer des lignes horizontales. --------------------------------------------------------------------- */ class HorizontalBar : public PassiveWidget { public: HorizontalBar (GraphicElement* anElement, int x0, int y0, unsigned int aWidth); virtual ~HorizontalBar (); void refreshWidget (); }; /* --------------------------------------------------------------------- La classe VerticalBar permet de creer des lignes verticales. --------------------------------------------------------------------- */ class VerticalBar : public PassiveWidget { public: VerticalBar (GraphicElement* anElement, int x0, int y0, unsigned int aHeight); virtual ~VerticalBar (); void refreshWidget (); }; /* --------------------------------------------------------------------- La classe RoundPanel permet de creer un panneau de groupement (fonce). --------------------------------------------------------------------- */ class RoundPanel : public PassiveWidget { public: RoundPanel (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, unsigned int aHeight); virtual ~RoundPanel (); void refreshWidget (); }; /* --------------------------------------------------------------------- La classe TextWidget permet de creer des textes (non editables) --------------------------------------------------------------------- */ class TextWidget : public PassiveWidget { public: TextWidget (GraphicElement* anElement, int x0, int y0, char* aText); virtual ~TextWidget (); void refreshWidget (); void change (char* aText); void setBoldDisplay (); void inverseDisplay (); void normalDisplay (); protected: char text[256]; int inversedDisplay; int boldDisplay; }; /* --------------------------------------------------------------------- La classe SelectableTextWidget permet de creer des textes (non editables, mais que l'on peut selectionner). --------------------------------------------------------------------- */ class SelectableTextWidget : public TextWidget { public: SelectableTextWidget (GraphicElement* anElement, int x0, int y0, char* aText); virtual ~SelectableTextWidget (); actionType manageEvent (XEvent anEvent); }; /* --------------------------------------------------------------------- La classe GraphicWindow permet de creer des fenetres graphiques, dont la gestion est laissee a la responsabilite du developpeur. --------------------------------------------------------------------- */ class GraphicWindow : public GraphicWidget { public: GraphicWindow (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, unsigned int aHeight, fonctionStateType aFonctionState, long anEventMask, colorType aBackgroundColor); virtual ~GraphicWindow (); actionType manageEvent (XEvent anEvent); int shouldBeRefreshed (); /* return 1 when is should be refreshed */ protected: actionType manageRefreshEvent (); }; /* --------------------------------------------------------------------- La classe ArrayWindow permet de creer une fenetre avec des lignes de donnees, que l'on peut scroller, selectionner, etc... --------------------------------------------------------------------- */ class ArrayWindow : public GraphicWidget { public: ArrayWindow (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, unsigned int aHeight, fonctionStateType aFonctionState, colorType aBackgroundColor, ArrayContent* anArrayContent); virtual ~ArrayWindow (); actionType manageEvent (XEvent anEvent); void refresh (); void reset (); void refreshAll (); int addLine (); void removeLine (unsigned int line); void addData (unsigned int line, unsigned int column, char* aChar); void addData (unsigned int line, unsigned int column, int aInt); void addData (unsigned int line, unsigned int column, double aDouble); int getSelectedLine (); /* -1 when no selected */ int setSelectedLine (); /* -1 when no selected */ void disableSelection (); void enableSelection (); int getFirstLine (); void goToLine (int line); GraphicWindow* textPanel; protected: int selectionEnabled; void manageRefreshEvent (); void setTextLines (); void setTextLine (unsigned int line); void refreshTextLines (); Button* previousPageButton; Button* nextPageButton; UpArrow* upButton; DownArrow* downButton; HorizontalBar* bar1; HorizontalBar* bar2; HorizontalBar* bar3; HorizontalBar* bar4; TextWidget* titleLine; SelectableTextWidget** textLine; time_t previousTime; int previousSelected; ArrayContent* arrayContent; int numberOfLines; int lenghtOfLine; int currentLine; /* -1 when nothing selected */ int firstLine; char blank[256]; }; /* --------------------------------------------------------------------- La classe DialogBox permet de creer une boite de dialogue (en fait cet objet propose des choix avec un bouton par choix). --------------------------------------------------------------------- */ class DialogBox : public Interface { public: DialogBox (Interface* toBeRefreshedInterface, int x0, int y0, int aWidth, int aHeight, char* DBWLabel, char* DBILabel, char* aText, char* choice1, Display* aDisplay); DialogBox (Interface* toBeRefreshedInterface, int x0, int y0, int aWidth, int aHeight, char* DBWLabel, char* DBILabel, char* aText, char* choice1, char* choice2, Display* aDisplay); DialogBox (Interface* toBeRefreshedInterface, int x0, int y0, int aWidth, int aHeight, char* DBWLabel, char* DBILabel, char* aText, char* choice1, char* choice2, char* choice3, Display* aDisplay); DialogBox (Interface* toBeRefreshedInterface, int x0, int y0, int aWidth, int aHeight, char* DBWLabel, char* DBILabel, char* aText, char* choice1, char* choice2, char* choice3, char* choice4, Display* aDisplay); virtual ~DialogBox (); unsigned int manageDialogBox (); void refresh (); protected: Interface* toBeRefreshed; int choiceNumber; TextWidget* theText; Button* choiceButton1; Button* choiceButton2; Button* choiceButton3; Button* choiceButton4; }; /* --------------------------------------------------------------------- La classe InputDialogBox permet de creer une boite de dialogue (avec des possibilites de saisie, cette fois-ci). --------------------------------------------------------------------- */ class InputDialogBox : public Interface { public: InputDialogBox (Interface* toBeRefreshedInterface, int x0, int y0, int aWidth, int aHeight, unsigned inputNb, char* DBWLabel, char* DBILabel); virtual ~InputDialogBox (); void addIntInput (char* aLabel, unsigned int aMaxWidth, int* returnedInt); void addLongInput (char* aLabel, unsigned int aMaxWidth, long* returnedLong); void addDoubleInput (char* aLabel, unsigned int aMaxWidth, double* returnedDouble); void addCharInput (char* aLabel, unsigned int aMaxWidth, char* returnedChar); void addEnumInput (char* aLabel, unsigned int aMaxWidth, Enumeration* anEnumeration); void addIntInput (char* aLabel, unsigned int aMaxWidth, int* returnedInt, fonctionStateType aFonctionState); void addLongInput (char* aLabel, unsigned int aMaxWidth, long* returnedLong, fonctionStateType aFonctionState); void addDoubleInput (char* aLabel, unsigned int aMaxWidth, double* returnedDouble, fonctionStateType aFonctionState); void addCharInput (char* aLabel, unsigned int aMaxWidth, char* returnedChar, fonctionStateType aFonctionState); void addEnumInput (char* aLabel, unsigned int aMaxWidth, Enumeration* anEnumeration, fonctionStateType aFonctionState); /* !!!! Be sure you've reserved memory space in returned value !!!! */ unsigned int manageInputDialogBox (); /* return 0 if ok else 1 when cancel*/ void refresh (); protected: Interface* toBeRefreshed; unsigned int current; Button* acceptButton; Button* cancelButton; TextInput** input; }; /* --------------------------------------------------------------------- La classe InfoBox permet de creer une fenetre avec un label et une barre defilante en fonction du travail a accomplir. On a aussi un bouton pour arreter le travail en cours. --------------------------------------------------------------------- */ class InfoBox : public Interface { public: InfoBox (Interface* toBeRefreshedInterface, int x0, int y0, int aWidth, int aHeight, char* IBWLabel, char* IBILabel, char* aText, int isAbortable); virtual ~InfoBox (); void setStatWindow (double val); int refreshStatWindow (); /* retourne 1 si bouton abort appuye */ void refresh (); protected: Interface* toBeRefreshed; Button* abortButton; TextWidget* theText; GraphicWindow* statWindow; double stat; int abortable; }; /* --------------------------------------------------------------------- La classe TextInput permet la saisie de texte (avec des types predetermines (chaine de caracteres, entier, entier long, flottant, enumerations, etc...). --------------------------------------------------------------------- */ class TextInput : public GraphicWidget { public: /* constructor for a char TextInput */ TextInput (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, char* aLabel, char* initValue, fonctionStateType aFonctionState); /* constructor for a double TextInput */ TextInput (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, char* aLabel, double* initValue, fonctionStateType aFonctionState); /* constructor for a int TextInput */ TextInput (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, char* aLabel, int* initValue, fonctionStateType aFonctionState); /* constructor for a double TextInput */ TextInput (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, char* aLabel, long* initValue, fonctionStateType aFonctionState); /* constructor for a enumeration TextInput */ TextInput (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, char* aLabel, Enumeration* anEnumeration, fonctionStateType aFonctionState); virtual ~TextInput (); actionType manageEvent (XEvent anEvent); void refresh (); int returnEnumerateValue (); int returnIntValue (); long returnLongValue (); double returnDoubleValue (); char* returnCharValue (); void enable (); void disable (); void changeIntValue (int* initValue); void changeLongValue (long* initValue); void changeDoubleValue (double* initValue); void changeCharValue (char* initValue); void changeEnumValue (int initValue); char* returnLabel (); void editText (); void uneditText (); ArrayContentType varType; double* doubleValue; int* intValue; long* longValue; char* charValue; /* contains the adresses where to store the new value */ protected: Enumeration* enumeration; int enumerationMode; Cursor textCursor; TextWidget* labelWidget; char label[50]; char value[256]; /* max 256 caracters in an InputText widget */ int cursorPos; int decal; int editing; /* 1 when editing, else 0 */ unsigned int maxWidth; int insertMode; /* 1 when insertMode, else 0 */ void refreshLabel (); void refreshValue (); void manageRefreshEvent (); void manageButtonPressEvent (); void manageButtonReleaseEvent (); actionType manageKeyPressEvent (); void manageKeyReleaseEvent (); }; /* --------------------------------------------------------------------- La classe FileViewer permet de creer une fenetre avec un editeur de texte (en fait read-only, faut pas exagerer). --------------------------------------------------------------------- */ class FileViewer { public: FileViewer (GraphicElement* anElement, int x0, int y0, unsigned int aWidth, unsigned int aHeight, fonctionStateType aFonctionState, colorType aBackgroundColor, char* aPathName, char* aFileName, char* title); ~FileViewer (); actionType manageEvent (XEvent anEvent); void refresh (); void reload (); void goToLine (int line); protected: ArrayWindow* arrayWindow; ArrayContent* arrayContent; TextWidget* currentLineText; char pathName[80]; char fileName[80]; int totalLine; int currentLine; }; /* --------------------------------------------------------------------- La classe Enumeration permet de gerer des enumerations (comme son nom l'indique d'ailleurs, comme quoi mon anglais....) --------------------------------------------------------------------- */ class Enumeration { public: Enumeration (); ~Enumeration (); void add (char* anEnum); /* when possible */ char* get (int index); /* when possible */ char* getDefault (); int defaultValue (); void incDefault (); /* when possible */ void decDefault (); /* when possible */ void setDefault (int aDefaultValue); /* when possible */ void clear (); /* after this method, Enumeration object is empty */ protected: int number; int defaultIndex; char enumText[maxEnum][20]; /* max maxEnum enumerations of 20 caracters */ }; #endif