Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Window.h
Go to the documentation of this file.
1 /* Project nGenEx
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: nGenEx.lib
6  FILE: Window.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Window class (a region of a screen or buffer)
13 */
14 
15 #ifndef Window_h
16 #define Window_h
17 
18 #include "Types.h"
19 #include "Geometry.h"
20 #include "List.h"
21 
22 // +--------------------------------------------------------------------+
23 
24 class Color;
25 class Bitmap;
26 class Font;
27 class Screen;
28 class View;
29 
30 // +--------------------------------------------------------------------+
31 
32 class Window
33 {
34  friend class Screen;
35 
36 public:
37  static const char* TYPENAME() { return "Window"; }
38 
39  Window(Screen* s, int ax, int ay, int aw, int ah);
40  virtual ~Window();
41 
42  int operator == (const Window& that) const { return this == &that; }
43 
44  // Screen dimensions:
45  Screen* GetScreen() const { return screen; }
46  const Rect& GetRect() const { return rect; }
47  int X() const { return rect.x; }
48  int Y() const { return rect.y; }
49  int Width() const { return rect.w; }
50  int Height() const { return rect.h; }
51 
52  // Operations:
53  virtual void Paint();
54  virtual void Show() { shown = true; }
55  virtual void Hide() { shown = false; }
56  virtual bool IsShown() const { return shown; }
57 
58  virtual void MoveTo(const Rect& r);
59 
60  virtual bool AddView(View* v);
61  virtual bool DelView(View* v);
62 
63  Rect ClipRect(const Rect& r);
64  bool ClipLine(int& x1, int& y1, int& x2, int& y2);
65  bool ClipLine(double& x1, double& y1, double& x2, double& y2);
66 
67  void DrawLine(int x1, int y1, int x2, int y2, Color color, int blend=0);
68  void DrawRect(int x1, int y1, int x2, int y2, Color color, int blend=0);
69  void DrawRect(const Rect& r, Color color, int blend=0);
70  void FillRect(int x1, int y1, int x2, int y2, Color color, int blend=0);
71  void FillRect(const Rect& r, Color color, int alpha=0);
72  void DrawBitmap(int x1, int y1, int x2, int y2, Bitmap* img, int blend=0);
73  void FadeBitmap(int x1, int y1, int x2, int y2, Bitmap* img, Color c, int blend);
74  void ClipBitmap(int x1, int y1, int x2, int y2, Bitmap* img, Color c, int blend, const Rect& clip);
75  void TileBitmap(int x1, int y1, int x2, int y2, Bitmap* img, int blend=0);
76  void DrawLines(int nPts, POINT* pts, Color color, int blend=0);
77  void DrawPoly(int nPts, POINT* pts, Color color, int blend=0);
78  void FillPoly(int nPts, POINT* pts, Color color, int blend=0);
79 
80  void DrawEllipse(int x1, int y1, int x2, int y2, Color color, int blend=0);
81  void FillEllipse(int x1, int y1, int x2, int y2, Color color, int blend=0);
82 
83  // text methods:
84  void SetFont(Font* f) { font = f; }
85  Font* GetFont() const { return font; }
86 
87  void Print(int x1, int y1, const char* fmt, ...);
88  void DrawText(const char* txt, int count, Rect& txt_rect, DWORD flags);
89 
90 protected:
91  // translate screen coords into window relative coords
92  virtual void ScreenToWindow(int& x, int& y) { }
93  virtual void ScreenToWindow(Rect& r) { }
94 
97  bool shown;
99 
101 };
102 
103 #endif Window_h
104