void TimeScene::drawTimeLog(const QModelIndex &index) { Task* task = _model->task(index); std::vector<TaskLog*> *logs = NULL; int groupLevel = 2; if (task != NULL) { logs = task->logs(true); groupLevel = (task->childCount() > 0) ? 1 : 2; } else { Project* project = _model->project(index); if (project != NULL) { logs = project->logs(); groupLevel = 0; } } if ((logs != NULL) && (logs->size() != 0)) { std::sort(logs->begin(), logs->end(), compareTaskLog); DateTime* currentDay = NULL; DTime currentTime(0); for (std::vector<TaskLog*>::iterator iter = logs->begin(); iter != logs->end(); iter++) { TaskLog* log = *iter; DateTime logDate(log->start->getYear(), log->start->getMonth(), log->start->getDay()); if (currentDay == NULL) { currentDay = new DateTime(logDate.toDouble()); currentTime = (*log->end - *log->start); } else if (logDate == *currentDay) { currentTime = currentTime + (*log->end - *log->start); } else { drawTime(*currentDay, currentTime, index, groupLevel); if (currentDay != NULL) { delete(currentDay); currentDay = NULL; } currentDay = new DateTime(logDate.toDouble()); currentTime = (*log->end - *log->start); } } if (currentTime.totalSecs() != 0) { drawTime(*currentDay, currentTime, index, groupLevel); } if (currentDay != NULL) { delete(currentDay); currentDay = NULL; } } _currentY += sizeHint(index).height(); if (!isCollapsed(index)) { for (int x = 0; x < _model->rowCount(index); x++) { QModelIndex child = _model->index(x, 0, index); if (child.isValid()) { drawIndex(child); } } } if (logs != NULL) { delete(logs); } }
void CVertexArray::DrawArray2d0(const int drawType, unsigned int stride) { if (drawIndex() == 0) return; CheckEndStrip(); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, stride, drawArray); DrawArrays(drawType, stride); glDisableClientState(GL_VERTEX_ARRAY); }
void TimeScene::setupScene() { this->clear(); calcZoom(); int projects = _model->rowCount(QModelIndex()); for (int x = 0; x < projects; x++) { QModelIndex index = _model->index(x, 0); drawIndex(index); } this->_viewSizeHeight = _currentY; // + headerSizeHint().height() createBackground(); setSceneRect(0, 0, _viewSizeWidth, _viewSizeHeight); }
void CVertexArray::DrawArray2dT(const int drawType, StripCallback callback, void* data, unsigned int stride) { if (drawIndex() == 0) return; CheckEndStrip(); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, stride, drawArray); glTexCoordPointer(2, GL_FLOAT, stride, drawArray + 2); DrawArraysCallback(drawType, stride, callback, data); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); }
void CVertexArray::DrawArrayC(const int drawType, unsigned int stride) { if (drawIndex() == 0) return; CheckEndStrip(); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(3, GL_FLOAT, stride, drawArray); glColorPointer(4, GL_UNSIGNED_BYTE, stride, drawArray + 3); DrawArrays(drawType, stride); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); }
void CVertexArray::DrawArrayTN(const int drawType, unsigned int stride) { if (drawIndex() == 0) return; CheckEndStrip(); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glVertexPointer(3, GL_FLOAT, stride, drawArray); glTexCoordPointer(2, GL_FLOAT, stride, drawArray + 3); glNormalPointer(GL_FLOAT, stride, drawArray + 5); DrawArrays(drawType, stride); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); }
void CVertexArray::DrawArrayTNT(const int drawType, unsigned int stride) { if (drawIndex() == 0) return; CheckEndStrip(); #define SET_ENABLE_ACTIVE_TEX(texUnit) \ glClientActiveTexture(texUnit); \ glEnableClientState(GL_TEXTURE_COORD_ARRAY); #define SET_DISABLE_ACTIVE_TEX(texUnit) \ glClientActiveTexture(texUnit); \ glDisableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); SET_ENABLE_ACTIVE_TEX(GL_TEXTURE0); glTexCoordPointer(2, GL_FLOAT, stride, drawArray + 3); SET_ENABLE_ACTIVE_TEX(GL_TEXTURE1); glTexCoordPointer(2, GL_FLOAT, stride, drawArray + 3); // FIXME? (format-specific) SET_ENABLE_ACTIVE_TEX(GL_TEXTURE5); glTexCoordPointer(3, GL_FLOAT, stride, drawArray + 8); SET_ENABLE_ACTIVE_TEX(GL_TEXTURE6); glTexCoordPointer(3, GL_FLOAT, stride, drawArray + 11); glVertexPointer(3, GL_FLOAT, stride, drawArray + 0); glNormalPointer(GL_FLOAT, stride, drawArray + 5); DrawArrays(drawType, stride); SET_DISABLE_ACTIVE_TEX(GL_TEXTURE6); SET_DISABLE_ACTIVE_TEX(GL_TEXTURE5); SET_DISABLE_ACTIVE_TEX(GL_TEXTURE1); SET_DISABLE_ACTIVE_TEX(GL_TEXTURE0); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); #undef SET_ENABLE_ACTIVE_TEX #undef SET_DISABLE_ACTIVE_TEX }
int main(int argc, char *argv[]) { int index; /* index of last key we pushed in the bitmap font */ SDL_Window *window; SDL_Event event; /* last event received */ SDLMod mod; /* key modifiers of last key we pushed */ SDL_scancode scancode; /* scancode of last key we pushed */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { printf("Error initializing SDL: %s", SDL_GetError()); } /* create window */ window = SDL_CreateWindow("iPhone keyboard test", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0); /* create renderer */ SDL_CreateRenderer(window, 0, 0); /* load up our font */ loadFont(); /* draw the background, we'll just paint over it */ SDL_SetRenderDrawColor(bg_color.r, bg_color.g, bg_color.b, bg_color.unused); SDL_RenderFill(NULL); SDL_RenderPresent(); int done = 0; /* loop till we get SDL_Quit */ while (SDL_WaitEvent(&event)) { switch (event.type) { case SDL_QUIT: done = 1; break; case SDL_KEYDOWN: index = keyToIndex(event.key.keysym); scancode = event.key.keysym.scancode; mod = event.key.keysym.mod; if (scancode == SDL_SCANCODE_DELETE) { /* if user hit delete, delete the last character */ backspace(); lastCharWasColon = 0; } else if (lastCharWasColon && scancode == SDL_SCANCODE_0 && (mod & KMOD_SHIFT)) { /* if our last key was a colon and this one is a close paren, the make a hoppy face */ backspace(); drawIndex(32); /* index for happy face */ numChars++; drawCursor(); lastCharWasColon = 0; } else if (index != -1) { /* if we aren't doing a happy face, then just draw the normal character */ drawIndex(index); numChars++; drawCursor(); lastCharWasColon = (event.key.keysym.scancode == SDL_SCANCODE_SEMICOLON && (event.key.keysym.mod & KMOD_SHIFT)); } /* check if the key was a colon */ /* draw our updates to the screen */ SDL_RenderPresent(); break; #ifdef __IPHONEOS__ case SDL_MOUSEBUTTONUP: /* mouse up toggles onscreen keyboard visibility this function is available ONLY on iPhone OS */ SDL_iPhoneKeyboardToggle(window); break; #endif } } cleanup(); return 0; }
/* draws the cursor icon at the current end position of the text */ void drawCursor(void) { drawIndex(29); /* cursor is at index 29 in the bitmap font */ }
QGraphicsItem* LogScene::getGroupItem(const QModelIndex &index) { // Project* project = _model->project(index); // Task* task = _model->task(index); // DateTime* startDate = NULL; // DateTime* endDate = NULL; // if (task != NULL) { // startDate = task->startDate(); // endDate = task->endDate(); // } else { // if (project != NULL) { // startDate = project->startDate(); // endDate = project->endDate(); // } else { // startDate = &_startDate; // endDate = &_endDate; // } // } // // Only print group header for projects (not for summary) // if (project != NULL) { // int days = startDate->daysTo(*endDate) + 1; // QPen pblack(QColor("black")); // QBrush bblack(QColor("black")); // QSize size = sizeHint(index); // int daysToStart = _startDate.daysTo(*startDate); // int x1 = daysToStart * _dayWidth; // int y1 = _currentY + size.height() - 10; // int x2 = x1 + (days * _dayWidth); // int y2 = _currentY + size.height() - 6; // QGraphicsItem* item = addRect(x1 - 4, y1, (x2 - x1) + 8, (y2 - y1), pblack, bblack); // item->setZValue(1); // QVector<QPointF> trian1; // trian1 << QPointF(x1 - 4, y2); // trian1 << QPointF(x1, y2 + 4); // trian1 << QPointF(x1 + 4, y2); // QPolygonF poly1(trian1); // item = addPolygon(poly1, pblack, bblack); // item->setZValue(1); // QVector<QPointF> trian2; // trian2 << QPointF(x2 - 4 , y2); // trian2 << QPointF(x2, y2 + 4); // trian2 << QPointF(x2 + 4, y2); // QPolygonF poly2(trian2); // item = addPolygon(poly2, pblack, bblack); // item->setZValue(1); // } Task* task = _model->task(index); if (task != NULL) { getTaskItem(index); } _currentY += sizeHint(index).height(); if (!isCollapsed(index)) { for (int x = 0; x < _model->rowCount(index); x++) { QModelIndex child = _model->index(x, 0, index); if (child.isValid()) { drawIndex(child); } } } }