Exemplo n.º 1
0
        internal protected override void GenerateBuildCode(GeneratorContext ctx, CodeExpression var)
        {
            base.GenerateBuildCode(ctx, var);

            string text = button.Label;

            if (!string.IsNullOrEmpty(text))
            {
                CodePropertyReferenceExpression cprop = new CodePropertyReferenceExpression(var, "Label");
                PropertyDescriptor prop = (PropertyDescriptor)this.ClassDescriptor ["Label"];
                bool           trans    = Type != ButtonType.StockItem && prop.IsTranslated(Wrapped);
                CodeExpression val      = ctx.GenerateValue(text, typeof(string), trans);
                ctx.Statements.Add(new CodeAssignStatement(cprop, val));
            }

            if (Type == ButtonType.TextAndIcon)
            {
                var imageWidget = (Gtk.Image)button.Image;
                if (imageWidget != null)
                {
                    Image imageWrapper = (Image)Widget.Lookup(imageWidget);
                    var   imgVar       = ctx.GenerateNewInstanceCode(imageWrapper);
                    var   imgProp      = new CodePropertyReferenceExpression(var, "Image");
                    ctx.Statements.Add(new CodeAssignStatement(imgProp, imgVar));
                }
            }
        }
Exemplo n.º 2
0
        internal protected override void GenerateBuildCode(GeneratorContext ctx, CodeExpression var)
        {
            base.GenerateBuildCode(ctx, var);

            if (Type != ButtonType.TextAndIcon)
            {
                CodePropertyReferenceExpression cprop = new CodePropertyReferenceExpression(var, "Label");
                PropertyDescriptor prop = (PropertyDescriptor)this.ClassDescriptor ["Label"];
                bool           trans    = Type != ButtonType.StockItem && prop.IsTranslated(Wrapped);
                CodeExpression val      = ctx.GenerateValue(button.Label, typeof(string), trans);
                ctx.Statements.Add(new CodeAssignStatement(cprop, val));
            }
        }
Exemplo n.º 3
0
        internal protected override CodeExpression GenerateObjectCreation(GeneratorContext ctx)
        {
            CodeObjectCreateExpression exp = new CodeObjectCreateExpression();

            PropertyDescriptor prop = (PropertyDescriptor)ClassDescriptor ["Name"];

            exp.Parameters.Add(ctx.GenerateValue(prop.GetValue(Wrapped), prop.RuntimePropertyType));

            prop = (PropertyDescriptor)ClassDescriptor ["Label"];
            string lab = (string)prop.GetValue(Wrapped);

            if (lab == "")
            {
                lab = null;
            }
            exp.Parameters.Add(ctx.GenerateValue(lab, prop.RuntimePropertyType, prop.Translatable));

            prop = (PropertyDescriptor)ClassDescriptor ["Tooltip"];
            exp.Parameters.Add(ctx.GenerateValue(prop.GetValue(Wrapped), prop.RuntimePropertyType, prop.Translatable));

            prop = (PropertyDescriptor)ClassDescriptor ["StockId"];
            exp.Parameters.Add(ctx.GenerateValue(prop.GetValue(Wrapped), prop.RuntimePropertyType, prop.Translatable));

            if (type == ActionType.Action)
            {
                exp.CreateType = new CodeTypeReference("Gtk.Action");
            }
            else if (type == ActionType.Toggle)
            {
                exp.CreateType = new CodeTypeReference("Gtk.ToggleAction");
            }
            else
            {
                exp.CreateType = new CodeTypeReference("Gtk.RadioAction");
                prop           = (PropertyDescriptor)ClassDescriptor ["Value"];
                exp.Parameters.Add(ctx.GenerateValue(prop.GetValue(Wrapped), typeof(int)));
            }
            return(exp);
        }
Exemplo n.º 4
0
        internal protected override void GenerateBuildCode(GeneratorContext ctx, CodeExpression var)
        {
            if (textCombo && Items != null && Items.Length > 0)
            {
                foreach (string str in Items)
                {
                    ctx.Statements.Add(new CodeMethodInvokeExpression(
                                           var,
                                           "AppendText",
                                           ctx.GenerateValue(str, typeof(string), true)
                                           ));
                }
            }

            base.GenerateBuildCode(ctx, var);
        }
