[Gtk-sharp-list] Points/Lines and Glade

Jorge Garcia jgarcia@ac.upc.es
Thu, 01 Apr 2004 18:28:50 +0200


--=-NxICbpmanuA2/mHRBIxI
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


Hello,

I'm trying to use glade-sharp and Drawarea and I think I have the  same
problems than you. This is an example of code that doesn't work. I will
appreciate any help.

Jorge

PS I'm using mono 0.31 and gtk-sharp 0.18


On dj, 2004-04-01 at 14:38, Sebastian Vorköper wrote:
> Am Mi, den 31.03.2004 schrieb Miguel de Icaza um 22:44:
> > Hello,
> > 
> > > I've giving up on Scribble and Glade, but the problem still remains.
> > > What i want to do is just loading a glade file where a Gtk.DrawingArea
> > > (or something similiar) is created and draw some points, lines or
> > > circles on it.
> > 
> > I do not understand the problem, we have done that before fairly
> > successfully.  What seems to be the problem?
> > 
> > Miguel
> 
> The problem with scribble and glade was (to put it in my own words/not
> knowing how to describe it clearly) that the events didn't get connected
> the right way?
> I mean, for example, that there is an event in scribble called
> "ConfigureEvent" that should create the pixmap and paint it with a white
> background.
> So it doesn't get called or the parameters aren't the right? I guess
> thats why it kills with a NullPointerException.
> I did both ways, configuring the events in glade and/or connecting them
> in scribble. Neither worked.
> 
> I've found a solution for the thing i wanted to do. (just loading a
> glade file with a drawingarea and paint to them.)
> 
> Then you do create the pixmap outsite of the events in scribble it won't
> fail to run, but it doesn't draw anything.
> You could draw to them by hand, but not with the created events.
> 
> So i hope this helps so far, maybe you or someone else does have a
> better idea?! (Maybe it has something to do with the [ConnectBefore]
> stuff???)
> 
> Btw.: Is there a chance to see the libgnomeprint/ui stuff for c# (gtk#)
> someday? I mean i would like to port the gnome-photo-printer stuff i
> worked on before to c#/gtk#.
> 
> Greetings,
> Sebastian Vorköper
> sv@fogman.de
> 
> 
> 
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

--=-NxICbpmanuA2/mHRBIxI
Content-Disposition: attachment; filename=sample.cs
Content-Type: text/plain; name=sample.cs; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

using System;
using Gtk;
using Glade;
using Gdk;
using GtkSharp;

namespace GladeSamples {

        public class GladeTest
	{	

		private Gdk.Pixmap pixmap = null;

		public static void Main (string[] args)
			{
				new GladeTest(args);
			}

		/* If you want to access the glade objects you have to "import" them.
		 * This is not required, but else you can only work with the
		 * pre-defined signal handlers */
		[Glade.Widget] Button IncZoomButton;
		[Glade.Widget] Button DecZoomButton;
		[Glade.Widget] DrawingArea darea;		

		public GladeTest (string[] args) 
			{
				Application.Init();

				Glade.XML ui = new Glade.XML ("wavview.glade", "app1", null);
				ui.Autoconnect (this);

				darea.SetSizeRequest (800, 600);				
				//darea.ConfigureEvent += new ConfigureEventHandler (OnDareaConfigureEvent);

				Application.Run();

			}

		/* Connect the Signals defined in Glade */
		public void OnWindowDeleteEvent (object o, DeleteEventArgs args) 
			{
				Application.Quit ();
				args.RetVal = true;
			}
    
		public void OnQuit1Activate(System.Object obj, EventArgs args){
				Application.Quit ();

		}
		
		void OnDecZoomButtonClicked (object obj, EventArgs args)
                {
			Console.WriteLine("Disminuir zoom");
                }

		void OnIncZoomButtonClicked (object obj, EventArgs args)
                {
			Console.WriteLine("Augmentar zoom");
                }


