void ArrayEditor<ElementType>::InitWidget() { static unsigned int editorCounter = 0; OC_DASSERT(mEditorWidget == 0); CEGUI::String editorName = "Editor/EntityWindow/ValueEditors/ArrayEditor" + string(Reflection::PropertyTypes::GetStringName(Reflection::PropertyTypes::GetTypeID<ElementType>())) + Utils::StringConverter::ToString(editorCounter++); // Create main editor widget mEditorWidget = gGUIMgr.CreateWindow("DefaultWindow", editorName); mMainLayout = new GUISystem::VerticalLayout(mEditorWidget, 0, true); // Create header widget mHeaderWidget = gGUIMgr.CreateWindow("DefaultWindow", editorName + "/Header"); mHeaderWidget->setHeight(CEGUI::UDim(0, GetEditboxHeight())); mMainLayout->AddChildWindow(mHeaderWidget); // Create label widget CEGUI::Window* labelWidget = this->CreateLabelWidget(editorName + "/Header/Label"); labelWidget->setArea(CEGUI::URect(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0), CEGUI::UDim(0.5f, -2), CEGUI::UDim(0, GetEditboxHeight()))); mHeaderWidget->addChildWindow(labelWidget); // Create add element button mButtonAddElement = static_cast<CEGUI::PushButton*>(gGUIMgr.CreateWindow("Editor/ImageButton", editorName + "/Header/AddElementButton")); mButtonAddElement->setProperty("NormalImage", "set:EditorToolbar image:btnAddNormal"); mButtonAddElement->setProperty("HoverImage", "set:EditorToolbar image:btnAddHover"); mButtonAddElement->setProperty("PushedImage", "set:EditorToolbar image:btnAddPushed"); mButtonAddElement->setProperty("DisabledImage", "set:EditorToolbar image:btnAddDisabled"); mButtonAddElement->setWantsMultiClickEvents(false); mButtonAddElement->setTooltipText(TR("entity_editor_add_hint")); mButtonAddElement->setVisible(true); mButtonAddElement->setSize(CEGUI::UVector2(cegui_absdim(24), cegui_absdim(24))); mButtonAddElement->setPosition(CEGUI::UVector2(CEGUI::UDim(1, -80), CEGUI::UDim(0, 0))); mButtonAddElement->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Editor::ArrayEditor<ElementType>::OnEventButtonAddPressed, this)); mHeaderWidget->addChildWindow(mButtonAddElement); // Create revert button mButtonRevert = static_cast<CEGUI::PushButton*>(gGUIMgr.CreateWindow("Editor/ImageButton", editorName + "/Header/RevertButton")); mButtonRevert->setProperty("NormalImage", "set:EditorToolbar image:btnCancelNormal"); mButtonRevert->setProperty("HoverImage", "set:EditorToolbar image:btnCancelHover"); mButtonRevert->setProperty("PushedImage", "set:EditorToolbar image:btnCancelPushed"); mButtonRevert->setProperty("DisabledImage", "set:EditorToolbar image:btnCancelDisabled"); mButtonRevert->setWantsMultiClickEvents(false); mButtonRevert->setTooltipText(TR("entity_editor_revert_hint")); mButtonRevert->setVisible(true); mButtonRevert->setSize(CEGUI::UVector2(cegui_absdim(24), cegui_absdim(24))); mButtonRevert->setPosition(CEGUI::UVector2(CEGUI::UDim(1, -52), CEGUI::UDim(0, 0))); mButtonRevert->setEnabled(false); mButtonRevert->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Editor::ArrayEditor<ElementType>::OnEventButtonRevertPressed, this)); mHeaderWidget->addChildWindow(mButtonRevert); // Create save button mButtonSave = static_cast<CEGUI::PushButton*>(gGUIMgr.CreateWindow("Editor/ImageButton", editorName + "/Header/SaveButton")); mButtonSave->setProperty("NormalImage", "set:EditorToolbar image:btnSaveNormal"); mButtonSave->setProperty("HoverImage", "set:EditorToolbar image:btnSaveHover"); mButtonSave->setProperty("PushedImage", "set:EditorToolbar image:btnSavePushed"); mButtonSave->setProperty("DisabledImage", "set:EditorToolbar image:btnSaveDisabled"); mButtonSave->setWantsMultiClickEvents(false); mButtonSave->setTooltipText(TR("entity_editor_save_hint")); mButtonSave->setVisible(true); mButtonSave->setSize(CEGUI::UVector2(cegui_absdim(24), cegui_absdim(24))); mButtonSave->setPosition(CEGUI::UVector2(CEGUI::UDim(1, -24), CEGUI::UDim(0, 0))); mButtonSave->setEnabled(false); mButtonSave->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Editor::ArrayEditor<ElementType>::OnEventButtonSavePressed, this)); mHeaderWidget->addChildWindow(mButtonSave); // Create is-shared checkbox CEGUI::Checkbox* isSharedCheckbox = CreateIsSharedCheckboxWidget(editorName + "/Header/IsSharedCheckbox"); isSharedCheckbox->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0))); isSharedCheckbox->subscribeEvent(CEGUI::Checkbox::EventCheckStateChanged, CEGUI::Event::Subscriber(&ArrayEditor::OnEventIsSharedCheckboxChanged, this)); mHeaderWidget->addChildWindow(isSharedCheckbox); // Create body widget CEGUI::Window* bodyWidget = gGUIMgr.CreateWindow("DefaultWindow", editorName + "/Body"); mBodyLayout = new GUISystem::VerticalLayout(bodyWidget, 0, true); mMainLayout->AddChildWindow(bodyWidget); }
int LoadAppScript::writeToDB(const QByteArray &pdata, const QString pkgname, QString &errMsg) { if (_name.isEmpty()) { errMsg = TR("<font color=orange>The script does not have" " a name.</font>"); return -1; } if (pdata.isEmpty()) { errMsg = TR("<font color=orange>The script %1 is empty.</font>") .arg(_filename); return -2; } if (_grade == INT_MIN) { QSqlQuery minOrder; minOrder.prepare("SELECT MIN(script_order) AS min " "FROM script " "WHERE (script_name=:name);"); minOrder.bindValue(":name", _name); minOrder.exec(); if (minOrder.first()) _grade = minOrder.value(0).toInt(); else if (minOrder.lastError().type() != QSqlError::NoError) { QSqlError err = minOrder.lastError(); errMsg = _sqlerrtxt.arg(_filename).arg(err.driverText()).arg(err.databaseText()); return -3; } else _grade = 0; } else if (_grade == INT_MAX) { QSqlQuery maxOrder; maxOrder.prepare("SELECT MAX(script_order) AS max " "FROM script " "WHERE (script_name=:name);"); maxOrder.bindValue(":name", _name); maxOrder.exec(); if (maxOrder.first()) _grade = maxOrder.value(0).toInt(); else if (maxOrder.lastError().type() != QSqlError::NoError) { QSqlError err = maxOrder.lastError(); errMsg = _sqlerrtxt.arg(_filename).arg(err.driverText()).arg(err.databaseText()); return -4; } else _grade = 0; } QSqlQuery select; QSqlQuery upsert; int scriptid = -1; int pkgheadid = -1; int pkgitemid = -1; if (pkgname.isEmpty()) select.prepare(QString("SELECT script_id, -1, -1" " FROM %1script " " WHERE ((script_name=:name)" " AND (script_order=:grade));") .arg(_system ? "" : "pkg")); else select.prepare(_pkgitemQueryStr); select.bindValue(":name", _name); select.bindValue(":pkgname", pkgname); select.bindValue(":grade", _grade); select.bindValue(":type", _pkgitemtype); select.exec(); if(select.first()) { scriptid = select.value(0).toInt(); pkgheadid = select.value(1).toInt(); pkgitemid = select.value(2).toInt(); } else if (select.lastError().type() != QSqlError::NoError) { QSqlError err = select.lastError(); errMsg = _sqlerrtxt.arg(_filename).arg(err.driverText()).arg(err.databaseText()); return -5; } if (scriptid >= 0) upsert.prepare(QString("UPDATE %1script " " SET script_order=:grade, " " script_enabled=:enabled," " script_source=:source," " script_notes=:notes " " WHERE (script_id=:id); ") .arg(_system ? "" : "pkg")); else { upsert.prepare("SELECT NEXTVAL('script_script_id_seq');"); upsert.exec(); if (upsert.first()) scriptid = upsert.value(0).toInt(); else if (upsert.lastError().type() != QSqlError::NoError) { QSqlError err = upsert.lastError(); errMsg = _sqlerrtxt.arg(_filename).arg(err.driverText()).arg(err.databaseText()); return -6; } upsert.prepare(QString("INSERT INTO %1script " " (script_id, script_name, script_order, " " script_enabled, script_source, script_notes) " "VALUES (:id, :name, :grade, " " :enabled, :source, :notes);") .arg(_system ? "" : "pkg")); } upsert.bindValue(":id", scriptid); upsert.bindValue(":grade", _grade); upsert.bindValue(":enabled", _enabled); upsert.bindValue(":source", QString(pdata)); upsert.bindValue(":notes", _comment); upsert.bindValue(":name", _name); if (!upsert.exec()) { QSqlError err = upsert.lastError(); errMsg = _sqlerrtxt.arg(_filename).arg(err.driverText()).arg(err.databaseText()); return -7; } if (pkgheadid >= 0) { int tmp = upsertPkgItem(pkgitemid, pkgheadid, scriptid, errMsg); if (tmp < 0) return tmp; } return scriptid; }
#include "[Name].h" #include "SA[Name]Factory.h" #include <QApplication> #include <QMessageBox> #include <QFileDialog> #include "SAUIReflection.h" #define TR(str)\ QApplication::translate("[Name]",str,0) static const QString s_pluginName = TR(""); static const QString s_pluginDescription = TR(""); static const QString s_pluginVersion = TR(""); static const SAAbstractPlugin::PluginType s_pluginType = SAAbstractPlugin::DataImport; SA_PLUGIN_EXPORT SAAbstractPlugin *createPlugin() { return new [Name](); } SA_PLUGIN_EXPORT void deletePlugin(SAAbstractPlugin *obj) { if(obj != nullptr) { delete obj; } } SA_PLUGIN_EXPORT QString pluginName() { return s_pluginName; } SA_PLUGIN_EXPORT QString pluginVersion() {
wresize(WINDOW *win, int ToLines, int ToCols) { int col, row, size_x, size_y; struct ldat *pline; struct ldat *new_lines = 0; #ifdef TRACE T((T_CALLED("wresize(%p,%d,%d)"), win, ToLines, ToCols)); if (win) { TR(TRACE_UPDATE, ("...beg (%ld, %ld), max(%ld,%ld), reg(%ld,%ld)", (long) win->_begy, (long) win->_begx, (long) win->_maxy, (long) win->_maxx, (long) win->_regtop, (long) win->_regbottom)); if (USE_TRACEF(TRACE_UPDATE)) { _tracedump("...before", win); _nc_unlock_global(tracef); } } #endif if (!win || --ToLines < 0 || --ToCols < 0) returnCode(ERR); size_x = win->_maxx; size_y = win->_maxy; if (ToLines == size_y && ToCols == size_x) returnCode(OK); if ((win->_flags & _SUBWIN)) { /* * Check if the new limits will fit into the parent window's size. If * not, do not resize. We could adjust the location of the subwindow, * but the application may not like that. */ if (win->_pary + ToLines > win->_parent->_maxy || win->_parx + ToCols > win->_parent->_maxx) { returnCode(ERR); } pline = win->_parent->_line; } else { pline = 0; } /* * Allocate new memory as needed. Do the allocations without modifying * the original window, in case an allocation fails. Always allocate * (at least temporarily) the array pointing to the individual lines. */ new_lines = typeCalloc(struct ldat, (unsigned) (ToLines + 1)); if (new_lines == 0) returnCode(ERR); /* * For each line in the target, allocate or adjust pointers for the * corresponding text, depending on whether this is a window or a * subwindow. */ for (row = 0; row <= ToLines; ++row) { int begin = (row > size_y) ? 0 : (size_x + 1); int end = ToCols; NCURSES_CH_T *s; if (!(win->_flags & _SUBWIN)) { if (row <= size_y) { if (ToCols != size_x) { if ((s = typeMalloc(NCURSES_CH_T, ToCols + 1)) == 0) returnCode(cleanup_lines(new_lines, row)); for (col = 0; col <= ToCols; ++col) { s[col] = (col <= size_x ? win->_line[row].text[col] : win->_nc_bkgd); } } else { s = win->_line[row].text; } } else { if ((s = typeMalloc(NCURSES_CH_T, ToCols + 1)) == 0) returnCode(cleanup_lines(new_lines, row)); for (col = 0; col <= ToCols; ++col) s[col] = win->_nc_bkgd; } } else { s = &pline[win->_pary + row].text[win->_parx]; } if_USE_SCROLL_HINTS(new_lines[row].oldindex = row); if (row <= size_y) { new_lines[row].firstchar = win->_line[row].firstchar; new_lines[row].lastchar = win->_line[row].lastchar; } if ((ToCols != size_x) || (row > size_y)) { if (end >= begin) { /* growing */ if (new_lines[row].firstchar < begin) new_lines[row].firstchar = begin; } else { /* shrinking */ new_lines[row].firstchar = 0; } new_lines[row].lastchar = ToCols; } new_lines[row].text = s; } /* * Dispose of unwanted memory. */ if (!(win->_flags & _SUBWIN)) { if (ToCols == size_x) { for (row = ToLines + 1; row <= size_y; row++) { free(win->_line[row].text); } } else { for (row = 0; row <= size_y; row++) { free(win->_line[row].text); } } } free(win->_line); win->_line = new_lines; /* * Finally, adjust the parameters showing screen size and cursor * position: */ win->_maxx = ToCols; win->_maxy = ToLines; if (win->_regtop > win->_maxy) win->_regtop = win->_maxy; if (win->_regbottom > win->_maxy || win->_regbottom == size_y) win->_regbottom = win->_maxy; if (win->_curx > win->_maxx) win->_curx = win->_maxx; if (win->_cury > win->_maxy) win->_cury = win->_maxy; /* * Check for subwindows of this one, and readjust pointers to our text, * if needed. */ repair_subwindows(win); #ifdef TRACE TR(TRACE_UPDATE, ("...beg (%ld, %ld), max(%ld,%ld), reg(%ld,%ld)", (long) win->_begy, (long) win->_begx, (long) win->_maxy, (long) win->_maxx, (long) win->_regtop, (long) win->_regbottom)); if (USE_TRACEF(TRACE_UPDATE)) { _tracedump("...after:", win); _nc_unlock_global(tracef); } #endif returnCode(OK); }
_nc_wgetch(WINDOW *win, unsigned long *result, int use_meta EVENTLIST_2nd(_nc_eventlist * evl)) { int ch; #ifdef NCURSES_WGETCH_EVENTS long event_delay = -1; #endif T((T_CALLED("_nc_wgetch(%p)"), win)); *result = 0; if (win == 0 || SP == 0) returnCode(ERR); if (cooked_key_in_fifo()) { if (wgetch_should_refresh(win)) wrefresh(win); *result = fifo_pull(); returnCode(OK); } #ifdef NCURSES_WGETCH_EVENTS if (evl && (evl->count == 0)) evl = NULL; event_delay = _nc_eventlist_timeout(evl); #endif /* * Handle cooked mode. Grab a string from the screen, * stuff its contents in the FIFO queue, and pop off * the first character to return it. */ if (head == -1 && !SP->_notty && !SP->_raw && !SP->_cbreak && !SP->_called_wgetch) { char buf[MAXCOLUMNS], *sp; int rc; TR(TRACE_IEVENT, ("filling queue in cooked mode")); SP->_called_wgetch = TRUE; rc = wgetnstr(win, buf, MAXCOLUMNS); SP->_called_wgetch = FALSE; /* ungetch in reverse order */ #ifdef NCURSES_WGETCH_EVENTS if (rc != KEY_EVENT) #endif ungetch('\n'); for (sp = buf + strlen(buf); sp > buf; sp--) ungetch(sp[-1]); #ifdef NCURSES_WGETCH_EVENTS /* Return it first */ if (rc == KEY_EVENT) { *result = rc; returnCode(OK); } #endif *result = fifo_pull(); returnCode(OK); } if (win->_use_keypad != SP->_keypad_on) _nc_keypad(win->_use_keypad); if (wgetch_should_refresh(win)) wrefresh(win); if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1)) { int delay; TR(TRACE_IEVENT, ("timed delay in wgetch()")); if (SP->_cbreak > 1) delay = (SP->_cbreak - 1) * 100; else delay = win->_delay; #ifdef NCURSES_WGETCH_EVENTS if (event_delay >= 0 && delay > event_delay) delay = event_delay; #endif TR(TRACE_IEVENT, ("delay is %d milliseconds", delay)); if (head == -1) { /* fifo is empty */ int rc = check_mouse_activity(delay EVENTLIST_2nd(evl)); #ifdef NCURSES_WGETCH_EVENTS if (rc & 4) { *result = KEY_EVENT; returnCode(OK); } #endif if (!rc) returnCode(ERR); } /* else go on to read data available */ } if (win->_use_keypad) { /* * This is tricky. We only want to get special-key * events one at a time. But we want to accumulate * mouse events until either (a) the mouse logic tells * us it's picked up a complete gesture, or (b) * there's a detectable time lapse after one. * * Note: if the mouse code starts failing to compose * press/release events into clicks, you should probably * increase the wait with mouseinterval(). */ int runcount = 0; int rc; do { ch = kgetch(EVENTLIST_1st(evl)); if (ch == KEY_MOUSE) { ++runcount; if (SP->_mouse_inline(SP)) break; } if (SP->_maxclick < 0) break; } while (ch == KEY_MOUSE && (((rc = check_mouse_activity(SP->_maxclick EVENTLIST_2nd(evl))) != 0 && !(rc & 4)) || !SP->_mouse_parse(runcount))); #ifdef NCURSES_WGETCH_EVENTS if ((rc & 4) && !ch == KEY_EVENT) { ungetch(ch); ch = KEY_EVENT; } #endif if (runcount > 0 && ch != KEY_MOUSE) { #ifdef NCURSES_WGETCH_EVENTS /* mouse event sequence ended by an event, report event */ if (ch == KEY_EVENT) { ungetch(KEY_MOUSE); /* FIXME This interrupts a gesture... */ } else #endif { /* mouse event sequence ended by keystroke, store keystroke */ ungetch(ch); ch = KEY_MOUSE; } } } else { if (head == -1) fifo_push(EVENTLIST_1st(evl)); ch = fifo_pull(); } if (ch == ERR) { #if USE_SIZECHANGE if (SP->_sig_winch) { _nc_update_screensize(); /* resizeterm can push KEY_RESIZE */ if (cooked_key_in_fifo()) { *result = fifo_pull(); returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK); } } #endif returnCode(ERR); } /* * If echo() is in effect, display the printable version of the * key on the screen. Carriage return and backspace are treated * specially by Solaris curses: * * If carriage return is defined as a function key in the * terminfo, e.g., kent, then Solaris may return either ^J (or ^M * if nonl() is set) or KEY_ENTER depending on the echo() mode. * We echo before translating carriage return based on nonl(), * since the visual result simply moves the cursor to column 0. * * Backspace is a different matter. Solaris curses does not * translate it to KEY_BACKSPACE if kbs=^H. This does not depend * on the stty modes, but appears to be a hardcoded special case. * This is a difference from ncurses, which uses the terminfo entry. * However, we provide the same visual result as Solaris, moving the * cursor to the left. */ if (SP->_echo && !(win->_flags & _ISPAD)) { chtype backup = (ch == KEY_BACKSPACE) ? '\b' : ch; if (backup < KEY_MIN) wechochar(win, backup); } /* * Simulate ICRNL mode */ if ((ch == '\r') && SP->_nl) ch = '\n'; /* Strip 8th-bit if so desired. We do this only for characters that * are in the range 128-255, to provide compatibility with terminals * that display only 7-bit characters. Note that 'ch' may be a * function key at this point, so we mustn't strip _those_. */ if (!use_meta) if ((ch < KEY_MIN) && (ch & 0x80)) ch &= 0x7f; T(("wgetch returning : %s", _tracechar(ch))); *result = ch; returnCode(ch >= KEY_MIN ? KEY_CODE_YES : OK); }
void _nc_hash_map(void) { sym *sp; register int i; int start, shift, size; if (screen_lines > lines_alloc) { if (hashtab) free (hashtab); hashtab = typeMalloc(sym, (screen_lines+1)*2); if (!hashtab) { if (oldhash) { FreeAndNull(oldhash); } lines_alloc = 0; return; } lines_alloc = screen_lines; } if (oldhash && newhash) { /* re-hash only changed lines */ for (i = 0; i < screen_lines; i++) { if (PENDING(i)) newhash[i] = hash(NEWTEXT(i)); } } else { /* re-hash all */ if (oldhash == 0) oldhash = typeCalloc (unsigned long, screen_lines); if (newhash == 0) newhash = typeCalloc (unsigned long, screen_lines); if (!oldhash || !newhash) return; /* malloc failure */ for (i = 0; i < screen_lines; i++) { newhash[i] = hash(NEWTEXT(i)); oldhash[i] = hash(OLDTEXT(i)); } } #ifdef HASH_VERIFY for (i = 0; i < screen_lines; i++) { if(newhash[i] != hash(NEWTEXT(i))) fprintf(stderr,"error in newhash[%d]\n",i); if(oldhash[i] != hash(OLDTEXT(i))) fprintf(stderr,"error in oldhash[%d]\n",i); } #endif /* * Set up and count line-hash values. */ memset(hashtab, '\0', sizeof(*hashtab)*(screen_lines+1)*2); for (i = 0; i < screen_lines; i++) { unsigned long hashval = oldhash[i]; for (sp = hashtab; sp->hashval; sp++) if (sp->hashval == hashval) break; sp->hashval = hashval; /* in case this is a new entry */ sp->oldcount++; sp->oldindex = i; } for (i = 0; i < screen_lines; i++) { unsigned long hashval = newhash[i]; for (sp = hashtab; sp->hashval; sp++) if (sp->hashval == hashval) break; sp->hashval = hashval; /* in case this is a new entry */ sp->newcount++; sp->newindex = i; OLDNUM(i) = _NEWINDEX; /* initialize old indices array */ } /* * Mark line pairs corresponding to unique hash pairs. * * We don't mark lines with offset 0, because it can make fail * extending hunks by cost_effective. Otherwise, it does not * have any side effects. */ for (sp = hashtab; sp->hashval; sp++) if (sp->oldcount == 1 && sp->newcount == 1 && sp->oldindex != sp->newindex) { TR(TRACE_UPDATE | TRACE_MOVE, ("new line %d is hash-identical to old line %d (unique)", sp->newindex, sp->oldindex)); OLDNUM(sp->newindex) = sp->oldindex; } grow_hunks(); /* * Eliminate bad or impossible shifts -- this includes removing * those hunks which could not grow because of conflicts, as well * those which are to be moved too far, they are likely to destroy * more than carry. */ for (i = 0; i < screen_lines; ) { while (i < screen_lines && OLDNUM(i) == _NEWINDEX) i++; if (i >= screen_lines) break; start = i; shift = OLDNUM(i) - i; i++; while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i == shift) i++; size = i - start; if (size < 3 || size+min(size/8,2) < abs(shift)) { while (start < i) { OLDNUM(start) = _NEWINDEX; start++; } } } /* After clearing invalid hunks, try grow the rest. */ grow_hunks(); #if NO_LEAKS FreeAndNull(hashtab); lines_alloc = 0; #endif }
bool group_fitrep(WGroup *ws, WWindow *par, const WFitParams *fp) { WGroupIterTmp tmp; WStacking *unweaved=NULL; int xdiff=0, ydiff=0; WStacking *st; WWindow *oldpar; WRectangle g; oldpar=REGION_PARENT(ws); if(par==NULL){ if(fp->mode®ION_FIT_WHATEVER) return TRUE; REGION_GEOM(ws)=fp->g; }else{ if(!region_same_rootwin((WRegion*)ws, (WRegion*)par)) return FALSE; if(ws->managed_stdisp!=NULL && ws->managed_stdisp->reg!=NULL) region_detach_manager(ws->managed_stdisp->reg); assert(ws->managed_stdisp==NULL); xdiff=fp->g.x-REGION_GEOM(ws).x; ydiff=fp->g.y-REGION_GEOM(ws).y; region_unset_parent((WRegion*)ws); XReparentWindow(ioncore_g.dpy, ws->dummywin, par->win, -1, -1); region_set_parent((WRegion*)ws, par); REGION_GEOM(ws).x=fp->g.x; REGION_GEOM(ws).y=fp->g.y; if(!(fp->mode®ION_FIT_WHATEVER)){ REGION_GEOM(ws).w=fp->g.w; REGION_GEOM(ws).h=fp->g.h; } if(oldpar!=NULL) unweaved=stacking_unweave(&oldpar->stacking, wsfilt, (void*)ws); } FOR_ALL_NODES_IN_GROUP(ws, st, tmp){ WFitParams fp2=*fp; if(st->reg==NULL) continue; g=REGION_GEOM(st->reg); g.x+=xdiff; g.y+=ydiff; if(fp->mode®ION_FIT_WHATEVER){ fp2.g=g; }else{ fp2.g=REGION_GEOM(ws); sizepolicy(&st->szplcy, st->reg, &g, REGION_RQGEOM_WEAK_ALL, &fp2); } if(!region_fitrep(st->reg, par, &fp2)){ warn(TR("Error reparenting %s."), region_name(st->reg)); region_detach_manager(st->reg); } }
QString addsubjectText() { return TR("Click this button to add a <i>subject</i>."); }
QString associationText() { return TR("Click this button to create an <i>association</i>"); }
QString addusecaseText() { return TR("Click this button to add an <i>use case</i> in the diagram. <br><br>" "You can also drop the use case from the <b>browser</b>."); }
QString addfragmentText() { return TR("Click this button to add a <i>fragment</i>."); }
QString addactorText() { return TR("Click this button to add an <i>actor</i> in the diagram. <br><br>" "You can also drop the class from the <b>browser</b>."); }
static void fallback_warn() { put_prog_name(); fprintf(stderr, TR("Oops. Error string compilation failed: %s"), strerror(errno)); }
void UcClassCanvas::menu(const QPoint&) { Q3PopupMenu m(0); Q3PopupMenu toolm(0); m.insertItem(new MenuTitle(browser_node->get_data()->definition(FALSE, TRUE), m.font()), -1); m.insertSeparator(); m.insertItem(TR("Upper"), 0); m.insertItem(TR("Lower"), 1); m.insertItem(TR("Go up"), 8); m.insertItem(TR("Go down"), 9); m.insertSeparator(); m.insertItem(TR("Add related elements"), 10); m.insertSeparator(); m.insertItem(TR("Edit drawing settings"), 4); m.insertSeparator(); if (browser_node->is_writable()) { m.insertItem(TR("Edit"), 7); m.insertSeparator(); } m.insertItem(TR("Select in browser"),2); if (linked()) m.insertItem(TR("Select linked items"), 3); m.insertSeparator(); m.insertItem(TR("Remove from diagram"),5); if (browser_node->is_writable()) m.insertItem(TR("Delete from model"), 6); m.insertSeparator(); if (Tool::menu_insert(&toolm, UmlClass, 20)) m.insertItem(TR("Tool"), &toolm); int rank = m.exec(QCursor::pos()); switch (rank) { case 0: upper(); hide(); show(); break; case 1: lower(); hide(); show(); break; case 2: browser_node->select_in_browser(); return; case 3: the_canvas()->unselect_all(); select_associated(); return; case 4: edit_drawing_settings(); return; case 5: // remove from diagram delete_it(); break; case 6: // delete from model browser_node->delete_it(); // will delete the canvas break; case 7: browser_node->open(TRUE); break; case 8: z_up(); hide(); show(); break; case 9: z_down(); hide(); show(); break; case 10: ((UmlCanvas *) canvas())->get_view() ->add_related_elements(this, TR("class/actor"), TRUE, FALSE); return; default: if (rank >= 20) ToolCom::run(Tool::command(rank - 20), browser_node); return; } package_modified(); }
ActivityPartitionDialog::ActivityPartitionDialog(ActivityPartitionData * d) : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), data(d) { d->browser_node->edit_start(); if (d->browser_node->is_writable()) { setOkButton(TR("OK")); setCancelButton(TR("Cancel")); } else { setOkButton(QString()); setCancelButton(TR("Close")); } setCaption(TR("Activity Partition dialog")); bool visit = !hasOkButton(); // general tab BrowserNode * bn = data->get_browser_node(); Q3Grid * grid = new Q3Grid(2, this); umltab = grid; grid->setMargin(5); grid->setSpacing(5); new QLabel(TR("name : "), grid); edname = new LineEdit(bn->get_name(), grid); edname->setReadOnly(visit); new QLabel(TR("stereotype : "), grid); edstereotype = new Q3ComboBox(!visit, grid); edstereotype->insertItem(toUnicode(data->get_stereotype())); if (! visit) { edstereotype->insertStringList(BrowserActivityPartition::default_stereotypes()); edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlActivityPartition)); edstereotype->setAutoCompletion(completion()); } edstereotype->setCurrentItem(0); QSizePolicy sp = edstereotype->sizePolicy(); sp.setHorData(QSizePolicy::Expanding); edstereotype->setSizePolicy(sp); connect(new SmallPushButton(TR("represents :"), grid), SIGNAL(clicked()), this, SLOT(menu_represents())); edrepresents = new Q3ComboBox(FALSE, grid); if ((data->represents != 0) && !data->represents->deletedp()) { represented = data->represents; edrepresents->insertItem(*(data->represents->pixmap(0)), data->represents->full_name(TRUE)); } else { represented = 0; edrepresents->insertItem(""); } if (! visit) edrepresents->insertItem(""); edrepresents->setCurrentItem(0); edrepresents->setSizePolicy(sp); Q3HBox * htab; new QLabel(grid); htab = new Q3HBox(grid); new QLabel(" ", htab); dimension_cb = new QCheckBox(TR("is dimension"), htab); if (data->is_dimension) dimension_cb->setChecked(TRUE); dimension_cb->setDisabled(visit); new QLabel("", htab); external_cb = new QCheckBox(TR("is external"), htab); if (data->is_external) external_cb->setChecked(TRUE); external_cb->setDisabled(visit); new QLabel("", htab); Q3VBox * vtab = new Q3VBox(grid); new QLabel(TR("description :"), vtab); if (! visit) connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()), this, SLOT(edit_description())); comment = new MultiLineEdit(grid); comment->setReadOnly(visit); comment->setText(bn->get_comment()); QFont font = comment->font(); if (! hasCodec()) font.setFamily("Courier"); font.setFixedPitch(TRUE); comment->setFont(font); addTab(grid, "Uml"); // USER : list key - value grid = new Q3Grid(2, this); grid->setMargin(5); grid->setSpacing(5); kvtable = new KeyValuesTable(bn, grid, visit); addTab(grid, TR("Properties")); // connect(this, SIGNAL(currentChanged(QWidget *)), this, SLOT(change_tabs(QWidget *))); open_dialog(this); }
QString inheritText() { return TR("Click this button to create a <i>generalisation</i>"); }
static void grow_hunks(void) { int start, end, shift; int back_limit, forward_limit; /* limits for cells to fill */ int back_ref_limit, forward_ref_limit; /* limits for refrences */ int i; int next_hunk; /* * This is tricky part. We have unique pairs to use as anchors. * Use these to deduce the presence of spans of identical lines. */ back_limit = 0; back_ref_limit = 0; i = 0; while (i < screen_lines && OLDNUM(i) == _NEWINDEX) i++; for ( ; i < screen_lines; i=next_hunk) { start = i; shift = OLDNUM(i) - i; /* get forward limit */ i = start+1; while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i == shift) i++; end = i; while (i < screen_lines && OLDNUM(i) == _NEWINDEX) i++; next_hunk = i; forward_limit = i; if (i >= screen_lines || OLDNUM(i) >= i) forward_ref_limit = i; else forward_ref_limit = OLDNUM(i); i = start-1; /* grow back */ if (shift < 0) back_limit = back_ref_limit + (-shift); while (i >= back_limit) { if(newhash[i] == oldhash[i+shift] || cost_effective(i+shift, i, shift<0)) { OLDNUM(i) = i+shift; TR(TRACE_UPDATE | TRACE_MOVE, ("connected new line %d to old line %d (backward continuation)", i, i+shift)); } else { TR(TRACE_UPDATE | TRACE_MOVE, ("not connecting new line %d to old line %d (backward continuation)", i, i+shift)); break; } i--; } i = end; /* grow forward */ if (shift > 0) forward_limit = forward_ref_limit - shift; while (i < forward_limit) { if(newhash[i] == oldhash[i+shift] || cost_effective(i+shift, i, shift>0)) { OLDNUM(i) = i+shift; TR(TRACE_UPDATE | TRACE_MOVE, ("connected new line %d to old line %d (forward continuation)", i, i+shift)); } else { TR(TRACE_UPDATE | TRACE_MOVE, ("not connecting new line %d to old line %d (forward continuation)", i, i+shift)); break; } i++; } back_ref_limit = back_limit = i; if (shift > 0) back_ref_limit += shift; } }
QString noteText() { return TR("Click this button to create a <i>note</i>"); }
void UcUseCaseCanvas::menu(const QPoint&) { QPopupMenu m(0); QPopupMenu toolm(0); m.insertItem(new MenuTitle(browser_node->get_data()->definition(FALSE, TRUE), m.font()), -1); m.insertSeparator(); m.insertItem("Upper", 0); m.insertItem("Lower", 1); m.insertItem("Go up", 13); m.insertItem("Go down", 14); m.insertSeparator(); m.insertItem("Add related elements", 10); m.insertSeparator(); m.insertItem("Edit", 2); m.insertSeparator(); m.insertItem("Edit drawing settings", 3); m.insertSeparator(); m.insertItem("Select in browser",4); if (linked()) m.insertItem("Select linked items", 5); m.insertSeparator(); if (browser_node->is_writable()) { if (browser_node->get_associated() != (BrowserNode *) the_canvas()->browser_diagram()) m.insertItem("Set associated diagram",6); if (browser_node->get_associated()) m.insertItem("Remove diagram association",9); } m.insertSeparator(); m.insertItem("Remove from diagram",7); if (browser_node->is_writable()) m.insertItem("Delete from model", 8); m.insertSeparator(); if (Tool::menu_insert(&toolm, UmlUseCase, 20)) m.insertItem("Tool", &toolm); int rank = m.exec(QCursor::pos()); switch (rank) { case 0: upper(); modified(); return; case 1: lower(); modified(); return; case 13: z_up(); modified(); return; case 14: z_down(); modified(); return; case 2: browser_node->open(TRUE); break; case 3: edit_drawing_settings(); return; case 4: browser_node->select_in_browser(); return; case 5: the_canvas()->unselect_all(); select_associated(); return; case 6: ((BrowserUseCase *) browser_node)->set_associated_diagram((BrowserUseCaseDiagram *) the_canvas()->browser_diagram()); break; case 12: ((BrowserUseCase *) browser_node) ->set_associated_diagram(0); return; case 7: // remove from diagram delete_it(); break; case 8: // delete from model browser_node->delete_it(); // will remove canvas break; case 10: ((UmlCanvas *) canvas())->get_view() ->add_related_elements(this, TR("use case"), TRUE, FALSE); return; default: if (rank >= 20) ToolCom::run(Tool::command(rank - 20), browser_node); return; } package_modified(); }
QString anchorText() { return TR("Click this button to create a connection between a " "<i>note</i> and any other item, or between an <i>association</i> " "and a <i>class</i> in case of an <i>association class</i>."); }
PrefsWindow::PrefsWindow(BRect frame) : BWindow(frame, TR("Program settings"), B_TITLED_WINDOW, B_NOT_V_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) { AddShortcut('1', B_COMMAND_KEY, new BMessage(M_SET_TAB_0)); AddShortcut('2', B_COMMAND_KEY, new BMessage(M_SET_TAB_1)); // general fProjectFolder = new PathBox("projectfolder", gProjectPath.GetFullPath(), ""); fProjectFolder->MakeValidating(true); SetToolTip(fProjectFolder, TR("The default path for new projects.")); fShowProjectFolder = new BCheckBox("showfolder", TR("Show project folder on open"), new BMessage); SetToolTip(fShowProjectFolder, TR("When checked, a project's folder is " "shown in Tracker when it is opened.")); if (gShowFolderOnOpen) fShowProjectFolder->SetValue(B_CONTROL_ON); fDontAddHeaders = new BCheckBox("dontaddheaders", TR("Omit header files from projects"), NULL); SetToolTip(fDontAddHeaders, TR("If checked, header files are not automatically " "added to projects.")); if (gDontManageHeaders) fDontAddHeaders->SetValue(B_CONTROL_ON); fSlowBuilds = new BCheckBox("slowbuilds", TR("Use single thread"), NULL); SetToolTip(fSlowBuilds, TR("Build with just one thread instead of one thread " "per processor")); if (gSingleThreadedBuild) fSlowBuilds->SetValue(B_CONTROL_ON); fCCache = new BCheckBox("ccache", TR("Use ccache to build faster"), NULL); SetToolTip(fCCache, TR("Compiler caching is another way to speed up builds")); if (gCCacheAvailable) { if (gUseCCache) fCCache->SetValue(B_CONTROL_ON); } else { BString label = fCCache->Label(); label << " -- " << TR("unavailable"); fCCache->SetLabel(label.String()); fCCache->SetEnabled(false); } fFastDep = new BCheckBox("fastdep", TR("Use fastdep dependency checker"), NULL); SetToolTip(fFastDep, TR("Use the fastdep dependency checker instead of gcc")); if (gFastDepAvailable) { if (gUseFastDep) fFastDep->SetValue(B_CONTROL_ON); } else { BString label = fFastDep->Label(); label << " -- " << TR("unavailable"); fFastDep->SetLabel(label.String()); fFastDep->SetEnabled(false); } BBox* buildBox = new BBox(B_FANCY_BORDER, BLayoutBuilder::Group<>(B_VERTICAL, 0) .Add(fSlowBuilds) .Add(fCCache) .Add(fFastDep) .SetInsets(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING, B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .View()); buildBox->SetLabel(TR("Build")); fAutoSyncModules = new BCheckBox("autosync", TR("Automatically synchronize modules"), NULL); SetToolTip(fAutoSyncModules, TR("Automatically synchronize modules in your " "projects with the those in the code library")); if (gAutoSyncModules) fAutoSyncModules->SetValue(B_CONTROL_ON); fBackupFolder = new PathBox("backupfolder", gBackupPath.GetFullPath(), ""); fBackupFolder->MakeValidating(true); SetToolTip(fBackupFolder, TR("Sets the location for project backups")); fTabs[0] = BLayoutBuilder::Grid<>(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(new BStringView("projects folder label", TR("Projects folder:")), 0, 0) .Add(fProjectFolder, 1, 0) .AddGroup(B_VERTICAL, 0.0f, 1, 1) .Add(fShowProjectFolder) .Add(fDontAddHeaders) .End() .Add(buildBox, 1, 2) .Add(fAutoSyncModules, 1, 3) .Add(new BStringView("backups folder label", TR("Backups folder:")), 0, 4) .Add(fBackupFolder, 1, 4) .SetInsets(B_USE_DEFAULT_SPACING) .View(); fTabs[0]->SetName(TR("General")); fTabs[0]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); #ifndef BUILD_CODE_LIBRARY fAutoSyncModules->Hide(); #endif // source control BPopUpMenu* scmMenu = new BPopUpMenu("SCM Chooser"); scmMenu->AddItem(new BMenuItem(TR("None"), NULL)); scmMenu->AddSeparatorItem(); scmMenu->AddItem(new BMenuItem(TR("Git"), NULL)); scmMenu->AddItem(new BMenuItem(TR("Mercurial"), NULL)); scmMenu->AddItem(new BMenuItem(TR("Subversion"), NULL)); fSCMChooser = new BMenuField("scmchooser", TR("Preferred source control:"), scmMenu); #ifdef DISABLE_GIT_SUPPORT scmMenu->ItemAt(2)->SetEnabled(false); #endif BMenuItem* marked = scmMenu->ItemAt(gDefaultSCM); if (marked != NULL) marked->SetMarked(true); else scmMenu->ItemAt(0)->SetMarked(true); if (!marked->IsEnabled()) { // if the default SCM is disabled unmark it and mark the first one that // is enabled. marked->SetMarked(false); for (int32 i = 0; i < scmMenu->CountItems(); i++) { if (scmMenu->ItemAt(i)->IsEnabled()) { scmMenu->ItemAt(i)->SetMarked(true); break; } } } fSVNRepoFolder = new PathBox("svnrepofolder", gSVNRepoPath.GetFullPath(), ""); fSVNRepoFolder->MakeValidating(true); SetToolTip(fSVNRepoFolder, TR("Sets the location for the 'server' side of " "local Subversion repositories.")); fTabs[1] = BLayoutBuilder::Group<>(B_VERTICAL) .AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(fSCMChooser->CreateLabelLayoutItem(), 0, 0) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 0) .Add(fSCMChooser->CreateMenuBarLayoutItem()) .AddGlue() .End() .Add(new BStringView("svn repo folder label", TR("Subversion repository folder:")), 0, 1) .Add(fSVNRepoFolder, 1, 1) .End() .AddGlue() .SetInsets(B_USE_DEFAULT_SPACING) .View(); fTabs[1]->SetName(TR("Source control")); fTabs[1]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // tab view fTabView = new BTabView("tabview", B_WIDTH_FROM_LABEL); fTabView->SetBorder(B_NO_BORDER); fTabView->AddTab(fTabs[0]); fTabView->AddTab(fTabs[1]); fTabView->Select(0L); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .AddStrut(B_USE_SMALL_SPACING) .Add(fTabView) .End(); fProjectFolder->MakeFocus(true); CenterOnScreen(); }
QString imageText() { return TR("Click this button to add an <i>image</i>"); }
static inline int fifo_push(EVENTLIST_0th(_nc_eventlist * evl)) { int n; int ch = 0; int mask = 0; (void) mask; if (tail == -1) return ERR; #ifdef HIDE_EINTR again: errno = 0; #endif #ifdef NCURSES_WGETCH_EVENTS if (evl #if USE_GPM_SUPPORT || USE_EMX_MOUSE || USE_SYSMOUSE || (SP->_mouse_fd >= 0) #endif ) { mask = check_mouse_activity(-1 EVENTLIST_2nd(evl)); } else mask = 0; if (mask & 4) { T(("fifo_push: ungetch KEY_EVENT")); ungetch(KEY_EVENT); return KEY_EVENT; } #elif USE_GPM_SUPPORT || USE_EMX_MOUSE || USE_SYSMOUSE if (SP->_mouse_fd >= 0) { mask = check_mouse_activity(-1 EVENTLIST_2nd(evl)); } #endif #if USE_GPM_SUPPORT || USE_EMX_MOUSE if ((SP->_mouse_fd >= 0) && (mask & 2)) { SP->_mouse_event(SP); ch = KEY_MOUSE; n = 1; } else #endif #if USE_SYSMOUSE if ((SP->_mouse_type == M_SYSMOUSE) && (SP->_sysmouse_head < SP->_sysmouse_tail)) { SP->_mouse_event(SP); ch = KEY_MOUSE; n = 1; } else if ((SP->_mouse_type == M_SYSMOUSE) && (mask <= 0) && errno == EINTR) { SP->_mouse_event(SP); ch = KEY_MOUSE; n = 1; } else #endif { /* Can block... */ unsigned char c2 = 0; n = read(SP->_ifd, &c2, 1); ch = c2; } #ifdef HIDE_EINTR /* * Under System V curses with non-restarting signals, getch() returns * with value ERR when a handled signal keeps it from completing. * If signals restart system calls, OTOH, the signal is invisible * except to its handler. * * We don't want this difference to show. This piece of code * tries to make it look like we always have restarting signals. */ if (n <= 0 && errno == EINTR) goto again; #endif if ((n == -1) || (n == 0)) { TR(TRACE_IEVENT, ("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno)); ch = ERR; } TR(TRACE_IEVENT, ("read %d characters", n)); SP->_fifo[tail] = ch; SP->_fifohold = 0; if (head == -1) head = peek = tail; t_inc(); TR(TRACE_IEVENT, ("pushed %s at %d", _tracechar(ch), tail)); #ifdef TRACE if (_nc_tracing & TRACE_IEVENT) _nc_fifo_dump(); #endif return ch; }
// id is an old ident in case of an import UseCaseDiagramWindow::UseCaseDiagramWindow(const QString & s, BrowserUseCaseDiagram * b, int id) : DiagramWindow(b, s), view(0) { Q3ToolBar * toolbar = new Q3ToolBar(this, "use case operations"); addToolBar(toolbar, TR("Toolbar"), Qt::DockTop, TRUE); add_edit_button(toolbar); select = new QToolButton(*selectButton, TR("Select"), QString::null, this, SLOT(hit_select()), toolbar, "select"); select->setToggleButton(TRUE); select->setOn(TRUE); current_button = UmlSelect; addClass = new QToolButton(*actorButton, TR("Actor"), QString::null, this, SLOT(hit_class()), toolbar, "actor"); addClass->setToggleButton(TRUE); Q3WhatsThis::add(addClass, addactorText()); addUseCase = new QToolButton(*usecaseButton, TR("Use Case"), QString::null, this, SLOT(hit_usecase()), toolbar, "use case"); addUseCase->setToggleButton(TRUE); Q3WhatsThis::add(addUseCase, addusecaseText()); addSubject = new QToolButton(*subjectButton, TR("Add Subject"), QString::null, this, SLOT(hit_subject()), toolbar, "add subject"); addSubject->setToggleButton(TRUE); Q3WhatsThis::add(addSubject, addsubjectText()); addPackage = new QToolButton(*packageButton, TR("Add Package"), QString::null, this, SLOT(hit_package()), toolbar, "add package"); addPackage->setToggleButton(TRUE); Q3WhatsThis::add(addPackage, addpackageText()); addFragment = new QToolButton(*fragmentButton, TR("Add Fragment"), QString::null, this, SLOT(hit_fragment()), toolbar, "add fragment"); addFragment->setToggleButton(TRUE); Q3WhatsThis::add(addFragment, addfragmentText()); association = new QToolButton(*associationButton, TR("Association"), QString::null, this, SLOT(hit_association()), toolbar, "association"); association->setToggleButton(TRUE); Q3WhatsThis::add(association, associationText()); directionalassociation = new QToolButton(*directionalAssociationButton, TR("Association"), QString::null, this, SLOT(hit_directionalassociation()), toolbar, "association"); directionalassociation->setToggleButton(TRUE); Q3WhatsThis::add(directionalassociation, associationText()); dependency = new QToolButton(*dependencyButton, TR("Dependency"), QString::null, this, SLOT(hit_dependency()), toolbar, "dependency"); dependency->setToggleButton(TRUE); Q3WhatsThis::add(dependency, dependencyText()); inherit = new QToolButton(*generalisationButton, TR("Generalisation"), QString::null, this, SLOT(hit_inherit()), toolbar, "generalisation"); inherit->setToggleButton(TRUE); Q3WhatsThis::add(inherit, inheritText()); note = new QToolButton(*noteButton, TR("Note"), QString::null, this, SLOT(hit_note()), toolbar, "note"); note->setToggleButton(TRUE); Q3WhatsThis::add(note, noteText()); anchor = new QToolButton(*anchorButton, TR("Anchor"), QString::null, this, SLOT(hit_anchor()), toolbar, "anchor"); anchor->setToggleButton(TRUE); Q3WhatsThis::add(anchor, anchorText()); text = new QToolButton(*textButton, TR("Text"), QString::null, this, SLOT(hit_text()), toolbar, "text"); text->setToggleButton(TRUE); Q3WhatsThis::add(text, textText()); image = new QToolButton(*imageButton, TR("Image"), QString::null, this, SLOT(hit_image()), toolbar, "image"); image->setToggleButton(TRUE); Q3WhatsThis::add(image, imageText()); toolbar->addSeparator(); add_scale_cmd(toolbar); // view = new UseCaseDiagramView(this, canvas, (id != -1) ? id : b->get_ident()); setFocusProxy(view); setCentralWidget(view); //qApp->setMainWidget(this); QWorkspace * w = UmlWindow::get_workspace(); resize((w->width() * 4)/5, (w->height() * 4)/5); /*if (w->windowList().isEmpty()) showMaximized(); else*/ show(); view->preferred_size_zoom(); //qApp->setMainWidget(0); }
static int kgetch(EVENTLIST_0th(_nc_eventlist * evl)) { struct tries *ptr; int ch = 0; int timeleft = ESCDELAY; TR(TRACE_IEVENT, ("kgetch() called")); ptr = SP->_keytry; for (;;) { if (cooked_key_in_fifo() && SP->_fifo[head] >= KEY_MIN) { break; } else if (!raw_key_in_fifo()) { ch = fifo_push(EVENTLIST_1st(evl)); if (ch == ERR) { peek = head; /* the keys stay uninterpreted */ return ERR; } #ifdef NCURSES_WGETCH_EVENTS else if (ch == KEY_EVENT) { peek = head; /* the keys stay uninterpreted */ return fifo_pull(); /* Remove KEY_EVENT from the queue */ } #endif } ch = fifo_peek(); if (ch >= KEY_MIN) { /* If not first in queue, somebody put this key there on purpose in * emergency. Consider it higher priority than the unfinished * keysequence we are parsing. */ peek = head; /* assume the key is the last in fifo */ t_dec(); /* remove the key */ return ch; } TR(TRACE_IEVENT, ("ch: %s", _tracechar((unsigned char) ch))); while ((ptr != NULL) && (ptr->ch != (unsigned char) ch)) ptr = ptr->sibling; if (ptr == NULL) { TR(TRACE_IEVENT, ("ptr is null")); break; } TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d", ptr, ptr->ch, ptr->value)); if (ptr->value != 0) { /* sequence terminated */ TR(TRACE_IEVENT, ("end of sequence")); if (peek == tail) fifo_clear(); else head = peek; return (ptr->value); } ptr = ptr->child; if (!raw_key_in_fifo()) { int rc; TR(TRACE_IEVENT, ("waiting for rest of sequence")); rc = check_mouse_activity(timeleft EVENTLIST_2nd(evl)); #ifdef NCURSES_WGETCH_EVENTS if (rc & 4) { TR(TRACE_IEVENT, ("interrupted by a user event")); /* FIXME Should have preserved remainder timeleft for reusal... */ peek = head; /* Restart interpreting later */ return KEY_EVENT; } #endif if (!rc) { TR(TRACE_IEVENT, ("ran out of time")); break; } } } ch = fifo_pull(); peek = head; return ch; }
_nc_scroll_window(WINDOW *win, int const n, NCURSES_SIZE_T const top, NCURSES_SIZE_T const bottom, NCURSES_CH_T blank) { int limit; int line; int j; size_t to_copy = (size_t) (sizeof(NCURSES_CH_T) * (win->_maxx + 1)); TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %ld, %ld)", win, n, (long) top, (long) bottom)); if (top < 0 || bottom < top || bottom > win->_maxy) { TR(TRACE_MOVE, ("nothing to scroll")); return; } /* * This used to do a line-text pointer-shuffle instead of text copies. * That (a) doesn't work when the window is derived and doesn't have * its own storage, (b) doesn't save you a lot on modern machines * anyway. Your typical memcpy implementations are coded in * assembler using a tight BLT loop; for the size of copies we're * talking here, the total execution time is dominated by the one-time * setup cost. So there is no point in trying to be excessively * clever -- esr. */ /* shift n lines downwards */ if (n < 0) { limit = top - n; for (line = bottom; line >= limit && line >= 0; line--) { TR(TRACE_MOVE, ("...copying %d to %d", line + n, line)); memcpy(win->_line[line].text, win->_line[line + n].text, to_copy); if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line + n].oldindex); } for (line = top; line < limit && line <= win->_maxy; line++) { TR(TRACE_MOVE, ("...filling %d", line)); for (j = 0; j <= win->_maxx; j++) win->_line[line].text[j] = blank; if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX); } } /* shift n lines upwards */ if (n > 0) { limit = bottom - n; for (line = top; line <= limit && line <= win->_maxy; line++) { memcpy(win->_line[line].text, win->_line[line + n].text, to_copy); if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line + n].oldindex); } for (line = bottom; line > limit && line >= 0; line--) { for (j = 0; j <= win->_maxx; j++) win->_line[line].text[j] = blank; if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX); } } touchline(win, top, bottom - top + 1); if_WIDEC({ if (WINDOW_EXT(win, addch_used) != 0) { int next = WINDOW_EXT(win, addch_y) + n; if (next < 0 || next > win->_maxy) { TR(TRACE_VIRTPUT, ("Alert discarded multibyte on scroll")); WINDOW_EXT(win, addch_y) = 0; } else { TR(TRACE_VIRTPUT, ("scrolled working position to %d,%d", WINDOW_EXT(win, addch_y), WINDOW_EXT(win, addch_x))); WINDOW_EXT(win, addch_y) = next; } } }) }
int tputs(const char *string, int affcnt, int (*outc)(int)) { bool always_delay; bool normal_delay; int number; #ifdef BSD_TPUTS int trailpad; #endif /* BSD_TPUTS */ #ifdef TRACE char addrbuf[17]; if (_nc_tracing & TRACE_TPUTS) { if (outc == _nc_outch) (void) strcpy(addrbuf, "_nc_outch"); else (void) sprintf(addrbuf, "%p", outc); if (_nc_tputs_trace) { TR(TRACE_MAXIMUM, ("tputs(%s = %s, %d, %s) called", _nc_tputs_trace, _nc_visbuf(string), affcnt, addrbuf)); } else { TR(TRACE_MAXIMUM, ("tputs(%s, %d, %s) called", _nc_visbuf(string), affcnt, addrbuf)); } _nc_tputs_trace = (char *)NULL; } #endif /* TRACE */ if (string == ABSENT_STRING || string == CANCELLED_STRING) return ERR; if (cur_term == 0) { always_delay = FALSE; normal_delay = TRUE; } else { always_delay = (string == bell) || (string == flash_screen); normal_delay = !xon_xoff && padding_baud_rate #ifdef NCURSES_NO_PADDING && (SP == 0 || !(SP->_no_padding)) #endif && (cur_term == 0 || cur_term->_baudrate >= padding_baud_rate); } #ifdef BSD_TPUTS /* * This ugly kluge deals with the fact that some ancient BSD programs * (like nethack) actually do the likes of tputs("50") to get delays. */ trailpad = 0; while (isdigit(*string)) { trailpad = trailpad * 10 + (*string - '0'); string++; } trailpad *= 10; if (*string == '.') { string++; if (isdigit(*string)) { trailpad += (*string - '0'); string++; } while (isdigit(*string)) string++; } if (*string == '*') { trailpad *= affcnt; string++; } #endif /* BSD_TPUTS */ my_outch = outc; /* redirect delay_output() */ while (*string) { if (*string != '$') (*outc)(*string); else { string++; if (*string != '<') { (*outc)('$'); if (*string) (*outc)(*string); } else { bool mandatory; string++; if ((!isdigit(*string) && *string != '.') || !strchr(string, '>')) { (*outc)('$'); (*outc)('<'); continue; } number = 0; while (isdigit(*string)) { number = number * 10 + (*string - '0'); string++; } number *= 10; if (*string == '.') { string++; if (isdigit(*string)) { number += (*string - '0'); string++; } while (isdigit(*string)) string++; } mandatory = FALSE; while (*string == '*' || *string == '/') { if (*string == '*') { number *= affcnt; string++; } else /* if (*string == '/') */ { mandatory = TRUE; string++; } } if (number > 0 && (always_delay || normal_delay || mandatory)) delay_output(number/10); } /* endelse (*string == '<') */ } /* endelse (*string == '$') */ if (*string == '\0') break; string++; } #ifdef BSD_TPUTS /* * Emit any BSD-style prefix padding that we've accumulated now. */ if (trailpad > 0 && (always_delay || normal_delay)) delay_output(trailpad/10); #endif /* BSD_TPUTS */ my_outch = _nc_outch; return OK; }
static void speeddisk(int fd, off_t mediasize, u_int sectorsize) { int bulk, i; off_t b0, b1, sectorcount, step; sectorcount = mediasize / sectorsize; step = 1ULL << (flsll(sectorcount / (4 * 200)) - 1); if (step > 16384) step = 16384; bulk = mediasize / (1024 * 1024); if (bulk > 100) bulk = 100; printf("Seek times:\n"); printf("\tFull stroke:\t"); b0 = 0; b1 = sectorcount - step; T0(); for (i = 0; i < 125; i++) { rdsect(fd, b0, sectorsize); b0 += step; rdsect(fd, b1, sectorsize); b1 -= step; } TN(250); printf("\tHalf stroke:\t"); b0 = sectorcount / 4; b1 = b0 + sectorcount / 2; T0(); for (i = 0; i < 125; i++) { rdsect(fd, b0, sectorsize); b0 += step; rdsect(fd, b1, sectorsize); b1 += step; } TN(250); printf("\tQuarter stroke:\t"); b0 = sectorcount / 4; b1 = b0 + sectorcount / 4; T0(); for (i = 0; i < 250; i++) { rdsect(fd, b0, sectorsize); b0 += step; rdsect(fd, b1, sectorsize); b1 += step; } TN(500); printf("\tShort forward:\t"); b0 = sectorcount / 2; T0(); for (i = 0; i < 400; i++) { rdsect(fd, b0, sectorsize); b0 += step; } TN(400); printf("\tShort backward:\t"); b0 = sectorcount / 2; T0(); for (i = 0; i < 400; i++) { rdsect(fd, b0, sectorsize); b0 -= step; } TN(400); printf("\tSeq outer:\t"); b0 = 0; T0(); for (i = 0; i < 2048; i++) { rdsect(fd, b0, sectorsize); b0++; } TN(2048); printf("\tSeq inner:\t"); b0 = sectorcount - 2048; T0(); for (i = 0; i < 2048; i++) { rdsect(fd, b0, sectorsize); b0++; } TN(2048); printf("Transfer rates:\n"); printf("\toutside: "); rdsect(fd, 0, sectorsize); T0(); for (i = 0; i < bulk; i++) { rdmega(fd); } TR(bulk * 1024); printf("\tmiddle: "); b0 = sectorcount / 2 - bulk * (1024*1024 / sectorsize) / 2 - 1; rdsect(fd, b0, sectorsize); T0(); for (i = 0; i < bulk; i++) { rdmega(fd); } TR(bulk * 1024); printf("\tinside: "); b0 = sectorcount - bulk * (1024*1024 / sectorsize) - 1;; rdsect(fd, b0, sectorsize); T0(); for (i = 0; i < bulk; i++) { rdmega(fd); } TR(bulk * 1024); printf("\n"); return; }
void DeploymentNodeCanvas::menu(const QPoint&) { Q3PopupMenu m(0); Q3PopupMenu toolm(0); MenuFactory::createTitle(m, browser_node->get_data()->definition(FALSE, TRUE)); m.insertSeparator(); m.insertItem(TR("Upper"), 0); m.insertItem(TR("Lower"), 1); m.insertItem(TR("Go up"), 13); m.insertItem(TR("Go down"), 14); m.insertSeparator(); m.insertItem(TR("Add related elements"), 10); m.insertSeparator(); m.insertItem(TR("Edit"), 2); m.insertSeparator(); m.insertItem(TR("Edit drawing settings"), 3); m.insertSeparator(); m.insertItem(TR("Select node in browser"), 4); if (linked()) m.insertItem(TR("Select linked items"), 5); m.insertSeparator(); m.insertItem(TR("Set node associated diagram"), 6); m.insertSeparator(); m.insertItem(TR("Remove from diagram"), 7); m.insertSeparator(); if (Tool::menu_insert(&toolm, UmlDeploymentNode, 20)) m.insertItem(TR("Tool"), &toolm); int rank = m.exec(QCursor::pos()); switch (rank) { case 0: upper(); modified(); // call package_modified() return; case 1: lower(); modified(); // call package_modified() return; case 13: z_up(); modified(); // call package_modified() return; case 14: z_down(); modified(); // call package_modified() return; case 2: open(); return; case 3: edit_drawing_settings(); return; case 4: browser_node->select_in_browser(); return; case 5: the_canvas()->unselect_all(); select_associated(); return; case 6: ((BrowserDeploymentNode *) browser_node) ->set_associated_diagram((BrowserDeploymentDiagram *) the_canvas()->browser_diagram()); return; case 7: // remove from diagram delete_it(); break; case 10: ((UmlCanvas *) canvas())->get_view() ->add_related_elements(this, TR("node"), FALSE, FALSE); return; default: if (rank >= 20) ToolCom::run(Tool::command(rank - 20), browser_node); return; } package_modified(); }
KeyValuesTable::KeyValuesTable(HaveKeyValueData * hv, QWidget * parent, bool isReadOnly) : StringTable(((hv == 0) ? 0 : hv->get_n_keys()) + ((isReadOnly) ? 0 : 1), (isReadOnly) ? 2 : 3, parent, isReadOnly) { horizontalHeader()->setLabel(0, TR("Key")); horizontalHeader()->setLabel(1, TR("Value")); if (!isReadOnly) horizontalHeader()->setLabel(2, TR("do")); int index; int sup = 0; if(hv) sup = hv->get_n_keys(); if (isReadOnly) { for (index = 0; index < sup; index += 1) { TableItem * ti; ti = new TableItem(this, Q3TableItem::Never, toUnicode(hv->get_key(index))); ti->setReplaceable(FALSE); setItem(index, 0, ti); QString s = toUnicode(hv->get_value(index)); int n = s.count('\n'); ti = new TableItem(this, Q3TableItem::Never, s); ti->setReplaceable(FALSE); setItem(index, 1, ti); if (n != 0) { // note : adjustRow(index) does nothing setRowHeight(index, rowHeight(index) * (n + 1)); } } } else { props.setAutoDelete(TRUE); QStringList items; for (index = 0; index < sup; index += 1) { QString k = toUnicode(hv->get_key(index)); QString v = toUnicode(hv->get_value(index)); QStringList * psl = props[k]; setText(index, 0, k); if (psl != 0) setItem(index, 1, new ComboItem(this, v, *psl, FALSE)); if ((k.contains(':') == 2) && ProfiledStereotypes::enumerated(k, items)) { psl = new QStringList(items); props.insert(k, psl); setItem(index, 1, new ComboItem(this, v, *psl, FALSE)); } else setItem(index, 1, new MLinesItem(this, v)); setText(index, 2, QString()); setRowStretchable(index, TRUE); } setText(index, 0, QString()); setItem(index, 1, new MLinesItem(this, QString())); setText(index, 2, QString()); setRowStretchable(index, TRUE); } horizontalHeader()->setResizeEnabled(TRUE, 0); //setColumnStretchable (0, TRUE); setColumnStretchable(1, TRUE); if (! isReadOnly) { adjustColumn(2); setColumnStretchable(2, FALSE); } }