private void SetColumnAttributes(TreeViewColumn column, WindowContext context)
 {
     Type t = column.GetType();
     t.FindMembers(
         MemberTypes.Property | MemberTypes.Event,
         BindingFlags.Public | BindingFlags.Instance,
         SetGtkPropertyValue, new object[] { column, context });
 }
Example #2
0
 public override object Eval(IExecutionContext context)
 {
     if(context is WindowContext)
         wincontext = (WindowContext)context;
     else
         wincontext = WindowContext.CreateAsChild(context);
     return base.Eval(wincontext);
 }
 protected override Gtk.Widget CreateWidget(WindowContext context)
 {
     if(this.Child != null)
     {
         Gtk.Widget child = this.Child.Build(context);
         return new Gtk.ToolButton(child, GetAttribute<string>("stock", ""));
     }
     return new Gtk.ToolButton(GetAttribute<string>("stock", ""));
 }
 protected override Gtk.Widget CreateWidget(WindowContext context)
 {
     Gtk.Bin bin = CreateBinWidget(context);
     if(Child != null)
     {
         bin.Child = Child.Build(context);
     }
     return bin;
 }
Example #5
0
 protected override Gtk.Widget CreateWidget(WindowContext context)
 {
     Gtk.Toolbar toolbar = new Gtk.Toolbar();
     foreach(IWidgetBuilder builder in Childs)
     {
         toolbar.Add(builder.Build(context));
     }
     return toolbar;
 }
Example #6
0
        protected override Gtk.Widget CreateWidget(WindowContext context)
        {
            if(Childs.Count != 2)
                throw new Exception("Paned widget musí mít právě dva prvky");

            Gtk.Paned paned = CreatePanedWidget(context);
            paned.Add1(Childs[0].Build(context));
            paned.Add2(Childs[1].Build(context));
            return paned;
        }
Example #7
0
 protected override Gtk.Widget CreateWidget(WindowContext context)
 {
     Gtk.Button btn;
     if(Child != null)
     {
         btn = new Gtk.Button(Child.Build(context));
         btn.ImagePosition = Gtk.PositionType.Left;
     }
     else
         btn = new Gtk.Button();
     return btn;
 }
Example #8
0
 protected override Widget CreateWidget(WindowContext context)
 {
     if(Child == null)
         throw new Exception("Scrolled musí obsahovat widget");
     ScrolledWindow sw = new ScrolledWindow();
     Widget child = Child.Build(context);
     if(IsNativelyScrolled(child.GetType()))
         sw.Add(child);
     else
         sw.AddWithViewport(child);
     return sw;
 }
Example #9
0
 protected override Gtk.Widget CreateWidget(WindowContext context)
 {
     if(Child == null)
         throw new Exception("Align musí obsahovat widget");
     Gtk.Alignment a = new Gtk.Alignment(
         GetAtr("x", 0.5f),
         GetAtr("y", 0.5f),
         GetAtr("xs", 1.0f),
         GetAtr("ys", 1.0f));
     a.Child = Child.Build(context);
     return a;
 }
Example #10
0
 protected override Gtk.Widget CreateWidget(WindowContext context)
 {
     if(this.HasAttribute("icon"))
     {
         return Gtk.Image.NewFromIconName(
             this.GetAttribute<string>("icon"),
             (IconSize)this.GetAttribute<int>("iconsize"));
     }
     Gtk.Image image = new Gtk.Image();
     if(SetStock(image, "dialog_stock", IconSize.Dialog)) { }
     else if(SetStock(image, "small_stock", IconSize.Menu)) { }
     else if(SetStock(image, "button_stock", IconSize.Button)) { }
     else if(SetStock(image, "smalltool_stock", IconSize.SmallToolbar)) { }
     else if(SetStock(image, "bigtool_stock", IconSize.LargeToolbar)) { }
     return image;
 }
Example #11
0
 protected override Gtk.Widget CreateWidget(WindowContext context)
 {
     Gtk.Box box = CreateBoxWidget();
     foreach(IWidgetBuilder builder in Childs)
     {
         if(builder.GetAttribute<bool>("packend", false))
             box.PackEnd(builder.Build(context),
                 builder.GetAttribute<bool>("expand", true),
                 builder.GetAttribute<bool>("fill", true),
                 builder.GetAttribute<uint>("padding", 0));
         else
             box.PackStart(builder.Build(context),
                 builder.GetAttribute<bool>("expand", true),
                 builder.GetAttribute<bool>("fill", true),
                 builder.GetAttribute<uint>("padding", 0));
     }
     return box;
 }
