Commit c09f404f authored by Russ Fish's avatar Russ Fish

Make the recent changes portable to Win32.

parent a5e8a6c9
......@@ -743,7 +743,7 @@ NAMESPACEHACK
extern HypView *hvMain(int,char *[],void *,int,int);
extern void hvKill(HypView *);
extern int hvReadFile(char *,int,int);
extern char *getSelected();
extern char const *getSelected();
extern char *getGraphCenter();
#define SWIG_MemoryError 1
......
......@@ -69,7 +69,7 @@ extern void hvKill(HypView *hv);
extern int hvReadFile(char *fname, int width, int height);
// Get the node id string last selected by the selectCB function.
extern char *getSelected();
extern char const *getSelected();
// Get the node id string at the graph center.
extern char *getGraphCenter();
......
......@@ -69,7 +69,7 @@ extern void hvKill(HypView *hv);
extern int hvReadFile(char *fname, int width, int height);
// Get the node id string last selected by the selectCB function.
extern char *getSelected();
extern char const *getSelected();
// Get the node id string at the graph center.
extern char *getGraphCenter();
......
......@@ -21,7 +21,7 @@
#include <iostream>
NAMESPACEHACK
#if 1
#ifndef WIN32
#include "wx/setup.h"
#include "wx/glcanvas.h"
#endif
......@@ -55,8 +55,12 @@ extern "C" {
//char prevsel[1024];
string prevsel;
#ifndef WIN32
auto_ptr<HypView> hv; // We own this; make sure the pointed-to HypView will be deleted.
wxGLCanvas *glcanvas; // We don't own this, so don't wrap it in an auto_ptr.
#else
HypView *hv = NULL; // VC++6 doesn't support the reset operation to change an auto_ptr.
#endif
char const *getSelected(){
return prevsel.c_str();
......@@ -79,8 +83,10 @@ void selectCB(const string & id, int shift, int control) {
}
void frameEndCB(int) {
#ifndef WIN32
//printf("frameEndCB glcanvas=0x%x\n", glcanvas);
glcanvas->SwapBuffers();
#endif
}
void display() { hv->drawFrame(); }
......@@ -136,7 +142,11 @@ void PrintAllocations()
{
// if (hv)
// delete(hv);
#ifndef WIN32
hv.reset(NULL);
#else
hv = NULL;
#endif
cerr << "HypNode objects not destroyed: " << HypNode::NumObjects() << endl;
cerr << "HypLink objects not destroyed: " << HypLink::NumObjects() << endl;
return;
......@@ -145,7 +155,13 @@ void PrintAllocations()
#if 0
int main(int argc, char *argv[]) {
#else
#ifndef WIN32
HypView *hvMain(int argc, char *argv[], void * window, int width, int height) {
#else
HypView *hvMain(int argc, char *argv[], int window, int width, int height) {
#endif
#endif
char *fname;
if (argc > 1)
......@@ -182,7 +198,7 @@ HypView *hvMain(int argc, char *argv[], void * window, int width, int height) {
#else
HWND hWnd = (HWND)window;
HDC hdc = ::GetDC(hWnd);
hv.reset(new HypView(hdc, hWnd));
hv = new HypView(hdc, hWnd);
HGLRC ctx = wglCreateContext(hdc);
if (!ctx) {
printf("wglCreateContext Failed\n");
......@@ -275,12 +291,22 @@ HypView *hvMain(int argc, char *argv[], void * window, int width, int height) {
// free(fname);
#else
#ifndef WIN32
return hv.get();
#else
return hv;
#endif
#endif
}
void hvKill(HypView * /*hv*/) {
#ifndef WIN32
delete hv.get();
#else
delete hv;
#endif
}
int hvReadFile(char *fname, int width, int height) {
......
......@@ -165,6 +165,14 @@ class hvFrame(hvFrameUI):
EVT_SCROLL_ENDSCROLL(self.AnimStepCount, self.OnAnimStepCount) # Windows
EVT_SLIDER(self.AnimStepCount, -1, self.OnAnimStepCount) # GTK
# Mouse-generated events.
EVT_LEFT_DOWN(self.hypView, self.OnClick)
EVT_LEFT_UP(self.hypView, self.OnClick)
EVT_MIDDLE_DOWN(self.hypView, self.OnClick)
EVT_MIDDLE_UP(self.hypView, self.OnClick)
EVT_MOTION(self.hypView, self.OnMove)
EVT_SIZE(self.hypView, self.OnResizeCanvas)
# Other events.
EVT_SIZE(self.window_1, self.OnResizeWindow)
EVT_SPLITTER_SASH_POS_CHANGED(self.window_1, -1, self.OnSashChanged)
......@@ -225,14 +233,6 @@ class hvFrame(hvFrameUI):
if self.vwr is None: # Must have been a problem....
return False
# Don't connect up the mouse events before the HyperView data is loaded!
EVT_LEFT_DOWN(self.hypView, self.OnClick)
EVT_LEFT_UP(self.hypView, self.OnClick)
EVT_MIDDLE_DOWN(self.hypView, self.OnClick)
EVT_MIDDLE_UP(self.hypView, self.OnClick)
EVT_MOTION(self.hypView, self.OnMove)
EVT_SIZE(self.hypView, self.OnResizeCanvas)
self.OnGoToTop(None) # Show info for the top node.
return True
......@@ -447,6 +447,9 @@ class hvFrame(hvFrameUI):
##
# Mouse click events.
def OnClick(self, mouseEvent):
if self.vwr is None:
return
# Encode mouse button events for HypView.
btnNum = -1
......@@ -487,6 +490,9 @@ class hvFrame(hvFrameUI):
##
# Mouse motion events in the HyperViewer canvas.
def OnMove(self, mouseEvent):
if self.vwr is None:
return
# Hyperviewer calls motion when a mouse button is clicked "active"
if mouseEvent.LeftIsDown() or mouseEvent.MiddleIsDown():
self.vwr.motion(mouseEvent.GetX(), mouseEvent.GetY(), 0, 0)
......@@ -520,7 +526,8 @@ class hvFrame(hvFrameUI):
self.hypView.SetSize(size)
# Tell HyperViewer about the change.
self.vwr.reshape(size.width, size.height)
if self.vwr:
self.vwr.reshape(size.width, size.height)
pass
##
......
......@@ -746,7 +746,7 @@ NAMESPACEHACK
extern HypView *hvMain(int,char *[],int,int,int);
extern void hvKill(HypView *);
extern int hvReadFile(char *,int,int);
extern char *getSelected();
extern char const *getSelected();
extern char *getGraphCenter();
#define SWIG_MemoryError 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment