File: bbgfxtarget.h

package info (click to toggle)
battleball 2.0-8
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,012 kB
  • ctags: 3,097
  • sloc: cpp: 15,307; makefile: 47; csh: 34
file content (67 lines) | stat: -rw-r--r-- 2,011 bytes parent folder | download | duplicates (5)
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
// Copyright (c) 1997 Philip A. Hardin (pahardin@cs.utexas.edu)
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License v2 or later.


#ifndef BBGFXTARGET_h
#define BBGFXTARGET_h


#include "general.h"
#include "pt2d.h"
#include "bbcolor.h"
#include "gfxtarget.h"

#define MINWINWIDTH 400
#define MINWINHEIGHT (200+6*14+2)


/*======================================================================*/
/* Graphics Target class.
   The "graphics target" is all the OS-specific data needed to draw to the
   game window.  Encapsulating it here makes BattleBall easier to port to
   other OS's.

   The text-printing stuff here is ugly.  It could have a MUCH cleaner, nicer
   interface...
*/
struct bbGfxTarget : gfxTarget {
  pt2d		gfxSize;	// width, height of 3d gfx area in pixels
  pt2d		fontSize;	// font width, height+1 in pixels
  pt2d		textSize;	// width, height of text area, including
                                // borders, in pixels
  pt2d		cursorOrg;	// position of text cursor's (0,0) origin,
                                // in pixels
  pt2d		cursor;		// text cursor position (text coords)
  int		rightmost;	// rightmost text position printed to (text
                                // coords)
  XFontStruct   *font;

 private:
  ulong		colors[totalColors];  // X color lookup table
  Drawable	savedWin;             // X window; used for double-buffering
  GC		savedGc;              // X GC;     used for double-buffering


 public:
  bbGfxTarget();
  ulong	*Colors() {return colors;};
  void	LoadFont(const char*);
  void	GetGC();
  void	CreateWindow(int,char*[]);
  void	AllocColors(char**,int);
  void	HandleResize(XEvent *event,bool refit);
  pt2d	PixelPos(const pt2d& pt);
  void	DoubleBufferBegin();
  void	DoubleBufferEnd();

  bbGfxTarget& operator<<(char*);
  bbGfxTarget& Box(int,int,int=1,int=1,bool hl=false);
  bbGfxTarget& Tab(int blanks=1,int newy=0);

 private:
  void	GetColor(char*,ulong&);
};


#endif