win_wrap/uia/pattern/range.rs
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
/*
* Copyright (c) 2024. The RigelA open source project team and
* its contributors reserve all rights.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
use crate::uia::pattern::{PatternCreator, PatternError};
use windows::Win32::UI::Accessibility::{
IUIAutomationRangeValuePattern, UIA_RangeValuePatternId, UIA_PATTERN_ID,
};
/**
提供对显示一系列值的控件的访问。
*/
pub struct UiAutomationRangeValuePattern(IUIAutomationRangeValuePattern);
impl TryFrom<IUIAutomationRangeValuePattern> for UiAutomationRangeValuePattern {
type Error = PatternError;
fn try_from(value: IUIAutomationRangeValuePattern) -> Result<Self, Self::Error> {
Ok(Self(value))
}
}
impl PatternCreator<IUIAutomationRangeValuePattern> for UiAutomationRangeValuePattern {
const PATTERN: UIA_PATTERN_ID = UIA_RangeValuePatternId;
}
/// https://learn.microsoft.com/en-us/windows/win32/api/uiautomationclient/nn-uiautomationclient-iuiautomationrangevaluepattern
impl UiAutomationRangeValuePattern {
/**
指示是否可以更改元素的值。
此属性是只读的。
*/
pub fn is_read_only(&self) -> bool {
unsafe { self.0.CurrentIsReadOnly().unwrap_or(Default::default()) }.as_bool()
}
/**
检索在进行较大更改时(例如,按下 PAGE DOWN 键时)向控件的值添加或减去的值。
此属性是只读的。
LargeChange 属性可以支持非数字 (NaN) 值。检索此属性时,客户端可以使用 _isnan 函数来确定该属性是否为 NaN 值。
*/
pub fn get_large_change(&self) -> f64 {
unsafe { self.0.CurrentLargeChange().unwrap_or(0f64) }
}
/**
检索控件的最大值。
此属性是只读的。
*/
pub fn get_maximum(&self) -> f64 {
unsafe { self.0.CurrentMaximum().unwrap_or(0f64) }
}
/**
检索控件的最小值。
此属性是只读的。
*/
pub fn get_minimum(&self) -> f64 {
unsafe { self.0.CurrentMinimum().unwrap_or(0f64) }
}
/**
检索在进行小的更改时(例如,当按下箭头键时)添加到控件的值或从控件的值中减去的值。
此属性是只读的。
SmallChange 属性可以支持非数字 (NaN) 值。检索此属性时,客户端可以使用 _isnan 函数来确定该属性是否为 NaN 值。
*/
pub fn get_small_change(&self) -> f64 {
unsafe { self.0.CurrentSmallChange().unwrap_or(0f64) }
}
/**
检索控件的值。
此属性是只读的。
*/
pub fn get_value(&self) -> f64 {
unsafe { self.0.CurrentValue().unwrap_or(0f64) }
}
/**
设置控件的值。
*/
pub fn set_value(&self, value: f64) -> bool {
unsafe { self.0.SetValue(value) }.is_ok()
}
}