예제 #1
0
 public void RemChild(Gadget gadget)
 {
     if (children.Remove(gadget))
     {
         gadget.parent = null;
     }
 }
예제 #2
0
        public bool MouseButtonUp(int x, int y, MouseButton button)
        {
            bool   result = false;
            Point  pos    = new Point(x, y);
            Gadget gadget = null;
            Window window = FindWindow(pos);

            if (window != null)
            {
                window.ClearDraggingAndSizing();
                gadget = window.FindGadget(pos);
            }
            dragging   = false;
            dragGadget = null;
            dragWindow = null;
            if (selectedGadget != null)
            {
                if (!selectedGadget.RelVerify || (selectedGadget == gadget))
                {
                    result = selectedGadget.HandleMouseButtonUp(selectedGadget.ScreenToGadget(pos), button);
                }
            }
            SetSelectedWindow(null);
            SetSelectedGadget(null);
            mousePos             = pos;
            mouseButton         &= ~button;
            engine.GUIUseseMouse = !result;
            return(result);
        }
예제 #3
0
        public ScrollbarGadget(Gadget parent, Orientation orientation = Orientation.Horizontal)
            : base(parent)
        {
            arrowPlace       = ArrowPlace.RightBottom;
            overlap          = 1;
            increment        = 1;
            this.orientation = orientation;
            bool vert = orientation == Orientation.Vertical;

            prop = new PropGadget(this)
            {
                FreeHoriz  = !vert,
                FreeVert   = vert,
                Borderless = true
            };
            prop.PropChanged += Prop_PropChanged;
            arrowInc          = new ButtonGadget(this, vert ? theme.ArrowDown : theme.ArrowRight)
            {
                Width      = 20,
                Height     = 20,
                Repeat     = true,
                Borderless = false
            };
            arrowInc.GadgetUp += ArrowInc_GadgetUp;
            arrowDec           = new ButtonGadget(this, vert ? theme.ArrowUp : theme.ArrowLeft)
            {
                Height     = 20,
                Width      = 20,
                Repeat     = true,
                Borderless = false
            };
            arrowDec.GadgetUp += ArrowDec_GadgetUp;
        }
예제 #4
0
        public bool MouseMove(int x, int y)
        {
            bool result = false;

            Hover = true;
            Point  pos    = new Point(x, y);
            Gadget gadget = null;
            Window window = FindWindow(pos);

            if (dragging && dragGadget != null)
            {
                result = dragGadget.HandleMouseDrag(dragGadget.ScreenToGadget(pos), pos - mousePos, mouseButton);
            }
            if (!result && dragging && dragWindow != null)
            {
                result = dragWindow.HandleMouseDrag(dragWindow.ScreenToGadget(pos), pos - mousePos, mouseButton);
            }
            if (window != null)
            {
                gadget = window.FindGadget(pos);
            }
            if (!result && gadget != null)
            {
                result = gadget.HandleMouseMove(gadget.ScreenToGadget(pos), mouseButton);
            }
            SetHoverWindow(window);
            SetHoverGadget(gadget);
            mousePos = pos;
            return(result);
        }
예제 #5
0
        public override Point GetPreferredSize(IGraphics gfx, Gadget gadget)
        {
            Point size    = new Point(2 * margin, 2 * margin);
            int   xOffset = gadget.BorderLeft + gadget.BorderRight;
            int   yOffset = gadget.BorderTop + gadget.BorderBottom;
            bool  first   = true;
            int   axis1   = (int)orientation;
            int   axis2   = (((int)orientation) + 1) % 2;

            foreach (var w in gadget.Children)
            {
                if (!w.Visible)
                {
                    continue;
                }
                if (first)
                {
                    first = false;
                }
                else
                {
                    size[axis1] += spacing;
                }

                Point ps         = w.GetPreferredSize(gfx);
                Point fs         = w.FixedSize;
                Point targetSize = GetValidSize(ps, fs);// new Vector2(fs.X != 0 ? fs.X : ps.X, fs.Y != 0 ? fs.Y : ps.Y);
                size[axis1] += targetSize[axis1];
                size[axis2]  = Math.Max(size[axis2], targetSize[axis2] + 2 * margin);
                first        = false;
            }
            return(size + new Point(xOffset, yOffset));
        }
예제 #6
0
 public StrGadget(Gadget parent, string label = "")
     : base(parent, label)
 {
     buffer       = "";
     textTabWidth = 4 * 24;
     lineSkip     = 24;
 }
예제 #7
0
파일: PopupWindow.cs 프로젝트: Jebeli/Tiles
 public PopupWindow(Gadget parent)
     : base(parent.Screen)
 {
     layout       = new BoxLayout(Orientation.Vertical, Alignment.Fill);
     parentGadget = parent;
     parentWindow = parent.Window;
     ThinBorder   = true;
 }
