2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
#ifndef __UI_H
|
|
|
|
#define __UI_H
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
class TextWindow {
|
|
|
|
public:
|
|
|
|
static const int MAX_COLS = 150;
|
|
|
|
static const int MAX_ROWS = 300;
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
#ifndef RGB
|
|
|
|
#define RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
|
|
|
|
#endif
|
|
|
|
static const int COLOR_BG_DEFAULT = RGB( 15, 15, 0);
|
|
|
|
static const int COLOR_FG_DEFAULT = RGB(255, 255, 255);
|
|
|
|
static const int COLOR_BG_CMDLINE = RGB( 0, 20, 80);
|
|
|
|
static const int COLOR_FG_CMDLINE = RGB(255, 255, 255);
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
typedef struct {
|
|
|
|
int fg;
|
|
|
|
int bg;
|
|
|
|
} Color;
|
|
|
|
static const Color colors[];
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
// The line with the user-typed command, that is currently being edited.
|
|
|
|
char cmd[MAX_COLS];
|
|
|
|
int cmdInsert;
|
|
|
|
int cmdLen;
|
|
|
|
|
|
|
|
// The rest of the window, text displayed in response to typed commands;
|
|
|
|
// some of this might do something if you click on it.
|
|
|
|
|
|
|
|
static const int NOT_A_LINK = 0;
|
|
|
|
|
|
|
|
static const int COLOR_NORMAL = 0;
|
|
|
|
|
|
|
|
BYTE text[MAX_ROWS][MAX_COLS];
|
2008-03-28 10:00:37 +00:00
|
|
|
typedef void LinkFunction(int link, DWORD v);
|
2008-03-25 10:02:13 +00:00
|
|
|
struct {
|
2008-03-28 10:00:37 +00:00
|
|
|
int color;
|
|
|
|
int link;
|
|
|
|
DWORD data;
|
|
|
|
LinkFunction *f;
|
2008-03-25 10:02:13 +00:00
|
|
|
} meta[MAX_ROWS][MAX_COLS];
|
|
|
|
|
|
|
|
int row0, rows;
|
|
|
|
|
|
|
|
void Init(void);
|
|
|
|
void Printf(char *fmt, ...);
|
|
|
|
void ClearScreen(void);
|
|
|
|
|
|
|
|
void ClearCommand(void);
|
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
void ProcessCommand(char *cmd);
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
// These are called by the platform-specific code.
|
|
|
|
void KeyPressed(int c);
|
|
|
|
bool IsHyperlink(int width, int height);
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
class GraphicsWindow {
|
|
|
|
public:
|
2008-03-26 09:18:12 +00:00
|
|
|
// This table describes the top-level menus in the graphics winodw.
|
|
|
|
typedef void MenuHandler(int id);
|
|
|
|
typedef struct {
|
2008-04-01 10:48:44 +00:00
|
|
|
int level; // 0 == on menu bar, 1 == one level down
|
2008-03-26 09:18:12 +00:00
|
|
|
char *label; // or NULL for a separator
|
|
|
|
int id; // unique ID
|
|
|
|
MenuHandler *fn;
|
|
|
|
} MenuEntry;
|
|
|
|
static const MenuEntry menu[];
|
|
|
|
|
2008-04-01 10:48:44 +00:00
|
|
|
// The width and height (in pixels) of the window.
|
|
|
|
double width, height;
|
2008-03-25 10:02:13 +00:00
|
|
|
// These parameters define the map from 2d screen coordinates to the
|
|
|
|
// coordinates of the 3d sketch points. We will use an axonometric
|
|
|
|
// projection.
|
|
|
|
Vector offset;
|
|
|
|
Vector projRight;
|
|
|
|
Vector projDown;
|
2008-03-27 09:53:51 +00:00
|
|
|
double scale;
|
|
|
|
struct {
|
|
|
|
Vector offset;
|
|
|
|
Vector projRight;
|
|
|
|
Vector projDown;
|
|
|
|
Point2d mouse;
|
|
|
|
} orig;
|
|
|
|
|
|
|
|
void Init(void);
|
|
|
|
void NormalizeProjectionVectors(void);
|
2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
// These are called by the platform-specific code.
|
2008-03-27 09:53:51 +00:00
|
|
|
void Paint(int w, int h);
|
2008-03-25 10:02:13 +00:00
|
|
|
void MouseMoved(double x, double y, bool leftDown, bool middleDown,
|
2008-03-27 09:53:51 +00:00
|
|
|
bool rightDown, bool shiftDown, bool ctrlDown);
|
|
|
|
void MouseLeftDown(double x, double y);
|
2008-03-25 10:02:13 +00:00
|
|
|
void MouseLeftDoubleClick(double x, double y);
|
2008-03-27 09:53:51 +00:00
|
|
|
void MouseMiddleDown(double x, double y);
|
2008-04-01 10:48:44 +00:00
|
|
|
void MouseScroll(double x, double y, int delta);
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
#endif
|