Ejemplo n.º 1
0
gcImgButtonCount::gcImgButtonCount( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : gcImageButton( parent, id, pos, size, style )
{
	m_uiCount = 0;
	m_imgCount = GetGCThemeManager()->getImageHandle("#count_background");
}
Ejemplo n.º 2
0
	void onActiveToggle(bool state)
	{
		m_imgHandle = GetGCThemeManager()->getImageHandle(state?"#menu_bg":"#menu_bg_nonactive");
		invalidatePaint();
	}
Ejemplo n.º 3
0
DesuraControl::DesuraControl(gcFrame* parent, bool offline) : gcPanel(parent)
{
	m_iIndex = -1;
	m_bDownloadingUpdate = false;
	m_uiUpdateProgress = 0;

	this->SetBackgroundColour( wxColor(GetGCThemeManager()->getColor("headerbottomborder", "bg")));
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
	*GetUserCore()->getNewAvatarEvent() += guiDelegate(this, &DesuraControl::onNewAvatar);

	parent->onActiveEvent += guiDelegate(this, &DesuraControl::onActiveToggle);


	m_pMainMenuButton = new MainMenuButton(this, offline);

	m_pAvatar = new gcImageButton( this, wxID_ANY, wxDefaultPosition, wxSize( 66,66 ), wxTAB_TRAVERSAL );

#ifdef WIN32
	m_pAvatar->SetCursor(wxCURSOR_HAND);
#endif

	const char* szAvatar = GetUserCore()->getAvatar();
	if (szAvatar && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(szAvatar)))
	{
		gc_lastavatar.setValue(szAvatar);
		m_pAvatar->setDefaultImage(szAvatar);
	}
	else
	{
		m_pAvatar->setDefaultImage("#icon_avatar");
	}

	m_pFiller = new DesuraMenuFiller(this);
	m_pFiller->SetMinSize( wxSize( 25,38 ) );
	
	m_pUsernameBox = new UsernameBox(this, offline?"Offline":GetUserCore()->getUserName());
	m_pMenuStrip = new MenuStrip(this);

	m_sizerContent = new wxFlexGridSizer( 1, 1, 0, 0 );
	m_sizerContent->AddGrowableCol( 0 );
	m_sizerContent->AddGrowableRow( 0 );
	m_sizerContent->SetFlexibleDirection( wxBOTH );
	m_sizerContent->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	wxFlexGridSizer* fgSizer3;

	fgSizer3 = new wxFlexGridSizer( 1, 4, 0, 0 );

	fgSizer3->AddGrowableCol( 2 );
	fgSizer3->SetFlexibleDirection( wxBOTH );
	fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	fgSizer3->Add( m_pUsernameBox, 1, wxEXPAND, 5 );
	fgSizer3->Add( m_pMenuStrip, 1, wxEXPAND, 5 ); 	// main buttons across the top
	fgSizer3->Add( m_pFiller, 1, wxEXPAND, 5 );

	
	m_sizerHeader = new wxBoxSizer( wxVERTICAL ); 
	



	wxFlexGridSizer* fgSizer4;
	fgSizer4 = new wxFlexGridSizer( 1, 2, 0, 0 );
	fgSizer4->SetFlexibleDirection( wxBOTH );
	fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	if (!offline)
	{
		m_bButtonStrip = new ButtonStrip( this );
		fgSizer4->Add( m_bButtonStrip, 1, wxEXPAND|wxBOTTOM, 1 ); // mail buttons
	}
	else
	{
		m_bButtonStrip = NULL;
		fgSizer4->Add( 5, 0, 1, wxEXPAND, 5 );
	}

	fgSizer4->AddGrowableCol( 1 );
	fgSizer4->Add( m_sizerHeader, 1, wxEXPAND, 5 ); // arrows, home button,


	wxFlexGridSizer* fgSizer2;
	fgSizer2 = new wxFlexGridSizer( 2, 1, 0, 0 );
	fgSizer2->AddGrowableCol( 0 );
	fgSizer2->SetFlexibleDirection( wxBOTH );
	fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	fgSizer2->Add( fgSizer3, 1, wxEXPAND, 5 );
	fgSizer2->Add( fgSizer4, 1, wxEXPAND, 5 );


	wxFlexGridSizer* fgSizer1;
	fgSizer1 = new wxFlexGridSizer( 1, 4, 0, 0 );
	fgSizer1->AddGrowableCol( 2 );
	fgSizer1->SetFlexibleDirection( wxBOTH );
	fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	fgSizer1->Add( m_pMainMenuButton, 1, 0, 5 );
	fgSizer1->Add( m_pAvatar, 1, wxSHAPED, 5 );
	fgSizer1->Add( fgSizer2, 1, wxEXPAND, 5 );

	wxFlexGridSizer* fgSizer5;
	fgSizer5 = new wxFlexGridSizer( 2, 1, 0, 0 );
	fgSizer5->AddGrowableCol( 0 );
	fgSizer5->AddGrowableRow( 1 );
	fgSizer5->SetFlexibleDirection( wxBOTH );
	fgSizer5->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	fgSizer5->Add( fgSizer1, 1, wxEXPAND, 5 );
	fgSizer5->Add( m_sizerContent, 1, wxEXPAND, 5 );
	
	this->SetSizer( fgSizer5 );
	this->Layout();

	*GetUserCore()->getAppUpdateProgEvent() += guiDelegate(this, &DesuraControl::onDesuraUpdate);

	m_bOffline = offline;
}
Ejemplo n.º 4
0
HtmlToolBarControl::HtmlToolBarControl(wxWindow* parent)
	: BaseToolBarControl(parent)
{
	m_butBack = new gcImageButton( this, BUTTON_BACK, wxDefaultPosition, wxSize( 19,19 ), 0 );
	m_butBack->setDefaultImage(("#browser_back"));
	m_butBack->setHoverImage(("#browser_back_hover"));
	m_butBack->SetToolTip(Managers::GetString(L"#BC_BACK"));

	m_butFoward = new gcImageButton( this, BUTTON_FOWARD, wxDefaultPosition, wxSize( 19,19 ), 0 );
	m_butFoward->setDefaultImage(("#browser_forward"));
	m_butFoward->setHoverImage(("#browser_forward_hover"));
	m_butFoward->SetToolTip(Managers::GetString(L"#BC_FORWARD"));

	m_butHome = new gcImageButton( this, BUTTON_HOME, wxDefaultPosition, wxSize( 19,19 ), 0 );
	m_butHome->setDefaultImage(("#browser_home"));
	m_butHome->setHoverImage(("#browser_home_hover"));
	m_butHome->SetToolTip(Managers::GetString(L"#BC_HOME"));

	m_pBreadCrumb = new BreadCrump( this, wxID_ANY);

	m_dispLoading = new DispLoading(this, Managers::GetString(L"#DL_LOADING"), wxSize(-1,19));
	m_dispLoading->Show(false);

	m_butStop = new gcImageButton( this, BUTTON_STOP, wxDefaultPosition, wxSize( 19,19 ), 0 );
	m_butStop->setDefaultImage(("#browser_stop"));
	m_butStop->setHoverImage(("#browser_stop_hover"));
	m_butStop->SetToolTip(Managers::GetString(L"#BC_STOP"));
	m_butStop->Show(false);

	m_butRefresh = new gcImageButton( this, BUTTON_REFRESH, wxDefaultPosition, wxSize( 19,19 ), 0 );
	m_butRefresh->setDefaultImage(("#browser_refresh"));
	m_butRefresh->setHoverImage(("#browser_refresh_hover"));
	m_butRefresh->SetToolTip(Managers::GetString(L"#BC_REFRESH"));

	m_butLaunch = new gcImageButton( this, BUTTON_LAUNCH, wxDefaultPosition, wxSize( 19,19 ), 0 );
	m_butLaunch->setDefaultImage(("#browser_break"));
	m_butLaunch->setHoverImage(("#browser_break_hover"));
	m_butLaunch->SetToolTip(Managers::GetString(L"#BC_BREAK"));

#ifdef ENABLE_SEARCH
	m_pSearch = new SearchControl(this);
	m_pSearch->onSearchEvent += delegate(&onSearchEvent);
	m_pSearch->onFullSearchEvent += delegate(&onFullSearchEvent);
#else
	m_pSearch = nullptr;
#endif

	wxFlexGridSizer* fgSizer1;
	fgSizer1 = new wxFlexGridSizer( 1, 11, 0, 0 );
	fgSizer1->AddGrowableCol( 4 );
	fgSizer1->AddGrowableRow( 0 );
	fgSizer1->SetFlexibleDirection( wxBOTH );
	fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	fgSizer1->Add( m_butBack, 0, wxTOP|wxBOTTOM, 4 );
	fgSizer1->Add( m_butFoward, 0, wxTOP|wxBOTTOM, 4 );
	fgSizer1->Add( 3, 0, 1, 0, 4 );
	fgSizer1->Add( m_butHome, 0, wxTOP|wxBOTTOM, 4 );
	fgSizer1->Add( m_pBreadCrumb, 0, wxTOP|wxBOTTOM, 4 );
	fgSizer1->Add( m_dispLoading, 1, wxTOP|wxBOTTOM, 4 );
	fgSizer1->Add( m_butStop, 1, wxTOP|wxBOTTOM, 4 );
	fgSizer1->Add( m_butRefresh, 0, wxTOP|wxBOTTOM, 4 );

#ifdef ENABLE_SEARCH
	fgSizer1->Add( m_butLaunch, 0, wxTOP|wxBOTTOM, 4 );
	fgSizer1->Add( m_pSearch, 0, wxTOP|wxBOTTOM, 4);
	fgSizer1->Add( m_pSearch->getButton(), 0, wxTOP|wxBOTTOM|wxRIGHT, 4);
#else
	fgSizer1->Add( m_butLaunch, 0, wxTOP|wxBOTTOM|wxRIGHT, 4 );
#endif

	this->SetSizer( fgSizer1 );
	this->Layout();

	onPageStartLoadingEvent += guiDelegate(this, &HtmlToolBarControl::onPageStartLoading);
	onPageEndLoadingEvent += guiDelegate(this, &HtmlToolBarControl::onPageFinishLoading);

	m_NormColor = this->GetForegroundColour();
	m_NonActiveColor = wxColor(GetGCThemeManager()->getColor("label", "na-fg"));
}
Ejemplo n.º 5
0
const char* IPCBrowser::getThemeFolder()
{
	return GetGCThemeManager()->getThemeFolder();
}
Ejemplo n.º 6
0
bool gcCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
{
    DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)item;

    if ( !IsOwnerDrawn() || dis->CtlType != ODT_BUTTON )
        return wxCheckBoxBase::MSWOnDraw(item);

    // calculate the rectangles for the check mark itself and the label
    HDC hdc = dis->hDC;
    RECT& rect = dis->rcItem;
    RECT rectCheck,
         rectLabel;
    rectCheck.top =
    rectLabel.top = rect.top;
    rectCheck.bottom =
    rectLabel.bottom = rect.bottom;
    const int checkSize = GetBestSize().y;
    const int MARGIN = 3;

    const bool isRightAligned = HasFlag(wxALIGN_RIGHT);
    if ( isRightAligned )
    {
        rectCheck.right = rect.right;
        rectCheck.left = rectCheck.right - checkSize;

        rectLabel.right = rectCheck.left - MARGIN;
        rectLabel.left = rect.left;
    }
    else // normal, left-aligned checkbox
    {
        rectCheck.left = rect.left;
        rectCheck.right = rectCheck.left + checkSize;

        rectLabel.left = rectCheck.right + MARGIN;
        rectLabel.right = rect.right;
    }

    // show we draw a focus rect?
    const bool isFocused = IsChecked() || FindFocus() == this;


    // draw the checkbox itself
    wxDCTemp dc(hdc);

    int flags = 0;
    if ( !IsEnabled() )
        flags |= wxCONTROL_DISABLED;
    switch ( Get3StateValue() )
    {
        case wxCHK_CHECKED:
            flags |= wxCONTROL_CHECKED;
            break;

        case wxCHK_UNDETERMINED:
            flags |= wxCONTROL_PRESSED;
            break;

        default:
            wxFAIL_MSG( _T("unexpected Get3StateValue() return value") );
            // fall through

        case wxCHK_UNCHECKED:
            // no extra styles needed
            break;
    }

    if ( wxFindWindowAtPoint(wxGetMousePosition()) == this )
        flags |= wxCONTROL_CURRENT;

    wxRendererNative::Get().
        DrawCheckBox(this, dc, wxRectFromRECT(rectCheck), flags);

    // draw the text
    const wxString& label = GetLabel();

    // first we need to measure it
    UINT fmt = DT_NOCLIP;

    // drawing underlying doesn't look well with focus rect (and the native
    // control doesn't do it)
    if ( isFocused )
        fmt |= DT_HIDEPREFIX;
    if ( isRightAligned )
        fmt |= DT_RIGHT;
    // TODO: also use DT_HIDEPREFIX if the system is configured so

    // we need to get the label real size first if we have to draw a focus rect
    // around it
    if ( isFocused )
    {
        if ( !::DrawText(hdc, label.wx_str(), label.length(), &rectLabel,
                         fmt | DT_CALCRECT) )
        {
            wxLogLastError(_T("DrawText(DT_CALCRECT)"));
        }
    }

    if ( !IsEnabled() )
    {
        ::SetTextColor(hdc, ::GetSysColor(COLOR_GRAYTEXT));
    }

    if ( !::DrawText(hdc, label.wx_str(), label.length(), &rectLabel, fmt) )
    {
        wxLogLastError(_T("DrawText()"));
    }



    //// finally draw the focus
    if ( isFocused )
    {
		COLORREF colBg = wxColourToRGB(wxColor(GetGCThemeManager()->getColor("checkbox", "focus-fg")));
		HBRUSH hbrush = ::CreateSolidBrush(colBg);

        rectLabel.left--;
        rectLabel.right++;

        ::FrameRect(hdc, &rectLabel, hbrush);
		::DeleteObject(hbrush);
    }

    return true;
}
Ejemplo n.º 7
0
void InternalLink::handleInternalLink(const char* link)
{
	std::vector<gcString> list;
	bool badLink = false;

	g_pMainApp->showMainWindow(true);
	
	if (strncmp("desura://", link, 9) == 0)
	{
		char* str = nullptr;
		Safe::strcpy(&str, link+9, 255);

		char* context = nullptr;

		char* token = Safe::strtok(str, "/", &context);

		while (token)
		{
			list.push_back(gcString(token));
			token = Safe::strtok(nullptr, "/", &context);
		}

		safe_delete(str);
	}
	else
	{	
		badLink = true;
	}

	if (list.size() >= 1)
	{
		if (list[0] == "switchtab" || list[0] == "tab")
		{
			if (!switchTab(badLink, list, link))
				return;
		}
		else if (list[0] == "settings")
		{
			gcString url(GetGCThemeManager()->getWebPage("settings"));

			if (list.size() >=2 )
				url += "#" + list[1];
			else
				url += "#general";

			g_pMainApp->loadUrl(url.c_str(), SUPPORT);
		}
		else if (list[0] == "cip")
		{
			handleInternalLink(0, ACTION_SHOWSETTINGS, FormatArgs("tab=cip"));
		}
		else if (list.size() < 3)
		{
#ifdef WIN32
			if (list[0] == "installwizard")
			{
				handleInternalLink(0, ACTION_INSTALLEDW);
			}
			else 
#endif	
			if (list[0] == "refresh")
			{
				GetUserCore()->forceUpdatePoll();

				if ((list.size() >= 2 && list[1] == "background") == false)
					g_pMainApp->showPlay();
			}
			else
			{
				badLink = true;
			}
		}
		else
		{
			if (!processItemLink(badLink, list, link))
				return;
		}
	}

	if (badLink)
	{
		Warning(gcString("{0} [{1}]\n", Managers::GetString("#MF_BADLINK"), link));

		gcWString errMsg(L"{0}: {1}.", Managers::GetString("#MF_BADLINK"), link);
		gcMessageBox(g_pMainApp->getMainWindow(), errMsg, Managers::GetString(L"#MF_ERRTITLE"));
	}
}
Ejemplo n.º 8
0
CreateMCFOverview::CreateMCFOverview( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : BasePage( parent, id, pos, size, style )
{
	wxFlexGridSizer* fgSizer2;
	fgSizer2 = new wxFlexGridSizer( 4, 1, 0, 0 );
	fgSizer2->AddGrowableRow( 2 );
	fgSizer2->AddGrowableCol( 0 );
	fgSizer2->SetFlexibleDirection( wxBOTH );
	fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
	
	m_labInfo = new gcStaticText( this, wxID_ANY, wxT("Creating MCF for [item] has completed."), wxDefaultPosition, wxSize( -1,-1 ), 0 );
	m_labInfo->Wrap( -1 );
	fgSizer2->Add( m_labInfo, 1, wxALL|wxEXPAND, 5 );
	

	
	fgSizer2->Add( 0, 5, 1, wxEXPAND, 5 );
	
	wxFlexGridSizer* fgSizer1;
	fgSizer1 = new wxFlexGridSizer( 3, 3, 0, 0 );
	fgSizer1->SetFlexibleDirection( wxBOTH );
	fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
	
	gcStaticText* m_staticText2 = new gcStaticText( this, wxID_ANY,  Managers::GetString(L"Name"), wxDefaultPosition, wxSize( 30,-1 ), wxALIGN_RIGHT );
	m_staticText2->Wrap( -1 );
	fgSizer1->Add( m_staticText2, 0, wxLEFT|wxRIGHT|wxTOP|wxALIGN_RIGHT, 3 );
	
	gcStaticText* m_staticText3 = new gcStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText3->Wrap( -1 );
	fgSizer1->Add( m_staticText3, 0, wxTOP, 3 );
	
	m_labName = new gcStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	m_labName->Wrap( -1 );
	fgSizer1->Add( m_labName, 0, wxLEFT|wxRIGHT|wxTOP, 3 );
	
	gcStaticText* m_staticText5 = new gcStaticText( this, wxID_ANY, Managers::GetString(L"Size"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
	m_staticText5->Wrap( -1 );
	fgSizer1->Add( m_staticText5, 0, wxLEFT|wxRIGHT|wxTOP|wxALIGN_RIGHT, 3 );
	
	gcStaticText* m_staticText6 = new gcStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText6->Wrap( -1 );
	fgSizer1->Add( m_staticText6, 0, wxTOP, 3 );
	
	m_labSize = new gcStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	m_labSize->Wrap( -1 );
	fgSizer1->Add( m_labSize, 0, wxLEFT|wxRIGHT|wxTOP, 3 );
	
	gcStaticText* m_staticText8 = new gcStaticText( this, wxID_ANY, Managers::GetString(L"Path"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
	m_staticText8->Wrap( -1 );
	fgSizer1->Add( m_staticText8, 0, wxLEFT|wxRIGHT|wxTOP|wxALIGN_RIGHT, 3 );
	
	gcStaticText* m_staticText9 = new gcStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText9->Wrap( -1 );
	fgSizer1->Add( m_staticText9, 0, wxTOP, 3 );
	
	m_labPath = new gcStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	m_labPath->Wrap( -1 );
	fgSizer1->Add( m_labPath, 0, wxLEFT|wxRIGHT|wxTOP, 3 );
	
	fgSizer2->Add( fgSizer1, 1, wxEXPAND, 5 );
	
	wxBoxSizer* bSizer2;
	bSizer2 = new wxBoxSizer( wxHORIZONTAL );
	
	
	wxColor col = wxColor(GetGCThemeManager()->getColor("abouttext", "bg"));

	m_staticText2->SetForegroundColour(col);
	m_staticText3->SetForegroundColour(col);
	m_labName->SetForegroundColour(col);
	m_staticText5->SetForegroundColour(col);
	m_staticText6->SetForegroundColour(col);
	m_labSize->SetForegroundColour(col);
	m_staticText8->SetForegroundColour(col);
	m_staticText9->SetForegroundColour(col);
	m_labPath->SetForegroundColour(col);


	bSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
	
	m_butViewFile = new gcButton( this, wxID_ANY, Managers::GetString(L"#CF_VIEWFILES"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer2->Add( m_butViewFile, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
	
	m_butUpload = new gcButton( this, wxID_ANY, Managers::GetString(L"#UPLOAD"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer2->Add( m_butUpload, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
	
	m_butClose = new gcButton( this, wxID_ANY, Managers::GetString(L"#CANCEL"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer2->Add( m_butClose, 0, wxALL, 5 );
	
	fgSizer2->Add( bSizer2, 0, wxEXPAND, 5 );
	
	this->SetSizer( fgSizer2 );
	this->Layout();

	m_labPath->SetCursor(wxCURSOR_HAND);
	m_labPath->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CreateMCFOverview::onMouseDown ), NULL, this );
}
Ejemplo n.º 9
0
	virtual void doPaint(wxDC* dc)
	{
		if (!m_imgHandle.getImg() || !m_imgHandle->IsOk())
		{
			dc->SetTextForeground(wxColor(0,0,0));
			dc->Clear();
			return;
		}

		dc->SetFont(GetFont());
		dc->SetTextBackground(GetBackgroundColour());

		if (m_bHovering)
			dc->SetTextForeground(m_colHover);
		else if (m_bSelected)
			dc->SetTextForeground(m_colSelected);
		else
			dc->SetTextForeground(m_colNormal);


		int h = GetSize().GetHeight();
		int w = GetSize().GetWidth();
		int iw = m_imgHandle->GetSize().GetWidth();

		wxBitmap   tmpBmp(w, h);
		wxMemoryDC tmpDC(tmpBmp);

		tmpDC.SetBrush(wxBrush(wxColor(255,0,255)));
		tmpDC.SetPen( wxPen(wxColor(255,0,255),1) );
		tmpDC.DrawRectangle(0,0,w,h);

		wxImage scaled = m_imgHandle->Scale(iw, h);

		wxBitmap left;
		wxBitmap right;
		wxBitmap centerImg = GetGCThemeManager()->getSprite(scaled, "playlist_button", "fill");

		if (m_uiPos == LEFT)
		{
			left = GetGCThemeManager()->getSprite(scaled, "playlist_button", "left");
		}
		else
		{
			left = GetGCThemeManager()->getSprite(scaled, "playlist_button", "fill");
		}

		if (m_uiPos == RIGHT)
		{
			right = GetGCThemeManager()->getSprite(scaled, "playlist_button", "right");
		}
		else
		{
			right = GetGCThemeManager()->getSprite(scaled, "playlist_button", "seperator");
		}


		wxBitmap center(w-(left.GetWidth()+right.GetWidth()),h);

		wxColor c(255,0,255);
		gcImage::tileImg(center, centerImg, &c);

		tmpDC.DrawBitmap(left, 0,0,true);
		tmpDC.DrawBitmap(center, left.GetWidth(),0,true);
		tmpDC.DrawBitmap(right, w-right.GetWidth(),0,true);

		tmpDC.SelectObject(wxNullBitmap);
		dc->DrawBitmap(tmpBmp, 0,0, true);

		if (m_bTransEnabled)
		{
			wxRegion region = wxRegion(tmpBmp, wxColor(255,0,255), 1);
			SetShape(region, this);
		}

		wxString lab = GetLabel();

		long x = (w - dc->GetTextExtent(lab).GetWidth())/2;
		long y = (h - dc->GetTextExtent(lab).GetHeight())/2;

		dc->DrawText(lab, x, y);
	}
Ejemplo n.º 10
0
DesuraControl::DesuraControl(gcFrame* parent, bool offline, const char* szProvider) 
	: gcPanel(parent)
{
	m_iIndex = -1;
	m_bDownloadingUpdate = false;
	m_uiUpdateProgress = 0;

	this->SetBackgroundColour( wxColor(GetGCThemeManager()->getColor("headerbottomborder", "bg")));
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
	auto userCore = GetUserCore();

	if (userCore)
		userCore->getNewAvatarEvent() += guiDelegate(this, &DesuraControl::onNewAvatar);

	parent->onActiveEvent += guiDelegate(this, &DesuraControl::onActiveToggle);


	m_pMainMenuButton = new MainMenuButton(this, offline);

	m_pAvatar = new gcImageButton( this, wxID_ANY, wxDefaultPosition, wxSize( 66,66 ), wxTAB_TRAVERSAL );

#ifdef WIN32
	m_pAvatar->SetCursor(wxCURSOR_HAND);
#endif

	const char* szUsername = Managers::GetString("#MP_OFFLINE");
	const char* szAvatar = nullptr;
	
	if (userCore)
	{
		szAvatar = GetUserCore()->getAvatar();

		if (!offline)
			szUsername = GetUserCore()->getUserName();
	}
		

	if (szAvatar && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(szAvatar)))
	{
		gc_lastavatar.setValue(szAvatar);
		m_pAvatar->setDefaultImage(szAvatar);
	}
	else
	{
		m_pAvatar->setDefaultImage("#icon_avatar");
	}

	m_pFiller = new DesuraMenuFiller(this);
	m_pFiller->SetMinSize( wxSize( 25,38 ) );
	
	m_pUsernameBox = new UsernameBox(this, szUsername);
	m_pMenuStrip = new MenuStrip(this);

	m_sizerContent = new wxFlexGridSizer( 1, 1, 0, 0 );
	m_sizerContent->AddGrowableCol( 0 );
	m_sizerContent->AddGrowableRow( 0 );
	m_sizerContent->SetFlexibleDirection( wxBOTH );
	m_sizerContent->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	wxFlexGridSizer* fgSizer3;

	fgSizer3 = new wxFlexGridSizer( 1, 4, 0, 0 );

	fgSizer3->AddGrowableCol( 2 );
	fgSizer3->SetFlexibleDirection( wxBOTH );
	fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	fgSizer3->Add( m_pUsernameBox, 1, wxEXPAND, 5 );
	fgSizer3->Add( m_pMenuStrip, 1, wxEXPAND, 5 ); 	// main buttons across the top
	fgSizer3->Add( m_pFiller, 1, wxEXPAND, 5 );

	
	m_sizerHeader = new wxBoxSizer( wxVERTICAL ); 
	



	wxFlexGridSizer* fgSizer4;
	fgSizer4 = new wxFlexGridSizer( 1, 2, 0, 0 );
	fgSizer4->SetFlexibleDirection( wxBOTH );
	fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	if (!offline)
	{
		m_bButtonStrip = new ButtonStrip( this );
		fgSizer4->Add( m_bButtonStrip, 1, wxEXPAND|wxBOTTOM, 1 ); // mail buttons
	}
	else
	{
		m_bButtonStrip = nullptr;
		fgSizer4->Add( 5, 0, 1, wxEXPAND, 5 );
	}

	fgSizer4->AddGrowableCol( 1 );
	fgSizer4->Add( m_sizerHeader, 1, wxEXPAND, 5 ); // arrows, home button,


	wxFlexGridSizer* fgSizer2;
	fgSizer2 = new wxFlexGridSizer( 2, 1, 0, 0 );
	fgSizer2->AddGrowableCol( 0 );
	fgSizer2->SetFlexibleDirection( wxBOTH );
	fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	fgSizer2->Add( fgSizer3, 1, wxEXPAND, 5 );
	fgSizer2->Add( fgSizer4, 1, wxEXPAND, 5 );


	wxFlexGridSizer* fgSizer1;
	fgSizer1 = new wxFlexGridSizer( 1, 4, 0, 0 );
	fgSizer1->AddGrowableCol( 2 );
	fgSizer1->SetFlexibleDirection( wxBOTH );
	fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	fgSizer1->Add( m_pMainMenuButton, 1, 0, 5 );
	fgSizer1->Add( m_pAvatar, 1, wxSHAPED, 5 );
	fgSizer1->Add( fgSizer2, 1, wxEXPAND, 5 );

	wxFlexGridSizer* fgSizer5;
	fgSizer5 = new wxFlexGridSizer( 3, 1, 0, 0 );
	fgSizer5->AddGrowableCol( 0 );
	
	fgSizer5->SetFlexibleDirection( wxBOTH );
	fgSizer5->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	fgSizer5->Add( fgSizer1, 1, wxEXPAND, 5 );

	if (gcString(szProvider).size() > 0)
	{
		gcString strProv("Warning: Staging Environment {0}. Client Updates Disabled", szProvider);
		wxStaticText *pText = new wxStaticText(this, wxID_ANY, strProv, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);

		pText->SetForegroundColour(*wxBLACK);
		pText->SetBackgroundColour(wxColour(255, 128, 64));
		pText->SetFont(wxFont(16, 70, 90, 90, false, wxEmptyString));

		fgSizer5->Add(pText, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, 10);

		fgSizer5->AddGrowableRow(2);
	}
	else
	{
		fgSizer5->AddGrowableRow(1);
	}

	fgSizer5->Add( m_sizerContent, 1, wxEXPAND, 5 );
	
	this->SetSizer( fgSizer5 );
	this->Layout();

	if (userCore)
		userCore->getAppUpdateProgEvent() += guiDelegate(this, &DesuraControl::onDesuraUpdate);

	m_bOffline = offline;
}