| 1 |
/** |
|---|
| 2 |
XXX |
|---|
| 3 |
|
|---|
| 4 |
Authors: Daniel Keep |
|---|
| 5 |
Copyright: 2006, Daniel Keep |
|---|
| 6 |
License: BSD v2 (http://opensource.org/licenses/bsd-license.php). |
|---|
| 7 |
**/ |
|---|
| 8 |
/** |
|---|
| 9 |
Copyright © 2006 Daniel Keep |
|---|
| 10 |
All rights reserved. |
|---|
| 11 |
|
|---|
| 12 |
Redistribution and use in source and binary forms, with or without |
|---|
| 13 |
modification, are permitted provided that the following conditions are |
|---|
| 14 |
met: |
|---|
| 15 |
|
|---|
| 16 |
* Redistributions of source code must retain the above copyright |
|---|
| 17 |
notice, this list of conditions and the following disclaimer. |
|---|
| 18 |
|
|---|
| 19 |
* Redistributions in binary form must reproduce the above copyright |
|---|
| 20 |
notice, this list of conditions and the following disclaimer in the |
|---|
| 21 |
documentation and/or other materials provided with the distribution. |
|---|
| 22 |
|
|---|
| 23 |
* Neither the name of this software, nor the names of its contributors |
|---|
| 24 |
may be used to endorse or promote products derived from this software |
|---|
| 25 |
without specific prior written permission. |
|---|
| 26 |
|
|---|
| 27 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|---|
| 28 |
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|---|
| 29 |
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|---|
| 30 |
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|---|
| 31 |
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|---|
| 32 |
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|---|
| 33 |
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|---|
| 34 |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|---|
| 35 |
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|---|
| 36 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|---|
| 37 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 38 |
**/ |
|---|
| 39 |
module cairooo.fontoptions; |
|---|
| 40 |
|
|---|
| 41 |
private |
|---|
| 42 |
{ |
|---|
| 43 |
import cairo.cairo; |
|---|
| 44 |
import cairooo.enums; |
|---|
| 45 |
import cairooo.exceptions; |
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
class FontOptions |
|---|
| 49 |
{ |
|---|
| 50 |
private: |
|---|
| 51 |
cairo_font_options_t* _handle; |
|---|
| 52 |
|
|---|
| 53 |
public: |
|---|
| 54 |
this() |
|---|
| 55 |
{ |
|---|
| 56 |
scope(success) checkStatus(); |
|---|
| 57 |
this._handle = cairo_font_options_create(); |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
this(cairo_font_options_t* handle, bool takeref) |
|---|
| 61 |
{ |
|---|
| 62 |
checkStatus(handle); |
|---|
| 63 |
if( takeref ) |
|---|
| 64 |
{ |
|---|
| 65 |
handle = cairo_font_options_copy(handle); |
|---|
| 66 |
checkStatus(handle); |
|---|
| 67 |
} |
|---|
| 68 |
this._handle = handle; |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
this(FontOptions fontOptions) |
|---|
| 72 |
{ |
|---|
| 73 |
scope(success) checkStatus(); |
|---|
| 74 |
this(fontOptions.handle, true); |
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
~this() |
|---|
| 78 |
{ |
|---|
| 79 |
cairo_font_options_destroy(this.handle); |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
// |
|---|
| 83 |
// cairo api members |
|---|
| 84 |
// |
|---|
| 85 |
|
|---|
| 86 |
FontOptions |
|---|
| 87 |
copy() |
|---|
| 88 |
{ |
|---|
| 89 |
return new FontOptions(this); |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
void |
|---|
| 93 |
merge(FontOptions other) |
|---|
| 94 |
{ |
|---|
| 95 |
scope(success) checkStatus(); |
|---|
| 96 |
cairo_font_options_merge(this.handle, other.handle); |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
bool |
|---|
| 100 |
equal(FontOptions other) |
|---|
| 101 |
{ |
|---|
| 102 |
scope(success) checkStatus(); |
|---|
| 103 |
return cast(bool) cairo_font_options_equal(this.handle, other.handle); |
|---|
| 104 |
} |
|---|
| 105 |
|
|---|
| 106 |
Antialias |
|---|
| 107 |
antialias() |
|---|
| 108 |
{ |
|---|
| 109 |
scope(success) checkStatus(); |
|---|
| 110 |
return cast(Antialias) cairo_font_options_get_antialias(this.handle); |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
Antialias |
|---|
| 114 |
antialias(Antialias value) |
|---|
| 115 |
{ |
|---|
| 116 |
scope(success) checkStatus(); |
|---|
| 117 |
cairo_font_options_set_antialias(this.handle, |
|---|
| 118 |
cast(cairo_antialias_t) value); |
|---|
| 119 |
return value; |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
SubpixelOrder |
|---|
| 123 |
subpixelOrder() |
|---|
| 124 |
{ |
|---|
| 125 |
scope(success) checkStatus(); |
|---|
| 126 |
return cast(SubpixelOrder) |
|---|
| 127 |
cairo_font_options_get_subpixel_order(this.handle); |
|---|
| 128 |
} |
|---|
| 129 |
|
|---|
| 130 |
SubpixelOrder |
|---|
| 131 |
subpixelOrder(SubpixelOrder value) |
|---|
| 132 |
{ |
|---|
| 133 |
scope(success) checkStatus(); |
|---|
| 134 |
cairo_font_options_set_subpixel_order(this.handle, |
|---|
| 135 |
cast(cairo_subpixel_order_t) value); |
|---|
| 136 |
return value; |
|---|
| 137 |
} |
|---|
| 138 |
|
|---|
| 139 |
HintStyle |
|---|
| 140 |
hintStyle() |
|---|
| 141 |
{ |
|---|
| 142 |
scope(success) checkStatus(); |
|---|
| 143 |
return cast(HintStyle) |
|---|
| 144 |
cairo_font_options_get_hint_style(this.handle); |
|---|
| 145 |
} |
|---|
| 146 |
|
|---|
| 147 |
HintStyle |
|---|
| 148 |
hintStyle(HintStyle value) |
|---|
| 149 |
{ |
|---|
| 150 |
scope(success) checkStatus(); |
|---|
| 151 |
cairo_font_options_set_hint_style(this.handle, |
|---|
| 152 |
cast(cairo_hint_style_t) value); |
|---|
| 153 |
return value; |
|---|
| 154 |
} |
|---|
| 155 |
|
|---|
| 156 |
HintMetrics |
|---|
| 157 |
hintMetrics() |
|---|
| 158 |
{ |
|---|
| 159 |
scope(success) checkStatus(); |
|---|
| 160 |
return cast(HintMetrics) |
|---|
| 161 |
cairo_font_options_get_hint_metrics(this.handle); |
|---|
| 162 |
} |
|---|
| 163 |
|
|---|
| 164 |
HintMetrics |
|---|
| 165 |
hintMetrics(HintMetrics value) |
|---|
| 166 |
{ |
|---|
| 167 |
scope(success) checkStatus(); |
|---|
| 168 |
cairo_font_options_set_hint_metrics(this.handle, |
|---|
| 169 |
cast(cairo_hint_metrics_t) value); |
|---|
| 170 |
return value; |
|---|
| 171 |
} |
|---|
| 172 |
|
|---|
| 173 |
// |
|---|
| 174 |
// miscellaneous members |
|---|
| 175 |
// |
|---|
| 176 |
|
|---|
| 177 |
FontOptions |
|---|
| 178 |
dup() |
|---|
| 179 |
{ |
|---|
| 180 |
return this.copy(); |
|---|
| 181 |
} |
|---|
| 182 |
|
|---|
| 183 |
cairo_font_options_t* |
|---|
| 184 |
handle() |
|---|
| 185 |
{ |
|---|
| 186 |
return this._handle; |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
int |
|---|
| 190 |
opEquals(FontOptions other) |
|---|
| 191 |
{ |
|---|
| 192 |
return cast(int) equal(other); |
|---|
| 193 |
} |
|---|
| 194 |
|
|---|
| 195 |
// |
|---|
| 196 |
// internal stuff |
|---|
| 197 |
// |
|---|
| 198 |
protected: |
|---|
| 199 |
void |
|---|
| 200 |
checkStatus() |
|---|
| 201 |
{ |
|---|
| 202 |
.checkStatus(cairo_font_options_status(this._handle)); |
|---|
| 203 |
} |
|---|
| 204 |
|
|---|
| 205 |
void |
|---|
| 206 |
checkStatus(cairo_font_options_t* handle) |
|---|
| 207 |
{ |
|---|
| 208 |
.checkStatus(cairo_font_options_status(handle)); |
|---|
| 209 |
} |
|---|
| 210 |
} |
|---|