Exemplo n.º 5
0
        protected CodeExpression GenerateUiManagerElement(GeneratorContext ctx, ActionTree tree)
        {
            Widget topLevel = GetTopLevel();
            string uiName   = topLevel.UIManagerName;

            if (uiName != null)
            {
                CodeFieldReferenceExpression uiManager = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), uiName);
                if (topLevel.includedActionGroups == null)
                {
                    topLevel.includedActionGroups = new ArrayList();
                }

                // Add to the uimanager all action groups required by the
                // actions of the tree

                foreach (ActionGroup grp in tree.GetRequiredGroups())
                {
                    if (!topLevel.includedActionGroups.Contains(grp))
                    {
                        // Insert the action group in the UIManager
                        CodeMethodInvokeExpression mi = new CodeMethodInvokeExpression(
                            uiManager,
                            "InsertActionGroup",
                            ctx.GenerateValue(grp, typeof(ActionGroup)),
                            new CodePrimitiveExpression(topLevel.includedActionGroups.Count)
                            );
                        ctx.Statements.Add(mi);
                        topLevel.includedActionGroups.Add(grp);
                    }
                }

                tree.GenerateBuildCode(ctx, uiManager);
                return(new CodeMethodInvokeExpression(
                           uiManager,
                           "GetWidget",
                           new CodePrimitiveExpression("/" + Wrapped.Name)
                           ));
            }
            return(null);
        }
Exemplo n.º 6
0
        internal protected override void GenerateBuildCode(GeneratorContext ctx, CodeExpression var)
        {
            if (Text.Length > 0)
            {
                PropertyDescriptor prop = (PropertyDescriptor)this.ClassDescriptor ["Text"];
                bool trans = prop.IsTranslated(Wrapped);

                ctx.Statements.Add(
                    new CodeAssignStatement(
                        new CodePropertyReferenceExpression(
                            new CodePropertyReferenceExpression(
                                var,
                                "Buffer"
                                ),
                            "Text"
                            ),
                        ctx.GenerateValue(Text, typeof(string), trans)
                        )
                    );
            }
            base.GenerateBuildCode(ctx, var);
        }
Exemplo n.º 7
0
		internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
		{
			CodeObjectCreateExpression exp = new CodeObjectCreateExpression ();
			
			PropertyDescriptor prop = (PropertyDescriptor) ClassDescriptor ["Name"];
			exp.Parameters.Add (ctx.GenerateValue (prop.GetValue (Wrapped), prop.RuntimePropertyType));
			
			prop = (PropertyDescriptor) ClassDescriptor ["Label"];
			string lab = (string) prop.GetValue (Wrapped);
			if (lab == "") lab = null;
			exp.Parameters.Add (ctx.GenerateValue (lab, prop.RuntimePropertyType, prop.Translatable));
			
			prop = (PropertyDescriptor) ClassDescriptor ["Tooltip"];
			exp.Parameters.Add (ctx.GenerateValue (prop.GetValue (Wrapped), prop.RuntimePropertyType, prop.Translatable));
			
			prop = (PropertyDescriptor) ClassDescriptor ["StockId"];
			exp.Parameters.Add (ctx.GenerateValue (prop.GetValue (Wrapped), prop.RuntimePropertyType, prop.Translatable));
			
			if (type == ActionType.Action)
				exp.CreateType = new CodeTypeReference ("Gtk.Action", CodeTypeReferenceOptions.GlobalReference);
			else if (type == ActionType.Toggle)
				exp.CreateType = new CodeTypeReference ("Gtk.ToggleAction", CodeTypeReferenceOptions.GlobalReference);
			else {
				exp.CreateType = new CodeTypeReference ("Gtk.RadioAction", CodeTypeReferenceOptions.GlobalReference);
				prop = (PropertyDescriptor) ClassDescriptor ["Value"];
				exp.Parameters.Add (ctx.GenerateValue (prop.GetValue (Wrapped), typeof(int)));
			}
			return exp;
		}
