Пример #1
0
 internal Layout(Widget parent, FString name, String file_name, bool visible)
 {
     mFileName = file_name;
     mLayoutName = name;
     mVisible = visible;
     mParent = parent;
 }
Пример #2
0
 private static void onEvent(Widget widget, EventArg arg)
 {
     switch (arg.EventType)
     {
         case EventType.MouseButtonClick:
             Widget.OnMouseButtonClick(widget, arg);
             break;
     }
 }
Пример #3
0
 public bool TryGetWidget(Instance widget_inst, out Widget widget)
 {
     foreach (KeyValuePair<FString, Widget> item in mWidgetTable)
     {
         if (item.Value.Instance == widget_inst)
         {
             widget = item.Value;
             return true;
         }
     }
     widget = null;
     return false;
 }
Пример #4
0
 internal ItemInfo(Widget parent, Widget item)
 {
     mParent = parent;
     mItem = item;
 }
Пример #5
0
 internal int GetIndexByWidget(Widget widget)
 {
     uint index = ICall_getIndexByWidget(mInstance.Ptr, widget.Instance.Ptr);
     if (index >= ItemCount)
     {
         return Util.UNVALID_COUNT;
     }
     return (int)index;
 }
Пример #6
0
 internal void Clear()
 {
     mParent = null;
     mItem = null;
     mLayoutName = null;
 }
