-
Notifications
You must be signed in to change notification settings - Fork 0
/
winbgitypes.h
110 lines (94 loc) · 5.6 KB
/
winbgitypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// $Id: winbgitypes.h,v 1.13 2003/07/21 23:14:45 bush Exp $
// Written by:
// Grant Macklem ([email protected])
// Gregory Schmelter ([email protected])
// Alan Schmidt ([email protected])
// Ivan Stashak ([email protected])
// CSCI 4830/7818: API Programming
// University of Colorado at Boulder, Spring 2003
// http://www.cs.colorado.edu/~main/bgi
#ifndef WINBGITYPES_H
#define WINBGITYPES_H
#include <windows.h> // Provides the Win32 API
#include <tchar.h> // Provides the _T macro
#include <queue> // Provides STL queue class
#include <string> // Provides STL string class
#include "winbgi.h" // Provides other structures
// Define maximum pages used for drawing.
#define MAX_PAGES 4
typedef void (*Handler)(int, int);
// ---------------------------------------------------------------------------
// Structures
// ---------------------------------------------------------------------------
// This structure gives all necessary information to the ThreadInitWindow
// function which creates a new window and processes its messages
struct WindowData
{
int width; // Width of window to create
int height; // Height of window to create
int initleft, inittop; // Initial top and left coordinates on screen
std::string title; // Title at the top of the window
std::queue<TCHAR> kbd_queue;// Queue of keyboard characters
arccoordstype arcInfo; // Information about the last arc drawn
fillsettingstype fillInfo; // Information about the fill style
char uPattern[8]; // A user-defined fill style
linesettingstype lineInfo; // Information about the line style
textsettingstype textInfo; // Information about the text style
viewporttype viewportInfo; // Information about the viewport
HWND hWnd; // Handle to the window created
HDC hDC[MAX_PAGES]; // Device contexts used for double buffering
HBITMAP hOldBitmap[MAX_PAGES]; // The bitmaps generated with CreateCompatibleBitmap
int VisualPage; // The current device context used for painting the window
int ActivePage; // The current device context used for drawing
bool DoubleBuffer; // Whether the user wants a double buffered window (DOUBLE_BUFFER in initwindow)
bool CloseBehavior; // false (do nothing); true (exit program)
int drawColor; // The current drawing color (That the user gave us)
int bgColor; // The current background color (That the user gave us)
// TODO: Maybe cahnge bgColor to always be the 0 index into the palette
HANDLE key_waiting; // Event signaled when a key is pressed
HANDLE WindowCreated; // Running event
DWORD threadID; // ID of thread
int error_code; // Error code used by graphresult (usually grOk)
int x_aspect_ratio; // Horizontal Aspect Ratio
int y_aspect_ratio; // Vertical Aspect Ratio
HBITMAP hbitmap; // The bitmap of the image the user loaded
POINT ipBitmap; // Location to draw the image
PBITMAPINFO pbmpInfo; // Bitmap header info
int t_scale[4]; // scaling factor for fonts multx, divx, multy, divy
UINT alignment; // current alignment
POINTS mouse; // Current location of the mouse
std::queue<POINTS> clicks[WM_MOUSELAST - WM_MOUSEFIRST + 1]; // Array to hold the coordinates of the clicks
bool mouse_queuing[WM_MOUSELAST - WM_MOUSEFIRST + 1]; // Array to tell whether mouse events should be queued
Handler mouse_handlers[WM_MOUSELAST - WM_MOUSEFIRST + 1]; // Array of mouse event handlers
bool refreshing; // True if autorefershing should be done after each drawing event
HANDLE hDCMutex; // A mutex so that only one thread at a time can access the hDC array.
};
// maybe need current position for lines, text, etc.
// palette settings
// graph error result
// lock on window
// ---------------------------------------------------------------------------
// Prototypes
// ---------------------------------------------------------------------------
// The entry point for each new window thread (WindowThread.cpp)
DWORD WINAPI BGI__ThreadInitWindow( LPVOID pThreadData );
// Returns a DC for the window specified by hWnd. If hWnd is NULL, the
// current window us used (drawing.cpp)
HDC BGI__GetWinbgiDC( HWND hWnd = NULL );
void BGI__ReleaseWinbgiDC( HWND hWnd = NULL );
// Returns a pointer to the window data structure associated with hWnd.
// If hWnd is NULL, the current window is used (drawing.cpp)
WindowData* BGI__GetWindowDataPtr( HWND hWnd = NULL );
// Refreshes an area of the window:
void RefreshWindow( RECT* rect );
// ---------------------------------------------------------------------------
// Global Variables
// ---------------------------------------------------------------------------
#include <vector> // MGM: Added for WindowTable
extern std::vector<HWND> BGI__WindowTable; // WindowThread.cpp
extern int BGI__WindowCount; // Number of windows currently in use, WindowThread.cpp
extern int BGI__CurrentWindow; // Index to current window, WindowThread.cpp
extern COLORREF BGI__Colors[16]; // The RGB values for the Borland 16 colors, misc.cpp
extern HINSTANCE BGI__hInstance; // Handle to the instance of the DLL
// (creating the window class) WindowThread.cpp
#endif // WINBGITYPES_H