Nekochan Net

Official Chat Channel: #nekochan // irc.nekochan.net
It is currently Sun Oct 19, 2014 9:23 pm

All times are UTC - 8 hours [ DST ]


Forum rules


Any posts concerning pirated software or offering to buy/sell/trade commercial software are subject to removal.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
Unread postPosted: Sat Jun 04, 2011 12:34 pm 
Offline
User avatar

Joined: Tue Oct 12, 2004 3:54 pm
Posts: 289
Location: London, Ingerlund
Hello all,

Am trying to use cairo for drawing in a Motif/ViewKit setup. I;m stuck :(

Here's my simple tester code minus the boilerplate:

Code:

MainWindow::MainWindow(const char* name) : VkWindow(name) {

   setMenuBar(mnu);

   ui_root = XtVaCreateWidget (
      
      "ui_root", xmFormWidgetClass, mainWindowWidget(),
      
      XmNwidth, 600,
      XmNheight, 400,

      NULL );
   
   ui_drawingarea = XtVaCreateWidget (
   
      "ui_drawingarea", xmDrawingAreaWidgetClass, ui_root,
      
      XmNtopAttachment, XmATTACH_FORM,
      XmNleftAttachment, XmATTACH_FORM,
      XmNrightAttachment, XmATTACH_FORM,
      XmNbottomAttachment, XmATTACH_FORM,
   
      NULL );
   
   XtManageChild(ui_drawingarea);

   Display *dpy = theApplication->display();

   cairo_surface_t *cs = cairo_xlib_surface_create( dpy, XtWindow(ui_drawingarea), DefaultVisual(dpy, 0), 200, 200 );
   cairo_t *c = cairo_create(cs);
   
   cairo_rectangle(c, 0.0, 0.0, 200, 200);
   cairo_set_source_rgb(c, 0.0, 0.0, 0.5);
   
   // I think cairo_fill() fails with BadWindow because the X11 drawables aren't mapped
   // since VkWindow->show() hasn't been called yet :(
   //
   //cairo_fill(c);
   //cairo_destroy(c);
   
   addView(ui_root);
}

MainWindow::~MainWindow() { // bye, bye. }
const char* MainWindow::className() { return "MainWindow"; }

void MainWindow::mnu_file_new() {

   cout << "called: mnu_file_new." << endl;
}

void MainWindow::mnu_file_new_cb(Widget w, XtPointer client_data, XtPointer call_data) {

   MainWindow *obj = (MainWindow *) client_data;
   obj->mnu_file_new();
}

void MainWindow::mnu_file_quit() {

   theApplication->quitYourself();
}

void MainWindow::mnu_file_quit_cb(Widget w, XtPointer client_data, XtPointer call_data) {

   MainWindow *obj = (MainWindow *) client_data;
   obj->mnu_file_quit();
}

VkMenuDesc MainWindow::mnu[] {

   {SUBMENU, "File", NULL, mnu_file},
   
   {END}
};

VkMenuDesc MainWindow::mnu_file[] {

   {ACTION, "New", &MainWindow::mnu_file_new_cb},
   {SEPARATOR, "Menu separator"},
   {ACTION, "Quit", &MainWindow::mnu_file_quit_cb},   

   {END}
};



My understanding is that cairo_fill() in the constructor gives me 'BadWindow' because the actual widgets haven't been mapped yet as VkWindow->show() hasn't been called yet. But when I move cairo_fill() to mnu_file_new() in the menubar, so I can call it when the window is mapped, I get a segmentation fault. Which I think is because of the whole C++ instance thing where things aren't actually mapped in memory like you think they are, which is why you need to define things as static for callbacks etc., which remains very confusing to me.

So my question is: how do I get a handle to the cairo drawable/surface in each of my VkWindow instances so I can draw into them at will?

thnx,

Jimmer


Top
 Profile  
 
Unread postPosted: Sat Jun 04, 2011 7:19 pm 
Offline
User avatar

Joined: Sun Mar 18, 2007 3:25 pm
Posts: 1893
Location: Minneapolis, Minnesota USA
Well I was going to take a look at this but, as usual, the Software Manager is killing me with circular conflicts between neko_cairo, neko_glib and neko_croco... :cry:

_________________
Project:
Temporarily lost at sea...
Plan:
World domination! Or something...


Top
 Profile  
 
Unread postPosted: Sun Jun 05, 2011 1:36 am 
Offline
User avatar

Joined: Tue Oct 12, 2004 3:54 pm
Posts: 289
Location: London, Ingerlund
lol - ah... well.. I'm using lesstif and ViewKlass on Arch linux inside a VirtualBox on my Macbook Air while I'm on this roadtrippe and haven't got the Fuel hooked up to anything.

Thanks for taking an interest :)


Top
 Profile  
 
Unread postPosted: Sun Jun 05, 2011 7:13 pm 
Offline
User avatar

Joined: Sun Mar 18, 2007 3:25 pm
Posts: 1893
Location: Minneapolis, Minnesota USA
Well I've got Viewkit 1.31 for Linux, supposedly compiled for libc6 by ICS in 1999, but the linker in gcc-4.5.2 doesn't seem to be able to use it, I'm getting tons of undefined reference errors:

undefined reference to `VkSimpleWindow::show()'
undefined reference to `VkSimpleWindow::hide()'
undefined reference to `VkComponent::okToQuit()'
undefined reference to `VkSimpleWindow::operator _WidgetRec*() const'

Most aggravating, If the linker can't link to a shared lib, why does it have to spew out dozens of error lines instead of just SAYING that it can't link!? I guess that would make too much sense... :cry:

_________________
Project:
Temporarily lost at sea...
Plan:
World domination! Or something...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group