예제 #8
0
 public ChooserGadget(Gadget parent)
     : base(parent)
 {
     RelVerify     = false;
     selectedIndex = -1;
     items         = new List <object>();
     Size          = new Point(64 + 24, 24);
 }
예제 #9
0
 public SliderGadget(Gadget parent, Orientation orientation)
     : base(parent)
 {
     labelFormat      = "{0}";
     increment        = 1;
     this.orientation = orientation;
     FreeHoriz        = orientation == Orientation.Horizontal;
     FreeVert         = orientation == Orientation.Vertical;
 }
예제 #10
0
파일: FileGadget.cs 프로젝트: Jebeli/Tiles
        public FileGadget(Gadget parent, IFileResolver fileResolver)
            : base(parent)
        {
            this.fileResolver = fileResolver;
            layout            = new BoxLayout(Orientation.Vertical, Alignment.Fill);
            table             = new TableGadget(this)
            {
                EvenColumns = false,
                SelectedCellChangedEvent = (o, i) => { TableSelectedChanged(); }
            };
            table.AddColumn("Name", -1);
            table.AddColumn("Size", 64);
            table.AddColumn("Date", 130);
            table.AddColumn("Comment", 140);
            var dirBox = new BoxGadget(this, Orientation.Horizontal, Alignment.Fill);

            new LabelGadget(dirBox, "Drawer")
            {
                FixedWidth = 100
            };
            dirName = new StrGadget(dirBox)
            {
                FixedWidth = 300
            };

            var fileBox = new BoxGadget(this, Orientation.Horizontal, Alignment.Fill);

            new LabelGadget(fileBox, "File")
            {
                FixedWidth = 100
            };
            fileName = new StrGadget(fileBox)
            {
                FixedWidth = 300
            };
            var buttonBox = new BoxGadget(this, Orientation.Horizontal, Alignment.Fill, 0, 100);

            butOk = new ButtonGadget(buttonBox, "Open")
            {
                GadgetUpEvent = (o, i) => { Ok(); }
            };
            butVolumes = new ButtonGadget(buttonBox, "Volumes")
            {
                GadgetUpEvent = (o, i) => { Volumes(); }
            };
            butParent = new ButtonGadget(buttonBox, "Parent")
            {
                GadgetUpEvent = (o, i) => { GoToParent(); }
            };
            butCancel = new ButtonGadget(buttonBox, "Cancel")
            {
                GadgetUpEvent = (o, i) => { Cancel(); }
            };
        }
예제 #11
0
 public TableGadget(Gadget parent)
     : base(parent)
 {
     evenColumns  = true;
     showHeader   = true;
     rowHeight    = 20;
     headerHeight = 24;
     columns      = new List <TableColumn>();
     rows         = new List <TableRow>();
     vScroll      = new ScrollbarGadget(this, Orientation.Vertical);
 }
예제 #12
0
 public Gadget(Gadget parent, string label = "", Icons icon = Icons.NONE)
 {
     visible    = true;
     enabled    = true;
     relVerify  = true;
     this.label = label;
     this.icon  = icon;
     children   = new List <Gadget>();
     if (parent != null)
     {
         parent.AddChild(this);
     }
 }
예제 #13
0
파일: Theme.cs 프로젝트: Jebeli/Tiles
 public void RenderTooltip(IGraphics gfx, Gadget gadget)
 {
     if (gadget.Hover && !string.IsNullOrEmpty(gadget.TooltipText))
     {
         var   frame = gadget.Bounds;
         var   pos   = gadget.TooltipPos;
         var   color = TextPen;
         Point tPos  = new Point(frame.X, frame.Y);
         tPos += pos;
         gfx.RenderText(gadget.Font, gadget.TooltipText, tPos.X + 1, tPos.Y + 1, Color.Black, HorizontalTextAlign.Center, VerticalTextAlign.Bottom);
         gfx.RenderText(gadget.Font, gadget.TooltipText, tPos.X - 1, tPos.Y - 1, Color.Black, HorizontalTextAlign.Center, VerticalTextAlign.Bottom);
         gfx.RenderText(gadget.Font, gadget.TooltipText, tPos.X, tPos.Y, color, HorizontalTextAlign.Center, VerticalTextAlign.Bottom);
     }
 }
예제 #14
0
        public bool MouseButtonDown(int x, int y, MouseButton button)
        {
            bool   result = false;
            Point  pos    = new Point(x, y);
            Gadget gadget = null;
            Window window = FindWindow(pos);

            if (window != null)
            {
                window.ClearDraggingAndSizing();
                gadget = window.FindGadget(pos);
                if (button == MouseButton.Left)
                {
                    dragGadget = gadget;
                    if (dragGadget == this)
                    {
                        dragGadget = null;
                    }
                    dragging = dragGadget != null;
                    if (dragging)
                    {
                        dragWindow = dragGadget.Window;
                    }
                    SetFocusedWindow(window);
                    SetFocusedGadget(gadget);
                }
                else
                {
                    dragging   = false;
                    dragGadget = null;
                    dragWindow = null;
                }
            }
            else
            {
                SetFocusedWindow(null);
                SetFocusedGadget(null);
            }
            if (gadget != null)
            {
                result = gadget.HandleMouseButtonDown(gadget.ScreenToGadget(pos), button);
            }
            SetSelectedWindow(window);
            SetSelectedGadget(gadget);
            mousePos             = pos;
            mouseButton         |= button;
            engine.GUIUseseMouse = result;
            return(result);
        }
