Ejemplo n.º 1
0
void RocketMenuPlugin::HighlightNextItem(Rocket::Core::ElementDocument *document = NULL) {
    DocumentData *doc_data = GetDocumentData(document);
    if (doc_data != NULL) {
        if (doc_data->active_item != NULL) {
            Rocket::Core::Element *e = FindNextItem(doc_data->active_item);
            if (e != NULL) {
                HighlightItem(e);
            }
        }
    } else {
        printf("[ROCK] RocketMenuPlugin::HighlightNextItem: attempt to activate next item on the document with no menu\n");
    }
}
Ejemplo n.º 2
0
bool ctFindReplaceDialog::DoFind(const wxString& textToFind, bool matchCase, bool wholeWord, bool wrap)
{
    ctConfigToolDoc* doc = wxGetApp().GetMainFrame()->GetDocument();
    if (!doc)
        return false;
    ctConfigToolView* view = (ctConfigToolView*) doc->GetFirstView();

    ctConfigItem* currentItem = NULL;
    ctConfigItem* focusItem = view->GetSelection();
    if (!focusItem)
    {
        focusItem = doc->GetTopItem();
        if (!focusItem)
            return false;
    }

    if (!sm_currentItem.empty())
    {
        currentItem = doc->GetTopItem()->FindItem(sm_currentItem);
    }

    // If we were at this item last time, skip the first one.
    bool skipFirstItem = (currentItem == focusItem);
    currentItem = FindNextItem(doc, currentItem, textToFind, matchCase, wholeWord, wrap,
        skipFirstItem);

    if (currentItem)
    {
        sm_currentItem = currentItem->GetName();
        wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->SelectItem(currentItem->GetTreeItemId());
        return true;
    }
    else
    {
        sm_currentItem = wxEmptyString;
    }

    return false;
}
Ejemplo n.º 3
0
/*
   The numArg here is the listbox item index while the strArg is used
   differently for the different actions:

   a) for wxACTION_LISTBOX_FIND it has the natural meaning: this is the string
      to find

   b) for wxACTION_LISTBOX_SELECT and wxACTION_LISTBOX_EXTENDSEL it is used
      to decide if the listbox should send the notification event (it is empty)
      or not (it is not): this allows us to reuse the same action for when the
      user is dragging the mouse when it has been released although in the
      first case no notification is sent while in the second it is sent.
 */
bool wxListBox::PerformAction(const wxControlAction& action,
                              long numArg,
                              const wxString& strArg)
{
    int item = (int)numArg;

    if ( action == wxACTION_LISTBOX_SETFOCUS )
    {
        SetCurrentItem(item);
    }
    else if ( action == wxACTION_LISTBOX_ACTIVATE )
    {
        Activate(item);
    }
    else if ( action == wxACTION_LISTBOX_TOGGLE )
    {
        if ( item == -1 )
            item = m_current;

        if ( IsSelected(item) )
            DoUnselect(item);
        else
            SelectAndNotify(item);
    }
    else if ( action == wxACTION_LISTBOX_SELECT )
    {
        DeselectAll(item);

        if ( strArg.empty() )
            SelectAndNotify(item);
        else
            DoSelect(item);
    }
    else if ( action == wxACTION_LISTBOX_SELECTADD )
        DoSelect(item);
    else if ( action == wxACTION_LISTBOX_UNSELECT )
        DoUnselect(item);
    else if ( action == wxACTION_LISTBOX_MOVEDOWN )
        ChangeCurrent(1);
    else if ( action == wxACTION_LISTBOX_MOVEUP )
        ChangeCurrent(-1);
    else if ( action == wxACTION_LISTBOX_PAGEDOWN )
        ChangeCurrent(GetItemsPerPage());
    else if ( action == wxACTION_LISTBOX_PAGEUP )
        ChangeCurrent(-GetItemsPerPage());
    else if ( action == wxACTION_LISTBOX_START )
        SetCurrentItem(0);
    else if ( action == wxACTION_LISTBOX_END )
        SetCurrentItem(GetCount() - 1);
    else if ( action == wxACTION_LISTBOX_UNSELECTALL )
        DeselectAll(item);
    else if ( action == wxACTION_LISTBOX_EXTENDSEL )
        ExtendSelection(item);
    else if ( action == wxACTION_LISTBOX_FIND )
        FindNextItem(strArg);
    else if ( action == wxACTION_LISTBOX_ANCHOR )
        AnchorSelection(item == -1 ? m_current : item);
    else if ( action == wxACTION_LISTBOX_SELECTALL ||
              action == wxACTION_LISTBOX_SELTOGGLE )
        wxFAIL_MSG(_T("unimplemented yet"));
    else
        return wxControl::PerformAction(action, numArg, strArg);

    return true;
}