示例#1
0
BOOL CXTThemeManagerStyle::TakeSnapShot(CWnd* pWndOwner)
{
    CWnd *pWndParent = pWndOwner->GetParent();
    if (::IsWindow(pWndParent->GetSafeHwnd()))
    {
        if (m_bmpSnapShot.GetSafeHandle() != NULL)
            m_bmpSnapShot.DeleteObject();

        //convert our coordinates to our parent coordinates.
        CXTPWindowRect rc(pWndOwner);
        pWndParent->ScreenToClient(&rc);

        //copy what's on the parents background at this point
        CDC *pDC = pWndParent->GetDC();

        CDC memDC;
        memDC.CreateCompatibleDC(pDC);
        m_bmpSnapShot.CreateCompatibleBitmap(pDC, rc.Width(), rc.Height());

        CXTPBitmapDC bitmapDC(&memDC, &m_bmpSnapShot);
        memDC.BitBlt(0, 0, rc.Width(), rc.Height(), pDC, rc.left, rc.top, SRCCOPY);

        pWndParent->ReleaseDC(pDC);

        return TRUE;
    }

    return FALSE;
}
void CollisionTypePanel::OnPaint(wxPaintEvent& event)
{
	//Double buffered dest dc
	wxAutoBufferedPaintDC destDC(this);

	//Get renderable client rect
	wxSize clientSize = GetClientSize();
	wxRect clientRect(0, 0, clientSize.x, clientSize.y);

	//Clear dest rect
	destDC.SetBrush(*wxBLACK_BRUSH);
	destDC.DrawRectangle(clientRect);

	//No outline
	destDC.SetPen(wxNullPen);

	const int maxCollisionTypesPerLayer = 16;

	//TODO: Multiple layers
	const int numCollisionLayers = 1;

	float rectSize = (m_orientation == eVertical) ? (clientSize.y / maxCollisionTypesPerLayer) : (clientSize.x / maxCollisionTypesPerLayer);

	wxBitmap bitmap(sIconWidth, sIconHeight, wxBITMAP_SCREEN_DEPTH);
	wxMemoryDC bitmapDC(bitmap);

	for(int i = 0; i < numCollisionLayers; i++)
	{
		for(int j = 0; j < maxCollisionTypesPerLayer; j++)
		{
			int x = (m_orientation == eVertical) ? i : j;
			int y = (m_orientation == eVertical) ? j : i;

			wxBrush brush;
			CollisionType* collisionType = m_project->GetCollisionType(1 << j);
			if(collisionType)
			{
				bitmapDC.DrawBitmap(m_icons[(i * maxCollisionTypesPerLayer) + j], 0, 0);
				destDC.StretchBlit(x * rectSize, y * rectSize, rectSize, rectSize, &bitmapDC, 0, 0, sIconWidth, sIconHeight);
			}
			else
			{
				brush.SetStyle(wxBRUSHSTYLE_CROSSDIAG_HATCH);
				brush.SetColour(wxColour(100, 100, 100, 50));
				destDC.SetBrush(brush);
				destDC.DrawRectangle(x * rectSize, y * rectSize, rectSize, rectSize);
			}
		}
	}
}
示例#3
0
BOOL CXTThemeManagerStyle::DrawTransparentBack(CDC* pDC, CWnd* pWndOwner)
{
    if (::GetWindowLong(pWndOwner->GetSafeHwnd(), GWL_EXSTYLE) & WS_EX_TRANSPARENT)
    {
        // Get background.
        if (!TakeSnapShot(pWndOwner))
            return FALSE;

        CXTPClientRect rc(pWndOwner);

        CDC memDC;
        memDC.CreateCompatibleDC(pDC);

        CXTPBitmapDC bitmapDC(&memDC, &m_bmpSnapShot);
        pDC->BitBlt(0, 0, rc.Width(), rc.Height(), &memDC, 0, 0, SRCCOPY);

        return TRUE;
    }

    return FALSE;
}
示例#4
0
//
/// Removes a cel from this CelArray. If index is < 0, all cels are removed. Returns
/// true if cels are removed; false otherwise.
//
bool
TCelArray::Remove(int index)
{
  if (index >= NCelsUsed)
    return false;

  if (index < 0) {
    NCelsUsed = 0;  // Remove all
  }
  else if (index < NCelsUsed) {
    if (index < NCelsUsed-1) {
      TPoint offs(CelOffset(index,0));
      TMemoryDC bitmapDC(*Bitmap);
      bitmapDC.BitBlt(offs.x, offs.y, (NCelsUsed-index-1)*CSize.cx,
                      CSize.cy*NRows,bitmapDC, offs.x+CSize.cx, offs.y);
    }
    NCelsUsed--;
  }

  TRACEX(OwlGadget, 1, "TCelArray @" << (void*)this << " removed index 0x" << index);
  return true;
}
示例#5
0
void CamuleDlg::ShowConnectionState(bool skinChanged)
{
	static wxImageList status_arrows(16,16,true,0);
	if (!status_arrows.GetImageCount()) {
		// Generate the image list (This is only done once)
		for (int t = 0; t < 7; ++t) {
			status_arrows.Add(connImages(t));
		}
	}

	m_serverwnd->UpdateED2KInfo();
	m_serverwnd->UpdateKadInfo();


	////////////////////////////////////////////////////////////
	// Determine the status of the networks
	//
	enum ED2KState { ED2KOff = 0, ED2KLowID = 1, ED2KConnecting = 2, ED2KHighID = 3, ED2KUndef = -1 };
	enum EKadState { EKadOff = 4, EKadFW = 5, EKadConnecting = 5, EKadOK = 6, EKadUndef = -1 };

	ED2KState ed2kState = ED2KOff;
	EKadState kadState  = EKadOff;

	////////////////////////////////////////////////////////////
	// Update the label on the status-bar and determine
	// the states of the two networks.
	//
	wxString msgED2K;
	if (theApp->IsConnectedED2K()) {
		CServer* server = theApp->serverconnect->GetCurrentServer();
		if (server) {
			msgED2K = CFormat(wxT("eD2k: %s")) % server->GetListName();
		}

		if (theApp->serverconnect->IsLowID()) {
			ed2kState = ED2KLowID;
		} else {
			ed2kState = ED2KHighID;
		}
	} else if (theApp->serverconnect->IsConnecting()) {
		msgED2K = _("eD2k: Connecting");

		ed2kState = ED2KConnecting;
	} else if (thePrefs::GetNetworkED2K()) {
		msgED2K = _("eD2k: Disconnected");
	}

	wxString msgKad;
	if (theApp->IsConnectedKad()) {
		if (theApp->IsFirewalledKad()) {
			msgKad = _("Kad: Firewalled");

			kadState = EKadFW;
		} else {
			msgKad = _("Kad: Connected");

			kadState = EKadOK;
		}
	} else if (theApp->IsKadRunning()) {
		msgKad = _("Kad: Connecting");

		kadState = EKadConnecting;
	} else if (thePrefs::GetNetworkKademlia()) {
		msgKad = _("Kad: Off");
	}

	wxStaticText* connLabel = CastChild( wxT("connLabel"), wxStaticText );
	{ wxCHECK_RET(connLabel, wxT("'connLabel' widget not found")); }

	wxString labelMsg;
	if (msgED2K.Length() && msgKad.Length()) {
		labelMsg = msgED2K + wxT(" | ") + msgKad;
	} else {
		labelMsg = msgED2K + msgKad;
	}

	connLabel->SetLabel(labelMsg);
	connLabel->GetParent()->Layout();


	////////////////////////////////////////////////////////////
	// Update the connect/disconnect/cancel button.
	//
	enum EConnState {
		ECS_Unknown,
		ECS_Connected,
		ECS_Connecting,
		ECS_Disconnected
	};

	static EConnState s_oldState = ECS_Unknown;
	EConnState currentState = ECS_Disconnected;

	if (theApp->serverconnect->IsConnecting() ||
			(theApp->IsKadRunning() && !theApp->IsConnectedKad())) {
		currentState = ECS_Connecting;
	} else if (theApp->IsConnected()) {
		currentState = ECS_Connected;
	} else {
		currentState = ECS_Disconnected;
	}

	if ( (true == skinChanged) || (currentState != s_oldState) ) {
		wxWindowUpdateLocker freezer(m_wndToolbar);

		wxToolBarToolBase* toolbarTool = m_wndToolbar->RemoveTool(ID_BUTTONCONNECT);

		switch (currentState) {
			case ECS_Connecting:
				toolbarTool->SetLabel(_("Cancel"));
				toolbarTool->SetShortHelp(_("Stop the current connection attempts"));
				toolbarTool->SetNormalBitmap(m_tblist.GetBitmap(2));
				break;

			case ECS_Connected:
				toolbarTool->SetLabel(_("Disconnect"));
				toolbarTool->SetShortHelp(_("Disconnect from the currently connected networks"));
				toolbarTool->SetNormalBitmap(m_tblist.GetBitmap(1));
				break;

			default:
				toolbarTool->SetLabel(_("Connect"));
				toolbarTool->SetShortHelp(_("Connect to the currently enabled networks"));
				toolbarTool->SetNormalBitmap(m_tblist.GetBitmap(0));
		}

		m_wndToolbar->InsertTool(0, toolbarTool);
		m_wndToolbar->Realize();
		m_wndToolbar->EnableTool(ID_BUTTONCONNECT, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()) && theApp->ipfilter->IsReady());

		s_oldState = currentState;
	}


	////////////////////////////////////////////////////////////
	// Update the globe-icon in the lower-right corner.
	// (only if connection state has changed)
	//
	static ED2KState s_ED2KOldState = ED2KUndef;
	static EKadState s_EKadOldState = EKadUndef;
	if (ed2kState != s_ED2KOldState || kadState != s_EKadOldState) {
		s_ED2KOldState = ed2kState;
		s_EKadOldState = kadState;
		wxStaticBitmap* connBitmap = CastChild( wxT("connImage"), wxStaticBitmap );
		wxCHECK_RET(connBitmap, wxT("'connImage' widget not found"));

		wxBitmap statusIcon = connBitmap->GetBitmap();
		// Sanity check - otherwise there's a crash here if aMule runs out of resources
		if (statusIcon.GetRefData() == NULL) {
			return;
		}

		wxMemoryDC bitmapDC(statusIcon);

		status_arrows.Draw(kadState, bitmapDC, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT);
		status_arrows.Draw(ed2kState, bitmapDC, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT);

		connBitmap->SetBitmap(statusIcon);
	}
}