예제 #1
0
//----------------------------------------------------------------------------------------------------
void UISearchTextField::draw (CDrawContext *pContext)
{
	drawBack (pContext);
	drawClearMark (pContext);

	if (platformControl)
	{
		setDirty (false);
		return;
	}

	pContext->setDrawMode (kAntiAliasing);

	CColor origFontColor (fontColor);
	if (getText ().empty ())
	{
		CColor color (fontColor);
		color.alpha /= 2;
		setFontColor (color);
		drawPlatformText(pContext, CString ("Search").getPlatformString ());
	}
	else
		drawPlatformText (pContext, getText ().getPlatformString ());

	setDirty (false);
	setFontColor (origFontColor);
}
예제 #2
0
void CDisplayView::mouse(CDrawContext *dstcon, CPoint &where)
{
  unsigned long delta=250, ticks = getParent()->getTicks();
  bool dblclick = false;
	long button = dstcon->getMouseButtons();

  if (!(button & kLButton))
  {
		return;
  }

  dblclick = (ticks-stTicks)<delta;
  stTicks = ticks;

  if(dblclick)
  {
    if(mEdit)
    {
      getParent()->setEditView(this);
      setBackColor(kGreyCColor);
      setFontColor(kWhiteCColor);
      setText(mText);
      takeFocus(dstcon);
      mDrawText = true;
    }
  }
  else
  {
    if(mParentView)
    {
      mParentView->notify(mView,(const char *)VNTF_MOUSE);
      mParentView->mouse(dstcon,where);
    }
  }
}
예제 #3
0
	void label::render(){
		//渲染标签
		float fcR, fcG, fcB, fcA;
		fcR = FgR; fcG = FgG; fcB = FgB; fcA = FgA;
		if (mouseon){
			fcR = FgR*1.2f; fcG = FgG*1.2f; fcB = FgB*1.2f; fcA = FgA*0.8f;
		}
		if (focused){                                                 //Focus
			glDisable(GL_TEXTURE_2D);
			glColor4f(FgR*0.6f, FgG*0.6f, FgB*0.6f, linealpha);
			glLineWidth(linewidth);
			//glBegin(GL_POINTS)
			//glVertex2i(xmin - 1, ymin)
			//glEnd()
			glBegin(GL_LINE_LOOP);
			glVertex2i(xmin, ymin);
			glVertex2i(xmin, ymax);
			glVertex2i(xmax, ymax);
			glVertex2i(xmax, ymin);
			glEnd();
		}
		glEnable(GL_TEXTURE_2D);
		setFontColor(fcR, fcG, fcB, fcA);
		renderChar(xmin, ymin, text);
	}
예제 #4
0
bool MenuButton::mouseLeave(double, double, osgWidget::WindowManager*) 
{
	// reset style
	setFontColor(MENU_BUTTON_FONT_COLOR);
			
    return true;
}
예제 #5
0
bool MenuButton::mouseEnter(double, double, osgWidget::WindowManager*) 
{
	// hover style
    setFontColor(MENU_BUTTON_FONT_COLOR_HOVER);

    return true;
}
예제 #6
0
bool CommonButton::initWithNode(Node *  normalNode, Node *  selectedNode,
                                Node *  disabledNode, int nEventID,
                                const char *  btnStr, const char *  btnBottomStr){
	m_bEnabled = true;
	m_bSelected = false;
	setNormalImage(normalNode);
	setSelectedImage(selectedNode);
	setDisabledImage(disabledNode);

	float scaleEle = GameConfig::getInterface()->scaleEle;
	float scaleEleX = GameConfig::getInterface()->scaleEleX;

	if (g_defaultBtnFontType == 2){
		m_label = CCLabelBMFont::create(btnStr, g_defaultBtnStringTnf.c_str());
		m_pBottomlabel = CCLabelBMFont::create(btnBottomStr, g_defaultBtnStringTnf.c_str());
	}else{
		m_label = CCLabelTTF::create(btnStr, "黑体", 40);
		m_pBottomlabel = CCLabelTTF::create(btnBottomStr, "黑体", 40);
	}
    
	m_label->setPosition(ccp(getContentSize().width/2, getContentSize().height/2));
	m_pBottomlabel->setPosition(ccp((getContentSize().width/2) + 75, -20));
	setFontColor(ccWHITE);
	addChild(m_label, 100);
	addChild(m_pBottomlabel, 101);

	return true;
}
예제 #7
0
파일: uilabel.cpp 프로젝트: dcthe1/GameUI
void Label::setTheme( Theme & t, const string prefix )
{
	Widget::setTheme( t, prefix );
  beginUpdate();
  setBorder( t.getBorder( prefix+"label" ) );
  setFont( t.getFont( prefix+"label" ) );
  setFontColor( t.getColor( prefix+"label_font" ) );
  endUpdate();
}
예제 #8
0
void EditPlayerDialog::selectFontColor()
{
    QColor selectedColor;
    selectedColor = QColorDialog::getColor(QColor(fontColor),this);
    if (selectedColor.isValid())
    {
        setFontColor(selectedColor.name());
    }
}
예제 #9
0
 ColorLabel(const char* label):
 osgWidget::Label("", "") {
     setFont("fonts/Vera.ttf");
     setFontSize(14);
     setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
     setColor(0.3f, 0.3f, 0.3f, 1.0f);
     addHeight(18.0f);
     setCanFill(true);
     setLabel(label);
     setEventMask(osgWidget::EVENT_MOUSE_PUSH | osgWidget::EVENT_MASK_MOUSE_MOVE);
 }
