vb6parse/language/controls/
mod.rs

1pub mod checkbox;
2pub mod combobox;
3pub mod commandbutton;
4pub mod custom;
5pub mod data;
6pub mod dirlistbox;
7pub mod drivelistbox;
8pub mod filelistbox;
9pub mod form;
10pub mod frame;
11pub mod image;
12pub mod label;
13pub mod line;
14pub mod listbox;
15pub mod mdiform;
16pub mod menus;
17pub mod ole;
18pub mod optionbutton;
19pub mod picturebox;
20pub mod scrollbars;
21pub mod shape;
22pub mod textbox;
23pub mod timer;
24
25use bstr::BString;
26use num_enum::TryFromPrimitive;
27use serde::Serialize;
28
29use crate::parsers::form::VB6PropertyGroup;
30
31use crate::language::controls::{
32    checkbox::CheckBoxProperties,
33    combobox::ComboBoxProperties,
34    commandbutton::CommandButtonProperties,
35    custom::CustomControlProperties,
36    data::DataProperties,
37    dirlistbox::DirListBoxProperties,
38    drivelistbox::DriveListBoxProperties,
39    filelistbox::FileListBoxProperties,
40    form::FormProperties,
41    frame::FrameProperties,
42    image::ImageProperties,
43    label::LabelProperties,
44    line::LineProperties,
45    listbox::ListBoxProperties,
46    mdiform::MDIFormProperties,
47    menus::{MenuProperties, VB6MenuControl},
48    ole::OLEProperties,
49    optionbutton::OptionButtonProperties,
50    picturebox::PictureBoxProperties,
51    scrollbars::ScrollBarProperties,
52    shape::ShapeProperties,
53    textbox::TextBoxProperties,
54    timer::TimerProperties,
55};
56
57#[derive(Debug, PartialEq, Eq, Clone, serde::Serialize, Default, TryFromPrimitive)]
58#[repr(i32)]
59pub enum FormLinkMode {
60    #[default]
61    None = 0,
62    Source = 1,
63}
64
65#[derive(Debug, PartialEq, Eq, Clone, serde::Serialize, Default, TryFromPrimitive)]
66#[repr(i32)]
67pub enum WindowState {
68    #[default]
69    Normal = 0,
70    Minimized = 1,
71    Maximized = 2,
72}
73
74#[derive(Debug, PartialEq, Eq, Clone, serde::Serialize, Default)]
75pub enum StartUpPosition {
76    /// 0
77    Manual {
78        client_height: i32,
79        client_width: i32,
80        client_top: i32,
81        client_left: i32,
82    },
83    /// 1
84    CenterOwner,
85    /// 2
86    CenterScreen,
87    #[default]
88    /// 3
89    WindowsDefault,
90}
91
92/// Represents a VB6 control.
93#[derive(Debug, PartialEq, Clone, Serialize)]
94pub struct VB6Control {
95    pub name: BString,
96    pub tag: BString,
97    pub index: i32,
98    pub kind: VB6ControlKind,
99}
100
101/// The `VB6ControlKind` determines the specific kind of control that the `VB6Control` represents.
102///
103/// Each variant contains the properties that are specific to that kind of control.
104#[derive(Debug, PartialEq, Clone, Serialize)]
105pub enum VB6ControlKind {
106    CommandButton {
107        properties: CommandButtonProperties,
108    },
109    Data {
110        properties: DataProperties,
111    },
112    TextBox {
113        properties: TextBoxProperties,
114    },
115    CheckBox {
116        properties: CheckBoxProperties,
117    },
118    Line {
119        properties: LineProperties,
120    },
121    Shape {
122        properties: ShapeProperties,
123    },
124    ListBox {
125        properties: ListBoxProperties,
126    },
127    Timer {
128        properties: TimerProperties,
129    },
130    Label {
131        properties: LabelProperties,
132    },
133    Frame {
134        properties: FrameProperties,
135        controls: Vec<VB6Control>,
136    },
137    PictureBox {
138        properties: PictureBoxProperties,
139    },
140    FileListBox {
141        properties: FileListBoxProperties,
142    },
143    DriveListBox {
144        properties: DriveListBoxProperties,
145    },
146    DirListBox {
147        properties: DirListBoxProperties,
148    },
149    Ole {
150        properties: OLEProperties,
151    },
152    OptionButton {
153        properties: OptionButtonProperties,
154    },
155    Image {
156        properties: ImageProperties,
157    },
158    ComboBox {
159        properties: ComboBoxProperties,
160    },
161    HScrollBar {
162        properties: ScrollBarProperties,
163    },
164    VScrollBar {
165        properties: ScrollBarProperties,
166    },
167    Menu {
168        properties: MenuProperties,
169        sub_menus: Vec<VB6MenuControl>,
170    },
171    Form {
172        properties: FormProperties,
173        controls: Vec<VB6Control>,
174        menus: Vec<VB6MenuControl>,
175    },
176    MDIForm {
177        properties: MDIFormProperties,
178        controls: Vec<VB6Control>,
179        menus: Vec<VB6MenuControl>,
180    },
181    Custom {
182        properties: CustomControlProperties,
183        property_groups: Vec<VB6PropertyGroup>,
184    },
185}
186
187impl VB6ControlKind {
188    #[must_use]
189    pub fn is_menu(&self) -> bool {
190        matches!(self, VB6ControlKind::Menu { .. })
191    }
192}
193
194/// Determines which side of the parent control to dock this control to.
195#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
196#[repr(i32)]
197pub enum Align {
198    /// The control is not docked to any side of the parent control.
199    /// This is the default setting.
200    #[default]
201    None = 0,
202    /// The control is docked to the top of the parent control.
203    Top = 1,
204    /// The control is docked to the bottom of the parent control.
205    Bottom = 2,
206    /// The control is docked to the left of the parent control.
207    Left = 3,
208    /// The control is docked to the right of the parent control.
209    Right = 4,
210}
211
212#[derive(Debug, PartialEq, Eq, Clone, Serialize, TryFromPrimitive, Default)]
213#[repr(i32)]
214pub enum JustifyAlignment {
215    #[default]
216    LeftJustify = 0,
217    RightJustify = 1,
218}
219
220#[derive(Debug, PartialEq, Eq, Clone, Serialize, TryFromPrimitive, Default)]
221#[repr(i32)]
222pub enum Alignment {
223    #[default]
224    LeftJustify = 0,
225    RightJustify = 1,
226    Center = 2,
227}
228
229/// The back style determines whether the background of a control is opaque or transparent.
230#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
231#[repr(i32)]
232pub enum BackStyle {
233    /// The background of the control is transparent.
234    Transparent = 0,
235    /// The background of the control is opaque. (default)
236    #[default]
237    Opaque = 1,
238}
239
240/// The appearance determines whether or not a control is painted at run time
241/// with 3D effects.
242#[derive(Debug, PartialEq, Eq, Clone, Serialize, TryFromPrimitive, Default)]
243#[repr(i32)]
244pub enum Appearance {
245    /// The control is painted with a flat style.
246    Flat = 0,
247    /// The control is painted with a 3D style.
248    #[default]
249    ThreeD = 1,
250}
251
252/// The border style determines the appearance of the border of a control.
253#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
254#[repr(i32)]
255pub enum BorderStyle {
256    /// The control has no border.
257    None = 0,
258    /// The control has a single-line border.
259    #[default]
260    FixedSingle = 1,
261}
262
263/// Determines the style of drag and drop operations.
264#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
265#[repr(i32)]
266pub enum DragMode {
267    /// The control does not support drag and drop operations until
268    /// the program manually initiates the drag operation.
269    #[default]
270    Manual = 0,
271    /// The control automatically initiates a drag operation when the
272    /// user presses the mouse button on the control.
273    Automatic = 1,
274}
275
276/// Specifies how the pen (the color used in drawing) interacts with the
277/// background.
278#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
279#[repr(i32)]
280pub enum DrawMode {
281    /// Black pen color is applied over the background.
282    Blackness = 1,
283    /// Inversion is applied after the combination of the pen and the background color.
284    NotMergePen = 2,
285    /// The combination of the colors common to the background color and the inverse of the pen.
286    MaskNotPen = 3,
287    /// Inversion is applied to the pen color.
288    NotCopyPen = 4,
289    /// The combination of the colors common to the pen and the inverse of the background color.
290    MaskPenNot = 5,
291    /// Inversion is applied to the background color.
292    Invert = 6,
293    /// The combination of the colors common to the pen and the background color, but not in both (ie, XOR).
294    XorPen = 7,
295    /// Inversion is applied to the combination of the colors common to both the pen and the background color.
296    NotMaskPen = 8,
297    /// The combination of the colors common to the pen and the background color.
298    MaskPen = 9,
299    /// Inversion of the combinationfs of the colors in the pen and the background color but not in both (ie, NXOR).
300    NotXorPen = 10,
301    /// No operation is performed. The output remains unchanged. In effect, this turns drawing off (No Operation).
302    Nop = 11,
303    /// The combinaton of the display color and the inverse of the pen color.
304    MergeNotPen = 12,
305    /// The color specified by the `ForeColor` property is applied over the background.
306    /// This is the default setting.
307    #[default]
308    CopyPen = 13,
309    /// The combination of the pen color and inverse of the display color.
310    MergePenNot = 14,
311    /// the combination of the pen color and the display color.
312    MergePen = 15,
313    /// White pen color is applied over the background.
314    Whiteness = 16,
315}
316
317/// Determines the line style of any drawing from any graphic method applied by the control.
318#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
319#[repr(i32)]
320pub enum DrawStyle {
321    /// A solid line. This is the default.
322    #[default]
323    Solid = 0,
324    /// A dashed line.
325    Dash = 1,
326    /// A dotted line.
327    Dot = 2,
328    /// A line that alternates between dashes and dots.
329    DashDot = 3,
330    /// A line that alternates between dashes and double dots.
331    DashDotDot = 4,
332    /// Invisible line, transparent interior.
333    Transparent = 5,
334    /// Invisible line, solid interior.
335    InsideSolid = 6,
336}
337
338/// Determines the appearance of the mouse pointer when it is over the control.
339#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
340#[repr(i32)]
341pub enum MousePointer {
342    /// Standard pointer. the image is determined by the object (default).
343    #[default]
344    Default = 0,
345    /// Arrow pointer.
346    Arrow = 1,
347    /// Cross-hair pointer.
348    Cross = 2,
349    /// I-beam pointer.
350    IBeam = 3,
351    /// Icon pointer. The image is determined by the `MouseIcon` property.
352    /// If the `MouseIcon` property is not set, the behavior is the same as the Default setting.
353    /// This is a duplicate of Custom (99).
354    Icon = 4,
355    /// Size all cursor (arrows pointing north, south, east, and west).
356    /// This cursor is used to indicate that the control can be resized in any direction.
357    Size = 5,
358    /// Double arrow pointing northeast and southwest.
359    SizeNESW = 6,
360    /// Double arrow pointing north and south.
361    SizeNS = 7,
362    /// Double arrow pointing northwest and southeast.
363    SizeNWSE = 8,
364    /// Double arrow pointing west and east.
365    SizeWE = 9,
366    /// Up arrow.
367    UpArrow = 10,
368    /// Hourglass or wait cursor.
369    Hourglass = 11,
370    /// "Not" symbol (circle with a diagonal line) on top of the object being dragged.
371    /// Indicates an invalid drop target.
372    NoDrop = 12,
373    // Arrow with an hourglass.
374    ArrowHourglass = 13,
375    /// Arrow with a question mark.
376    ArrowQuestion = 14,
377    /// Size all cursor (arrows pointing north, south, east, and west).
378    /// This cursor is used to indicate that the control can be resized in any direction.
379    /// Duplicate of Size (5).
380    SizeAll = 15,
381    /// Uses the icon specified by the `MouseIcon` property.
382    /// If the `MouseIcon` property is not set, the behavior is the same as the Default setting.
383    /// This is a duplicate of Icon (4).
384    Custom = 99,
385}
386
387/// Determines the style of drag and drop operations.
388#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
389#[repr(i32)]
390pub enum OLEDragMode {
391    /// The programmer handles all OLE drag/drop events manually. (default).
392    #[default]
393    Manual = 0,
394    /// The control automatically handles all OLE drag/drop events.
395    Automatic = 1,
396}
397
398/// Determines the style of drop operations.
399#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
400#[repr(i32)]
401pub enum OLEDropMode {
402    /// The control does not accept any OLE drop operations.
403    #[default]
404    None = 0,
405    /// The programmer handles all OLE drop events manually.
406    Manual = 1,
407}
408
409#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
410#[repr(i32)]
411pub enum ClipControls {
412    /// The controls are not clipped to the bounds of the parent control.
413    False = 0,
414    /// The controls are clipped to the bounds of the parent control.
415    #[default]
416    True = 1,
417}
418
419/// Determines if the control uses standard styling or if it uses graphical styling from it's
420/// picture properties.
421#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
422#[repr(i32)]
423pub enum Style {
424    /// The control uses standard styling.
425    #[default]
426    Standard = 0,
427    /// The control uses graphical styling using its appropriate picture properties.
428    Graphical = 1,
429}
430
431#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
432#[repr(i32)]
433pub enum FillStyle {
434    Solid = 0,
435    #[default]
436    Transparent = 1,
437    HorizontalLine = 2,
438    VerticalLine = 3,
439    UpwardDiagonal = 4,
440    DownwardDiagonal = 5,
441    Cross = 6,
442    DiagonalCross = 7,
443}
444
445#[derive(Debug, PartialEq, Eq, Clone, Serialize, TryFromPrimitive, Default)]
446#[repr(i32)]
447pub enum LinkMode {
448    #[default]
449    None = 0,
450    Automatic = 1,
451    Manual = 2,
452    Notify = 3,
453}
454
455#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
456#[repr(i32)]
457pub enum MultiSelect {
458    #[default]
459    None = 0,
460    Simple = 1,
461    Extended = 2,
462}
463
464#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
465#[repr(i32)]
466pub enum ScaleMode {
467    User = 0,
468    #[default]
469    Twip = 1,
470    Point = 2,
471    Pixel = 3,
472    Character = 4,
473    Inches = 5,
474    Millimeter = 6,
475    Centimeter = 7,
476}
477
478#[derive(Debug, PartialEq, Eq, Clone, Serialize, Default, TryFromPrimitive)]
479#[repr(i32)]
480pub enum SizeMode {
481    #[default]
482    Clip = 0,
483    Stretch = 1,
484    AutoSize = 2,
485    Zoom = 3,
486}