Esempio n. 1
0
        public static void RenderPlaceholderText(Gtk.Widget widget, Gtk.ExposeEventArgs args, string placeHolderText, ref Pango.Layout layout)
        {
            if (layout == null)
            {
                layout = new Pango.Layout(widget.PangoContext);
                layout.FontDescription = widget.PangoContext.FontDescription.Copy();
            }

            int wh, ww;

            args.Event.Window.GetSize(out ww, out wh);

            int width, height;

            layout.SetText(placeHolderText);
            layout.GetPixelSize(out width, out height);
            using (var gc = new Gdk.GC(args.Event.Window)) {
                gc.Copy(widget.Style.TextGC(Gtk.StateType.Normal));
                Color color_a = widget.Style.Base(Gtk.StateType.Normal).ToXwtValue();
                Color color_b = widget.Style.Text(Gtk.StateType.Normal).ToXwtValue();
                gc.RgbFgColor = color_b.BlendWith(color_a, 0.5).ToGtkValue();

                args.Event.Window.DrawLayout(gc, 2, (wh - height) / 2, layout);
            }
        }
Esempio n. 2
0
		internal static void RenderPlaceholderText (Gtk.Entry entry, Gtk.ExposeEventArgs args, string placeHolderText, ref Pango.Layout layout)
		{
			// The Entry's GdkWindow is the top level window onto which
			// the frame is drawn; the actual text entry is drawn into a
			// separate window, so we can ensure that for themes that don't
			// respect HasFrame, we never ever allow the base frame drawing
			// to happen
			if (args.Event.Window == entry.GdkWindow)
				return;

			if (entry.Text.Length > 0)
				return;

			if (layout == null) {
				layout = new Pango.Layout (entry.PangoContext);
				layout.FontDescription = entry.PangoContext.FontDescription.Copy ();
			}

			int wh, ww;
			args.Event.Window.GetSize (out ww, out wh);

			int width, height;
			layout.SetText (placeHolderText);
			layout.GetPixelSize (out width, out height);
			using (var gc = new Gdk.GC (args.Event.Window)) {
				gc.Copy (entry.Style.TextGC (Gtk.StateType.Normal));
				Color color_a = entry.Style.Base (Gtk.StateType.Normal).ToXwtValue ();
				Color color_b = entry.Style.Text (Gtk.StateType.Normal).ToXwtValue ();
				gc.RgbFgColor = color_b.BlendWith (color_a, 0.5).ToGtkValue ();

				args.Event.Window.DrawLayout (gc, 2, (wh - height) / 2 + 1, layout);
			}
		}
Esempio n. 3
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            bool res = base.OnExposeEvent(evnt);

            if (Text.Length == 0 && !string.IsNullOrEmpty(EmptyMessage))
            {
                if (text_gc == null)
                {
                    text_gc = new Gdk.GC(evnt.Window);
                    text_gc.Copy(Style.TextGC(Gtk.StateType.Normal));
                    Gdk.Color color_a = Style.Base(Gtk.StateType.Normal);
                    Gdk.Color color_b = Style.Text(Gtk.StateType.Normal);
                    text_gc.RgbFgColor = ColorBlend(color_a, color_b);
                }

                if (layout == null)
                {
                    layout = new Pango.Layout(PangoContext);
                    layout.FontDescription = FontService.SansFont.CopyModified(Styles.FontScale11);
                }

                int width, height;
                layout.SetMarkup(EmptyMessage);
                layout.GetPixelSize(out width, out height);
                evnt.Window.DrawLayout(text_gc, 2, 2, layout);
            }
            return(res);
        }
Esempio n. 4
0
        void HandleExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            if (!string.IsNullOrEmpty(Control.Text) || args.Event.Window == Control.GdkWindow)
            {
                return;
            }

            if (placeholderLayout == null)
            {
                placeholderLayout = new Pango.Layout(Control.PangoContext);
                placeholderLayout.FontDescription = Control.PangoContext.FontDescription.Copy();
            }
            placeholderLayout.SetText(placeholderText);

            int currentHeight, currentWidth;

            args.Event.Window.GetSize(out currentWidth, out currentHeight);

            int width, height;

            placeholderLayout.GetPixelSize(out width, out height);

            var style = Control.Style;
            var bc    = style.Base(Gtk.StateType.Normal);
            var tc    = style.Text(Gtk.StateType.Normal);

            using (var gc = new Gdk.GC(args.Event.Window)) {
                gc.Copy(style.TextGC(Gtk.StateType.Normal));

                gc.RgbFgColor = new Gdk.Color((byte)(((int)bc.Red + tc.Red) / 2 / 256), (byte)(((int)bc.Green + (int)tc.Green) / 2 / 256), (byte)((bc.Blue + tc.Blue) / 2 / 256));

                args.Event.Window.DrawLayout(gc, 2, (currentHeight - height) / 2 + 1, placeholderLayout);
            }
        }