Пример #7
0
        // ----------------------- 模板,勿删 -----------------------------------------
        //internal static void On(Widget widget, EventArg arg)
        //{
        //    widget.mHandle(widget.Name);
        //}
        //internal event Event. Event
        //{
        //    add
        //    {
        //        if (null == )
        //        {
        //            if (ICall_appendEvent(this, mInstance.Ptr, EventType.))
        //            {
        //                += value;
        //            }
        //        }
        //    }
        //    remove
        //    {
        //        -= value;
        //        if (null == )
        //        {
        //            ICall_removeEvent(this, mInstance.Ptr, EventType.);
        //        }
        //    }
        //}
        //protected Event. mHandle;
        private static unsafe void onEvent(Widget widget, IntPtr int_ptr)
        {
            EventArg arg = Util.PtrToStruct<EventArg>(int_ptr);
            switch (arg.EventType)
            {
                case EventType.MouseButtonClick:
                    {
                        Widget.OnMouseButtonClick(widget, Util.PtrToStruct<EventArg>(int_ptr));//
                    }
                    break;
                case EventType.MouseButtonPressed:
                    {
                        Widget.OnMouseButtonPressed(widget, Util.PtrToStruct<MouseButtonEventArg>(int_ptr));
                    }
                    break;
                case EventType.MouseButtonReleased:
                    {
                        Widget.OnMouseButtonReleased(widget, Util.PtrToStruct<MouseButtonEventArg>(int_ptr));
                    }
                    break;
                case EventType.MouseButtonDoubleClick:
                    {
                        Widget.OnMouseButtonDoubleClick(widget, Util.PtrToStruct<EventArg>(int_ptr));
                    }
                    break;
                case EventType.MouseLostFocus:
                    {
                        Widget.OnMouseLostFocus(widget, Util.PtrToStruct<FocusEventArg>(int_ptr));
                    }
                    break;
                case EventType.MouseSetFocus:
                    {
                        Widget.OnMouseSetFocus(widget, Util.PtrToStruct<FocusEventArg>(int_ptr));
                    }
                    break;
                case EventType.MouseDrag:
                    {
                        Widget.OnMouseDrag(widget, Util.PtrToStruct<MouseDragEventArg>(int_ptr));
                    }
                    break;
                case EventType.MouseMove:
                    {
                        Widget.OnMouseMove(widget, Util.PtrToStruct<MouseMoveEventArg>(int_ptr));
                    }
                    break;
                case EventType.MouseWheel:
                    {
                        Widget.OnMouseWheel(widget, Util.PtrToStruct<MouseWheelEventArg>(int_ptr));
                    }
                    break;
                case EventType.KeyLostFocus:
                    {
                        Widget.OnKeyLostFocus(widget, Util.PtrToStruct<FocusEventArg>(int_ptr));
                    }
                    break;
                case EventType.KeySetFocus:
                    {
                        Widget.OnKeySetFocus(widget, Util.PtrToStruct<FocusEventArg>(int_ptr));
                    }
                    break;
                case EventType.KeyButtonPressed:
                    {
                        Widget.OnKeyButtonPressed(widget, Util.PtrToStruct<KeyButtonPressedEventArg>(int_ptr));
                    }
                    break;
                case EventType.KeyButtonReleased:
                    {
                        Widget.OnKeyButtonReleased(widget, Util.PtrToStruct<KeyButtonReleasedEventArg>(int_ptr));
                    }
                    break;
                case EventType.RootMouseChangeFocus:
                    {
                        Widget.OnRootMouseChangeFocus(widget, Util.PtrToStruct<RootChangeFocusEventArg>(int_ptr));
                    }
                    break;
                case EventType.RootKeyChangeFocus:
                    {
                        Widget.OnRootKeyChangeFocus(widget, Util.PtrToStruct<RootChangeFocusEventArg>(int_ptr));
                    }
                    break;
                case EventType.ToolTip:
                    {
                        Widget.OnToolTip(widget, Util.PtrToStruct<ToolTipEventArg>(int_ptr));
                    }
                    break;

                case EventType.ScrollChangePosition:
                    {
                        ScrollBar sb = widget as ScrollBar;
                        if (null != sb)
                        {
                            ScrollBar.OnScrollChangePosition(sb, Util.PtrToStruct<ScrollChangePositionEventArg>(int_ptr));
                        }
                    }
                    break;
                // --------------------------------------- DDContainer event ------------------------------------------------
                case EventType.StartDrag:
                    {
                        DDContainer ct = widget as DDContainer;
                        if (null != ct)
                        {
                            DDContainer.OnStartDrag(ct, Util.PtrToStruct<DragEventArg>(int_ptr));
                        }
                    }
                    break;

                case EventType.RequestDrop:
                    {
                        DDContainer ct = widget as DDContainer;
                        if (null != ct)
                        {
                            DDContainer.OnRequestDrop(ct, Util.PtrToStruct<DragEventArg>(int_ptr));
                        }
                    }
                    break;
                case EventType.DropResult:
                    {
                        DDContainer ct = widget as DDContainer;
                        if (null != ct)
                        {
                            DDContainer.OnDropResult(ct, Util.PtrToStruct<DragEventArg>(int_ptr));
                        }
                    }
                    break;
                case EventType.ChangeDDState:
                    {
                        DDContainer ct = widget as DDContainer;
                        if (null != ct)
                        {
                            DDContainer.OnChangeDDState(ct, Util.PtrToStruct<ChangeDDStateEventArg>(int_ptr));
                        }
                    }
                    break;
                case EventType.RequestDragWidgetInfo:
                    {
                        DDContainer ct = widget as DDContainer;
                        if (null != ct)
                        {
                            DDContainer.OnDragWidgetInfo(ct, Util.PtrToStruct<RequestDragWidgetInfoEventArg>(int_ptr));
                        }
                    }
                    break;
                // --------------------------------------- item box event ------------------------------------------------
                case EventType.RequestCoordItem:
                    {
                        ItemBox ib = widget as ItemBox;
                        if (null != ib)
                        {
                            ItemBox.OnRequestCoordItem(ib, Util.PtrToStruct<RequestCoordWidgetItemEventArg>(int_ptr));
                        }
                    }
                    break;
                case EventType.RequestCreateWidgetItem:
                    {
                        ItemBox ib = widget as ItemBox;
                        if (null != ib)
                        {
                            ItemBox.OnRequestCreateWidgetItem(ib, Util.PtrToStruct<RequestCreateWidgetItemEventArg>(int_ptr));
                        }
                    }
                    break;
                case EventType.RequestDrawItem:
                    {
                        ItemBox ib = widget as ItemBox;
                        if (null != ib)
                        {
                            ItemBox.OnRequestDrawItem(ib, Util.PtrToStruct<RequestDrawItemEventArg>(int_ptr));
                        }
                    }
                    break;

                case EventType.SelectItemAccept:
                    {
                        ItemBox ib = widget as ItemBox;
                        if (null != ib)
                        {
                            ItemBox.OnSelectItemAccept(ib, Util.PtrToStruct<ItemEventArg>(int_ptr));
                        }
                    }
                    break;

                case EventType.ChangeItemPosition:
                    {
                        ItemBox ib = widget as ItemBox;
                        if (null != ib)
                        {
                            ItemBox.OnChangeItemPosition(ib, Util.PtrToStruct<ItemEventArg>(int_ptr));
                        }
                    }
                    break;

                case EventType.MouseItemActivate:
                    {
                        ItemBox ib = widget as ItemBox;
                        if (null != ib)
                        {
                            ItemBox.OnMouseItemActivate(ib, Util.PtrToStruct<ItemEventArg>(int_ptr));
                        }
                    }
                    break;

                case EventType.NotifyItem:
                    {
                        ItemBox ib = widget as ItemBox;
                        if (null != ib)
                        {
                            ItemBox.OnNotifyItem(ib, Util.PtrToStruct<NotifyItemEventArg>(int_ptr));
                        }
                    }
                    break;

                // -------------------------------- List Box event ----------------------------------
                case EventType.ListSelectAccept:
                    {
                        ListBox ib = widget as ListBox;
                        if (null != ib)
                        {
                            ListBox.OnListSelectAccept(ib, Util.PtrToStruct<ListBoxEventArg>(int_ptr));
                        }
                    }
                    break;

                case EventType.ListChangePosition:
                    {
                        ListBox ib = widget as ListBox;
                        if (null != ib)
                        {
                            ListBox.OnListChangePosition(ib, Util.PtrToStruct<ListBoxEventArg>(int_ptr));
                        }
                    }
                    break;

                case EventType.ListMouseItemActivate:
                    {
                        ListBox ib = widget as ListBox;
                        if (null != ib)
                        {
                            ListBox.OnListMouseItemActivate(ib, Util.PtrToStruct<ListBoxEventArg>(int_ptr));
                        }
                    }
                    break;

                case EventType.ListMouseItemFocus:
                    {
                        ListBox ib = widget as ListBox;
                        if (null != ib)
                        {
                            ListBox.OnListMouseItemFocus(ib, Util.PtrToStruct<ListBoxEventArg>(int_ptr));
                        }
                    }
                    break;

                case EventType.ListChangeScroll:
                    {
                        ListBox ib = widget as ListBox;
                        if (null != ib)
                        {
                            ListBox.OnListChangeScroll(ib, Util.PtrToStruct<ListBoxEventArg>(int_ptr));
                        }
                    }
                    break;

                // -------------------------------- Window event ----------------------------------
                case EventType.WindowButtonPressed:
                    {
                        Window window = widget as Window;
                        if (null != window)
                        {
                            Window.OnWindowButtonPressed(window, Util.PtrToStruct<WindowButtonPressedEventArg>(int_ptr));
                        }
                    }
                    break;
                case EventType.WindowChangeCoord:
                    {
                        Window window = widget as Window;
                        if (null != window)
                        {
                            Window.OnWindowChangeCoord(window, arg);
                        }
                    }
                    break;
                // -------------------------------- Canvas event ----------------------------------
                case EventType.PreTextureChanges:
                    {
                        Canvas canvas = widget as Canvas;
                        if (null != canvas)
                        {
                            Canvas.OnPreTextureChanges(canvas, Util.PtrToStruct<EventArg>(int_ptr));
                        }
                    }
                    break;
                case EventType.RequestUpdateCanvas:
                    {
                        Canvas canvas = widget as Canvas;
                        if (null != canvas)
                        {
                            Canvas.OnRequestUpdateCanvas(canvas, Util.PtrToStruct<RequestUpdateCanvasEventArg>(int_ptr));
                        }
                    }
                    break;
                default:
                    break;
            }
        }
