void MadHighlightingDialog::SetAttrBC(const wxColor &color, const wxString &colorname)
{
    KeywordInfo &kinfo=g_KeywordInfoTable[g_Index];
    if(g_Index==0)
    {
        SetItemBackgroundColour(WxListCtrlBC, 0, color);
        WxListCtrlKeyword->SetBackgroundColour(color);
        kinfo.attr->bgcolor=color;
    }
    else
    {
        wxASSERT(kinfo.kind!=kindSysAttr2);
        switch(kinfo.kind)
        {
        case kindSysAttr1:
        case kindKeyword:
            if(colorname==wxT("(Automatic)")) kinfo.attr->bgcolor=wxNullColour;
            else                              kinfo.attr->bgcolor=color;
            break;
        case kindRange:
            if(colorname==wxT("(Automatic)")) *kinfo.range_bgcolor=wxNullColour;
            else                              *kinfo.range_bgcolor=color;
            break;
        }
    }
    RepaintKeyword();

    SetItemBackgroundColour(WxListCtrlFC, 0, color);
    WxListCtrlFC->SetBackgroundColour(color);
    WxListCtrlFC->Refresh();
}
Exemplo n.º 2
0
void SessionTreeControl::addSession( std::string address, bool audio,
                                        bool rotate )
{
    bool added = false;
    wxTreeItemId node;
    wxTreeItemId current;
    SessionType type;

    // we don't account for audio + rotate since that's not supported
    if ( audio )
    {
        type = AUDIOSESSION;
        node = audioNodeID;
    }
    else if ( rotate )
    {
        type = AVAILABLEVIDEOSESSION;

        // make available video group if not there
        if ( !availableVideoNodeID.IsOk() )
        {
            availableVideoNodeID = AppendItem( rootID, _("Available Video") );
        }
        node = availableVideoNodeID;
    }
    else
    {
        type = VIDEOSESSION;
        node = videoNodeID;
    }

    added = sessionManager->addSession( address, type );

    current = AppendItem( node, wxString( address.c_str(), wxConvUTF8 ) );
    Expand( node );

    // note, these two cases shouldn't overlap - a rotate add won't return false
    // in SessionManager
    if ( rotate )
        SetItemBackgroundColour( current, *wxBLUE );
    else if ( !added )
    {
        SetItemBackgroundColour( current, *wxRED );
        gravUtil::logWarning( "SessionTreeControl::addObject: "
                            "failed to initialize %s\n", address.c_str() );
    }
}
Exemplo n.º 3
0
wxTreeItemId ctlTree::AppendItem(const wxTreeItemId &parent, const wxString &text, int image, int selImage, wxTreeItemData *data)
{
	wxTreeItemId itm = wxTreeCtrl::AppendItem(parent, text, image, selImage, data);

	// Set the item colour
	if (data)
	{
		if (((pgObject *)data)->GetMetaType() == PGM_SERVER)
		{
			if (!((pgServer *)data)->GetColour().IsEmpty())
				SetItemBackgroundColour(itm, wxColour(((pgServer *)data)->GetColour()));
		}
		else if (((pgObject *)data)->GetServer())
		{
			if (!((pgObject *)data)->GetServer()->GetColour().IsEmpty())
				SetItemBackgroundColour(itm, wxColour(((pgObject *)data)->GetServer()->GetColour()));
		}
	}

	return itm;
}
Exemplo n.º 4
0
void ctlTree::SetItemImage(const wxTreeItemId &item, int image, wxTreeItemIcon which)
{
	wxTreeCtrl::SetItemImage(item, image, which);

	wxTreeItemData *data = GetItemData(item);

	// Set the item colour
	if (data)
	{
		if (((pgObject *)data)->GetMetaType() == PGM_SERVER)
		{
			if (!((pgServer *)data)->GetColour().IsEmpty())
				SetItemBackgroundColour(item, wxColour(((pgServer *)data)->GetColour()));
		}
		else if (((pgObject *)data)->GetServer())
		{
			if (!((pgObject *)data)->GetServer()->GetColour().IsEmpty())
				SetItemBackgroundColour(item, wxColour(((pgObject *)data)->GetServer()->GetColour()));
		}
	}
}
Exemplo n.º 5
0
void SessionTreeControl::unrotateVideoSessions()
{
    wxTreeItemId current = findSession( availableVideoNodeID,
            sessionManager->getCurrentRotateSessionAddress() );
    if ( current.IsOk() )
    {
        SetItemBackgroundColour( current, *wxBLUE );
        SetItemTextColour( current, *wxBLACK );
    }

    sessionManager->unrotate( false );
}
Exemplo n.º 6
0
void SessionTreeControl::rotateToVideoSession( std::string addr, bool fromAuto )
{
    if ( !sessionManager->rotateTo( addr, false ) )
    {
        gravUtil::logVerbose( "SessionTreeControl::rotateTo %s failed\n",
                                addr.c_str() );
        return;
    }

    wxTreeItemId current = findSession( availableVideoNodeID,
            sessionManager->getCurrentRotateSessionAddress() );
    wxTreeItemId last = findSession( availableVideoNodeID,
            sessionManager->getLastRotateSessionAddress() );

    if ( last.IsOk() )
    {
        SetItemBackgroundColour( last, *wxBLUE );
        SetItemTextColour( last, *wxBLACK );
    }
    if ( current.IsOk() )
    {
        if ( sessionManager->isInFailedState(
                sessionManager->getCurrentRotateSessionAddress(),
                AVAILABLEVIDEOSESSION ) )
        {
            SetItemBackgroundColour( current, *wxRED );
        }
        else
        {
            SetItemBackgroundColour( current, *wxWHITE );
            SetItemTextColour( current, *wxBLUE );
        }
    }

    // if manually rotated & currently autorotating, stop autorotating
    if ( !fromAuto && timer->IsRunning() )
    {
        toggleAutomaticRotate();
    }
}
Exemplo n.º 7
0
void SessionTreeControl::toggleEnableSessionEvent( wxCommandEvent& evt )
{
    std::string selectedAddress = std::string(
                                     GetItemText( GetSelection() ).char_str() );
    if ( sessionManager->setSessionProcessEnable( selectedAddress,
            !sessionManager->isSessionProcessEnabled( selectedAddress ) ) )
    {
        wxColour col =
                sessionManager->isSessionProcessEnabled( selectedAddress ) ?
                        *wxWHITE : *wxLIGHT_GREY;
        SetItemBackgroundColour( GetSelection(), col );
    }
}
Exemplo n.º 8
0
void frmMain::SetItemBackgroundColour(wxTreeItemId item, wxColour colour)
{
    wxTreeItemIdValue cookie;

    browser->SetItemBackgroundColour(item, wxColour(colour));
    if (browser->ItemHasChildren(item))
    {
        wxTreeItemId childitem = browser->GetFirstChild(item, cookie);
        while (childitem)
        {
            SetItemBackgroundColour(childitem, colour);
            childitem = browser->GetNextChild(item, cookie);
        }
    }
}
Exemplo n.º 9
0
void MyTreeCtrl::CreateButtonsImageList(int size)
{
    if ( size == -1 )
    {
        SetButtonsImageList(NULL);
        return;
    }

    // Make an image list containing small icons
    wxImageList *images = new wxImageList(size, size, true);

    // should correspond to TreeCtrlIcon_xxx enum
    wxBusyCursor wait;
    wxIcon icons[4];
    icons[0] = wxIcon(icon3_xpm);   // closed
    icons[1] = wxIcon(icon3_xpm);   // closed, selected
    icons[2] = wxIcon(icon5_xpm);   // open
    icons[3] = wxIcon(icon5_xpm);   // open, selected

    for ( size_t i = 0; i < WXSIZEOF(icons); i++ )
    {
        int sizeOrig = icons[i].GetWidth();
        if ( size == sizeOrig )
        {
            images->Add(icons[i]);
        }
        else
        {
            images->Add(wxBitmap(wxBitmap(icons[i]).ConvertToImage().Rescale(size, size)));
        }
    }

    AssignButtonsImageList(images);
#else
void MyTreeCtrl::CreateButtonsImageList(int WXUNUSED(size))
{
#endif
}

int MyTreeCtrl::OnCompareItems(const wxTreeItemId& item1,
                               const wxTreeItemId& item2)
{
    if ( m_reverseSort )
    {
        // just exchange 1st and 2nd items
        return wxTreeCtrl::OnCompareItems(item2, item1);
    }
    else
    {
        return wxTreeCtrl::OnCompareItems(item1, item2);
    }
}

void MyTreeCtrl::AddItemsRecursively(const wxTreeItemId& idParent,
                                     size_t numChildren,
                                     size_t depth,
                                     size_t folder)
{
    if ( depth > 0 )
    {
        bool hasChildren = depth > 1;

        wxString str;
        for ( size_t n = 0; n < numChildren; n++ )
        {
            // at depth 1 elements won't have any more children
            if ( hasChildren )
                str.Printf(wxT("%s child %u"), wxT("Folder"), unsigned(n + 1));
            else
                str.Printf(wxT("%s child %u.%u"), wxT("File"), unsigned(folder), unsigned(n + 1));

            // here we pass to AppendItem() normal and selected item images (we
            // suppose that selected image follows the normal one in the enum)
            int image, imageSel;
            if ( wxGetApp().ShowImages() )
            {
                image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder;
                imageSel = image + 1;
            }
            else
            {
                image = imageSel = -1;
            }
            wxTreeItemId id = AppendItem(idParent, str, image, imageSel,
                                         new MyTreeItemData(str));

            // and now we also set the expanded one (only for the folders)
            if ( hasChildren && wxGetApp().ShowImages() )
            {
                SetItemImage(id, TreeCtrlIcon_FolderOpened,
                             wxTreeItemIcon_Expanded);
            }

            // remember the last child for OnEnsureVisible()
            if ( !hasChildren && n == numChildren - 1 )
            {
                m_lastItem = id;
            }

            AddItemsRecursively(id, numChildren, depth - 1, n + 1);
        }
    }
    //else: done!
}

void MyTreeCtrl::AddTestItemsToTree(size_t numChildren,
                                    size_t depth)
{
    int image = wxGetApp().ShowImages() ? MyTreeCtrl::TreeCtrlIcon_Folder : -1;
    wxTreeItemId rootId = AddRoot(wxT("Root"),
                                  image, image,
                                  new MyTreeItemData(wxT("Root item")));
    if ( !HasFlag(wxTR_HIDE_ROOT) && image != -1 )
    {
        SetItemImage(rootId, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded);
    }

    AddItemsRecursively(rootId, numChildren, depth, 0);

    // set some colours/fonts for testing
    if ( !HasFlag(wxTR_HIDE_ROOT) )
        SetItemFont(rootId, *wxITALIC_FONT);

    wxTreeItemIdValue cookie;
    wxTreeItemId id = GetFirstChild(rootId, cookie);
    SetItemTextColour(id, *wxBLUE);

    id = GetNextChild(rootId, cookie);
    id = GetNextChild(rootId, cookie);
    SetItemTextColour(id, *wxRED);
    SetItemBackgroundColour(id, *wxLIGHT_GREY);
}
/*
 * WxListCtrlKeywordSelected
 */
void MadHighlightingDialog::WxListCtrlKeywordSelected(wxListEvent& event)
{
    long oldIndex=g_Index;
    g_Index = event.m_itemIndex;

    WxListCtrlKeyword->Freeze();
    WxListCtrlFC->Freeze();

    if(oldIndex!=g_Index)
    {
        wxString str;
        if(oldIndex>=0)
        {
            str = WxListCtrlKeyword->GetItemText(oldIndex);
            if(str[0]==wxT('*')) 
            {
                WxListCtrlKeyword->SetItemText(oldIndex, str.Right(str.Len()-1));
            }
        }

        str = WxListCtrlKeyword->GetItemText(g_Index);
        WxListCtrlKeyword->SetItemText(g_Index, wxString(wxT('*'))+str);

        WxListCtrlKeyword->SetColumnWidth(0, WxListCtrlKeyword->GetClientSize().x - 4);
    }

    KeywordInfo &kinfo=g_KeywordInfoTable[g_Index];
    if(g_Index==0) // set (Automatic) colors
    {
        SetItemTextColour(WxListCtrlFC, 0, kinfo.attr->color);
        int c = (kinfo.attr->bgcolor.Red()+kinfo.attr->bgcolor.Green()+kinfo.attr->bgcolor.Blue())/3;
        if(c >= 128)
        {
            SetItemColour(WxListCtrlBC, 0, *wxBLACK, kinfo.attr->bgcolor);
        }
        else
        {
            SetItemColour(WxListCtrlBC, 0, *wxWHITE, kinfo.attr->bgcolor);
        }
    }

    wxColour bgc;
    switch(kinfo.kind)
    {
    case kindSysAttr1:
    case kindKeyword:
        WxCheckBoxBold->Enable();
        WxCheckBoxItalic->Enable();
        WxCheckBoxUnderline->Enable();
        WxCheckBoxBold->SetValue((kinfo.attr->style&fsBold)!=0);
        WxCheckBoxItalic->SetValue((kinfo.attr->style&fsItalic)!=0);
        WxCheckBoxUnderline->SetValue((kinfo.attr->style&fsUnderline)!=0);
        SetPanelFC(kinfo.attr->color);
        SetPanelBC(kinfo.attr->bgcolor);
        WxListCtrlFC->Enable();
        WxButtonFC->Enable();
        WxListCtrlBC->Enable();
        WxButtonBC->Enable();
        bgc=kinfo.attr->bgcolor;
        break;
    case kindSysAttr2:
        WxCheckBoxBold->SetValue(false);
        WxCheckBoxItalic->SetValue(false);
        WxCheckBoxUnderline->SetValue(false);
        WxCheckBoxBold->Disable();
        WxCheckBoxItalic->Disable();
        WxCheckBoxUnderline->Disable();
        SetPanelFC(kinfo.attr->color);
        SetPanelBC(wxNullColour);
        WxListCtrlFC->Enable();
        WxButtonFC->Enable();
        WxListCtrlBC->Disable();
        WxButtonBC->Disable();
        bgc==wxNullColour;
        break;
    case kindRange:
        WxCheckBoxBold->SetValue(false);
        WxCheckBoxItalic->SetValue(false);
        WxCheckBoxUnderline->SetValue(false);
        WxCheckBoxBold->Disable();
        WxCheckBoxItalic->Disable();
        WxCheckBoxUnderline->Disable();
        SetPanelFC(wxNullColour);
        SetPanelBC(*kinfo.range_bgcolor);
        WxListCtrlFC->Disable();
        WxButtonFC->Disable();
        WxListCtrlBC->Enable();
        WxButtonBC->Enable();
        bgc=*kinfo.range_bgcolor;
        break;
    }
    if(bgc==wxNullColour) bgc=g_KeywordInfoTable[0].attr->bgcolor;
    WxListCtrlFC->SetBackgroundColour(bgc);
    SetItemBackgroundColour(WxListCtrlFC, 0, bgc);
    this->Layout();

    WxListCtrlKeyword->SetItemState(event.m_itemIndex, 0, wxLIST_STATE_SELECTED);
    WxListCtrlKeyword->Thaw();
    WxListCtrlFC->Thaw();
}
Exemplo n.º 11
0
void SessionTreeControl::shiftSession( std::string address, bool audio )
{
    wxTreeItemId item = findSession( rootID, address );
    if ( item.IsOk() )
    {
        wxTreeItemId parent = GetItemParent( item );
        wxTreeItemId newParent;
        SessionType type;

        if ( parent == videoNodeID )
        {
            type = VIDEOSESSION;

            // make available video group if not there
            if ( !availableVideoNodeID.IsOk() )
            {
                availableVideoNodeID = AppendItem( rootID,
                                                    _("Available Video") );
            }

            newParent = availableVideoNodeID;
        }
        else if ( parent == availableVideoNodeID )
        {
            type = AVAILABLEVIDEOSESSION;
            newParent = videoNodeID;
        }
        else
        {
            gravUtil::logError( "SessionTreeControl::shiftSession: "
                                "cannot shift %s, invalid tree position\n",
                                address.c_str() );
            return;
        }

        if ( !sessionManager->shiftSession( address, type ) )
        {
            gravUtil::logError( "SessionTreeControl::shiftSession: "
                                "shift of %s failed \n", address.c_str() );
            return;
        }

        Delete( item );

        wxTreeItemId newNode = AppendItem( newParent,
                wxString( address.c_str(), wxConvUTF8 ) );
        Expand( newParent );

        if ( newParent == availableVideoNodeID )
            SetItemBackgroundColour( newNode, *wxBLUE );
        // if we added a session to the regular video list but it failed to
        // initialize, keep it there but note it by making it red
        // in the future, may have dialog option for choosing whether to keep
        // it in the list or not
        if ( newParent == videoNodeID &&
                sessionManager->isInFailedState( address, VIDEOSESSION ) )
            SetItemBackgroundColour( newNode, *wxRED );
    }
    else
    {
        gravUtil::logWarning( "SessionTreeControl::shiftSession: "
                                "item %s not found?\n", address.c_str() );
    }
}