Esempio n. 5
0
        protected override void Render(Gdk.Drawable drawable, Widget widget,
                                       Gdk.Rectangle background_area, Gdk.Rectangle cell_area,
                                       Gdk.Rectangle expose_area, CellRendererState flags)
        {
            Pango.Layout layout = GetLayout(widget);

            // FIXME: If this code is ever built into its own library,
            // the call to Tomboy will definitely have to change
            layout.SetText(Tomboy.GuiUtils.GetPrettyPrintDate(date, show_time));

            int x, y, w, h;

            CalculateSize(layout, out x, out y, out w, out h);

            StateType state = RendererStateToWidgetState(flags);

            Gdk.GC gc;
            if (state.Equals(StateType.Selected))
            {
                // Use the proper Gtk.StateType so text appears properly when selected
                gc = new Gdk.GC(drawable);
                gc.Copy(widget.Style.TextGC(state));
                gc.RgbFgColor = widget.Style.Foreground(state);
            }
            else
            {
                gc = widget.Style.TextGC(Gtk.StateType.Normal);
            }

            drawable.DrawLayout(
                gc,
                cell_area.X + (int)Xalign + (int)Xpad,
                cell_area.Y + ((cell_area.Height - h) / 2),
                layout);
        }
Esempio n. 6
0
            private void RefreshGC()
            {
                if (text_window == null)
                {
                    return;
                }

                text_gc = new Gdk.GC(text_window);
                text_gc.Copy(Style.TextGC(StateType.Normal));
                Gdk.Color color_a = parent.Style.Foreground(StateType.Normal);
                Gdk.Color color_b = parent.Style.Background(StateType.Normal);
                text_gc.RgbFgColor = DrawingUtilities.ColorBlend(color_a, color_b, 0.5);
            }
Esempio n. 7
0
            private void RefreshGC()
            {
                if (text_window == null)
                {
                    return;
                }

                text_gc = new Gdk.GC(text_window);
                text_gc.Copy(Style.TextGC(StateType.Normal));
                Gdk.Color color_a = parent.Style.Base(StateType.Normal);
                Gdk.Color color_b = parent.Style.Text(StateType.Normal);
                text_gc.RgbFgColor = DockServices.Drawing.ColorBlend(color_a, color_b);
            }
            private void RefreshGC()
            {
                if (text_window == null)
                {
                    return;
                }

                text_gc = new Gdk.GC(text_window);
                text_gc.Copy(Style.TextGC(StateType.Normal));
                Gdk.Color color_a = parent.Style.Base(StateType.Normal);
                Gdk.Color color_b = parent.Style.Text(StateType.Normal);
                text_gc.RgbFgColor = Hyena.Gui.GtkUtilities.ColorBlend(color_a, color_b);
            }
Esempio n. 9
0
            protected override bool OnExposeEvent(Gdk.EventExpose evnt)
            {
                // The Entry's GdkWindow is the top level window onto which
                // the frame is drawn; the actual text entry is drawn into a
                // separate window, so we can ensure that for themes that don't
                // respect HasFrame, we never ever allow the base frame drawing
                // to happen
                if (evnt.Window == GdkWindow)
                {
                    return(true);
                }

                bool ret = base.OnExposeEvent(evnt);

                if (text_gc == null)
                {
                    text_gc = new Gdk.GC(evnt.Window);
                    text_gc.Copy(Style.TextGC(StateType.Normal));
                    Gdk.Color color_a = parent.Style.Base(StateType.Normal);
                    Gdk.Color color_b = parent.Style.Text(StateType.Normal);
                    text_gc.RgbFgColor = ColorBlend(color_a, color_b);
                }

                if (Text.Length > 0 || HasFocus || parent.EmptyMessage == null)
                {
                    return(ret);
                }

                if (layout == null)
                {
                    layout = new Pango.Layout(PangoContext);
                    layout.FontDescription = PangoContext.FontDescription.Copy();
                }

                int width, height;

                layout.SetMarkup(parent.EmptyMessage);
                layout.GetPixelSize(out width, out height);
                evnt.Window.DrawLayout(text_gc, 2, (SizeRequest().Height - height) / 2, layout);

                return(ret);
            }
