Ejemplo n.º 1
0
void KDirListBox::keyPressEvent( QKeyEvent *e )
{
  int index = 0;
  
  switch ( e->key() ) {
  case Key_Return: // fall through
  case Key_Enter:
      index = currentItem();
      if ( index == -1 )
          return;
    
      if ( isDir( index ) )
          select( index );
    
      break;
  case Key_Home:
      highlightItem( 0 );
      setTopCell( 0 );		  // somehow highlightItem() does NOT scroll!?
      break;
  case Key_End:
      index = QListBox::count() -1;
      if ( index >= 0 ) {
	  highlightItem( index ); // somehow highlightItem() does NOT scroll!?
	  setBottomItem( index );
      }
      break;
  default:  
      QListBox::keyPressEvent( e );
  }
}
Ejemplo n.º 2
0
static void
winGoto(rdWin *w, ulong p0, char *str)
{
	/* If this is a list,
	then it counts as a selection. Otherwise,  we just reflect it back to wily as a normal
	B3 event. */

	assert(w);
	assert(str);
	if (w->wintype == rdList) {
		rdItemRange r = itemNumber(w, p0, p0);
		if (r.first == -1) {
			DPRINT("Goto occurred outside range of items");
			return;		/* sigh */
		}
		highlightItem(w, r);
		user_listSelection(w,r);
		return;
	} else {
		if (rpc_goto(wilyq, w->id, str)) {
			DPRINT("could not send goto to wily");
		}
	}
	return;
}
Ejemplo n.º 3
0
LRESULT ModelTreeDialog::doTreeSelChanged(LPNMTREEVIEW notification)
{
	if (!m_clearing)
	{
		if (m_highlight)
		{
			highlightItem(notification->itemNew.hItem);
		}
		updateStatusText();
	}
	return 1;	// Ignored
}
Ejemplo n.º 4
0
static void
winExec(rdWin *w, char *cmd, char *arg)
{
	ulong p0, p1;
	/*
	 * Lots of options here:
	*	- B2 with "|<>" - reflect back to wily.
	*	- B2 cmd recognised by the reader routines - Del is about it. Execute
	*	  them ourselves.
	*	- B2 not recognised by the reader routines - pass them onto the user,
	*	  after first getting the position of the argument within the body, if
	*	 necessary.
	*	- B2B1 recognised by the reader routines - none spring to mind, but
	*	  I might add some. Execute them ourselves.
	*	- B2B1 not recognised - pass onto user.
	*/

	assert(w);
	assert(cmd);
	assert(arg);
	DPRINT("Command received...");
	DPRINT(cmd);
	if (!*cmd || strstr(cmd,"|<>")) {
		DPRINT("Reflecting command");
		winReflectCmd(w,cmd, arg);
		return;
	}
	if (rdBuiltin(w,cmd,arg) == 0) {
		DPRINT("command is reader builtin - handled");
		return;
	}
	if (rpc_addr(wilyq, w->id, ".", &p0, &p1)) {
		DPRINT("could not get address of dot");
		return;
	}

	if (w->wintype == rdList) {
		rdItemRange r = itemNumber(w, p0, p1);

		if (r.first == -1) {
			p0 = p1 = 0;
		} else {
			highlightItem(w, r);
			p0 = r.i0->p0;
			p1 = r.i1->p1;
		}
		user_cmdList(w,cmd,p0,p1,r,arg);
		return;
	}
	user_cmdArt(w, cmd, p0, p1, arg);
	return;
}
Ejemplo n.º 5
0
LRESULT ModelTreeDialog::doHighlightCheck(void)
{
	m_highlight = checkGet(IDC_HIGHLIGHT);
	if (m_highlight)
	{
		highlightItem(TreeView_GetSelection(m_hTreeView));
	}
	else
	{
		m_modelWindow->getModelViewer()->setHighlightPaths("");
	}
	TCUserDefaults::setBoolForKey(m_highlight, MODEL_TREE_HIGHLIGHT_KEY, false);
	return 0;
}
Ejemplo n.º 6
0
void SubprogramsCollectionDialog::updateValues()
{
	mUi->listWidget->clear();
	mUi->selectAllButton->hide();
	for (auto file : mValues.keys()) {
		mUi->listWidget->addItem(file);
		QListWidgetItem *item = mUi->listWidget->item(mUi->listWidget->count() - 1);
		item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
		item->setCheckState(mValues[file] ? Qt::Checked : Qt::Unchecked);
		highlightItem(item);
	}

	if (mValues.size() > 0) {
		mUi->selectAllButton->show();
	}
}
Ejemplo n.º 7
0
void DropDownList::drawItem(DC& dc, int y, size_t item) {
    if (y + item_size.height <= 0 || y >= dc.GetSize().y) return; // not visible
    // draw background
    dc.SetPen(*wxTRANSPARENT_PEN);
    if (item == selected_item) {
        if (itemEnabled(item)) {
            dc.SetBrush         (wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
            dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
        } else {
            dc.SetBrush         (wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
            dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
        }
        dc.DrawRectangle(marginW, y, (int)item_size.width, (int)item_size.height);
    } else if (!itemEnabled(item)) {
        // mix between foreground and background
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
    } else if (highlightItem(item)) {
        // mix a color between selection and window
        dc.SetBrush         (lerp(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT),
                                  wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), 0.75));
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
        dc.DrawRectangle(marginW, y, (int)item_size.width, (int)item_size.height);
    } else {
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
    }
    // draw text and icon
    drawIcon(dc, marginW, y, item, item == selected_item);
    dc.DrawText(capitalize(itemText(item)), marginW + (int)icon_size.width + 1, y + text_offset);
    // draw popup icon
    if (submenu(item)) {
        draw_menu_arrow(this, dc, RealRect(marginW, y, item_size.width, item_size.height), item == selected_item);
    }
    // draw line below
    if (lineBelow(item) && item != itemCount()) {
        dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
        dc.DrawLine(marginW, y + (int)item_size.height, marginW + (int)item_size.width, y + (int)item_size.height);
    }
}
Ejemplo n.º 8
0
void highlighter::check(const QString &text)
{
    items.clear();
    QStringList datal = text.split('\n', QString::SkipEmptyParts);

    // 第一轮:检查元素
    for (int i = 0; i < datal.count(); i++)
    {
        QString data = datal[i];

        int colon = data.indexOf(':');
        int equal = data.indexOf('=');
        bool basic = data[0] == '#';
        bool star = data[0] == '*';
        int idstart = basic || star ? 1 : 0;

        if (basic && equal != -1)
        {
            /* #id:tr=...
                     ^~~~
               基本元素不需要组合 */

            highlightItem hi = highlightItem(datal[i], i, equal, data.length() - equal);
            hi.describe = tr("error #1");
            items << hi;
        }
        else if (!basic && equal == -1)
        {
            /* id:tr
                    ^
               没有组合 */

            highlightItem hi = highlightItem(datal[i], i, 0, 0);
            hi.describe = tr("error #2");
            items << hi;
        }

        if (colon == -1)
        {
            /* id =...
                 ^
               没有名称 */

            highlightItem hi = highlightItem(datal[i], i, idstart, equal - idstart);
            hi.describe = tr("error #3");
            items << hi;
        }
        else
        {
            QString id = data.mid(idstart, colon - idstart).trimmed();
            QString name = data.mid(colon + 1, equal - colon - 1).trimmed();

            if (id.isEmpty())
            {
                // id为空
                highlightItem hi = highlightItem(datal[i], i, idstart, equal - idstart);
                hi.describe = tr("error #4");
                items << hi;
            }
            else
            {
                 QRegExp regexp("[A-Za-z0-9_]*");
                 int index = regexp.indexIn(id);

                 if (index != 0 || regexp.matchedLength() != id.length())
                 {
                     // id不符合规则
                     highlightItem hi = highlightItem(datal[i], i, idstart, equal - idstart);
                     hi.describe = tr("error #5");
                     items << hi;
                 }
                 else elements << id;
            }

            if (name.isEmpty())
            {
                // 名称为空
                highlightItem hi = highlightItem(datal[i], i, colon + 1, equal - colon - 1);
                hi.describe = tr("error #6");
                items << hi;
            }
        }
    }

    // 第二轮:检查组合
    for (int j = 0; j < datal.count(); j++)
    {
        QString data = datal[j];
        int first = 0;

        if (data[0] == '*' || data[0] == '#')
        {
            if (data[0] == '#') continue;
            data = data.mid(1);
            first = 1;
        }

        QStringList product = subString(data, QString::null, "=").split('+', QString::SkipEmptyParts);
        QStringList source = subString(data, "=").split('+', QString::SkipEmptyParts);
        int equal = data.indexOf('=');

        int l1 = 0;
        for (int i = 0; i < product.length(); i++)
        {
            QString s = subString(product[i], QString::null, ":");
            if (elements.indexOf(s) == -1)
            {
                // id无效
                highlightItem hi = highlightItem(datal[j], j, first + l1, s.length());
                hi.describe = tr("error #7");
                items << hi;
            }

            l1 += product[i].length() + 1;
        }

        if (product.length() == 0)
        {
            // 没有目标组合
            highlightItem hi = highlightItem(datal[j], j, 0, 0);
            hi.describe = tr("error #8");
            items << hi;
        }

        int l2 = 0;
        for (int i = 0; i < source.length(); i++)
        {
            if (elements.indexOf(source[i]) == -1)
            {
                // id无效
                highlightItem hi = highlightItem(datal[j], j, first + l1 + l2, source[i].length());
                hi.describe = tr("error #7");
                items << hi;
            }

            l2 += source[i].length() + 1;
        }

        if (source.length() == 0)
        {
            // 没有源组合
            highlightItem hi = highlightItem(datal[j], j, equal + 1, 0);
            hi.describe = tr("error #9");
            items << hi;
        }
    }

    this->rehighlight();
}