예제 #10
0
//-----------------------------------------------------------------------------
void CDrawContext::init ()
{
	// set the default values
	setFrameColor (kWhiteCColor);
	setLineStyle (kLineSolid);
	setLineWidth (1);
	setFillColor (kBlackCColor);
	setFontColor (kWhiteCColor);
	setFont (kSystemFont);
	setDrawMode (kAliasing);
	setClipRect (surfaceRect);
}
예제 #11
0
파일: Graphics.cpp 프로젝트: Agreon/Fallen
    void Graphics::setFont(std::string name, ushort fontSize, color fontColor)
    {
        std::map<std::string, FTGLPixmapFont*>::iterator iter = m_Fonts.find( name );
        if( iter != m_Fonts.end() )
        {
            m_CurrentFont = m_Fonts[ name ];
            m_CurrentFont->FaceSize(fontSize);
            setFontColor(fontColor);
        }
        else
        {
			Log::write(AL::LOG_ERROR, "GraphicsManager", std::string("There is no font loaded with this name! Name: ") + name);
        }
    }
예제 #12
0
//-----------------------------------------------------------------------------
void D2DDrawContext::setGlobalAlpha (float newAlpha)
{
    if (currentState.globalAlpha == newAlpha)
        return;
    COffscreenContext::setGlobalAlpha (newAlpha);
    CColor color (currentState.frameColor);
    currentState.frameColor = kTransparentCColor;
    setFrameColor (color);
    color = currentState.fillColor;
    currentState.fillColor = kTransparentCColor;
    setFillColor (color);
    color = currentState.fontColor;
    currentState.fontColor = kTransparentCColor;
    setFontColor (color);
}
예제 #13
0
MenuButton::MenuButton(const char* label, std::tr1::function<void ()> callback) : 
	osgWidget::Label("", ""), 
	_callback(callback)
{	
	// styling
	setFont("fonts/times.ttf");
	setFontSize(MENU_BUTTON_FONT_SIZE);
    setFontColor(MENU_BUTTON_FONT_COLOR);
    setLabel(label);
	setPadding(MENU_BUTTON_PADDING);
	setAlignHorizontal(osgWidget::Widget::HA_LEFT);
    
	// activate event handling for mouse clicks and moves
	setEventMask(osgWidget::EVENT_MOUSE_PUSH | osgWidget::EVENT_MASK_MOUSE_MOVE);
}
    ColorLabel(const char* label):
        osgWidget::Label(label, "") {
        setFont("fonts/VeraMono.ttf");
        setFontSize(14);
        setFontColor(1.0f, 1.0f, 1.0f, 1.0f);

        setColor(0.3f, 0.3f, 0.3f, 1.0f);
        setPadding(2.0f);
        setCanFill(true);

        addSize(150.0f, 25.0f);

        setLabel(label);
        setEventMask(osgWidget::EVENT_MOUSE_PUSH | osgWidget::EVENT_MASK_MOUSE_MOVE);
    }
