Motif, Viewkit and Cairo...

IRIX/Nekoware development, porting and related topics.
Forum rules
Any posts concerning pirated software or offering to buy/sell/trade commercial software are subject to removal.
User avatar
jimmer
Posts: 297
Joined: Tue Oct 12, 2004 3:54 pm
Location: London, Ingerlund

Motif, Viewkit and Cairo...

Unread postby jimmer » Sat Jun 04, 2011 12:34 pm

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: Select all


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

User avatar
vishnu
Posts: 2261
Joined: Sun Mar 18, 2007 3:25 pm
Location: Minneapolis, Minnesota USA

Re: Motif, Viewkit and Cairo...

Unread postby vishnu » Sat Jun 04, 2011 7:19 pm

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...

User avatar
jimmer
Posts: 297
Joined: Tue Oct 12, 2004 3:54 pm
Location: London, Ingerlund

Re: Motif, Viewkit and Cairo...

Unread postby jimmer » Sun Jun 05, 2011 1:36 am

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 :)

User avatar
vishnu
Posts: 2261
Joined: Sun Mar 18, 2007 3:25 pm
Location: Minneapolis, Minnesota USA

Re: Motif, Viewkit and Cairo...

Unread postby vishnu » Sun Jun 05, 2011 7:13 pm

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...


Return to “SGI: Development”

Who is online

Users browsing this forum: No registered users and 1 guest