Example #12
0
 protected override Widget CreateWidget(WindowContext context)
 {
     switch(this.Kind)
     {
     case MenuExpressionKind.MenuBar:
         MenuBar bar = new MenuBar();
         AppendItems(bar, context);
         return bar;
     case MenuExpressionKind.Menu:
         MenuItem item = CreateMenuItem(context);
         Menu menu = new Menu();
         item.Submenu = menu;
         AppendItems(menu, context);
         return item;
     case MenuExpressionKind.MenuItem:
         return CreateMenuItem(context);
     case MenuExpressionKind.ItemSeparator:
         return new SeparatorMenuItem();
     default:
         throw new NotImplementedException();
     }
 }
        public TreeViewColumn CreateColumn(WindowContext context)
        {
            string title = Params.Get<string>("title", "");
            TreeViewColumn column;

            switch(this.ColumnType)
            {
            case "text":
                column = new TreeViewColumn(title, new CellRendererText(), "text", this.StoreIndex);
                break;
            case "markup":
                column = new TreeViewColumn(title, new CellRendererText(), "markup", this.StoreIndex);
                break;
            case "pixbuf":
                column = new TreeViewColumn(title, new CellRendererPixbuf(), "stock-id", this.StoreIndex);
                break;
            default:
                throw new NotSupportedException("Sloupec typu '"+this.ColumnType+"' není podporován");
            }
            SetColumnAttributes(column, context);
            return column;
        }
Example #14
0
        protected override Gtk.Widget CreateWidget(WindowContext context)
        {
            uint rows = 0;
            uint columns = 0;
            uint wrow = 0;
            uint wcolumn = 0;
            uint startrow = 0;
            uint startcolumn = 0;
            bool rowmode = GetAttribute<bool>("rowmode", true);
            rowmode = !GetAttribute<bool>("colmode", !rowmode);
            List<WidgetTableInfo> wlist = new List<WidgetTableInfo>(Childs.Count);
            foreach(IWidgetBuilder b in Childs)
            {
                WidgetTableInfo w = new WidgetTableInfo();
                w.Widget = b.Build(context);

                startcolumn = b.GetAttribute<uint>("col", startcolumn);
                startrow = b.GetAttribute<uint>("row", startrow);
                wcolumn = b.GetAttribute<uint>("col", wcolumn);
                wrow = b.GetAttribute<uint>("row", wrow);

                if(b.GetAttribute<bool>("newcol", false))
                    { wrow = startrow; wcolumn = ++startcolumn; }
                else if(b.GetAttribute<bool>("newrow", false))
                    { wcolumn = startcolumn; wrow = ++startrow; }

                w.Left = wcolumn;
                w.Right = wcolumn + b.GetAttribute<uint>("colspan", 1u);
                w.Top = wrow;
                w.Bottom = wrow + b.GetAttribute<uint>("rowspan", 1u);

                if(!b.GetAttribute<bool>("xnoexpand", false)) w.XOptions |= Gtk.AttachOptions.Expand;
                if(!b.GetAttribute<bool>("xnofill", false)) w.XOptions |= Gtk.AttachOptions.Fill;
                if(b.GetAttribute<bool>("xshrink", false)) w.XOptions |= Gtk.AttachOptions.Shrink;

                if(!b.GetAttribute<bool>("ynoexpand", false)) w.YOptions |= Gtk.AttachOptions.Expand;
                if(!b.GetAttribute<bool>("ynofill", false)) w.YOptions |= Gtk.AttachOptions.Fill;
                if(b.GetAttribute<bool>("yshrink", false)) w.YOptions |= Gtk.AttachOptions.Shrink;

                w.XPadding = b.GetAttribute<uint>("xpadding", 0u);
                w.YPadding = b.GetAttribute<uint>("ypadding", 0u);
                wlist.Add(w);

                if(rows < w.Bottom) rows = (uint)w.Bottom;
                if(columns < w.Right) columns = (uint)w.Right;

                if(rowmode)
                    wcolumn++;
                else
                    wrow++;
            }
            Gtk.Table table = new Gtk.Table(rows, columns, GetAttribute<bool>("homogeneous", false));
            List<Gtk.Widget> focuschain = new List<Gtk.Widget>(wlist.Count);
            foreach(WidgetTableInfo w in wlist)
            {
                table.Attach(w.Widget,
                    w.Left, w.Right, w.Top, w.Bottom,
                    w.XOptions, w.YOptions, w.XPadding, w.YPadding);
                if(w.Widget.CanFocus)
                    focuschain.Add(w.Widget);
            }
            table.FocusChain = focuschain.ToArray();
            return table;
        }