예제 #15
0
//평수
void EstimateUserInfo::setSizeInputBox()
{
    auto editbox = EditBox::create(Size(300, 30), ui::Scale9Sprite::create());
    editbox->setPosition(ratioPosition(50, 52.5f));
    editbox->setPlaceHolder("공사할 공간의 면적(평수)");
    editbox->setMaxLength(100);
    editbox->setPlaceholderFontColor(Color3B::GRAY);
    editbox->setFontColor(Color3B::BLACK);
    editbox->setPlaceholderFontSize(10);
    editbox->setReturnType(EditBox::KeyboardReturnType::DONE);
    editbox->setInputMode(EditBox::InputMode::NUMERIC);

    this->addChild(editbox);
    editbox->setDelegate(this);
    
}
예제 #16
0
EditPlayerDialog::EditPlayerDialog(int playerNumber,QWidget *parent) :
        QDialog(parent),
        ui(new Ui::EditPlayerDialog)
{
    ui->setupUi(this);
    this->playerNumber = playerNumber;

    PlaylistPlayer *player = PlaylistPlayer::getObjectWithNumber(playerNumber);
    ui->deviceSelectWidget->selectDevice(player->getType(),player->getDeviceID(),player->getChannel());
    setColor(player->getColor());
    setFontColor(player->getFontColor());

    connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(save()));
    connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(closeDialog()));
    connect(ui->selectColorButton, SIGNAL(clicked()), this, SLOT(selectColor()));
    connect(ui->selectFontColorButton, SIGNAL(clicked()), this, SLOT(selectFontColor()));
}
예제 #17
0
//주소
void EstimateUserInfo::setAddressInputBox()
{
    
    auto editbox = EditBox::create(Size(300, 30), ui::Scale9Sprite::create());
//    "images/UIButtons/UI_TopMenuBG-hd.png"
    editbox->setPosition(ratioPosition(50, 63));
    editbox->setPlaceHolder("상세주소입력");                        //처음 보여주는 문자열
    editbox->setMaxLength(100);                                //최대로 입력받을수 잇는 문자의 길이
    editbox->setPlaceholderFontColor(Color3B::GRAY);        //문자열 색변경
    editbox->setFontColor(Color3B::BLACK);                    //입력한 문자열 색변경

    //키보드 오른쪽하단 enter키를 search로 변경
    editbox->setReturnType(EditBox::KeyboardReturnType::DONE);
    this->addChild(editbox);
    editbox->setDelegate(this);
    
}
예제 #18
0
ItemSettings::ItemSettings(ItemProperties *prop,QWidget *parent):QWidget(parent,Qt::Tool)
{
    setupUi(this);

    this->prop = prop;

    this->fontColor = prop->fontColor;
    this->penColor = prop->itemPen.color();
    this->brushColor = prop->itemBrush.color();

    QPixmap penColor(45,11);
    penColor.fill(prop->itemPen.color());
    QIcon penIcon(penColor);
    this->pb_penColor->setIcon(penIcon);
    this->pb_penColor->setIconSize(QSize(45,11));
    this->sd_penWidth->setValue(prop->itemPen.width());
    this->cb_penStyle->setCurrentIndex(this->prop->itemPen.style() - 1);

    QPixmap brushColor(45,11);
    brushColor.fill(prop->itemBrush.color());
    QIcon brushIcon(brushColor);
    this->pb_brushColor->setIcon(brushIcon);
    this->pb_brushColor->setIconSize(QSize(45,11));
    this->cb_brushStyle->setCurrentIndex(this->prop->itemBrush.style());

    QPixmap fontColor(45,11);
    fontColor.fill(prop->fontColor);
    QIcon fontIcon(fontColor);
    this->pb_fontColor->setIcon(fontIcon);
    this->pb_fontColor->setIconSize(QSize(45,11));

    connect(pb_penColor,SIGNAL(released()),this,SLOT(setPenColor()));
    connect(pb_brushColor,SIGNAL(released()),this,SLOT(setBrushColor()));
    connect(pb_done,SIGNAL(released()),this,SLOT(saveSettings()));
    connect(pb_selectFont,SIGNAL(released()),this,SLOT(selectFont()));
    connect(pb_fontColor,SIGNAL(released()),this,SLOT(setFontColor()));

    int p_midX = parent->x() + 100;
    int p_midY = parent->y() + 150;

    this->move(p_midX , p_midY) ;

    this->activateWindow();
}
예제 #19
0
void HelloWorld::testEditBox()
{
    auto sp = Scale9Sprite::create("textField.png");
    //设置大小
    sp->setPreferredSize(Size(255, 40));
    sp->setAnchorPoint(Point(0.5, 0.5));
    
    
    auto editBox=EditBox::create(Size(255, 40), sp);
    editBox->setPlaceHolder("请输入内容");
    editBox->setFontColor(Color3B(255, 0, 255));
    editBox->setPosition(Point(240, 60));
    editBox->setInputMode(EditBox::InputMode::ANY);
    editBox->setMaxLength(10);
    editBox->setReturnType(EditBox::KeyboardReturnType::DONE);
    editBox->setDelegate(this);
    editBox->setInputFlag(EditBox::InputFlag::PASSWORD);
    this->addChild(editBox);
}
예제 #20
0
//요청사항
void EstimateUserInfo::setRequestInputBox()
{
    auto editbox = EditBox::create(Size(300, 30), ui::Scale9Sprite::create());
    editbox->setPosition(ratioPosition(50, 42));
    editbox->setPlaceHolder("세부 요청사항을 작성해주세요.");                            editbox->setMaxLength(100);
    editbox->setPlaceholderFontColor(Color3B::GRAY);
    editbox->setFontColor(Color3B::BLACK);
    editbox->setReturnType(EditBox::KeyboardReturnType::DONE);
    editbox->setPlaceholderFontSize(20);
    editbox->setTag(TAG_REQUEST_BOX);
    editbox->setDelegate(this);
    this->addChild(editbox);
    
    _lbRequest = setLabelSystemTTFUnAdd("", 20, ratioPosition(50, 44));
    _lbRequest->setAnchorPoint(Vec2(0.5f, 1.0f));
    _lbRequest->setAlignment(TextHAlignment::LEFT, TextVAlignment::TOP);
    _lbRequest->setDimensions(300, 100);
    _lbRequest->setColor(Color3B::BLACK);
    addChild(_lbRequest);
    
}
예제 #21
0
파일: font.cpp 프로젝트: dergunov/scummvm
void FontRenderer::setFontColorByCharacter(int32 characterId) {
	debugC(5, kDebugFont, "setFontColorByCharacter(%d)", characterId);

	// unfortunately this table was hardcoded in the original executable
	static const byte colorsByCharacters[] = {
		0xe0, 0xdc, 0xc8,   0xd6, 0xc1, 0xc8,   0xe9, 0xde, 0xc8,   0xeb, 0xe8, 0xc8,
		0xd1, 0xcf, 0xc8,   0xdb, 0xd5, 0xc8,   0xfb, 0xfa, 0xc8,   0xd9, 0xd7, 0xc8,
		0xe8, 0xe4, 0xc8,   0xe9, 0xfa, 0xc8,   0xeb, 0xe4, 0xc8,   0xeb, 0xe4, 0xc8,
		0xd2, 0xea, 0xc8,   0xd3, 0xd0, 0xc8,   0xe1, 0xdd, 0xc8,   0xd9, 0xd7, 0xc8,
		0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,
		0xd2, 0xcf, 0xc8,   0xd1, 0xcf, 0xc8,   0xd9, 0xd7, 0xc8,   0xe3, 0xdd, 0xc8,
		0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,
		0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,
		0xd9, 0xd7, 0xc8,   0xe6, 0xe4, 0xc8,   0xd9, 0xd7, 0xc8,   0xcd, 0xca, 0xc8,
		0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xeb, 0xe8, 0xc8,   0xdb, 0xd5, 0xc8,
		0xe0, 0xdc, 0xc8,   0xd6, 0xc1, 0xc8,   0xd3, 0xd0, 0xc8,   0xd1, 0xcf, 0xc8,
		0xe6, 0xe4, 0xc8,   0xd1, 0xcf, 0xc8,   0xd2, 0xcf, 0xc8,   0xcc, 0xcb, 0xc8,
		0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,
		0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,
		0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8,   0xd9, 0xd7, 0xc8
	};

	setFontColor(colorsByCharacters[characterId * 3 + 2], colorsByCharacters[characterId * 3 + 1], colorsByCharacters[characterId * 3 + 0]);
}
예제 #22
0
파일: main.cpp 프로젝트: GValiente/torrijas
int main()
{
    trj::ApplicationConfig config;
    config.setWindowTitle("Torrijas Template");

    trj::main(std::move(config), []()
    {
        auto textNode = trj::TextNode::create();
        textNode->setFontSize(80);
        textNode->setFontColor(1, 1, 1);
        textNode->setHorizontalAlignment(trj::TextNode::HorizontalAlignment::CENTER);
        textNode->addText(0, 0, "Hi :D");

        auto& rootNode = trj::Node::getRootNode();
        rootNode.addChild(std::move(textNode));

        while(true)
        {
            trj::Application::update();
        }
    });

    return 0;
}
예제 #23
0
파일: subWindow.cpp 프로젝트: kongove/toys
//初始化聊天室界面和程序基本信息
void SubWindow::initialize()
{
	
	resize(620,600);
	setMinimumSize(620,600);
	setMaximumSize(620,600);
	setWindowTitle(tr("Pigeons by Xiyou-Linux-Group"));

	messageWindow = new QWidget(this);
	messageWindow->resize(620,600);
	messageWindow->setMinimumSize(620,600);
        messageWindow->setMaximumSize(620,600);
	
	recordTextEdit = new QTextEdit(messageWindow);
	recordTextEdit->setReadOnly(true);
	recordTextEdit->setMinimumSize(600,300);

	inputTextEdit = new QTextEdit(messageWindow);
	inputTextEdit->setMinimumSize(490,100);
	inputTextEdit->setMaximumSize(600,180);

	editToolBar = new QToolBar(messageWindow);

	//编辑工具栏上的字体
	fontComboBox = new QComboBox(editToolBar);
	editToolBar->addWidget(fontComboBox);
	fontComboBox->setEditable(true);
	QFontDatabase fontDB;
	fontComboBox->addItems(fontDB.families());
	connect(fontComboBox, SIGNAL(activated(const QString &)),
	inputTextEdit, SLOT(setFontFamily(const QString &)));
	fontComboBox->setCurrentIndex(fontComboBox->findText(QApplication::font().family()));

	//编辑工具栏的字体大小
	sizeComboBox = new QComboBox(editToolBar);
	editToolBar->addWidget(sizeComboBox);
	sizeComboBox->setEditable(true);
	foreach(int size, fontDB.standardSizes())
		sizeComboBox->addItem(QString::number(size));
	connect(sizeComboBox, SIGNAL(activated(const QString &)),
		this, SLOT(setFontSize(const QString &)));
	sizeComboBox->setCurrentIndex(sizeComboBox->findText(QString::number(QApplication::font().pointSize())));

	//粗体
	boldButton = new QToolButton(editToolBar);
	editToolBar->addWidget(boldButton);
	boldButton->setCheckable(true);
	boldButton->setIcon(QIcon(":/data/textbold.png"));
	connect(boldButton, SIGNAL(toggled(bool)), this, SLOT(setBoldFont(bool)));

	//斜体
	italicButton = new QToolButton(editToolBar);
	editToolBar->addWidget(italicButton);
	italicButton->setCheckable(true);
	italicButton->setIcon(QIcon(":/data/textitalic.png"));
	connect(italicButton, SIGNAL(toggled(bool)), inputTextEdit, SLOT(setFontItalic(bool)));

	//下划线
	underlineButton = new QToolButton(editToolBar);
	editToolBar->addWidget(underlineButton);
	underlineButton->setCheckable(true);
	underlineButton->setIcon(QIcon(":/data/textunder.png"));
	connect(underlineButton, SIGNAL(toggled(bool)), inputTextEdit, SLOT(setFontUnderline(bool)));

	//颜色
	colorButton = new QToolButton(editToolBar);
	editToolBar->addWidget(colorButton);
	colorButton->setIcon(QIcon(":/data/textcolor.png"));
	connect(colorButton, SIGNAL(clicked()), this, SLOT(setFontColor()));

	//打开图片
	imageButton = new QToolButton(editToolBar);
	editToolBar->addWidget(imageButton);
	imageButton->setIcon(QIcon(":/data/openimage.png"));
	connect(imageButton, SIGNAL(clicked()), this, SLOT(openImage()));
	
	//发送文件
	fileButton = new QToolButton(editToolBar);
	editToolBar->addWidget(fileButton);
	fileButton->setIcon(QIcon(":/data/file.png"));
	connect(fileButton, SIGNAL(clicked()), this, SLOT(sendFile()));

	//发送按钮
	sendButton = new QPushButton(tr("&Send"), messageWindow);
	sendButton->setEnabled(false);
	connect(inputTextEdit, SIGNAL(textChanged()), this, SLOT(enabledSendButton()));
	connect(sendButton, SIGNAL(clicked()), this, SLOT(sendMessage()));

	//关于按钮
	aboutButton = new QPushButton(tr("&About"),messageWindow);
	connect(aboutButton, SIGNAL(clicked()), this, SLOT(about()));

	//用户昵称表
	//userListWidget = new QListWidget(messageWindow);
	//userListWidget->setMinimumSize(120,420);
	//userListWidget->setMaximumSize(180,600);

	//退出按钮
	quitButton = new QPushButton(tr("&Quit"),messageWindow);
	connect(quitButton,SIGNAL(clicked()), this, SLOT(close()));
			
	//布局
	QHBoxLayout *buttonLayout = new QHBoxLayout;
	buttonLayout->addWidget(aboutButton);
	buttonLayout->addStretch(3);
	buttonLayout->addWidget(sendButton);
	buttonLayout->addStretch(1);
	buttonLayout->addWidget(quitButton);

	QVBoxLayout *leftLayout = new QVBoxLayout;
	leftLayout->addWidget(recordTextEdit);
	leftLayout->addWidget(editToolBar);
	leftLayout->addWidget(inputTextEdit);

	QGridLayout *mainLayout = new QGridLayout;
	mainLayout->addLayout(leftLayout,0,0);
	//mainLayout->addWidget(userListWidget,0,1);
	mainLayout->addLayout(buttonLayout,1,0,1,2);
	mainLayout->setSizeConstraint(QLayout::SetFixedSize);

	messageWindow->setLayout(mainLayout);
	messageWindow->show();
}
예제 #24
0
파일: UIEditBox.cpp 프로젝트: 289/DouPo
void EditBox::setFontColor(const Color3B& color)
{
    setFontColor(Color4B(color));
}
예제 #25
0
	void button::render(){

		//渲染按钮
		float fcR, fcG, fcB, fcA;
		fcR = FgR; fcG = FgG; fcB = FgB; fcA = FgA;
		if (mouseon){
			fcR = FgR*1.2f; fcG = FgG*1.2f; fcB = FgB*1.2f; fcA = FgA*0.8f;
		}
		if (pressed){
			fcR = FgR*0.8f; fcG = FgG*0.8f; fcB = FgB*0.8f; fcA = FgA*1.5f;
		}
		if (!enabled){
			fcR = FgR*0.5f; fcG = FgG*0.5f; fcB = FgB*0.5f; fcA = FgA*0.3f;
		}
		glColor4f(fcR, fcG, fcB, fcA);

		glDisable(GL_TEXTURE_2D);    //Button
		glBegin(GL_QUADS);
		glVertex2i(xmin, ymin);
		glVertex2i(xmin, ymax);
		glVertex2i(xmax, ymax);
		glVertex2i(xmax, ymin);
		glEnd();
		glColor4f(FgR*0.9f, FgG*0.9f, FgB*0.9f, linealpha);

		if (!enabled) glColor4f(0.5f, 0.5f, 0.5f, linealpha);
		glLineWidth(linewidth);
		glBegin(GL_LINE_LOOP);
		glVertex2i(xmin, ymin);
		glVertex2i(xmin, ymax);
		glVertex2i(xmax, ymax);
		glVertex2i(xmax, ymin);
		glEnd();

		glBegin(GL_LINE_LOOP);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.8f, 0.8f, 0.8f, linealpha);
		glVertex2i(xmin + 1, ymin + 1);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.4f, 0.4f, 0.4f, linealpha);
		glVertex2i(xmin + 1, ymax - 1);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.4f, 0.4f, 0.4f, linealpha);
		glVertex2i(xmax - 1, ymax - 1);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.8f, 0.8f, 0.8f, linealpha);
		glVertex2i(xmax - 1, ymin + 1);

		glEnd();

		glEnable(GL_TEXTURE_2D);
		setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
		if (!enabled) setFontColor(0.6f, 0.6f, 0.6f, 1.0f);
		renderChar((xmin + xmax - getStrWidth(text)) / 2, (ymin + ymax - 20) / 2, text);
	}
