sap_scripting/
types.rs

1use com_shim::{HasIDispatch, IDispatchExt, VariantTypeExt, com_shim};
2use windows::{Win32::System::Com::*, Win32::System::Variant::*, core::*};
3
4/// A wrapper over the SAP scripting engine, equivalent to CSapROTWrapper.
5pub struct SAPWrapper {
6    inner: IDispatch,
7}
8
9impl SAPWrapper {
10    pub(crate) fn new() -> crate::Result<Self> {
11        unsafe {
12            let clsid: GUID = CLSIDFromProgID(w!("SapROTWr.SapROTWrapper"))?;
13            let p_clsid: *const GUID = &clsid;
14            log::debug!("CSapROTWrapper CLSID: {:?}", clsid);
15
16            let dispatch: IDispatch =
17                CoCreateInstance(p_clsid, None, CLSCTX_LOCAL_SERVER | CLSCTX_INPROC_SERVER)?;
18            Ok(SAPWrapper { inner: dispatch })
19        }
20    }
21
22    /// Get the Scripting Engine object from this wrapper.
23    pub fn scripting_engine(&self) -> crate::Result<GuiApplication> {
24        log::debug!("Getting UI ROT entry...");
25        let result = self.inner.call(
26            "GetROTEntry",
27            vec![VARIANT::variant_from("SAPGUI".to_string())],
28        )?;
29
30        let sap_gui: &IDispatch = result.variant_into()?;
31
32        log::debug!("Getting scripting engine.");
33        let scripting_engine = sap_gui.call("GetScriptingEngine", vec![])?;
34
35        Ok(GuiApplication {
36            inner: <com_shim::VARIANT as VariantTypeExt<'_, &IDispatch>>::variant_into(
37                &scripting_engine,
38            )?
39            .clone(),
40        })
41    }
42}
43
44pub trait HasSAPType {
45    fn sap_type() -> &'static str;
46    fn sap_subtype() -> Option<&'static str>;
47}
48
49macro_rules! sap_type {
50    ($tgt: ident, $type: expr) => {
51        impl HasSAPType for $tgt {
52            fn sap_type() -> &'static str {
53                $type
54            }
55            fn sap_subtype() -> Option<&'static str> {
56                None
57            }
58        }
59    };
60    ($tgt: ident, $type: expr, $subtype: expr) => {
61        impl HasSAPType for $tgt {
62            fn sap_type() -> &'static str {
63                $type
64            }
65            fn sap_subtype() -> Option<&'static str> {
66                Some($subtype)
67            }
68        }
69    };
70}
71
72impl GuiComponent {
73    pub fn cast<T: HasIDispatch + HasSAPType + From<IDispatch>>(&self) -> Option<T> {
74        if let Ok(mut kind) = self.r_type() {
75            log::debug!("Converting GuiComponent to {kind}.");
76            if kind.as_str() == "GuiShell" {
77                log::debug!("Kind is shell, checking subkind.");
78                if let Ok(sub_kind) = (GuiShell {
79                    inner: self.inner.clone(),
80                })
81                .sub_type()
82                {
83                    // use subkind if a GuiShell
84                    log::debug!("Subkind is {sub_kind}");
85                    kind = sub_kind;
86                }
87            }
88            let target_kind = T::sap_subtype().unwrap_or(T::sap_type());
89            if kind == target_kind {
90                Some(T::from(self.inner.clone()))
91            } else {
92                None
93            }
94        } else {
95            None
96        }
97    }
98}
99
100com_shim! {
101    struct GuiApplication: GuiContainer + GuiComponent {
102        // TODO ActiveSession: Object,
103        mut AllowSystemMessages: bool,
104        mut ButtonbarVisible: bool,
105        Children: GuiComponentCollection,
106        ConnectionErrorText: String,
107        Connections: GuiComponentCollection,
108        mut HistoryEnabled: bool,
109        MajorVersion: i32,
110        MinorVersion: i32,
111        NewVisualDesign: bool,
112        Patchlevel: i32,
113        Revision: i32,
114        mut StatusbarVisible: bool,
115        mut TitlebarVisible: bool,
116        mut ToolbarVisible: bool,
117        Utils: GuiUtils,
118
119        fn AddHistoryEntry(String, String) -> bool,
120        fn CreateGuiCollection() -> GuiCollection,
121        fn DropHistory() -> bool,
122        fn Ignore(i16),
123        fn OpenConnection(String) -> GuiComponent,
124        fn OpenConnectionByConnectionString(String) -> GuiComponent,
125    }
126}
127sap_type!(GuiApplication, "GuiApplication");
128
129com_shim! {
130    struct GuiBarChart: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent + GuiShell {
131        ChartCount: i32,
132
133        fn BarCount(i32) -> i32,
134        fn GetBarContent(i32, i32, i32) -> String,
135        fn GetGridLineContent(i32, i32, i32) -> String,
136        fn GridCount(i32) -> i32,
137        fn LinkCount(i32) -> i32,
138        fn SendData(String),
139    }
140}
141sap_type!(GuiBarChart, "GuiShell", "BarChart");
142
143com_shim! {
144    struct GuiBox: GuiVComponent + GuiComponent {
145        CharHeight: i32,
146        CharLeft: i32,
147        CharTop: i32,
148        CharWidth: i32,
149    }
150}
151sap_type!(GuiBox, "GuiBox");
152
153com_shim! {
154    struct GuiButton: GuiVComponent + GuiComponent {
155        Emphasized: bool,
156        LeftLabel: GuiComponent,
157        RightLabel: GuiComponent,
158
159        fn Press(),
160    }
161}
162sap_type!(GuiButton, "GuiButton");
163
164com_shim! {
165    struct GuiCalendar: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent + GuiShell {
166        endSelection: String,
167        mut FirstVisibleDate: String,
168        mut FocusDate: String,
169        FocusedElement: i32,
170        horizontal: bool,
171        mut LastVisibleDate: String,
172        mut SelectionInterval: String,
173        startSelection: String,
174        Today: String,
175
176        fn ContextMenu(i32, i32, i32, String, String),
177        fn CreateDate(i32, i32, i32),
178        fn GetColor(String) -> i32,
179        fn GetColorInfo(i32) -> String,
180        fn GetDateTooltip(String) -> String,
181        fn GetDay(String) -> i32,
182        fn GetMonth(String) -> i32,
183        fn GetWeekday(String) -> String,
184        fn GetWeekNumber(String) -> i32,
185        fn GetYear(String) -> i32,
186        fn IsWeekend(String) -> bool,
187        fn SelectMonth(i32, i32),
188        fn SelectRange(String, String),
189        fn SelectWeek(i32, i32),
190    }
191}
192sap_type!(GuiCalendar, "GuiShell", "Calendar");
193
194com_shim! {
195    struct GuiChart: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent + GuiShell {
196        fn ValueChange(i32, i32, String, String, bool, String, String, i32),
197    }
198}
199sap_type!(GuiChart, "GuiShell", "Chart");
200
201com_shim! {
202    struct GuiCheckBox: GuiVComponent + GuiComponent {
203        ColorIndex: i32,
204        ColorIntensified: i32,
205        ColorInverse: bool,
206        Flushing: bool,
207        IsLeftLabel: bool,
208        IsListElement: bool,
209        IsRightLabel: bool,
210        LeftLabel: GuiComponent,
211        RightLabel: GuiComponent,
212        RowText: String,
213        mut Selected: bool,
214
215        fn GetListProperty(String) -> String,
216        fn GetListPropertyNonRec(String) -> String,
217    }
218}
219sap_type!(GuiCheckBox, "GuiCheckBox");
220
221com_shim! {
222    struct GuiCollection {
223        Count: i32,
224        Length: i32,
225        r#Type: String,
226        TypeAsNumber: i32,
227
228        // TODO fn Add(&IDispatch),
229        fn ElementAt(i32) -> GuiComponent,
230    }
231}
232
233com_shim! {
234    struct GuiColorSelector: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent + GuiShell {
235        fn ChangeSelection(i16),
236    }
237}
238sap_type!(GuiColorSelector, "GuiShell", "ColorSelector");
239
240com_shim! {
241    struct GuiComboBox: GuiVComponent + GuiComponent {
242        CharHeight: i32,
243        CharLeft: i32,
244        CharTop: i32,
245        CharWidth: i32,
246        CurListBoxEntry: GuiComponent,
247        Entries: GuiCollection,
248        Flushing: bool,
249        Highlighted: bool,
250        IsLeftLabel: bool,
251        IsListBoxActive: bool,
252        IsRightLabel: bool,
253        mut Key: String,
254        LeftLabel: GuiComponent,
255        Required: bool,
256        RightLabel: GuiComponent,
257        ShowKey: bool,
258        Text: String,
259        mut Value: String,
260
261        fn SetKeySpace(),
262    }
263}
264sap_type!(GuiComboBox, "GuiComboBox");
265
266com_shim! {
267    struct GuiComboBoxControl: GuiVComponent + GuiVContainer + GuiComponent + GuiContainer + GuiShell {
268        CurListBoxEntry: GuiComponent,
269        Entries: GuiCollection,
270        IsListBoxActive: bool,
271        LabelText: String,
272        mut Selected: String,
273        Text: String,
274
275        fn FireSelected(),
276    }
277}
278sap_type!(GuiComboBoxControl, "GuiShell", "ComboBoxControl");
279
280com_shim! {
281    struct GuiComboBoxEntry {
282        Key: String,
283        Pos: i32,
284        Value: String,
285    }
286}
287sap_type!(GuiComboBoxEntry, "GuiComboBoxEntry");
288
289com_shim! {
290    struct GuiComponent {
291        ContainerType: bool,
292        Id: String,
293        Name: String,
294        r#Type: String,
295        TypeAsNumber: i32,
296    }
297}
298sap_type!(GuiComponent, "GuiComponent");
299
300com_shim! {
301    struct GuiComponentCollection {
302        Count: i32,
303        Length: i32,
304        r#Type: String,
305        TypeAsNumber: i32,
306
307        fn ElementAt(i32) -> GuiComponent,
308    }
309}
310
311com_shim! {
312    struct GuiConnection: GuiContainer + GuiComponent {
313        Children: GuiComponentCollection,
314        ConnectionString: String,
315        Description: String,
316        DisabledByServer: bool,
317        Sessions: GuiComponentCollection,
318
319        fn CloseConnection(),
320        fn CloseSession(String),
321    }
322}
323sap_type!(GuiConnection, "GuiConnection");
324
325com_shim! {
326    struct GuiContainer: GuiComponent {
327        Children: GuiComponentCollection,
328
329        fn FindById(String) -> GuiComponent,
330    }
331}
332sap_type!(GuiContainer, "GuiContainer");
333
334com_shim! {
335    struct GuiContainerShell: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent + GuiShell {
336        AccDescription: String,
337    }
338}
339sap_type!(GuiContainerShell, "GuiShell", "ContainerShell");
340
341com_shim! {
342    struct GuiCTextField: GuiTextField + GuiVComponent + GuiComponent { }
343}
344sap_type!(GuiCTextField, "GuiCTextField");
345
346com_shim! {
347    struct GuiCustomControl: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent {
348        CharHeight: i32,
349        CharLeft: i32,
350        CharTop: i32,
351        CharWidth: i32,
352    }
353}
354sap_type!(GuiCustomControl, "GuiCustomControl");
355
356com_shim! {
357    struct GuiDialogShell: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent {
358        Title: String,
359
360        fn Close(),
361    }
362}
363sap_type!(GuiDialogShell, "GuiDialogShell");
364
365com_shim! {
366    struct GuiDockShell: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent {
367        AccDescription: String,
368        DockerIsVertical: bool,
369        mut DockerPixelSize: i32,
370    }
371}
372
373com_shim! {
374    struct GuiEAIViewer2D: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent + GuiShell {
375        mut AnnoutationEnabled: i32,
376        mut AnnotationMode: i16,
377        mut RedliningStream: String,
378
379        fn annotationTextRequest(String),
380    }
381}
382sap_type!(GuiEAIViewer2D, "GuiShell", "EAIViewer2D");
383
384com_shim! {
385    struct GuiEAIViewer3D: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent + GuiShell { }
386}
387sap_type!(GuiEAIViewer3D, "GuiShell", "EAIViewer3D");
388
389com_shim! {
390    struct GuiFrameWindow: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent {
391        mut ElementVisualizationMode: bool,
392        GuiFocus: GuiComponent,
393        Handle: i32,
394        Iconic: bool,
395        SystemFocus: GuiComponent,
396        WorkingPaneHeight: i32,
397        WorkingPaneWidth: i32,
398
399        fn Close(),
400        fn CompBitmap(String, String) -> i32,
401        fn HardCopy(String, i16) -> String,
402        fn Iconify(),
403        fn IsVKeyAllowed(i16) -> bool,
404        fn JumpBackward(),
405        fn JumpForward(),
406        fn Maximize(),
407        fn Restore(),
408        fn SendVKey(i16),
409        fn ShowMessageBox(String, String, i32, i32) -> i32,
410        fn TabBackward(),
411        fn TabForward(),
412    }
413}
414sap_type!(GuiFrameWindow, "GuiFrameWindow");
415
416com_shim! {
417    struct GuiGOSShell: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent { }
418}
419sap_type!(GuiGOSShell, "GuiGOSShell");
420
421com_shim! {
422    struct GuiGraphAdapt: GuiVComponent + GuiVContainer + GuiContainer + GuiComponent + GuiShell { }
423}
424sap_type!(GuiGraphAdapt, "GuiShell", "GraphAdapt");
425
426com_shim! {
427    struct GuiGridView: GuiVComponent + GuiVContainer + GuiComponent + GuiContainer + GuiShell {
428        ColumnCount: i32,
429        // TODO mut ColumnOrder: Object,
430        mut CurrentCellColumn: String,
431        mut CurrentCellRow: i32,
432        mut FirstVisibleColumn: String,
433        mut FirstVisibleRow: i32,
434        FrozenColumnCount: i32,
435        RowCount: i32,
436        // TODO mut SelectedCells: Object,
437        // TODO mut SelectedColumns: Object,
438        mut SelectedRows: String,
439        SelectionMode: String,
440        Title: String,
441        ToolbarButtonCount: i32,
442        VisibleRowCount: i32,
443
444        fn ClearSelection(),
445        fn Click(i32, String),
446        fn ClickCurrentCell(),
447        fn ContextMenu(),
448        fn CurrentCellMoved(),
449        fn DeleteRows(String),
450        fn DeselectColumn(String),
451        fn DoubleClick(i32, String),
452        fn DoubleClickCurrentCell(),
453        fn DuplicateRows(String),
454        fn GetCellChangeable(i32, String) -> bool,
455        fn GetCellCheckBoxChecked(i32, String) -> bool,
456        fn GetCellColor(i32, String) -> i32,
457        fn GetCellHeight(i32, String) -> i32,
458        fn GetCellHotspotType(i32, String) -> String,
459        fn GetCellIcon(i32, String) -> String,
460        fn GetCellLeft(i32, String) -> i32,
461        fn GetCellListBoxCount(i32, String) -> i32,
462        fn GetCellListBoxCurIndex(i32, String) -> String,
463        fn GetCellMaxLength(i32, String) -> i32,
464        fn GetCellState(i32, String) -> String,
465        fn GetCellTooltip(i32, String) -> String,
466        fn GetCellTop(i32, String) -> i32,
467        fn GetCellType(i32, String) -> String,
468        fn GetCellValue(i32, String) -> String,
469        fn GetCellWidth(i32, String) -> i32,
470        fn GetColorInfo(i32) -> String,
471        fn GetColumnDataType(String) -> String,
472        fn GetColumnOperationType(String) -> String,
473        fn GetColumnPosition(String) -> i32,
474        fn GetColumnSortType(String) -> String,
475        // TODO fn GetColumnTitles(String) -> Object,
476        fn GetColumnTooltip(String) -> String,
477        fn GetColumnTotalType(String) -> String,
478        fn GetDisplayedColumnTitle(String) -> String,
479        fn GetRowTotalLevel(i32) -> i32,
480        fn GetSymbolInfo(String) -> String,
481        fn GetToolbarButtonChecked(i32) -> bool,
482        fn GetToolbarButtonEnabled(i32) -> bool,
483        fn GetToolbarButtonIcon(i32) -> String,
484        fn GetToolbarButtonId(i32) -> String,
485        fn GetToolbarButtonText(i32) -> String,
486        fn GetToolbarButtonTooltip(i32) -> String,
487        fn GetToolbarButtonType(i32) -> String,
488        fn GetToolbarFocusButton() -> i32,
489        fn HasCellF4Help(i32, String) -> bool,
490        fn HistoryCurEntry(i32, String) -> String,
491        fn HistoryCurIndex(i32, String) -> i32,
492        fn HistoryIsActive(i32, String) -> bool,
493        fn HistoryList(i32, String) -> GuiCollection,
494        fn InsertRows(String),
495        fn IsCellHotspot(i32, String) -> bool,
496        fn IsCellSymbol(i32, String) -> bool,
497        fn IsCellTotalExpander(i32, String) -> bool,
498        fn IsColumnFiltered(String) -> bool,
499        fn IsColumnKey(String) -> bool,
500        fn IsTotalRowExpanded(i32) -> bool,
501        fn ModifyCell(i32, String, String),
502        fn ModifyCheckBox(i32, String, bool),
503        fn MoveRows(i32, i32, i32),
504        fn PressButton(i32, String),
505        fn PressButtonCurrentCell(),
506        fn PressColumnHeader(String),
507        fn PressEnter(),
508        fn PressF1(),
509        fn PressF4(),
510        fn PressToolbarButton(String),
511        fn PressToolbarContextButton(String),
512        fn PressTotalRow(i32, String),
513        fn PressTotalRowCurrentCell(),
514        fn SelectAll(),
515        fn SelectColumn(String),
516        fn SelectionChanged(),
517        fn SelectToolbarMenuItem(String),
518        fn SetColumnWidth(String, i32),
519        fn SetCurrentCell(i32, String),
520        fn TriggerModified(),
521    }
522}
523sap_type!(GuiGridView, "GuiShell", "GridView");
524
525com_shim! {
526    struct GuiHTMLViewer: GuiVComponent + GuiVContainer + GuiComponent + GuiContainer + GuiShell {
527        // TODO BrowserHandle: Object,
528        DocumentComplete: i32,
529
530        fn ContextMenu(),
531        fn GetBrowerControlType() -> i32,
532        fn SapEvent(String, String, String),
533    }
534}
535sap_type!(GuiHTMLViewer, "GuiShell", "HTMLViewer");
536
537com_shim! {
538    struct GuiInputFieldControl: GuiVComponent + GuiVContainer + GuiComponent + GuiContainer + GuiShell {
539        ButtonTooltip: String,
540        FindButtonActivated: bool,
541        HistoryCurEntry: String,
542        HistoryCurIndex: i32,
543        HistoryIsActive: bool,
544        HistoryList: GuiCollection,
545        LabelText: String,
546        PromptText: String,
547
548        fn Submit(),
549    }
550}
551sap_type!(GuiInputFieldControl, "GuiShell", "InputFieldControl");
552
553com_shim! {
554    struct GuiLabel: GuiVComponent + GuiComponent {
555        mut CaretPosition: i32,
556        CharHeight: i32,
557        CharLeft: i32,
558        CharTop: i32,
559        CharWidth: i32,
560        ColorIndex: i32,
561        ColorIntensified: bool,
562        ColorInverse: bool,
563        DisplayedText: String,
564        Highlighted: String,
565        IsHotspot: String,
566        IsLeftLabel: bool,
567        IsListElement: bool,
568        IsRightLabel: bool,
569        MaxLength: i32,
570        Numerical: bool,
571        RowText: String,
572
573        fn GetListProperty(String) -> String,
574        fn GetListPropertyNonRec(String) -> String,
575    }
576}
577sap_type!(GuiLabel, "GuiLabel");
578
579com_shim! {
580    struct GuiMainWindow: GuiFrameWindow + GuiVComponent + GuiVContainer + GuiContainer + GuiComponent {
581        mut ButtonbarVisible: bool,
582        mut StatusbarVisible: bool,
583        mut TitlebarVisible: bool,
584        mut ToolbarVisible: bool,
585
586        fn ResizeWorkingPane(i32, i32, bool),
587        fn ResizeWorkingPaneEx(i32, i32, bool),
588    }
589}
590sap_type!(GuiMainWindow, "GuiMainWindow");
591
592com_shim! {
593    struct GuiMap: GuiVComponent + GuiVContainer + GuiComponent + GuiContainer + GuiShell { }
594}
595sap_type!(GuiMap, "GuiShell", "Map");
596
597com_shim! {
598    struct GuiMenu: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent {
599        fn Select(),
600    }
601}
602sap_type!(GuiMenu, "GuiMenu");
603
604com_shim! {
605    struct GuiMenubar: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent { }
606}
607sap_type!(GuiMenubar, "GuiMenubar");
608
609com_shim! {
610    struct GuiMessageWindow: GuiVComponent + GuiComponent {
611        FocusedButton: i32,
612        HelpButtonHelpText: String,
613        HelpButtonText: String,
614        MessageText: String,
615        MessageType: i32,
616        OKButtonHelpText: String,
617        OKButtonText: String,
618        ScreenLeft: i32,
619        ScreenTop: i32,
620        Visible: bool,
621    }
622}
623
624com_shim! {
625    struct GuiModalWindow: GuiFrameWindow + GuiVComponent + GuiVContainer + GuiComponent + GuiContainer {
626        fn IsPopupDialog() -> bool,
627        fn PopupDialogText() -> String,
628    }
629}
630sap_type!(GuiModalWindow, "GuiModalWindow");
631
632com_shim! {
633    struct GuiNetChart: GuiVComponent + GuiVContainer + GuiComponent + GuiContainer + GuiShell {
634        LinkCount: i32,
635        NodeCount: i32,
636
637        fn GetLinkContent(i32, i32) -> String,
638        fn GetNodeContent(i32, i32) -> String,
639        fn SendData(String),
640    }
641}
642sap_type!(GuiNetChart, "GuiShell", "NetChart");
643
644com_shim! {
645    struct GuiOfficeIntegration: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent + GuiShell {
646        // TODO Document: Object,
647        HostedApplication: i32,
648
649        fn AppendRow(String, String),
650        fn CloseDocument(i32, bool, bool),
651        // TODO fn CustomEvent(i32, String, i32, ...),
652        fn RemoveContent(String),
653        fn SaveDocument(i32, bool),
654        fn SetDocument(i32, String),
655    }
656}
657sap_type!(GuiOfficeIntegration, "GuiShell", "OfficeIntegration");
658
659com_shim! {
660    struct GuiOkCodeField: GuiVComponent + GuiComponent {
661        Opened: bool,
662
663        fn PressF1(),
664    }
665}
666sap_type!(GuiOkCodeField, "GuiOkCodeField");
667
668com_shim! {
669    struct GuiPasswordField: GuiTextField + GuiVComponent + GuiComponent { }
670}
671sap_type!(GuiPasswordField, "GuiPasswordField");
672
673com_shim! {
674    struct GuiPicture: GuiVComponent + GuiVContainer + GuiComponent + GuiContainer + GuiShell {
675        AltText: String,
676        DisplayMode: String,
677        Icon: String,
678        Url: String,
679
680        fn Click(),
681        fn ClickControlArea(i32, i32),
682        fn ClickPictureArea(i32, i32),
683        fn ContextMenu(i32, i32),
684        fn DoubleClick(),
685        fn DoubleClickControlArea(i32, i32),
686        fn DoubleClickPictureArea(i32, i32),
687    }
688}
689sap_type!(GuiPicture, "GuiShell", "Picture");
690
691com_shim! {
692    struct GuiRadioButton: GuiVComponent + GuiComponent {
693        CharHeight: i32,
694        CharLeft: i32,
695        CharTop: i32,
696        CharWidth: i32,
697        Flushing: bool,
698        GroupCount: i32,
699        GroupMembers: GuiComponentCollection,
700        GroupPos: i32,
701        IsLeftLabel: bool,
702        IsRightLabel: bool,
703        LeftLabel: GuiComponent,
704        RightLabel: GuiComponent,
705        Selected: bool,
706
707        fn Select(),
708    }
709}
710sap_type!(GuiRadioButton, "GuiRadioButton");
711
712com_shim! {
713    struct GuiSapChart: GuiVComponent + GuiVContainer + GuiComponent + GuiContainer + GuiShell { }
714}
715sap_type!(GuiSapChart, "GuiShell", "SapChart");
716
717com_shim! {
718    struct GuiScrollbar {
719        Maximum: i32,
720        Minimum: i32,
721        PageSize: i32,
722        mut Position: i32,
723        Range: i32,
724    }
725}
726sap_type!(GuiScrollbar, "GuiScrollbar");
727
728com_shim! {
729    struct GuiScrollContainer: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent {
730        HorizontalScrollbar: GuiComponent,
731        VerticalScrollbar: GuiComponent,
732    }
733}
734sap_type!(GuiScrollContainer, "GuiScrollContainer");
735
736com_shim! {
737    struct GuiSession: GuiContainer + GuiComponent {
738        mut AccEnhancedTabChain: bool,
739        mut AccSymbolReplacement: bool,
740        ActiveWindow: GuiComponent,
741        mut Busy: bool,
742        // TODO mut ErrorList: GuiCollection,
743        Info: GuiSessionInfo,
744        IsActive: bool,
745        IsListBoxActive: bool,
746        ListBoxCurrEntry: i32,
747        ListBoxCurrEntryHeight: i32,
748        ListBoxCurrEntryLeft: i32,
749        ListBoxCurrEntryTop: i32,
750        ListBoxCurrEntryWidth: i32,
751        ListBoxHeight: i32,
752        ListBoxLeft: i32,
753        ListBoxTop: i32,
754        ListBoxWidth: i32,
755        mut PassportPreSystemId: String,
756        mut PassportSystemId: String,
757        mut PassportTransactionId: String,
758        ProgressPercent: i32,
759        ProgressText: String,
760        mut Record: bool,
761        mut RecordFile: String,
762        mut SaveAsUnicode: bool,
763        mut ShowDropdownKeys: bool,
764        mut SuppressBackendPopups: bool,
765        mut TestToolMode: i32,
766
767        fn AsStdNumberFormat(String) -> String,
768        fn ClearErrorList(),
769        fn CreateSession(),
770        fn EnableJawsEvents(),
771        fn EndTransaction(),
772        fn FindByPosition(i32, i32) -> GuiComponent,
773        fn GetIconResourceName(String) -> String,
774        fn GetObjectTree(String) -> String,
775        fn GetVKeyDescription(i32) -> String,
776        fn LockSessionUI(),
777        fn SendCommand(String),
778        fn SendCommandAsync(String),
779        fn StartTransaction(String),
780        fn UnlockSessionUI(),
781    }
782}
783sap_type!(GuiSession, "GuiSession");
784
785com_shim! {
786    struct GuiSessionInfo {
787        ApplicationServer: String,
788        Client: String,
789        Codepage: i32,
790        Flushes: i32,
791        Group: String,
792        GuiCodepage: i32,
793        I18NMode: bool,
794        InterpretationTime: i32,
795        IsLowSpeedConnection: bool,
796        Language: String,
797        MessageServer: String,
798        Program: String,
799        ResponseTime: i32,
800        RoundTrips: i32,
801        ScreenNumber: i32,
802        ScriptingModeReadOnly: bool,
803        ScriptingModeRecordingDisabled: bool,
804        SessionNumber: i32,
805        SystemName: String,
806        SystemNumber: i32,
807        SystemSessionId: String,
808        Transaction: String,
809        UI_GUIDELINE: String,
810        User: String,
811    }
812}
813
814com_shim! {
815    struct GuiShell: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent {
816        AccDescription: String,
817        DragDropSupported: bool,
818        Handle: i32,
819        OcxEvents: GuiCollection,
820        SubType: String,
821
822        fn SelectContextMenuItem(String),
823        fn SelectContextMenuItemByPosition(String),
824        fn SelectContextMenuItemByText(String),
825    }
826}
827sap_type!(GuiShell, "GuiShell");
828
829com_shim! {
830    struct GuiSimpleContainer: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent {
831        IsListElement: bool,
832        IsStepLoop: bool,
833        IsStepLoopInTableStructure: bool,
834        LoopColCount: i32,
835        LoopCurrentCol: i32,
836        LoopCurrentColCount: i32,
837        LoopCurrentRow: i32,
838        LoopRowCount: i32,
839
840        fn GetListProperty(String) -> String,
841        fn GetListPropertyNonRec(String) -> String,
842    }
843}
844sap_type!(GuiSimpleContainer, "GuiSimpleContainer");
845
846com_shim! {
847    struct GuiSplit: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent + GuiShell {
848        IsVertical: i32,
849
850        fn GetColSize(i32) -> i32,
851        fn GetRowSize(i32) -> i32,
852        fn SetColSize(i32, i32),
853        fn SetRowSize(i32, i32),
854    }
855}
856sap_type!(GuiSplit, "GuiShell", "Split");
857
858com_shim! {
859    struct GuiSplitterContainer: GuiVContainer + GuiVComponent + GuiComponent + GuiContainer + GuiShell {
860        IsVertical: bool,
861        mut SashPosition: i32,
862    }
863}
864sap_type!(GuiSplitterContainer, "GuiShell", "SplitterContainer");
865
866com_shim! {
867    struct GuiStage: GuiVComponent + GuiVContainer + GuiContainer + GuiShell + GuiComponent {
868        fn ContextMenu(String),
869        fn DoubleClick(String),
870        fn SelectItems(String),
871    }
872}
873sap_type!(GuiStage, "GuiShell", "Stage");
874
875com_shim! {
876    struct GuiStatusbar: GuiVComponent + GuiVContainer + GuiComponent + GuiContainer {
877        Handle: i32,
878        MessageAsPopup: bool,
879        MessageHasLongText: i32,
880        MessageId: String,
881        MessageNumber: String,
882        MessageParameter: String,
883        MessageType: String,
884
885        fn CreateSupportMessageClick(),
886        fn DoubleClick(),
887        fn ServiceRequestClick(),
888    }
889}
890sap_type!(GuiStatusbar, "GuiStatusbar");
891
892com_shim! {
893    struct GuiStatusBarLink: GuiVComponent + GuiComponent {
894        fn Press(),
895    }
896}
897
898com_shim! {
899    struct GuiStatusPane: GuiVComponent + GuiComponent {
900        Children: GuiComponentCollection,
901    }
902}
903sap_type!(GuiStatusPane, "GuiStatusPane");
904
905com_shim! {
906    struct GuiTab: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent {
907        fn ScrollToLeft(),
908        fn Select(),
909    }
910}
911sap_type!(GuiTab, "GuiTab");
912
913com_shim! {
914    struct GuiTableColumn: GuiComponentCollection {
915        DefaultTooltip: String,
916        Fixed: bool,
917        IconName: String,
918        Selected: bool,
919        Title: String,
920        Tooltip: String,
921    }
922}
923
924com_shim! {
925    struct GuiTableControl: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent {
926        CharHeight: i32,
927        CharLeft: i32,
928        CharTop: i32,
929        CharWidth: i32,
930        // TODO ColSelectMode: GuiTableSelectionType,
931        Columns: GuiCollection,
932        CurrentCol: i32,
933        CurrentRow: i32,
934        HorizontalScrollbar: GuiComponent,
935        RowCount: i32,
936        Rows: GuiCollection,
937        // TODO RowSelectMode: GuiTableSelectionType,
938        TableFieldName: String,
939        VerticalScrollbar: GuiComponent,
940        VisibleRowCount: i32,
941
942        fn ConfigureLayout(),
943        fn DeselectAllColumns(),
944        fn GetAbsoluteRow(i32) -> GuiTableRow,
945        fn GetCell(i32, i32) -> GuiComponent,
946        fn ReorderTable(String),
947        fn SelectAllColumns(),
948    }
949}
950sap_type!(GuiTableControl, "GuiTableControl");
951
952com_shim! {
953    struct GuiTableRow: GuiComponentCollection {
954        Selectable: bool,
955        mut Selected: bool,
956    }
957}
958
959com_shim! {
960    struct GuiTabStrip: GuiVContainer + GuiVComponent + GuiContainer + GuiComponent {
961        CharHeight: i32,
962        CharLeft: i32,
963        CharTop: i32,
964        CharWidth: i32,
965        LeftTab: GuiComponent,
966        SelectedTab: GuiComponent,
967    }
968}
969sap_type!(GuiTabStrip, "GuiTabStrip");
970
971com_shim! {
972    struct GuiTextedit: GuiShell + GuiVComponent + GuiVContainer + GuiContainer + GuiComponent {
973        CurrentColumn: i32,
974        CurrentLine: i32,
975        mut FirstVisibleLine: i32,
976        LastVisibleLine: i32,
977        LineCount: i32,
978        NumberOfUnprotectedTextParts: i32,
979        SelectedText: String,
980        SelectionEndColumn: i32,
981        SelectionEndLine: i32,
982        SelectionIndexEnd: i32,
983        SelectionIndexStart: i32,
984        SelectionStartColumn: i32,
985        SelectionStartLine: i32,
986
987        fn ContextMenu(),
988        fn DoubleClick(),
989        fn GetLineText(i32) -> String,
990        fn GetUnprotectedTextPart(i32) -> String,
991        fn IsBreakpointLine(i32) -> bool,
992        fn IsCommentLine(i32) -> bool,
993        fn IsHighlightedLine(i32) -> bool,
994        fn IsProtectedLine(i32) -> bool,
995        fn IsSelectedLine(i32) -> bool,
996        fn ModifiedStatusChanged(bool),
997        fn MultipleFilesDropped(),
998        fn PressF1(),
999        fn PressF4(),
1000        fn SetSelectionIndexes(i32, i32),
1001        fn SetUnprotectedTextPart(i32, String) -> bool,
1002        fn SingleFileDropped(String),
1003    }
1004}
1005sap_type!(GuiTextedit, "GuiShell", "Textedit");
1006
1007com_shim! {
1008    struct GuiTextField: GuiVComponent + GuiComponent {
1009        mut CaretPosition: i32,
1010        DisplayedText: String,
1011        Highlighted: bool,
1012        HistoryCurEntry: String,
1013        HistoryCurIndex: i32,
1014        HistoryIsActive: bool,
1015        HistoryList: GuiCollection,
1016        IsHotspot: bool,
1017        IsLeftLabel: bool,
1018        IsListElement: bool,
1019        IsOField: bool,
1020        IsRightLabel: bool,
1021        LeftLabel: GuiComponent,
1022        MaxLength: i32,
1023        Numerical: bool,
1024        Required: bool,
1025        RightLabel: GuiComponent,
1026
1027        fn GetListProperty(String) -> String,
1028        fn GetListPropertyNonRec(String) -> String,
1029    }
1030}
1031sap_type!(GuiTextField, "GuiTextField");
1032
1033com_shim! {
1034    struct GuiTitlebar: GuiVComponent + GuiVContainer + GuiContainer + GuiComponent { }
1035}
1036sap_type!(GuiTitlebar, "GuiTitlebar");
1037
1038com_shim! {
1039    struct GuiToolbar: GuiVComponent + GuiVContainer + GuiContainer + GuiComponent { }
1040}
1041sap_type!(GuiToolbar, "GuiToolbar");
1042
1043com_shim! {
1044    struct GuiToolbarControl: GuiShell + GuiVComponent + GuiVContainer + GuiComponent + GuiContainer {
1045        ButtonCount: i32,
1046        FocusedButton: i32,
1047
1048        fn GetButtonChecked(i32) -> bool,
1049        fn GetButtonEnabled(i32) -> bool,
1050        fn GetButtonIcon(i32) -> String,
1051        fn GetButtonId(i32) -> String,
1052        fn GetButtonText(i32) -> String,
1053        fn GetButtonTooltip(i32) -> String,
1054        fn GetButtonType(i32) -> String,
1055        fn GetMenuItemIdFromPosition(i32) -> String,
1056        fn PressButton(String),
1057        fn PressContextButton(String),
1058        fn SelectMenuItem(String),
1059        fn SelectMenuItemByText(String),
1060    }
1061}
1062
1063com_shim! {
1064    struct GuiTree: GuiShell + GuiVContainer + GuiVComponent + GuiComponent + GuiContainer {
1065        // TODO ColumnOrder: Object,
1066        HierarchyHeaderWidth: i32,
1067        SelectedNode: String,
1068        TopNode: String,
1069
1070        fn ChangeCheckbox(String, String, bool),
1071        fn ClickLink(String, String),
1072        fn CollapseNode(String),
1073        fn DefaultContextMenu(),
1074        fn DoubleClickItem(String, String),
1075        fn DoubleClickNode(String),
1076        fn EnsureVisibleHorizontalItem(String, String),
1077        fn ExpandNode(String),
1078        fn FindNodeKeyByPath(String) -> String,
1079        fn GetAbapImage(String, String) -> String,
1080        // TODO fn GetAllNodeKeys() -> Object,
1081        fn GetCheckBoxState(String, String) -> bool,
1082        // TODO fn GetColumnCol(String) -> Object,
1083        // TODO fn GetColumnHeaders() -> Object,
1084        fn GetColumnIndexFromName(String) -> i32,
1085        // TODO fn GetColumnNames() -> Object,
1086        fn GetColumnTitleFromName(String) -> String,
1087        // TODO fn GetColumnTitles() -> Object,
1088        fn GetFocusedNodeKey() -> String,
1089        fn GetHierarchyLevel(String) -> i32,
1090        fn GetHierarchyTitle() -> String,
1091        fn GetIsDisabled(String, String) -> bool,
1092        fn GetIsEditable(String, String) -> bool,
1093        fn GetIsHighLighted(String, String) -> bool,
1094        fn GetItemHeight(String, String) -> i32,
1095        fn GetItemLeft(String, String) -> i32,
1096        fn GetItemStyle(String, String) -> i32,
1097        fn GetItemText(String, String) -> String,
1098        fn GetItemTextColor(String, String) -> u64,
1099        fn GetItemToolTip(String, String) -> String,
1100        fn GetItemTop(String, String) -> i32,
1101        fn GetItemType(String, String) -> i32,
1102        fn GetItemWidth(String, String) -> i32,
1103        fn GetListTreeNodeItemCount(String) -> i32,
1104        fn GetNextNodeKey(String) -> String,
1105        fn GetNodeAbapImage(String) -> String,
1106        fn GetNodeChildrenCount(String) -> i32,
1107        fn GetNodeChildrenCountByPath(String) -> i32,
1108        fn GetNodeHeight(String) -> i32,
1109        fn GetNodeIndex(String) -> i32,
1110        // TODO fn GetNodeItemHeaders(String) -> Object,
1111        fn GetNodeKeyByPath(String) -> String,
1112        fn GetNodeLeft(String) -> i32,
1113        fn GetNodePathByKey(String) -> String,
1114        // TODO fn GetNodesCol() -> Object,
1115        fn GetNodeStyle(String) -> i32,
1116        fn GetNodeTextByKey(String) -> String,
1117        fn GetNodeTextByPath(String) -> String,
1118        fn GetNodeTextColor(String) -> u64,
1119        fn GetNodeToolTip(String) -> String,
1120        fn GetNodeTop(String) -> i32,
1121        fn GetNodeWidth(String) -> i32,
1122        fn GetParent(String) -> String,
1123        fn GetPreviousNodeKey(String) -> String,
1124        // TODO fn GetSelectedNodes() -> Object,
1125        fn GetSelectionMode() -> i16,
1126        fn GetStyleDescription(i32) -> String,
1127        // TODO fn GetSubNodesCol(String) -> Object,
1128        fn GetTreeType() -> i32,
1129        fn HeaderContextMenu(String),
1130        fn IsFolder(String) -> bool,
1131        fn IsFolderExpandable(String) -> bool,
1132        fn IsFolderExpanded(String) -> bool,
1133        fn ItemContextMenu(String, String),
1134        fn NodeContextMenu(String),
1135        fn PressButton(String, String),
1136        fn PressHeader(String),
1137        fn PressKey(String),
1138        fn SelectColumn(String),
1139        fn SelectedItemColumn() -> String,
1140        fn SelectedItemNode() -> String,
1141        fn SelectItem(String, String),
1142        fn SelectNode(String),
1143        fn SetCheckBoxState(String, String, i32),
1144        fn SetColumnWidth(String, i32),
1145        fn UnselectAll(),
1146        fn UnselectColumn(String),
1147        fn UnselectNode(String),
1148    }
1149}
1150sap_type!(GuiTree, "GuiShell", "Tree");
1151
1152com_shim! {
1153    struct GuiUserArea: GuiVContainer + GuiVComponent + GuiComponent + GuiContainer {
1154        HorizontalScrollbar: GuiComponent,
1155        IsOTFPreview: bool,
1156        VerticalScrollbar: GuiComponent,
1157
1158        fn FindByLabel(String, String) -> GuiComponent,
1159        fn ListNavigate(String),
1160    }
1161}
1162sap_type!(GuiUserArea, "GuiUserArea");
1163
1164com_shim! {
1165    struct GuiUtils {
1166        MESSAGE_OPTION_OK: i32,
1167        MESSAGE_OPTION_OKCANCEL: i32,
1168        MESSAGE_OPTION_YESNO: i32,
1169        MESSAGE_RESULT_CANCEL: i32,
1170        MESSAGE_RESULT_NO: i32,
1171        MESSAGE_RESULT_OK: i32,
1172        MESSAGE_RESULT_YES: i32,
1173        MESSAGE_TYPE_ERROR: i32,
1174        MESSAGE_TYPE_INFORMATION: i32,
1175        MESSAGE_TYPE_PLAIN: i32,
1176        MESSAGE_TYPE_QUESTION: i32,
1177        MESSAGE_TYPE_WARNING: i32,
1178
1179        fn CloseFile(i32),
1180        fn OpenFile(String) -> i32,
1181        fn ShowMessageBox(String, String, i32, i32) -> i32,
1182        fn Write(i32, String),
1183        fn WriteLine(i32, String),
1184    }
1185}
1186
1187com_shim! {
1188    struct GuiVComponent: GuiComponent {
1189        AccLabelCollection: GuiComponentCollection,
1190        AccText: String,
1191        AccTextOnRequest: String,
1192        AccTooltip: String,
1193        Changeable: bool,
1194        DefaultTooltip: String,
1195        Height: i32,
1196        IconName: String,
1197        IsSymbolFont: bool,
1198        Left: i32,
1199        Modified: bool,
1200        ParentFrame: GuiComponent,
1201        ScreenLeft: i32,
1202        ScreenTop: i32,
1203        mut Text: String,
1204        Tooltip: String,
1205        Top: i32,
1206        Width: i32,
1207
1208        fn DumpState(String) -> GuiCollection,
1209        fn SetFocus(),
1210        fn Visualize(bool) -> bool,
1211    }
1212}
1213sap_type!(GuiVComponent, "GuiVComponent");
1214
1215com_shim! {
1216    struct GuiVContainer: GuiVComponent + GuiComponent + GuiContainer {
1217        fn FindAllByName(String, String) -> GuiComponentCollection,
1218        fn FindAllByNameEx(String, i32) -> GuiComponentCollection,
1219        fn FindByName(String, String) -> GuiComponent,
1220        fn FindByNameEx(String, String) -> GuiComponent,
1221    }
1222}
1223sap_type!(GuiVContainer, "GuiVContainer");
1224
1225com_shim! {
1226    struct GuiVHViewSwitch: GuiVComponent + GuiComponent {}
1227}
1228sap_type!(GuiVHViewSwitch, "GuiVHViewSwitch");