/* -*- c++ -*- FILE: MachineX.h RCS REVISION: $Revision: 1.12 $ COPYRIGHT: (c) 1999 -- 2003 Melinda Green, Don Hatch, and Jay Berkenbilt - Superliminal Software LICENSE: Free to use and modify for non-commercial purposes as long as the following conditions are adhered to: 1) Obvious credit for the source of this code and the designs it embodies are clearly made, and 2) Ports and derived versions of 4D Magic Cube programs are not distributed without the express written permission of the authors. DESCRIPTION: This is the Xlib/Xt Machine interface. */ #ifndef MACHINEX_H #define MACHINEX_H #include "Machine.h" #include #include #include #include class PuzzleState; class MachineX; class WidgetsX; class EventHandler; class MachineX: public Machine { public: MachineX(EventHandler*, int& argc, char *argv[], Preferences& prefs); virtual ~MachineX(); virtual void init(PuzzleState*); virtual void drawFrame(struct frame *); virtual void frontBuffer(); virtual void backBuffer(); virtual void swapBuffers(); virtual void addEventHandler(unsigned int eventmask, Machine::event_handler handler, void *arg = 0); virtual void eventLoop(); virtual void setColors(); virtual void toggleOutline(); virtual void turnBackgroundBlack(); virtual void turnBackgroundWhite(); virtual void bell(); virtual bool getEventIfThereIsOne(int eventmask, EventHandler::Event* event); virtual Widgets* getWidgets(); static void dispatchEvent(Widget, XtPointer arg, XEvent* xevent, Boolean *); private: struct AppRes { Boolean outline; Boolean redraw; Boolean rightmacros; Boolean fastautomoves; Boolean nobuttons; String faceshrink; String degrees; String nframes180; String nframes120; String nframes90; String eyew; String eyez; String nshades; String tilt; String twirl; String nscramblechen; String logfile; String stickershrink; String face_colors[8]; }; class EventClosure { public: EventClosure(MachineX* m, Machine::event_handler h, void *arg) : machine(m), handler(h), arg(arg) { }; MachineX* machine; Machine::event_handler handler; void *arg; }; char *expandTwiddles(char* s); void putenvFromString(char* variable, char* val); void putenvFromBool(char* variable, Boolean val); void resourcesToEnvironment(); int getFileLength(char *filename); void makeSureTheGCsExistAndEverything(); int numberOfAvailableColormapEntries(); void makeNewBackbuffer(); bool xeventToEvent(XEvent *, EventHandler::Event *); EventMask eventMaskToXEventMask(unsigned int eventmask); void XtFPrintWidgetName(FILE* fp, Widget wid); void XtPrintWidgetName(Widget wid); static char *default_face_colors[]; static XrmOptionDescRec options[]; static XtResource resources[]; static int const MAXSHADES = 32; int nshades; unsigned long colormap_entries[NFACES][MAXSHADES]; Preferences& preferences; EventHandler* event_handler; PuzzleState* puzzle_state; WidgetsX* widgets_x; char* window_title; bool Xverbose; bool do_outline; AppRes app_res; Widget toplevel; Widget widget; // drawing window GC gc, bggc, outlinegc; Pixel black_pixel, white_pixel; Pixmap backbuffer; Drawable current; // the window or the backbuffer unsigned int window_width; unsigned int window_height; unsigned int window_depth; }; #endif // Local Variables: // c-basic-offset: 4 // c-comment-only-line-offset: 0 // c-file-offsets: ((defun-block-intro . +) (block-open . 0) (substatement-open . 0) (statement-cont . +) (statement-case-open . +4) (arglist-intro . +) (arglist-close . +) (inline-open . 0)) // indent-tabs-mode: nil // End: