]>
Commit | Line | Data |
---|---|---|
1fc25a89 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: misc.h | |
3 | // Purpose: Miscellaneous utilities for OGL | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 12/07/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
2ba06d5a | 9 | // Licence: wxWindows licence |
1fc25a89 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _OGL_MISC_H_ | |
13 | #define _OGL_MISC_H_ | |
14 | ||
5f331691 | 15 | |
1fc25a89 JS |
16 | // List to use when copying objects; may need to associate elements of new objects |
17 | // with elements of old objects, e.g. when copying constraint.s | |
18 | extern wxList oglObjectCopyMapping; | |
19 | ||
20 | /* | |
21 | * TEXT FORMATTING FUNCTIONS | |
22 | * | |
23 | */ | |
24 | ||
25 | // Centres the given list of wxShapeTextLine strings in the given box | |
26 | // (changing the positions in situ). Doesn't actually draw into the DC. | |
5f331691 | 27 | WXDLLIMPEXP_OGL void oglCentreText(wxDC& dc, wxList *text, double m_xpos, double m_ypos, |
1fc25a89 JS |
28 | double width, double height, |
29 | int formatMode = FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT); | |
30 | ||
31 | // Given a string, returns a list of strings that fit within the given | |
32 | // width of box. Height is ignored. | |
5f331691 | 33 | WXDLLIMPEXP_OGL wxStringList* oglFormatText(wxDC& dc, const wxString& text, double width, double height, int formatMode = 0); |
1fc25a89 JS |
34 | |
35 | // Centres the list of wxShapeTextLine strings, doesn't clip. | |
36 | // Doesn't actually draw into the DC. | |
5f331691 | 37 | WXDLLIMPEXP_OGL void oglCentreTextNoClipping(wxDC& dc, wxList *text_list, |
1fc25a89 JS |
38 | double m_xpos, double m_ypos, double width, double height); |
39 | ||
40 | // Gets the maximum width and height of the given list of wxShapeTextLines. | |
5f331691 | 41 | WXDLLIMPEXP_OGL void oglGetCentredTextExtent(wxDC& dc, wxList *text_list, |
1fc25a89 JS |
42 | double m_xpos, double m_ypos, double width, double height, |
43 | double *actual_width, double *actual_height); | |
44 | ||
45 | // Actually draw the preformatted list of wxShapeTextLines. | |
5f331691 | 46 | WXDLLIMPEXP_OGL void oglDrawFormattedText(wxDC& context, wxList *text_list, |
1fc25a89 JS |
47 | double m_xpos, double m_ypos, double width, double height, |
48 | int formatMode = FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT); | |
49 | ||
50 | // Give it a list of points, finds the centre. | |
5f331691 | 51 | WXDLLIMPEXP_OGL void oglFindPolylineCentroid(wxList *points, double *x, double *y); |
1fc25a89 | 52 | |
5f331691 | 53 | WXDLLIMPEXP_OGL void oglCheckLineIntersection(double x1, double y1, double x2, double y2, |
1fc25a89 JS |
54 | double x3, double y3, double x4, double y4, |
55 | double *ratio1, double *ratio2); | |
56 | ||
5f331691 | 57 | WXDLLIMPEXP_OGL void oglFindEndForPolyline(double n, double xvec[], double yvec[], |
1fc25a89 JS |
58 | double x1, double y1, double x2, double y2, double *x3, double *y3); |
59 | ||
60 | ||
5f331691 | 61 | WXDLLIMPEXP_OGL void oglFindEndForBox(double width, double height, |
1fc25a89 JS |
62 | double x1, double y1, // Centre of box (possibly) |
63 | double x2, double y2, // other end of line | |
64 | double *x3, double *y3); // End on box edge | |
65 | ||
5f331691 | 66 | WXDLLIMPEXP_OGL void oglFindEndForCircle(double radius, |
1fc25a89 JS |
67 | double x1, double y1, // Centre of circle |
68 | double x2, double y2, // Other end of line | |
69 | double *x3, double *y3); | |
70 | ||
5f331691 | 71 | WXDLLIMPEXP_OGL void oglGetArrowPoints(double x1, double y1, double x2, double y2, |
1fc25a89 JS |
72 | double length, double width, |
73 | double *tip_x, double *tip_y, | |
74 | double *side1_x, double *side1_y, | |
75 | double *side2_x, double *side2_y); | |
76 | ||
77 | /* | |
78 | * Given an ellipse and endpoints of a line, returns the point at which | |
79 | * the line touches the ellipse in values x4, y4. | |
80 | * This function assumes that the centre of the ellipse is at x1, y1, and the | |
81 | * ellipse has a width of a1 and a height of b1. It also assumes you are | |
82 | * wanting to draw an arc FROM point x2, y2 TOWARDS point x3, y3. | |
67d54b58 | 83 | * This function calculates the x,y coordinates of the intersection point of |
1fc25a89 JS |
84 | * the arc with the ellipse. |
85 | * Author: Ian Harrison | |
86 | */ | |
87 | ||
5f331691 | 88 | WXDLLIMPEXP_OGL void oglDrawArcToEllipse(double x1, double y1, double a1, double b1, double x2, double y2, double x3, double y3, |
1fc25a89 JS |
89 | double *x4, double *y4); |
90 | ||
5f331691 | 91 | WXDLLIMPEXP_OGL bool oglRoughlyEqual(double val1, double val2, double tol = 0.00001); |
1fc25a89 JS |
92 | |
93 | extern wxFont* g_oglNormalFont; | |
94 | extern wxPen* g_oglBlackPen; | |
95 | extern wxPen* g_oglWhiteBackgroundPen; | |
96 | extern wxPen* g_oglTransparentPen; | |
97 | extern wxBrush* g_oglWhiteBackgroundBrush; | |
98 | extern wxPen* g_oglBlackForegroundPen; | |
1fc25a89 | 99 | |
5f7ea955 | 100 | WXDLLIMPEXP_OGL wxFont* oglMatchFont(int point_size); |
1fc25a89 | 101 | |
5f7ea955 JS |
102 | WXDLLIMPEXP_OGL wxString oglColourToHex(const wxColour& colour); |
103 | WXDLLIMPEXP_OGL wxColour oglHexToColour(const wxString& hex); | |
104 | WXDLLIMPEXP_OGL void oglDecToHex(unsigned int dec, char *buf); | |
105 | WXDLLIMPEXP_OGL unsigned int oglHexToDec(char* buf); | |
1fc25a89 JS |
106 | |
107 | ||
108 | #endif | |
109 | // _OGL_MISC_H_ |