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

lcwin32.h File Reference

Go to the source code of this file.

Data Structures

struct  _disp

Defines

#define APPNAME   "Lincity"
#define IS_WIN32   FALSE
#define IS_NT   IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
#define IS_WIN32S   IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
#define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
#define WINWIDTH   640
#define WINHEIGHT   480
#define PALETTESIZE   256
#define PALVERSION   0x300
#define IS_WIN30_DIB(lpbi)   ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))
#define RECTWIDTH(lpRect)   ((lpRect)->right - (lpRect)->left)
#define RECTHEIGHT(lpRect)   ((lpRect)->bottom - (lpRect)->top)
#define WIDTHBYTES(bits)   (((bits) + 31) / 32 * 4)

Typedefs

typedef _disp disp

Functions

 DECLARE_HANDLE (HDIB)
void ProcessPendingEvents (void)
void ProcessNextEvent (void)
char GetKeystroke (void)
void HandleMouse (void)
void RefreshScreen (void)
void RefreshArea (int, int, int, int)
void SaveUnder (int, int, int, int, void *)
void RestoreSaveUnder (int, int, int, int, void *)
void CopyPixmapToScreen (int t2, int src_x, int src_y, int width, int height, int dst_x, int dst_y)
void AddPaletteEntry (int col, int red, int grn, int blu)
void HandleError (char *, int)
void UpdatePalette (void)
HBRUSH GetPaletteBrush (int col)
int AdjustX (int x)
int AdjustY (int y)
int UnAdjustX (int x)
int UnAdjustY (int y)
void my_x_putchar (int, int, unsigned char)
void open_x_putchar (int, int, unsigned char)
void call_event (void)
void do_call_event (int)
void init_windows_font (void)
void init_mouse (void)
void draw_border (void)
void EnableWindowsMenuItems (void)
void DisableWindowsMenuItems (void)

Variables

HANDLE hAccelTable
disp display
char * bg_color
int verbose
int pix_double
int text_bg
int text_fg
int x_key_value
BOOL x_key_shifted
int borderx
int bordery
long unsigned int colour_table [256]
int xclip_x1
int xclip_y1
int xclip_x2
int xclip_y2
int clipping_flag
unsigned char * open_font
int open_font_height
int suppress_next_expose
int no_init_help
char colour_pal_file []
char fontfile []
char windowsfontfile []
int cs_mouse_x
int cs_mouse_y
int cs_mouse_button
int cs_mouse_shifted
float gamma_correct_red
float gamma_correct_green
float gamma_correct_blue


Define Documentation

#define APPNAME   "Lincity"
 

Definition at line 16 of file lcwin32.h.

#define IS_NT   IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
 

Definition at line 24 of file lcwin32.h.

#define IS_WIN30_DIB lpbi   )     ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))
 

Definition at line 44 of file lcwin32.h.

#define IS_WIN32   FALSE
 

Definition at line 22 of file lcwin32.h.

#define IS_WIN32S   IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
 

Definition at line 25 of file lcwin32.h.

#define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
 

Definition at line 26 of file lcwin32.h.

#define PALETTESIZE   256
 

Definition at line 32 of file lcwin32.h.

#define PALVERSION   0x300
 

Definition at line 33 of file lcwin32.h.

#define RECTHEIGHT lpRect   )     ((lpRect)->bottom - (lpRect)->top)
 

Definition at line 46 of file lcwin32.h.

#define RECTWIDTH lpRect   )     ((lpRect)->right - (lpRect)->left)
 

Definition at line 45 of file lcwin32.h.

#define WIDTHBYTES bits   )     (((bits) + 31) / 32 * 4)
 

Definition at line 52 of file lcwin32.h.

#define WINHEIGHT   480
 

Definition at line 29 of file lcwin32.h.

#define WINWIDTH   640
 

Definition at line 28 of file lcwin32.h.


Typedef Documentation

typedef struct _disp disp
 


Function Documentation

void AddPaletteEntry int  col,
int  red,
int  grn,
int  blu
 

Definition at line 1338 of file winmain.c.

