/// <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> /// 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> 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 }
/// <summary> This method returns the current context menu. In case a context menu is not set on the object itself, we /// get the parent's context menu /// </summary> internal ContextMenu getContextMenu() { ControlsMap controlsMap = ControlsMap.getInstance(); ContextMenu ret = base.ContextMenu; if (ret == null) { GuiMgMenu contextMenu = Events.OnGetContextMenu(GuiMgControl); if (contextMenu != null) { Form form = GuiUtils.FindForm(_tableControl); MapData mapData = controlsMap.getFormMapData(form); MenuReference menuRefernce = contextMenu.getInstantiatedMenu(mapData.getForm(), MenuStyle.MENU_STYLE_CONTEXT); ret = (ContextMenu)controlsMap.object2Widget(menuRefernce); } } return(ret); }
/// <summary> /// /// </summary> /// <param name="type"></param> /// <param name="sender"></param> /// <param name="e"></param> /// <param name="mapData"></param> internal void handleEvent(EventType type, Control sender, EventArgs e, MapData mapData) { MapData orgMapData = mapData; ContainerManager containerManager = GuiUtils.getContainerManager(sender); switch (type) { #if !PocketPC case EventType.DRAG_OVER: case EventType.DRAG_DROP: // Need to get current Control, Hence needed Point pt = new Point(((DragEventArgs)e).X, ((DragEventArgs)e).Y); Point screen = sender.PointToClient(pt); mapData = containerManager.HitTest(screen, true, false); break; #endif case EventType.MOUSE_MOVE: // the mouse move will handle the tooltip mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, false); break; case EventType.NCMOUSE_DOWN: MapData containerMapData = ControlsMap.getInstance().getMapData(sender); Events.OnMouseDown(containerMapData.getForm(), containerMapData.getControl(), null, true, 0, true, true); break; case EventType.MOUSE_DOWN: // check if a point on some table child // fixed bug #986057 (same in online) // * when pressing Rclick(button != 1) on Table or on the divider the Table's Context Menu will be // display( if press on other row no focus will move to the new row) // * when pressing Rclick exactly edit the context menu of the edit will be display and the focus // will move to the control bool LeftClickWasPressed = ((MouseEventArgs)e).Button == MouseButtons.Left; bool findExact = (sender is TableControl && LeftClickWasPressed ? false : true); mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), findExact, true); if (mapData != null) { // Defect# 130085: When we click on a control (say checkbox) placed on table header, mouseDown is not needed to be processed. // Actually, this is received from WM_PARENTNOTIFY from TableControl. This will avoid multiple ACT_CTRL_HIT on table header child // control and Table control. Another option was to set WS_EX_NOPARENTNOTIFY style to table header child. GuiMgControl mgControl = mapData.getControl(); if (mgControl.IsTableHeaderChild) { return; } // mark that we need to focus on the control GuiUtils.saveFocusingControl(GuiUtils.FindForm(sender), mapData); } else if (sender is TableControl) { GuiUtils.restoreFocus(GuiUtils.FindForm(sender)); } break; case EventType.MOUSE_UP: // for mouse up we need control the has been clicked and not nearest control mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, true); break; case EventType.MOUSE_DBLCLICK: if (!(sender is TableControl)) //TODO { mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, true); } break; case EventType.PRESS: findExact = !(sender is TableControl); // Mobile clients for which this event type is applicable must // pass actual press co-ords Point point = new Point(0, 0); mapData = containerManager.HitTest(point, findExact, true); if (mapData != null) { GuiUtils.saveFocusingControl(GuiUtils.FindForm(sender), mapData); } break; case EventType.PAINT: if (containerManager is BasicControlsManager) { ((BasicControlsManager)containerManager).Paint(((PaintEventArgs)e).Graphics); } break; #if PocketPC case EventType.RESIZE: EditorSupportingPlacementLayout placementLayout1 = ((TagData)sender.Tag).PlacementLayout; if (placementLayout1 != null) { LayoutEventArgs le = new LayoutEventArgs(); placementLayout1.layout(sender, le); } break; #endif case EventType.LAYOUT: EditorSupportingPlacementLayout placementLayout = ((TagData)sender.Tag).PlacementLayout; if (placementLayout != null) { placementLayout.layout(sender, (LayoutEventArgs)e); } break; case EventType.DISPOSED: containerManager.Dispose(); break; } if (mapData == null) { mapData = orgMapData; } DefaultHandler.getInstance().handleEvent(type, sender, e, mapData); }
/// <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; } Object guiMgObject = mapData.getControl(); if (guiMgObject == null) { guiMgObject = mapData.getForm(); } var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgObject)); try { switch (type) { #if !PocketPC case EventType.SCROLL: { if (sender is ScrollableControl) { ScrollableControl scrollableControl = sender as ScrollableControl; TagData tg = (TagData)scrollableControl.Tag; if (scrollableControl.BackgroundImage != null) { scrollableControl.Invalidate(); } else { //This is a.Net bug. When scrollbar gets hidden during the process of thumb drag, framework still keeps //a rectangular bar visible to keep dragging on. Now, this rectangle is not removed even when the scrolling is stopped. //The workaround is to repaint the form if scrollbar is not present on the form when scroll dragging is stopped. ScrollEventArgs se = (ScrollEventArgs)e; if (se.Type == ScrollEventType.ThumbPosition) { bool hasVerticalScrollBar = scrollableControl.AutoScrollMinSize.Height > scrollableControl.ClientSize.Height; if (!hasVerticalScrollBar) { scrollableControl.Invalidate(); } } } } } break; #endif case EventType.RESIZE: onResize((Control)sender); break; } DefaultContainerHandler.getInstance().handleEvent(type, sender, e); #if PocketPC // paint the subform's border. Do it after the controls are painted, so we can paint over them. if (type == EventType.PAINT && ((MgPanel)sender).BorderStyle != BorderStyle.None) { BorderRenderer.PaintBorder(((PaintEventArgs)e).Graphics, ((Control)sender).ClientRectangle, Color.Black, ControlStyle.Windows, false); } #endif } finally { contextIDGuard.Dispose(); } }
/// <summary> handle the context of a control /// /// </summary> /// <param name="widget">: /// is the widget of the control \ tab \ table /// </param> /// <param name="ctrl"> /// </param> public void handleContext(Control control, GuiMgControl guiMgControl, GuiMgForm guiMgForm) { ControlsMap controlsMap = ControlsMap.getInstance(); GuiMgMenu contextMenu = null; ContextMenuStrip menu = null; ContextMenuStrip prevMenu = control.ContextMenuStrip; GuiMgForm controlsForm = guiMgForm; if (guiMgControl != null) { // save the form that holds the control. if (guiMgControl.isSubform()) { controlsForm = guiMgForm; } else { controlsForm = guiMgControl.GuiMgForm; } contextMenu = Events.OnGetContextMenu(guiMgControl); Form form = GuiUtils.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 = (ContextMenuStrip)controlsMap.object2Widget(menuRefernce); } // Fix bug#:927653, problem #2, when set context menu to the control need to refresh the event on the context menu // because on MgForm :instatiatedMenus is one per form per style (the style is the key) and it keeps only the menu // created for the last child of the form. // Qcr #909188 : Use the controlsForm to refresh menus action and not the 'form' which might be topmost. // The reason is that the form sent to OnRefreshMenuActions has to point to the task that holds the // control because it holds the relevant 'Action manager'. An action enabled for the control , might be disabled // in the top most form's task and be wrongly disabled in the context menu. if (controlsForm != null) { Events.OnRefreshMenuActions(contextMenu, controlsForm); } if (menu != prevMenu) { GuiUtils.setContextMenu(control, menu); //Save the control on which context menu is invoked. This is required later for creating dummy context menu. if (menu != null) { ((TagData)menu.Tag).MouseDownOnControl = control; } } }
internal override void handleEvent(EventType type, Object sender, EventArgs e) { ControlsMap controlsMap = ControlsMap.getInstance(); UtilImeJpn utilImeJpn = Manager.UtilImeJpn; TextBox textCtrl = (TextBox)sender; int start; int end; MapData mapData = controlsMap.getMapData(textCtrl); if (mapData == null) { return; } GuiMgControl guiMgCtrl = mapData.getControl(); GuiMgForm guiMgForm = mapData.getForm(); var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgCtrl)); if (Events.ShouldLog(Logger.LogLevels.Gui)) { Events.WriteGuiToLog("TextBoxHandler(\"" + mapData.getControl().getName(mapData.getIdx()) + "\"): " + type); } try { switch (type) { case EventType.GOT_FOCUS: // check the paste enable. check the clip content. if (mapData != null) { GuiUtils.checkPasteEnable(mapData.getControl(), true); GuiUtils.SetFocusColor(textCtrl); } break; case EventType.LOST_FOCUS: // Always disable paste when exiting a text ctrl. (since we might be focusing on a diff type of // ctrl). if (mapData != null) { GuiUtils.disablePaste(mapData.getControl()); GuiUtils.ResetFocusColor(textCtrl); } break; case EventType.KEY_UP: GuiUtils.enableDisableEvents(sender, mapData.getControl()); return; case EventType.KEY_DOWN: KeyEventArgs keyEventArgs = (KeyEventArgs)e; if (ShouldBeHandledByTextBox(textCtrl, keyEventArgs)) { GuiUtils.checkAutoWide(mapData.getControl(), textCtrl, GuiUtils.getValue(textCtrl)); keyEventArgs.Handled = false; return; } break; case EventType.IME_EVENT: // (Korean) IME messages (WM_IME_COMPOSITION, etc.) are handled as pseudo-input // where action=MG_ACT_CHAR, text=" ". // To distinguish with real " ", ImeParam im is attached to RuntimeEvent. ImeEventArgs iea = (ImeEventArgs)e; start = textCtrl.SelectionStart; end = textCtrl.SelectionStart + textCtrl.SelectionLength; Events.OnKeyDown(guiMgForm, guiMgCtrl, Modifiers.MODIFIER_NONE, 0, start, end, " ", iea.im, true, "-1", false, iea.Handled); iea.Handled = true; break; case EventType.KEY_PRESS: KeyPressEventArgs keyPressEventArgs = (KeyPressEventArgs)e; // skipp control key if (Char.IsControl(keyPressEventArgs.KeyChar)) { return; } start = textCtrl.SelectionStart; end = textCtrl.SelectionStart + textCtrl.SelectionLength; String pressedChar = "" + keyPressEventArgs.KeyChar; // flag the isActChar to indicate this is MG_ACT_CHAR Events.OnKeyDown(guiMgForm, guiMgCtrl, Modifiers.MODIFIER_NONE, 0, start, end, pressedChar, true, "-1", keyPressEventArgs.Handled); keyPressEventArgs.Handled = true; break; case EventType.MOUSE_UP: GuiUtils.enableDisableEvents(sender, mapData.getControl()); break; case EventType.CUT: Events.CutEvent(mapData.getControl()); return; case EventType.COPY: Events.CopyEvent(mapData.getControl()); return; case EventType.PASTE: Events.PasteEvent(mapData.getControl()); return; case EventType.CLEAR: Events.ClearEvent(mapData.getControl()); return; case EventType.UNDO: Events.UndoEvent(mapData.getControl()); return; case EventType.STATUS_TEXT_CHANGED: // JPN: ZIMERead function if (utilImeJpn != null && sender is MgTextBox && !utilImeJpn.IsEditingCompStr((Control)sender)) { utilImeJpn.StrImeRead = ((MgTextBox)sender).GetCompositionString(); } return; } } finally { contextIDGuard.Dispose(); } DefaultHandler.getInstance().handleEvent(type, sender, e); }
/* (non-Javadoc) * @see org.eclipse.swt.widgets.Handler#handleEvent(org.eclipse.swt.widgets.Event) */ internal override void handleEvent(EventType type, Object sender, EventArgs e) { ControlsMap controlsMap = ControlsMap.getInstance(); RichTextBox richTextCtrl = (RichTextBox)sender; MapData mapData = controlsMap.getMapData(richTextCtrl); if (mapData == null) { return; } GuiMgControl ctrl = mapData.getControl(); GuiMgForm guiMgForm = mapData.getForm(); UtilImeJpn utilImeJpn = Manager.UtilImeJpn; // JPN: IME support var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(ctrl)); try { switch (type) { case EventType.GOT_FOCUS: // check the paste enable. check the clip content. if (mapData != null) { GuiUtils.checkPasteEnable(mapData.getControl(), true); } // For RichEdit Ctrl, Set AcceptButton(i.e. DefaultButton) to null in order to allow enter key on RichEdit control. if (sender is MgRichTextBox) { Form form = GuiUtils.FindForm(richTextCtrl); form.AcceptButton = null; if (((MgRichTextBox)sender).ReadOnly) { GuiUtils.restoreFocus(form); } } break; case EventType.LOST_FOCUS: // Always disable paste when exiting a text ctrl. (since we might be focusing on a diff type of // ctrl). if (mapData != null) { GuiUtils.disablePaste(mapData.getControl()); } break; case EventType.KEY_UP: // Korean if (sender is MgRichTextBox && ((MgRichTextBox)sender).KoreanInterimSel >= 0) { return; } if (utilImeJpn != null) { if (utilImeJpn.IsEditingCompStr(richTextCtrl)) // JPN: IME support { return; } if (richTextCtrl is MgRichTextBox) // JPN: ZIMERead function { utilImeJpn.StrImeRead = ((MgRichTextBox)richTextCtrl).GetCompositionString(); } } GuiUtils.enableDisableEvents(sender, mapData.getControl()); return; case EventType.KEY_DOWN: // Korean if (sender is MgRichTextBox && ((MgRichTextBox)sender).KoreanInterimSel >= 0) { return; } if (utilImeJpn != null && utilImeJpn.IsEditingCompStr(richTextCtrl)) // JPN: IME support { return; } KeyEventArgs keyEventArgs = (KeyEventArgs)e; // marking the text (next/prev char or beg/end text) we let the // system to take care of it. // why ? There is no way in windows to set the caret at the beginning of // a selected text. it works only on multi mark for some reason. // also posting a shift+key does not work well since we have no way of knowing // if the shift is already pressed or not. // *** ALL other keys will continue to handleEvent. if ((keyEventArgs.Shift && (keyEventArgs.KeyCode == Keys.Left || keyEventArgs.KeyCode == Keys.Right || keyEventArgs.KeyCode == Keys.Up || keyEventArgs.KeyCode == Keys.Down || keyEventArgs.KeyCode == Keys.Home || keyEventArgs.KeyCode == Keys.End)) || (keyEventArgs.Control && (keyEventArgs.KeyCode == Keys.Left || keyEventArgs.KeyCode == Keys.Right))) { keyEventArgs.Handled = false; return; } break; case EventType.KEY_PRESS: KeyPressEventArgs keyPressEventArgs = (KeyPressEventArgs)e; bool IgnoreKeyPress = ((TagData)richTextCtrl.Tag).IgnoreKeyPress; // should we ignore the key pressed ? if (IgnoreKeyPress) { ((TagData)richTextCtrl.Tag).IgnoreKeyPress = false; return; } // skipp control key if (Char.IsControl(keyPressEventArgs.KeyChar)) { return; } int start = richTextCtrl.SelectionStart; int end = richTextCtrl.SelectionStart + richTextCtrl.SelectionLength; String pressedChar = "" + keyPressEventArgs.KeyChar; // flag the isActChar to indicate this is MG_ACT_CHAR Events.OnKeyDown(guiMgForm, ctrl, Modifiers.MODIFIER_NONE, 0, start, end, pressedChar, true, "-1", keyPressEventArgs.Handled); // keyPressEventArgs.Handled wii stay 'false' in order to let the system put the correct char. // What will happen is 2 things : 1. processKeyDown will add 'MG_ACT_CHAR'. 2. The system will write the char. // In the past, the 'ACT_CHAR' was using sendKeys in order to write the char, but it makes problems in multilanguage systems. // So, in TextMaskEditor for rich , ACT_CHAR will do nothing, just pass there in order to rais the 'control modify'. //keyPressEventArgs.Handled = true; break; case EventType.MOUSE_UP: GuiUtils.enableDisableEvents(sender, mapData.getControl()); break; } } finally { contextIDGuard.Dispose(); } DefaultHandler.getInstance().handleEvent(type, sender, e); }