예제 #26
0
void PlotArea::setFontColorSlot()
{								 //invalid
	setFontColor(QColor());
}
예제 #27
0
	void trackbar::render(){

		//渲染TrackBar(How can I translate it?)
		float fcR, fcG, fcB, fcA;
		float bcR, bcG, bcB, bcA;
		fcR = FgR; fcG = FgG; fcB = FgB; fcA = FgA;
		bcR = BgR; bcG = BgG; bcB = BgB; bcA = BgA;
		if (mouseon){
			fcR = FgR*1.2f; fcG = FgG*1.2f; fcB = FgB*1.2f; fcA = FgA*0.8f;
		}
		if (pressed){
			fcR = FgR*0.8f; fcG = FgG*0.8f; fcB = FgB*0.8f; fcA = FgA*1.5f;
		}
		if (!enabled){
			fcR = FgR*0.5f; fcG = FgG*0.5f; fcB = FgB*0.5f; fcA = FgA*0.3f;
		}

		glColor4f(bcR, bcG, bcB, bcA);                                              //Track
		glDisable(GL_TEXTURE_2D);
		glBegin(GL_QUADS);
		glVertex2i(xmin, ymin);
		glVertex2i(xmax, ymin);
		glVertex2i(xmax, ymax);
		glVertex2i(xmin, ymax);
		glEnd();
		glDisable(GL_TEXTURE_2D);                                                //Bar
		glColor4f(fcR, fcG, fcB, fcA);
		glBegin(GL_QUADS);
		glVertex2i(xmin + barpos, ymin);
		glVertex2i(xmin + barpos + barwidth, ymin);
		glVertex2i(xmin + barpos + barwidth, ymax);
		glVertex2i(xmin + barpos, ymax);
		glEnd();
		glColor4f(FgR*0.9f, FgG*0.9f, FgB*0.9f, linealpha);

		if (!enabled) glColor4f(0.5f, 0.5f, 0.5f, linealpha);
		//glLineWidth(linewidth)                                                  //Focus
		glBegin(GL_LINE_LOOP);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.8f, 0.8f, 0.8f, linealpha);
		glVertex2i(xmin + 1, ymin + 1);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.4f, 0.4f, 0.4f, linealpha);
		glVertex2i(xmin + 1, ymax - 1);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.4f, 0.4f, 0.4f, linealpha);
		glVertex2i(xmax - 1, ymax - 1);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.8f, 0.8f, 0.8f, linealpha);
		glVertex2i(xmax - 1, ymin + 1);

		glEnd();
		glEnable(GL_TEXTURE_2D);
		setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
		if (!enabled) setFontColor(0.6f, 0.6f, 0.6f, 1.0f);
		renderChar((xmin + xmax - getStrWidth(text)) / 2, ymin, text);

	}