01339 {
01340   
01341     red = (red * 255) / 62;
01342     if (red > 255)
01343         red = 255;
01344   
01345     grn = (grn * 255) / 62;
01346     if (grn > 255)
01347         grn = 255;
01348   
01349     blu = (blu * 255) / 62;
01350     if (blu > 255)
01351         blu = 255;
01352     
01353     display.colorrefPal[col] = RGB (red, grn, blu);
01354     
01355     if (display.brushPal[col]) {
01356         DeleteObject (display.brushPal[col]);
01357         display.brushPal[col] = 0;
01358     }
01359   
01360     if (display.hasPalette) {
01361         display.pLogPal->palPalEntry[col].peRed = red;
01362         display.pLogPal->palPalEntry[col].peGreen = grn;
01363         display.pLogPal->palPalEntry[col].peBlue = blu;
01364         display.pLogPal->palPalEntry[col].peFlags = PC_NOCOLLAPSE;
01365     }
01366   
01367     if (display.useDIB) {
01368         display.pbminfo->bmiColors[col].rgbRed = red;
01369         display.pbminfo->bmiColors[col].rgbGreen = grn;
01370         display.pbminfo->bmiColors[col].rgbBlue = blu;
01371         display.pbminfo->bmiColors[col].rgbReserved = 0;
01372     }
01373 }

int AdjustX int  x  ) 
 

Definition at line 23 of file lcwin32.c.

00024 {
00025     x <<= pix_double;
00026     x += borderx;
00027     return x;
00028 }

int AdjustY int  y  ) 
 

Definition at line 31 of file lcwin32.c.

00032 {
00033     y <<= pix_double;
00034     y += bordery;
00035     return y;
00036 }

void call_event void   ) 
 

Definition at line 598 of file lcwin32.c.

00599 {
00600     do_call_event (0);
00601 }

void CopyPixmapToScreen int  t2,
int  src_x,
int  src_y,
int  width,
int  height,
int  dst_x,
int  dst_y
 

DECLARE_HANDLE HDIB   ) 
 

void DisableWindowsMenuItems void   ) 
 

Definition at line 472 of file winmain.c.

00473 {
00474 #if defined (USE_WIN32_MENU)
00475     HMENU hMenu = GetMenu (display.hWnd);
00476     EnableMenuItem (hMenu, IDM_OPEN, MF_BYCOMMAND | MF_GRAYED);
00477     EnableMenuItem (hMenu, IDM_SAVE, MF_BYCOMMAND | MF_GRAYED);
00478     EnableMenuItem (hMenu, IDM_HELPCONTENTS, MF_BYCOMMAND | MF_GRAYED);
00479 #endif
00480 }

void do_call_event int   ) 
 

Definition at line 590 of file lcwin32.c.

00591 {
00592     if (wait)
00593         lc_usleep (1000);
00594     HandleMouse ();
00595 }

void draw_border void   ) 
 

Definition at line 661 of file lcwin32.c.

00662 {
00663 }

void EnableWindowsMenuItems void   ) 
 

Definition at line 460 of file winmain.c.

00461 {
00462 #if defined (USE_WIN32_MENU)
00463     HMENU hMenu = GetMenu (display.hWnd);
00464     EnableMenuItem (hMenu, IDM_OPEN, MF_BYCOMMAND | MF_ENABLED);
00465     EnableMenuItem (hMenu, IDM_SAVE, MF_BYCOMMAND | MF_ENABLED);
00466     EnableMenuItem (hMenu, IDM_HELPCONTENTS, MF_BYCOMMAND | MF_ENABLED);
00467 #endif
00468 }

char GetKeystroke void   ) 
 

Definition at line 528 of file winmain.c.

00529 {
00530     char key;
00531     /* GCS 02/02/2003  I found out that sometimes the mouse events were
00532                        getting lost here. */
00533     HandleMouse ();
00534 //    ProcessPendingEvents ();
00535     key = x_key_value;
00536     x_key_value = 0;
00537     return key;
00538 }

HBRUSH GetPaletteBrush int  col  ) 
 

Definition at line 115 of file lcwin32.c.

00116 {
00117     assert (col >= 0 || col <= 255);
00118     if (display.brushPal[col] == 0)
00119         display.brushPal[col] = CreateSolidBrush (GetPaletteColorref (col));
00120     return display.brushPal[col];
00121 }

void HandleError char *  ,
int 
 

Definition at line 240 of file lcsvga.c.

00241 {
00242   fprintf (stderr,
00243            _("An error has occurred.  The description is below...\n"));
00244   fprintf (stderr, "%s\n", description);
00245 
00246   if (degree == FATAL) {
00247       fprintf (stderr, _("Program aborting...\n"));
00248       exit (-1);
00249     }
00250 }

void HandleMouse void   ) 
 

Definition at line 488 of file winmain.c.