Пример #8
0
 public bool GetWidget(FString widget_name, out Widget widget)
 {
     return mWidgetTable.TryGetValue(widget_name, out widget);
 }
Пример #9
0
 public void Add(Widget widget)
 {
     mWidgetTable.Add(widget.Name, widget);
 }
Пример #10
0
        internal static Widget CreateWidget(Instance inst, FString name, Layout parent_layout)
        {
            WidgetType type = ICall_getType(inst.Ptr);

            Widget widget = null;
            switch (type)
            {
                case WidgetType.Widget:
                    widget = new Widget(inst, name, parent_layout, WidgetType.Widget);
                    break;
                case WidgetType.ImageBox:
                    widget = new ImageBox(inst, name, parent_layout);
                    break;
                case WidgetType.Window:
                    widget = new Window(inst, name, parent_layout);
                    break;
                case WidgetType.TextBox:
                    widget = new TextBox(inst, name, parent_layout);
                    break;
                case WidgetType.ListBox:
                    widget = new ListBox(inst, name, parent_layout);
                    break;
                case WidgetType.Button:
                    widget = new Button(inst, name, parent_layout);
                    break;
                case WidgetType.EditBox:
                    widget = new EditBox(inst, name, parent_layout);
                    break;
                case WidgetType.ComboBox:
                    widget = new ComboBox(inst, name, parent_layout);
                    break;

                case WidgetType.ScrollBar:
                    widget = new ScrollBar(inst, name, parent_layout);
                    break;
                case WidgetType.DDContainer:
                    widget = new DDContainer(inst, name, parent_layout);
                    break;
                case WidgetType.ItemBox:
                    widget = new ItemBox(inst, name, parent_layout);
                    break;
                case WidgetType.Canvas:
                    widget = new Canvas(inst, name, parent_layout);
                    break;
                default:
                    widget = new Widget(inst, name, parent_layout, WidgetType.Unknown);
                    break;
            }
            return widget;
        }