		void OnDareaConfigureEvent (object obj, ConfigureEventArgs args)
		{
			Gdk.EventConfigure ev = args.Event;
			Gdk.Window window = ev.Window;

			Console.WriteLine("ConfigureEvent event!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

			Gdk.Rectangle allocation = darea.Allocation;
			pixmap = new Gdk.Pixmap (window, allocation.Width, allocation.Height, -1);
			pixmap.DrawRectangle (darea.Style.WhiteGC, true, 0, 0,allocation.Width, allocation.Height);
			
			DrawSin();
			args.RetVal = true;
		}

		void DrawSin(){
			int punty, lasty = 300, i;
			
			for (i = 1; i < 800; i++){
				pixmap.DrawPoint(darea.Style.BlackGC,i,300);				
				punty = (Convert.ToInt16(Math.Sin(i) * 100)  + 300);				
				pixmap.DrawLine(darea.Style.BlackGC, i-1,lasty,i,punty);
				lasty = punty;
			}
			darea.QueueDrawArea(0,0,800,600);
		}


	}
}

--=-NxICbpmanuA2/mHRBIxI
Content-Disposition: attachment; filename=Makefile
Content-Type: text/x-makefile; name=Makefile; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

MCS=mcs
MCSFLAGS= -r glib-sharp.dll -r gtk-sharp.dll -r gdk-sharp.dll -r glade-sharp.dll  

all: sample.exe

%.exe: %.cs
	$(MCS) $(MCSFLAGS) $<

clean:
	rm -f *.exe

--=-NxICbpmanuA2/mHRBIxI
Content-Disposition: attachment; filename=wavview.glade
Content-Type: text/xml; name=wavview.glade; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>
<requires lib="gnome"/>
<requires lib="bonobo"/>

<widget class="GnomeApp" id="app1">
  <property name="visible">True</property>
  <property name="title" translatable="yes">Waview.sample</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_CENTER</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <property name="enable_layout_config">True</property>

  <child internal-child="dock">
    <widget class="BonoboDock" id="bonobodock1">
      <property name="visible">True</property>
      <property name="allow_floating">True</property>

      <child>
	<widget class="BonoboDockItem" id="bonobodockitem1">
	  <property name="visible">True</property>
	  <property name="shadow_type">GTK_SHADOW_NONE</property>

	  <child>
	    <widget class="GtkMenuBar" id="menubar1">
	      <property name="visible">True</property>

	      <child>
		<widget class="GtkImageMenuItem" id="file1">
		  <property name="visible">True</property>
		  <property name="stock_item">GNOMEUIINFO_MENU_FILE_TREE</property>

		  <child>
		    <widget class="GtkMenu" id="file1_menu">

		      <child>
			<widget class="GtkImageMenuItem" id="new1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_NEW_ITEM</property>
			  <property name="label" translatable="yes">_Nou</property>
			  <property name="use_underline">True</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkImageMenuItem" id="open1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_OPEN_ITEM</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkImageMenuItem" id="save1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_SAVE_ITEM</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkImageMenuItem" id="save_as1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_SAVE_AS_ITEM</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkSeparatorMenuItem" id="separator1">
			  <property name="visible">True</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkImageMenuItem" id="quit1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_EXIT_ITEM</property>
			  <signal name="activate" handler="OnQuit1Activate" last_modification_time="Mon, 29 Mar 2004 14:17:34 GMT"/>
			</widget>
		      </child>
		    </widget>
		  </child>
		</widget>
	      </child>

	      <child>
		<widget class="GtkImageMenuItem" id="edit1">
		  <property name="visible">True</property>
		  <property name="stock_item">GNOMEUIINFO_MENU_EDIT_TREE</property>

		  <child>
		    <widget class="GtkMenu" id="edit1_menu">

		      <child>
			<widget class="GtkImageMenuItem" id="cut1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_CUT_ITEM</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkImageMenuItem" id="copy1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_COPY_ITEM</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkImageMenuItem" id="paste1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_PASTE_ITEM</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkImageMenuItem" id="clear1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_CLEAR_ITEM</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkSeparatorMenuItem" id="separator2">
			  <property name="visible">True</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkImageMenuItem" id="properties1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_PROPERTIES_ITEM</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkSeparatorMenuItem" id="separator3">
			  <property name="visible">True</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkImageMenuItem" id="preferences1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_PREFERENCES_ITEM</property>
			</widget>
		      </child>
		    </widget>
		  </child>
		</widget>
	      </child>

	      <child>
		<widget class="GtkImageMenuItem" id="view1">
		  <property name="visible">True</property>
		  <property name="stock_item">GNOMEUIINFO_MENU_VIEW_TREE</property>

		  <child>
		    <widget class="GtkMenu" id="view1_menu">
		    </widget>
		  </child>
		</widget>
	      </child>