예제 #28
0
/***************************
Methods of class GLText:
***************************/
GLText::GLText(void)
:fontType(FL_SCREEN),fontSize(12)
{
	setFontColor(0.0, 0.0, 0.0);
	setFontScale(0.1, 0.1);
}
예제 #29
0
	void RichEdit::addHtml(const wchar_t* html) {
		size_t i = 0, j, len = wcslen(html);
		FastStrBuff tmp;
		bool insideTag = false;

		while(i < len) {
			switch(html[i]) {
			case L'\r':
			case L'\n':
				break;
			case L'<':
				if(tmp.size() > 0) {
					addText(tmp.c_str());
					tmp.clear();
				}
				insideTag = true;
				break;
			case L'>':
				insideTag = false;
				if(tmp.equalIC(L"b"))
					setBold(true);
				else if(tmp.equalIC(L"/b"))
					setBold(false);
				else if(tmp.equalIC(L"i"))
					setItalic(true);
				else if(tmp.equalIC(L"/i"))
					setItalic(false);
				else if(tmp.equalIC(L"u"))
					setUnderline(true);
				else if(tmp.equalIC(L"/u"))
					setUnderline(false);
				else if(tmp.equalIC(L"br") || tmp.equalIC(L"br/") || tmp.equalIC(L"br /")) {
					addText(L"\r\n");
					setFontColor(_defaultCf.crTextColor);
				}
				else if(tmp.size() > 4) {
					std::wstring tag = tmp.firstChars(3);
					if(tag == L"img" || tag == L"IMG")
						handleImg(tmp.c_str());
				}
				tmp.clear();
				break;
			case L'&':
				if(insideTag) {
					tmp.push_back(html[i]); // it's tag, don't care
					break;
				}
				if(len > i + 3) {
					// &lt;
					if(html[i+1] == L'l' && html[i+2] == L't' && html[i+3] == L';')	{
						addText(tmp.c_str());
						tmp.clear();
						addText(L"<");
						i += 3;
						break;
					}
					// &gt;
					else if(html[i+1] == L'g' && html[i+2] == L't' && html[i+3] == L';') {
						addText(tmp.c_str());
						tmp.clear();
						addText(L">");
						i += 3;
						break;
					}
				}
				if(len > i + 4) {
					// &amp;
					if(html[i+1] == L'a' && html[i+2] == L'm' && html[i+3] == L'p' && html[i+4] == L';') {
						addText(tmp.c_str());
						tmp.clear();
						addText(L"&");
						i += 4;
						break;
					}
				}
				if(len > i + 5) {
					// &quot;
					if(html[i+1] == L'q' && html[i+2] == L'u' && html[i+3] == L'o' && html[i+4] == L't' && html[i+5] == L';') {
						addText(tmp.c_str());
						tmp.clear();
						addText(L"\"");
						i += 5;
						break;
					} 
					// &nbsp;
					else if(html[i+1] == L'n' && html[i+2] == L'b' && html[i+3] == L's' && html[i+4] == L'p' && html[i+5] == L';') {
						addText(tmp.c_str());
						tmp.clear();
						addText(L" ");
						i += 5;
						break;
					}
					// &apos;
					else if(html[i+1] == L'a' && html[i+2] == L'p' && html[i+3] == L'o' && html[i+4] == L's' && html[i+5] == L';') {
						addText(tmp.c_str());
						tmp.clear();
						addText(L"'");
						i += 5;
						break;
					}
				}
				// &#xxxx;
				if(len > i + 6 && html[i+1] == L'#' && html[i+6] == L';') {
					wchar_t hex[4];
					bool valid = true;
					for(j=0; j<4; j++) {
						hex[j] = html[i+j+2];
						if(hex[j] < L'0' || hex[j] > L'9') {
							valid = false;
							break;
						}
						hex[j] -= 0x30;
					}
					addText(tmp.c_str());
					tmp.clear();
					if(valid) {
						wchar_t letter[2] = {0,0};
						letter[0] = hex[0]*1000 + hex[1]*100 + hex[2]*10 + hex[3];
						addText(letter);
					}
					i += 6;
					break;
				}
				tmp.push_back(html[i]); // if & not for special char
				break;
			default:
				tmp.push_back(html[i]);
			}
			i++;
		}
		if(tmp.size() > 0)
			addText(tmp.c_str());
	}
