Buttons and Callbacks

New Message Reply Date view Thread view Subject view Author view

From: Mike (phoneix++at++sympatico.ca)
Date: 02/01/2000 04:29:45


Hi !

I'm trying to make a simple GUI interface using Performer. I have not
been able to get any pushbuttons to work.

Can anyone be kind enough to provide a simple source code with a couple
of pushbuttons and callbacks. This would be greately appreciated.
Actually, we already took the source code from one of the previous
messages here, and tried to modify it (by refering to the manuals and
the sample programs) but its not working.
Here it is . Can you please help us!

Thanks in advance,

Mike

Thanks
Mike


/*#include <Performer/pfutil.h>
#include <Performer/pf.h>
#include <Performer/pfui.h>
#include <Performer/pfdu.h>
//#include <Performer/pfui/pfiXformer.h>
#include <Performer/pfutil/pfuProcessManager.h>
#include <Performer/pf/pfPipeWindow.h>
#include <Performer/pf/pfChannel.h>
 
/* X Window includes
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
 
#include <iostream.h> */

// general includes
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <getopt.h> // for cmdline handler

// proecess control includes
#include <sys/types.h>
#include <sys/prctl.h>
#ifndef __linux__
#include <sys/sysmp.h>
#include <sys/schedctl.h>
#endif

// X Window includes
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>

// GL includes

// Performer includes
#include <Performer/pf/pfChannel.h>
#include <Performer/pf/pfDCS.h>
#include <Performer/pf/pfLightSource.h>
#include <Performer/pf/pfGeode.h>
#include <Performer/pr/pfTexture.h>
#include <Performer/pr/pfGeoSet.h>

#include <Performer/pfutil.h>
#include <Performer/pfdu.h>
#include <Performer/pfui/pfiXformer.h>

static void mouse(int a, void* b, pfuCustomEvent* c) {
        cout << "mouse" << endl;
        return;
}
 
static void drawPanel(pfuWidget *w, pfuPanel *p){

        static int f=0,x,y;

        if(f==0) {
                x=y=50;
                f=1;
                
        } else {
                x=y=100;
                f=0;
        }

     pfuWidgetDim(w, 0, 0, x, y);
        pfuFitWidgets(1);
 
}

static void controlPanel(pfuWidget *w){

        exit(0);
    switch(pfuGetWidgetId(w))
    {
    case 3:
        cout<<"QUIT pressed"<<endl;
        break;

    default:
        break;
    }
}

int main() {
 
     pfInit();

     pfConfig();
     pfuInit();
     pfiInit();

// pfuInitUtil();
 
 
     pfPipe* p = pfGetPipe(0);
     pfPipeWindow *pw = new pfPipeWindow(p);
// if (Shared->input == PFUINPUT_X)
        pw->setWinType(PFPWIN_TYPE_X);

// pw->setConfigFunc(OpenPipeWin);
// pw->config();
// pw->open();

        pfuEventStream *events;

        pfFrame();
      pfuInitGUI(pw);
        pfuInitInput(pw, PFUINPUT_X);

     pfuEnableGUI(1);
     pw->setWinType(PFPWIN_TYPE_X);
     pw->setName("IRIS Performer");
     pw->setOriginSize(0,0,500,500);

 
     pfChannel *chan1 = pfuGetGUIChan();
     pw->addChan(chan1);

// pfWSConnection dsp = pfGetCurWSConnection();
// pfuEventStream *event;

                                                 pfuMouse* mmouse;

// pfuCollectXEventStream(dsp, event, mmouse, PFUINPUT_CATCH_ALL, mouse);

        pfuInputHandler(mouse,PFUINPUT_CATCH_ALL);

     cout<<chan1<<endl;

        pfuGUIViewport(0, 0.2, 0.5, 1);
 
        pfuPanel* panel = pfuNewPanel();

     pfuWidget* wid3 = pfuNewWidget(panel, PFUGUI_BUTTON, 3);
     pfuWidgetDim(wid3, 0, 0, 50, 50);
     pfuWidgetLabel(wid3, "A");
// pfuWidgetDrawFunc(wid3, drawPanel);
     pfuWidgetActionFunc(wid3, controlPanel);
     pfuEnableWidget(wid3);

/* pfuWidget* wid4 = pfuNewWidget(panel, PFUGUI_BUTTON, 4);
     pfuWidgetDim(wid4, 0, 100, 49, 49);
     pfuWidgetLabel(wid4, "B");
     pfuWidgetActionFunc(wid4, controlPanel);
     pfuEnableWidget(wid4);

        pfuWidget* wid = pfuNewWidget(panel, PFUGUI_BUTTON, 1);
     pfuWidgetDim(wid, 0, 0, 49, 49);
     pfuWidgetLabel(wid, "Quit");
     pfuWidgetActionFunc(wid, controlPanel);
     pfuEnableWidget(wid);

     pfuWidget* wid2 = pfuNewWidget(panel, PFUGUI_BUTTON, 2);
     pfuWidgetDim(wid2, 0, 50, 49, 49);
     pfuWidgetLabel(wid2, "Hi");
     pfuWidgetActionFunc(wid2, controlPanel);
     pfuEnableWidget(wid2); */

     pfuEnablePanel(panel);
     pfuResetGUI();

        while(1) {
                pfuRedrawGUI();

                pfuGetMouse(mmouse);
                pfuGetEvents(events);

// controlPanel(wid3);
                pfSync();
                pfFrame();
                pfuCollectInput();
        }
}


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Jan 31 2000 - 01:28:51 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.