	      <child>
		<widget class="GtkImageMenuItem" id="help1">
		  <property name="visible">True</property>
		  <property name="stock_item">GNOMEUIINFO_MENU_HELP_TREE</property>

		  <child>
		    <widget class="GtkMenu" id="help1_menu">

		      <child>
			<widget class="GtkImageMenuItem" id="about1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_ABOUT_ITEM</property>
			</widget>
		      </child>
		    </widget>
		  </child>
		</widget>
	      </child>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name="placement">BONOBO_DOCK_TOP</property>
	  <property name="band">0</property>
	  <property name="position">0</property>
	  <property name="offset">0</property>
	  <property name="behavior">BONOBO_DOCK_ITEM_BEH_EXCLUSIVE|BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL|BONOBO_DOCK_ITEM_BEH_LOCKED</property>
	</packing>
      </child>

      <child>
	<widget class="BonoboDockItem" id="bonobodockitem2">
	  <property name="visible">True</property>
	  <property name="shadow_type">GTK_SHADOW_OUT</property>

	  <child>
	    <widget class="GtkToolbar" id="toolbar1">
	      <property name="visible">True</property>
	      <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
	      <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
	      <property name="tooltips">True</property>

	      <child>
		<widget class="button" id="button1">
		  <property name="visible">True</property>
		  <property name="tooltip" translatable="yes">Nou Fitxer</property>
		  <property name="label">gtk-new</property>
		  <property name="use_stock">True</property>
		</widget>
	      </child>

	      <child>
		<widget class="button" id="button2">
		  <property name="visible">True</property>
		  <property name="tooltip" translatable="yes">Obre el fitxer</property>
		  <property name="label">gtk-open</property>
		  <property name="use_stock">True</property>
		</widget>
	      </child>

	      <child>
		<widget class="button" id="button3">
		  <property name="visible">True</property>
		  <property name="tooltip" translatable="yes">Desa el fitxer</property>
		  <property name="label">gtk-save</property>
		  <property name="use_stock">True</property>
		</widget>
	      </child>

	      <child>
		<widget class="button" id="DecZoomButton">
		  <property name="visible">True</property>
		  <property name="label" translatable="yes">Redueix Zoom</property>
		  <property name="use_underline">True</property>
		  <property name="stock_pixmap">gtk-zoom-out</property>
		  <signal name="clicked" handler="OnDecZoomButtonClicked" last_modification_time="Mon, 29 Mar 2004 15:00:27 GMT"/>
		</widget>
	      </child>

	      <child>
		<widget class="button" id="IncZoomButton">
		  <property name="visible">True</property>
		  <property name="label" translatable="yes">Augmenta Zoom</property>
		  <property name="use_underline">True</property>
		  <property name="stock_pixmap">gtk-zoom-in</property>
		  <signal name="clicked" handler="OnIncZoomButtonClicked" last_modification_time="Mon, 29 Mar 2004 14:57:58 GMT"/>
		</widget>
	      </child>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name="placement">BONOBO_DOCK_TOP</property>
	  <property name="band">1</property>
	  <property name="position">0</property>
	  <property name="offset">0</property>
	  <property name="behavior">BONOBO_DOCK_ITEM_BEH_EXCLUSIVE</property>
	</packing>
      </child>

      <child>
	<widget class="GtkDrawingArea" id="darea">
	  <property name="width_request">800</property>
	  <property name="height_request">600</property>
	  <property name="visible">True</property>
	  <property name="can_focus">True</property>
	  <property name="has_focus">True</property>
	  <signal name="configure_event" handler="OnDareaConfigureEvent" last_modification_time="Thu, 01 Apr 2004 15:46:51 GMT"/>
	</widget>
      </child>
    </widget>
    <packing>
      <property name="padding">0</property>
      <property name="expand">True</property>
      <property name="fill">True</property>
    </packing>
  </child>

  <child internal-child="appbar">
    <widget class="GnomeAppBar" id="appbar1">
      <property name="visible">True</property>
      <property name="has_progress">True</property>
      <property name="has_status">True</property>
    </widget>
    <packing>
      <property name="padding">0</property>
      <property name="expand">True</property>
      <property name="fill">True</property>
    </packing>
  </child>
</widget>

</glade-interface>

--=-NxICbpmanuA2/mHRBIxI--