/// <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> according to shell return the last control that was in focus /// it can be on subform \ sub sub form.... /// </summary> /// <param name="shell"> /// </param> /// <returns> /// </returns> private GuiMgControl getLastFocusedControl(Object menuObj) { Form form = menuObjToForm(menuObj); ControlsMap controlsMap = ControlsMap.getInstance(); GuiMgControl guiMgControl = null; if (form.IsMdiContainer) { Form activeMDIChild = GuiUtils.GetActiveMDIChild(form); if (activeMDIChild != null) { form = activeMDIChild; } } if (form.ActiveControl != null) { MapData mapData = controlsMap.getMapData(form.ActiveControl); if (mapData != null) { guiMgControl = mapData.getControl(); } } return(guiMgControl); }
/// <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> /// /// </summary> /// <param name="type"></param> /// <param name="sender"></param> /// <param name="evtArgs"></param> internal override void handleEvent(EventType type, Object sender, EventArgs evtArgs) { MapData mapData = ControlsMap.getInstance().getMapData(sender); if (mapData == null) { return; } var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(mapData.getControl())); try { switch (type) { case EventType.RESIZE: GuiUtils.setBackgroundImage((Control)sender); break; case EventType.MOUSE_WHEEL: case EventType.MOUSE_DOWN: case EventType.MOUSE_UP: case EventType.MOUSE_DBLCLICK: //case EventType.KeyDown: break; } } finally { contextIDGuard.Dispose(); } DefaultHandler.getInstance().handleEvent(type, sender, evtArgs); }
internal override void handleEvent(EventType type, Object sender, EventArgs e) { ControlsMap controlsMap = ControlsMap.getInstance(); MgPanel tabControlPanel = (MgPanel)sender; TabControl tabControl = ((TagData)(tabControlPanel.Tag)).ContainerTabControl; MapData mapData = controlsMap.getMapData(tabControl); switch (type) { case EventType.PAINT: ControlRenderer.FillRectAccordingToGradientStyle(((PaintEventArgs)e).Graphics, tabControlPanel.ClientRectangle, tabControlPanel.BackColor, tabControlPanel.ForeColor, ControlStyle.NoBorder, false, tabControlPanel.GradientColor, tabControlPanel.GradientStyle); break; } DefaultContainerHandler.getInstance().handleEvent(type, (Control)sender, e, mapData); if (type == EventType.DISPOSED) { tabControl.Tag = null; } }
/// <summary>link control to the editor</summary> /// <param name="staticControl"></param> /// <param name="editor"></param> /// <param name="create"></param> internal void linkControlToEditor(LogicalControl lg, StaticControlEditor editor, bool create) { Control control; if (create) { if (editor.Control != null) { GuiUtilsBase.ControlToDispose = editor.Control; } control = toControl(lg.GuiMgControl); control.Size = new Size(); } else { control = editor.Control; } ControlsMap.getInstance().setMapData(lg.GuiMgControl, lg._mgRow, control); editor.Control = control; lg.setProperties(control); editor.BoundsComputer = (BoundsComputer)lg.Coordinator; editor.Layout(); lg.setPasswordToControl(control); }
/// <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> open temporary editor for tree child create a text control for the editor /// </summary> /// <param name="child"></param> /// <returns></returns> internal Control showTmpEditor(TreeChild child) { Debug.Assert(Misc.IsGuiThread()); if (_form == null) { _form = GuiUtils.FindForm(_treeControl); } GuiUtils.SetTmpEditorOnTagData(_form, _tmpEditor); TextBox text = (_tmpEditor.Control == null ? (TextBox)toControl(_mgTreeControl, CommandType.CREATE_EDIT) : (TextBox)_tmpEditor.Control); text.Show(); //fixed bug #:310473, control is created as hiden we need to show the created editor. ControlUtils.SetBGColor(text, Color.White); text.BorderStyle = BorderStyle.FixedSingle; ControlsMap.getInstance().setMapData(_mgTreeControl, child._mgRow, text); if (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ja") // JPN: IME support { child.Modifable = true; } child.setProperties(text); _tmpEditor.Control = text; _tmpEditor.Node = child.getTreeNode(); _tmpEditor.Layout(); ((TagData)_form.Tag).LastFocusedControl = text; GuiUtils.setFocus(text, true, false); return(text); }
/// <summary>this is an entry point for all objects handlers</summary> /// <param name="objectHashCode"> hash code of the object</param> /// <param name="eventName"> event name</param> /// <param name="parameters">event parameters</param> /// <returns></returns> public static void handleDotNetEvent(int objectHashCode, String eventName, Object[] parameters) { Object invokedObject = DNManager.getInstance().DNObjectEventsCollection.getObject(objectHashCode); GuiMgControl mgControl = null; bool raiseRuntimeEvent = true; Manager.ContextIDGuard contextIDGuard = null; // If Object is a control and it is 'our' control (not created dynamically, decided by .Tag) if (invokedObject is Control && ((Control)invokedObject).Tag != null) { ControlsMap controlsMap = ControlsMap.getInstance(); MapData mapData = controlsMap.getControlMapData((Control)invokedObject); if (mapData == null) { return; } mgControl = mapData.getControl(); contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(mgControl)); //first execute default magic handling of event EventType type = DNControlEvents.getStandardEvent(eventName); if (type != EventType.NONE && parameters.Length == 2) { DefaultHandler.getInstance().handleEvent(type, invokedObject, (EventArgs)parameters[1]); } if (eventName == "KeyDown") //QCR #736734 KeyDown is handled from Filter.cs on WM_KEYDOWN - do not duplicate the event { raiseRuntimeEvent = false; } else if (eventName == "Disposed") { // a Disposed event for a control can't be handled as a runtime-event after the task/form are closed raiseRuntimeEvent = false; } else { // raise .NET runtime event only if hooked from the application (i.e. have a handler in the task) List <String> applicationHookedDNeventsNames = ((TagData)((Control)invokedObject).Tag).ApplicationHookedDNeventsNames; if (applicationHookedDNeventsNames == null || !applicationHookedDNeventsNames.Contains(eventName)) { raiseRuntimeEvent = false; } } } // raise .NET event if (raiseRuntimeEvent) { Events.OnDotNetEvent(invokedObject, mgControl, eventName, parameters); } if (contextIDGuard != null) { contextIDGuard.Dispose(); } }
/// <summary>singleton</summary> internal static ControlsMap getInstance() { if (_instance == null) { _instance = new ControlsMap(); } return(_instance); }
internal override void Dispose() { Debug.Assert(Misc.IsGuiThread()); ControlsMap controlsMap = ControlsMap.getInstance(); controlsMap.removeFromIdx(_mgTreeControl, 1); _tmpEditor.Dispose(); }
//<summary> get tree child from tree item</summary> //<param name="treeNode"></param> //<returns></returns> internal static TreeChild getTreeChild(TreeNode treeNode) { Debug.Assert(Misc.IsGuiThread()); ControlsMap controlsMap = ControlsMap.getInstance(); MapData mapdata = controlsMap.getMapData(treeNode); TreeChild child = (TreeChild)controlsMap.object2Widget(mapdata.getControl(), mapdata.getIdx()); return(child); }
/// <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> /// /// </summary> /// <param name="type"></param> /// <param name="sender"></param> /// <param name="e"></param> internal override void handleEvent(EventType type, Object sender, EventArgs e) { MapData mapData = ControlsMap.getInstance().getMapData(sender); if (mapData == null) { return; } DefaultContainerHandler.getInstance().handleEvent(type, sender, e); }
/// <summary> /// This method will register handlers for DataView Control. /// </summary> /// <param name="mgCtrl"></param> /// <param name="dataTable"></param> public void AddHandler(GuiMgControl mgCtrl, DataTable dataTable) { Object obj = ControlsMap.getInstance().object2Widget(mgCtrl); Control ctrl = (Control)obj; dataTable.ColumnChanged += ColumnChangedHandler; //get BindingManagerBase object and registering handler for it BindingManagerBase dm = ctrl.BindingContext[dataTable]; dm.CurrentChanged += CurrentChangedHandler; }
/// <summary> Handle form activation. </summary> /// <param name="form">the form being activated.</param> internal void OnFormActivate(Form form) { #if PocketPC // if forms were hidden, we need to show all the forms if (!form.Visible) { GUIManager.Instance.restoreHiddenForms(); } #else if (PrintPreviewFocusManager.GetInstance().ShouldResetPrintPreviewInfo) { PrintPreviewFocusManager.GetInstance().ShouldPrintPreviewBeFocused = false; PrintPreviewFocusManager.GetInstance().PrintPreviewFormHandle = IntPtr.Zero; } // #943264 & 942768. Fixed a .net Framework issue. // Suppose, we have a window with a user control (with a child control inside it). // When parking on this child control, we open another window. // Now, if we close the new window, the focus should be back on the last // focused control i.e. the child control in this case. // But, this happens only if the widows are opened outside the MDI frame. // If they are opened inside the MDI frame, the focus is not set on the child control. // So, we need to explicitly set the focus on the last focused control. Form activeForm = ((TagData)form.Tag).ActiveChildWindow ?? form; if (activeForm.IsMdiContainer) { Form activeMDIChild = GuiUtils.GetActiveMDIChild(activeForm); if (activeMDIChild != null) { activeForm = activeMDIChild; } } GuiUtils.restoreFocus(activeForm); lastActiveTopLevelForm = GuiUtils.FindTopLevelForm(activeForm); Control clientPanel = ((TagData)form.Tag).ClientPanel; if (((TagData)form.Tag).IsMDIClientForm) { clientPanel = ((TagData)form.MdiParent.Tag).ClientPanel; } MapData mapData = ControlsMap.getInstance().getMapData(clientPanel); Events.OnFormActivate(mapData.getForm()); if (PrintPreviewFocusManager.GetInstance().IsInModalFormOpening) { PrintPreviewFocusManager.GetInstance().ShouldResetPrintPreviewInfo = true; } #endif }
internal ContainerManager(Control mainControl) { controlsMap = ControlsMap.getInstance(); this.mainControl = mainControl; if (mainControl.Tag == null) { GuiUtils.CreateTagData(mainControl); } TagData td = (TagData)mainControl.Tag; td.ContainerManager = this; }
/// <summary> hides temporary editor</summary> /// <param name="form"></param> internal static void hideTmpEditor(Form form) { Editor editor = GuiUtils.GetTmpEditorFromTagData(form); if (editor != null) { if (editor.Control != null) { ControlsMap.removeMapData(editor.Control); } editor.Hide(); } }
/// <summary> /// </summary> /// <param name="type"></param> /// <param name="sender"></param> /// <param name="e"></param> internal override void handleEvent(EventType type, Object sender, EventArgs e) { ControlsMap controlsMap = ControlsMap.getInstance(); MgWebBrowser webBroswer = (MgWebBrowser)sender; MapData mapData = controlsMap.getMapData(webBroswer); if (mapData == null) { return; } GuiMgControl guiMgCtrl = mapData.getControl(); var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgCtrl)); try { switch (type) { case EventType.GOT_FOCUS: Events.OnFocus(guiMgCtrl, 0, false, false); return; case EventType.DISPOSED: break; #if !PocketPC case EventType.STATUS_TEXT_CHANGED: String statusText = webBroswer.StatusText.Trim(); String previousStatusText = ((TagData)webBroswer.Tag).BrowserControlStatusText; if (statusText.Length > 0 && !statusText.Equals(previousStatusText)) { ((TagData)webBroswer.Tag).BrowserControlStatusText = statusText; Events.OnBrowserStatusTxtChange(guiMgCtrl, statusText); } break; #endif case EventType.EXTERNAL_EVENT: ExternalEventArgs args = (ExternalEventArgs)e; Events.OnBrowserExternalEvent(guiMgCtrl, args.Param); break; } } finally { contextIDGuard.Dispose(); } DefaultHandler.getInstance().handleEvent(type, sender, e); }
/// <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 Form menuObjToForm(Object menuObj) { Form form = null; GuiMgForm guiMgForm; ControlsMap controlsMap = ControlsMap.getInstance(); MapData mapData = controlsMap.getMapData(menuObj); MenuReference menuRef = mapData.getMenuReference(); guiMgForm = menuRef.GetMgForm(); form = GuiUtils.FindForm((Control)controlsMap.object2Widget(guiMgForm)); return(form); }
private void handlePredefinedEvent(string eventName, object sender, EventArgs e) { GuiMgControl guiMgCtrl = null; Debug.Assert(sender is Control && DNControlEvents.isPredefinedEvent(eventName)); ControlsMap controlsMap = ControlsMap.getInstance(); MapData mapData = controlsMap.getMapData(sender); if (mapData != null) { guiMgCtrl = mapData.getControl(); } Events.OnDotNetEvent(sender, guiMgCtrl, eventName, new[] { sender, e }); }
/// <summary> /// callback - get the ControlDesignerInfo for the requested object /// </summary> /// <param name="component"></param> /// <returns></returns> ControlDesignerInfo GetControlDesignerInfo(object component) { object mgObject = ControlsMap.getInstance().GetObjectFromWidget(component); if (mgObject == null || !controlDesignerInfoDictionary.ContainsKey(mgObject)) //TMP - prevent subform exception yoel { return(null); } if (mgObject != null) { controlDesignerInfoDictionary[mgObject].PreviousPlacementBounds = EditorSupportingPlacementLayout.GetPlacementDifRect(component); } return(mgObject != null ? controlDesignerInfoDictionary[mgObject] : null); }
/// <summary> </summary> internal override void handleEvent(EventType type, Object sender, EventArgs e) { if (type == EventType.DISPOSED) { ControlsMap controlsMap = ControlsMap.getInstance(); ToolStripItem toolStripItem = (ToolStripItem)sender; MapData mapData = controlsMap.getMapData(sender); if (mapData != null) { GuiMgControl guiMgControl = mapData.getControl(); toolStripItem.Tag = null; controlsMap.remove(guiMgControl, mapData.getIdx()); } } }
/// <summary> /// This function handles DN control value changed event. /// </summary> /// <param name="objectHashCode">object hash code.</param> public static void HandleDNControlValueChanged(int objectHashCode) { Object invokedObject = DNManager.getInstance().DNObjectEventsCollection.getObject(objectHashCode); // Get the gui control from the control's map. if (invokedObject is Control && ((Control)invokedObject).Tag != null) { ControlsMap controlsMap = ControlsMap.getInstance(); MapData mapData = controlsMap.getControlMapData((Control)invokedObject); if (mapData != null) { //Raise the event. Events.OnDNControlValueChanged(mapData.getControl(), mapData.getIdx()); } } }
/// <summary> /// get editor control of child /// </summary> /// <returns></returns> public override Control getEditorControl() { TreeEditor treeEditor = _treeManager.getTmpEditor(); Control control = treeEditor.Control; if (control != null) { MapData mapData = ControlsMap.getInstance().getMapData(control); if (mapData != null && _mgRow == mapData.getIdx()) { // this child has temporary editor return(control); } } return(null); }
/// <summary> /// create List for all controls /// </summary> /// <returns></returns> public Dictionary <Control, bool> CreateAllControlsForFormDesigner() { Dictionary <Control, bool> list = new Dictionary <Control, bool>(); if (LogicalControls != null) { foreach (LogicalControl lg in LogicalControls) { Control control; // if the logical control does not have an editor, or if its editor is hidden, create a control for it // and add it to the list if (lg.getEditorControl() == null || IsHiddenEditor(lg.getEditorControl())) { control = toControl(lg.GuiMgControl); control.Parent = null; ControlsMap.getInstance().setMapData(lg.GuiMgControl, lg._mgRow, control); lg.setProperties(control); lg.setPasswordToControl(control); list[control] = true; lg.setSpecificControlPropertiesForFormDesigner(control); } else { control = lg.getEditorControl(); } ((TagData)control.Tag).Bounds = lg.getRectangle(); // to handle negative values control.Bounds = lg.getRectangle(); Rectangle rect = new Rectangle(lg.X, lg.Y, lg.Width, lg.Height); ((TagData)control.Tag).LastBounds = rect; //TODO: RTL //if (containerRightToLeft) // rect.X -= dx; } } // add the real child controls, unless the child control is a hidden tmp editor or a form foreach (Control item in this.mainControl.Controls) { if (!IsHiddenEditor(item) && !(item is Form)) { list[item] = false; } } return(list); }
/// <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> /// default implementation of get editor control /// </summary> /// <returns></returns> public Control getEditorControl() { if (_supportEditor) { StaticControlEditor staticControlEditor = getEditor(); Control control = staticControlEditor.Control; if (control != null) { MapData mapData = ControlsMap.getInstance().getMapData(control); if (mapData != null && ((LogicalControl)_lg).GuiMgControl == mapData.getControl()) { // this child has temporary editor return(control); } } } return(null); }
/// <summary> refresh temporary editor of static controls</summary> /// <param name="form"></param> internal static void refreshTmpEditor(Form form) { Editor editor = GuiUtils.GetTmpEditorFromTagData(form); if (editor != null && (!editor.isHidden())) { if (editor.Control != null) { MapData mapData = ControlsMap.getInstance().getMapData(editor.Control); Object obj = ControlsMap.getInstance().object2Widget(mapData.getControl(), mapData.getIdx()); //for now only refesh static text LgText staticControl = obj as LgText; if (staticControl != null && staticControl.RefreshNeeded) { ((LgText)staticControl).setProperties(editor.Control); } } } }
/// <summary> /// get data describing control from the windows message /// </summary> /// <param name="m"></param> /// <returns> null, if not magic control, /// ControlData if it is magic control</returns> private static ControlData MessageToMapData(Message m) { ControlData controlData = null; Control control = Control.FromChildHandle(m.HWnd); if (control != null) { MapData mapData = ControlsMap.getInstance().getControlMapData(control); if (mapData != null) //this is a magic control { controlData = new ControlData() { Control = control, MapData = mapData } } ; } return(controlData); }