示例#1
0
void DateTimeDelegate::paint(QPainter *painter,
        const QStyleOptionViewItem &option,
        const QModelIndex &index) const
{
    const QFileSystemModel *model =
            qobject_cast<const QFileSystemModel*>(index.model());
    Q_ASSERT(model);
    const QDateTime &lastModified = model->lastModified(index);
    painter->save();
    painter->setRenderHints(QPainter::Antialiasing|
                            QPainter::TextAntialiasing);

    if (option.state & QStyle::State_Selected)
        painter->fillRect(option.rect, option.palette.highlight());
    const qreal diameter = qMin(option.rect.width(),
                                option.rect.height());
    const QRectF rect = clockRect(option.rect, diameter);
    drawClockFace(painter, rect, lastModified);
    drawClockHand(painter, rect.center(), diameter / 3.5,
                  ((lastModified.time().hour() +
                   (lastModified.time().minute() / 60.0))) * 30);
    drawClockHand(painter, rect.center(), diameter / 2.5,
                  lastModified.time().minute() * 6);
    drawDate(painter, option, diameter, lastModified);
    painter->restore();
}
示例#2
0
文件: game.c 项目: ricardoleitee/LCOM
int load_menu() {
	vg_init(0x117);
	vg_fill(0xff);
	vg_draw("/usr/src/drivers/proj/images/image_title.mg", 156, 413, 279, 107);
	vg_draw("/usr/src/drivers/proj/images/image_play.mg", 83, 460, 45, 350);
	vg_draw("/usr/src/drivers/proj/images/image_exit.mg", 90, 378, 45, 470);
	drawDate();
}
示例#3
0
int main(int argc, char *argv[])
{
	//>>>>>>>>>>  carregament da codepage  <<<<<<<<<<
	load_char_table(codepage);
	
	
	//>>>>>>>>>>  init kbc  <<<<<<<<<
	Bool mouse_detected = kbc_init(0);
	
	
	//>>>>>>>>>>  init kbd  <<<<<<<<<<
	kbd_init();
	
	
	//>>>>>>>>>>  init mouse  <<<<<<<<<<
	if (mouse_detected == true)
		mouse_init((int) 0);
	
	
	//>>>>>>>>>>  init rtc  <<<<<<<<<<
	rtc_init();
	drawDate();
	drawTime();
	drawCounter();
	
	
	//>>>>>>>>>>  init timer  <<<<<<<<<<
	timer0_init();
	timer_init(TIMER_2, LSBMSB | MODE3);

	
//#################
	menu_start();
//#################		
	
	
	
	//>>>>>>>>>>  restore kbd isr <<<<<<<<<<
	restore_keyboard_isr();
	
	
	//>>>>>>>>>>  restore mouse isr <<<<<<<<<<
	if (mouse_detected == true)
		restore_mouse_isr();
	
	
	//>>>>>>>>>>  restore rtc isr <<<<<<<<<<
	restore_rtc_isr();
	
	//>>>>>>>>>>  init timer isr <<<<<<<<<<
	restore_timer0();
	
	
	return 0;
}
示例#4
0
void DIGITAL_drawBackground(struct tm *t)
{
  drawDate(t);
  
  /* Initialize the current time */
  drawNumber(t->tm_hour, TIME_ROW, HOUR_COL);
  drawNumber(t->tm_min,  TIME_ROW, MINUTE_COL);
  drawNumber(t->tm_sec,  TIME_ROW, SECOND_COL);
  
  GUI_DispStringAt(":",  6 * 8, TIME_ROW);
  GUI_DispStringAt(":",  9 * 8, TIME_ROW);
}
示例#5
0
void drawMainMenu(MainMenu* mm, Date* d){
	drawBitmap(mm->Title1Bmp, Title1X, Title1Y, ALIGN_LEFT, 0);
	drawBitmap(mm->Title2Bmp, Title2X, Title2Y, ALIGN_LEFT, 0);
	drawBitmap(mm->SinglePlayBmp, SinglePlayX, SinglePlayY, ALIGN_LEFT, 0);
	drawBitmap(mm->MultiPlayBmp, MultiPlayX, MultiPlayY, ALIGN_LEFT, 0);
	drawBitmap(mm->HighScoreBmp, HighScoreX, HighScoreY, ALIGN_LEFT, 0);
	drawBitmap(mm->ExitBmp, ExitX, ExitY, ALIGN_LEFT, 0);
	drawDate(d, 10, 10);
	if (mm->singlePlay == 1) {
		drawBitmap(mm->Highlight, SinglePlayX, SinglePlayY, ALIGN_LEFT, 0);
	} else if (mm->highScores == 1) {
		drawBitmap(mm->Highlight, HighScoreX, HighScoreY, ALIGN_LEFT, 0);
	} else if (mm->exit == 1) {
		drawBitmap(mm->Highlight, ExitX, ExitY, ALIGN_LEFT, 0);
	} else if (mm->multiPlay == 1) {
		drawBitmap(mm->Highlight, MultiPlayX, MultiPlayY, ALIGN_LEFT, 0);
	}
}
示例#6
0
static display_t draw()
{
#if COMPILE_ANIMATIONS
	static byte usbImagePos = FRAME_HEIGHT;
	static byte chargeImagePos = FRAME_HEIGHT;
#endif

	// Draw date
	drawDate();

	// Draw time animated
	display_t busy = ticker();

	// Draw battery icon
	drawBattery();

	byte fix = 20;

	// Draw USB icon
	image_s icon = newImage(fix, FRAME_HEIGHT - 9, usbIcon, 16, 8, WHITE, NOINVERT, 0);
	draw_bitmap_set(&icon);

#if COMPILE_ANIMATIONS
	if(animateIcon(USB_CONNECTED(), &usbImagePos))
	{
		icon.y = usbImagePos;
		draw_bitmap_s2(NULL);
		icon.x += 20;
	}
#else
	if(USB_CONNECTED())
	{
		draw_bitmap_s2(NULL);
		icon.x += 20;
	}
#endif
	
	// Draw charging icon
	icon.width = 8;
#if COMPILE_ANIMATIONS
	if(animateIcon(CHARGING(), &chargeImagePos))
	{
		icon.bitmap = chargeIcon;
		icon.y = chargeImagePos;
		draw_bitmap_s2(NULL);
		icon.x += 12;
	}	
#else
	if(CHARGING())
	{
		icon.bitmap = chargeIcon;
		draw_bitmap_s2(NULL);
		icon.x += 12;
	}
#endif

	icon.y = FRAME_HEIGHT - 8;

#if COMPILE_STOPWATCH
	// Stopwatch icon
	if(stopwatch_active())
	{
		icon.bitmap = stopwatch;
		draw_bitmap_s2(&icon);
		icon.x += 12;
	}
#endif	

	// Draw next alarm
	alarm_s nextAlarm;
	if(alarm_getNext(&nextAlarm))
	{
		time_s alarmTime;
		alarmTime.hour = nextAlarm.hour;
		alarmTime.mins = nextAlarm.min;
		alarmTime.ampm = CHAR_24;
		time_timeMode(&alarmTime, appConfig.timeMode);
		
		char buff[9];
		sprintf_P(buff, PSTR("%02hhu:%02hhu%c"), alarmTime.hour, alarmTime.mins, alarmTime.ampm);
		draw_string(buff, false, icon.x, FRAME_HEIGHT - 8);
		icon.x += (alarmTime.ampm == CHAR_24) ? 35 : 42;

		icon.bitmap = dowImg[alarm_getNextDay()];
		draw_bitmap_s2(&icon);

//		icon.x += 9;
	}

	return busy;
}
示例#7
0
void
kMyMoneyDateTbl::paintCell(QPainter *painter, int row, int col)
{
  QRect rect;
  QString text;
  QPen pen;
  int w=cellWidth();
  int h=cellHeight();
  QBrush brushBlue(KGlobalSettings::activeTitleColor());
  QBrush brushLightblue(KGlobalSettings::baseColor());
  QFont font=KGlobalSettings::generalFont();

  // -----
  font.setPointSize(fontsize);

#if KDE_VERSION < 310
  int firstWeekDay = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
#else
  int firstWeekDay = KGlobal::locale()->weekStartDay();
#endif

  if (row==0)
  { // we are drawing the headline
    if (m_type == MONTHLY)
    {
      font.setBold(true);
      painter->setFont(font);
      bool normalday = true;
      QString daystr;
      if ( col+firstWeekDay < 8 )
        daystr = WEEK_DAY_NAME(col+firstWeekDay, true);
      else
        daystr = WEEK_DAY_NAME(col+firstWeekDay-7, true);

      if ( daystr==i18n("Sunday", "Sun") || daystr==i18n("Saturday", "Sat") )
        normalday=false;

      if (!normalday)
      {
        painter->setPen(KGlobalSettings::baseColor());
        painter->setBrush(brushLightblue);
        painter->drawRect(0, 0, w, h);
        painter->setPen(KGlobalSettings::activeTitleColor());
      } else {
        painter->setPen(KGlobalSettings::activeTitleColor());
        painter->setBrush(brushBlue);
        painter->drawRect(0, 0, w, h);
        painter->setPen(KGlobalSettings::activeTextColor());
      }
      painter->drawText(0, 0, w, h-1, AlignCenter,
                        daystr, -1, &rect);
      painter->setPen(KGlobalSettings::textColor());
      painter->moveTo(0, h-1);
      painter->lineTo(w-1, h-1);

      if(rect.width()>maxCell.width())
        maxCell.setWidth(rect.width());

      if(rect.height()>maxCell.height())
        maxCell.setHeight(rect.height());
    }
    else if (m_type == WEEKLY)
    {
      painter->setPen(KGlobalSettings::activeTitleColor());
      painter->setBrush(brushBlue);
      painter->drawRect(0, 0, w, h);
      painter->setPen(KGlobalSettings::activeTextColor());

      int year=date.year();
      QString headerText;
#if QT_VERSION > 0x030005
      // FIXME: Shouldn't that be i18n()'ed as well
      QString weekStr = QString::number(date.weekNumber(&year));
      QString yearStr = QString::number(year);
      headerText = i18n("Week %1 for year %2.")
        .arg(weekStr)
        .arg(yearStr);
#else
      // FIXME: include code to display the same as for KDE >= 3.0.5
      QString weekStr = QString::number(weekNumber(date, &year));
      QString yearStr = QString::number(year);
      headerText = i18n("Week %1 for year %2.")
        .arg(weekStr)
        .arg(yearStr);
#endif

      painter->drawText(0, 0, w, h-1, AlignCenter, headerText, -1, &rect);

      maxCell.setWidth(width());

      if(rect.height()>maxCell.height())
        maxCell.setHeight(rect.height());
    }
    else if (m_type == QUARTERLY)
    {
      int athird = width()/3;

      painter->setPen(KGlobalSettings::activeTitleColor());
      painter->setBrush(brushBlue);
      painter->setPen(/*KGlobalSettings::activeTextColor()*/black);

      if (col == 0)
      {
        painter->drawRect(0, 0, athird, h);
        painter->drawText(0, 0, athird, h-1, AlignCenter, "Month 1", -1, &rect);

        painter->drawRect(athird, 0, athird, h);
        painter->drawText(athird, 0, athird, h-1, AlignCenter, "Month 2", -1, &rect);

        painter->drawRect(athird*2, 0, athird, h);
        painter->drawText(athird*2, 0, athird, h-1, AlignCenter, "Month 3", -1, &rect);
      }
    }
  }
  else
  {
    int pos;

    QDate drawDate(date);

    if (m_type == MONTHLY)
    {
      pos=7*(row-1)+col;
      if ( firstWeekDay < 4 )
        pos += firstWeekDay;
      else
        pos += firstWeekDay - 7;

      if (pos<firstday || (firstday+numdays<=pos))
      { // we are either
        //  painting a day of the previous month or
        //  painting a day of the following month

        if (pos<firstday)
        { // previous month
          drawDate = drawDate.addMonths(-1);
          text.setNum(numDaysPrevMonth+pos-firstday+1);
          drawDate.setYMD(drawDate.year(), drawDate.month(), text.toInt());
        } else { // following month
          drawDate = drawDate.addMonths(1);
          text.setNum(pos-firstday-numdays+1);
          drawDate.setYMD(drawDate.year(), drawDate.month(), text.toInt());
        }
      } else { // paint a day of the current month
        text.setNum(pos-firstday+1);
        drawDate.setYMD(drawDate.year(), drawDate.month(), text.toInt());
      }
    }
    else if (m_type == WEEKLY)
    {
      // TODO: Handle other start weekdays than Monday
      text = QDate::shortDayName(row);
      text += " ";

      int dayOfWeek = date.dayOfWeek();
      int diff;

      if (row < dayOfWeek)
      {
        diff = -(dayOfWeek - row);
      }
      else
      {
        diff = row - dayOfWeek;
      }

      drawDate = date.addDays(diff);
    }
    else if (m_type == QUARTERLY)
    {
    }

    drawCellContents(painter, row, col, drawDate);
  }
}
示例#8
0
void kMyMoneyDateTbl::contentsMouseMoveEvent(QMouseEvent* e)
{
  int row, col, pos;
  QPoint mouseCoord;

  mouseCoord = e->pos();
  row = rowAt(mouseCoord.y());
  col = columnAt(mouseCoord.x());
  if (row<1 || col<0)
  {
    return;
  }

#if KDE_VERSION < 310
  int firstWeekDay = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
#else
  int firstWeekDay = KGlobal::locale()->weekStartDay();
#endif

  QDate drawDate(date);
  QString text;

  if (m_type == MONTHLY)
  {
    pos=7*(row-1)+col;
    if ( firstWeekDay < 4 )
      pos += firstWeekDay;
    else
      pos += firstWeekDay - 7;

    if (pos<firstday || (firstday+numdays<=pos))
    { // we are either
      //  painting a day of the previous month or
      //  painting a day of the following month

      if (pos<firstday)
      { // previous month
        drawDate = drawDate.addMonths(-1);
        text.setNum(numDaysPrevMonth+pos-firstday+1);
        drawDate.setYMD(drawDate.year(), drawDate.month(), text.toInt());
      } else { // following month
        drawDate = drawDate.addMonths(1);
        text.setNum(pos-firstday-numdays+1);
        drawDate.setYMD(drawDate.year(), drawDate.month(), text.toInt());
      }
    } else { // paint a day of the current month
      text.setNum(pos-firstday+1);
      drawDate.setYMD(drawDate.year(), drawDate.month(), text.toInt());
    }
  }
  else if (m_type == WEEKLY)
  {
    // TODO: Handle other start weekdays than Monday
    text = QDate::shortDayName(row);
    text += " ";

    int dayOfWeek = date.dayOfWeek();
    int diff;

    if (row < dayOfWeek)
    {
      diff = -(dayOfWeek - row);
    }
    else
    {
      diff = row - dayOfWeek;
    }

    drawDate = date.addDays(diff);
  }
  else if (m_type == QUARTERLY)
  {
  }

  if (m_drawDateOrig != drawDate)
  {
    m_drawDateOrig = drawDate;
    emit hoverDate(drawDate);
  }

  QGridView::contentsMouseMoveEvent(e);
}