コード例 #1
0
ファイル: Button.cs プロジェクト: noah1510/dotdevelop
        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));
                }
            }
        }
コード例 #2
0
ファイル: Expander.cs プロジェクト: Kalnor/monodevelop
		protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
		{
			if (wrapper.Wrapped == expander.LabelWidget) {
				CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
				CodeAssignStatement assign = new CodeAssignStatement (
					new CodePropertyReferenceExpression (
						parentVar,
						"LabelWidget"
					),
					var
				);
				ctx.Statements.Add (assign);
			} else
				base.GenerateChildBuildCode (ctx, parentVar, wrapper);
		}
コード例 #3
0
 protected override void GenerateChildBuildCode(GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
 {
     if (wrapper.Wrapped == frame.LabelWidget)
     {
         CodeExpression      var    = ctx.GenerateNewInstanceCode(wrapper);
         CodeAssignStatement assign = new CodeAssignStatement(
             new CodePropertyReferenceExpression(
                 parentVar,
                 "LabelWidget"
                 ),
             var
             );
         ctx.Statements.Add(assign);
     }
     else
     {
         base.GenerateChildBuildCode(ctx, parentVar, wrapper);
     }
 }
コード例 #4
0
ファイル: ButtonBox.cs プロジェクト: noah1510/dotdevelop
        protected override void GenerateChildBuildCode(GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
        {
            if (actionDialog != null && wrapper is Button)
            {
                // If this is the action area of a dialog, buttons must be added using AddActionWidget,
                // so they are properly registered.

                ObjectWrapper childwrapper = ChildWrapper(wrapper);
                Button        button       = wrapper as Button;

                if (childwrapper != null)
                {
                    CodeExpression dialogVar = ctx.WidgetMap.GetWidgetExp(actionDialog);
                    ctx.Statements.Add(new CodeCommentStatement("Container child " + Wrapped.Name + "." + childwrapper.Wrapped.GetType()));
                    CodeExpression var = ctx.GenerateNewInstanceCode(wrapper);
                    if (button.ResponseId != (int)Gtk.ResponseType.None)
                    {
                        CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression(
                            dialogVar,
                            "AddActionWidget",
                            var,
                            new CodePrimitiveExpression(button.ResponseId)
                            );
                        ctx.Statements.Add(invoke);
                    }
                    else
                    {
                        CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression(
                            parentVar,
                            "Add",
                            var
                            );
                        ctx.Statements.Add(invoke);
                    }
                    GenerateSetPacking(ctx, parentVar, var, childwrapper);
                }
            }
            else
            {
                base.GenerateChildBuildCode(ctx, parentVar, wrapper);
            }
        }
コード例 #5
0
		protected virtual void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
		{
			ObjectWrapper childwrapper = ChildWrapper (wrapper);
			if (childwrapper != null) {
				ctx.Statements.Add (new CodeCommentStatement ("Container child " + Wrapped.Name + "." + childwrapper.Wrapped.GetType ()));
				CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
				CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (
					parentVar,
					"Add",
					var
				);
				ctx.Statements.Add (invoke);

				GenerateSetPacking (ctx, parentVar, var, childwrapper);
			}
		}
コード例 #6
0
ファイル: Notebook.cs プロジェクト: noah1510/dotdevelop
        protected override void GenerateChildBuildCode(GeneratorContext ctx, CodeExpression parentExp, Widget wrapper)
        {
            Gtk.Widget child = (Gtk.Widget)wrapper.Wrapped;

            if (notebook.PageNum(child) == -1)
            {
                // It's a tab

                ctx.Statements.Add(new CodeCommentStatement("Notebook tab"));
                Gtk.Widget     page = null;
                CodeExpression pageVar;

                // Look for the page widget contained in this tab
                for (int n = 0; n < notebook.NPages; n++)
                {
                    if (notebook.GetTabLabel(notebook.GetNthPage(n)) == child)
                    {
                        page = notebook.GetNthPage(n);
                        break;
                    }
                }

                // If the page contains a placeholder, generate a dummy page
                if (page is Stetic.Placeholder)
                {
                    CodeVariableDeclarationStatement dvar = new CodeVariableDeclarationStatement(
                        "Gtk.Label".ToGlobalTypeRef(),
                        ctx.NewId(),
                        new CodeObjectCreateExpression("Gtk.Label".ToGlobalTypeRef())
                        );
                    ctx.Statements.Add(dvar);
                    ctx.Statements.Add(
                        new CodeAssignStatement(
                            new CodePropertyReferenceExpression(
                                new CodeVariableReferenceExpression(dvar.Name),
                                "Visible"
                                ),
                            new CodePrimitiveExpression(true)
                            )
                        );
                    ctx.Statements.Add(
                        new CodeMethodInvokeExpression(
                            parentExp,
                            "Add",
                            new CodeVariableReferenceExpression(dvar.Name)
                            )
                        );
                    pageVar = new CodeVariableReferenceExpression(dvar.Name);
                }
                else
                {
                    pageVar = ctx.WidgetMap.GetWidgetExp(page);
                }

                // Generate code for the tab
                CodeExpression var = ctx.GenerateNewInstanceCode(wrapper);

                // Assign the tab to the page
                CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression(
                    parentExp,
                    "SetTabLabel",
                    pageVar,
                    var
                    );
                ctx.Statements.Add(invoke);

                // Workaround for GTK bug. ShowAll is not propagated to tab labels.
                invoke = new CodeMethodInvokeExpression(
                    var,
                    "ShowAll"
                    );
                ctx.Statements.Add(invoke);
            }
            else
            {
                base.GenerateChildBuildCode(ctx, parentExp, wrapper);
            }
        }
コード例 #7
0
ファイル: ButtonBox.cs プロジェクト: Kalnor/monodevelop
		protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
		{
			if (actionDialog != null && wrapper is Button) {
			
				// If this is the action area of a dialog, buttons must be added using AddActionWidget,
				// so they are properly registered.
				
				ObjectWrapper childwrapper = ChildWrapper (wrapper);
				Button button = wrapper as Button;
				
				if (childwrapper != null) {
					CodeExpression dialogVar = ctx.WidgetMap.GetWidgetExp (actionDialog);
					ctx.Statements.Add (new CodeCommentStatement ("Container child " + Wrapped.Name + "." + childwrapper.Wrapped.GetType ()));
					CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
					if (button.ResponseId != (int) Gtk.ResponseType.None) {
						CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (
							dialogVar,
							"AddActionWidget",
							var,
							new CodePrimitiveExpression (button.ResponseId)
						);
						ctx.Statements.Add (invoke);
					}
					else {
						CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (
							parentVar,
							"Add",
							var
						);
						ctx.Statements.Add (invoke);
					}
					GenerateSetPacking (ctx, parentVar, var, childwrapper);
				}
			} else
				base.GenerateChildBuildCode (ctx, parentVar, wrapper);
		}
コード例 #8
0
ファイル: Notebook.cs プロジェクト: Kalnor/monodevelop
		protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentExp, Widget wrapper)
		{
			Gtk.Widget child = (Gtk.Widget) wrapper.Wrapped;
			
			if (notebook.PageNum (child) == -1) {
				// It's a tab
				
				ctx.Statements.Add (new CodeCommentStatement ("Notebook tab"));
				Gtk.Widget page = null;
				CodeExpression pageVar;
				
				// Look for the page widget contained in this tab
				for (int n=0; n < notebook.NPages; n++) {
					if (notebook.GetTabLabel (notebook.GetNthPage (n)) == child) {
						page = notebook.GetNthPage (n);
						break;
					}
				}
				
				// If the page contains a placeholder, generate a dummy page
				if (page is Stetic.Placeholder) {
					CodeVariableDeclarationStatement dvar = new CodeVariableDeclarationStatement (
						"Gtk.Label".ToGlobalTypeRef (),
						ctx.NewId (),
						new CodeObjectCreateExpression ("Gtk.Label".ToGlobalTypeRef ())
					);
					ctx.Statements.Add (dvar);
					ctx.Statements.Add (
						new CodeAssignStatement (
							new CodePropertyReferenceExpression (
								new CodeVariableReferenceExpression (dvar.Name),
								"Visible"
							),
							new CodePrimitiveExpression (true)
						)
					);
					ctx.Statements.Add (
						new CodeMethodInvokeExpression (
							parentExp,
							"Add",
							new CodeVariableReferenceExpression (dvar.Name)
						)
					);
					pageVar = new CodeVariableReferenceExpression (dvar.Name);
				} else
					pageVar = ctx.WidgetMap.GetWidgetExp (page);
				
				// Generate code for the tab
				CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
				
				// Assign the tab to the page
				CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (
					parentExp,
					"SetTabLabel",
					pageVar,
					var
				);
				ctx.Statements.Add (invoke);
				
				// Workaround for GTK bug. ShowAll is not propagated to tab labels.
				invoke = new CodeMethodInvokeExpression (
					var,
					"ShowAll"
				);
				ctx.Statements.Add (invoke);
			} else
				base.GenerateChildBuildCode (ctx, parentExp, wrapper);
		}
コード例 #9
0
ファイル: Button.cs プロジェクト: Kalnor/monodevelop
		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));
				}
			}
		}