예제 #30
0
void Simulation::configure(const config::Configuration& config)
{
    // Resize world
    {
        auto size = config.get<SizeVector>("world-size");

        if (size.getWidth() == Zero || size.getHeight() == Zero)
            throw config::Exception("Width or height is zero!");

        setWorldSize(size);
    }

    // Time step
    setTimeStep(config.get<units::Time>("dt"));

    if (config.has("length-coefficient"))
    {
        m_converter.setLengthCoefficient(config.get<RealType>("length-coefficient"));
    }

    // Set gravity
    setGravity(config.get("gravity", getGravity()));

    // Number of iterations
    setIterations(config.get("iterations", getIterations()));

    // Background color
    setBackgroundColor(config.get("background", getBackgroundColor()));

#if CONFIG_RENDER_TEXT_ENABLE
    setFontColor(config.get("text-color", getBackgroundColor().inverted()));
#endif

#if CONFIG_RENDER_TEXT_ENABLE
    setFontSize(config.get("text-size", getFontSize()));
#endif

#if CONFIG_RENDER_TEXT_ENABLE
    setSimulationTimeRender(config.get("show-simulation-time", isSimulationTimeRender()));
#endif

#ifdef CECE_ENABLE_RENDER
    setVisualized(config.get("visualized", isVisualized()));
#endif

    // Parse plugins
    for (auto&& pluginConfig : config.getConfigurations("plugin"))
    {
        // Returns valid pointer or throws an exception
        requirePlugin(pluginConfig.get("name"))->configure(*this, pluginConfig);
    }

    // Parse parameters
    for (auto&& parameterConfig : config.getConfigurations("parameter"))
    {
        setParameter(parameterConfig.get("name"), units::parse(parameterConfig.get("value")));
    }

    // Register user types
    for (auto&& typeConfig : config.getConfigurations("type"))
    {
        addObjectType({
            typeConfig.get("name"),
            typeConfig.get("base"),
            typeConfig.toMemory()
        });
    }

    // Parse init
    for (auto&& initConfig : config.getConfigurations("init"))
    {
        const String typeName = initConfig.has("language")
            ? initConfig.get("language")
            : initConfig.get("type");

        auto initializer = getPluginContext().createInitializer(typeName);

        if (initializer)
        {
            // Configure initializer
            initializer->loadConfig(*this, initConfig);

            // Register initializer
            addInitializer(std::move(initializer));
        }
    }

    // Parse modules
    for (auto&& moduleConfig : config.getConfigurations("module"))
    {
        // Get name
        auto name = moduleConfig.get("name");

        if (hasModule(name))
            continue;

        const String typeName = moduleConfig.has("language")
            ? moduleConfig.get("language")
            : moduleConfig.has("type")
                ? moduleConfig.get("type")
                : name
        ;

        auto module = getPluginContext().createModule(typeName, *this);

        if (module)
        {
            module->loadConfig(*this, moduleConfig);

            addModule(std::move(name), std::move(module));
        }
    }

    // Parse programs
    for (auto&& programConfig : config.getConfigurations("program"))
    {
        const String typeName = programConfig.has("language")
            ? programConfig.get("language")
            : programConfig.get("type");

        auto program = getPluginContext().createProgram(typeName);

        if (program)
        {
            // Configure program
            program->loadConfig(*this, programConfig);

            // Register program
            addProgram(programConfig.get("name"), std::move(program));
        }
    }

    // Parse objects
    for (auto&& objectConfig : config.getConfigurations("object"))
    {
        // Create object
        auto object = buildObject(
            objectConfig.get("class"),
            objectConfig.get("type", object::Object::Type::Dynamic)
        );

        if (object)
            object->configure(objectConfig, *this);
    }

    if (config.has("data-out-objects-filename"))
    {
        m_dataOutObjects = makeUnique<OutFileStream>(config.get("data-out-objects-filename"));
        *m_dataOutObjects << "iteration;totalTime;id;typeName;posX;posY;velX;velY\n";
    }
}