Main Page | Data Structures | Directories | File List | Data Fields | Globals

lcwin32.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------- *
00002  * lcwin32.h
00003  * This file is part of lincity.
00004  * Lincity is copyright (c) I J Peters 1995-1997, (c) Greg Sharp 1997-2001.
00005  * ---------------------------------------------------------------------- */
00006 #ifndef __lcwin32_h__
00007 #define __lcwin32_h__
00008 
00009 // Turn off compiler warning converting const double to float
00010 #pragma warning(disable : 4244)
00011 
00012 
00013 /* ---------------------------------------------------------------------- *
00014  * Defines
00015  * ---------------------------------------------------------------------- */
00016 #define APPNAME "Lincity"
00017 
00018 // Operating System Versions
00019 #if defined (WIN32)
00020 #define IS_WIN32 TRUE
00021 #else   /*  */
00022 #define IS_WIN32 FALSE
00023 #endif  /*  */
00024 #define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
00025 #define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
00026 #define IS_WIN95 (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
00027 
00028 #define WINWIDTH 640
00029 #define WINHEIGHT 480
00030 
00031 // Palette and DIB constants
00032 #define PALETTESIZE      256
00033 #define PALVERSION   0x300
00034 
00035 
00036 // ---------------------------------------------------------------------------
00037 // Macros
00038 // ---------------------------------------------------------------------------
00039 /* Handle to a DIB */ 
00040 DECLARE_HANDLE (HDIB);
00041 
00042 
00043 // DIB Macros
00044 #define IS_WIN30_DIB(lpbi)  ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))
00045 #define RECTWIDTH(lpRect)     ((lpRect)->right - (lpRect)->left)
00046 #define RECTHEIGHT(lpRect)    ((lpRect)->bottom - (lpRect)->top)
00047 
00048 // WIDTHBYTES performs DWORD-aligning of DIB scanlines.  The "bits"
00049 // parameter is the bit count for the scanline (biWidth * biBitCount),
00050 // and this macro returns the number of DWORD-aligned bytes needed
00051 // to hold those bits.
00052 #define WIDTHBYTES(bits)    (((bits) + 31) / 32 * 4)
00053 
00054 
00055 // ---------------------------------------------------------------------------
00056 // Type Definitions
00057 // ---------------------------------------------------------------------------
00058 typedef struct _disp 
00059 {
00060     HINSTANCE hInst;    
00061     HANDLE hAccelTable;
00062 
00063     HWND hWnd;
00064     HDC hdcMem;
00065     HBITMAP hBitmap;            // Backing store
00066 
00067     HDC hSaveUnderHdc;
00068     HBITMAP hSaveUnderBitmap;
00069 
00070     int winX;
00071     int winY;
00072     int winW;
00073     int winH;
00074 
00075     BOOL fullscreen;
00076     INT screenW;                // Width of screen
00077     INT screenH;                // Height of screen
00078     INT winFullscreenClientW;   // Width of full screen window
00079     INT winFullscreenClientH;   // Height of full screen window
00080     INT clientW;                // Width of pixmap (adjusted by borderx/pix_double)
00081     INT clientH;                // Height of pixmap (adjusted by borderx/pix_double)
00082     long colorDepth;            // Number of color planes (e.g. 24 for full color)
00083     int min_h;                  // Minimum size for resizing
00084     int min_w;                  // Minimum size for resizing
00085 
00086     BOOL useDIB;                // Use DIB or DDB?
00087     BITMAPINFO *pbminfo;        // DIB Header
00088     PBYTE pBits;                // DIB Bits
00089     HBITMAP hDIB;               // DIB BITMAP
00090 
00091     BOOL hasPalette;
00092     INT paletteSize;            // Only valid if hasPalette
00093     INT defaultPaletteSize;     // Only valid if hasPalette
00094     HANDLE hPal;                // Handle to the application's logical palette
00095     HANDLE hPaletteMemOri;      // Original palette for hdcMem
00096     NPLOGPALETTE pLogPal;       // Pointer to program's logical palette
00097     COLORREF colorrefPal[256];  // For mapping index to COLORREF (for full color)
00098     HBRUSH brushPal[256];       // For mapping index to HBRUSH
00099 
00100     HFONT hFont;                // Lin City font
00101 }
00102 disp;
00103 
00104 // ---------------------------------------------------------------------------
00105 // Globals
00106 // ---------------------------------------------------------------------------
00107 extern HANDLE hAccelTable;
00108 extern disp display;
00109 extern char *bg_color;
00110 extern int verbose;
00111 extern int pix_double;
00112 extern int text_bg;
00113 extern int text_fg;
00114 extern int x_key_value;
00115 extern BOOL x_key_shifted;
00116 extern int borderx, bordery;
00117 extern long unsigned int colour_table[256];
00118 extern int xclip_x1, xclip_y1, xclip_x2, xclip_y2, clipping_flag;
00119 extern unsigned char *open_font;
00120 extern int open_font_height;
00121 extern int suppress_next_expose;
00122 extern int no_init_help;
00123 extern char colour_pal_file[], fontfile[];
00124 extern char windowsfontfile[];
00125 extern int cs_mouse_x, cs_mouse_y;
00126 /* extern int cs_current_mouse_x, cs_current_mouse_y;
00127 extern int cs_current_mouse_button;*/
00128 extern int cs_mouse_button;
00129 extern int cs_mouse_shifted;
00130 extern float gamma_correct_red, gamma_correct_green, gamma_correct_blue;
00131 
00132 #ifdef USE_PIXMAPS
00133 extern HBITMAP icon_pixmap[];
00134 #endif  /* USE_PIXMAPS */
00135 
00136 
00137 // ---------------------------------------------------------------------------
00138 // Function Prototypes
00139 // ---------------------------------------------------------------------------
00140 void ProcessPendingEvents (void);
00141 void ProcessNextEvent (void);
00142 char GetKeystroke (void);
00143 void HandleMouse (void);
00144 void RefreshScreen (void);
00145 void RefreshArea (int, int, int, int);
00146 void SaveUnder (int, int, int, int, void *);
00147 void RestoreSaveUnder (int, int, int, int, void *);
00148 void CopyPixmapToScreen (int t2, int src_x, int src_y, int width, int height, 
00149                          int dst_x, int dst_y);
00150 void AddPaletteEntry (int col, int red, int grn, int blu);
00151 void HandleError (char *, int);
00152 void UpdatePalette (void);
00153 HBRUSH GetPaletteBrush (int col);
00154 
00155 int AdjustX (int x);
00156 int AdjustY (int y);
00157 int UnAdjustX (int x);
00158 int UnAdjustY (int y);
00159 
00160 void my_x_putchar (int, int, unsigned char);
00161 void open_x_putchar (int, int, unsigned char);
00162 void call_event (void);
00163 void do_call_event (int);
00164 void init_windows_font (void);
00165 void init_mouse (void);
00166 void draw_border (void);
00167 
00168 void EnableWindowsMenuItems (void);
00169 void DisableWindowsMenuItems (void);
00170 
00171 #endif  /* __lcwin32_h__ */

Generated on Sun Dec 26 11:23:24 2004 for lincity by  doxygen 1.3.9.1