Example #15
0
 private MenuItem CreateMenuItem(WindowContext context)
 {
     if(HasAttribute("stock"))
     {
         ImageMenuItem imi = new ImageMenuItem(this.GetAttribute<string>("stock"), context.AccelGroup);
         //IconSet icons = IconFactory.LookupDefault();
         //imi.Image = new Image(icons.RenderIcon(imi.Style, TextDirection.Ltr, StateType.Normal, IconSize.Menu, imi, null));
         return imi;
     }
     return new MenuItem(GetAttribute<string>("title",""));
 }
Example #16
0
 protected void AppendItems(MenuShell shell, WindowContext context)
 {
     if(this.MenuItems != null)
         foreach(MenuExpression expr in this.MenuItems)
             shell.Append(expr.Build(context));
 }
Example #17
0
 private void CreateColumns(WindowContext context, TreeView view)
 {
     foreach(TreeViewColumnExpression col in this.Columns)
         view.AppendColumn(col.CreateColumn(context));
 }
Example #18
0
 protected override Widget CreateWidget(WindowContext context)
 {
     TreeView view = new TreeView();
     CreateColumns(context, view);
     return view;
 }
Example #19
0
 protected override Gtk.Widget CreateWidget(WindowContext context)
 {
     Gtk.Label l = new Gtk.Label();
     l.Markup = this.Markup;
     return l;
 }
Example #20
0
 protected override Gtk.Paned CreatePanedWidget(WindowContext context)
 {
     return new Gtk.VPaned();
 }
Example #21
0
 protected abstract Gtk.Paned CreatePanedWidget(WindowContext context);
Example #22
0
        protected override Gtk.Widget CreateWidget(WindowContext context)
        {
            Window win;
            if(HasAttribute("dialog"))
            {
                Dialog dialog = new Dialog();
                dialog.AddAccelGroup(context.AccelGroup);
                SetWindowAttribs(dialog);
                if(Child != null)
                    dialog.VBox.Add(Child.Build(context));
                foreach(string s in GetAttribute<Array>("dialog"))
                {
                    string[] bits = s.Split(':');
                    string text = bits[0];
                    int response = 0;
                    if(bits.Length > 4)
                        throw new Exception("Neplatný počet parametrů tlačítka v poli tlačítek dialogu");
                    if(bits.Length > 1)
                        response = (int)IntLiteral.Parse(bits[1]);
                    Label l = new Label();
                    l.Markup = text;
                    Button btn;
                    if(bits.Length > 2 && !String.IsNullOrEmpty(bits[2]))
                    {
                        HBox hbox = new HBox(false, 0);
                        hbox.PackStart(ImageExpression.CreateImage(bits[2], IconSize.Button));
                        hbox.PackStart(l);
                        btn = new Button(hbox);
                    }
                    else
                        btn = new Button(l);
                    btn.ShowAll();
                    dialog.AddActionWidget(btn, response);
                    if(bits.Length > 3)
                    {
                        switch(bits[3].ToLower())
                        {
                        case "default":
                            btn.CanDefault = true;
                            dialog.Default = btn;
                            break;
                        case "cancel":
                            // set as cancel action - how?
                            break;
                        case "":
                        case "none":
                            break;
                        default:
                            throw new Exception("Neznámý příznak tlačítka dialogu");
                        }
                    }

                }
                win = dialog;
            }
            else
            {
                win = new Window(Gtk.WindowType.Toplevel);
                win.AddAccelGroup(context.AccelGroup);
                if(Child != null)
                    win.Add(Child.Build(context));
            }

            if(HasAttribute("iconset"))
            {
                IconSet icons = IconFactory.LookupDefault(GetAttribute<string>("iconset"));
                List<Gdk.Pixbuf> list = new List<Gdk.Pixbuf>();
                foreach(IconSize size in icons.Sizes)
                {
                    list.Add(icons.RenderIcon(win.Style, TextDirection.Ltr, StateType.Normal, size, win, ""));
                }
                win.IconList = list.ToArray();
            }

            return win;
        }
Example #23
0
 public virtual Gtk.Bin CreateBinWidget(WindowContext context)
 {
     return (Gtk.Bin)Activator.CreateInstance(this.BinType);
 }