예제 #1
0
void CtrlrMenuBarLookAndFeel::drawMenuBarItem (Graphics &g, int width, int height, int itemIndex, const String &itemText, bool isMouseOverItem, bool isMenuOpen, bool isMouseOverBar, MenuBarComponent &menuBar)
{
	if (itemText.isEmpty())
		return;

	Colour textColour	= getColour (Ids::ctrlrMenuBarTextColour);
	Font textFont		= getMenuBarFont (menuBar, itemIndex, itemText);

	if (!menuBar.isEnabled())
	{
		textColour = textColour.withMultipliedAlpha (0.5f);
	}
	else if (isMouseOverItem && !isMenuOpen)
	{
		textColour = getColour (Ids::ctrlrMenuBarHighlightedTextColour);
		drawSelectionRectangle (g, width, height, getColour (Ids::ctrlrMenuBarHighlightColour).darker(0.3f));
	}
	else if (isMouseOverItem && isMenuOpen)
	{
		textColour = getColour (Ids::ctrlrMenuBarHighlightedTextColour);
		drawSelectionRectangle (g, width, height, getColour (Ids::ctrlrMenuBarHighlightColour));
	}
	else if (isMenuOpen)
	{
		textColour = getColour (Ids::ctrlrMenuBarHighlightedTextColour);
		drawSelectionRectangle (g, width, height, getColour (Ids::ctrlrMenuBarHighlightColour));
	}

	g.setColour (textColour);
	g.setFont (textFont);
	g.drawFittedText (itemText, 0, 0, width, height, Justification::centred, 1);
}
예제 #2
0
파일: map.c 프로젝트: Gilles86/afni
/*****
* Name: 		_XmHTMLDrawImagemapSelection
* Return Type: 	void
* Description: 	draws a bounding box around each area in an imagemap
* In: 
*	html:		XmHTMLWidget id
*	image:		image for which to paint bounding boxes
* Returns:
*	nothing
*****/
void
_XmHTMLDrawImagemapSelection(XmHTMLWidget html, XmHTMLImage *image)
{
	XmHTMLImageMap *map;
	int xs, ys;
	mapArea *area;

	if((map = _XmHTMLGetImagemap(html, image->map_url)) == NULL)
		return;

	/* map coordinates to upperleft corner of image */
	xs = html->html.scroll_x - image->owner->x;
	ys = html->html.scroll_y - image->owner->y;

	area = map->areas;

	while(area)
	{
		switch(area->shape)
		{
			case MAP_RECT:
				drawSelectionRectangle(html, image, area);
				break;
			case MAP_CIRCLE:
				drawSelectionArc(html, image, area);
				break;
			case MAP_POLY:
				drawSelectionPolygon(html, image, area);
				break;
			default:
				break;
		}
		area = area->next;
	}
}
예제 #3
0
void cOutput::drawFrameUnitSelection(Uint32 ticks)
{
    drawMap();
    drawEntities();
    if(pUnitSelectionInputs->doDrawRect){ drawSelectionRectangle(&(pUnitSelectionInputs->DrawRect)); }

    if(selectedNumber > 0)
    {
        drawUnitHud(ticks);
    }
    else if(selectedBuildings > 0)
    {
        ///TODO
        //drawBuildingHud();
    }

    if(drawAoe != -1)
    {
        applyDrawAoe((pMousePosition->X)/TILE_WIDTH,(pMousePosition->Y)/TILE_HEIGHT,drawAoe);
    }
    // Draw the cursor
    cSurface::Draw(mScreen,cursorGraphic[pUnitSelectionInputs->cursorType],pMousePosition->X+CURSOR_OFFSET_X,pMousePosition->Y+CURSOR_OFFSET_Y);

    //Show the new screen
    SDL_Flip(mScreen);
}
void CtrlrPanelResourceEditor::paintRowBackground (Graphics& g, int rowNumber, int width, int height, bool rowIsSelected)
{
	if (rowIsSelected)
	{
		drawSelectionRectangle (g, width, height);
	}
}
예제 #5
0
void CtrlrValueTreeEditorItem::paintItem (Graphics &g, int width, int height)
{
	Image icon = provider.getIconForItem (treeToEdit);
	if (isSelected())
	{
		drawSelectionRectangle (g,width,height);
	}

	g.setColour (Colours::black);

	AttributedString as = provider.getDisplayString(treeToEdit);
	as.setJustification (Justification (Justification::centredLeft));
	as.draw (g, Rectangle <float> (24.0, 0.0, width - 24.0, height));
	g.drawImageWithin (icon, 4, 0, 16, height, RectanglePlacement (RectanglePlacement::centred));
}
예제 #6
0
void RectangleView::
        draw()
{
    if (visible)
        drawSelectionRectangle();
}
예제 #7
0
void ZLTextView::drawTextLine(const ZLTextLineInfo &info, int y, size_t from, size_t to) {
	const ZLTextParagraphCursor &paragraph = info.RealStart.paragraphCursor();

	const ZLTextElementIterator fromIt = myTextElementMap.begin() + from;
	const ZLTextElementIterator toIt = myTextElementMap.begin() + to;

	if (!mySelectionModel.isEmpty() && (from != to)) {
		const std::vector<ZLTextSelectionModel::Range> &ranges = mySelectionModel.ranges();

		if (!ranges.empty()) {
			RangeVector::const_iterator rt = ranges.end();
			const int top = y + 1;
			int bottom = y + info.Height + info.Descent;
			if (strongFindRange(ranges, info.End) != ranges.end()) {
				bottom += info.VSpaceAfter;
			}
			int left = viewWidth() + lineStartMargin() - 1;
			int right = lineStartMargin();
			const int baseRTL = myStyle.baseBidiLevel() % 2;

			for (ZLTextElementIterator it = fromIt; it < toIt; ++it) {
				const ZLTextElementArea &area = *it;
				RangeVector::const_iterator rt2 = findRange(ranges, area);
				if (rt2 == rt) {
					if (rt != ranges.end()) {
						const bool mainDir = area.BidiLevel % 2 == baseRTL;
						int r = area.XEnd;
						const ZLTextSelectionModel::BoundElement &bound =
							mainDir ? rt->second : rt->first;
						if (bound.ElementIndex == area.ElementIndex) {
							const ZLTextElement &element = paragraph[area.ElementIndex];
							if (element.kind() == ZLTextElement::WORD_ELEMENT) {
								r = areaBound(paragraph, area, bound.CharIndex, mainDir);
							}
						}
						right = std::max(right, r);
					}
				} else {
					if (rt != ranges.end()) {
						drawSelectionRectangle(left, top, right, bottom);
						left = viewWidth() + lineStartMargin() - 1;
						right = lineStartMargin();
					}
					rt = rt2;
					if (rt != ranges.end()) {
						if ((it == fromIt) &&
								(info.StartBidiLevel % 2 == baseRTL) &&
								strongContains(*rt, info.Start)) {
							left = lineStartMargin();
						}

						const bool mainDir = area.BidiLevel % 2 == baseRTL;

						int l = area.XStart - 1;
						int r = area.XEnd;

						const ZLTextSelectionModel::BoundElement &rightBound =
							mainDir ? rt->second : rt->first;
						const ZLTextSelectionModel::BoundElement &leftBound =
							mainDir ? rt->first : rt->second;
						if (paragraph[area.ElementIndex].kind() == ZLTextElement::WORD_ELEMENT) {
							if (rightBound.ElementIndex == area.ElementIndex) {
								r = areaBound(paragraph, area, rightBound.CharIndex, mainDir);
							}
							if (leftBound.ElementIndex == area.ElementIndex) {
								l = areaBound(paragraph, area, leftBound.CharIndex, mainDir);
							}
						}

						left = std::min(left, l);
						right = std::max(right, r);
					}
				}
			}
			if (rt != ranges.end()) {
				if ((paragraph.index() < (size_t)rt->second.ParagraphIndex) &&
						strongContains(*rt, info.End)) {
					right = viewWidth() + lineStartMargin() - 1;
				}
				drawSelectionRectangle(left, top, right, bottom);
			}
		}
	}

	y = std::min(y + info.Height, topMargin() + textAreaHeight());
	int x = lineStartMargin();
	if (!info.NodeInfo.isNull()) {
		drawTreeLines(*info.NodeInfo, x, y, info.Height, info.Descent + info.VSpaceAfter);
	}
	ZLTextElementIterator it = fromIt;
	const int endElementIndex = info.End.elementIndex();
	for (; (it != toIt) && (it->ElementIndex != endElementIndex); ++it) {
		const ZLTextElement &element = paragraph[it->ElementIndex];
		ZLTextElement::Kind kind = element.kind();
	
		if ((kind == ZLTextElement::WORD_ELEMENT) || (kind == ZLTextElement::IMAGE_ELEMENT)) {
			myStyle.setTextStyle(it->Style, it->BidiLevel);
			const int wx = myStyle.baseIsRtl() ? context().width() - it->XEnd : it->XStart;
			const int wy = it->YEnd - myStyle.elementDescent(element) - myStyle.textStyle()->verticalShift();
			if (kind == ZLTextElement::WORD_ELEMENT) {
				drawWord(wx, wy, (const ZLTextWord&)element, it->StartCharIndex, -1, false);
			} else {
				context().drawImage(wx, wy, *((const ZLTextImageElement&)element).image());
			}
		}
	}
	if (it != toIt) {
		myStyle.setTextStyle(it->Style, it->BidiLevel);
		int start = 0;
		if (info.Start.equalElementIndex(info.End)) {
			start = info.Start.charIndex();
		}
		int len = info.End.charIndex() - start;
		const ZLTextWord &word = (const ZLTextWord&)info.End.element();
		context().setColor(myStyle.textStyle()->color());
		const int x = myStyle.baseIsRtl() ? context().width() - it->XEnd : it->XStart;
		const int y = it->YEnd - myStyle.elementDescent(word) - myStyle.textStyle()->verticalShift();
		drawWord(x, y, word, start, len, it->AddHyphenationSign);
	}
}
예제 #8
0
void CtrlrMenuBarLookAndFeel::drawPopupMenuItem (Graphics &g, const Rectangle<int>& area, bool isSeparator, bool isActive, bool isHighlighted, bool isTicked, bool hasSubMenu, const String& text, const String& shortcutKeyText, const Drawable* icon, const Colour* textColourToUse)
{
	const float halfH = area.getHeight() * 0.5f;

    if (isSeparator)
    {
        const float separatorIndent = 5.5f;

        g.setColour (getColour (Ids::ctrlrMenuItemSeparatorColour));
		g.fillRect (separatorIndent, halfH, area.getWidth() - (separatorIndent*2), 1.25f);
    }
    else
    {
        Colour textColour (getColour (Ids::ctrlrMenuItemTextColour));

        if (isHighlighted)
        {
			drawSelectionRectangle (g, area.getWidth(), area.getHeight(), getColour (Ids::ctrlrMenuItemHighlightColour));
            g.setColour (getColour (Ids::ctrlrMenuItemHighlightedTextColour));
        }
        else
        {
            g.setColour (getColour (Ids::ctrlrMenuItemTextColour));
        }

        if (! isActive)
            g.setOpacity (0.3f);

        Font font (getPopupMenuFont());

        if (font.getHeight() > area.getHeight() / 1.3f)
            font.setHeight (area.getHeight() / 1.3f);

        g.setFont (font);

        const int leftBorder = (area.getHeight() * 5) / 4;
        const int rightBorder = 4;

        if (icon != nullptr)
        {
			icon->drawWithin (g, Rectangle<float> (2.0f, 1.0f, leftBorder - 4.0f, area.getHeight() - 2.0f), RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f);
        }
        else if (isTicked)
        {
            const Path tick (getTickShape (1.0f));
            const float th = font.getAscent();
            const float ty = halfH - th * 0.5f;

            g.fillPath (tick, tick.getTransformToScaleToFit (2.0f, ty, (float) (leftBorder - 4),
                                                             th, true));
        }

        g.drawFittedText (text,
							leftBorder, 0, area.getWidth() - (leftBorder + rightBorder), area.getHeight(),
                          Justification::centredLeft, 1);

        if (shortcutKeyText.isNotEmpty())
        {
            Font f2 (font);
            f2.setHeight (f2.getHeight() * 0.75f);
            f2.setHorizontalScale (0.95f);
            g.setFont (f2);

            g.drawText (shortcutKeyText,
                        leftBorder, 0, area.getWidth() - (leftBorder + rightBorder + 4), area.getHeight(),
                        Justification::centredRight,
                        true);
        }

        if (hasSubMenu)
        {
            const float arrowH = 0.6f * getPopupMenuFont().getAscent();
            const float x = area.getWidth() - area.getHeight() * 0.6f;

            Path p;
            p.addTriangle (x, halfH - arrowH * 0.5f,
                           x, halfH + arrowH * 0.5f,
                           x + arrowH * 0.6f, halfH);

            g.fillPath (p);
        }
    }
}
예제 #9
0
void ZLTextView::drawString(int x, int y, const char *str, int len, const ZLTextWord::Mark *mark, int shift, bool rtl) {
    context().setColor(myStyle.textStyle()->color());
    if (mark == 0) {
        context().drawString(x, y, str, len, rtl);
    } else {
        if (rtl) {
            x += context().stringWidth(str, len, rtl);
        }
        int pos = 0;
        for (; (mark != 0) && (pos < len); mark = mark->next()) {
            int markStart = mark->start() - shift;
            int markLen = mark->length();

            if (markStart < pos) {
                markLen += markStart - pos;
                markStart = pos;
            }

            if (markLen <= 0) {
                continue;
            }

            if (markStart > pos) {
                int endPos = std::min(markStart, len);
                if (rtl) {
                    x -= context().stringWidth(str + pos, endPos - pos, rtl);
                }
                context().drawString(x, y, str + pos, endPos - pos, rtl);
                if (!rtl) {
                    x += context().stringWidth(str + pos, endPos - pos, rtl);
                }
            }
            if (markStart < len) {
                context().setColor(ZLTextStyleCollection::instance().baseStyle().SelectedTextColorOption.value());
                {
                    int endPos = std::min(markStart + markLen, len);
                    int stringHeight = context().stringHeight();
                    int stringWidth = context().stringWidth(str + markStart, endPos - markStart, rtl);
                    if (rtl) {
                        x -= stringWidth;
                    }
                    // John: TODO adjust the y and stringHeight.
                    drawSelectionRectangle(x, y - stringHeight, x + stringWidth, y + stringHeight / 2);
                    context().drawString(x, y, str + markStart, endPos - markStart, rtl);
                    if (!rtl) {
                        x += stringWidth;
                    }
                }
                context().setColor(myStyle.textStyle()->color());
            }
            pos = markStart + markLen;
        }

        if (pos < len) {
            if (rtl) {
                x -= context().stringWidth(str + pos, len - pos, rtl);
            }
            context().drawString(x, y, str + pos, len - pos, rtl);
        }
    }
}