Esempio n. 1
0
int init_gc()
{
	XGCValues gcv;
   	gcv.font = fontstruct->fid;
   	gcv.foreground = name2color(FGCOLOR);
   	gcv.background = name2color(BGCOLOR);
   	gcv.function = GXcopy;
   	gcv.subwindow_mode = IncludeInferiors;
   	gcv.line_width = 1;
   	BARE_GC = XCreateGC(display, root, GCForeground | GCBackground | GCFunction | GCLineWidth | GCSubwindowMode | GCFont, &gcv);
   	gcv.foreground = name2color(SELFGCOLOR);
   	BARE_SELECTEDFG_GC = XCreateGC(display, root, GCForeground | GCBackground | GCFunction | GCLineWidth | GCSubwindowMode | GCFont, &gcv);
	gcv.foreground = name2color(SELBGCOLOR);
	BARE_SELECTEDBG_GC = XCreateGC(display, root, GCForeground | GCBackground | GCFunction | GCLineWidth | GCSubwindowMode | GCFont, &gcv);

	return 0;
}
Esempio n. 2
0
void message(const char *text, ...)
{
	char tmp[256];
	va_list vl;
	va_start(vl, text);
	vsprintf(tmp, text, vl);
	va_end(vl);
	tmp[strlen(tmp)] = 0;
        
	int th = TextHeight(fontstruct);
	int char_width = TextWidth(fontstruct, " ");
	int win_width = (strlen(tmp) * char_width) + (WLISTPADDING * 2);		
	int win_height = th;
	int win_x, win_y;
	switch(WLISTPOS)
		{
			case 0:
				win_x = PADDING_WEST;
				win_y = PADDING_NORTH;
				break;
			case 1:
				win_x = SCREEN_WIDTH - PADDING_EAST - win_width - (BORDER * 2);
				win_y = PADDING_NORTH;
				break;
			case 2:
				win_x = 0 + SCREEN_WIDTH - PADDING_EAST - win_width;
				win_y = 0 + SCREEN_HEIGHT - PADDING_SOUTH - win_height;
				break;
			case 3:
				win_x = PADDING_WEST;
				win_y = 0 + SCREEN_HEIGHT - PADDING_SOUTH - win_height;
				break;
			case 4:
				win_x = (SCREEN_WIDTH / 2) - (win_width / 2);
				win_y = (SCREEN_HEIGHT / 2) - (win_height / 2);
				break;
			default:
				win_x = PADDING_WEST;
				win_y = PADDING_NORTH;
				break;
		}
	Window message_window = XCreateSimpleWindow(display, root, win_x,  win_y, win_width, win_height, BORDER, name2color(FGCOLOR), name2color(BGCOLOR));
	XSetWindowBorderWidth(display, message_window, BORDER);		
	XSetWindowBorder(display, message_window, name2color(SELBGCOLOR));		
	XMapRaised(display, message_window);
	XDrawString(display, message_window, BARE_GC, WLISTPADDING, 0 + th - fontstruct->max_bounds.descent, tmp, strlen(tmp));
	XFlush(display);
	sleep(TIMEOUT);
	XFlush(display);
	if(message_window)
	{
		XDestroyWindow(display, message_window);
	}
}
void OptionsTabAppearanceGeneral::chooseColor(QAbstractButton* button)
{
    QColor c;
    int x = (bg_color->buttons()).indexOf(button);

    c = o->color[x];

    c = QColorDialog::getColor(c, parentWidget);
    if(c.isValid()) {
        o->color[x] = c;
        ((QPushButton*) bg_color->buttons()[x])->setPixmap(name2color(o->color[x].name()));

        emit dataChanged();
    }
}
void OptionsTabAppearanceGeneral::restoreOptions(const Options *opt)
{
    if ( !w )
        return;

    //OptAppearanceUI *d = (OptAppearanceUI *)w;
    //d->ck_avatarsChatdlg->setChecked( opt->avatarsChatdlgEnabled ); // Avatars

    int n;
    for (n = 0; n < 4; ++n)
        le_font[n]->setFont(opt->font[n]);

    for (n = 0; n < cNumColors; ++n) {
        o->color[n] = opt->color[n];
        ((QPushButton*) (bg_color->buttons()[n]))->setPixmap(name2color(opt->color[n].name()));
    }
}
Esempio n. 5
0
void list_windows()
{
	int th, ypos, x;
        th = TextHeight(fontstruct);
	ypos = 0 + th - fontstruct->max_bounds.descent;
	Window WINDOW_LIST_WINDOW = None;
	char *tmp;
	char title[256];
	int number = 0;
	int max_title = 0;
	XWindowAttributes winattr;
	Window root_return;
	int char_width = TextWidth(fontstruct, " ");

 	for (x = 0; x< max_windows; x++)
	{
		if(windows_container[x] != None)
		{
			if(!XGetWindowAttributes(display, windows_container[x], &winattr) || winattr.override_redirect || XGetTransientForHint(display, windows_container[x], &root_return)) continue;
				if(winattr.map_state == IsViewable)
				{
					if(XFetchName(display, windows_container[x], &tmp))
					{
						number++;
						if(windows_container[x] == selected)
						{	
							sprintf(title, "%d - %s", get_position(windows_container[x]), tmp);
						} else {
							sprintf(title, "%d - %s", get_position(windows_container[x]), tmp);
						}
						if(strlen(title) > max_title) max_title = strlen(title);
						title[0] = 0;	
					}
				}
			}
		}
	if(number > 0)
	{	
		int win_width = (max_title * char_width) + (WLISTPADDING * 2);		
		int win_height = number * th;
		int win_x, win_y;
		switch(WLISTPOS)
		{
			case 0:
				win_x = PADDING_WEST;
				win_y = PADDING_NORTH;
				break;
			case 1:
				win_x = SCREEN_WIDTH - PADDING_EAST - win_width - (BORDER * 2);
				win_y = PADDING_NORTH;
				break;
			case 2:
				win_x = 0 + SCREEN_WIDTH - PADDING_EAST - win_width;
				win_y = 0 + SCREEN_HEIGHT - PADDING_SOUTH - win_height;
				break;
			case 3:
				win_x = PADDING_WEST;
				win_y = 0 + SCREEN_HEIGHT - PADDING_SOUTH - win_height;
				break;
			case 4:
				win_x = (SCREEN_WIDTH / 2) - (win_width / 2);
				win_y = (SCREEN_HEIGHT / 2) - (win_height / 2);
				break;
			default:
				win_x = PADDING_WEST;
				win_y = PADDING_NORTH;
				break;
		}
		WINDOW_LIST_WINDOW = XCreateSimpleWindow(display, root, win_x,  win_y, win_width, win_height, BORDER, name2color(FGCOLOR), name2color(BGCOLOR));
		XSetWindowBorderWidth(display, WINDOW_LIST_WINDOW, BORDER);		
		XSetWindowBorder(display, WINDOW_LIST_WINDOW, name2color(SELBGCOLOR));		
		XMapRaised(display, WINDOW_LIST_WINDOW);

		for (x = 0; x< max_windows; x++)
		{
			if(windows_container[x] != None)
			{
				if(!XGetWindowAttributes(display, windows_container[x], &winattr) || winattr.override_redirect || XGetTransientForHint(display, windows_container[x], &root_return)) continue;
					if(winattr.map_state == IsViewable)
					{
						if(XFetchName(display, windows_container[x], &tmp))
						{
							if(windows_container[x] == selected)
							{
								sprintf(title, "%d - %s", get_position(windows_container[x]), tmp);
								XFillRectangle(display, WINDOW_LIST_WINDOW, BARE_SELECTEDBG_GC, 0, ypos - th  + fontstruct->max_bounds.descent, win_width, th);
								XDrawString(display, WINDOW_LIST_WINDOW, BARE_SELECTEDFG_GC, WLISTPADDING, ypos, title, strlen(title));
								ypos+=th;
							} else {
								sprintf(title, "%d - %s", get_position(windows_container[x]), tmp);
								XDrawString(display, WINDOW_LIST_WINDOW, BARE_GC, WLISTPADDING, ypos, title, strlen(title));
								ypos+=th;
							}
						title[0] = 0;
						}
					}
			}
		}
		XFlush(display);
		sleep(TIMEOUT);
		XFlush(display);
		if(WINDOW_LIST_WINDOW)
		{
			XDestroyWindow(display, WINDOW_LIST_WINDOW);
		}
	} else {
		message("No windows to list!");
	}
}