Initial commit - from Precise source
[freerdp-ubuntu-pcb-backport.git] / libfreerdp-gdi / drawing.c
1 /**
2  * FreeRDP: A Remote Desktop Protocol Client
3  * GDI Drawing Functions
4  *
5  * Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 /* GDI Drawing Functions: http://msdn.microsoft.com/en-us/library/dd162760/ */
21
22 #include <stdio.h>
23 #include <string.h>
24 #include <stdlib.h>
25
26 #include <freerdp/freerdp.h>
27 #include <freerdp/gdi/gdi.h>
28
29 #include <freerdp/gdi/dc.h>
30
31 /**
32  * Set current foreground draw mode.\n
33  * @msdn{dd144922}
34  * @param hdc device context
35  * @return draw mode
36  */
37
38 int gdi_GetROP2(HGDI_DC hdc)
39 {
40         return hdc->drawMode;
41 }
42
43 /**
44  * Set current foreground draw mode.\n
45  * @msdn{dd145088}
46  * @param hdc device context
47  * @param fnDrawMode draw mode
48  * @return previous draw mode
49  */
50
51 int gdi_SetROP2(HGDI_DC hdc, int fnDrawMode)
52 {
53         int prevDrawMode = hdc->drawMode;
54
55         if (fnDrawMode > 0 && fnDrawMode <= 16)
56                 hdc->drawMode = fnDrawMode;
57
58         return prevDrawMode;
59 }
60
61 /**
62  * Get the current background color.\n
63  * @msdn{dd144852}
64  * @param hdc device context
65  * @return background color
66  */
67
68 GDI_COLOR gdi_GetBkColor(HGDI_DC hdc)
69 {
70         return hdc->bkColor;
71 }
72
73 /**
74  * Set the current background color.\n
75  * @msdn{dd162964}
76  * @param hdc device color
77  * @param crColor new background color
78  * @return previous background color
79  */
80
81 GDI_COLOR gdi_SetBkColor(HGDI_DC hdc, GDI_COLOR crColor)
82 {
83         GDI_COLOR previousBkColor = hdc->bkColor;
84         hdc->bkColor = crColor;
85         return previousBkColor;
86 }
87
88 /**
89  * Get the current background mode.\n
90  * @msdn{dd144853}
91  * @param hdc device context
92  * @return background mode
93  */
94
95 int gdi_GetBkMode(HGDI_DC hdc)
96 {
97         return hdc->bkMode;
98 }
99
100 /**
101  * Set the current background mode.\n
102  * @msdn{dd162965}
103  * @param hdc device context
104  * @param iBkMode background mode
105  * @return
106  */
107
108 int gdi_SetBkMode(HGDI_DC hdc, int iBkMode)
109 {
110         if (iBkMode == GDI_OPAQUE || iBkMode == GDI_TRANSPARENT)
111                 hdc->bkMode = iBkMode;
112         else
113                 hdc->bkMode = GDI_OPAQUE;
114
115         return 0;
116 }
117
118 /**
119  * Set the current text color.\n
120  * @msdn{dd145093}
121  * @param hdc device context
122  * @param crColor new text color
123  * @return previous text color
124  */
125
126 GDI_COLOR gdi_SetTextColor(HGDI_DC hdc, GDI_COLOR crColor)
127 {
128         GDI_COLOR previousTextColor = hdc->textColor;
129         hdc->textColor = crColor;
130         return previousTextColor;
131 }