/// <summary> /// This method is activated when a menu was selected. It performs the needed operations in order to /// translate the selected menu into the matching operation /// </summary> private void onSelection(Object sender) { //Object object_Renamed = widget.getData(); GuiMenuEntry menuEntry = null; MenuItem menuItem = null; menuItem = (MenuItem)sender; menuEntry = ((TagData)(menuItem.Tag)).guiMenuEntry; // when a menu with check style is selected, it is automatically checked. // we want to check it only if it should be checked - according to the state. //In Compact framework it is not allowed to set "Checked" for top level menus. if (!(menuItem.Parent is MainMenu)) { ((MenuItem)sender).Checked = menuEntry.getChecked(); } try { GuiMgForm guiMgForm = menuObjToForm(sender); Events.OnMenuSelection(menuEntry, guiMgForm, false); } catch (ApplicationException e) { Misc.WriteStackTrace(e, Console.Error); } }
/// <summary> /// Perform actions required when a dragged object is dropped (mouse released). /// Put actions : ACT_CTRL_HIT or ACT_HIT and MG_ACT_BEGIN_DROP. /// </summary> /// <param name="guiMgForm"></param> /// <param name="guiMgCtrl"></param> /// <param name="line"></param> protected virtual void processBeginDrop(GuiMgForm guiMgForm, GuiMgControl guiMgCtrl, int line) { MgControlBase mgControl = (MgControlBase)guiMgCtrl; MgFormBase mgForm = (guiMgForm == null) ? mgControl.getForm() : (MgFormBase)guiMgForm; bool isCtrlHit = (mgControl != null) ? true : false; // Drop occurs on a control or a form? if (isCtrlHit) { Manager.EventsManager.addGuiTriggeredEvent(mgControl, InternalInterface.MG_ACT_CTRL_HIT, line); if (mgControl.isSubform()) { Manager.EventsManager.addGuiTriggeredEvent(mgControl.GetSubformMgForm().getTask(), InternalInterface.MG_ACT_BEGIN_DROP); } else { Manager.EventsManager.addGuiTriggeredEvent(mgControl, InternalInterface.MG_ACT_BEGIN_DROP, line); } } else { // If Drop occurs on FORM. Manager.EventsManager.addGuiTriggeredEvent(mgForm.getTask(), InternalInterface.MG_ACT_HIT); Manager.EventsManager.addGuiTriggeredEvent(mgForm.getTask(), InternalInterface.MG_ACT_BEGIN_DROP); } }
/// <summary> </summary> /// <param name="form"></param> /// <param name="mgForm"></param> private void onWindowResizeEnd(Form form) { // ((TagData)form.Tag).Bounds saves X and Y with respect to the Form, // but Width and Height are with respect to Client area. So, compare them // accordingly. Point location = form.Location; Size size = form.ClientSize; ControlsMap controlsMap = ControlsMap.getInstance(); MapData mapData = controlsMap.getFormMapData(form); GuiMgForm mgForm = mapData.getForm(); Rectangle?prevRectPtr = GuiUtils.getSavedBounds(form); Rectangle prevRect = Rectangle.Empty; if (prevRectPtr != null) { prevRect = (Rectangle)prevRectPtr; } if (location.X != prevRect.X || location.Y != prevRect.Y) { onMove(form, mgForm); } if (size.Width != prevRect.Width || size.Height != prevRect.Height) { onResize(form, mgForm); } }
/// <summary> /// resize form /// </summary> /// <param name="form"></param> /// <param name="mgForm"></param> private void onResize(Form form, GuiMgForm guiMgForm) { #if !PocketPC GuiUtils.saveFormBounds(form); if (GuiUtils.getActiveForm() == form) { ((GuiForm)form).RaiseMouseDownIfNeeded(); Events.OnWindowResize(guiMgForm); } if (!GuiUtils.IsFormMinimized(form)) { if (((TagData)form.Tag).Minimized) { ((TagData)form.Tag).Minimized = false; form.PerformLayout(form, "Size"); } } #else // Perform the layout now, as we don't get the layout event. if (((TagData)form.Tag).WindowType == WindowType.Sdi) { SDIFormLayout(form); } #endif }
/// <summary> /// Function handling form close event. /// </summary> /// <param name="guiMgForm"></param> /// <returns>true if event is CLR handled else false.</returns> protected virtual bool processFormClose(GuiMgForm guiMgForm) { bool clrHandledEvent = false; MgFormBase mgForm = (MgFormBase)guiMgForm; if (mgForm.IsMDIFrame) { Manager.EventsManager.addGuiTriggeredEvent(mgForm.getTask(), InternalInterface.MG_ACT_EXIT_SYSTEM); } else { if (!mgForm.IsHelpWindow) { if (mgForm.ShouldPutActOnFormClose()) { Manager.EventsManager.addGuiTriggeredEvent(mgForm.getTask(), InternalInterface.MG_ACT_HIT, RaisedBy.CLOSE_SYSTEM_MENU); } Manager.EventsManager.addGuiTriggeredEvent(mgForm.getTask(), InternalInterface.MG_ACT_CLOSE); } else { if (mgForm.Opened) { clrHandledEvent = true; } } } return(clrHandledEvent); }
/// <summary> This method updates a toolbar as instantiated for a specific form and style. It returns a reference to a /// menu object - to be used in order to retrieve this menu object, if it is needed. The returned object /// should be placed in the controlsMap, with the created menu for future use /// </summary> /// <param name="form">the form for which the menus is instatiated</param> /// <param name="menuStyle">the menu style (pulldown, context)</param> /// <returns> menu reference object</returns> public MenuReference setToolItemInstantiated(GuiMgForm form) { MenuReference menuReference = new MenuReference(form); _instantiatedToolItem[form] = menuReference; return(menuReference); }
/// <summary>******************************************************************************************************* /// **************************** DO NOT DELETE THIS CODE **************************** /// *********************************************************************************************** This /// method refreshes the enabling of internal event menu entries. It is activated when the menu is /// displayed. /// /// NOTE: currently not used - we refresh all action menu entries when the action is enabled\disabled. But, /// we may decide to use this method instead, due to performance issues. If we decide to use this, we need /// to add the SWT.Show to the listeber. /// /// </summary> /// <param name="widget">- /// on which show was received /// </param> /* * private void menuShow (Widget widget) { Menu menu = null; MgMenu mgMenu = null; MenuEntryMenu * menuEntryMenu = null; MenuEntry menuEntry = null; MgForm form = null; * * if (widget instanceof Menu) { menu = (Menu)widget; Object data = menu.getData(); int style = * menu.getStyle(); MenuStyle menuStyle = (style == SWT.POP_UP ? MenuStyle.MENU_STYLE_CONTEXT : * MenuStyle.MENU_STYLE_PULLDOWN); * * form = (MgForm)menu.getShell().getData(); if (data instanceof MgMenu) { mgMenu = (MgMenu) data; * mgMenu.refreshInternalEventMenus(form); } else if (data instanceof MenuEntryMenu) { menuEntryMenu = * (MenuEntryMenu)data; menuEntryMenu.refreshActionMenus(form, menuStyle); } } else if (widget instanceof * MenuItem) { MenuItem menuItem = (MenuItem)widget; menuEntry = (MenuEntry)menuItem.getData(); } } */ /// <summary> This mdthod takes care of toolitem's prompt - we get the mouse move \ mouse exit event on the toolbar. /// /// </summary> /// <param name="event">- /// the event which occured. /// </param> private void onItemEnterLeave(ToolStripItem menuItem, EventType type) { GuiMenuEntry guiMenuEntry = null; GuiMgForm guiMgForm = null; ControlsMap controlsMap = ControlsMap.getInstance(); MapData mapData = controlsMap.getMapData(menuItem); MenuReference menuRef = mapData.getMenuReference(); guiMgForm = menuRef.GetMgForm(); if (type == EventType.MOUSE_ENTER) { guiMenuEntry = ((TagData)menuItem.Tag).guiMenuEntry; // handle tooltip if (menuItem is ToolStripButton) { String tooltipStrMLS = Events.Translate(guiMenuEntry.ToolTip); if (tooltipStrMLS == null) { tooltipStrMLS = ""; } menuItem.ToolTipText = tooltipStrMLS; } } Events.OnMenuPrompt(guiMgForm, (GuiMenuEntry)guiMenuEntry); }
/// <summary> /// handle the context of a control /// </summary> /// <param name = "widget">: /// is the widget of the control \ tab \ table /// </param> /// <param name = "ctrl"> /// </param> private void handleContext(Control control, GuiMgControl guiMgControl, GuiMgForm guiMgForm) { ControlsMap controlsMap = ControlsMap.getInstance(); GuiMgMenu contextMenu = null; ContextMenu menu = null; ContextMenu prevMenu = (ContextMenu)control.ContextMenu; if (guiMgControl != null) { contextMenu = Events.OnGetContextMenu(guiMgControl); Form form = GuiUtilsBase.FindForm(control); MapData mapData = controlsMap.getFormMapData(form); guiMgForm = mapData.getForm(); } else { contextMenu = Events.OnGetContextMenu(guiMgForm); } if (contextMenu != null) { MenuReference menuRefernce = contextMenu.getInstantiatedMenu(guiMgForm, MenuStyle.MENU_STYLE_CONTEXT); menu = (ContextMenu)controlsMap.object2Widget(menuRefernce); } if (menu != prevMenu) { GuiUtilsBase.setContextMenu(control, menu); } }
/// <summary> /// When menuEntry is selected on Menu, this method gets called. It calls appropriate functions depending /// upon type of menu selected. /// </summary> /// <param name="menuEntry">selected menu entry</param> /// <param name="activeForm">current active form, when menu is selected.</param> /// <param name="activatedFromMDIFrame">Is menu selected from MDI Frame. </param> public void onMenuSelection(GuiMenuEntry menuEntry, GuiMgForm activeForm, bool activatedFromMDIFrame) { try { MgFormBase topMostForm = null; TaskBase task = null; if (!((MgFormBase)activeForm).IsHelpWindow) { task = ((MgFormBase)activeForm).getTask(); //from the menu task get the form of the menu(topmost) and save member of the last menu Id selected. topMostForm = (MgFormBase)task.getTopMostForm(); } else { //In case of help window, get the parent form of help form and get task from that. activeForm = topMostForm = ((MgFormBase)activeForm).ParentForm; task = topMostForm.getTask(); } topMostForm.LastClickedMenuUid = menuEntry.menuUid(); if (menuEntry is MenuEntryProgram) { Events.OnMenuProgramSelection(task.ContextID, (MenuEntryProgram)menuEntry, activeForm, activatedFromMDIFrame); } else if (menuEntry is MenuEntryOSCommand) { Events.OnMenuOSCommandSelection(task.ContextID, (MenuEntryOSCommand)menuEntry, activeForm); } else if (menuEntry is MenuEntryEvent) { // in order to get the correct ctlidx we take it from the parent MgMenu of the menuentry and then // change it if the event is a user event from another component int ctlIdx = ((MenuEntryEvent)menuEntry).getParentMgMenu().CtlIdx; MenuEntryEvent menuEntryEvent = (MenuEntryEvent)menuEntry; if (menuEntryEvent.UserEvtCompIndex > 0) { ctlIdx = menuEntryEvent.UserEvtCompIndex; } Events.OnMenuEventSelection(task.ContextID, (MenuEntryEvent)menuEntry, activeForm, ctlIdx); } else if (menuEntry is MenuEntryWindowMenu) { MgFormBase mgFormbase = ((MenuEntryWindowMenu)menuEntry).MgForm; // Activate the form associated with the entry Commands.addAsync(CommandType.ACTIVATE_FORM, mgFormbase); // Put ACT_HIT on form. Events.OnMenuWindowSelection((MenuEntryWindowMenu)menuEntry); } } catch (ApplicationException ex) { Events.WriteExceptionToLog(ex); } }
/// <summary> /// returns the form of the menu which was activated. /// </summary> /// <param> Object menuObj /// </param> /// <returns> The form which the menu belongs to. /// </returns> private GuiMgForm menuObjToForm(Object menuObj) { ControlsMap controlsMap = ControlsMap.getInstance(); MapData mapData = controlsMap.getMapData(menuObj); MenuReference menuRef = mapData.getMenuReference(); GuiMgForm guiMgForm = menuRef.GetMgForm(); return(guiMgForm); }
/// <summary> Refresh internal actions used in Menus </summary> /// <param name = "guiMgMenu"></param> /// <param name = "guiMgForm"></param> private void refreshMenuActions(GuiMgMenu guiMgMenu, GuiMgForm guiMgForm) { MgMenu mgMenu = (MgMenu)guiMgMenu; MgFormBase mgForm = (MgFormBase)guiMgForm; if (mgMenu != null) { mgMenu.refreshInternalEventMenus(mgForm); } }
/// <summary> /// Create MenuEntries for WindowList Items. /// </summary> /// <param name="guiMgForm"></param> /// <param name="guiMenuEntry"></param> /// <param name="menuStyle"></param> public void CreateWindowMenuEntries(GuiMgForm guiMgForm, Object guiMenuEntry, MenuStyle menuStyle) { Debug.Assert(Misc.IsGuiThread()); bool IsMenuEntryWindowMenu = guiMenuEntry is MenuEntryWindowMenu; MenuEntry menuEntry; int windowMenuIdx = 0; //We get this flag as true only when the menu contains WindowList at first level and it is being used as context menu if (IsMenuEntryWindowMenu) { //Here we add the new WindowMenu in the parent MgMenu menuEntry = (MenuEntryWindowMenu)guiMenuEntry; windowMenuIdx = menuEntry.getParentMgMenu().GetWindowMenuEntryIndex(); } else { //We add the WindowMenu in the MenuEntryMenu menuEntry = (MenuEntryMenu)guiMenuEntry; windowMenuIdx = ((MenuEntryMenu)menuEntry).GetWindowMenuEntryIndex(); } // Enable/Disable MenuEntries for CloseAll, NextWindow & PreviousWindow. TaskBase task = ((MgFormBase)guiMgForm).getTask(); MgMenu mgMenu = menuEntry.getParentMgMenu(); mgMenu.enableInternalEvent((MgFormBase)guiMgForm, InternalInterface.MG_ACT_CLOSE_ALL_WIN, task.ActionManager.isEnabled(InternalInterface.MG_ACT_CLOSE_ALL_WIN), null); mgMenu.enableInternalEvent((MgFormBase)guiMgForm, InternalInterface.MG_ACT_NEXT_RT_WINDOW, task.ActionManager.isEnabled(InternalInterface.MG_ACT_NEXT_RT_WINDOW), null); mgMenu.enableInternalEvent((MgFormBase)guiMgForm, InternalInterface.MG_ACT_PREV_RT_WINDOW, task.ActionManager.isEnabled(InternalInterface.MG_ACT_PREV_RT_WINDOW), null); lock (_windowListLock) { if (IsValidIndex(windowMenuIdx)) { // Delete the existing MenuEntries. DeleteWindowMenuEntries(menuEntry, windowMenuIdx + 1, IsMenuEntryWindowMenu); // Create new MenuEntries for WindowList Items. if (_windowList.Count > 0) { // Create menu item for a form in window list. for (int i = 0; i < _windowList.Count; i++) { MgFormBase mgForm = _windowList[i]; menuEntry.CreateMenuEntry(mgForm, GuiMenuEntry.MenuType.WINDOW_MENU_ENTRY, windowMenuIdx++, guiMgForm, menuStyle, _sortByRecentlyUsed ? i == 0 : i == _currWinIdx); } // Create a separator to distinguish the window menu items only for PullDown menu if (menuStyle != MenuStyle.MENU_STYLE_CONTEXT) { menuEntry.CreateMenuEntry(null, GuiMenuEntry.MenuType.SEPARATOR, windowMenuIdx++, guiMgForm, menuStyle, false); } } } } }
/// <summary> This method removes an instantiated menu from the list</summary> /// <param name="form">the form for which the menus is instantiated</param> /// <param name="menuStyle">the menu style (pulldown, context)</param> /// <returns> menu reference object</returns> internal void removeInstantiatedMenu(GuiMgForm form, MenuStyle menuStyle) { if (menuStyle == MenuStyle.MENU_STYLE_PULLDOWN) { instantiatedPullDown.Remove(form); } else { instantiatedContext.Remove(form); } }
/// <summary> Move form</summary> /// <param name="form"></param> /// <param name="mgForm"></param> private void onMove(Form form, GuiMgForm mgForm) { #if !PocketPC ((GuiForm)form).RaiseMouseDownIfNeeded(); #endif GuiUtils.saveFormBounds(form); if (GuiUtils.getActiveForm() == form) { Events.OnWindowMove(mgForm); } }
/// <summary>Put ACT_CTRL_FOCUS, ACT_CTRL_HIT and MG_ACT_BEGIN_DROP to Runtime thread.</summary> protected override void processBeginDrop(GuiMgForm guiMgForm, GuiMgControl guiMgCtrl, int line) { MgControl mgControl = (MgControl)guiMgCtrl; if (mgControl != null && (mgControl.Type == MgControlType.CTRL_TYPE_TEXT || mgControl.Type == MgControlType.CTRL_TYPE_TREE)) { ClientManager.Instance.EventsManager.addGuiTriggeredEvent(mgControl, line, InternalInterface.MG_ACT_CTRL_FOCUS, false); } base.processBeginDrop(guiMgForm, guiMgCtrl, line); }
/// <summary></summary> /// <param name = "guiMgForm"></param> /// <param name = "guiMgCtrl"></param> /// <param name = "modifier"></param> /// <param name = "keyCode"></param> /// <param name = "start"></param> /// <param name = "end"></param> /// <param name = "text"></param> /// <param name = "im"></param> /// <param name = "isActChar"></param> /// <param name = "suggestedValue"></param> /// <param name = "dotNetArgs"></param> /// <param name = "comboIsDropDown"></param> /// <param name="handled">boolean variable event is handled or not.</param> /// <returns> true only if we have handled the KeyDown event (otherwise the CLR should handle). If true magic will handle else CLR will handle.</returns> protected override bool processKeyDown(GuiMgForm guiMgForm, GuiMgControl guiMgCtrl, Modifiers modifier, int keyCode, int start, int end, String text, ImeParam im, bool isActChar, String suggestedValue, bool comboIsDropDown, bool handled) { // time of last user action for IDLE function ClientManager.Instance.LastActionTime = Misc.getSystemMilliseconds(); // DOWN or UP invoked on a SELECT/RADIO control return(base.processKeyDown(guiMgForm, guiMgCtrl, modifier, keyCode, start, end, text, im, isActChar, suggestedValue, comboIsDropDown, handled)); }
/// <summary> /// Release references to mgData and to the task in order to let the gc to free the memory. /// This code was moved from processClose in order to clean also when the "open window = NO" (non interactive tasks). /// </summary> /// <param name = "form"></param> internal void processDispose(GuiMgForm guiMgForm) { var form = (MgForm)guiMgForm; var task = (Task)form.getTask(); MGData mgd = task.getMGData(); RCTimer.StopAll(mgd); if (mgd.IsAborting) { MGDataCollection.Instance.deleteMGDataTree(mgd.GetId()); } }
/// <summary> This method returns a menu object reference for a specific form and menu style (pulldown, context). The /// returned reference should be used in order to retrieve the specific instantiated menu object from the /// controls map.</summary> /// <param name="form">the form for which the menus is instatiated</param> /// <param name="menuStyle">the menu style (pulldown, context)</param> /// <returns> a menu object reference. In case the menu was not yet instantiated for the specfic form and /// style, null is returned. /// </returns> public MenuReference getInstantiatedMenu(GuiMgForm form, MenuStyle menuStyle) { MenuReference menuReference = null; if (menuStyle == MenuStyle.MENU_STYLE_PULLDOWN) { menuReference = (MenuReference)instantiatedPullDown[form]; } else { menuReference = (MenuReference)instantiatedContext[form]; } return(menuReference); }
/// <summary> This method updates a menu as instantiated for a specific form and style. It returns a reference to a /// menu object - to be used in order to retrieve this menu object, if it is needed. The returned object /// should be placed in the controlsMap, with the created menu for future use /// /// </summary> /// <param name="form">the form for which the menus is instantiated</param> /// <param name="menuStyle">the menu style (pulldown, context)</param> /// <returns> menu reference object</returns> protected MenuReference setMenuIsInstantiated(GuiMgForm form, MenuStyle menuStyle) { var menuReference = new MenuReference(form); if (menuStyle == MenuStyle.MENU_STYLE_PULLDOWN) { instantiatedPullDown[form] = menuReference; } else { instantiatedContext[form] = menuReference; } return(menuReference); }
/// <summary> Remove the menu reference for the menu entry</summary> /// <param name="menuReference"></param> /// <param name="style"></param> internal void removeMenuIsInstantiated(GuiMgForm guiMgForm, MenuStyle style) { if (style == MenuStyle.MENU_STYLE_PULLDOWN) { _instantiatedPullDown.Remove(guiMgForm); } else if (style == MenuStyle.MENU_STYLE_CONTEXT) { _instantiatedContext.Remove(guiMgForm); } else if (style == MenuStyle.MENU_STYLE_TOOLBAR) { _instantiatedToolItem.Remove(guiMgForm); } }
/// <summary> This method is activated when a menu was selected. It performs the needed operations in order to /// translate the selected menu into the matching operation /// /// </summary> /// <param name="widget">- /// the selected menu entry widget /// </param> private void onSelection(Object sender) { //Object object_Renamed = widget.getData(); GuiMenuEntry guiMenuEntry = null; ToolStripItem menuItem = null; ToolStrip ts; menuItem = (ToolStripItem)sender; ts = menuItem.GetCurrentParent(); guiMenuEntry = ((TagData)menuItem.Tag).guiMenuEntry; // when a menu with check style is selected, it is automatically checked. // we want to check it only if it should be checked - according to the state. if (sender is ToolStripButton) { ((ToolStripButton)sender).Checked = guiMenuEntry.getChecked(); } else { ((ToolStripMenuItem)sender).Checked = guiMenuEntry.getChecked(); } Form form = menuObjToForm(sender); GuiMgForm activeForm = null; bool activatedFromMDIFrame = false; if (form.IsMdiContainer) { activatedFromMDIFrame = true; Form activeMDIChild = GuiUtils.GetActiveMDIChild(form); if (activeMDIChild != null) { form = activeMDIChild; } } ControlsMap controlsMap = ControlsMap.getInstance(); Control c = ((TagData)(form.Tag)).ClientPanel; activeForm = controlsMap.getControlMapData(c).getForm(); Events.OnMenuSelection(guiMenuEntry, activeForm, activatedFromMDIFrame); }
/// <summary> /// Gets the contextID using the GuiMgForm. /// </summary> /// <param name="mgObject">Magic Object - GuiMgForm/GuiMgControl/Logical control</param> /// <returns>contextID</returns> internal static Int64 GetContextID(Object mgObject) { GuiMgForm guiMgForm = null; if (mgObject is LogicalControl) { guiMgForm = ((LogicalControl)mgObject).GuiMgControl.GuiMgForm; } else if (mgObject is GuiMgControl) { guiMgForm = ((GuiMgControl)mgObject).GuiMgForm; } else if (mgObject is GuiMgForm) { guiMgForm = (GuiMgForm)mgObject; } return(Events.GetContextID(guiMgForm)); }
/// <summary> Add Open Context Menu event on right click on form.</summary> /// <param name = "guiMgControl">control </param> /// <param name = "guiMgForm">code of internal event </param> /// <param name = "left">code of internal event </param> /// <param name = "top">code of internal event </param> /// <param name = "line">code of internal event </param> public void AddOpenContextMenuEvent(GuiMgControl guiMgControl, GuiMgForm guiMgForm, int left, int top, int line) { MgControl ctrl = null; Task task = null; if (guiMgControl != null) { if (guiMgControl is MgControl) { ctrl = (MgControl)guiMgControl; if (ctrl.Type == MgControlType.CTRL_TYPE_SUBFORM) { task = (Task)ctrl.GetSubformMgForm().getTask(); } else { task = (Task)((MgControlBase)guiMgControl).getForm().getTask(); } } } else { task = (Task)((MgFormBase)guiMgForm).getTask(); } // Prepare event for MG_ACT_CONTEXT_MENU to open context menu. var rtEvt = new RunTimeEvent(task); rtEvt.setInternal(InternalInterface.MG_ACT_CONTEXT_MENU); rtEvt.setCtrl(ctrl); //Prepare an argument list for left and top co-ordinate. var argsList = new GuiExpressionEvaluator.ExpVal[3]; argsList[0] = new GuiExpressionEvaluator.ExpVal(StorageAttribute.ALPHA, false, left.ToString()); argsList[1] = new GuiExpressionEvaluator.ExpVal(StorageAttribute.ALPHA, false, top.ToString()); argsList[2] = new GuiExpressionEvaluator.ExpVal(StorageAttribute.ALPHA, false, line.ToString()); var args = new ArgumentsList(argsList); rtEvt.setArgList(args); ClientManager.Instance.EventsManager.addToTail(rtEvt); }
/// <summary>Pass keycode and modifier to bridge, bridge then converts it to keyboard action and adds in MgCore.dll /// events queue</summary> /// <param name="form"></param> /// <param name="guiMgCtrl"></param> /// <param name="modifier"></param> /// <param name="keyCode"></param> /// <param name="start"></param> /// <param name="end"></param> /// <param name="caretPos"></param> /// <param name="text"></param> /// <param name="im"></param> /// <param name="isActChar"></param> /// <param name="suggestedValue"></param> /// <param name="ComboIsDropDown"></param> /// <param name="handled">boolean variable event is handled or not.</param> /// <returns> true only if we have handled the KeyDown event (otherwise the CLR should handle). If true magic will handle else CLR will handle.</returns> protected virtual bool processKeyDown(GuiMgForm guiMgForm, GuiMgControl guiMgCtrl, Modifiers modifier, int keyCode, int start, int end, string text, ImeParam im, bool isActChar, string suggestedValue, bool ComboIsDropDown, bool handled) { bool eventHandled = handled; bool addKeyBoardEvent = true; MgControlBase mgControl = (MgControlBase)guiMgCtrl; MgFormBase mgForm = (MgFormBase)guiMgForm; if (mgControl != null) { //In case of help window, the events like up arrow\down arrow key, should be handled by the //CLR.So first check if the form is help form and return the value true or false. if (mgControl.getForm() != null && mgControl.getForm().IsHelpWindow&& keyCode != GuiConstants.KEY_ESC) { //events related with the help window will NOT be handled by magic. return(false); } // DOWN or UP invoked on a SELECT/RADIO control if ((mgControl.isRadio() || mgControl.isListBox() || (mgControl.isComboBox() && ComboIsDropDown) || (mgControl.isTabControl() && !suggestedValue.Equals("-1")))) { if (processKeyForSelectionControl(mgForm, mgControl, modifier, keyCode, suggestedValue)) { addKeyBoardEvent = false; } } } if (addKeyBoardEvent) { // raise event Manager.EventsManager.AddKeyboardEvent(mgForm, mgControl, modifier, keyCode, start, end, text, im, isActChar, suggestedValue, InternalInterface.MG_ACT_CTRL_KEYDOWN); } return(eventHandled); }
/// <summary> /// Process press event. Move Focus and raise internal press event /// </summary> /// <param name="guiMgForm"></param> /// <param name="guiMgCtrl"></param> /// <param name="line"></param> private void ProcessPress(GuiMgForm guiMgForm, GuiMgControl guiMgCtrl, int line) { MgControlBase mgControl = (MgControlBase)guiMgCtrl; // The internal press event is fired if press event is fired on form or subform if (mgControl == null) { Manager.EventsManager.addGuiTriggeredEvent(((MgFormBase)guiMgForm).getTask(), InternalInterface.MG_ACT_HIT); } else if (mgControl.isSubform()) { mgControl.OnSubformClick(); } else { Manager.EventsManager.addGuiTriggeredEvent(mgControl, InternalInterface.MG_ACT_CTRL_HIT, line); } Manager.EventsManager.addGuiTriggeredEvent(mgControl, InternalInterface.MG_ACT_PRESS, line); }
/// <summary> </summary> /// <param name = "guiMgForm"></param> /// <param name = "prompt"></param> private void onMenuPrompt(GuiMgForm guiMgForm, GuiMenuEntry guiMenuEntry) { MgFormBase mgForm = null; TaskBase task = null; if (guiMgForm is MgFormBase) { mgForm = (MgFormBase)guiMgForm; } if (mgForm != null) { task = mgForm.getTask(); } if (task != null) { if (guiMenuEntry == null) { if (!task.isAborting()) { Manager.CleanMessagePane(task); } } else { if (guiMenuEntry is MenuEntry) { MenuEntry menuEntry = (MenuEntry)guiMenuEntry; String prompt = menuEntry.getPrompt(); if (prompt == null) { prompt = ""; } Manager.WriteToMessagePane(task, StrUtil.makePrintable(prompt), false); } } } }
/// <summary> This method returns a menu object reference for a specific form and menu style (pulldown, context). The /// returned reference should be used in order to retrieve the specific instantiated menu object from the /// controls map. /// </summary> /// <param name="form">the form for which the menus is instatiated</param> /// <param name="menuStyle">the menu style (pulldown, context)</param> /// <returns> a menu object reference. In case the menu was not yet instantiated for the specfic form and /// style, null is returned.</returns> public MenuReference getInstantiatedMenu(GuiMgForm form, MenuStyle menuStyle) { MenuReference menuReference = null; if (menuStyle == MenuStyle.MENU_STYLE_PULLDOWN) { menuReference = (MenuReference)_instantiatedPullDown[form]; } else if (menuStyle == MenuStyle.MENU_STYLE_CONTEXT) { menuReference = (MenuReference)_instantiatedContext[form]; } else if (menuStyle == MenuStyle.MENU_STYLE_TOOLBAR) { menuReference = (MenuReference)_instantiatedToolItem[form]; } else { Debug.Assert(false); } return(menuReference); }
/// <summary> This method updates a menu as instantiated for a specific form and style. It returns a reference to a /// menu object - to be used in order to retrieve this menu object, if it is needed. The returned object /// should be placed in the controlsMap, with the created menu for future use /// </summary> /// <param name="form">the form for which the menus is instatiated</param> /// <param name="menuStyle">the menu style (pulldown, context)</param> /// <returns> menu reference object</returns> protected MenuReference setMenuIsInstantiated(GuiMgForm form, MenuStyle menuStyle) { MenuReference menuReference = new MenuReference(form); if (menuStyle == MenuStyle.MENU_STYLE_PULLDOWN) { _instantiatedPullDown[form] = menuReference; } else if (menuStyle == MenuStyle.MENU_STYLE_CONTEXT) { _instantiatedContext[form] = menuReference; } else if (menuStyle == MenuStyle.MENU_STYLE_TOOLBAR) { _instantiatedToolItem[form] = menuReference; } else { Debug.Assert(false); } return(menuReference); }
/// <summary></summary> /// <param name = "guiMgForm"></param> /// <param name = "guiMgCtrl"></param> /// <param name = "dotNetArgs"></param> /// <param name = "leftClickWasPressed"></param> /// <param name = "line"></param> private void processMouseDown(GuiMgForm guiMgForm, GuiMgControl guiMgCtrl, Object[] dotNetArgs, bool leftClickWasPressed, int line, bool onMultiMark, bool canProduceClick) { MgControlBase mgControl = (MgControlBase)guiMgCtrl; // Click on form or Click on the Subform's form should handle mg_act_hit (not control_hit). if (mgControl == null) { Debug.Assert(guiMgForm != null); // As in online. clicking on a form results in ACT_HIT Manager.EventsManager.addGuiTriggeredEvent(((MgFormBase)guiMgForm).getTask(), InternalInterface.MG_ACT_HIT, onMultiMark); return; } else if (mgControl.isSubform()) { mgControl.OnSubformClick(); return; } if (mgControl.RaiseControlHitOnMouseDown(leftClickWasPressed)) { Manager.EventsManager.addGuiTriggeredEvent(mgControl, InternalInterface.MG_ACT_CTRL_HIT, line, null, onMultiMark); } if (leftClickWasPressed && canProduceClick) { // fixed bug#927942 // we never get to this method with the control type button & checkbox. // for button & checkbox, we sent the trigger MG_ACT_WEB_CLICK in EventsManager.handleMouseUp() that call // from simulateSelection() // the "if" is only for make sure that if we will get it (in the feture) we will not be sent the same trigger twice if (mgControl.Type != MgControlType.CTRL_TYPE_BUTTON && mgControl.Type != MgControlType.CTRL_TYPE_CHECKBOX) { Manager.EventsManager.addGuiTriggeredEvent(mgControl, InternalInterface.MG_ACT_WEB_CLICK, line, dotNetArgs, false); } } }
/// <summary> /// An empty virtual method. Implemented in MenuEntryWindowMenu and MenuEntryMenu used for ContextMenu and PullDownMenu respectively. /// </summary> /// <param name="mgFormBase"></param> /// <param name="menuType"></param> /// <param name="windowMenuIdx"></param> /// <param name="guiMgForm"></param> /// <param name="menuStyle"></param> /// <param name="setChecked"></param> public virtual void CreateMenuEntry(MgFormBase mgFormBase, MenuType menuType, int windowMenuIdx, GuiMgForm guiMgForm, MenuStyle menuStyle, bool setChecked) { }