Esempio n. 10
0
        void HandleWidgetExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            // The Entry's GdkWindow is the top level window onto which
            // the frame is drawn; the actual text entry is drawn into a
            // separate window, so we can ensure that for themes that don't
            // respect HasFrame, we never ever allow the base frame drawing
            // to happen
            if (args.Event.Window == Widget.GdkWindow)
            {
                return;
            }

            if (Widget.Text.Length > 0)
            {
                return;
            }

            if (layout == null)
            {
                layout = new Pango.Layout(Widget.PangoContext);
                layout.FontDescription = Widget.PangoContext.FontDescription.Copy();
            }

            int wh, ww;

            args.Event.Window.GetSize(out ww, out wh);

            int width, height;

            layout.SetText(placeHolderText);
            layout.GetPixelSize(out width, out height);
            Gdk.GC gc = new Gdk.GC(args.Event.Window);
            gc.Copy(Widget.Style.TextGC(Gtk.StateType.Normal));
            Color color_a = Util.ToXwtColor(Widget.Style.Base(Gtk.StateType.Normal));
            Color color_b = Util.ToXwtColor(Widget.Style.Text(Gtk.StateType.Normal));

            gc.RgbFgColor = Util.ToGdkColor(color_b.BlendWith(color_a, 0.5));

            args.Event.Window.DrawLayout(gc, 2, (wh - height) / 2 + 1, layout);
            gc.Dispose();
        }
Esempio n. 11
0
        internal static void RenderPlaceholderText(Gtk.Entry entry, Gtk.ExposeEventArgs args, string placeHolderText, ref Pango.Layout layout)
        {
            // The Entry's GdkWindow is the top level window onto which
            // the frame is drawn; the actual text entry is drawn into a
            // separate window, so we can ensure that for themes that don't
            // respect HasFrame, we never ever allow the base frame drawing
            // to happen
            if (args.Event.Window == entry.GdkWindow)
            {
                return;
            }

            if (entry.Text.Length > 0)
            {
                return;
            }

            if (layout == null)
            {
                layout = new Pango.Layout(entry.PangoContext);
                layout.FontDescription = entry.PangoContext.FontDescription.Copy();
            }

            int wh, ww;

            args.Event.Window.GetSize(out ww, out wh);

            int width, height;

            layout.SetText(placeHolderText);
            layout.GetPixelSize(out width, out height);
            using (var gc = new Gdk.GC(args.Event.Window)) {
                gc.Copy(entry.Style.TextGC(Gtk.StateType.Normal));
                Color color_a = entry.Style.Base(Gtk.StateType.Normal).ToXwtValue();
                Color color_b = entry.Style.Text(Gtk.StateType.Normal).ToXwtValue();
                gc.RgbFgColor = color_b.BlendWith(color_a, 0.5).ToGtkValue();

                args.Event.Window.DrawLayout(gc, 2, (wh - height) / 2 + 1, layout);
            }
        }
Esempio n. 12
0
		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
		{
			bool res = base.OnExposeEvent (evnt);
			if (Text.Length == 0 && !string.IsNullOrEmpty (EmptyMessage)) {
				if (text_gc == null) {
					text_gc = new Gdk.GC (evnt.Window);
					text_gc.Copy (Style.TextGC (Gtk.StateType.Normal));
					Gdk.Color color_a = Style.Base (Gtk.StateType.Normal);
					Gdk.Color color_b = Style.Text (Gtk.StateType.Normal);
					text_gc.RgbFgColor = ColorBlend (color_a, color_b);
				}
				
				if (layout == null) {
					layout = new Pango.Layout (PangoContext);
					layout.FontDescription = PangoContext.FontDescription.Copy ();
				}
				
				int width, height;
				layout.SetMarkup (EmptyMessage);
				layout.GetPixelSize (out width, out height);
				evnt.Window.DrawLayout (text_gc, 2, 2, layout);
			}
			return res;
		}
Esempio n. 13
0
            private void RefreshGC()
            {
                if(text_window == null) {
                    return;
                }

                text_gc = new Gdk.GC(text_window);
                text_gc.Copy(Style.TextGC(StateType.Normal));
                Gdk.Color color_a = parent.Style.Base(StateType.Normal);
                Gdk.Color color_b = parent.Style.Text(StateType.Normal);
                text_gc.RgbFgColor = Hyena.Gui.GtkUtilities.ColorBlend(color_a, color_b);
            }
