1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
// This file is auto-generated by rute_gen. DO NOT EDIT.
use std::cell::Cell;
use std::rc::Rc;
#[allow(unused_imports)]
use std::marker::PhantomData;
#[allow(unused_imports)]
use std::os::raw::c_void;
#[allow(unused_imports)]
use std::mem::transmute;
#[allow(unused_imports)]
use std::ffi::{CStr, CString};
use rute_ffi_base::*;
#[allow(unused_imports)]
use auto::*;
/// **Notice these docs are heavy WIP and not very relevent yet**
///
/// QPaintEngineState records which properties that have changed since
/// the last time the paint engine was updated, as well as their
/// current value.
///
/// Which properties that have changed can at any time be retrieved
/// using the state() function. This function returns an instance of
/// the QPaintEngine::DirtyFlags type which stores an OR combination
/// of QPaintEngine::DirtyFlag values. The QPaintEngine::DirtyFlag
/// enum defines whether a property has changed since the last update
/// or not.
///
/// If a property is marked with a dirty flag, its current value can
/// be retrieved using the corresponding get function:
///
/// * Property Flag
/// * Current Property Value
/// * QPaintEngine::DirtyBackground
/// * backgroundBrush()
/// * QPaintEngine::DirtyBackgroundMode
/// * backgroundMode()
/// * QPaintEngine::DirtyBrush
/// * brush()
/// * QPaintEngine::DirtyBrushOrigin
/// * brushOrigin()
/// * QPaintEngine::DirtyClipRegion *or* QPaintEngine::DirtyClipPath
/// * clipOperation()
/// * QPaintEngine::DirtyClipPath
/// * clipPath()
/// * QPaintEngine::DirtyClipRegion
/// * clipRegion()
/// * QPaintEngine::DirtyCompositionMode
/// * compositionMode()
/// * QPaintEngine::DirtyFont
/// * font()
/// * QPaintEngine::DirtyTransform
/// * transform()
/// * QPaintEngine::DirtyClipEnabled
/// * isClipEnabled()
/// * QPaintEngine::DirtyPen
/// * pen()
/// * QPaintEngine::DirtyHints
/// * renderHints()
///
/// The QPaintEngineState class also provide the painter() function
/// which returns a pointer to the painter that is currently updating
/// the paint engine.
///
/// An instance of this class, representing the current state of the
/// active paint engine, is passed as argument to the
/// QPaintEngine::updateState() function. The only situation in which
/// you will have to use this class directly is when implementing your
/// own paint engine.
///
/// **See also:** QPaintEngine
/// # Licence
///
/// The documentation is an adoption of the original [Qt Documentation](http://doc.qt.io/) and provided herein is licensed under the terms of the [GNU Free Documentation License version 1.3](http://www.gnu.org/licenses/fdl.html) as published by the Free Software Foundation.
#[derive(Clone)]
pub struct PaintEngineState<'a> {
#[doc(hidden)]
pub data: Rc<Cell<Option<*const RUBase>>>,
#[doc(hidden)]
pub all_funcs: *const RUPaintEngineStateAllFuncs,
#[doc(hidden)]
pub owned: bool,
#[doc(hidden)]
pub _marker: PhantomData<::std::cell::Cell<&'a ()>>,
}
impl<'a> PaintEngineState<'a> {
pub fn new() -> PaintEngineState<'a> {
let data = Rc::new(Cell::new(None));
let ffi_data = unsafe {
((*rute_ffi_get()).create_paint_engine_state)(
::std::ptr::null(),
transmute(rute_object_delete_callback as usize),
Rc::into_raw(data.clone()) as *const c_void,
)
};
data.set(Some(ffi_data.qt_data));
PaintEngineState {
data,
all_funcs: ffi_data.all_funcs,
owned: true,
_marker: PhantomData,
}
}
#[allow(dead_code)]
pub(crate) fn new_from_rc(ffi_data: RUPaintEngineState) -> PaintEngineState<'a> {
PaintEngineState {
data: unsafe { Rc::from_raw(ffi_data.host_data as *const Cell<Option<*const RUBase>>) },
all_funcs: ffi_data.all_funcs,
owned: false,
_marker: PhantomData,
}
}
#[allow(dead_code)]
pub(crate) fn new_from_owned(ffi_data: RUPaintEngineState) -> PaintEngineState<'a> {
PaintEngineState {
data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
all_funcs: ffi_data.all_funcs,
owned: true,
_marker: PhantomData,
}
}
#[allow(dead_code)]
pub(crate) fn new_from_temporary(ffi_data: RUPaintEngineState) -> PaintEngineState<'a> {
PaintEngineState {
data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
all_funcs: ffi_data.all_funcs,
owned: false,
_marker: PhantomData,
}
}
///
/// Returns a combination of flags identifying the set of properties
/// that need to be updated when updating the paint engine's state
/// (i.e. during a call to the QPaintEngine::updateState() function).
///
/// **See also:** QPaintEngine::updateState()
pub fn state(&self) -> DirtyFlags {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).state)(obj_data);
let ret_val = { transmute::<i32, DirtyFlags>(ret_val) };
ret_val
}
}
///
/// Returns the pen in the current paint engine state.
///
/// This variable should only be used when the state() returns a
/// combination which includes the QPaintEngine::DirtyPen flag.
///
/// **See also:** state()
/// QPaintEngine::updateState()
///
/// Returns whether the coordinate of the stroke have been specified
/// as bounded by the current rendering operation and have to be
/// resolved (about the currently rendered primitive).
pub fn pen(&self) -> Pen {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).pen)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Pen::new_from_rc(t);
} else {
ret_val = Pen::new_from_owned(t);
}
ret_val
}
}
///
/// Returns the brush in the current paint engine state.
///
/// This variable should only be used when the state() returns a
/// combination which includes the QPaintEngine::DirtyBrush flag.
///
/// **See also:** state()
/// QPaintEngine::updateState()
///
/// Returns the brush origin in the current paint engine state.
///
/// This variable should only be used when the state() returns a
/// combination which includes the QPaintEngine::DirtyBrushOrigin flag.
///
/// **See also:** state()
/// QPaintEngine::updateState()
///
/// Returns whether the coordinate of the fill have been specified
/// as bounded by the current rendering operation and have to be
/// resolved (about the currently rendered primitive).
pub fn brush(&self) -> Brush {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).brush)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Brush::new_from_rc(t);
} else {
ret_val = Brush::new_from_owned(t);
}
ret_val
}
}
///
/// Returns the brush origin in the current paint engine state.
///
/// This variable should only be used when the state() returns a
/// combination which includes the QPaintEngine::DirtyBrushOrigin flag.
///
/// **See also:** state()
/// QPaintEngine::updateState()
pub fn brush_origin(&self) -> PointF {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).brush_origin)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = PointF::new_from_rc(t);
} else {
ret_val = PointF::new_from_owned(t);
}
ret_val
}
}
///
/// Returns the background brush in the current paint engine state.
///
/// This variable should only be used when the state() returns a
/// combination which includes the QPaintEngine::DirtyBackground flag.
///
/// **See also:** state()
/// QPaintEngine::updateState()
pub fn background_brush(&self) -> Brush {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).background_brush)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Brush::new_from_rc(t);
} else {
ret_val = Brush::new_from_owned(t);
}
ret_val
}
}
///
/// Returns the background mode in the current paint engine
/// state.
///
/// This variable should only be used when the state() returns a
/// combination which includes the QPaintEngine::DirtyBackgroundMode flag.
///
/// **See also:** state()
/// QPaintEngine::updateState()
pub fn background_mode(&self) -> BGMode {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).background_mode)(obj_data);
let ret_val = { transmute::<i32, BGMode>(ret_val) };
ret_val
}
}
///
/// Returns the font in the current paint engine
/// state.
///
/// This variable should only be used when the state() returns a
/// combination which includes the QPaintEngine::DirtyFont flag.
///
/// **See also:** state()
/// QPaintEngine::updateState()
pub fn font(&self) -> Font {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).font)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Font::new_from_rc(t);
} else {
ret_val = Font::new_from_owned(t);
}
ret_val
}
}
///
/// Returns the clip operation in the current paint engine
/// state.
///
/// This variable should only be used when the state() returns a
/// combination which includes either the QPaintEngine::DirtyClipPath
/// or the QPaintEngine::DirtyClipRegion flag.
///
/// **See also:** state()
/// QPaintEngine::updateState()
pub fn clip_operation(&self) -> ClipOperation {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).clip_operation)(obj_data);
let ret_val = { transmute::<i32, ClipOperation>(ret_val) };
ret_val
}
}
///
/// Returns the clip region in the current paint engine state.
///
/// This variable should only be used when the state() returns a
/// combination which includes the QPaintEngine::DirtyClipRegion flag.
///
/// **See also:** state()
/// QPaintEngine::updateState()
pub fn clip_region(&self) -> Region {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).clip_region)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Region::new_from_rc(t);
} else {
ret_val = Region::new_from_owned(t);
}
ret_val
}
}
///
/// Returns whether clipping is enabled or not in the current paint
/// engine state.
///
/// This variable should only be used when the state() returns a
/// combination which includes the QPaintEngine::DirtyClipEnabled
/// flag.
///
/// **See also:** state()
/// QPaintEngine::updateState()
pub fn is_clip_enabled(&self) -> bool {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).is_clip_enabled)(obj_data);
ret_val
}
}
///
/// Returns the render hints in the current paint engine state.
///
/// This variable should only be used when the state() returns a
/// combination which includes the QPaintEngine::DirtyHints
/// flag.
///
/// **See also:** state()
/// QPaintEngine::updateState()
pub fn render_hints(&self) -> RenderHints {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).render_hints)(obj_data);
let ret_val = { transmute::<i32, RenderHints>(ret_val) };
ret_val
}
}
///
/// Returns the composition mode in the current paint engine state.
///
/// This variable should only be used when the state() returns a
/// combination which includes the QPaintEngine::DirtyCompositionMode
/// flag.
///
/// **See also:** state()
/// QPaintEngine::updateState()
pub fn composition_mode(&self) -> CompositionMode {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).composition_mode)(obj_data);
let ret_val = { transmute::<i32, CompositionMode>(ret_val) };
ret_val
}
}
///
/// Returns the opacity in the current paint engine state.
pub fn opacity(&self) -> f32 {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).opacity)(obj_data);
ret_val
}
}
///
/// Returns a pointer to the painter currently updating the paint
/// engine.
pub fn painter(&self) -> Option<Painter> {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).painter)(obj_data);
if ret_val.qt_data == ::std::ptr::null() {
return None;
}
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Painter::new_from_rc(t);
} else {
ret_val = Painter::new_from_owned(t);
}
Some(ret_val)
}
}
///
/// Returns whether the coordinate of the fill have been specified
/// as bounded by the current rendering operation and have to be
/// resolved (about the currently rendered primitive).
pub fn brush_needs_resolving(&self) -> bool {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).brush_needs_resolving)(obj_data);
ret_val
}
}
///
/// Returns whether the coordinate of the stroke have been specified
/// as bounded by the current rendering operation and have to be
/// resolved (about the currently rendered primitive).
pub fn pen_needs_resolving(&self) -> bool {
let (obj_data, funcs) = self.get_paint_engine_state_obj_funcs();
unsafe {
let ret_val = ((*funcs).pen_needs_resolving)(obj_data);
ret_val
}
}
}
pub trait PaintEngineStateTrait<'a> {
#[inline]
#[doc(hidden)]
fn get_paint_engine_state_obj_funcs(&self) -> (*const RUBase, *const RUPaintEngineStateFuncs);
}
impl<'a> PaintEngineStateTrait<'a> for PaintEngineState<'a> {
#[doc(hidden)]
fn get_paint_engine_state_obj_funcs(&self) -> (*const RUBase, *const RUPaintEngineStateFuncs) {
let obj = self.data.get().unwrap();
unsafe { (obj, (*self.all_funcs).paint_engine_state_funcs) }
}
}