/// <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>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> /// returns the clicked control on the task /// </summary> public MgControlBase getClickedControl() { MgControlBase clickedCtrl = Manager.GetCurrentRuntimeContext().CurrentClickedCtrl; if (clickedCtrl != null && clickedCtrl.getForm().getTask() != this) { clickedCtrl = null; } return(clickedCtrl); }
/// <summary> /// set the last focused control and the task for current window. /// </summary> /// <param name="task"></param> /// <param name="MgControlBase"></param> internal static void setLastFocusedControl(Task task, MgControlBase mgControl) { int currMgdID; currMgdID = task.getMgdID(); Debug.Assert(mgControl == null || task == mgControl.getForm().getTask()); LastFocusMgdID = currMgdID; setLastFocusedControlAt(mgControl, currMgdID); ClientManager.Instance.setLastFocusedTask(task); }
/// <summary> /// /// </summary> /// <param name="control"></param> /// <param name="properties"></param> static void BuildFormNameProperty(MgControlBase control, Dictionary <string, DesignerPropertyInfo> properties) { MgFormBase form = control.GetSubformMgForm(); if (form == null) { form = control.getForm(); } String controlsPersistencyPath = EnvControlsPersistencyPath.GetInstance().GetFullControlsPersistencyFileName(form); properties.Add(Constants.ConfigurationFilePropertyName, new DesignerPropertyInfo() { VisibleInPropertyGrid = true, Value = controlsPersistencyPath, IsNativeProperty = false }); }
/// <summary> /// Set read only for controls /// </summary> /// <param name = "ctrl">the control to change its property </param> /// <param name = "isReadOnly">boolean </param> internal static void SetReadOnlyControl(MgControlBase ctrl, bool isReadOnly) { if (ctrl.isTextOrTreeControl() || ctrl.isRichEditControl() || ctrl.isRichText() || ctrl.IsRepeatable) // Defect 131802: Set ReadOnly for Rich Text control in Table Header and defect 131704: in general for Rich Text. { // JPN: IME support (enable IME in query mode) if (UtilStrByteMode.isLocaleDefLangDBCS() && !ctrl.isTreeControl() && !ctrl.isMultiline()) { if (ctrl.getForm().getTask().checkProp(PropInterface.PROP_TYPE_ALLOW_LOCATE_IN_QUERY, false)) { return; } } Commands.addAsync(CommandType.PROP_SET_READ_ONLY, ctrl, ctrl.getDisplayLine(false), isReadOnly); Commands.beginInvoke(); } }
/// <summary> /// createMenu This method creates the gui commands in order to create the matching menu object. First we /// create a GUI command which verifies the object will have a menu definition (either he already has one or /// we will create it). Then it calls the CreateSubMenuObject in order to create the actual menu. /// </summary> /// <param name = "form"></param> /// <param name = "menuStyle"></param> public void createMenu(MgFormBase form, MenuStyle menuStyle) { int i; MgFormBase actualForm = form; if (form.isSubForm()) { MgControlBase subformCtrl = form.getSubFormCtrl(); actualForm = subformCtrl.getForm().getTopMostForm(); } // #991912. We will create menus anyway even though showMenu on the foem is false. so that when they are // later accessed with Access key, we can find the menus. The actual SWT menus will be created only // if Showmenu (MGFrom.shouldShowPullDownMenu()) is TRUE. setMenuIsInstantiated(actualForm, menuStyle); Commands.addAsync(CommandType.CREATE_MENU, null, actualForm, menuStyle, this, true, actualForm.ShouldShowPullDownMenu); actualForm.addMgMenuToList(this, menuStyle); //We are initializing window list menu items for context menu if (menuStyle == MenuStyle.MENU_STYLE_CONTEXT) { for (i = 0; i < _menuEntries.Count; i++) { if (((GuiMenuEntry)_menuEntries[i]).menuType() == GuiMenuEntry.MenuType.WINDOW_MENU_ENTRY) { Events.InitWindowListMenuItems(actualForm, _menuEntries[i], menuStyle); break;//We should initialize the Window List only once } } } for (i = 0; i < _menuEntries.Count; i++) { _menuEntries[i].createMenuEntryObject(this, menuStyle, actualForm, false); } refreshMenuAction(form, menuStyle); if (menuStyle == MenuStyle.MENU_STYLE_CONTEXT) { Commands.invoke(); } }
/// <summary> /// update the display /// </summary> public void updateDisplay(String displayValue, bool isNull, bool calledFromEditSet) { MgControlBase ctrl; MgControlBase ctrlValue = null; String defaultValue = "" + GuiConstants.DEFAULT_VALUE_INT; String savedValue = null; String savePrevValue = null; bool savedIsNull = false; bool savePrevIsNull = false; if (_controls != null) { MgControlBase firstControlValue = null; bool foundControlValue = false; MgControlBase savedControlToFocus = ControlToFocus; for (int i = 0; i < _controls.getSize(); i++) { ctrl = _controls.getCtrl(i); if (calledFromEditSet) { savedValue = ctrl.Value; savePrevValue = ctrl.getPrevValueInArray(ctrl.getDisplayLine(true)); savedIsNull = ctrl.IsNull; savePrevIsNull = ctrl.getPrevIsNullsInArray(); } if (!ctrl.getForm().inRefreshDisplay()) { ctrl.resetPrevVal(); // force update of the display ctrl.SetAndRefreshDisplayValue(displayValue, isNull, false); // Even if the control that contains the correct value is found we don't break the loop because: // (1) we need to refresh all the controls // (2) the last control that was focus with the correct value is the one that should be checked if (!ctrl.isRadio()) { if (ctrlValue == null || ctrl.Value != null && !ctrl.Value.Equals(defaultValue) && (ctrl == savedControlToFocus)) { ctrlValue = ctrl; } } else { //Fixed bug#:780359, for radio control select the correct control //if not found any ctrlvalue(the control that was in focuse) //select the first control with the correct value if not exist select the first control. //a. save the first control (with or without the correct value) if (firstControlValue == null) { firstControlValue = ctrl; } if (ctrl.Value != null && !ctrl.Value.Equals(defaultValue)) { //b. save the first control with the correct value if (!foundControlValue) { firstControlValue = ctrl; foundControlValue = true; } //c.save the control that belong to the focus control if (ctrl == savedControlToFocus) { ctrlValue = ctrl; } else if (ctrlValue == null) { ctrlValue = firstControlValue; } } } } if (calledFromEditSet) { ctrl.setValueForEditSet(savedValue, savePrevValue, savedIsNull, savePrevIsNull); } } // if there was a control that had the correct value and this field is linked to more than one // control then it means that the control that contained the correct value might have been reset by // one of its siblings so there is a need to refresh its value again. if (ctrlValue != null) { if (calledFromEditSet) { savedValue = ctrlValue.Value; savePrevValue = ctrlValue.getPrevValueInArray(ctrlValue.getDisplayLine(true)); savedIsNull = ctrlValue.IsNull; savePrevIsNull = ctrlValue.getPrevIsNullsInArray(); } //save the control that belong to the value on the field. ControlToFocus = ctrlValue; if (_controls.getSize() > 1) { ctrlValue.resetPrevVal(); // force update of the display ctrlValue.SetAndRefreshDisplayValue(displayValue, isNull, false); } if (calledFromEditSet) { ctrlValue.setValueForEditSet(savedValue, savePrevValue, savedIsNull, savePrevIsNull); ctrlValue.getForm().getTask().setLastParkedCtrl(ctrlValue); Manager.SetFocus(ctrlValue, -1); } //Fixed bug#:465616, when the control is the current focus control then refresh his focus control if (ctrlValue.isRadio() && ctrlValue == ctrlValue.getForm().getTask().getLastParkedCtrl()) { Manager.SetFocus(ctrlValue, -1); } } } }
/// <summary> /// getDefaultValue returns the default value of a property /// </summary> /// <param name = "propId">The property id</param> /// <param name = "parentType">PARENT_TYPE_CONTROL, PARENT_TYPE_FORM, PARENT_TYPE_TASK</param> /// <param name = "propParent">TODO</param> /// <returns> The property default value String representation</returns> internal static String getDefaultValue(int propId, char parentType, PropParentInterface propParent) { String val = null; MgControlBase control = null; if (parentType == GuiConstants.PARENT_TYPE_TASK) { bool handled; val = getDefaultValueForTask(propId, parentType, propParent, out handled); if (handled) { return(val); } } if (parentType == GuiConstants.PARENT_TYPE_CONTROL) { control = (MgControlBase)propParent; if (control.IsDotNetControl()) { //.NET control does not have most of the default properties, //these are the only properties that it supports switch (propId) { case PropInterface.PROP_TYPE_ENABLED: case PropInterface.PROP_TYPE_VISIBLE: case PropInterface.PROP_TYPE_ALLOW_PARKING: case PropInterface.PROP_TYPE_TAB_IN: case PropInterface.PROP_TYPE_MODIFIABLE: case PropInterface.PROP_TYPE_DATAVIEWCONTROL: case PropInterface.PROP_TYPE_LAYER: break; default: return(null); } } } switch (propId) { case PropInterface.PROP_TYPE_COLOR: val = getNumericMgValue(propParent, "1"); if (parentType == GuiConstants.PARENT_TYPE_CONTROL) { control = (MgControlBase)propParent; if (control.Type == MgControlType.CTRL_TYPE_BUTTON && control.IsImageButton()) { val = getNumericMgValue(propParent, "0"); } } else if (parentType == GuiConstants.PARENT_TYPE_FORM) { if (((MgFormBase)propParent).IsMDIFrame) { val = getNumericMgValue(propParent, "0"); } } break; case PropInterface.PROP_TYPE_BORDER: val = "0"; // no boolean if (parentType == GuiConstants.PARENT_TYPE_CONTROL) { control = (MgControlBase)propParent; switch (control.Type) { case MgControlType.CTRL_TYPE_SUBFORM: // only for subform that is son of frame set don't create border. // Sub form that is not frame, n if (control.getForm().IsFrameSet) { Object parent = control.getParent(); if (parent is MgControlBase) { MgControlBase mgControl = (MgControlBase)parent; if (mgControl.Type == MgControlType.CTRL_TYPE_FRAME_SET) { return(val); } } } //fixed bug #777633, the default value of subform control is No and not Yes val = "0"; // no boolean break; case MgControlType.CTRL_TYPE_TEXT: case MgControlType.CTRL_TYPE_TABLE: case MgControlType.CTRL_TYPE_LIST: case MgControlType.CTRL_TYPE_TREE: case MgControlType.CTRL_TYPE_BROWSER: val = "1"; // yes boolean break; } } break; case PropInterface.PROP_TYPE_AUTO_WIDE: case PropInterface.PROP_TYPE_MAXBOX: case PropInterface.PROP_TYPE_MINBOX: case PropInterface.PROP_TYPE_MUST_INPUT: case PropInterface.PROP_TYPE_MULTILINE: case PropInterface.PROP_TYPE_PASSWORD: case PropInterface.PROP_TYPE_HEBREW: case PropInterface.PROP_TYPE_MULTILINE_VERTICAL_SCROLL: case PropInterface.PROP_TYPE_MULTILINE_ALLOW_CR: case PropInterface.PROP_TYPE_IS_CACHED: case PropInterface.PROP_TYPE_MODIFY_IN_QUERY: case PropInterface.PROP_TYPE_SHOW_FULL_ROW: case PropInterface.PROP_TYPE_TRACK_SELECTION: case PropInterface.PROP_TYPE_COLUMN_DIVIDER: case PropInterface.PROP_TYPE_LINE_DIVIDER: case PropInterface.PROP_TYPE_THREE_STATES: case PropInterface.PROP_TYPE_REFRESH_WHEN_HIDDEN: case PropInterface.PROP_TYPE_RETAIN_FOCUS: case PropInterface.PROP_TYPE_ROW_PLACEMENT: case PropInterface.PROP_TYPE_SHOW_IN_WINDOW_MENU: case PropInterface.PROP_TYPE_DATAVIEWCONTROL: case PropInterface.PROP_TYPE_SORT_COLUMN: case PropInterface.PROP_TYPE_BEFORE_900_VERSION: case PropInterface.PROP_TYPE_FILL_WIDTH: case PropInterface.PROP_TYPE_MULTI_COLUMN_DISPLAY: val = "0"; // no boolean break; case PropInterface.PROP_TYPE_SYSTEM_MENU: case PropInterface.PROP_TYPE_TITLE_BAR: case PropInterface.PROP_TYPE_ENABLED: case PropInterface.PROP_TYPE_VISIBLE: case PropInterface.PROP_TYPE_ALLOW_PARKING: case PropInterface.PROP_TYPE_TAB_IN: case PropInterface.PROP_TYPE_MODIFIABLE: case PropInterface.PROP_TYPE_HIGHLIGHTING: case PropInterface.PROP_TYPE_AUTO_REFRESH: case PropInterface.PROP_TYPE_PARK_ON_CLICK: case PropInterface.PROP_TYPE_DISPLAY_MENU: case PropInterface.PROP_TYPE_DISPLAY_TOOLBAR: case PropInterface.PROP_TYPE_SHOW_BUTTONS: case PropInterface.PROP_TYPE_LINES_AT_ROOT: case PropInterface.PROP_TYPE_SCROLL_BAR: case PropInterface.PROP_TYPE_SHOW_LINES: case PropInterface.PROP_TYPE_ALLOW_QUERY: case PropInterface.PROP_TYPE_RIGHT_BORDER: case PropInterface.PROP_TYPE_TOP_BORDER: case PropInterface.PROP_TYPE_TOP_BORDER_MARGIN: case PropInterface.PROP_TYPE_SHOW_ELLIPISIS: val = "1"; // yes boolean break; // all those properties need not create a default case PropInterface.PROP_TYPE_TRIGGER: case PropInterface.PROP_TYPE_PROMPT: case PropInterface.PROP_TYPE_DISPLAY_LIST: case PropInterface.PROP_TYPE_DATA: case PropInterface.PROP_TYPE_IMAGE_FILENAME: case PropInterface.PROP_TYPE_LABEL: case PropInterface.PROP_TYPE_PLACEMENT: case PropInterface.PROP_TYPE_PULLDOWN_MENU: case PropInterface.PROP_TYPE_CONTEXT_MENU: case PropInterface.PROP_TYPE_NODE_ID: case PropInterface.PROP_TYPE_NODE_PARENTID: case PropInterface.PROP_TYPE_SELECT_PROGRAM: case PropInterface.PROP_TYPE_VISIBLE_LAYERS_LIST: case PropInterface.PROP_TYPE_EXPANDED_IMAGEIDX: case PropInterface.PROP_TYPE_COLLAPSED_IMAGEIDX: case PropInterface.PROP_TYPE_OBJECT_TYPE: case PropInterface.PROP_TYPE_TAB_ORDER: case PropInterface.PROP_TYPE_LOAD_IMAGE_FROM: case PropInterface.PROP_TYPE_FORM_NAME: case PropInterface.PROP_TYPE_COLUMN_TITLE: case PropInterface.PROP_TYPE_HEIGHT: case PropInterface.PROP_TYPE_WIDTH: case PropInterface.PROP_TYPE_ROW_HIGHLIGHT_COLOR: case PropInterface.PROP_TYPE_PRGTSK_NUM: break; case PropInterface.PROP_TYPE_MULTILINE_WORDWRAP_SCROLL: // 2- HORIZONTAL_SCROLL_NO case PropInterface.PROP_TYPE_AUTO_FIT: // AUTO_FIT_AS_CONTROL case PropInterface.PROP_TYPE_BORDER_STYLE: // BORDER_TYPE_THICK val = getNumericMgValue(propParent, "2"); break; case PropInterface.PROP_TYPE_WINDOW_TYPE: // WINDOW_TYPE_MODAL val = getNumericMgValue(propParent, "6"); break; case PropInterface.PROP_TYPE_ROW_HIGHLIGHT_STYLE: val = getNumericMgValue(propParent, "4"); //HIGHLIGHT_BACKGROUND_CONTROLS break; case PropInterface.PROP_TYPE_GRADIENT_STYLE: case PropInterface.PROP_TYPE_TABBING_ORDER: case PropInterface.PROP_TYPE_STARTUP_MODE: // 1.DEFAULT case PropInterface.PROP_TYPE_CHOICE_COLUMNS: // 1 case PropInterface.PROP_TYPE_HORIZONTAL_ALIGNMENT: // 1 ALIGNMENT_TYPE_HORI_LEFT case PropInterface.PROP_TYPE_STARTUP_POSITION: // 1 WIN_POS_CUSTOMIZED case PropInterface.PROP_TYPE_FONT: // 1 case PropInterface.PROP_TYPE_WALLPAPER_STYLE: // CTRL_IMAGE_STYLE_TILED case PropInterface.PROP_TYPE_CHECKBOX_MAIN_STYLE: // CHECKBOX_MAIN_STYLE_BOX case PropInterface.PROP_TYPE_TAB_CONTROL_SIDE: // SIDE_TYPE_TOP: case PropInterface.PROP_TYPE_RAISE_AT: case PropInterface.PROP_TYPE_ALLOWED_DIRECTION: case PropInterface.PROP_TYPE_SUBFORM_TYPE: case PropInterface.PROP_TYPE_UOM: case PropInterface.PROP_TYPE_BOTTOM_POSITION_INTERVAL: val = getNumericMgValue(propParent, "1"); break; case PropInterface.PROP_TYPE_TASK_PROPERTIES_TRANSACTION_MODE: val = TransMode.Physical.ToString(); break; case PropInterface.PROP_TYPE_PARKED_COLLAPSED_IMAGEIDX: case PropInterface.PROP_TYPE_PARKED_IMAGEIDX: case PropInterface.PROP_TYPE_MINIMUM_HEIGHT: case PropInterface.PROP_TYPE_TOP: case PropInterface.PROP_TYPE_LEFT: case PropInterface.PROP_TYPE_TITLE_HEIGHT: case PropInterface.PROP_TYPE_LAYER: // Layer case PropInterface.PROP_TYPE_VISIBLE_LINES: case PropInterface.PROP_TYPE_FRAMESET_STYLE: case PropInterface.PROP_TYPE_TRANSLATOR: case PropInterface.PROP_TYPE_HOR_FAC: case PropInterface.PROP_TYPE_VER_FAC: case PropInterface.PROP_TYPE_FOCUS_COLOR: val = getNumericMgValue(propParent, "0"); break; case PropInterface.PROP_TYPE_STYLE_3D: if (parentType == GuiConstants.PARENT_TYPE_CONTROL) { control = (MgControlBase)propParent; switch (control.Type) { case MgControlType.CTRL_TYPE_COMBO: val = getNumericMgValue(propParent, "2"); // CTRL_DIM_3D break; case MgControlType.CTRL_TYPE_RADIO: case MgControlType.CTRL_TYPE_CHECKBOX: val = getNumericMgValue(propParent, "3"); // CTRL_DIM_3D_SUNKEN break; } } break; case PropInterface.PROP_TYPE_DEFAULT_BUTTON: case PropInterface.PROP_TYPE_IMAGE_LIST_INDEXES: case PropInterface.PROP_TYPE_WALLPAPER: case PropInterface.PROP_TYPE_TEXT: case PropInterface.PROP_TYPE_TOOLTIP: case PropInterface.PROP_TYPE_FORMAT: val = String.Empty; break; case PropInterface.PROP_TYPE_IMAGE_STYLE: val = getNumericMgValue(propParent, "2"); // CTRL_IMAGE_STYLE_COPIED break; case PropInterface.PROP_TYPE_SELECTION_MODE: val = getNumericMgValue(propParent, ((int)ListboxSelectionMode.Single).ToString()); break; case PropInterface.PROP_TYPE_INDEX: case PropInterface.PROP_TYPE_LINK_FIELD: case PropInterface.PROP_TYPE_DISPLAY_FIELD: case PropInterface.PROP_TYPE_PERSISTENT_FORM_STATE_VERSION: val = getNumericMgValue(propParent, "0"); break; default: #if DEBUG Debug.Assert(false, "Undefined default value", String.Format("No default value was defined for property {0} ({1}).", Property.GetPropertyName(propId), propId)); // throw new Error("In getDefaultValue prop id " + propId + "does not exist"); #endif break; } return(val); }
/// <summary> returns if ContextMenu is allowed </summary> /// <param name="guiMgControl"></param> private bool isContextMenuAllowed(GuiMgControl guiMgControl) { MgControlBase mgControl = (MgControlBase)guiMgControl; return(mgControl.getForm().getTask().IsInteractive); }
/// <summary> /// set the focus to the specified control /// </summary> /// <param name = "ctrl"></param> /// <param name = "line"></param> public static void SetFocus(MgControlBase ctrl, int line) { SetFocus(ctrl.getForm().getTask(), ctrl, line, true); }