Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: awang@cs.bgsu.edu (Aiyuan Wang)
Subject: C++ and XLIB
Date: 1995/06/15	[thread overview]
Message-ID: <3robk9$q3g@infoserver.bgsu.edu> (raw)

Hello!!!

   I need your help. I have the following program. I have used
cxx main/define=VMS to compile it, but it gives me many odd errors about
standard X libraries. Anyone can help me, please give me an email. Thank you.



window.h:

#ifndef ZWINDOW_H
#define ZWINDOW_H
#pragma extern_prefix save
#pragma extern_prefix ""
extern "C" {
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xresource.h>
#include <X11/StringDefs.h>
#pragma extern_prefix restore
}
class ZWindow{
public:
        ZWindow(int, int, int, int, int, int, int, int);
        ~ZWindow(){ XDestroyWindow( pDisp, mainWin);};
        void line(int, int, int, int);
        void lineto( int, int);
       void lineto( int, int);
        void moveto(int, int);
        void main_loop(){while(1) ;};
        Display *get_disp(){ return(pDisp);};
        Window get_win(){ return(mainWin); };
protected: 
        XPoint          p0, cp;
        Display        *pDisp;
        Window          mainWin;
        GC              gc;
        XGCValues       xgcv;
        XSizeHints      xsh;
        unsigned long   mask, fgPix, bgPix;
        XEvent          the_event;
};
#endif

window.cxx:

#pragma extern_prefix save
#pragma extern_prefix ""
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xresource.h>
#include <X11/StringDefs.h>
#include<iostream.h>
#include "window.h"
#pragma  extern_prefix restore
ZWindow::ZWindow(int x1, int y1, int x2, int y2, int x, int y, int width, int h`
{
        p0.x = x1; p0.y = y1;
        cp.x = x2; cp.y = y2;
        xsh.x = x; xsh.y = y;
        xsh.width = width;
        xsh.height = height;
        cout<<"I am in the win constructor."<<endl;
        if ((pDisp = XOpenDisplay(NULL)) == NULL) {
            cout<< "Can't open display"<<endl;
        };
        mainWin = XCreateSimpleWindow(pDisp,
                                      DefaultRootWindow(pDisp),
                                      xsh.x, xsh.y, xsh.width, xsh.height,
                                      1,        /* default_bdwidth */
                            fgPix = BlackPixel(pDisp, DefaultScreen(pDisp)),
                            bgPix = WhitePixel(pDisp, DefaultScreen(pDisp))
                );
        XFlush(pDisp);
        XSelectInput(pDisp, mainWin, ExposureMask | ButtonPressMask |
                              Button1MotionMask | ButtonReleaseMask);
        XFlush(pDisp);
        XMapRaised(pDisp, mainWin);

        xgcv.foreground = fgPix;
        xgcv.background = bgPix;
        xgcv.function = GXcopy;
        cout<<fgPix<<";;;"<<bgPix<<endl;
        mask = GCForeground | GCBackground | GCFunction;
       mask = GCForeground | GCBackground | GCFunction;
        cout<<mask<<";;;"<<bgPix<<endl;
        gc = XCreateGC(pDisp, mainWin, mask, &xgcv);
        XFlush(pDisp);
        XClearWindow(pDisp, mainWin);
        XNextEvent(pDisp,&the_event);
        while(the_event.type != Expose) ;   /* wait for window popping up */ 
                                         XDrawLine(pDisp,mainWin,gc,100,100,500`
        cout<<"end of window."<<endl;
}

void ZWindow::lineto(int x, int y)
{
        p0 = cp;
        cp.x = x;
        cp.y = y;
        XDrawLine(pDisp, mainWin, gc, p0.x, p0.y, cp.x, cp.y);
        XFlush(pDisp);
        return;
}
void ZWindow::line(int x1, int y1, int x2, int y2)
{
        cp.x = x1; cp.y = y1;
        lineto(x2, y2);
        return;
}

void ZWindow::moveto(int x, int y)
{
        cp.x= x; cp.y = y;
        return;
}
[End of file]

main.cxx:


#pragma extern_prefix save
#pragma extern_prefix ""
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include<iostream.h>
#include "window.h"
#pragma extern_prefix restore
// #include "line.h"
main(){
ZWindow win(0, 0, 0, 0, 100, 100, 800, 800);
ZWindow win1(0, 0, 0, 0, 0, 0, 80, 80);
ZWindow win2(0, 0, 0, 0, 80,0, 80, 80);
ZWindow win3(0, 0, 0, 0, 160, 0, 80, 80);
ZWindow win4(0, 0, 0, 0, 240, 0, 80, 80);
// line l1(10, 20, 100, 100);
// l1.set_disp_win(win.get_disp(), win.get_win());
// l1.draw();
cout<<"jjj"<<endl;
// win.line(100, 100, 200, 200);
// win.lineto(300, 400);
while(1)
;
}










Keywords: C++ compiler


-- 
Allan Aiyuan Wang
Dept. of Mathematics & Statistics
Dept. of Computer Science
Bowling Green State University
Bowling Green, Oh 43403
Home Tele: (419)353-6530
Email: awang@bgsuvax.bgsu.edu
       awang@cs.bgsu.edu









-- 
Allan Aiyuan Wang
Dept. of Mathematics & Statistics
Dept. of Computer Science
Bowling Green State University
Bowling Green, Oh 43403
Home Tele: (419)353-6530
Email: awang@bgsuvax.bgsu.edu
       awang@cs.bgsu.edu







                 reply	other threads:[~1995-06-15  4:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox