Hallo,
im zu portierenden Qt3 Code wurde undokumentierte funktion qt_xget_readonly_gc benutzt. Kennt jemand das Pendant dazu in Qt4?
Eine Mögligkeit wäre, sie komplett aus Qt3 Quellen zu übernehmen, aber sie scheint selbst viele Abhängigkeiten zu den Qt-Internas zu aben.
Vielen Dank für Eure Vorschläge!
Portieren Qt3->Qt4
gelöst: qt_xget_readonly_gc Portierung zu Qt4
Hallo noch mal,
Abhängigkeiten waren doch nicht so wild wie befürchtet:
1 typedef, 4 globale Variablen und 1 Funktion
//VH taken grom Qt3-src
typedef struct _XGC *GC;
static Display *appDpy = 0; // X11 application display
static int appScreenCount = 0;
static GC* app_gc_ro = 0; // read-only GC
static GC* app_gc_ro_m = 0; // read-only GC (monochrome)
static GC create_gc( int scrn, bool monochrome )
{
GC gc;
if ( monochrome ) {
Pixmap pm = XCreatePixmap( appDpy, RootWindow( appDpy, scrn ), 8, 8, 1 );
gc = XCreateGC( appDpy, pm, 0, 0 );
XFreePixmap( appDpy, pm );
} else {
if ( QPaintDevice::x11AppDefaultVisual( scrn ) ) {
gc = XCreateGC( appDpy, RootWindow( appDpy, scrn ), 0, 0 );
} else {
Window w;
XSetWindowAttributes a;
a.background_pixel = QColor(Qt::black).pixel( scrn );
a.border_pixel = QColor(Qt::black).pixel( scrn );
a.colormap = QPaintDevice::x11AppColormap( scrn );
w = XCreateWindow( appDpy, RootWindow( appDpy, scrn ), 0, 0, 100, 100,
0, QPaintDevice::x11AppDepth( scrn ), InputOutput,
(Visual*)QPaintDevice::x11AppVisual( scrn ),
CWBackPixel|CWBorderPixel|CWColormap, &a );
gc = XCreateGC( appDpy, w, 0, 0 );
XDestroyWindow( appDpy, w );
}
}
XSetGraphicsExposures( appDpy, gc, False );
return gc;
}
GC qt_xget_readonly_gc( int scrn, bool monochrome ) // get read-only GC
{
if ( scrn < 0 || scrn >= appScreenCount ) {
qDebug("invalid screen %d %d", scrn, appScreenCount );
QWidget* bla = 0;
bla->setName("hello");
}
GC gc;
if ( monochrome ) {
if ( !app_gc_ro_m ) // create GC for bitmap
memset( (app_gc_ro_m = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) );
if ( !app_gc_ro_m[scrn] )
app_gc_ro_m[scrn] = create_gc( scrn, TRUE );
gc = app_gc_ro_m[scrn];
} else { // create standard GC
if ( !app_gc_ro )
memset( (app_gc_ro = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) );
if ( !app_gc_ro[scrn] )
app_gc_ro[scrn] = create_gc( scrn, FALSE );
gc = app_gc_ro[scrn];
}
return gc;
}
//VH EOF taken grom Qt3-src
Gruß.
Abhängigkeiten waren doch nicht so wild wie befürchtet:
1 typedef, 4 globale Variablen und 1 Funktion
//VH taken grom Qt3-src
typedef struct _XGC *GC;
static Display *appDpy = 0; // X11 application display
static int appScreenCount = 0;
static GC* app_gc_ro = 0; // read-only GC
static GC* app_gc_ro_m = 0; // read-only GC (monochrome)
static GC create_gc( int scrn, bool monochrome )
{
GC gc;
if ( monochrome ) {
Pixmap pm = XCreatePixmap( appDpy, RootWindow( appDpy, scrn ), 8, 8, 1 );
gc = XCreateGC( appDpy, pm, 0, 0 );
XFreePixmap( appDpy, pm );
} else {
if ( QPaintDevice::x11AppDefaultVisual( scrn ) ) {
gc = XCreateGC( appDpy, RootWindow( appDpy, scrn ), 0, 0 );
} else {
Window w;
XSetWindowAttributes a;
a.background_pixel = QColor(Qt::black).pixel( scrn );
a.border_pixel = QColor(Qt::black).pixel( scrn );
a.colormap = QPaintDevice::x11AppColormap( scrn );
w = XCreateWindow( appDpy, RootWindow( appDpy, scrn ), 0, 0, 100, 100,
0, QPaintDevice::x11AppDepth( scrn ), InputOutput,
(Visual*)QPaintDevice::x11AppVisual( scrn ),
CWBackPixel|CWBorderPixel|CWColormap, &a );
gc = XCreateGC( appDpy, w, 0, 0 );
XDestroyWindow( appDpy, w );
}
}
XSetGraphicsExposures( appDpy, gc, False );
return gc;
}
GC qt_xget_readonly_gc( int scrn, bool monochrome ) // get read-only GC
{
if ( scrn < 0 || scrn >= appScreenCount ) {
qDebug("invalid screen %d %d", scrn, appScreenCount );
QWidget* bla = 0;
bla->setName("hello");
}
GC gc;
if ( monochrome ) {
if ( !app_gc_ro_m ) // create GC for bitmap
memset( (app_gc_ro_m = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) );
if ( !app_gc_ro_m[scrn] )
app_gc_ro_m[scrn] = create_gc( scrn, TRUE );
gc = app_gc_ro_m[scrn];
} else { // create standard GC
if ( !app_gc_ro )
memset( (app_gc_ro = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) );
if ( !app_gc_ro[scrn] )
app_gc_ro[scrn] = create_gc( scrn, FALSE );
gc = app_gc_ro[scrn];
}
return gc;
}
//VH EOF taken grom Qt3-src
Gruß.
-
Christian81
- Beiträge: 7319
- Registriert: 26. August 2004 14:11
- Wohnort: Bremen
- Kontaktdaten: