Example #1
0
SearchBar::SearchBar(QWidget *parent) : QWidget(parent)
{
    widget.setupUi(this);
    connect(widget.closeButton, SIGNAL(clicked()), this, SLOT(hide()));
    connect(widget.searchTextEdit, SIGNAL(textChanged(QString)), this, SIGNAL(searchCriteriaChanged()));
    connect(widget.findPreviousButton, SIGNAL(clicked()), this, SIGNAL(findPrevious()));
    connect(widget.findNextButton, SIGNAL(clicked()), this, SIGNAL(findNext()));

    connect(this, SIGNAL(searchCriteriaChanged()), this, SLOT(clearBackgroundColor()));

    QMenu *optionsMenu = new QMenu(widget.optionsButton);
    widget.optionsButton->setMenu(optionsMenu);

    m_matchCaseMenuEntry = optionsMenu->addAction(tr("Match case"));
    m_matchCaseMenuEntry->setCheckable(true);
    m_matchCaseMenuEntry->setChecked(true);
    connect(m_matchCaseMenuEntry, SIGNAL(toggled(bool)), this, SIGNAL(searchCriteriaChanged()));


    m_useRegularExpressionMenuEntry = optionsMenu->addAction(tr("Regular expression"));
    m_useRegularExpressionMenuEntry->setCheckable(true);
    connect(m_useRegularExpressionMenuEntry, SIGNAL(toggled(bool)), this, SIGNAL(searchCriteriaChanged()));

    m_highlightMatchesMenuEntry = optionsMenu->addAction(tr("Higlight all matches"));
    m_highlightMatchesMenuEntry->setCheckable(true);
    m_highlightMatchesMenuEntry->setChecked(true);
    connect(m_highlightMatchesMenuEntry, SIGNAL(toggled(bool)), this, SIGNAL(highlightMatchesChanged(bool)));
}
Example #2
0
File: main.cpp Project: jhasse/jngl
void setBackgroundColor(const unsigned char red, const unsigned char green, const unsigned char blue) {
    pWindow.ThrowIfNull();
    bgRed = red / 255.0f;
    bgGreen = green / 255.0f;
    bgBlue = blue / 255.0f;
    clearBackgroundColor();
    glClear(GL_COLOR_BUFFER_BIT);
}
Example #3
0
ParagraphDecorations::ParagraphDecorations(QWidget *parent)
    : QWidget(parent)
{
    widget.setupUi(this);

    connect(widget.backgroundColor, SIGNAL(changed(QColor)), this, SLOT(slotBackgroundColorChanged()));
    connect(widget.resetBackgroundColor, SIGNAL(clicked()), this, SLOT(clearBackgroundColor()));
}
ParagraphDecorations::ParagraphDecorations(QWidget* parent)
        : QWidget(parent)
        , widget(new Ui::ParagraphDecorations())
{
    widget->setupUi(this);

    connect(widget->backgroundColor, SIGNAL(changed(const QColor&)), this, SLOT(slotBackgroundColorChanged()));
    connect(widget->resetBackgroundColor, SIGNAL(clicked()), this, SLOT(clearBackgroundColor()));
}
void ParagraphDecorations::setDisplay(KoParagraphStyle *style)
{
    m_backgroundColorChanged = false;
    m_backgroundColorReset = style->background().style() == Qt::NoBrush;
    if (m_backgroundColorReset) {
        clearBackgroundColor();
    } else {
        widget->backgroundColor->setColor(style->background().color());
    }
}
Example #6
0
int eInput::event(int event, void *data, void *data2)
{
	switch (event)
	{
	case evtPaint:
	{
		gPainter &painter = *(gPainter*)data2;
		ePtr<eWindowStyle> style;
		
		getStyle(style);
		
		eWidget::event(event, data, data2);
		
		ePtr<eTextPara> para = new eTextPara(eRect(0, 0, size().width(), size().height()));
		
		std::string text;
		int cursor = -1;
		
		if (m_content)
			m_content->getDisplay(text, cursor);
		
		eDebug("cursor is %d", cursor);
		para->setFont(m_font);
		para->renderString(text.empty()?0:text.c_str(), 0);
		int glyphs = para->size();
		
		if (m_have_focus)
		{
			if (m_mode && cursor < glyphs)
			{
					/* in overwrite mode, when not at end of line, invert the current cursor position. */
				para->setGlyphFlag(cursor, GS_INVERT);
				eRect bbox = para->getGlyphBBox(cursor);
				bbox = eRect(bbox.left(), 0, bbox.width(), size().height());
				painter.fill(bbox);
			} else
			{
					/* otherwise, insert small cursor */
				eRect bbox;
				if (cursor < glyphs)
				{
					bbox = para->getGlyphBBox(cursor);
					bbox = eRect(bbox.left()-1, 0, 2, size().height());
				} else if (cursor)
				{
					bbox = para->getGlyphBBox(cursor - 1);
					bbox = eRect(bbox.right(), 0, 2, size().height());
				} else
				{
					bbox = eRect(0, 0, 2, size().height());
				}
				painter.fill(bbox);
			}
		}
		
		painter.renderPara(para, ePoint(0, 0));
		
		return 0;
	}
	case evtAction:
		if (isVisible())
		{
			if ((long)data == ASCII_ACTIONS)
			{
				if ((long)data2 == gotAsciiCode)
				{
					if (m_content)
					{
						extern int getPrevAsciiCode();  // defined in enigma.cpp
						return m_content->haveKey(getPrevAsciiCode(), m_mode);
					}
				}
			}
			else if ((long)data == INPUT_ACTIONS)
			{
				switch((long)data2)
				{
				case moveLeft:
					if (m_content)
						m_content->moveCursor(eInputContent::dirLeft);
					break;
				case moveRight:
					if (m_content)
						m_content->moveCursor(eInputContent::dirRight);
					break;
				case moveHome:
					if (m_content)
						m_content->moveCursor(eInputContent::dirHome);
					break;
				case moveEnd:
					if (m_content)
						m_content->moveCursor(eInputContent::dirEnd);
					break;
				case deleteForward:
					if (m_content)
						m_content->deleteChar(eInputContent::deleteForward);
					break;
				case deleteBackward:
					if (m_content)
						m_content->deleteChar(eInputContent::deleteBackward);
					break;
				case toggleOverwrite:
					setOverwriteMode(!m_mode);
					break;
				case accept:
					changed();
					mayKillFocus();
				}
				return 1;
			}
		}
		return 0;
	case evtKey:
	{
		long key = (long)data;
		long flags = (long)data2;
		if (m_content && !(flags & 1)) // only make/repeat, no break
			return m_content->haveKey(key, m_mode);
		break;
	}
	case evtFocusGot:
	{
		eDebug("focus got in %p", this);
		ePtr<eActionMap> ptr;
		eActionMap::getInstance(ptr);
		ptr->bindAction("InputActions", 0, INPUT_ACTIONS, this);
		ptr->bindAction("AsciiActions", 0, ASCII_ACTIONS, this);
		m_have_focus = 1;
		eRCInput::getInstance()->setKeyboardMode(eRCInput::kmAscii);
			// fixme. we should use a style for this.
		setBackgroundColor(gRGB(64, 64, 128));
		invalidate();
		break;
	}
	case evtFocusLost:
	{
		eDebug("focus lostin %p", this);
		ePtr<eActionMap> ptr;
		eActionMap::getInstance(ptr);
		ptr->unbindAction(this, INPUT_ACTIONS);
		ptr->unbindAction(this, ASCII_ACTIONS);
		m_have_focus = 0;
		if (m_content)
			m_content->validate();
		eRCInput::getInstance()->setKeyboardMode(eRCInput::kmNone);
		clearBackgroundColor();
		invalidate();
		break;
	}
	default:
		break;
	}
	return eWidget::event(event, data, data2);
}