Click here to Skip to main content
15,885,875 members
Articles / Desktop Programming / X11

Programming Xlib with Mono Develop - Part 2: Athena widgets (proof of concept)

Rate me:
Please Sign up or sign in to vote.
4.89/5 (4 votes)
14 Sep 2013CPOL12 min read 30.6K   231   5  
How to call native Xt API from Mono Develop C# ending up in a very little Athena widget application.
/* Based on MIT's copywritten Template widget.  Modifications copyright circa
   1992 by James Morris and John Grotzinger.  Permissions to use etc are 
   granted as per those in the X11 copyright.  No warranties or guarantees 
   are made implicity or explicity; no responsiblity is taken for anything
   involving use of this software; no claims are made as to its performance 
   or any other aspect; use at your own risk. */

/* The Canvas widget is a very slightly modified Core.  It has a background
   pixmap that you draw into; it handles resizing it itself.  That's it.  You
   just use it as a drawing canvas, hence the clever name.  Class names etc
   are completely standard.  Functions to use are
   ClearCanvas(Widget canvas) --- clears the pixmap to the background color
   Pixmap CanvasPixmap(Widget canvas) --- the pixmap, so you can draw in it
   ExposeCanvas(Widget canvas) --- does a XClearArea on the pixmap, thus 
               sending appropriate Expose events so that the pixmap gets 
	       redrawn into the widget's window
   You usually use them in about that order --- Clear the canvas of old
   material; get the Pixmap; draw into it; Expose the new drawings.  */


#ifndef _Canvas_h
#define _Canvas_h

/****************************************************************
 *
 * Canvas widget
 *
 ****************************************************************/

/* Resources:  Core only, but default backgroundPixmap changed:

 Name		     Class		RepType		Default Value
 ----		     -----		-------		-------------
 backgroundPixmap    Pixmap	  	Pixmap	 	new, blank pixmap

Attempts to set backgroundPixmap will be ignored.		
'Blank' means it starts out filled with XtNbackground color.

*/

/* define any special resource names here that are not in <X11/StringDefs.h> */
  
  /* declare specific CanvasWidget class and instance datatypes */

typedef struct _CanvasClassRec*	        CanvasWidgetClass;
typedef struct _CanvasRec*		CanvasWidget;

/* declare the class constant */

extern WidgetClass canvasWidgetClass;
extern void ClearCanvas();
extern void ExposeCanvas();
extern Pixmap CanvasPixmap();

#endif /* _Canvas_h */

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader Celonis SA
Germany Germany
I am currently the CEO of Symbioworld GmbH and as such responsible for personnel management, information security, data protection and certifications. Furthermore, as a senior programmer, I am responsible for the automatic layout engine, the simulation (Activity Based Costing), the automatic creation of Word/RTF reports and the data transformation in complex migration projects.

The main focus of my work as a programmer is the development of Microsoft Azure Services using C# and Visual Studio.

Privately, I am interested in C++ and Linux in addition to C#. I like the approach of open source software and like to support OSS with own contributions.

Comments and Discussions