示例#1
0
void drawDecorations(Display *display, Drawable window, GC gc, const char *title, XWindowAttributes attr) {
	if (!white || !black) {
		white = XWhitePixel(display, DefaultScreen(display));
		black = XBlackPixel(display, DefaultScreen(display));
	}
	
	// Draw bounding box
	whiteOutTitleBar(display, window, gc, attr);
	XSetForeground(display, gc, black);
	XDrawRectangle(display, window, gc, RECT_TITLEBAR);
	
	// Draw texture
	for (int y = TITLEBAR_TEXTURE_START; y < TITLEBAR_TEXTURE_START + TITLEBAR_CONTROL_SIZE; y += TITLEBAR_TEXTURE_SPACE) {
		XDrawLine(display, window, gc, 2, y, attr.width - 4, y);
	}
	
	// White out areas for buttons and title
	XSetForeground(display, gc, white);
	// Subwindow box
	XFillRectangle(display, window, gc,
				   1,
				   TITLEBAR_THICKNESS,
				   attr.width - 3,
				   attr.height - (TITLEBAR_THICKNESS + 3));
	
	// Draw buttons and title
	XSetForeground(display, gc, black);
	// Subwindow box
	XDrawRectangle(display, window, gc,
				   0,
				   TITLEBAR_THICKNESS - 1,
				   attr.width - 2,
				   attr.height - 20);
	// Shadow
	XDrawLine(display, window, gc, 1, attr.height - 1, attr.width, attr.height - 1);
	XDrawLine(display, window, gc, attr.width - 1, attr.height - 1, attr.width - 1, 1);

	// White out the shadow ends
	XSetForeground(display, gc, white);
	XDrawPoint(display, window, gc, 0, attr.height - 1);
	XDrawPoint(display, window, gc, attr.width - 1, 0);
	XSetForeground(display, gc, black);
	
	// Draw Title
	drawTitle(display, window, gc, title, attr);
	
	// Draw Close Button
	drawCloseButton(display, window, gc, RECT_CLOSE_BTN);
	
	// Draw Maximize Button
	drawMaximizeButton(display, window, gc, RECT_MAX_BTN);

#ifdef COLLAPSE_BUTTON_ENABLED
	// Draw Collapse Button
	drawCollapseButton(display, window, gc, RECT_COLLAPSE_BTN);
#endif
}
示例#2
0
    void Frame::repaint()
    {
        if (this->__g == NULL) return;
        /* 矩形ウィンドウ */
        int w = getWidth();
        int h = getHeight();
        /* 外枠 */
        __g->setColor(Color::lightGray);
        __g->fillRect(0, 0, w, h);
        __g->setColor(Color::black);
        __g->drawRect(0, 0, w, h);
        /* 内枠 */
        __g->setColor(Color::black);
        __g->drawRect(5, 21, w - 10, h - 26);

        /* 枠 */
        __g->setColor(Color::white);
        __g->drawLine(1, 1, w - 2, 1);
        __g->drawLine(1, 1, 1, h - 2);
        __g->drawLine(w - 5, 21, w - 5, h - 5);
        __g->drawLine(5, h - 5, w - 5, h - 5);
        __g->setColor(Color::gray);
        __g->drawLine(w - 2, 2, w - 2, h - 2);
        __g->drawLine(2, h - 2, w - 2, h - 2);
        __g->drawLine(4, 20, w - 6, 20);
        __g->drawLine(4, 20, 4, h - 6);

        if (getFocused() == true) {
            /* タイトルバー */
            for (int i = 4; i <= 14; i = i + 2) {
                __g->setColor(Color::gray);
                __g->drawLine(20, i, w - 7, i);
                __g->setColor(Color::white);
                __g->drawLine(21, i + 1, w - 6, i + 1);
            }
            drawCloseButton(__g);
        }

        /* タイトル */
        int fw = getFontMetrics()->getWidth(getTitle());
        int fh = getFontMetrics()->getHeight(getTitle());
        __g->setColor(Color::lightGray);
        __g->fillRect(((w - fw) / 2) - 4, 2, fw + 8, getInsets()->top - 4);
        if (getFocused() == true) {
            __g->setColor(Color::black);
        } else {
            __g->setColor(Color::gray);
        }
        __g->drawString(getTitle(), ((w - fw) / 2), ((getInsets()->top - fh) / 2));
        Container::repaint();
    }