Пример #11
0
        internal void Unload()
        {
            if (IsLoaded)
            {
                mChilds.Clear();
                mWidget.Dispose();
                mWidget = null;

            }
        }
Пример #12
0
 internal bool TryGetWidget(Instance widget_inst, out Widget widget)
 {
     return mChilds.TryGetWidget(widget_inst, out widget);
 }
Пример #13
0
 internal ExecuteResult Load()
 {
     //throw new Exception("mWinPtr not null");
     Instance inst = GUI.LoadLayout(mParent, mFileName);
     if (inst.IsValid)
     {
         mWidget = Widget.CreateWidget(inst, null, this);
         mWidget.Visible = mVisible;
         return ExecuteResult.Success;
     }
     return ExecuteResult.False;
 }
Пример #14
0
 internal bool FindWidget(FString widget_name, out Widget widget)
 {
     if (mChilds.GetWidget(widget_name, out widget))
      {
          return true;
      }
      else
      {
         Instance inst = GUI.FindWidget(mWidget.Instance.Ptr, widget_name.Name);
         if (inst.IsValid)
         {
             widget = Widget.CreateWidget(inst, widget_name.Name, this);
             mChilds.Add(widget);
             return true;
         }
         else
         {
             widget = null;
             return false;
         }
     }
 }
Пример #15
0
 internal void AddWidget(Widget wiget)
 {
     mChilds.Add(wiget);
 }