示例#1
0
void InsertTextWidget::mouseMoveEvent(QMouseEvent* e)
{
    if ( rect().contains( e->x(), e->y() ) )
    {
        if ( e->buttons() == Qt::LeftButton && d->currentMoving )
        {
            uint newxpos = e->x();
            uint newypos = e->y();

            d->textRect.translate(newxpos - d->xpos, newypos - d->ypos);

            makePixmap();
            repaint();

            d->xpos = newxpos;
            d->ypos = newypos;
            setCursor( Qt::PointingHandCursor );
        }
        else if ( d->textRect.contains( e->x(), e->y() ) )
        {
            setCursor ( Qt::SizeAllCursor );
        }
        else
        {
            setCursor ( Qt::ArrowCursor );
        }
    }
}
示例#2
0
void InsertTextWidget::resetEdit()
{
    // signal this needs to be filled by makePixmap
    d->textRect = QRect();
    makePixmap();
    repaint();
}
示例#3
0
SoundUserConfig::SoundUserConfig(QWidget *parent, void *data, SoundPlugin *plugin)
        : SoundUserConfigBase(parent)
{
    m_plugin = plugin;
    lstSound->addColumn(i18n("Sound"));
    lstSound->addColumn(i18n("File"));
    lstSound->setExpandingColumn(1);

    SoundUserData *user_data = (SoundUserData*)data;
    string s;
    s = plugin->fullName(user_data->Alert);
    QListViewItem *item = new QListViewItem(lstSound, i18n("Online alert"), QFile::decodeName(s.c_str()));
    item->setText(2, QString::number(ONLINE_ALERT));
    item->setPixmap(0, makePixmap("licq"));

    CommandDef *cmd;
    CommandsMapIterator it(m_plugin->core->messageTypes);
    while ((cmd = ++it) != NULL){
        MessageDef *def = (MessageDef*)(cmd->param);
        if ((def == NULL) || (cmd->icon == NULL) ||
                (def->flags & (MESSAGE_HIDDEN | MESSAGE_SENDONLY)))
            continue;
		if ((def->singular == NULL) || (def->plural == NULL) || 
			(*def->singular == 0) || (*def->plural == 0))
			continue;
        QString type = i18n(def->singular, def->plural, 1);
		int pos = type.find("1 ");
		if (pos == 0){
			type = type.mid(2);
		}else if (pos > 0){
			type = type.left(pos);
		}
        type = type.left(1).upper() + type.mid(1);
        item = new QListViewItem(lstSound, type,
                                 QFile::decodeName(m_plugin->messageSound(cmd->id, user_data).c_str()));
        item->setText(2, QString::number(cmd->id));
        item->setPixmap(0, makePixmap(cmd->icon));
    }
    lstSound->adjustColumn();
    chkActive->setChecked((user_data->NoSoundIfActive) != 0);
    chkDisable->setChecked((user_data->Disable) != 0);
    connect(chkDisable, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
    toggled((user_data->Disable) != 0);
    m_edit = NULL;
    m_editItem = NULL;
    connect(lstSound, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*)));
}
示例#4
0
static void showText(WScreen *scr, int x, int y, int h, int w, const char *text)
{
	int width;
	int height;
	Pixmap pixmap;
	Pixmap mask;
	WMFont *font = scr->info_text_font;
	int side = 0;
	int ty;
	int bx, by;

	if (scr->balloon->contents)
		XFreePixmap(dpy, scr->balloon->contents);

	width = getMaxStringWidth(font, text) + 16;
	height = countLines(text) * WMFontHeight(font) + 4;

	if (height < 16)
		height = 16;
	if (width < height)
		width = height;

	if (x + width > scr->scr_width) {
		side = RIGHT;
		bx = x - width + w / 2;
		if (bx < 0)
			bx = 0;
	} else {
		side = LEFT;
		bx = x + w / 2;
	}
	if (bx + width > scr->scr_width)
		bx = scr->scr_width - width;

	if (y - (height + SPACE) < 0) {
		side |= TOP;
		by = y + h - 1;
		ty = SPACE;
	} else {
		side |= BOTTOM;
		by = y - (height + SPACE);
		ty = 0;
	}
	pixmap = makePixmap(scr, width, height, side, &mask);

	drawMultiLineString(scr->wmscreen, pixmap, scr->black, font, 8, ty + 2, text, strlen(text));

	XSetWindowBackgroundPixmap(dpy, scr->balloon->window, pixmap);
	scr->balloon->contents = pixmap;

	XResizeWindow(dpy, scr->balloon->window, width, height + SPACE);
	XShapeCombineMask(dpy, scr->balloon->window, ShapeBounding, 0, 0, mask, ShapeSet);
	XFreePixmap(dpy, mask);
	XMoveWindow(dpy, scr->balloon->window, bx, by);
	XMapRaised(dpy, scr->balloon->window);

	scr->balloon->mapped = 1;
}
示例#5
0
void Waveform::reset()
{
    makePixmap();

    currentValue = 0;
    numSamples = 0;
    windowPosn = 0;

    update();
}
示例#6
0
void InsertTextWidget::setPositionHint(const QRect& hint)
{
    // interpreted by composeImage
    d->positionHint = hint;

    if (d->textRect.isValid())
    {
        // invalidate current position so that hint is certainly interpreted
        d->textRect = QRect();
        makePixmap();
        repaint();
    }
}
示例#7
0
NPError 
NPP_SetWindow(NPP instance, NPWindow* window)
{
    PluginInstance* This;
    NPSetWindowCallbackStruct *ws_info;

    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;

    This = (PluginInstance*) instance->pdata;

    if (This == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;

    ws_info = (NPSetWindowCallbackStruct *)window->ws_info;

#ifdef MOZ_X11
    if (This->window == (Window) window->window) {
        /* The page with the plugin is being resized.
           Save any UI information because the next time
           around expect a SetWindow with a new window
           id.
        */
#ifdef DEBUG
        fprintf(stderr, "Nullplugin: plugin received window resize.\n");
        fprintf(stderr, "Window=(%i)\n", (int)window);
        if (window) {
           fprintf(stderr, "W=(%i) H=(%i)\n",
               (int)window->width, (int)window->height);
        }
#endif
        return NPERR_NO_ERROR;
    } else {

      This->window = (Window) window->window;
      This->x = window->x;
      This->y = window->y;
      This->width = window->width;
      This->height = window->height;
      This->display = ws_info->display;
      This->visual = ws_info->visual;
      This->depth = ws_info->depth;
      This->colormap = ws_info->colormap;
      makePixmap(This);
      makeWidget(This);
    }
#endif  /* #ifdef MOZ_X11 */
    
    return NPERR_NO_ERROR;
}
示例#8
0
void Waveform::changeSettings( int frequency, int channels )
{
    makePixmap();

    samplesPerPixel = frequency * channels / (5 * windowSize);
    if (samplesPerPixel == 0 )
        samplesPerPixel = 1;

    currentValue = 0;
    numSamples = 0;
    windowPosn = 0;

    update();
}
示例#9
0
void InsertTextWidget::setText(const QString& text, const QFont& font, const QColor& color, int opacity,
                               int alignMode, bool border, bool transparent, int rotation)
{
    d->textString      = text;
    d->textColor       = color;
    d->textOpacity     = opacity;
    d->textBorder      = border;
    d->textTransparent = transparent;
    d->textRotation    = rotation;

    switch (alignMode)
    {
        case ALIGN_LEFT:
            d->alignMode = Qt::AlignLeft;
            break;

        case ALIGN_RIGHT:
            d->alignMode = Qt::AlignRight;
            break;

        case ALIGN_CENTER:
            d->alignMode = Qt::AlignHCenter;
            break;

        case ALIGN_BLOCK:
            d->alignMode = Qt::AlignJustify;
            break;
    }

    // Center text if top left corner text area is not visible.

/*
    if ( d->textFont.pointSize() != font.pointSize() &&
         !rect().contains( d->textRect.x(), d->textRect.y() ) )
    {
        d->textFont = font;
        resetEdit();
        return;
    }
*/

    d->textFont = font;

    makePixmap();
    repaint();
}
示例#10
0
void InsertTextWidget::resizeEvent(QResizeEvent* e)
{
    blockSignals(true);
    delete d->pixmap;

    int w     = e->size().width();
    int h     = e->size().height();

    int textX = d->textRect.x() - d->rect.x();
    int textY = d->textRect.y() - d->rect.y();
    int old_w = d->w;
    int old_h = d->h;
    d->iface->setPreviewSize(QSize(w, h));
    d->w      = d->iface->previewSize().width();
    d->h      = d->iface->previewSize().height();

    d->pixmap = new QPixmap(w, h);
    d->rect   = QRect(w/2-d->w/2, h/2-d->h/2, d->w, d->h);

    if (d->textRect.isValid())
    {
        int textWidth  = d->textRect.width();
        int textHeight = d->textRect.height();

        textX      = qRound(textX      * (float)d->w / (float)old_w);
        textY      = qRound(textY      * (float)d->h / (float)old_h);
        textWidth  = qRound(textWidth  * (float)d->w / (float)old_w);
        textHeight = qRound(textHeight * (float)d->h / (float)old_h);

        d->textRect.setX(textX + d->rect.x());
        d->textRect.setY(textY + d->rect.y());
        d->textRect.setWidth(textWidth);
        d->textRect.setHeight(textHeight);
        makePixmap();
    }

    blockSignals(false);
}
示例#11
0
GLObjectWindow::GLObjectWindow( QWidget* parent, const char* name )
    : QWidget( parent, name )
{
    // Create a menu
    file = new QPopupMenu( this );
    file->setCheckable( TRUE );
    file->insertItem( "Grab Frame Buffer", this, SLOT(grabFrameBuffer()) );
    file->insertItem( "Render Pixmap", this, SLOT(makePixmap()) );
    file->insertItem( "Render Pixmap Hidden", this, SLOT(makePixmapHidden()) );
    file->insertSeparator();
    fixMenuItemId = file->insertItem( "Use Fixed Pixmap Size", this, 
				      SLOT(useFixedPixmapSize()) );
    file->insertSeparator();
    insertMenuItemId = file->insertItem( "Insert Pixmap Here", this, 
					 SLOT(makePixmapForMenu()) );
    file->insertSeparator();
    file->insertItem( "Exit",  qApp, SLOT(quit()), CTRL+Key_Q );

    // Create a menu bar
    QMenuBar *m = new QMenuBar( this );
    m->setSeparator( QMenuBar::InWindowsStyle );
    m->insertItem("&File", file );

    // Create nice frames to put around the OpenGL widgets
    QFrame* f1 = new QFrame( this, "frame1" );
    f1->setFrameStyle( QFrame::Sunken | QFrame::Panel );
    f1->setLineWidth( 2 );

    // Create an OpenGL widget
    c1 = new GLBox( f1, "glbox1");

    // Create a label that can display the pixmap
    lb = new QLabel( this, "pixlabel" );
    lb->setFrameStyle( QFrame::Sunken | QFrame::Panel );
    lb->setLineWidth( 2 );
    lb->setAlignment( AlignCenter );
    lb->setMargin( 0 );
    lb->setIndent( 0 );

    // Create the three sliders; one for each rotation axis
    QSlider* x = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "xsl" );
    x->setTickmarks( QSlider::Left );
    connect( x, SIGNAL(valueChanged(int)), c1, SLOT(setXRotation(int)) );

    QSlider* y = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "ysl" );
    y->setTickmarks( QSlider::Left );
    connect( y, SIGNAL(valueChanged(int)), c1, SLOT(setYRotation(int)) );

    QSlider* z = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "zsl" );
    z->setTickmarks( QSlider::Left );
    connect( z, SIGNAL(valueChanged(int)), c1, SLOT(setZRotation(int)) );


    // Now that we have all the widgets, put them into a nice layout

    // Put the sliders on top of each other
    QVBoxLayout* vlayout = new QVBoxLayout( 20, "vlayout");
    vlayout->addWidget( x );
    vlayout->addWidget( y );
    vlayout->addWidget( z );

    // Put the GL widget inside the frame
    QHBoxLayout* flayout1 = new QHBoxLayout( f1, 2, 2, "flayout1");
    flayout1->addWidget( c1, 1 );

    // Top level layout, puts the sliders to the left of the frame/GL widget
    QHBoxLayout* hlayout = new QHBoxLayout( this, 20, 20, "hlayout");
    hlayout->setMenuBar( m );
    hlayout->addLayout( vlayout );
    hlayout->addWidget( f1, 1 );
    hlayout->addWidget( lb, 1 );

}
示例#12
0
void InsertTextWidget::setBackgroundColor(const QColor& bg)
{
    d->bgColor = bg;
    makePixmap();
    repaint();
}
示例#13
0
static void showText(Balloon * bPtr, int x, int y, int w, int h, const char *text)
{
	WMScreen *scr = bPtr->view->screen;
	Display *dpy = WMScreenDisplay(scr);
	int width;
	int height;
	Pixmap pixmap;
	Pixmap mask;
	WMFont *font = bPtr->font ? bPtr->font : scr->normalFont;
	int textHeight;
	int side = 0;
	int ty;
	int bx, by;

	{
		int w;
		const char *ptr, *ptr2;

		ptr2 = ptr = text;
		width = 0;
		while (ptr && ptr2) {
			ptr2 = strchr(ptr, '\n');
			if (ptr2) {
				w = WMWidthOfString(font, ptr, ptr2 - ptr);
			} else {
				w = WMWidthOfString(font, ptr, strlen(ptr));
			}
			if (w > width)
				width = w;
			ptr = ptr2 + 1;
		}
	}

	width += 16;

	textHeight = W_GetTextHeight(font, text, width, False);

	height = textHeight + 4;

	if (height < 16)
		height = 16;
	if (width < height)
		width = height;

	if (x + width > scr->rootView->size.width) {
		side = RIGHT;
		bx = x - width + w / 2;
		if (bx < 0)
			bx = 0;
	} else {
		side = LEFT;
		bx = x + w / 2;
	}
	if (bx + width > scr->rootView->size.width)
		bx = scr->rootView->size.width - width;

	if (y - (height + SPACE) < 0) {
		side |= TOP;
		by = y + h - 1;
		ty = SPACE;
	} else {
		side |= BOTTOM;
		by = y - (height + SPACE);
		ty = 0;
	}
	pixmap = makePixmap(scr, width, height, side, &mask);

	W_PaintText(bPtr->view, pixmap, font, 8, ty + (height - textHeight) / 2,
		    width, bPtr->flags.alignment,
		    bPtr->textColor ? bPtr->textColor : scr->black, False, text, strlen(text));

	XSetWindowBackgroundPixmap(dpy, bPtr->view->window, pixmap);

	W_ResizeView(bPtr->view, width, height + SPACE);

	XFreePixmap(dpy, pixmap);

#ifdef USE_XSHAPE
	XShapeCombineMask(dpy, bPtr->view->window, ShapeBounding, 0, 0, mask, ShapeSet);
#endif
	XFreePixmap(dpy, mask);

	W_MoveView(bPtr->view, bx, by);

	W_MapView(bPtr->view);
}
示例#14
0
NPError 
NPP_SetWindow(NPP instance, NPWindow* window)
{
    PluginInstance* This;
    NPSetWindowCallbackStruct *ws_info;
    const SDL_VideoInfo* info = NULL;
    char windowEnv[3][500];
   	
    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;

    This = (PluginInstance*) instance->pdata;

    if (This == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;

    ws_info = (NPSetWindowCallbackStruct *)window->ws_info;

    fprintf(stderr,"Setting up events for viewer\n");
    int app_event_mask = !ButtonPressMask;
    XSelectInput(ws_info->display, (int)(window->window), app_event_mask);

    fprintf(stderr,"Loading environment for viewer:\n");
    sprintf(windowEnv[0],"SDL_WINDOWID=%d",(int)(window->window));
    sprintf(windowEnv[1],"FFW_WINX=%d",(int)(window->width));
    sprintf(windowEnv[2],"FFW_WINY=%d",(int)(window->height));
    int i=0;
    for(i=0; i<3; i++) putenv(windowEnv[i]);

    fprintf(stderr, "Window=(%i)\n", (int)(window->window));
    fprintf(stderr, "W=(%i) H=(%i)\n",(int)window->width, (int)window->height);

/*
    if(SDL_Init(SDL_INIT_EVERYTHING)==-1) return NPERR_GENERIC_ERROR;
    info = SDL_GetVideoInfo();
	if(!info) { fprintf(stderr,"err1\n"); return NPERR_GENERIC_ERROR; }

	SDL_GL_SetAttribute(SDL_GL_RED_SIZE,8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,16);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,8);
	

	if((SDL_SetVideoMode(window->x,window->y,0,SDL_OPENGL | SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_ASYNCBLIT ))==0) { fprintf(stderr,"err2\n"); return NPERR_GENERIC_ERROR; }
	glViewport(0,0,(GLsizei) window->x , (GLsizei) window->y );
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D (0.0, (GLdouble) window->x, 0.0, (GLdouble) window->y);
	/*glEnable(GL_LINE_SMOOTH);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glClearColor(1,0,0,1);*/
	/**/
#ifdef MOZ_X11
//    if (This->window == (Window) window->window) {
        /* The page with the plugin is being resized.
           Save any UI information because the next time
           around expect a SetWindow with a new window
           id.
        */
//        return NPERR_NO_ERROR;
 //   } else {

      This->window = (Window) window->window;
      This->x = window->x;
      This->y = window->y;
      This->width = window->width;
      This->height = window->height;
      This->display = ws_info->display;
      This->visual = ws_info->visual;
      This->depth = ws_info->depth;
      This->colormap = ws_info->colormap;
      makePixmap(This);
      makeWidget(This);
//    }
#endif  /* #ifdef MOZ_X11 */
    if (viewer_proc == NULL) {
        char viewerArgs[2][50];
        PRProcessAttr* viewerProcAttr = PR_NewProcessAttr();
        PR_ProcessAttrSetCurrentDirectory(viewerProcAttr,"/slbrowser/");
        sprintf(viewerArgs[0],"/slbrowser/packaged/secondlife\0");
        sprintf(viewerArgs[1],"--autologin\0");
        fprintf(stderr,"Starting viewer!\n");
        viewer_proc = PR_CreateProcess("/slbrowser/secondlife",NULL,NULL,viewerProcAttr);
        PR_DetachProcess(viewer_proc);
    }

    return NPERR_NO_ERROR;
}
示例#15
0
文件: widgets.c 项目: awmaker/awmaker
WMScreen *WMCreateScreenWithRContext(Display * display, int screen, RContext * context)
{
	W_Screen *scrPtr;
	XGCValues gcv;
	Pixmap stipple;
	static int initialized = 0;
	static char *atomNames[] = {
		"_GNUSTEP_WM_ATTR",
		"WM_DELETE_WINDOW",
		"WM_PROTOCOLS",
		"CLIPBOARD",
		"XdndAware",
		"XdndSelection",
		"XdndEnter",
		"XdndLeave",
		"XdndPosition",
		"XdndDrop",
		"XdndFinished",
		"XdndTypeList",
		"XdndActionList",
		"XdndActionDescription",
		"XdndStatus",
		"XdndActionCopy",
		"XdndActionMove",
		"XdndActionLink",
		"XdndActionAsk",
		"XdndActionPrivate",
		"_WINGS_DND_MOUSE_OFFSET",
		"WM_STATE",
		"UTF8_STRING",
		"_NET_WM_NAME",
		"_NET_WM_ICON_NAME",
		"_NET_WM_ICON",
	};
	Atom atoms[wlengthof(atomNames)];
	int i;

	if (!initialized) {

		initialized = 1;

		W_ReadConfigurations();

		assert(W_ApplicationInitialized());
	}

	scrPtr = malloc(sizeof(W_Screen));
	if (!scrPtr)
		return NULL;
	memset(scrPtr, 0, sizeof(W_Screen));

	scrPtr->aflags.hasAppIcon = 1;

	scrPtr->display = display;
	scrPtr->screen = screen;
	scrPtr->rcontext = context;

	scrPtr->depth = context->depth;

	scrPtr->visual = context->visual;
	scrPtr->lastEventTime = 0;

	scrPtr->colormap = context->cmap;

	scrPtr->rootWin = RootWindow(display, screen);

	scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks);

	scrPtr->xftdraw = XftDrawCreate(scrPtr->display, W_DRAWABLE(scrPtr), scrPtr->visual, scrPtr->colormap);

	/* Create missing CUT_BUFFERs */
	{
		Atom *rootWinProps;
		int exists[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
		int count;

		rootWinProps = XListProperties(display, scrPtr->rootWin, &count);
		for (i = 0; i < count; i++) {
			switch (rootWinProps[i]) {
			case XA_CUT_BUFFER0:
				exists[0] = 1;
				break;
			case XA_CUT_BUFFER1:
				exists[1] = 1;
				break;
			case XA_CUT_BUFFER2:
				exists[2] = 1;
				break;
			case XA_CUT_BUFFER3:
				exists[3] = 1;
				break;
			case XA_CUT_BUFFER4:
				exists[4] = 1;
				break;
			case XA_CUT_BUFFER5:
				exists[5] = 1;
				break;
			case XA_CUT_BUFFER6:
				exists[6] = 1;
				break;
			case XA_CUT_BUFFER7:
				exists[7] = 1;
				break;
			default:
				break;
			}
		}
		if (rootWinProps) {
			XFree(rootWinProps);
		}
		for (i = 0; i < 8; i++) {
			if (!exists[i]) {
				XStoreBuffer(display, "", 0, i);
			}
		}
	}

	scrPtr->ignoredModifierMask = 0;
	{
		int i;
		XModifierKeymap *modmap;
		KeyCode nlock, slock;
		static int mask_table[8] = {
			ShiftMask, LockMask, ControlMask, Mod1Mask,
			Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
		};
		unsigned int numLockMask = 0, scrollLockMask = 0;

		nlock = XKeysymToKeycode(display, XK_Num_Lock);
		slock = XKeysymToKeycode(display, XK_Scroll_Lock);

		/*
		 * Find out the masks for the NumLock and ScrollLock modifiers,
		 * so that we can bind the grabs for when they are enabled too.
		 */
		modmap = XGetModifierMapping(display);

		if (modmap != NULL && modmap->max_keypermod > 0) {
			for (i = 0; i < 8 * modmap->max_keypermod; i++) {
				if (modmap->modifiermap[i] == nlock && nlock != 0)
					numLockMask = mask_table[i / modmap->max_keypermod];
				else if (modmap->modifiermap[i] == slock && slock != 0)
					scrollLockMask = mask_table[i / modmap->max_keypermod];
			}
		}

		if (modmap)
			XFreeModifiermap(modmap);

		scrPtr->ignoredModifierMask = numLockMask | scrollLockMask | LockMask;
	}

	/* initially allocate some colors */
	WMWhiteColor(scrPtr);
	WMBlackColor(scrPtr);
	WMGrayColor(scrPtr);
	WMDarkGrayColor(scrPtr);

	gcv.graphics_exposures = False;

	gcv.function = GXxor;
	gcv.foreground = W_PIXEL(scrPtr->white);
	if (gcv.foreground == 0)
		gcv.foreground = 1;
	scrPtr->xorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
				  | GCGraphicsExposures | GCForeground, &gcv);

	gcv.function = GXxor;
	gcv.foreground = W_PIXEL(scrPtr->gray);
	gcv.subwindow_mode = IncludeInferiors;
	scrPtr->ixorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
				   | GCGraphicsExposures | GCForeground | GCSubwindowMode, &gcv);

	gcv.function = GXcopy;
	scrPtr->copyGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction | GCGraphicsExposures, &gcv);

	scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction | GCGraphicsExposures, &gcv);

	stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr), STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
	gcv.foreground = W_PIXEL(scrPtr->darkGray);
	gcv.background = W_PIXEL(scrPtr->gray);
	gcv.fill_style = FillStippled;
	gcv.stipple = stipple;
	scrPtr->stippleGC = XCreateGC(display, W_DRAWABLE(scrPtr),
				      GCForeground | GCBackground | GCStipple
				      | GCFillStyle | GCGraphicsExposures, &gcv);

	scrPtr->drawStringGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCGraphicsExposures, &gcv);
	scrPtr->drawImStringGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCGraphicsExposures, &gcv);

	/* we need a 1bpp drawable for the monoGC, so borrow this one */
	scrPtr->monoGC = XCreateGC(display, stipple, 0, NULL);

	scrPtr->stipple = stipple;

	scrPtr->antialiasedText = WINGsConfiguration.antialiasedText;

	scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 0);

	scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 0);

	if (!scrPtr->boldFont)
		scrPtr->boldFont = scrPtr->normalFont;

	if (!scrPtr->normalFont) {
		wwarning(_("could not load any fonts. Make sure your font installation"
			   " and locale settings are correct."));

		return NULL;
	}

	/* create input method stuff */
	W_InitIM(scrPtr);

	scrPtr->checkButtonImageOn = makePixmap(scrPtr, CHECK_BUTTON_ON,
						CHECK_BUTTON_ON_WIDTH, CHECK_BUTTON_ON_HEIGHT, False);

	scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF,
						 CHECK_BUTTON_OFF_WIDTH, CHECK_BUTTON_OFF_HEIGHT, False);

	scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON,
						RADIO_BUTTON_ON_WIDTH, RADIO_BUTTON_ON_HEIGHT, False);

	scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF,
						 RADIO_BUTTON_OFF_WIDTH, RADIO_BUTTON_OFF_HEIGHT, False);

	scrPtr->tristateButtonImageOn = makePixmap(scrPtr, TRISTATE_BUTTON_ON,
	                                           TRISTATE_BUTTON_ON_WIDTH, TRISTATE_BUTTON_ON_HEIGHT, False);

	scrPtr->tristateButtonImageOff = makePixmap(scrPtr, TRISTATE_BUTTON_OFF,
	                                            TRISTATE_BUTTON_OFF_WIDTH, TRISTATE_BUTTON_OFF_HEIGHT, False);

	scrPtr->tristateButtonImageTri = makePixmap(scrPtr, TRISTATE_BUTTON_TRI,
	                                            TRISTATE_BUTTON_TRI_WIDTH, TRISTATE_BUTTON_TRI_HEIGHT, False);

	scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW, BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT, False);

	scrPtr->pushedButtonArrow = makePixmap(scrPtr, BUTTON_ARROW2,
					       BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT, False);

	scrPtr->scrollerDimple = makePixmap(scrPtr, SCROLLER_DIMPLE,
					    SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT, False);

	scrPtr->upArrow = makePixmap(scrPtr, SCROLLER_ARROW_UP,
				     SCROLLER_ARROW_UP_WIDTH, SCROLLER_ARROW_UP_HEIGHT, True);

	scrPtr->downArrow = makePixmap(scrPtr, SCROLLER_ARROW_DOWN,
				       SCROLLER_ARROW_DOWN_WIDTH, SCROLLER_ARROW_DOWN_HEIGHT, True);

	scrPtr->leftArrow = makePixmap(scrPtr, SCROLLER_ARROW_LEFT,
				       SCROLLER_ARROW_LEFT_WIDTH, SCROLLER_ARROW_LEFT_HEIGHT, True);

	scrPtr->rightArrow = makePixmap(scrPtr, SCROLLER_ARROW_RIGHT,
					SCROLLER_ARROW_RIGHT_WIDTH, SCROLLER_ARROW_RIGHT_HEIGHT, True);

	scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP,
				       SCROLLER_ARROW_UP_WIDTH, SCROLLER_ARROW_UP_HEIGHT, True);

	scrPtr->hiDownArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_DOWN,
					 SCROLLER_ARROW_DOWN_WIDTH, SCROLLER_ARROW_DOWN_HEIGHT, True);

	scrPtr->hiLeftArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_LEFT,
					 SCROLLER_ARROW_LEFT_WIDTH, SCROLLER_ARROW_LEFT_HEIGHT, True);

	scrPtr->hiRightArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_RIGHT,
					  SCROLLER_ARROW_RIGHT_WIDTH, SCROLLER_ARROW_RIGHT_HEIGHT, True);

	scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR,
					    POPUP_INDICATOR_WIDTH, POPUP_INDICATOR_HEIGHT, True);

	scrPtr->pullDownIndicator = makePixmap(scrPtr, PULLDOWN_INDICATOR,
					       PULLDOWN_INDICATOR_WIDTH, PULLDOWN_INDICATOR_HEIGHT, True);

	scrPtr->checkMark = makePixmap(scrPtr, CHECK_MARK, CHECK_MARK_WIDTH, CHECK_MARK_HEIGHT, True);

	loadPixmaps(scrPtr);

	scrPtr->defaultCursor = XCreateFontCursor(display, XC_left_ptr);

	scrPtr->textCursor = XCreateFontCursor(display, XC_xterm);

	{
		XColor bla;
		Pixmap blank;

		blank = XCreatePixmap(display, scrPtr->stipple, 1, 1, 1);
		XSetForeground(display, scrPtr->monoGC, 0);
		XFillRectangle(display, blank, scrPtr->monoGC, 0, 0, 1, 1);

		scrPtr->invisibleCursor = XCreatePixmapCursor(display, blank, blank, &bla, &bla, 0, 0);
		XFreePixmap(display, blank);
	}

#ifdef HAVE_XINTERNATOMS
	XInternAtoms(display, atomNames, wlengthof(atomNames), False, atoms);
#else
	for (i = 0; i < wlengthof(atomNames); i++) {
		atoms[i] = XInternAtom(display, atomNames[i], False);
	}
#endif

	i = 0;
	scrPtr->attribsAtom = atoms[i++];

	scrPtr->deleteWindowAtom = atoms[i++];

	scrPtr->protocolsAtom = atoms[i++];

	scrPtr->clipboardAtom = atoms[i++];

	scrPtr->xdndAwareAtom = atoms[i++];
	scrPtr->xdndSelectionAtom = atoms[i++];
	scrPtr->xdndEnterAtom = atoms[i++];
	scrPtr->xdndLeaveAtom = atoms[i++];
	scrPtr->xdndPositionAtom = atoms[i++];
	scrPtr->xdndDropAtom = atoms[i++];
	scrPtr->xdndFinishedAtom = atoms[i++];
	scrPtr->xdndTypeListAtom = atoms[i++];
	scrPtr->xdndActionListAtom = atoms[i++];
	scrPtr->xdndActionDescriptionAtom = atoms[i++];
	scrPtr->xdndStatusAtom = atoms[i++];

	scrPtr->xdndActionCopy = atoms[i++];
	scrPtr->xdndActionMove = atoms[i++];
	scrPtr->xdndActionLink = atoms[i++];
	scrPtr->xdndActionAsk = atoms[i++];
	scrPtr->xdndActionPrivate = atoms[i++];

	scrPtr->wmIconDragOffsetAtom = atoms[i++];

	scrPtr->wmStateAtom = atoms[i++];

	scrPtr->utf8String = atoms[i++];
	scrPtr->netwmName = atoms[i++];
	scrPtr->netwmIconName = atoms[i++];
	scrPtr->netwmIcon = atoms[i++];

	scrPtr->rootView = W_CreateRootView(scrPtr);

	scrPtr->balloon = W_CreateBalloon(scrPtr);

	W_InitApplication(scrPtr);

	return scrPtr;
}
示例#16
0
ActionConfig::ActionConfig(QWidget *parent, struct ActionUserData *data, ActionPlugin *plugin)
        : ActionConfigBase(parent)
{
    m_data   = data;
    m_plugin = plugin;
    m_menu   = NULL;
    setButtonsPict(this);

    lstEvent->addColumn(i18n("Event"));
    lstEvent->addColumn(i18n("Program"));
    lstEvent->setExpandingColumn(1);

    connect(btnHelp, SIGNAL(clicked()), this, SLOT(help()));

    QListViewItem *item = new QListViewItem(lstEvent, i18n("Contact online"));
    item->setText(2, QString::number(CONTACT_ONLINE));
    item->setPixmap(0, makePixmap("ICQ"));
    if (data->OnLine.ptr)
        item->setText(1, QString::fromUtf8(data->OnLine.ptr));

    item = new QListViewItem(lstEvent, i18n("Status changed"));
    item->setText(2, QString::number(CONTACT_STATUS));
    item->setPixmap(0, makePixmap("ICQ"));
    if (data->Status.ptr)
        item->setText(1, QString::fromUtf8(data->Status.ptr));

    CommandDef *cmd;
    CommandsMapIterator it(m_plugin->core->messageTypes);
    while ((cmd = ++it) != NULL){
        MessageDef *def = (MessageDef*)(cmd->param);
        if ((def == NULL) || (cmd->icon == NULL) ||
                (def->flags & (MESSAGE_HIDDEN | MESSAGE_SENDONLY | MESSAGE_CHILD)))
            continue;
        if ((def->singular == NULL) || (def->plural == NULL) ||
                (*def->singular == 0) || (*def->plural == 0))
            continue;
        QString type = i18n(def->singular, def->plural, 1);
        int pos = type.find("1 ");
        if (pos == 0){
            type = type.mid(2);
        }else if (pos > 0){
            type = type.left(pos);
        }
        type = type.left(1).upper() + type.mid(1);
        QListViewItem *item = new QListViewItem(lstEvent, type);
        item->setText(2, QString::number(cmd->id));
        item->setPixmap(0, makePixmap(cmd->icon));
        item->setText(1, QString::fromUtf8(get_str(data->Message, cmd->id)));
    }
    m_edit = NULL;
    m_editItem = NULL;
    connect(lstEvent, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*)));

    for (QObject *p = parent; p != NULL; p = p->parent()){
        if (!p->inherits("QTabWidget"))
            continue;
        QTabWidget *tab = static_cast<QTabWidget*>(p);
        m_menu = new MenuConfig(tab, data);
        tab->addTab(m_menu, i18n("Menu"));
        tab->adjustSize();
        break;
    }
    lstEvent->adjustColumn();
    setMinimumSize(sizeHint());
}