// ------------------------------------------------------------------- Table::Table(string n, string s, Form *f, Pane *p) : Child(n,s,f,p) { type="table"; initglobals(); ifhdr=false; rws=cls=len=0; row1=col1=0; row2=col2=-1; markrow=markcol=0; dblclick=QDateTime::currentDateTime(); QTableWidgex *w=new QTableWidgex(this); widget=(QWidget*) w; w->setObjectName(s2q(n)); QStringList opt=qsplit(s); if (invalidoptn(n,opt,"selectrows sortable")) return; QStringList shape; if (opt.size()>=2) { if ((isint(q2s(opt.at(0)))) && ((isint(q2s(opt.at(1)))))) { shape=qsplit((q2s(opt.at(0)))+" "+(q2s(opt.at(1)))); setshape(shape); } } w->resizeColumnsToContents(); w->resizeRowsToContents(); w->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); w->horizontalHeader()->setHighlightSections(false); w->horizontalHeader()->setStretchLastSection(true); w->horizontalHeader()->setVisible(false); w->verticalHeader()->setHighlightSections(false); w->verticalHeader()->setVisible(false); QFontMetrics fm(w->font()); w->verticalHeader()->setDefaultSectionSize(fm.height() + 6); w->setSelectionMode(QAbstractItemView::ContiguousSelection); w->setAlternatingRowColors(true); if (opt.contains("selectrows")) { w->setSelectionBehavior(QAbstractItemView::SelectRows); w->selectRow(0); } #ifndef QT50 if (opt.contains("sortable")) { w->horizontalHeader()->setClickable(true); connect(w->horizontalHeader(),SIGNAL(sectionDoubleClicked(int)),this,SLOT(on_headerClicked(int))); }
void resize_opaque (Client * c) { XEvent report; Client *p; int old_x, old_y; int move_x, move_y; char geo[32]; int len, sx, sy, rx = 0, ry = 0, mx = 0, my = 0; if (!c) return; getmouse (&old_x, &old_y, c->screen); if (c->size.flags & PMinSize) { mx = c->size.min_width; my = c->size.min_height; } if (c->size.flags & PResizeInc) { rx = c->size.width_inc; ry = c->size.height_inc; } XMapRaised (dpy, c->parent); setmouse (c->x + c->dx + 1 + BORDER, c->y + c->dy + 1 + BORDER, c->screen); XChangeActivePointerGrab (dpy, PointerMotionHintMask | ButtonMotionMask | ButtonReleaseMask | OwnerGrabButtonMask, c->screen->sweep, CurrentTime); while (1) { XNextEvent (dpy, &report); switch (report.type) { #ifdef THREE_D case Expose: p = getclient (report.xexpose.window, 0); if (p) { draw_border (p, p == current ? 1 : 0); } break; #endif case ButtonRelease: if (report.xbutton.button == Button1) { getmouse (&move_x, &move_y, c->screen); c->dx = move_x - BORDER - c->x - 1; c->dy = move_y - BORDER - c->y - 1; adjust_hints (c); XResizeWindow (dpy, c->window, c->dx, c->dy); XResizeWindow (dpy, c->parent, c->dx + (2 * BORDER), c->dy + (2 * BORDER)); sendconfig (c); if (shape) setshape (c); setmouse (old_x, old_y, c->screen); update_tbar (); return; } break; case MotionNotify: while (XCheckTypedEvent (dpy, MotionNotify, &report)); getmouse (&move_x, &move_y, c->screen); c->dx = move_x - BORDER - c->x - 1; c->dy = move_y - BORDER - c->y - 1; adjust_hints (c); sx = c->dx; sy = c->dy; XResizeWindow (dpy, c->window, c->dx, c->dy); XResizeWindow (dpy, c->parent, c->dx + (2 * BORDER), c->dy + (2 * BORDER)); sendconfig (c); if (shape) setshape (c); if (rx) { if (mx) sx -= mx; sx /= rx; sx++; } if (ry) { if (my) sy -= my; sy /= ry; sy++; } if (rx || ry) len = sprintf (geo, "%dx%d (%dx%d)", sx, sy, c->dx, c->dy); else len = sprintf (geo, "%dx%d", c->dx, c->dy); XClearWindow (dpy, c->screen->barwin); #ifdef THREE_D XDrawLine (dpy, c->screen->barwin, c->screen->botwhitegc, 0, prefs.bar_height - 1, BAR_WIDTH (c->screen) - 1, prefs.bar_height - 1); XDrawLine (dpy, c->screen->barwin, c->screen->botwhitegc, BAR_WIDTH (c->screen) - 1, prefs.bar_height - 1, BAR_WIDTH (c->screen) - 1, 0); XDrawLine (dpy, c->screen->barwin, c->screen->topwhitegc, 0, 0, BAR_WIDTH (c->screen) - 1, 0); XDrawLine (dpy, c->screen->barwin, c->screen->topwhitegc, 0, 0, 0, prefs.bar_height - 1); #endif XDrawString (dpy, c->screen->barwin, c->screen->gc, prefs.bar_height, BAR_TEXT_Y, geo, len); break; } } }