Exemplo n.º 8
0
		internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
		{
			if (textCombo && Items != null && Items.Length > 0) {
				foreach (string str in Items) {
					ctx.Statements.Add (new CodeMethodInvokeExpression (
						var,
						"AppendText",
						ctx.GenerateValue (str, typeof(string), true)
					));
				}
			}
			
			base.GenerateBuildCode (ctx, var);
		}
		protected CodeExpression GenerateUiManagerElement (GeneratorContext ctx, ActionTree tree)
		{
			Widget topLevel = GetTopLevel ();
			string uiName = topLevel.UIManagerName;
			if (uiName != null) {
				CodeFieldReferenceExpression uiManager = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), uiName);
				if (topLevel.includedActionGroups == null)
					topLevel.includedActionGroups = new ArrayList ();
				
				// Add to the uimanager all action groups required by the 
				// actions of the tree
				
				foreach (ActionGroup grp in tree.GetRequiredGroups ()) {
					if (!topLevel.includedActionGroups.Contains (grp)) {
						// Insert the action group in the UIManager
						CodeMethodInvokeExpression mi = new CodeMethodInvokeExpression (
							uiManager,
							"InsertActionGroup",
							ctx.GenerateValue (grp, typeof(ActionGroup)),
							new CodePrimitiveExpression (topLevel.includedActionGroups.Count)
						);
						ctx.Statements.Add (mi);
						topLevel.includedActionGroups.Add (grp);
					}
				}
				
				tree.GenerateBuildCode (ctx, uiManager);
				return new CodeMethodInvokeExpression (
					uiManager,
					"GetWidget",
					new CodePrimitiveExpression ("/" + Wrapped.Name)
				);
			}
			return null;
		}
Exemplo n.º 10
0
		internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
		{
			base.GenerateBuildCode (ctx, var);
			
			if (Type != ButtonType.TextAndIcon) {
				CodePropertyReferenceExpression cprop = new CodePropertyReferenceExpression (var, "Label");
				PropertyDescriptor prop = (PropertyDescriptor) this.ClassDescriptor ["Label"];
				bool trans = Type != ButtonType.StockItem && prop.IsTranslated (Wrapped);
				CodeExpression val = ctx.GenerateValue (button.Label, typeof(string), trans);
				ctx.Statements.Add (new CodeAssignStatement (cprop, val));
			}
		}
Exemplo n.º 11
0
		protected virtual void GenerateChildPropertySet (GeneratorContext ctx, CodeVariableReferenceExpression var, ClassDescriptor containerChildClass, PropertyDescriptor prop, object child)
		{
			if (containerChildClass.InitializationProperties != null && Array.IndexOf (containerChildClass.InitializationProperties, prop) != -1)
				return;
			
			// Design time
			if (prop.Name == "AutoSize")
				return;
				
			object oval = prop.GetValue (child);
			if (oval == null || (prop.HasDefault && prop.IsDefaultValue (oval)))
				return;
				
			CodePropertyReferenceExpression cprop = new CodePropertyReferenceExpression (var, prop.Name);
			CodeExpression val = ctx.GenerateValue (oval, prop.RuntimePropertyType, prop.Translatable);
			ctx.Statements.Add (new CodeAssignStatement (cprop, val));
		}
Exemplo n.º 12
0
		internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
		{
			base.GenerateBuildCode (ctx, var);

			string text = button.Label;
			if (!string.IsNullOrEmpty (text)) {
				CodePropertyReferenceExpression cprop = new CodePropertyReferenceExpression (var, "Label");
				PropertyDescriptor prop = (PropertyDescriptor)this.ClassDescriptor ["Label"];
				bool trans = Type != ButtonType.StockItem && prop.IsTranslated (Wrapped);
				CodeExpression val = ctx.GenerateValue (text, typeof(string), trans);
				ctx.Statements.Add (new CodeAssignStatement (cprop, val));
			}

			if (Type == ButtonType.TextAndIcon) {
				var imageWidget = (Gtk.Image) button.Image;
				if (imageWidget != null) {
					Image imageWrapper = (Image)Widget.Lookup (imageWidget);
					var imgVar = ctx.GenerateNewInstanceCode (imageWrapper);
					var imgProp = new CodePropertyReferenceExpression (var, "Image");
					ctx.Statements.Add (new CodeAssignStatement (imgProp, imgVar));
				}
			}
		}