1pub mod checkbox;
20pub mod combobox;
21pub mod commandbutton;
22pub mod custom;
23pub mod data;
24pub mod dirlistbox;
25pub mod drivelistbox;
26pub mod filelistbox;
27pub mod form;
28pub mod form_root;
29pub mod frame;
30pub mod image;
31pub mod label;
32pub mod line;
33pub mod listbox;
34pub mod mdiform;
35pub mod menus;
36pub mod ole;
37pub mod optionbutton;
38pub mod picturebox;
39pub mod scrollbars;
40pub mod shape;
41pub mod textbox;
42pub mod timer;
43
44use std::convert::{From, TryFrom};
45use std::fmt::{Display, Formatter};
46use std::str::FromStr;
47
48use num_enum::TryFromPrimitive;
49use serde::Serialize;
50
51use crate::errors::{ErrorKind, FormError};
52use crate::language::PropertyGroup;
53
54use crate::language::controls::{
55 checkbox::CheckBoxProperties,
56 combobox::ComboBoxProperties,
57 commandbutton::CommandButtonProperties,
58 custom::CustomControlProperties,
59 data::DataProperties,
60 dirlistbox::DirListBoxProperties,
61 drivelistbox::DriveListBoxProperties,
62 filelistbox::FileListBoxProperties,
63 frame::FrameProperties,
64 image::ImageProperties,
65 label::LabelProperties,
66 line::LineProperties,
67 listbox::ListBoxProperties,
68 menus::{MenuControl, MenuProperties},
69 ole::OLEProperties,
70 optionbutton::OptionButtonProperties,
71 picturebox::PictureBoxProperties,
72 scrollbars::ScrollBarProperties,
73 shape::ShapeProperties,
74 textbox::TextBoxProperties,
75 timer::TimerProperties,
76};
77
78pub use form_root::{Form, FormRoot, MDIForm};
80
81#[derive(Debug, PartialEq, Clone, Serialize, PartialOrd)]
85pub struct Font {
86 pub name: String,
90 pub size: f32,
94 pub charset: i32,
98 pub weight: i32,
102 pub underline: bool,
106 pub italic: bool,
110 pub strikethrough: bool,
114}
115
116impl Default for Font {
117 fn default() -> Self {
118 Font {
119 name: "MS Sans Serif".to_string(),
120 size: 8.0,
121 charset: 0,
122 weight: 400,
123 underline: false,
124 italic: false,
125 strikethrough: false,
126 }
127 }
128}
129
130#[derive(
135 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
136)]
137#[repr(i32)]
138pub enum AutoRedraw {
139 #[default]
145 Manual = 0,
146 Automatic = -1,
151}
152
153impl TryFrom<&str> for AutoRedraw {
154 type Error = ErrorKind;
155
156 fn try_from(value: &str) -> Result<Self, Self::Error> {
157 match value {
158 "0" => Ok(AutoRedraw::Manual),
159 "-1" => Ok(AutoRedraw::Automatic),
160 _ => Err(ErrorKind::Form(FormError::InvalidAutoRedraw {
161 value: value.to_string(),
162 })),
163 }
164 }
165}
166
167impl FromStr for AutoRedraw {
168 type Err = ErrorKind;
169
170 fn from_str(s: &str) -> Result<Self, Self::Err> {
171 AutoRedraw::try_from(s)
172 }
173}
174
175impl From<bool> for AutoRedraw {
176 fn from(value: bool) -> Self {
177 if value {
178 AutoRedraw::Automatic
179 } else {
180 AutoRedraw::Manual
181 }
182 }
183}
184
185impl Display for AutoRedraw {
186 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
187 let text = match self {
188 AutoRedraw::Manual => "Manual",
189 AutoRedraw::Automatic => "Automatic",
190 };
191 write!(f, "{text}")
192 }
193}
194
195#[derive(
199 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
200)]
201#[repr(i32)]
202pub enum TextDirection {
203 #[default]
207 LeftToRight = 0,
208 RightToLeft = -1,
210}
211
212impl TryFrom<&str> for TextDirection {
213 type Error = ErrorKind;
214
215 fn try_from(value: &str) -> Result<Self, Self::Error> {
216 match value {
217 "0" => Ok(TextDirection::LeftToRight),
218 "-1" => Ok(TextDirection::RightToLeft),
219 _ => Err(ErrorKind::Form(FormError::InvalidTextDirection {
220 value: value.to_string(),
221 })),
222 }
223 }
224}
225
226impl FromStr for TextDirection {
227 type Err = ErrorKind;
228
229 fn from_str(s: &str) -> Result<Self, ErrorKind> {
230 TextDirection::try_from(s)
231 }
232}
233
234impl From<bool> for TextDirection {
235 fn from(value: bool) -> Self {
236 if value {
237 TextDirection::RightToLeft
238 } else {
239 TextDirection::LeftToRight
240 }
241 }
242}
243
244impl Display for TextDirection {
245 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
246 let text = match self {
247 TextDirection::LeftToRight => "Left to Right",
248 TextDirection::RightToLeft => "Right to Left",
249 };
250 write!(f, "{text}")
251 }
252}
253
254#[derive(
263 Debug,
264 PartialEq,
265 Eq,
266 Clone,
267 serde::Serialize,
268 Default,
269 TryFromPrimitive,
270 Copy,
271 Hash,
272 PartialOrd,
273 Ord,
274)]
275#[repr(i32)]
276pub enum AutoSize {
277 #[default]
282 Fixed = 0,
283 Resize = -1,
285}
286
287impl TryFrom<&str> for AutoSize {
288 type Error = ErrorKind;
289
290 fn try_from(value: &str) -> Result<Self, ErrorKind> {
291 match value {
292 "0" => Ok(AutoSize::Fixed),
293 "-1" => Ok(AutoSize::Resize),
294 _ => Err(ErrorKind::Form(FormError::InvalidAutoSize {
295 value: value.to_string(),
296 })),
297 }
298 }
299}
300
301impl From<bool> for AutoSize {
302 fn from(value: bool) -> Self {
303 if value {
304 AutoSize::Resize
305 } else {
306 AutoSize::Fixed
307 }
308 }
309}
310
311impl FromStr for AutoSize {
312 type Err = ErrorKind;
313
314 fn from_str(s: &str) -> Result<Self, ErrorKind> {
315 AutoSize::try_from(s)
316 }
317}
318
319impl Display for AutoSize {
320 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
321 let text = match self {
322 AutoSize::Fixed => "Fixed",
323 AutoSize::Resize => "Resize",
324 };
325 write!(f, "{text}")
326 }
327}
328
329#[derive(
333 Debug,
334 PartialEq,
335 Eq,
336 Clone,
337 serde::Serialize,
338 Default,
339 TryFromPrimitive,
340 Copy,
341 Hash,
342 PartialOrd,
343 Ord,
344)]
345#[repr(i32)]
346pub enum Activation {
347 Disabled = 0,
349 #[default]
353 Enabled = -1,
354}
355
356impl From<bool> for Activation {
357 fn from(value: bool) -> Self {
358 if value {
359 Activation::Enabled
360 } else {
361 Activation::Disabled
362 }
363 }
364}
365
366impl TryFrom<&str> for Activation {
367 type Error = ErrorKind;
368
369 fn try_from(value: &str) -> Result<Self, Self::Error> {
370 match value {
371 "0" => Ok(Activation::Disabled),
372 "-1" => Ok(Activation::Enabled),
373 _ => Err(ErrorKind::Form(FormError::InvalidActivation {
374 value: value.to_string(),
375 })),
376 }
377 }
378}
379
380impl Display for Activation {
381 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
382 let text = match self {
383 Activation::Disabled => "Disabled",
384 Activation::Enabled => "Enabled",
385 };
386 write!(f, "{text}")
387 }
388}
389
390#[derive(
403 Debug,
404 PartialEq,
405 Eq,
406 Clone,
407 serde::Serialize,
408 Default,
409 TryFromPrimitive,
410 Copy,
411 Hash,
412 PartialOrd,
413 Ord,
414)]
415#[repr(i32)]
416pub enum TabStop {
417 ProgrammaticOnly = 0,
421 #[default]
425 Included = -1,
426}
427
428impl From<bool> for TabStop {
429 fn from(value: bool) -> Self {
430 if value {
431 TabStop::Included
432 } else {
433 TabStop::ProgrammaticOnly
434 }
435 }
436}
437
438impl TryFrom<&str> for TabStop {
439 type Error = ErrorKind;
440
441 fn try_from(value: &str) -> Result<Self, Self::Error> {
442 match value {
443 "0" => Ok(TabStop::ProgrammaticOnly),
444 "-1" => Ok(TabStop::Included),
445 _ => Err(ErrorKind::Form(FormError::InvalidTabStop {
446 value: value.to_string(),
447 })),
448 }
449 }
450}
451
452impl Display for TabStop {
453 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
454 let text = match self {
455 TabStop::ProgrammaticOnly => "Programmatic Only",
456 TabStop::Included => "Included",
457 };
458 write!(f, "{text}")
459 }
460}
461
462#[derive(
466 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
467)]
468#[repr(i32)]
469pub enum Visibility {
470 Hidden = 0,
472 #[default]
476 Visible = -1,
477}
478
479impl TryFrom<&str> for Visibility {
480 type Error = ErrorKind;
481
482 fn try_from(value: &str) -> Result<Self, Self::Error> {
483 match value {
484 "0" => Ok(Visibility::Hidden),
485 "-1" => Ok(Visibility::Visible),
486 _ => Err(ErrorKind::Form(FormError::InvalidVisibility {
487 value: value.to_string(),
488 })),
489 }
490 }
491}
492
493impl FromStr for Visibility {
494 type Err = ErrorKind;
495
496 fn from_str(s: &str) -> Result<Self, Self::Err> {
497 Visibility::try_from(s)
498 }
499}
500
501impl From<bool> for Visibility {
502 fn from(value: bool) -> Self {
503 if value {
504 Visibility::Visible
505 } else {
506 Visibility::Hidden
507 }
508 }
509}
510
511impl Display for Visibility {
512 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
513 let text = match self {
514 Visibility::Hidden => "Hidden",
515 Visibility::Visible => "Visible",
516 };
517 write!(f, "{text}")
518 }
519}
520
521#[derive(
530 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
531)]
532#[repr(i32)]
533pub enum HasDeviceContext {
534 NoContext = 0,
536 #[default]
540 HasContext = -1,
541}
542
543impl TryFrom<&str> for HasDeviceContext {
544 type Error = ErrorKind;
545
546 fn try_from(value: &str) -> Result<Self, Self::Error> {
547 match value {
548 "0" => Ok(HasDeviceContext::NoContext),
549 "-1" => Ok(HasDeviceContext::HasContext),
550 _ => Err(ErrorKind::Form(FormError::InvalidHasDeviceContext {
551 value: value.to_string(),
552 })),
553 }
554 }
555}
556
557impl FromStr for HasDeviceContext {
558 type Err = ErrorKind;
559
560 fn from_str(s: &str) -> Result<Self, Self::Err> {
561 HasDeviceContext::try_from(s)
562 }
563}
564
565impl From<bool> for HasDeviceContext {
566 fn from(value: bool) -> Self {
567 if value {
568 HasDeviceContext::HasContext
569 } else {
570 HasDeviceContext::NoContext
571 }
572 }
573}
574
575impl Display for HasDeviceContext {
576 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
577 let text = match self {
578 HasDeviceContext::NoContext => "No Context",
579 HasDeviceContext::HasContext => "Has Context",
580 };
581 write!(f, "{text}")
582 }
583}
584
585#[derive(
591 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
592)]
593#[repr(i32)]
594pub enum UseMaskColor {
595 #[default]
599 DoNotUseMaskColor = 0,
600 UseMaskColor = -1,
603}
604
605impl Display for UseMaskColor {
606 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
607 let text = match self {
608 UseMaskColor::DoNotUseMaskColor => "Do not use Mask Color",
609 UseMaskColor::UseMaskColor => "Use Mask Color",
610 };
611 write!(f, "{text}")
612 }
613}
614
615#[derive(
627 Debug,
628 PartialEq,
629 Eq,
630 Clone,
631 serde::Serialize,
632 Default,
633 TryFromPrimitive,
634 Copy,
635 Hash,
636 PartialOrd,
637 Ord,
638)]
639#[repr(i32)]
640pub enum CausesValidation {
641 No = 0,
645 #[default]
650 Yes = -1,
651}
652
653impl TryFrom<&str> for CausesValidation {
654 type Error = ErrorKind;
655
656 fn try_from(value: &str) -> Result<Self, Self::Error> {
657 match value {
658 "0" => Ok(CausesValidation::No),
659 "-1" => Ok(CausesValidation::Yes),
660 _ => Err(ErrorKind::Form(FormError::InvalidCausesValidation {
661 value: value.to_string(),
662 })),
663 }
664 }
665}
666
667impl FromStr for CausesValidation {
668 type Err = ErrorKind;
669
670 fn from_str(s: &str) -> Result<Self, Self::Err> {
671 CausesValidation::try_from(s)
672 }
673}
674
675impl From<bool> for CausesValidation {
676 fn from(value: bool) -> Self {
677 if value {
678 CausesValidation::Yes
679 } else {
680 CausesValidation::No
681 }
682 }
683}
684
685impl Display for CausesValidation {
686 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
687 let text = match self {
688 CausesValidation::No => "No",
689 CausesValidation::Yes => "Yes",
690 };
691 write!(f, "{text}")
692 }
693}
694
695#[derive(
703 Debug,
704 PartialEq,
705 Eq,
706 Clone,
707 Default,
708 TryFromPrimitive,
709 serde::Serialize,
710 Copy,
711 Hash,
712 PartialOrd,
713 Ord,
714)]
715#[repr(i32)]
716pub enum Movability {
717 Fixed = 0,
719 #[default]
723 Moveable = -1,
724}
725
726impl TryFrom<&str> for Movability {
727 type Error = ErrorKind;
728
729 fn try_from(value: &str) -> Result<Self, Self::Error> {
730 match value {
731 "0" => Ok(Movability::Fixed),
732 "-1" => Ok(Movability::Moveable),
733 _ => Err(ErrorKind::Form(FormError::InvalidMovability {
734 value: value.to_string(),
735 })),
736 }
737 }
738}
739
740impl FromStr for Movability {
741 type Err = ErrorKind;
742
743 fn from_str(s: &str) -> Result<Self, Self::Err> {
744 Movability::try_from(s)
745 }
746}
747
748impl From<bool> for Movability {
749 fn from(value: bool) -> Self {
750 if value {
751 Movability::Moveable
752 } else {
753 Movability::Fixed
754 }
755 }
756}
757
758impl Display for Movability {
759 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
760 let text = match self {
761 Movability::Fixed => "Fixed",
762 Movability::Moveable => "Moveable",
763 };
764 write!(f, "{text}")
765 }
766}
767
768#[derive(
773 Debug,
774 PartialEq,
775 Eq,
776 Clone,
777 Default,
778 TryFromPrimitive,
779 serde::Serialize,
780 Copy,
781 Hash,
782 PartialOrd,
783 Ord,
784)]
785#[repr(i32)]
786pub enum FontTransparency {
787 Opaque = 0,
790 #[default]
795 Transparent = -1,
796}
797
798impl TryFrom<&str> for FontTransparency {
799 type Error = ErrorKind;
800
801 fn try_from(value: &str) -> Result<Self, Self::Error> {
802 match value {
803 "0" => Ok(FontTransparency::Opaque),
804 "-1" => Ok(FontTransparency::Transparent),
805 _ => Err(ErrorKind::Form(FormError::InvalidFontTransparency {
806 value: value.to_string(),
807 })),
808 }
809 }
810}
811
812impl FromStr for FontTransparency {
813 type Err = ErrorKind;
814
815 fn from_str(s: &str) -> Result<Self, Self::Err> {
816 FontTransparency::try_from(s)
817 }
818}
819
820impl From<bool> for FontTransparency {
821 fn from(value: bool) -> Self {
822 if value {
823 FontTransparency::Transparent
824 } else {
825 FontTransparency::Opaque
826 }
827 }
828}
829
830impl Display for FontTransparency {
831 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
832 let text = match self {
833 FontTransparency::Opaque => "Opaque",
834 FontTransparency::Transparent => "Transparent",
835 };
836 write!(f, "{text}")
837 }
838}
839
840#[derive(
846 Debug,
847 PartialEq,
848 Eq,
849 Clone,
850 Default,
851 TryFromPrimitive,
852 serde::Serialize,
853 Copy,
854 Hash,
855 PartialOrd,
856 Ord,
857)]
858#[repr(i32)]
859pub enum WhatsThisHelp {
860 #[default]
865 F1Help = 0,
866 WhatsThisHelp = -1,
870}
871
872impl TryFrom<&str> for WhatsThisHelp {
873 type Error = ErrorKind;
874
875 fn try_from(value: &str) -> Result<Self, Self::Error> {
876 match value {
877 "0" => Ok(WhatsThisHelp::F1Help),
878 "-1" => Ok(WhatsThisHelp::WhatsThisHelp),
879 _ => Err(ErrorKind::Form(FormError::InvalidWhatsThisHelp {
880 value: value.to_string(),
881 })),
882 }
883 }
884}
885
886impl From<bool> for WhatsThisHelp {
887 fn from(value: bool) -> Self {
888 if value {
889 WhatsThisHelp::WhatsThisHelp
890 } else {
891 WhatsThisHelp::F1Help
892 }
893 }
894}
895
896impl FromStr for WhatsThisHelp {
897 type Err = ErrorKind;
898
899 fn from_str(s: &str) -> Result<Self, Self::Err> {
900 WhatsThisHelp::try_from(s)
901 }
902}
903
904impl Display for WhatsThisHelp {
905 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
906 let text = match self {
907 WhatsThisHelp::F1Help => "F1Help",
908 WhatsThisHelp::WhatsThisHelp => "WhatsThisHelp",
909 };
910 write!(f, "{text}")
911 }
912}
913
914#[derive(
923 Debug,
924 PartialEq,
925 Eq,
926 Clone,
927 serde::Serialize,
928 Default,
929 TryFromPrimitive,
930 Copy,
931 Hash,
932 PartialOrd,
933 Ord,
934)]
935#[repr(i32)]
936pub enum FormLinkMode {
937 #[default]
943 None = 0,
944 Source = 1,
951}
952
953impl TryFrom<&str> for FormLinkMode {
954 type Error = ErrorKind;
955
956 fn try_from(value: &str) -> Result<Self, Self::Error> {
957 match value {
958 "0" => Ok(FormLinkMode::None),
959 "1" => Ok(FormLinkMode::Source),
960 _ => Err(ErrorKind::Form(FormError::InvalidFormLinkMode {
961 value: value.to_string(),
962 })),
963 }
964 }
965}
966
967impl FromStr for FormLinkMode {
968 type Err = ErrorKind;
969
970 fn from_str(s: &str) -> Result<Self, Self::Err> {
971 FormLinkMode::try_from(s)
972 }
973}
974
975impl From<bool> for FormLinkMode {
976 fn from(value: bool) -> Self {
977 if value {
978 FormLinkMode::Source
979 } else {
980 FormLinkMode::None
981 }
982 }
983}
984
985impl Display for FormLinkMode {
986 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
987 let text = match self {
988 FormLinkMode::None => "None",
989 FormLinkMode::Source => "Source",
990 };
991 write!(f, "{text}")
992 }
993}
994
995#[derive(
1000 Debug,
1001 PartialEq,
1002 Eq,
1003 Clone,
1004 serde::Serialize,
1005 Default,
1006 TryFromPrimitive,
1007 Copy,
1008 Hash,
1009 PartialOrd,
1010 Ord,
1011)]
1012#[repr(i32)]
1013pub enum WindowState {
1014 #[default]
1018 Normal = 0,
1019 Minimized = 1,
1021 Maximized = 2,
1023}
1024
1025impl TryFrom<&str> for WindowState {
1026 type Error = ErrorKind;
1027
1028 fn try_from(value: &str) -> Result<Self, Self::Error> {
1029 match value {
1030 "0" => Ok(WindowState::Normal),
1031 "1" => Ok(WindowState::Minimized),
1032 "2" => Ok(WindowState::Maximized),
1033 _ => Err(ErrorKind::Form(FormError::InvalidWindowState {
1034 value: value.to_string(),
1035 })),
1036 }
1037 }
1038}
1039
1040impl FromStr for WindowState {
1041 type Err = ErrorKind;
1042
1043 fn from_str(s: &str) -> Result<Self, Self::Err> {
1044 WindowState::try_from(s)
1045 }
1046}
1047
1048impl Display for WindowState {
1049 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1050 let text = match self {
1051 WindowState::Normal => "Normal",
1052 WindowState::Minimized => "Minimized",
1053 WindowState::Maximized => "Maximized",
1054 };
1055 write!(f, "{text}")
1056 }
1057}
1058
1059#[derive(Debug, PartialEq, Eq, Clone, serde::Serialize, Default, Copy, Hash, PartialOrd, Ord)]
1064pub enum StartUpPosition {
1065 Manual {
1070 client_height: i32,
1072 client_width: i32,
1074 client_top: i32,
1076 client_left: i32,
1078 },
1079 CenterOwner,
1083 CenterScreen,
1087 #[default]
1088 WindowsDefault,
1094}
1095
1096impl Display for StartUpPosition {
1097 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1098 match self {
1099 StartUpPosition::Manual {
1100 client_height,
1101 client_width,
1102 client_top,
1103 client_left,
1104 } => write!(
1105 f,
1106 "Manual {{ client height: {client_height}, client width: {client_width}, client top: {client_top}, client left: {client_left} }}"
1107 ),
1108 StartUpPosition::CenterOwner => write!(f, "CenterOwner"),
1109 StartUpPosition::CenterScreen => write!(f, "CenterScreen"),
1110 StartUpPosition::WindowsDefault => write!(f, "WindowsDefault"),
1111 }
1112 }
1113}
1114
1115#[derive(Debug, PartialEq, Clone, Serialize)]
1126pub enum ReferenceOrValue<T> {
1127 Reference { filename: String, offset: u32 },
1128 Value(T),
1129}
1130
1131impl<T> Display for ReferenceOrValue<T> {
1132 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1133 match self {
1134 ReferenceOrValue::Reference { filename, offset } => {
1135 write!(f, "Reference {{ filename: {filename}, offset: {offset} }}",)
1136 }
1137 ReferenceOrValue::Value(_) => write!(f, "Value"),
1138 }
1139 }
1140}
1141
1142#[derive(Debug, PartialEq, Clone, Serialize)]
1144pub struct Control {
1145 name: String,
1147 tag: String,
1149 index: i32,
1151 kind: ControlKind,
1153}
1154
1155impl Control {
1156 #[must_use]
1169 pub fn new(name: String, tag: String, index: i32, kind: ControlKind) -> Self {
1170 Self {
1171 name,
1172 tag,
1173 index,
1174 kind,
1175 }
1176 }
1177
1178 #[must_use]
1180 pub fn name(&self) -> &str {
1181 &self.name
1182 }
1183
1184 #[must_use]
1186 pub fn tag(&self) -> &str {
1187 &self.tag
1188 }
1189
1190 #[must_use]
1192 pub fn index(&self) -> i32 {
1193 self.index
1194 }
1195
1196 #[must_use]
1198 pub fn kind(&self) -> &ControlKind {
1199 &self.kind
1200 }
1201
1202 #[must_use]
1204 pub fn into_name(self) -> String {
1205 self.name
1206 }
1207
1208 #[must_use]
1210 pub fn into_tag(self) -> String {
1211 self.tag
1212 }
1213
1214 #[must_use]
1216 pub fn into_kind(self) -> ControlKind {
1217 self.kind
1218 }
1219
1220 #[must_use]
1226 pub fn into_parts(self) -> (String, String, i32, ControlKind) {
1227 (self.name, self.tag, self.index, self.kind)
1228 }
1229
1230 pub fn set_name(&mut self, name: String) {
1235 self.name = name;
1236 }
1237}
1238
1239impl Display for Control {
1240 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1241 write!(f, "Control: {} ({})", self.name, self.kind)
1242 }
1243}
1244
1245#[derive(Debug, PartialEq, Clone, Serialize)]
1249pub enum ControlKind {
1250 CommandButton {
1252 properties: CommandButtonProperties,
1254 },
1255 Data {
1257 properties: DataProperties,
1259 },
1260 TextBox {
1262 properties: TextBoxProperties,
1264 },
1265 CheckBox {
1267 properties: CheckBoxProperties,
1269 },
1270 Line {
1272 properties: LineProperties,
1274 },
1275 Shape {
1277 properties: ShapeProperties,
1279 },
1280 ListBox {
1282 properties: ListBoxProperties,
1284 },
1285 Timer {
1287 properties: TimerProperties,
1289 },
1290 Label {
1292 properties: LabelProperties,
1294 },
1295 Frame {
1297 properties: FrameProperties,
1299 controls: Vec<Control>,
1301 },
1302 PictureBox {
1304 properties: PictureBoxProperties,
1306 controls: Vec<Control>,
1308 },
1309 FileListBox {
1311 properties: FileListBoxProperties,
1313 },
1314 DriveListBox {
1316 properties: DriveListBoxProperties,
1318 },
1319 DirListBox {
1321 properties: DirListBoxProperties,
1323 },
1324 Ole {
1326 properties: OLEProperties,
1328 },
1329 OptionButton {
1331 properties: OptionButtonProperties,
1333 },
1334 Image {
1336 properties: ImageProperties,
1338 },
1339 ComboBox {
1341 properties: ComboBoxProperties,
1343 },
1344 HScrollBar {
1346 properties: ScrollBarProperties,
1348 },
1349 VScrollBar {
1351 properties: ScrollBarProperties,
1353 },
1354 Menu {
1356 properties: MenuProperties,
1358 sub_menus: Vec<MenuControl>,
1360 },
1361 Custom {
1363 properties: CustomControlProperties,
1365 property_groups: Vec<PropertyGroup>,
1367 },
1368}
1369
1370impl Display for ControlKind {
1371 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1372 match self {
1373 ControlKind::CommandButton { .. } => write!(f, "CommandButton"),
1374 ControlKind::Data { .. } => write!(f, "Data"),
1375 ControlKind::TextBox { .. } => write!(f, "TextBox"),
1376 ControlKind::CheckBox { .. } => write!(f, "CheckBox"),
1377 ControlKind::Line { .. } => write!(f, "Line"),
1378 ControlKind::Shape { .. } => write!(f, "Shape"),
1379 ControlKind::ListBox { .. } => write!(f, "ListBox"),
1380 ControlKind::Timer { .. } => write!(f, "Timer"),
1381 ControlKind::Label { .. } => write!(f, "Label"),
1382 ControlKind::Frame { .. } => write!(f, "Frame"),
1383 ControlKind::PictureBox { .. } => write!(f, "PictureBox"),
1384 ControlKind::FileListBox { .. } => write!(f, "FileListBox"),
1385 ControlKind::DriveListBox { .. } => write!(f, "DriveListBox"),
1386 ControlKind::DirListBox { .. } => write!(f, "DirListBox"),
1387 ControlKind::Ole { .. } => write!(f, "OLE"),
1388 ControlKind::OptionButton { .. } => write!(f, "OptionButton"),
1389 ControlKind::Image { .. } => write!(f, "Image"),
1390 ControlKind::ComboBox { .. } => write!(f, "ComboBox"),
1391 ControlKind::HScrollBar { .. } => write!(f, "HScrollBar"),
1392 ControlKind::VScrollBar { .. } => write!(f, "VScrollBar"),
1393 ControlKind::Menu { .. } => write!(f, "Menu"),
1394 ControlKind::Custom { .. } => write!(f, "Custom"),
1395 }
1396 }
1397}
1398
1399impl ControlKind {
1401 #[must_use]
1407 pub fn is_menu(&self) -> bool {
1408 matches!(self, ControlKind::Menu { .. })
1409 }
1410
1411 #[must_use]
1417 pub fn can_contain_children(&self) -> bool {
1418 matches!(
1419 self,
1420 ControlKind::Frame { .. } | ControlKind::PictureBox { .. }
1421 )
1422 }
1423
1424 #[must_use]
1433 pub fn can_contain_menus(&self) -> bool {
1434 false
1435 }
1436
1437 #[must_use]
1446 pub fn has_menu(&self) -> bool {
1447 false
1448 }
1449
1450 #[must_use]
1456 pub fn has_children(&self) -> bool {
1457 matches!(
1458 self,
1459 ControlKind::Frame { controls, .. } |
1460 ControlKind::PictureBox { controls, .. } if !controls.is_empty()
1461 )
1462 }
1463
1464 #[must_use]
1492 pub fn children(&self) -> Option<impl Iterator<Item = &Control>> {
1493 match self {
1494 ControlKind::Frame { controls, .. } | ControlKind::PictureBox { controls, .. } => {
1495 Some(controls.iter())
1496 }
1497 _ => None,
1498 }
1499 }
1500
1501 #[must_use]
1528 pub fn menus(&self) -> Option<impl Iterator<Item = &MenuControl>> {
1529 None::<std::iter::Empty<&MenuControl>>
1530 }
1531
1532 #[must_use]
1575 pub fn descendants(&self) -> Box<dyn Iterator<Item = &Control> + '_> {
1576 Box::new(
1577 self.children()
1578 .into_iter()
1579 .flatten()
1580 .flat_map(|child| child.descendants()),
1581 )
1582 }
1583}
1584
1585impl Control {
1586 #[must_use]
1588 pub fn is_menu(&self) -> bool {
1589 self.kind.is_menu()
1590 }
1591
1592 #[must_use]
1594 pub fn has_menu(&self) -> bool {
1595 self.kind.has_menu()
1596 }
1597
1598 #[must_use]
1624 pub fn menus(&self) -> Option<impl Iterator<Item = &MenuControl>> {
1625 self.kind.menus()
1626 }
1627
1628 #[must_use]
1630 pub fn can_contain_menus(&self) -> bool {
1631 self.kind.can_contain_menus()
1632 }
1633
1634 #[must_use]
1636 pub fn can_contain_children(&self) -> bool {
1637 self.kind.can_contain_children()
1638 }
1639
1640 #[must_use]
1668 pub fn children(&self) -> Option<impl Iterator<Item = &Control>> {
1669 self.kind.children()
1670 }
1671
1672 #[must_use]
1674 pub fn has_children(&self) -> bool {
1675 matches!(
1676 self.kind,
1677 ControlKind::Frame { .. } | ControlKind::PictureBox { .. }
1678 )
1679 }
1680
1681 #[must_use]
1725 pub fn descendants(&self) -> Box<dyn Iterator<Item = &Control> + '_> {
1726 Box::new(std::iter::once(self).chain(self.kind.descendants()))
1727 }
1728}
1729
1730#[derive(
1736 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
1737)]
1738#[repr(i32)]
1739pub enum Align {
1740 #[default]
1745 None = 0,
1746 Top = 1,
1751 Bottom = 2,
1754 Left = 3,
1757 Right = 4,
1760}
1761
1762impl TryFrom<&str> for Align {
1763 type Error = ErrorKind;
1764
1765 fn try_from(value: &str) -> Result<Self, Self::Error> {
1766 match value {
1767 "0" => Ok(Align::None),
1768 "1" => Ok(Align::Top),
1769 "2" => Ok(Align::Bottom),
1770 "3" => Ok(Align::Left),
1771 "4" => Ok(Align::Right),
1772 _ => Err(ErrorKind::Form(FormError::InvalidAlign {
1773 value: value.to_string(),
1774 })),
1775 }
1776 }
1777}
1778
1779impl FromStr for Align {
1780 type Err = ErrorKind;
1781
1782 fn from_str(s: &str) -> Result<Self, Self::Err> {
1783 Align::try_from(s)
1784 }
1785}
1786
1787impl Display for Align {
1788 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1789 let text = match self {
1790 Align::None => "None",
1791 Align::Top => "Top",
1792 Align::Bottom => "Bottom",
1793 Align::Left => "Left",
1794 Align::Right => "Right",
1795 };
1796 write!(f, "{text}")
1797 }
1798}
1799
1800#[derive(
1807 Debug, PartialEq, Eq, Clone, Serialize, TryFromPrimitive, Default, Copy, Hash, PartialOrd, Ord,
1808)]
1809#[repr(i32)]
1810pub enum JustifyAlignment {
1811 #[default]
1815 LeftJustify = 0,
1816 RightJustify = 1,
1818}
1819
1820impl TryFrom<&str> for JustifyAlignment {
1821 type Error = ErrorKind;
1822
1823 fn try_from(value: &str) -> Result<Self, Self::Error> {
1824 match value {
1825 "0" => Ok(JustifyAlignment::LeftJustify),
1826 "1" => Ok(JustifyAlignment::RightJustify),
1827 _ => Err(ErrorKind::Form(FormError::InvalidJustifyAlignment {
1828 value: value.to_string(),
1829 })),
1830 }
1831 }
1832}
1833
1834impl FromStr for JustifyAlignment {
1835 type Err = ErrorKind;
1836
1837 fn from_str(s: &str) -> Result<Self, Self::Err> {
1838 JustifyAlignment::try_from(s)
1839 }
1840}
1841
1842impl Display for JustifyAlignment {
1843 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1844 let text = match self {
1845 JustifyAlignment::LeftJustify => "Left Justify",
1846 JustifyAlignment::RightJustify => "Right Justify",
1847 };
1848 write!(f, "{text}")
1849 }
1850}
1851
1852#[derive(
1859 Debug, PartialEq, Eq, Clone, Serialize, TryFromPrimitive, Default, Copy, Hash, PartialOrd, Ord,
1860)]
1861#[repr(i32)]
1862pub enum Alignment {
1863 #[default]
1867 LeftJustify = 0,
1868 RightJustify = 1,
1870 Center = 2,
1872}
1873
1874impl TryFrom<&str> for Alignment {
1875 type Error = ErrorKind;
1876
1877 fn try_from(value: &str) -> Result<Self, Self::Error> {
1878 match value {
1879 "0" => Ok(Alignment::LeftJustify),
1880 "1" => Ok(Alignment::RightJustify),
1881 "2" => Ok(Alignment::Center),
1882 _ => Err(ErrorKind::Form(FormError::InvalidAlignment {
1883 value: value.to_string(),
1884 })),
1885 }
1886 }
1887}
1888
1889impl FromStr for Alignment {
1890 type Err = ErrorKind;
1891
1892 fn from_str(s: &str) -> Result<Self, Self::Err> {
1893 Alignment::try_from(s)
1894 }
1895}
1896
1897impl Display for Alignment {
1898 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1899 let text = match self {
1900 Alignment::LeftJustify => "LeftJustify",
1901 Alignment::RightJustify => "RightJustify",
1902 Alignment::Center => "Center",
1903 };
1904 write!(f, "{text}")
1905 }
1906}
1907
1908#[derive(
1913 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
1914)]
1915#[repr(i32)]
1916pub enum BackStyle {
1917 Transparent = 0,
1920 #[default]
1925 Opaque = 1,
1926}
1927
1928impl TryFrom<&str> for BackStyle {
1929 type Error = ErrorKind;
1930
1931 fn try_from(value: &str) -> Result<Self, Self::Error> {
1932 match value {
1933 "0" => Ok(BackStyle::Transparent),
1934 "1" => Ok(BackStyle::Opaque),
1935 _ => Err(ErrorKind::Form(FormError::InvalidBackStyle {
1936 value: value.to_string(),
1937 })),
1938 }
1939 }
1940}
1941
1942impl FromStr for BackStyle {
1943 type Err = ErrorKind;
1944
1945 fn from_str(s: &str) -> Result<Self, Self::Err> {
1946 BackStyle::try_from(s)
1947 }
1948}
1949
1950impl Display for BackStyle {
1951 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1952 let text = match self {
1953 BackStyle::Transparent => "Transparent",
1954 BackStyle::Opaque => "Opaque",
1955 };
1956 write!(f, "{text}")
1957 }
1958}
1959
1960#[derive(
1982 Debug, PartialEq, Eq, Clone, Serialize, TryFromPrimitive, Default, Copy, Hash, PartialOrd, Ord,
1983)]
1984#[repr(i32)]
1985pub enum Appearance {
1986 Flat = 0,
1988 #[default]
1992 ThreeD = 1,
1993}
1994
1995impl TryFrom<&str> for Appearance {
1996 type Error = ErrorKind;
1997
1998 fn try_from(value: &str) -> Result<Self, Self::Error> {
1999 match value {
2000 "0" => Ok(Appearance::Flat),
2001 "1" => Ok(Appearance::ThreeD),
2002 _ => Err(ErrorKind::Form(FormError::InvalidAppearance {
2003 value: value.to_string(),
2004 })),
2005 }
2006 }
2007}
2008
2009impl FromStr for Appearance {
2010 type Err = ErrorKind;
2011
2012 fn from_str(s: &str) -> Result<Self, Self::Err> {
2013 Appearance::try_from(s)
2014 }
2015}
2016
2017impl Display for Appearance {
2018 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2019 let text = match self {
2020 Appearance::Flat => "Flat",
2021 Appearance::ThreeD => "ThreeD",
2022 };
2023 write!(f, "{text}")
2024 }
2025}
2026
2027#[derive(
2031 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2032)]
2033#[repr(i32)]
2034pub enum BorderStyle {
2035 None = 0,
2039 #[default]
2044 FixedSingle = 1,
2045}
2046
2047impl TryFrom<&str> for BorderStyle {
2048 type Error = ErrorKind;
2049
2050 fn try_from(value: &str) -> Result<Self, Self::Error> {
2051 match value {
2052 "0" => Ok(BorderStyle::None),
2053 "1" => Ok(BorderStyle::FixedSingle),
2054 _ => Err(ErrorKind::Form(FormError::InvalidBorderStyle {
2055 value: value.to_string(),
2056 })),
2057 }
2058 }
2059}
2060
2061impl FromStr for BorderStyle {
2062 type Err = ErrorKind;
2063
2064 fn from_str(s: &str) -> Result<Self, Self::Err> {
2065 BorderStyle::try_from(s)
2066 }
2067}
2068
2069impl Display for BorderStyle {
2070 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2071 let text = match self {
2072 BorderStyle::None => "None",
2073 BorderStyle::FixedSingle => "FixedSingle",
2074 };
2075 write!(f, "{text}")
2076 }
2077}
2078
2079#[derive(
2081 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2082)]
2083#[repr(i32)]
2084pub enum DragMode {
2085 #[default]
2090 Manual = 0,
2091 Automatic = 1,
2094}
2095
2096impl TryFrom<&str> for DragMode {
2097 type Error = ErrorKind;
2098
2099 fn try_from(value: &str) -> Result<Self, Self::Error> {
2100 match value {
2101 "0" => Ok(DragMode::Manual),
2102 "1" => Ok(DragMode::Automatic),
2103 _ => Err(ErrorKind::Form(FormError::InvalidDragMode {
2104 value: value.to_string(),
2105 })),
2106 }
2107 }
2108}
2109
2110impl FromStr for DragMode {
2111 type Err = ErrorKind;
2112
2113 fn from_str(s: &str) -> Result<Self, Self::Err> {
2114 DragMode::try_from(s)
2115 }
2116}
2117
2118impl Display for DragMode {
2119 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2120 let text = match self {
2121 DragMode::Manual => "Manual",
2122 DragMode::Automatic => "Automatic",
2123 };
2124 write!(f, "{text}")
2125 }
2126}
2127
2128#[derive(
2131 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2132)]
2133#[repr(i32)]
2134pub enum DrawMode {
2135 Blackness = 1,
2137 NotMergePen = 2,
2139 MaskNotPen = 3,
2141 NotCopyPen = 4,
2143 MaskPenNot = 5,
2145 Invert = 6,
2147 XorPen = 7,
2149 NotMaskPen = 8,
2151 MaskPen = 9,
2153 NotXorPen = 10,
2155 Nop = 11,
2157 MergeNotPen = 12,
2159 #[default]
2163 CopyPen = 13,
2164 MergePenNot = 14,
2166 MergePen = 15,
2168 Whiteness = 16,
2170}
2171
2172impl TryFrom<&str> for DrawMode {
2173 type Error = ErrorKind;
2174
2175 fn try_from(value: &str) -> Result<Self, Self::Error> {
2176 match value {
2177 "1" => Ok(DrawMode::Blackness),
2178 "2" => Ok(DrawMode::NotMergePen),
2179 "3" => Ok(DrawMode::MaskNotPen),
2180 "4" => Ok(DrawMode::NotCopyPen),
2181 "5" => Ok(DrawMode::MaskPenNot),
2182 "6" => Ok(DrawMode::Invert),
2183 "7" => Ok(DrawMode::XorPen),
2184 "8" => Ok(DrawMode::NotMaskPen),
2185 "9" => Ok(DrawMode::MaskPen),
2186 "10" => Ok(DrawMode::NotXorPen),
2187 "11" => Ok(DrawMode::Nop),
2188 "12" => Ok(DrawMode::MergeNotPen),
2189 "13" => Ok(DrawMode::CopyPen),
2190 "14" => Ok(DrawMode::MergePenNot),
2191 "15" => Ok(DrawMode::MergePen),
2192 "16" => Ok(DrawMode::Whiteness),
2193 _ => Err(ErrorKind::Form(FormError::InvalidDrawMode {
2194 value: value.to_string(),
2195 })),
2196 }
2197 }
2198}
2199
2200impl FromStr for DrawMode {
2201 type Err = ErrorKind;
2202
2203 fn from_str(s: &str) -> Result<Self, Self::Err> {
2204 DrawMode::try_from(s)
2205 }
2206}
2207
2208impl Display for DrawMode {
2209 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2210 let text = match self {
2211 DrawMode::Blackness => "Blackness",
2212 DrawMode::NotMergePen => "Not Merge Pen",
2213 DrawMode::MaskNotPen => "Mask Not Pen",
2214 DrawMode::NotCopyPen => "Not Copy Pen",
2215 DrawMode::MaskPenNot => "Mask Pen Not",
2216 DrawMode::Invert => "Invert",
2217 DrawMode::XorPen => "Xor Pen",
2218 DrawMode::NotMaskPen => "Not Mask Pen",
2219 DrawMode::MaskPen => "Mask Pen",
2220 DrawMode::NotXorPen => "Not Xor Pen",
2221 DrawMode::Nop => "Nop",
2222 DrawMode::MergeNotPen => "Merge Not Pen",
2223 DrawMode::CopyPen => "Copy Pen",
2224 DrawMode::MergePenNot => "Merge Pen Not",
2225 DrawMode::MergePen => "Merge Pen",
2226 DrawMode::Whiteness => "Whiteness",
2227 };
2228 write!(f, "{text}")
2229 }
2230}
2231
2232#[derive(
2234 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2235)]
2236#[repr(i32)]
2237pub enum DrawStyle {
2238 #[default]
2242 Solid = 0,
2243 Dash = 1,
2245 Dot = 2,
2247 DashDot = 3,
2249 DashDotDot = 4,
2251 Transparent = 5,
2253 InsideSolid = 6,
2255}
2256
2257impl TryFrom<&str> for DrawStyle {
2258 type Error = ErrorKind;
2259
2260 fn try_from(value: &str) -> Result<Self, Self::Error> {
2261 match value {
2262 "0" => Ok(DrawStyle::Solid),
2263 "1" => Ok(DrawStyle::Dash),
2264 "2" => Ok(DrawStyle::Dot),
2265 "3" => Ok(DrawStyle::DashDot),
2266 "4" => Ok(DrawStyle::DashDotDot),
2267 "5" => Ok(DrawStyle::Transparent),
2268 "6" => Ok(DrawStyle::InsideSolid),
2269 _ => Err(ErrorKind::Form(FormError::InvalidDrawStyle {
2270 value: value.to_string(),
2271 })),
2272 }
2273 }
2274}
2275
2276impl FromStr for DrawStyle {
2277 type Err = ErrorKind;
2278
2279 fn from_str(s: &str) -> Result<Self, Self::Err> {
2280 DrawStyle::try_from(s)
2281 }
2282}
2283
2284impl Display for DrawStyle {
2285 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2286 let text = match self {
2287 DrawStyle::Solid => "Solid",
2288 DrawStyle::Dash => "Dash",
2289 DrawStyle::Dot => "Dot",
2290 DrawStyle::DashDot => "DashDot",
2291 DrawStyle::DashDotDot => "DashDotDot",
2292 DrawStyle::Transparent => "Transparent",
2293 DrawStyle::InsideSolid => "InsideSolid",
2294 };
2295 write!(f, "{text}")
2296 }
2297}
2298
2299#[derive(
2301 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2302)]
2303#[repr(i32)]
2304pub enum MousePointer {
2305 #[default]
2309 Default = 0,
2310 Arrow = 1,
2312 Cross = 2,
2314 IBeam = 3,
2316 Icon = 4,
2320 Size = 5,
2323 SizeNESW = 6,
2325 SizeNS = 7,
2327 SizeNWSE = 8,
2329 SizeWE = 9,
2331 UpArrow = 10,
2333 Hourglass = 11,
2335 NoDrop = 12,
2338 ArrowHourglass = 13,
2340 ArrowQuestion = 14,
2342 SizeAll = 15,
2346 Custom = 99,
2350}
2351
2352impl TryFrom<&str> for MousePointer {
2353 type Error = ErrorKind;
2354
2355 fn try_from(value: &str) -> Result<Self, Self::Error> {
2356 match value {
2357 "0" => Ok(MousePointer::Default),
2358 "1" => Ok(MousePointer::Arrow),
2359 "2" => Ok(MousePointer::Cross),
2360 "3" => Ok(MousePointer::IBeam),
2361 "4" => Ok(MousePointer::Icon),
2362 "5" => Ok(MousePointer::Size),
2363 "6" => Ok(MousePointer::SizeNESW),
2364 "7" => Ok(MousePointer::SizeNS),
2365 "8" => Ok(MousePointer::SizeNWSE),
2366 "9" => Ok(MousePointer::SizeWE),
2367 "10" => Ok(MousePointer::UpArrow),
2368 "11" => Ok(MousePointer::Hourglass),
2369 "12" => Ok(MousePointer::NoDrop),
2370 "13" => Ok(MousePointer::ArrowHourglass),
2371 "14" => Ok(MousePointer::ArrowQuestion),
2372 "15" => Ok(MousePointer::SizeAll),
2373 "99" => Ok(MousePointer::Custom),
2374 _ => Err(ErrorKind::Form(FormError::InvalidMousePointer {
2375 value: value.to_string(),
2376 })),
2377 }
2378 }
2379}
2380
2381impl FromStr for MousePointer {
2382 type Err = ErrorKind;
2383
2384 fn from_str(s: &str) -> Result<Self, Self::Err> {
2385 MousePointer::try_from(s)
2386 }
2387}
2388
2389impl Display for MousePointer {
2390 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2391 let text = match self {
2392 MousePointer::Default => "Default",
2393 MousePointer::Arrow => "Arrow",
2394 MousePointer::Cross => "Cross",
2395 MousePointer::IBeam => "IBeam",
2396 MousePointer::Icon => "Icon",
2397 MousePointer::Size => "Size",
2398 MousePointer::SizeNESW => "SizeNESW",
2399 MousePointer::SizeNS => "SizeNS",
2400 MousePointer::SizeNWSE => "SizeNWSE",
2401 MousePointer::SizeWE => "SizeWE",
2402 MousePointer::UpArrow => "UpArrow",
2403 MousePointer::Hourglass => "Hourglass",
2404 MousePointer::NoDrop => "NoDrop",
2405 MousePointer::ArrowHourglass => "ArrowHourglass",
2406 MousePointer::ArrowQuestion => "ArrowQuestion",
2407 MousePointer::SizeAll => "SizeAll",
2408 MousePointer::Custom => "Custom",
2409 };
2410 write!(f, "{text}")
2411 }
2412}
2413
2414#[derive(
2416 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2417)]
2418#[repr(i32)]
2419pub enum OLEDragMode {
2420 #[default]
2424 Manual = 0,
2425 Automatic = 1,
2427}
2428
2429impl TryFrom<&str> for OLEDragMode {
2430 type Error = ErrorKind;
2431
2432 fn try_from(value: &str) -> Result<Self, Self::Error> {
2433 match value {
2434 "0" => Ok(OLEDragMode::Manual),
2435 "1" => Ok(OLEDragMode::Automatic),
2436 _ => Err(ErrorKind::Form(FormError::InvalidOLEDragMode {
2437 value: value.to_string(),
2438 })),
2439 }
2440 }
2441}
2442
2443impl FromStr for OLEDragMode {
2444 type Err = ErrorKind;
2445
2446 fn from_str(s: &str) -> Result<Self, Self::Err> {
2447 OLEDragMode::try_from(s)
2448 }
2449}
2450
2451impl Display for OLEDragMode {
2452 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2453 let text = match self {
2454 OLEDragMode::Manual => "Manual",
2455 OLEDragMode::Automatic => "Automatic",
2456 };
2457 write!(f, "{text}")
2458 }
2459}
2460
2461#[derive(
2463 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2464)]
2465#[repr(i32)]
2466pub enum OLEDropMode {
2467 #[default]
2471 None = 0,
2472 Manual = 1,
2474}
2475
2476impl TryFrom<&str> for OLEDropMode {
2477 type Error = ErrorKind;
2478
2479 fn try_from(value: &str) -> Result<Self, Self::Error> {
2480 match value {
2481 "0" => Ok(OLEDropMode::None),
2482 "1" => Ok(OLEDropMode::Manual),
2483 _ => Err(ErrorKind::Form(FormError::InvalidOLEDropMode {
2484 value: value.to_string(),
2485 })),
2486 }
2487 }
2488}
2489
2490impl FromStr for OLEDropMode {
2491 type Err = ErrorKind;
2492
2493 fn from_str(s: &str) -> Result<Self, Self::Err> {
2494 OLEDropMode::try_from(s)
2495 }
2496}
2497
2498impl Display for OLEDropMode {
2499 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2500 let text = match self {
2501 OLEDropMode::None => "None",
2502 OLEDropMode::Manual => "Manual",
2503 };
2504 write!(f, "{text}")
2505 }
2506}
2507
2508#[derive(
2511 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2512)]
2513#[repr(i32)]
2514pub enum ClipControls {
2515 Unbounded = 0,
2517 #[default]
2521 Clipped = 1,
2522}
2523
2524impl TryFrom<&str> for ClipControls {
2525 type Error = ErrorKind;
2526
2527 fn try_from(value: &str) -> Result<Self, Self::Error> {
2528 match value {
2529 "0" => Ok(ClipControls::Unbounded),
2530 "1" => Ok(ClipControls::Clipped),
2531 _ => Err(ErrorKind::Form(FormError::InvalidClipControls {
2532 value: value.to_string(),
2533 })),
2534 }
2535 }
2536}
2537
2538impl FromStr for ClipControls {
2539 type Err = ErrorKind;
2540
2541 fn from_str(s: &str) -> Result<Self, Self::Err> {
2542 ClipControls::try_from(s)
2543 }
2544}
2545
2546impl Display for ClipControls {
2547 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2548 let text = match self {
2549 ClipControls::Unbounded => "Unbounded",
2550 ClipControls::Clipped => "Clipped",
2551 };
2552 write!(f, "{text}")
2553 }
2554}
2555
2556#[derive(
2559 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2560)]
2561#[repr(i32)]
2562pub enum Style {
2563 #[default]
2567 Standard = 0,
2568 Graphical = 1,
2570}
2571
2572impl TryFrom<&str> for Style {
2573 type Error = ErrorKind;
2574
2575 fn try_from(value: &str) -> Result<Self, Self::Error> {
2576 match value {
2577 "0" => Ok(Style::Standard),
2578 "1" => Ok(Style::Graphical),
2579 _ => Err(ErrorKind::Form(FormError::InvalidStyle {
2580 value: value.to_string(),
2581 })),
2582 }
2583 }
2584}
2585
2586impl FromStr for Style {
2587 type Err = ErrorKind;
2588
2589 fn from_str(s: &str) -> Result<Self, Self::Err> {
2590 Style::try_from(s)
2591 }
2592}
2593
2594impl Display for Style {
2595 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2596 let text = match self {
2597 Style::Standard => "Standard",
2598 Style::Graphical => "Graphical",
2599 };
2600 write!(f, "{text}")
2601 }
2602}
2603
2604#[derive(
2607 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2608)]
2609#[repr(i32)]
2610pub enum FillStyle {
2611 Solid = 0,
2613 #[default]
2617 Transparent = 1,
2618 HorizontalLine = 2,
2620 VerticalLine = 3,
2622 UpwardDiagonal = 4,
2624 DownwardDiagonal = 5,
2627 Cross = 6,
2629 DiagonalCross = 7,
2632}
2633
2634impl TryFrom<&str> for FillStyle {
2635 type Error = ErrorKind;
2636
2637 fn try_from(value: &str) -> Result<Self, Self::Error> {
2638 match value {
2639 "0" => Ok(FillStyle::Solid),
2640 "1" => Ok(FillStyle::Transparent),
2641 "2" => Ok(FillStyle::HorizontalLine),
2642 "3" => Ok(FillStyle::VerticalLine),
2643 "4" => Ok(FillStyle::UpwardDiagonal),
2644 "5" => Ok(FillStyle::DownwardDiagonal),
2645 "6" => Ok(FillStyle::Cross),
2646 "7" => Ok(FillStyle::DiagonalCross),
2647 _ => Err(ErrorKind::Form(FormError::InvalidFillStyle {
2648 value: value.to_string(),
2649 })),
2650 }
2651 }
2652}
2653
2654impl FromStr for FillStyle {
2655 type Err = ErrorKind;
2656
2657 fn from_str(s: &str) -> Result<Self, Self::Err> {
2658 FillStyle::try_from(s)
2659 }
2660}
2661
2662impl Display for FillStyle {
2663 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2664 let text = match self {
2665 FillStyle::Solid => "Solid",
2666 FillStyle::Transparent => "Transparent",
2667 FillStyle::HorizontalLine => "HorizontalLine",
2668 FillStyle::VerticalLine => "VerticalLine",
2669 FillStyle::UpwardDiagonal => "UpwardDiagonal",
2670 FillStyle::DownwardDiagonal => "DownwardDiagonal",
2671 FillStyle::Cross => "Cross",
2672 FillStyle::DiagonalCross => "DiagonalCross",
2673 };
2674 write!(f, "{text}")
2675 }
2676}
2677
2678#[derive(
2683 Debug, PartialEq, Eq, Clone, Serialize, TryFromPrimitive, Default, Copy, Hash, PartialOrd, Ord,
2684)]
2685#[repr(i32)]
2686pub enum LinkMode {
2687 #[default]
2691 None = 0,
2692 Automatic = 1,
2699 Manual = 2,
2706 Notify = 3,
2713}
2714
2715impl TryFrom<&str> for LinkMode {
2716 type Error = ErrorKind;
2717
2718 fn try_from(value: &str) -> Result<Self, Self::Error> {
2719 match value {
2720 "0" => Ok(LinkMode::None),
2721 "1" => Ok(LinkMode::Automatic),
2722 "2" => Ok(LinkMode::Manual),
2723 "3" => Ok(LinkMode::Notify),
2724 _ => Err(ErrorKind::Form(FormError::InvalidLinkMode {
2725 value: value.to_string(),
2726 })),
2727 }
2728 }
2729}
2730
2731impl FromStr for LinkMode {
2732 type Err = ErrorKind;
2733
2734 fn from_str(s: &str) -> Result<Self, Self::Err> {
2735 LinkMode::try_from(s)
2736 }
2737}
2738
2739impl Display for LinkMode {
2740 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2741 let text = match self {
2742 LinkMode::None => "None",
2743 LinkMode::Automatic => "Automatic",
2744 LinkMode::Manual => "Manual",
2745 LinkMode::Notify => "Notify",
2746 };
2747 write!(f, "{text}")
2748 }
2749}
2750
2751#[derive(
2755 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2756)]
2757#[repr(i32)]
2758pub enum MultiSelect {
2759 #[default]
2761 None = 0,
2762 Simple = 1,
2765 Extended = 2,
2768}
2769
2770impl TryFrom<&str> for MultiSelect {
2771 type Error = ErrorKind;
2772
2773 fn try_from(value: &str) -> Result<Self, Self::Error> {
2774 match value {
2775 "0" => Ok(MultiSelect::None),
2776 "1" => Ok(MultiSelect::Simple),
2777 "2" => Ok(MultiSelect::Extended),
2778 _ => Err(ErrorKind::Form(FormError::InvalidMultiSelect {
2779 value: value.to_string(),
2780 })),
2781 }
2782 }
2783}
2784
2785impl FromStr for MultiSelect {
2786 type Err = ErrorKind;
2787
2788 fn from_str(s: &str) -> Result<Self, Self::Err> {
2789 MultiSelect::try_from(s)
2790 }
2791}
2792
2793impl Display for MultiSelect {
2794 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2795 let text = match self {
2796 MultiSelect::None => "None",
2797 MultiSelect::Simple => "Simple",
2798 MultiSelect::Extended => "Extended",
2799 };
2800 write!(f, "{text}")
2801 }
2802}
2803
2804#[derive(
2809 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2810)]
2811#[repr(i32)]
2812pub enum ScaleMode {
2813 User = 0,
2815 #[default]
2817 Twip = 1,
2818 Point = 2,
2820 Pixel = 3,
2822 Character = 4,
2824 Inches = 5,
2826 Millimeter = 6,
2828 Centimeter = 7,
2830 HiMetric = 8,
2832 ContainerPosition = 9,
2834 ContainerSize = 10,
2836}
2837
2838impl FromStr for ScaleMode {
2839 type Err = ErrorKind;
2840
2841 fn from_str(s: &str) -> Result<Self, Self::Err> {
2842 ScaleMode::try_from(s)
2843 }
2844}
2845
2846impl TryFrom<&str> for ScaleMode {
2847 type Error = ErrorKind;
2848
2849 fn try_from(value: &str) -> Result<Self, Self::Error> {
2850 match value {
2851 "0" => Ok(ScaleMode::User),
2852 "1" => Ok(ScaleMode::Twip),
2853 "2" => Ok(ScaleMode::Point),
2854 "3" => Ok(ScaleMode::Pixel),
2855 "4" => Ok(ScaleMode::Character),
2856 "5" => Ok(ScaleMode::Inches),
2857 "6" => Ok(ScaleMode::Millimeter),
2858 "7" => Ok(ScaleMode::Centimeter),
2859 "8" => Ok(ScaleMode::HiMetric),
2860 "9" => Ok(ScaleMode::ContainerPosition),
2861 "10" => Ok(ScaleMode::ContainerSize),
2862 _ => Err(ErrorKind::Form(FormError::InvalidScaleMode {
2863 value: value.to_string(),
2864 })),
2865 }
2866 }
2867}
2868
2869impl Display for ScaleMode {
2870 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2871 let text = match self {
2872 ScaleMode::User => "User",
2873 ScaleMode::Twip => "Twip",
2874 ScaleMode::Point => "Point",
2875 ScaleMode::Pixel => "Pixel",
2876 ScaleMode::Character => "Character",
2877 ScaleMode::Inches => "Inches",
2878 ScaleMode::Millimeter => "Millimeter",
2879 ScaleMode::Centimeter => "Centimeter",
2880 ScaleMode::HiMetric => "HiMetric",
2881 ScaleMode::ContainerPosition => "ContainerPosition",
2882 ScaleMode::ContainerSize => "ContainerSize",
2883 };
2884 write!(f, "{text}")
2885 }
2886}
2887
2888#[derive(
2893 Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive, Copy, Hash, PartialOrd, Ord,
2894)]
2895#[repr(i32)]
2896pub enum SizeMode {
2897 #[default]
2904 Clip = 0,
2905 Stretch = 1,
2907 AutoSize = 2,
2909 Zoom = 3,
2911}
2912
2913impl TryFrom<&str> for SizeMode {
2914 type Error = ErrorKind;
2915
2916 fn try_from(value: &str) -> Result<Self, Self::Error> {
2917 match value {
2918 "0" => Ok(SizeMode::Clip),
2919 "1" => Ok(SizeMode::Stretch),
2920 "2" => Ok(SizeMode::AutoSize),
2921 "3" => Ok(SizeMode::Zoom),
2922 _ => Err(ErrorKind::Form(FormError::InvalidSizeMode {
2923 value: value.to_string(),
2924 })),
2925 }
2926 }
2927}
2928
2929impl FromStr for SizeMode {
2930 type Err = ErrorKind;
2931
2932 fn from_str(s: &str) -> Result<Self, Self::Err> {
2933 SizeMode::try_from(s)
2934 }
2935}
2936
2937impl Display for SizeMode {
2938 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2939 let text = match self {
2940 SizeMode::Clip => "Clip",
2941 SizeMode::Stretch => "Stretch",
2942 SizeMode::AutoSize => "AutoSize",
2943 SizeMode::Zoom => "Zoom",
2944 };
2945 write!(f, "{text}")
2946 }
2947}