1- use std:: ops:: { BitAnd , BitAndAssign , BitOr , BitOrAssign } ;
2-
31use crate :: { MaybeBorrowedWindow , ui:: sys} ;
42
53/// Style of message box.
@@ -16,60 +14,22 @@ pub enum MessageBoxStyle {
1614 Error ,
1715}
1816
19- /// The pre-defined message box buttons.
20- #[ repr( i32 ) ]
21- #[ derive( Debug , Default , PartialEq , Eq , Clone , Copy ) ]
22- #[ non_exhaustive]
23- pub enum MessageBoxButton {
24- /// No pre-defined button.
25- #[ default]
26- None = 0 ,
27- /// "Ok"
28- Ok = 1 << 0 ,
29- /// "Yes"
30- Yes = 1 << 1 ,
31- /// "No"
32- No = 1 << 2 ,
33- /// "Cancel"
34- Cancel = 1 << 3 ,
35- /// "Retry"
36- Retry = 1 << 4 ,
37- /// "Close"
38- Close = 1 << 5 ,
39- }
40-
41- impl MessageBoxButton {
42- /// Check if it contains specific pre-defined button.
43- pub fn contains ( & self , v : Self ) -> bool {
44- * self & v == v
45- }
46- }
47-
48- impl BitOr for MessageBoxButton {
49- type Output = MessageBoxButton ;
50-
51- fn bitor ( self , rhs : Self ) -> Self :: Output {
52- unsafe { std:: mem:: transmute ( self as i32 | rhs as i32 ) }
53- }
54- }
55-
56- impl BitOrAssign for MessageBoxButton {
57- fn bitor_assign ( & mut self , rhs : Self ) {
58- * self = * self | rhs;
59- }
60- }
61-
62- impl BitAnd for MessageBoxButton {
63- type Output = MessageBoxButton ;
64-
65- fn bitand ( self , rhs : Self ) -> Self :: Output {
66- unsafe { std:: mem:: transmute ( self as i32 & rhs as i32 ) }
67- }
68- }
69-
70- impl BitAndAssign for MessageBoxButton {
71- fn bitand_assign ( & mut self , rhs : Self ) {
72- * self = * self & rhs;
17+ bitflags:: bitflags! {
18+ /// The pre-defined message box buttons.
19+ #[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
20+ pub struct MessageBoxButton : i32 {
21+ /// "Ok"
22+ const Ok = 1 << 0 ;
23+ /// "Yes"
24+ const Yes = 1 << 1 ;
25+ /// "No"
26+ const No = 1 << 2 ;
27+ /// "Cancel"
28+ const Cancel = 1 << 3 ;
29+ /// "Retry"
30+ const Retry = 1 << 4 ;
31+ /// "Close"
32+ const Close = 1 << 5 ;
7333 }
7434}
7535
0 commit comments