예제 #15
0
 public void SetHoverGadget(Gadget gadget)
 {
     if (gadget is Window)
     {
         return;
     }
     if (gadget != hoverGadget)
     {
         if (hoverGadget != null)
         {
             hoverGadget.Hover = false;
         }
         hoverGadget = gadget;
         if (hoverGadget != null)
         {
             hoverGadget.Hover = true;
         }
     }
 }
예제 #16
0
 public void SetFocusedGadget(Gadget gadget)
 {
     if (gadget is Window)
     {
         return;
     }
     if (gadget != null && !gadget.Enabled)
     {
         return;
     }
     if (gadget != focusedGadget)
     {
         if (focusedGadget != null)
         {
             focusedGadget.Focused = false;
         }
         focusedGadget = gadget;
         if (focusedGadget != null)
         {
             focusedGadget.Focused = true;
         }
     }
 }
예제 #17
0
 private void SetSelectedGadget(Gadget gadget)
 {
     if (gadget is Window)
     {
         return;
     }
     if (gadget != null && !gadget.Enabled)
     {
         return;
     }
     if (gadget != selectedGadget)
     {
         if (selectedGadget != null)
         {
             selectedGadget.MouseSelected = false;
         }
         selectedGadget = gadget;
         if (selectedGadget != null)
         {
             selectedGadget.MouseSelected = true;
         }
     }
 }
예제 #18
0
 public NumericalGadget(Gadget parent)
     : base(parent)
 {
     increment = 0.1;
     strGadget = new StrGadget(this)
     {
         Flags         = StrFlags.Double,
         GadgetUpEvent = (o, i) => { OnGadgetUp(); }
     };
     upGadget = new ButtonGadget(this, Icons.ENTYPO_ICON_PLUS)
     {
         Repeat        = true,
         Width         = BUT_SIZE,
         Height        = BUT_SIZE,
         GadgetUpEvent = (o, i) => { IncValue(); }
     };
     downGadget = new ButtonGadget(this, Icons.ENTYPO_ICON_MINUS)
     {
         Repeat        = true,
         Width         = BUT_SIZE,
         Height        = BUT_SIZE,
         GadgetUpEvent = (o, i) => { DecValue(); }
     };
 }
예제 #19
0
 public ButtonGadget(Gadget parent, string label, Icons icon = Icons.NONE)
     : base(parent, label, icon)
 {
     Size = new Point(64, 24);
 }
예제 #20
0
 public TabPanelGadget(Gadget parent)
     : base(parent)
 {
     tabs       = new List <TabGadget>();
     tabHeaders = new List <TabHeaderGadget>();
 }
예제 #21
0
 public ImageGadget(Gadget parent)
     : base(parent)
 {
     frame = true;
 }
예제 #22
0
 public CheckBoxGadget(Gadget parent, string label)
     : base(parent, label)
 {
     Size = new Point(64, 24);
 }
예제 #23
0
파일: BoxGadget.cs 프로젝트: Jebeli/Tiles
 public BoxGadget(Gadget parent, Orientation orientation, Alignment alignment = Alignment.Middle, int margin = 0, int spacing = 0)
     : base(parent)
 {
     layout = new BoxLayout(orientation, alignment, margin, spacing);
 }
예제 #24
0
 public SeparatorGadget(Gadget parent, Orientation orientation = Orientation.Vertical)
     : base(parent)
 {
     padding          = 8;
     this.orientation = orientation;
 }
예제 #25
0
 public virtual void AddChild(int index, Gadget gadget)
 {
     children.Insert(index, gadget);
     gadget.parent = this;
     gadget.theme  = theme;
 }
예제 #26
0
 public TabHeaderGadget(Gadget parent, string label)
     : base(parent, label)
 {
     Sticky = true;
 }
예제 #27
0
 public ProgressbarGadget(Gadget parent)
     : base(parent)
 {
 }
예제 #28
0
 public ButtonGadget(Gadget parent, Icons icon = Icons.NONE)
     : base(parent, "", icon)
 {
     Size = new Point(24, 24);
 }
예제 #29
0
파일: ItemGadget.cs 프로젝트: Jebeli/Tiles
 public ItemGadget(Gadget parent, string label)
     : base(parent, label)
 {
     items = new List <ItemGadget>();
 }
예제 #30
0
 public void AddChild(Gadget gadget)
 {
     AddChild(children.Count, gadget);
 }