Пример #1
0
void Graph::saveData(DataFileParser *file)
{
    // background color
    file->writeBlockIdentifier("graphWBgColor");
    file->writeString(getBgColor().name());

    // markers
    file->writeBlockIdentifier("graphWMarkersX");
    saveMarkers(file, QwtPlot::xBottom);

    file->writeBlockIdentifier("graphWMarkersY");
    saveMarkers(file, QwtPlot::yLeft);

    file->writeBlockIdentifier("graphWMarkersYRight");
    saveMarkers(file, QwtPlot::yRight);

    // axes
    file->writeBlockIdentifier("graphWAxisRangeV2");
    *file << (quint32)QwtPlot::axisCnt;
    for(size_t i = 0; i < QwtPlot::axisCnt; ++i)
    {
        const QwtScaleDiv div = axisScaleDiv(i);
        *file << div.lowerBound();
        *file << div.upperBound();
    }
}
Пример #2
0
void StylesPlugin::setColors()
{
    if (getSystemColors()){
        QApplication::setPalette(*m_savePalette, true);
    }else{
        QApplication::setPalette(QPalette(QColor(getBtnColor()), QColor(getBgColor())), true);
    }
}
Пример #3
0
void Button::draw() {
  if (_active) {
    _drawLabel(getLabel(), getFgActive(), getBgActive());
  } else if (_pressed) {
    _drawLabel(getLabel(), getFgPressed(), getBgPressed());
  } else {
    _drawLabel(getLabel(), getFgColor(), getBgColor());    
  }
}
Пример #4
0
void ImageView::onPaint(PaintEvent& ev)
{
  Graphics* g = ev.getGraphics();
  gfx::Rect bounds = getClientBounds();
  gfx::Rect icon;
  getTextIconInfo(NULL, NULL, &icon, getAlign(), m_bmp->w, m_bmp->h);

  g->fillRect(getBgColor(), bounds);
  g->blit(m_bmp, 0, 0, icon.x, icon.y, icon.w, icon.h);
}
Пример #5
0
void ImageView::onPaint(PaintEvent& ev)
{
  Graphics* g = ev.getGraphics();
  gfx::Rect bounds = getClientBounds();
  gfx::Rect icon;
  getTextIconInfo(NULL, NULL, &icon, getAlign(),
    m_sur->width(), m_sur->height());

  g->fillRect(getBgColor(), bounds);
  g->drawRgbaSurface(m_sur, icon.x, icon.y);
}
Пример #6
0
void ImageView::onPaint(PaintEvent& ev)
{
  struct jrect box, text, icon;

  jwidget_get_texticon_info(this, &box, &text, &icon,
                            getAlign(), m_bmp->w, m_bmp->h);

  jdraw_rectexclude(rc, &icon, getBgColor());

  blit(m_bmp, ji_screen, 0, 0,
       icon.x1, icon.y1, jrect_w(&icon), jrect_h(&icon));
}
Пример #7
0
//-----------------------------------------------------------------------------
// Purpose: Label paint functions - take into account current highligh status
//-----------------------------------------------------------------------------
void CLabelHeader::paintBackground()
{
	Color oldBg;
	getBgColor(oldBg);

	if (gViewPort->GetScoreBoard()->m_iHighlightRow == _row)
	{
		setBgColor(134, 91, 19, 0);
	}

	Panel::paintBackground();

	setBgColor(oldBg);
}
Пример #8
0
void ColorButton::onPaint(PaintEvent& ev) // TODO use "ev.getGraphics()"
{
  struct jrect box, text, icon;
  jwidget_get_texticon_info(this, &box, &text, &icon, 0, 0, 0);

  int bg = getBgColor();
  if (bg < 0) bg = ji_color_face();
  jdraw_rectfill(this->rc, bg);

  Color color;

  // When the button is pushed, show the negative
  if (isSelected()) {
    color = Color::fromRgb(255-m_color.getRed(),
			   255-m_color.getGreen(),
			   255-m_color.getBlue());
  }
  // When the button is not pressed, show the real color
  else
    color = this->m_color;

  draw_color_button
    (ji_screen,
     this->getBounds(),
     true, true, true, true,
     true, true, true, true,
     this->m_imgtype,
     color,
     this->hasMouseOver(), false);

  // Draw text
  std::string str = m_color.toFormalString(this->m_imgtype, false);

  setTextQuiet(str.c_str());
  jwidget_get_texticon_info(this, &box, &text, &icon, 0, 0, 0);
  
  int textcolor = makecol(255, 255, 255);
  if (color.isValid())
    textcolor = color_utils::blackandwhite_neg(color.getRed(), color.getGreen(), color.getBlue());

  jdraw_text(ji_screen, getFont(), getText(), text.x1, text.y1,
	     textcolor, -1, false, jguiscale());
}
Пример #9
0
void LineWrapper::setColors() {
    data[Background] = getBgColor(data[Name]);
    data[Colour] = getTxtColor(data[Name]);
}
Пример #10
0
void MMSWindowClass::setAttributesFromTAFF(MMSTaffFile *tafff, string *path, bool reset_paths) {
    MMSFBColor color;

    if ((reset_paths)&&(path)&&(*path!="")) {
    	// unset my paths
    	unsetBgImagePath();
    }

	startTAFFScan
	{
        switch (attrid) {
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_alignment:
            setAlignment(getAlignmentFromString(attrval_str));
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_dx:
            setDx(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_dy:
            setDy(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_w:
            setWidth(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_h:
            setHeight(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgcolor:
            setBgColor(MMSFBColor((unsigned int)attrval_int));
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgcolor_a:
			color.a = color.r = color.g = color.b = 0;
            if (isBgColor()) getBgColor(color);
            color.a = attrval_int;
            setBgColor(color);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgcolor_r:
			color.a = color.r = color.g = color.b = 0;
            if (isBgColor()) getBgColor(color);
            color.r = attrval_int;
            setBgColor(color);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgcolor_g:
			color.a = color.r = color.g = color.b = 0;
            if (isBgColor()) getBgColor(color);
            color.g = attrval_int;
            setBgColor(color);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgcolor_b:
			color.a = color.r = color.g = color.b = 0;
            if (isBgColor()) getBgColor(color);
            color.b = attrval_int;
            setBgColor(color);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgimage:
            if (*attrval_str)
                setBgImagePath("");
            else
                setBgImagePath((path)?*path:"");
            setBgImageName(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgimage_path:
            if (*attrval_str)
                setBgImagePath(attrval_str);
            else
                setBgImagePath((path)?*path:"");
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgimage_name:
            setBgImageName(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_opacity:
            setOpacity(attrval_int);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_fadein:
            setFadeIn((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_fadeout:
            setFadeOut((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_debug:
            setDebug((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_margin:
            setMargin(attrval_int);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_up_arrow:
            setUpArrow(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_down_arrow:
            setDownArrow(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_left_arrow:
            setLeftArrow(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_right_arrow:
            setRightArrow(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_navigate_up:
            setNavigateUp(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_navigate_down:
            setNavigateDown(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_navigate_left:
            setNavigateLeft(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_navigate_right:
            setNavigateRight(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_own_surface:
#ifdef __HAVE_DIRECTFB__
			if(attrval_int) {
				MMSConfigData config;
				if(config.getBackend() == MMSFB_BE_DFB) {
					cerr << "Warning: DirectFB backend does not support own_surface=true (ignored)" << endl;
					break;
				}
			}
#endif
            setOwnSurface((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_movein:
            setMoveIn(getDirectionFromString(attrval_str));
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_moveout:
            setMoveOut(getDirectionFromString(attrval_str));
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_modal:
            setModal((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_static_zorder:
            setStaticZOrder((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_always_on_top:
            setAlwaysOnTop((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_focusable:
            setFocusable((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_backbuffer:
            setBackBuffer((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_initial_load:
            setInitialLoad((attrval_int) ? true : false);
            break;
		}
	}
	endTAFFScan

    if ((reset_paths)&&(path)&&(*path!="")) {
    	// set my paths
    	if (!isBgImagePath())
    		setBgImagePath(*path);
    }
}
Пример #11
0
ColorBar::ColorBar(int align)
  : Box(align)
  , m_paletteButton("Edit Palette", JI_BUTTON)
  , m_paletteView(false)
  , m_fgColor(Color::fromIndex(15), IMAGE_INDEXED)
  , m_bgColor(Color::fromIndex(0), IMAGE_INDEXED)
  , m_lock(false)
{
  setBorder(gfx::Border(1*jguiscale()));
  child_spacing = 1*jguiscale();

  m_paletteView.setBoxSize(6*jguiscale());
  m_paletteView.setColumns(4);
  m_fgColor.setPreferredSize(0, m_fgColor.getPreferredSize().h);
  m_bgColor.setPreferredSize(0, m_bgColor.getPreferredSize().h);

  m_scrollableView.attachToView(&m_paletteView);
  int w = (m_scrollableView.getBorder().getSize().w +
           m_scrollableView.getViewport()->getBorder().getSize().w +
           m_paletteView.getPreferredSize().w +
           getTheme()->scrollbar_size);

  jwidget_set_min_size(&m_scrollableView, w, 0);

  m_scrollableView.setExpansive(true);

  addChild(&m_paletteButton);
  addChild(&m_scrollableView);
  addChild(&m_fgColor);
  addChild(&m_bgColor);

  this->border_width.l = 2*jguiscale();
  this->border_width.t = 2*jguiscale();
  this->border_width.r = 2*jguiscale();
  this->border_width.b = 2*jguiscale();
  this->child_spacing = 2*jguiscale();

  m_paletteView.IndexChange.connect(&ColorBar::onPaletteIndexChange, this);
  m_fgColor.Change.connect(&ColorBar::onFgColorButtonChange, this);
  m_bgColor.Change.connect(&ColorBar::onBgColorButtonChange, this);

  // Set background color reading its value from the configuration.
  setBgColor(get_config_color("ColorBar", "BG", getBgColor()));

  // Clear the selection of the BG color in the palette.
  m_paletteView.clearSelection();

  // Set foreground color reading its value from the configuration.
  setFgColor(get_config_color("ColorBar", "FG", getFgColor()));

  // Change color-bar background color (not ColorBar::setBgColor)
  Widget::setBgColor(((SkinTheme*)getTheme())->get_tab_selected_face_color());
  m_paletteView.setBgColor(((SkinTheme*)getTheme())->get_tab_selected_face_color());

  // Change labels foreground color
  setup_mini_look(&m_paletteButton);
  m_paletteButton.setFont(((SkinTheme*)getTheme())->getMiniFont());
  m_paletteButton.Click.connect(Bind<void>(&ColorBar::onPaletteButtonClick, this));

  setDoubleBuffered(true);

  onColorButtonChange(getFgColor());
}
Пример #12
0
ColorBar::~ColorBar()
{
  set_config_color("ColorBar", "FG", getFgColor());
  set_config_color("ColorBar", "BG", getBgColor());
}
/*! Draw the statistics lines.
*/
void SimpleStatisticsForeground::draw(DrawEnv *pEnv, Viewport *pPort)
{
    if(getActive() == false)
        return;

    if(_face == 0)
        initText(getFamily(), getSize());

    if ((getCollector() == NULL) || 
        (!getCollector()->getNumOfElems() && !getMFElementIDs()->size()))
        return; // nothing to do

    Real32  pw = Real32(pPort->getPixelWidth ());
    Real32  ph = Real32(pPort->getPixelHeight());

    if(pw < 1 || ph < 1)
        return;

    glPushAttrib(GL_LIGHTING_BIT | GL_POLYGON_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_COLOR_MATERIAL);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);

    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();

    // Set viewport. We want to map one unit to one pixel on the
    // screen. Some sources in the internet say that we should
    // add an offset of -0.375 to prevent rounding errors. Don't
    // know if that is true, but it seems to work.
    glOrtho(0 - 0.375, pw - 0.375, 0 - 0.375, ph - 0.375, 0, 1);

    // retrieve text
    std::vector < std::string > stat;

    StatCollector *col = this->getCollector();
    StatElem      *el;

    if(getMFElementIDs()->size() != 0)
    {
        for(UInt32 i = 0; i < getMFElementIDs()->size(); ++i)
        {
            Int32 id(getElementIDs(i));
            el = ((id >= 0) ? col->getElem(id) : 0);

            stat.resize(stat.size() + 1);
            std::vector < std::string >::iterator str = stat.end() - 1;

            const char  *format = NULL;
            if(i < getMFFormats()->size() && getFormats(i).length())
            {
                format = getFormats(i).c_str();
            }

            if (el)
                el->putToString(*str, format);
            else
                *str = format;
        }
    }
    else    // fallback, show all elements
    {
        for(UInt32 i = 0; i < col->getNumOfElems(); ++i)
        {
            el = col->getElem(i, false);
            if(el)
            {
                std::string desc(el->getDesc()->getName()), eltext;

                el->putToString(eltext);
                desc = desc + " : " + eltext;

                stat.resize(stat.size() + 1);
                std::vector < std::string >::iterator str = stat.end() - 1;
                *str = desc;
            }
        }
    }

    TextLayoutParam layoutParam;
    layoutParam.spacing = 1.1f;
    layoutParam.majorAlignment = TextLayoutParam::ALIGN_BEGIN;
    layoutParam.minorAlignment = TextLayoutParam::ALIGN_BEGIN;

    TextLayoutResult layoutResult;
    _face->layout(stat, layoutParam, layoutResult);

    Real32 scale = 1 / _face->getScale();
    Real32 size = _face->getParam().size;
    Real32 textWidth = layoutResult.textBounds.x() * scale + size + getTextMargin().x() * 2.0f;
    Real32 textHeight = layoutResult.textBounds.y() * scale + size + getTextMargin().y() * 2.0f;

    // Let's do some simple form of layout management
    Real32 orthoX = 0, orthoY = ph;

    switch ( getHorizontalAlign() )
    {
        case Right:
            orthoX = pw - textWidth;
            break;
        case Middle:
            orthoX = (pw - textWidth) * 0.5;
            break;
        case Left:
        default:
            break;
    }

    switch ( getVerticalAlign() )
    {
        case Bottom:
            orthoY = textHeight;
            break;
        case Center:
            orthoY = (ph - textHeight) * 0.5 + textHeight;
            break;
        case Top:
        default:
            break;
    }

    glTranslatef(orthoX, orthoY, 0.0);

    // draw background
    glColor4fv(static_cast<const GLfloat *>(getBgColor().getValuesRGBA()));
    glBegin(GL_QUADS);
        glVertex2f(0, -textHeight);
        glVertex2f(textWidth, -textHeight);
        glVertex2f(textWidth, 0);
        glVertex2f(0, 0);
    glEnd();

    // draw border
    if(getBorderColor().alpha() >= 0.0f)
    {
        glColor4fv(
            static_cast<const GLfloat *>(getBorderColor().getValuesRGBA()));

        glBegin(GL_LINE_LOOP);
            glVertex2f(getBorderOffset().x(), 
                       -textHeight + 1 + getBorderOffset().y());
            glVertex2f(textWidth - 1 - getBorderOffset().x(), 
                       -textHeight + 1 + getBorderOffset().y());
            glVertex2f(textWidth - 1 - getBorderOffset().x(), 
                       -1 - getBorderOffset().y());
            glVertex2f(getBorderOffset().x(), -1 - getBorderOffset().y());
        glEnd();
    }

    glTranslatef( 0.5 * size + getTextMargin().x(), 
                 -0.5 * size - getTextMargin().y(), 
                  0.0);

    _texchunk   ->activate(pEnv);
    _texenvchunk->activate(pEnv);

    // draw text shadow
    glColor4fv(static_cast<const GLfloat *>(getShadowColor().getValuesRGBA()));
    glPushMatrix();
    glTranslatef(getShadowOffset().x(), getShadowOffset().y(), 0);
    glScalef(scale, scale, 1);
    _face->drawCharacters(layoutResult);

    // draw text
    glColor4fv(static_cast<const GLfloat *>(getColor().getValuesRGBA()));
    glPopMatrix();
    glScalef(scale, scale, 1);
    _face->drawCharacters(layoutResult);

    _texchunk   ->deactivate(pEnv);
    _texenvchunk->deactivate(pEnv);

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();

    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();

    glPopAttrib();
}
Пример #14
0
void StatusBar::onPaint(ui::PaintEvent& ev)
{
  SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
  ui::Color textColor = theme->getColorById(kStatusBarText);
  Rect rc = getClientBounds();
  Graphics* g = ev.getGraphics();

  g->fillRect(getBgColor(), rc);

  rc.shrink(Border(2, 1, 2, 2)*jguiscale());

  int x = rc.x + 4*jguiscale();

  // Color
  if (m_state == SHOW_COLOR) {
    // Draw eyedropper icon
    BITMAP* icon = theme->get_toolicon("eyedropper");
    if (icon) {
      g->drawAlphaBitmap(icon, x, rc.y + rc.h/2 - icon->h/2);
      x += icon->w + 4*jguiscale();
    }

    // Draw color
    draw_color_button(g, gfx::Rect(x, rc.y, 32*jguiscale(), rc.h),
      true, true, true, true,
      true, true, true, true,
      app_get_current_pixel_format(), m_color,
      false, false);

    x += (32+4)*jguiscale();

    // Draw color description
    std::string str = m_color.toHumanReadableString(app_get_current_pixel_format(),
      app::Color::LongHumanReadableString);
    if (m_alpha < 255) {
      char buf[512];
      usprintf(buf, ", Alpha %d", m_alpha);
      str += buf;
    }

    g->drawString(str, textColor, ColorNone, false,
      gfx::Point(x, rc.y + rc.h/2 - text_height(getFont())/2));

    x += ji_font_text_len(getFont(), str.c_str()) + 4*jguiscale();
  }

  // Show tool
  if (m_state == SHOW_TOOL) {
    // Draw eyedropper icon
    BITMAP* icon = theme->get_toolicon(m_tool->getId().c_str());
    if (icon) {
      g->drawAlphaBitmap(icon, x, rc.y + rc.h/2 - icon->h/2);
      x += icon->w + 4*jguiscale();
    }
  }

  // Status bar text
  if (getTextLength() > 0) {
    g->drawString(getText(), textColor, ColorNone, false,
      gfx::Point(x, rc.y + rc.h/2 - text_height(getFont())/2));

    x += ji_font_text_len(getFont(), getText().c_str()) + 4*jguiscale();
  }

  // Draw progress bar
  if (!m_progress.empty()) {
    int width = 64;
    int x = rc.x2() - (width+4);

    for (ProgressList::iterator it = m_progress.begin(); it != m_progress.end(); ++it) {
      Progress* progress = *it;

      theme->paintProgressBar(g,
        gfx::Rect(x, rc.y, width, rc.h),
        progress->getPos());

      x -= width+4;
    }
  }

  updateSubwidgetsVisibility();
}
Пример #15
0
bool Entity::canMoveAbsolute(Point2 p, Level* level, bool force) {
    
    
    if (level->tileAt(p)->doesNotHaveAnyOfFlags(getSolidity())) {
        bool block = false;
        for (Entity* e : level->entityList) {
            if (e->uniqueId == uniqueId) {
                continue;
            }
            if ((bool)(e->getSolidity() & getSolidity())) {
                if (e->pos == p) {
                    block = true;
                    break;
                }
            }
        }
        if (!block || force) {
            if(distanceSquared(pos, p) > 1){
                Animator::renderFlash(pos, level, {defaultIcon, 'O', 'o', '.'}, 1, fgColor, getBgColor(0, pos, level));
                Point2 pp = pos;
                pos = p;
                //level->currentWorld->menuGame->viewUpdate();
                level->currentWorld->menuGame->render(level->currentWorld->worldTime);
                Animator::renderFlash(pos, level, {'.', 'o', 'O', defaultIcon}, 1, fgColor, getBgColor(0, pos, level));
                pos = pp;
            }
            return true;
        }
    }
    return false;
}