All Classes Functions
MyDC.h
1 #ifndef MYDC_H
2 #define MYDC_H
3 
4 #include <string>
5 #include <orbitersdk.h>
6 
7 #ifdef ORB2006
8  typedef HDC MyDC;
9  typedef HPEN MyPEN;
10 #else
11  #ifdef ORB2009
12  typedef oapi::Sketchpad * MyDC;
13  typedef oapi::Pen * MyPEN;
14  #endif
15 #endif
16 
17 
18 #define GREEN RGB(0x00, 0xFF, 0x00)
19 #define YELLOW RGB(0xDF, 0xDF, 0x00)
20 #define WHITE RGB(0xFF, 0xFF, 0xFF)
21 #define RED RGB(0xFF, 0x00, 0x00)
22 #define GREY RGB(0xE0, 0xE0, 0xE0)
23 #define LIGHT_BLUE RGB(0x22, 0xDD, 0xFF)
24 
25 // Macro for doing a more maneagable TextOut.
26 // Use as TextOut, except specifying the colour as you would with SetTextColour. If Colour is 0, it will use the old colour
27 // The ... (__VA_ARGS__) can be used as the extra formatting parameters as you would use for sprintf.
28 // No need to specify text length - it will get it from strlen.
29 // eg.: MFDTextOut(hDC, 30, 20, GREEN, "Pi is equal to %lf", M_PI);
30 #ifdef ORB2006
31 #define MFDTextOut(hDC, x, y, colour, text, ...) {char buf[1024]; sprintf_s(buf, 1024, text, __VA_ARGS__); \
32  if(colour != 0)\
33  SetTextColor(hDC, colour);\
34  TextOut(hDC, x, y, buf, (int)strlen(buf));\
35  }
36 #else
37 #define MFDTextOut(skp, x, y, colour, text, ...) {char buf[1024]; sprintf_s(buf, 1024, text, __VA_ARGS__); \
38  if(colour != 0)\
39  skp->SetTextColor(colour);\
40  skp->Text(x, y, buf, (int)strlen(buf));\
41  }
42 #endif
43 
44 
45 #ifdef ORB2006
46 #define MFDLine(hDC, x0, y0, x1, y1) { MoveToEx(hDC, (int)(x0), (int)(y0), NULL);\
47  LineTo(hDC, (int)(x1), (int)(y1) );\
48  }
49 #else
50 #define MFDLine(skp, x0, y0, x1, y1) { skp->Line(x0, y0, x1, y1);\
51  }
52 
53 #endif
54 #ifdef ORB2006
55 #define MFDPoint(hDC, x, y) { MoveToEx(hDC, (int)(x), (int)(y), NULL);\
56  LineTo(hDC, (int)(x+1), (int)(y) );\
57  }
58 #else
59 #define MFDPoint(skp, x, y) { skp->Line(x, y, x+1, y);\
60  }
61 #endif
62 
63 #ifdef ORB2006
64  #define MFDSetPen(hDC, p) { SelectObject(hDC, p); }
65 #else
66  #define MFDSetPen(skp, p) { skp->SetPen(p); }
67 #endif
68 
69 #ifdef ORB2006
70  #define MFDTextAlignCenter(hDC) { SetTextAlign(hDC, TA_CENTER); }
71 #else
72  #define MFDTextAlignCenter(skp) { skp->SetTextAlign( oapi::Sketchpad::CENTER, oapi::Sketchpad::BASELINE ); }
73 #endif
74 
75 
76 #endif // MYDC_H