示例#3
0
void drawCloseButtonDown(Display *display, Drawable window, GC gc, int x, int y, int w, int h) {	
	drawCloseButton(display, window, gc, x, y, w, h);
	
	// Draw first diag
	XDrawLine(display, window, gc, x + 2, y + 2, x + w - 2, y + h - 2);

	// Draw |
	XDrawLine(display, window, gc, x + w / 2, y, x + w / 2, y + h);

	// Draw -
	XDrawLine(display, window, gc, x, y + h / 2, x + w, y + h / 2);

	// Draw /
	XDrawLine(display, window, gc, x + w - 2, y + 2, x + 2, y + h - 2);

	// Remove Center
	XSetForeground(display, gc, white);
	XFillRectangle(display, window, gc, x + w / 2 - 1, y + h / 2 - 1, 3, 3);
}
示例#4
0
void AMCloseItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {

	if(closeButtonEnabled_ && index.data(AM::CanCloseRole).toBool()) {
		// trick the base class paint version into thinking we have less width than we do.
		QStyleOptionViewItemV4 opt(option);
		initStyleOption(&opt, index);
		opt.rect.setWidth(option.rect.width() - 20);
		QStyledItemDelegate::paint(painter, opt, index);

		// finish drawing the background in the remaining width
		QStyle* sty = opt.widget ? opt.widget->style() : QApplication::style();
		opt.rect = option.rect;
		opt.rect.setLeft(option.rect.right() - 20);
		sty->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter);

	}
	else
		QStyledItemDelegate::paint(painter, option, index);

	drawCloseButton(painter, option, index);
}
示例#5
0
void game::MainLoop(void)
{
  r3dOutToLog("Starting updater, v:%s, cmd:%s\n", UPDATER_VERSION, __r3dCmdLine);

  CUpdater updater;
  
  // parse command line
  int argc = 0;
  char** argv = CommandLineToArgvA(__r3dCmdLine, &argc);
  for(int i=0; i<argc; i++) 
  {
    /*if(strcmp(argv[i], "-steam") == 0 && (i + 0) < argc)
    {
      r3dOutToLog("Trying to init steam\n");
      gSteam.InitSteam();
      continue;
    }*/
  }

  if(g_isConsoleUpdater)
  {
    cmdLine_MainLoop(updater);
    return;
  }
  
  updater.Start();

  win32_input_Flush();
  
  if(g_taskbar) g_taskbar->SetProgressState(win::hWnd, TBPF_NORMAL);
  
  r3dStartFrame();
  while(1)
  {
    r3dEndFrame();
    r3dStartFrame();

    g_mb = 0;
    g_hCursor = gCursorArrow;
    tempDoMsgLoop();
    ::Sleep(1);
    
    r3dRenderer->StartRender();
    r3dRenderer->StartFrame();
    r3dRenderer->SetRenderingMode(R3D_BLEND_ALPHA | R3D_BLEND_NZ);
    r3dSetFiltering(R3D_POINT);
    
    r3dDrawBox2D(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(64, 64, 64));
    
    #if 0
    updater.status_ = CUpdater::STATUS_TimeExpired;
    updater.showProgress_ = false;
    updater.prgTotal_.cur = 100;
    updater.prgTotal_.total = 100;
    r3dscpy(updater.updMsg1_, "Xxxxxxx");
    #endif

    switch(updater.status_) 
    {
      default: r3d_assert(0);
      
      case CUpdater::STATUS_Checking:
	g_bkgStarting->draw(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(255, 255, 255));
	break;

      case CUpdater::STATUS_NeedLogin:
	g_bkgLogin->draw(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(255, 255, 255));
	
	drawLoginButtons(updater);
	break;

      case CUpdater::STATUS_SerialCheck:
	g_bkgSerialCheck->draw(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(255, 255, 255));

	drawSerialCheckButtons(updater);
	break;
    
      case CUpdater::STATUS_NeedRegister:
	g_bkgRegister->draw(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(255, 255, 255));

	drawRegisterButtons(updater);
	break;
	
      case CUpdater::STATUS_TimeExpired:
	g_bkgExpired->draw(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(255, 255, 255));

	drawTimeExpiredButtons(updater);
	break;

      case CUpdater::STATUS_Updating:
	g_bkgUpdate->draw(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(255, 255, 255));

	drawUpdateButtons(updater);
        drawServerStatus(updater);
	drawNews(updater);
	break;
    }
    drawProgressBar(updater);
    drawCloseButton();

    r3dRenderer->EndFrame();
    r3dRenderer->EndRender(true);

    // if exit requested by control-f4
    if(g_bExit) {
      updater.RequestStop();
      break;
    }
    
    // activate updater window if other instance requested it
    if(WaitForSingleObject(g_updaterEvt, 0) == WAIT_OBJECT_0) {
      SwitchToThisWindow(win::hWnd, TRUE);
    }

    // try to remove mouse lock because of 
    // win::HandleActivate code that will lock mouse inside window
    ClipCursor(NULL);

    // if signalled to play game
    if(g_bStartGame)
      break;

    if(updater.result_ != CUpdater::RES_UPDATING && updater.result_ != CUpdater::RES_PLAY)
      break;
      
    // wndclass.hCursor must be NULL for this to work
    //SetCursor(g_hCursor);
  }
  
  updater.Stop();

  if(g_taskbar) g_taskbar->SetProgressState(win::hWnd, TBPF_NOPROGRESS);
  
  switch(updater.result_)
  {
    default: r3d_assert(0); 
    case CUpdater::RES_STOPPED:
      break;

    case CUpdater::RES_PLAY:
      startGame(updater);
      break;
      
    case CUpdater::RES_ERROR:
      showErrorMessageBox(updater);
      break;
  }
  
  gHwInfoPoster.Stop();
  TerminateProcess(GetCurrentProcess(), 0);
  
  return;
}
示例#6
0
void AMDetailedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const  {

	QStyleOptionViewItemV4 opt(option);
	initStyleOption(&opt, index);


	QStyle* sty = QApplication::style();

	// Draw the background: (this will handle selection for us. You can also probe selection directly with opt.state & QStyle::State_Selected)
	sty->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter);


	int textStartingPoint = horizontalMargin();
	// Do we have a pixmap available?
	QRect pmap = opt.rect;
	pmap.setLeft( pmap.left() + horizontalMargin() );
	pmap.setTop( pmap.top() + verticalMargin() );
	pmap.setBottom( pmap.bottom() - verticalMargin() );

	if(opt.features & QStyleOptionViewItemV2::HasDecoration) {
		QPixmap p = opt.icon.pixmap(pmap.height());
		sty->drawItemPixmap(painter, pmap, Qt::AlignLeft | Qt::AlignVCenter, p);
		textStartingPoint += horizontalMargin() + p.width() + horizontalSpacing();
	}

	QRect textRect = opt.rect;
	textRect.setLeft( textRect.left() + textStartingPoint);


	if (index.data(AM::ModifiedRole).toBool()) {
		fontItalic_.setPointSize(size1_);
		painter->setFont(fontItalic_);
	}
	else {
		font_.setPointSize(size1_);
		painter->setFont(font_);
	}
	painter->setPen(color1_);

	painter->drawText(textRect, index.data(Qt::DisplayRole).toString());

	QVariant description = index.data(AM::DescriptionRole);
	if(!description.isNull()){
		font_.setPointSize(size2_);
		painter->setFont(font_);
		painter->setPen(color2_);
		QFontMetrics fontMetrics(font_);

		painter->drawText(textRect.translated(QPoint(0,20)), fontMetrics.elidedText(description.toString(), Qt::ElideRight, textRect.width() ));

	}

	/// call base class to draw close button:
	drawCloseButton(painter, opt, index);


	/* What info is available:
enum OptionType
enum Position
enum StyleOptionType
enum StyleOptionVersion
enum ViewItemFeature
flags ViewItemFeatures
enum ViewItemPosition
QStyleOptionViewItemV4 ()
QStyleOptionViewItemV4 ( const QStyleOptionViewItemV4 & )
QStyleOptionViewItemV4 ( const QStyleOptionViewItem & )
backgroundBrush : QBrush
checkState : Qt::CheckState
decorationAlignment : Qt::Alignment
decorationPosition : Position
decorationSize : QSize
direction : Qt::LayoutDirection
displayAlignment : Qt::Alignment
features : ViewItemFeatures
font : QFont
fontMetrics : QFontMetrics
icon : QIcon
index : QModelIndex
initFrom ( const QWidget * )
locale : QLocale
palette : QPalette
rect : QRect
showDecorationSelected : bool
state : QStyle::State
text : QString
textElideMode : Qt::TextElideMode
type : int
version : int
viewItemPosition : ViewItemPosition
widget : const QWidget *
operator= ( const QStyleOptionViewItem & ) : QStyleOption
*/
}