Esempio n. 14
0
            private void RefreshGC()
            {
                if(text_window == null) {
                    return;
                }

                text_gc = new Gdk.GC(text_window);
                text_gc.Copy(Style.TextGC(StateType.Normal));
                Gdk.Color color_a = parent.Style.Base(StateType.Normal);
                Gdk.Color color_b = parent.Style.Text(StateType.Normal);
                text_gc.RgbFgColor = DockServices.Drawing.ColorBlend(color_a, color_b);
            }
			protected override bool OnExposeEvent (Gdk.EventExpose evnt)
			{
				// The Entry's GdkWindow is the top level window onto which
				// the frame is drawn; the actual text entry is drawn into a
				// separate window, so we can ensure that for themes that don't
				// respect HasFrame, we never ever allow the base frame drawing
				// to happen
				if (evnt.Window == GdkWindow) {
					return true;
				}
				
				bool ret = base.OnExposeEvent (evnt);
				
				if (text_gc == null) {
					text_gc = new Gdk.GC (evnt.Window);
					text_gc.Copy (Style.TextGC (StateType.Normal));
					Gdk.Color color_a = parent.Style.Base (StateType.Normal);
					Gdk.Color color_b = parent.Style.Text (StateType.Normal);
					text_gc.RgbFgColor = ColorBlend (color_a, color_b);
				}
				
				if (Text.Length > 0 || HasFocus || parent.EmptyMessage == null) {
					return ret;
				}
				
				if (layout == null) {
					layout = new Pango.Layout (PangoContext);
					layout.FontDescription = PangoContext.FontDescription.Copy ();
				}
				
				int width, height;
				layout.SetMarkup (parent.EmptyMessage);
				layout.GetPixelSize (out width, out height);
				evnt.Window.DrawLayout (text_gc, 2, (SizeRequest ().Height - height) / 2, layout);
				
				return ret;
			}
Esempio n. 16
0
        protected override void Render(Gdk.Drawable drawable, Widget widget,
		                                Gdk.Rectangle background_area, Gdk.Rectangle cell_area,
		                                Gdk.Rectangle expose_area, CellRendererState flags)
        {
            Pango.Layout layout = GetLayout (widget);

            // FIXME: If this code is ever built into its own library,
            // the call to Tomboy will definitely have to change
            layout.SetText (Utilities.GetPrettyPrintDate (date, show_time));

            int x, y, w, h;
            CalculateSize (layout, out x, out y, out w, out h);

            StateType state = RendererStateToWidgetState(flags);

            Gdk.GC gc;
            if (state.Equals(StateType.Selected)) {
                // Use the proper Gtk.StateType so text appears properly when selected
                gc = new Gdk.GC(drawable);
                gc.Copy(widget.Style.TextGC(state));
                gc.RgbFgColor = widget.Style.Foreground(state);
            } else
                gc = widget.Style.TextGC(Gtk.StateType.Normal);

            drawable.DrawLayout (
                    gc,
                    cell_area.X + (int)Xalign + (int)Xpad,
                    cell_area.Y + ((cell_area.Height - h) / 2),
                    layout);
        }
Esempio n. 17
0
        void HandleWidgetExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            // The Entry's GdkWindow is the top level window onto which
            // the frame is drawn; the actual text entry is drawn into a
            // separate window, so we can ensure that for themes that don't
            // respect HasFrame, we never ever allow the base frame drawing
            // to happen
            if (args.Event.Window == Widget.GdkWindow)
                return;

            if (Widget.Text.Length > 0)
                return;

            if (layout == null) {
                layout = new Pango.Layout (Widget.PangoContext);
                layout.FontDescription = Widget.PangoContext.FontDescription.Copy ();
            }

            int wh, ww;
            args.Event.Window.GetSize (out ww, out wh);

            int width, height;
            layout.SetText (placeHolderText);
            layout.GetPixelSize (out width, out height);
            Gdk.GC gc = new Gdk.GC (args.Event.Window);
            gc.Copy (Widget.Style.TextGC (Gtk.StateType.Normal));
            Color color_a = Util.ToXwtColor (Widget.Style.Base (Gtk.StateType.Normal));
            Color color_b = Util.ToXwtColor (Widget.Style.Text (Gtk.StateType.Normal));
            gc.RgbFgColor = Util.ToGdkColor (color_b.BlendWith (color_a, 0.5));

            args.Event.Window.DrawLayout (gc, 2, (wh - height) / 2 + 1, layout);
            gc.Dispose ();
        }
Esempio n. 18
0
            private void RefreshGC()
            {
                if(text_window == null) {
                    return;
                }

                text_gc = new Gdk.GC(text_window);
                text_gc.Copy(Style.TextGC(StateType.Normal));
                Gdk.Color color_a = parent.Style.Foreground(StateType.Normal);
                Gdk.Color color_b = parent.Style.Background(StateType.Normal);
                text_gc.RgbFgColor = DrawingUtilities.ColorBlend(color_a, color_b, 0.5);
            }