rust_macios/appkit/
ns_status_bar.rs

1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4    core_graphics::CGFloat,
5    object,
6    objective_c_runtime::traits::{FromId, PNSObject},
7};
8
9use super::{interface_impl, NSStatusItem};
10
11object! {
12     /// An individual element displayed in the system menu bar.
13    unsafe pub struct NSStatusBar;
14}
15
16#[interface_impl(NSObject)]
17impl NSStatusBar {
18    /* Getting the System-Wide Instance
19     */
20
21    /// Returns the system-wide status bar located in the menu bar.
22    #[property]
23    pub fn system_status_bar() -> Self
24    where
25        Self: Sized + FromId,
26    {
27        unsafe { Self::from_id(msg_send![Self::m_class(), systemStatusBar]) }
28    }
29
30    /* Managing Status items
31     */
32
33    /// Returns a newly created status item that has been allotted a specified space within the status bar.
34    #[method]
35    pub fn status_item_with_length(&self, length: CGFloat) -> NSStatusItem {
36        unsafe { NSStatusItem::from_id(msg_send![self.m_self(), statusItemWithLength: length]) }
37    }
38}