// Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL]
// see below for copyright information on the second portion of this file
-#include "POSIX.cc"
-
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <X11/keysymdef.h>
#include <X11/Xmu/StdCmap.h>
#include <java/lang/String.h>
-#include <org/ibex/Surface.h>
-#include <org/ibex/Picture.h>
-#include <org/ibex/Box.h>
+#include <org/ibex/graphics/Surface.h>
+#include <org/ibex/graphics/Picture.h>
+#include <org/ibex/core/Box.h>
#include <org/ibex/plat/X11.h>
#include <org/ibex/plat/X11$X11Surface.h>
#include <org/ibex/plat/X11$X11Picture.h>
#include <org/ibex/plat/X11$X11PixelBuffer.h>
#include <org/ibex/util/Semaphore.h>
-#include <org/ibex/Platform.h>
+#include <org/ibex/plat/Platform.h>
#include <java/lang/Long.h>
#include <java/util/Hashtable.h>
#include <org/ibex/util/Log.h>
#include <java/lang/System.h>
#include <java/io/PrintStream.h>
+#include "POSIX.cc"
+
// static (per-xserver) data
static Visual* visual;
static Colormap s_colormap;
}
}
-void org::ibex::plat::X11$X11PixelBuffer::fastDrawPicture(org::ibex::Picture* s,
+void org::ibex::plat::X11$X11PixelBuffer::fastDrawPicture(org::ibex::graphics::Picture* s,
jint dx, jint dy, jint cx1, jint cy1, jint cx2, jint cy2) {
org::ibex::plat::X11$X11Picture* source = (org::ibex::plat::X11$X11Picture*)s;
cx1 - dx, cy1 - dy, cx2 - cx1, cy2 - cy1, cx1, cy1);
}
-void org::ibex::plat::X11$X11PixelBuffer::slowDrawPicture(org::ibex::Picture* s,
+void org::ibex::plat::X11$X11PixelBuffer::slowDrawPicture(org::ibex::graphics::Picture* s,
jint dx, jint dy, jint cx1, jint cy1, jint cx2, jint cy2,
jint rgb, jboolean alphaOnly) {
(((int)*(current_pixel + 1)) << 8) |
(((int)*(current_pixel + 2))); break;
case 32: targetpixel = *((int*)current_pixel); break;
- default: org::ibex::Platform::criticalAbort(JvNewStringLatin1("ERROR: bpp not a multiple of 8!"));
+ default: org::ibex::plat::Platform::criticalAbort(JvNewStringLatin1("ERROR: bpp not a multiple of 8!"));
}
targetpixel -= colormap_info->base_pixel;
break;
}
case 32: *((uint32_t*)current_pixel) = destpixel; break;
- default: org::ibex::Platform::criticalAbort(JvNewStringLatin1("ERROR: bpp not a multiple of 8!"));
+ default: org::ibex::plat::Platform::criticalAbort(JvNewStringLatin1("ERROR: bpp not a multiple of 8!"));
}
}
}
XPutImage(display, (*((Pixmap*)stipple)), stipple_gc, &xi, 0, 0, 0, 0, width, height);
}
-void org::ibex::plat::X11$X11Surface::blit(org::ibex::PixelBuffer* db, jint sx, jint sy, jint dx, jint dy, jint dx2, jint dy2) {
+void org::ibex::plat::X11$X11Surface::blit(org::ibex::graphics::PixelBuffer* db, jint sx, jint sy, jint dx, jint dy, jint dx2, jint dy2) {
org::ibex::plat::X11$X11PixelBuffer *xdb = (org::ibex::plat::X11$X11PixelBuffer*)db;
XCopyArea(display, *((Pixmap*)xdb->pm), *((Window*)window), *((GC*)gc), sx, sy, dx2 - dx, dy2 - dy, dx, dy);
XFlush(display);
// X11Surface //////////////////////////////////////////////////////////////////////
-void org::ibex::plat::X11$X11Surface::setIcon(org::ibex::Picture* pic) {
+void org::ibex::plat::X11$X11Surface::setIcon(org::ibex::graphics::Picture* pic) {
org::ibex::plat::X11$X11Picture* p = ((org::ibex::plat::X11$X11Picture*)pic);
org::ibex::plat::X11$X11PixelBuffer* old_dbuf = p->doublebuf;
p->buildPixelBuffer(1);
XTextProperty tp;
tp.value = (unsigned char*)"Ibex";
- tp.nitems = 3;
+ tp.nitems = 4;
tp.encoding = XA_STRING;
tp.format = 8;
XSetTextProperty(display, (*((Window*)window)), &tp, XA_WM_CLASS);
} else if (e->type == ButtonPress) {
XButtonEvent* xbe = (XButtonEvent*)(e);
+ switch(xbe->button) {
+ case 4: VScroll((jfloat)-1.0); return;
+ case 5: VScroll((jfloat)1.0); return;
+ case 6: HScroll((jfloat)-1.0); return;
+ case 7: HScroll((jfloat)1.0); return;
+ }
if (xbe->button == 2) xbe->button = 3;
else if (xbe->button == 3) xbe->button = 2;
Press(xbe->button);
void org::ibex::plat::X11::natInit() {
if (!XInitThreads())
- org::ibex::Platform::criticalAbort(JvNewStringLatin1("Your X11 libraries do not support multithreaded programs"));
+ org::ibex::plat::Platform::criticalAbort(JvNewStringLatin1("Your X11 libraries do not support multithreaded programs"));
char* DISPLAY = getenv("DISPLAY");
if (DISPLAY == NULL || strlen(DISPLAY) == 0) DISPLAY = ":0.0";
display = XOpenDisplay(DISPLAY);
if (display == 0)
- org::ibex::Platform::criticalAbort(JvNewStringLatin1("Unable to connect to X11 display server"));
+ org::ibex::plat::Platform::criticalAbort(JvNewStringLatin1("Unable to connect to X11 display server"));
screen_num = XDefaultScreen(display);
colorDepth = (jint)(DefaultDepth(((Display*)display), 0));
// FIXME: don't know why (True, False) is the best solution...
if(XmuLookupStandardColormap(display, screen_num, visual->visualid, colorDepth, XA_RGB_BEST_MAP, True, False) == 0)
- org::ibex::Platform::criticalAbort(JvNewStringLatin1("ERROR: XmuLookupStandardColormap failed"));
-
+ org::ibex::plat::Platform::criticalAbort(JvNewStringLatin1("ERROR: XmuLookupStandardColormap failed"));
XStandardColormap* best_map_info = NULL;
int count;
if (XGetRGBColormaps(display, RootWindow(display, screen_num), &best_map_info, &count, XA_RGB_BEST_MAP) == 0)
- org::ibex::Platform::criticalAbort(JvNewStringLatin1("ERROR: couldn't allocate a standard colormap"));
+ org::ibex::plat::Platform::criticalAbort(JvNewStringLatin1("ERROR: couldn't allocate a standard colormap"));
if (!best_map_info->colormap)
- org::ibex::Platform::criticalAbort(JvNewStringLatin1("ERROR: XmuLookupStandardColomap succeded, but no colormap was found on the root window"));
+ org::ibex::plat::Platform::criticalAbort(JvNewStringLatin1("ERROR: XmuLookupStandardColomap succeded, but no colormap was found on the root window"));
if (best_map_info->red_max == 0)
- org::ibex::Platform::criticalAbort(JvNewStringLatin1("ERROR: standard colormap exists, but was improperly allocated"));
+ org::ibex::plat::Platform::criticalAbort(JvNewStringLatin1("ERROR: standard colormap exists, but was improperly allocated"));
s_colormap = best_map_info->colormap;
colormap_info = best_map_info;
org::ibex::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
}
-
+#include "WINGs/WINGs.h"
+jstring org::ibex::plat::X11::_fileDialog(jstring suggestedFileName, jboolean write) {
+ int argc = 1;
+ char* argv[2];
+ argv[0] = "Ibex";
+ argv[1] = NULL;
+ // FIXME see WINGs/Tests/filedialog.c for more info... need an icon
+ WMInitializeApplication("Ibex", &argc, argv);
+ WMScreen *scr = WMCreateSimpleApplicationScreen(display);
+ int len = min(1024, JvGetStringUTFLength(suggestedFileName));
+ char buf[len + 1];
+ JvGetStringUTFRegion(suggestedFileName, 0, len, buf);
+ buf[len] = '\0';
+ if (write) {
+ WMSavePanel *sPanel;
+ sPanel = WMGetSavePanel(scr);
+ if (WMRunModalFilePanelForDirectory(sPanel, NULL, buf, /*title*/ NULL, NULL) != True) return NULL;
+ return JvNewStringLatin1(WMGetFilePanelFileName(sPanel));
+ } else {
+ WMOpenPanel *oPanel;
+ oPanel = WMGetOpenPanel(scr);
+ if (WMRunModalFilePanelForDirectory(oPanel, NULL, buf, /*title*/ NULL, NULL) != True) return NULL;
+ return JvNewStringLatin1(WMGetFilePanelFileName(oPanel));
+ }
+ return NULL;
+}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
}
}
+