00489 {
00490     MSG msg;
00491     /* Process queued events, ignoring mouse moves. */
00492     while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
00493         if (!TranslateAccelerator (msg.hwnd, (HACCEL) display.hAccelTable, 
00494                                    &msg)) {
00495             pending_mouse_x = cs_mouse_x;
00496             pending_mouse_y = cs_mouse_y;
00497             pending_mouse_event = 0;
00498             pending_resize_event = 0;
00499             TranslateMessage (&msg);
00500             DispatchMessage (&msg);
00501             if (pending_mouse_event)
00502                 cs_mouse_handler (pending_mouse_event,
00503                                   pending_mouse_x - cs_mouse_x,
00504                                   pending_mouse_y - cs_mouse_y);
00505             if (pending_resize_event) {
00506                 /* Force resize, because I can't tell difference between
00507                    size change and restoring a minimized window.  Ideally,
00508                    this would simply redraw. */
00509                 display.winW = 0;
00510                 resize_geometry (pending_resize_w, pending_resize_h);
00511             }
00512         }
00513     }
00514   
00515     /* Now move the mouse if necessary. */
00516     if (pending_mouse_x != cs_mouse_x 
00517         || pending_mouse_y != cs_mouse_y)
00518         cs_mouse_handler (0, pending_mouse_x - cs_mouse_x, 
00519                           pending_mouse_y - cs_mouse_y);
00520 }

void init_mouse void   ) 
 

Definition at line 253 of file lcsvga.c.

00254 {
00255     mouse_setup ();
00256 }

void init_windows_font void   ) 
 

Definition at line 148 of file lcwin32.c.

00149 {
00150 #if defined (USE_WINDOWS_FONT)
00151     int rc;
00152     LOGFONT logfont;
00153     int fonts_added = AddFontResource (windowsfontfile);
00154     if (fonts_added != 1) {
00155         HandleError ("Can't open the font file", FATAL);
00156     }
00157     SendMessage (HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
00158     ProcessPendingEvents ();
00159 
00160     // GCS: This typedef is for the typecast...
00161     // typedef int (FAR WINAPI *voidfnptr)(void);
00162     // KSH: Changed the typedef to get around VC 6 strict type enformcement
00163 #if defined (commentout)
00164     typedef int (FAR WINAPI * voidfnptr) (const struct tagLOGFONTA *, const struct tagTEXTMETRICA *, unsigned long, long);
00165     EnumFontFamilies (display.hdcMem, "Lincity", (voidfnptr) EnumFontFamProc, (LPARAM) & logfont);
00166 #endif
00167     // GCS: Hmm.  There must be a way to get this to work on both compilers.  
00168     //            How about this?
00169     //EnumFontFamilies (display.hdcMem, "iso8859-1-16x16", (FONTENUMPROC) EnumFontFamProc, (LPARAM) & logfont);
00170     //rc = EnumFontFamilies (display.hdcMem, "iso8859-1-8x8", (FONTENUMPROC) EnumFontFamProc, (LPARAM) & logfont);
00171     rc = EnumFontFamilies (display.hdcMem, "Lincity", (FONTENUMPROC) EnumFontFamProc, (LPARAM) & logfont);
00172 
00173     display.hFont = CreateFontIndirect (&logfont);
00174     if (!display.hFont) {
00175         HandleError ("Error executing CreateFontIndirect", FATAL);
00176     }
00177     SelectObject (display.hdcMem, display.hFont);
00178 #endif /* defined (USE_WINDOWS_FONT) */
00179 }

void my_x_putchar int  ,
int  ,
unsigned  char
 

Definition at line 429 of file lcwin32.c.

00430 {
00431     int x, y, b;
00432     for (y = 0; y < 8; y++) {
00433         b = main_font[c * 8 + y];
00434         for (x = 0; x < 8; x++) {
00435             if ((b & 0x80) == 0) {
00436 #if defined (USE_WINDOWS_FONT)
00437                 pixmap_setpixel (xx + x, yy + y, text_bg);
00438 #else
00439                 Fgl_setpixel (xx + x, yy + y, text_bg);
00440 #endif
00441             } else {
00442 #if defined (USE_WINDOWS_FONT)
00443                 pixmap_setpixel (xx + x, yy + y, text_fg);
00444 #else
00445                 Fgl_setpixel (xx + x, yy + y, text_fg);
00446 #endif
00447             }
00448             b = b << 1;
00449         }
00450     }
00451 }

void open_x_putchar int  ,
int  ,
unsigned  char
 

Definition at line 455 of file lcwin32.c.

00456 {
00457     int x, y, b;
00458     for (y = 0; y < open_font_height; y++) {
00459         b = open_font[c * open_font_height + y];
00460         for (x = 0; x < 8; x++) {
00461             if ((b & 0x80) == 0)
00462                 Fgl_setpixel (xx + x, yy + y, text_bg);
00463             else
00464                 Fgl_setpixel (xx + x, yy + y, text_fg);
00465             b = b << 1;
00466         }
00467     }
00468 }

void ProcessNextEvent void   ) 
 

Definition at line 419 of file winmain.c.

00420 {
00421   
00422     MSG msg;
00423     if (GetMessage (&msg, NULL, 0, 0)) {
00424         if (!TranslateAccelerator (msg.hwnd, (HACCEL) display.hAccelTable, 
00425                                    &msg)) {
00426             TranslateMessage (&msg);
00427             DispatchMessage (&msg);
00428         }
00429     }
00430     ProcessPendingEvents ();
00431 }

void ProcessPendingEvents void   ) 
 

Definition at line 440 of file winmain.c.

00441 {
00442     MSG msg;
00443     while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
00444         if (!TranslateAccelerator (msg.hwnd, (HACCEL) display.hAccelTable, 
00445                                    &msg)) {
00446             TranslateMessage (&msg);
00447             DispatchMessage (&msg);
00448         }
00449     }
00450 }

void RefreshArea int  ,
int  ,
int  ,
int 
 

Definition at line 557 of file lcwin32.c.

00558 {
00559     RECT rect;
00560     rect.left = AdjustX (x1);
00561     rect.top = AdjustY (y1);
00562     rect.right = AdjustX (x2);
00563     rect.bottom = AdjustY (y2);
00564     InvalidateRect (display.hWnd, &rect, FALSE);
00565     UpdateWindow (display.hWnd);
00566 }

void RefreshScreen void   ) 
 

Definition at line 550 of file lcwin32.c.

00551 {
00552     InvalidateRect (display.hWnd, NULL, FALSE);
00553     ProcessNextEvent ();
00554 }

void RestoreSaveUnder int  ,
int  ,
int  ,
int  ,
void * 
 

void SaveUnder int  ,
int  ,
int  ,
int  ,
void * 
 

int UnAdjustX int  x  ) 
 

Definition at line 39 of file lcwin32.c.

00040 {
00041     x -= borderx;
00042     x >>= pix_double;
00043     return x;
00044 }

int UnAdjustY int  y  ) 
 

Definition at line 47 of file lcwin32.c.

00048 {
00049     y -= bordery;
00050     y >>= pix_double;
00051     return y;
00052 }

void UpdatePalette void   ) 
 

Definition at line 1380 of file winmain.c.

01381 {
01382     if (display.hasPalette) {
01383         // Make a new HPALETTE and select to hdcGlobal and hdcMem
01384         HPALETTE hPalNew;
01385         hPalNew = CreatePalette ((LPLOGPALETTE) display.pLogPal);
01386         SelectPalette (display.hdcMem, hPalNew, FALSE);
01387         RealizePalette (display.hdcMem);
01388         DeleteObject (display.hPal);
01389         display.hPal = hPalNew;
01390     }
01391 }


Variable Documentation

char* bg_color
 

int borderx
 

Definition at line 123 of file cliglobs.c.

int bordery
 

Definition at line 123 of file cliglobs.c.

int clipping_flag
 

char colour_pal_file[]
 

Definition at line 109 of file fileutil.c.

long unsigned int colour_table[256]
 

int cs_mouse_button
 

Definition at line 36 of file cliglobs.c.

int cs_mouse_shifted
 

Definition at line 37 of file cliglobs.c.

int cs_mouse_x
 

Definition at line 36 of file cliglobs.c.

int cs_mouse_y
 

Definition at line 36 of file cliglobs.c.

disp display
 

Definition at line 122 of file cliglobs.c.

char fontfile[]
 

Definition at line 112 of file fileutil.c.

float gamma_correct_blue
 

float gamma_correct_green
 

float gamma_correct_red
 

Definition at line 33 of file cliglobs.c.

HANDLE hAccelTable
 

int no_init_help
 

Definition at line 21 of file cliglobs.c.

unsigned char* open_font
 

int open_font_height
 

int pix_double
 

Definition at line 19 of file shrglobs.c.

int suppress_next_expose
 

int text_bg
 

int text_fg
 

int verbose
 

char windowsfontfile[]
 

BOOL x_key_shifted
 

int x_key_value
 

int xclip_x1
 

int xclip_x2
 

int xclip_y1
 

int xclip_y2
 


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