Example #1
0
LoginView::LoginView(BRect rect, char *server, char *share) :
  BView(rect, "LoginView", B_FOLLOW_ALL, B_WILL_DRAW)
{
	strcpy(resource, share);
	strcat(resource, " on ");
	strcat(resource, server);

	rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
	SetViewColor(gray);

	BRect bmpRect(0.0, 0.0, 31.0, 31.0);
	icon = new BBitmap(bmpRect, B_CMAP8);
	BMimeType mime("application/x-vnd.Teldar-FileSharing");
	mime.GetIcon(icon, B_LARGE_ICON);

	BRect r(10, 72, 240, 92);
	user = new BTextControl(r, "User", "User:"******"", NULL);
	user->SetDivider(55);
	AddChild(user);

	r.top = 97;
	r.bottom = r.top + 20;
	password = new BTextControl(r, "Password", "Password:"******"", NULL);
	password->SetDivider(55);
	password->TextView()->HideTyping(true);
	AddChild(password);

	r.Set(LOGIN_PANEL_WIDTH - 160, LOGIN_PANEL_HEIGHT - 33, LOGIN_PANEL_WIDTH - 90, LOGIN_PANEL_HEIGHT - 13);
	BButton *okBtn = new BButton(r, "OkayBtn", "Login", new BMessage(MSG_LOGIN_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	okBtn->MakeDefault(true);
	AddChild(okBtn);

	r.Set(LOGIN_PANEL_WIDTH - 80, LOGIN_PANEL_HEIGHT - 33, LOGIN_PANEL_WIDTH - 10, LOGIN_PANEL_HEIGHT - 13);
	AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_LOGIN_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));
}
Example #2
0
		InetHostView(BRect rect) :
		  BView(rect, "InetHostView", B_FOLLOW_ALL, B_WILL_DRAW)
		{
			rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
			SetViewColor(gray);

			BRect bmpRect(0.0, 0.0, 31.0, 31.0);
			icon = new BBitmap(bmpRect, B_CMAP8);
			BMimeType mime("application/x-vnd.BeServed-inetserver");
			mime.GetIcon(icon, B_LARGE_ICON);

			BRect r(10, 52, 310, 72);
			editName = new BTextControl(r, "ShareName", "Name or Address:", "", NULL);
			editName->SetDivider(90);
			AddChild(editName);

			r.Set(155, 97, 225, 117);
			BButton *okBtn = new BButton(r, "OkayBtn", "OK", new BMessage(MSG_HOST_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
			okBtn->MakeDefault(true);
			AddChild(okBtn);

			r.Set(235, 97, 310, 117);
			AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_HOST_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));

			editName->MakeFocus();
		}
Example #3
0
static Bitmap *WICDecodeImageFromStream(IStream *stream)
{
    ScopedCom com;

#define HR(hr) if (FAILED(hr)) return NULL;
    ScopedComPtr<IWICImagingFactory> pFactory;
    if (!pFactory.Create(CLSID_WICImagingFactory)) return NULL;
    ScopedComPtr<IWICBitmapDecoder> pDecoder;
    HR(pFactory->CreateDecoderFromStream(stream, NULL, WICDecodeMetadataCacheOnDemand,
                                         &pDecoder));
    ScopedComPtr<IWICBitmapFrameDecode> srcFrame;
    HR(pDecoder->GetFrame(0, &srcFrame));
    ScopedComPtr<IWICFormatConverter> pConverter;
    HR(pFactory->CreateFormatConverter(&pConverter));
    HR(pConverter->Initialize(srcFrame, GUID_WICPixelFormat32bppBGRA,
                              WICBitmapDitherTypeNone, NULL, 0.f, WICBitmapPaletteTypeCustom));

    UINT w, h;
    HR(pConverter->GetSize(&w, &h));
    double xres, yres;
    HR(pConverter->GetResolution(&xres, &yres));
    Bitmap bmp(w, h, PixelFormat32bppARGB);
    Rect bmpRect(0, 0, w, h);
    BitmapData bmpData;
    Status ok = bmp.LockBits(&bmpRect, ImageLockModeWrite, PixelFormat32bppARGB, &bmpData);
    if (ok != Ok)
        return NULL;
    HR(pConverter->CopyPixels(NULL, bmpData.Stride, bmpData.Stride * h, (BYTE *)bmpData.Scan0));
    bmp.UnlockBits(&bmpData);
    bmp.SetResolution((REAL)xres, (REAL)yres);
#undef HR

    // hack to avoid the use of ::new (because there won't be a corresponding ::delete)
    return bmp.Clone(0, 0, w, h, PixelFormat32bppARGB);
}
Example #4
0
void SharedBitmap::clearPixels(const IntRect& rect)
{
    if (!m_pixels)
        return;

    IntRect bmpRect(0, 0, width(), height());
    bmpRect.intersect(rect);
    if (is16bit()) {
        unsigned w = m_bmpInfo.paddedWidth();
        unsigned short* dst = static_cast<unsigned short*>(m_pixels);
        dst += bmpRect.y() * w + bmpRect.x();
        int wordsToSet = bmpRect.width();
        const unsigned short* dstEnd = dst + bmpRect.height() * w;
        while (dst < dstEnd) {
            wmemset(reinterpret_cast<wchar_t*>(dst), 0, wordsToSet);
            dst += w;
        }
        return;
    }

    unsigned w = width();
    unsigned* dst = static_cast<unsigned*>(m_pixels);
    dst += bmpRect.y() * w + bmpRect.x();
    int wordsToSet = bmpRect.width() * 2;
    const unsigned* dstEnd = dst + bmpRect.height() * w;
    while (dst < dstEnd) {
        wmemset(reinterpret_cast<wchar_t*>(dst), 0, wordsToSet);
        dst += w;
    }
}
Example #5
0
MyNetHeaderView::MyNetHeaderView(BRect rect)
	: BView(rect, "MyNetHeaderView", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW)
{
	rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
	SetViewColor(gray);

	BRect bmpRect(0.0, 0.0, 31.0, 31.0);
	icon = new BBitmap(bmpRect, B_CMAP8);
	BMimeType mime("application/x-vnd.Teldar-MyNetwork");
	mime.GetIcon(icon, B_LARGE_ICON);

	BRect r;
	r.Set(15, 55, 70, 75);
	openBtn = new BButton(r, "OpenBtn", "Open", new BMessage(MSG_HOST_INVOKE));
	openBtn->SetEnabled(false);
	AddChild(openBtn);

	r.Set(77, 55, 215, 75);
	hostBtn = new BButton(r, "HostBtn", "About this Computer...", new BMessage(MSG_HOST_INFO));
	hostBtn->SetEnabled(false);
	AddChild(hostBtn);

	r.Set(222, 55, 288, 75);
	AddChild(new BButton(r, "RefreshBtn", "Refresh", new BMessage(MSG_HOST_REFRESH)));

	r.Set(295, 55, 390, 75);
	AddChild(new BButton(r, "InternetBtn", "Internet Host...", new BMessage(MSG_INET_HOSTS)));
}
GroupPropertiesView::GroupPropertiesView(BRect rect, const char *name) :
    BView(rect, "GroupInfoView", B_FOLLOW_ALL, B_WILL_DRAW)
{
    newGroup = name == NULL;
    strcpy(group, newGroup ? "unknown" : name);
    getGroupDesc(group, desc, sizeof(desc));

    rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
    SetViewColor(gray);

    BRect bmpRect(0.0, 0.0, 31.0, 31.0);
    icon = new BBitmap(bmpRect, B_CMAP8);
    BMimeType mime("application/x-vnd.Teldar-Group");
    mime.GetIcon(icon, B_LARGE_ICON);

    BRect r(10, 52, 200, 72);
    editName = new BTextControl(r, "GroupName", "Name:", group, NULL);
    editName->SetDivider(70);
    editName->SetEnabled(newGroup);
    AddChild(editName);

    r.Set(10, 77, 250, 97);
    editDesc = new BTextControl(r, "Description", "Description:", desc, NULL);
    editDesc->SetDivider(70);
    AddChild(editDesc);

    r.Set(205, 320, 275, 340);
    BButton *okBtn = new BButton(r, "OkayBtn", "OK", new BMessage(MSG_GROUP_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    okBtn->MakeDefault(true);
    AddChild(okBtn);

    r.Set(285, 320, 360, 340);
    AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_GROUP_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));

    r.Set(285, 125, 360, 145);
    AddChild(new BButton(r, "AddUserBtn", "Add", new BMessage(MSG_GROUP_ADD), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));

    r.Set(285, 155, 360, 175);
    removeBtn = new BButton(r, "RemoveBtn", "Remove", new BMessage(MSG_GROUP_REMOVE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    removeBtn->SetEnabled(false);
    AddChild(removeBtn);

    // Now add the membership list.
    CLVContainerView *listContView;
    r.Set(13, 125, 280 - B_V_SCROLL_BAR_WIDTH, 305);
    listView = new SmartColumnListView(r, &listContView, NULL, B_FOLLOW_ALL_SIDES,
                                       B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE, B_SINGLE_SELECTION_LIST,
                                       false, false, true, false, B_FANCY_BORDER);

    listView->AddColumn(new CLVColumn(NULL, 20.0, CLV_LOCK_AT_BEGINNING | CLV_NOT_MOVABLE |
                                      CLV_NOT_RESIZABLE | CLV_PUSH_PASS | CLV_MERGE_WITH_RIGHT));
    listView->AddColumn(new CLVColumn("User", 85.0, CLV_SORT_KEYABLE, 50.0));
    listView->AddColumn(new CLVColumn("Full Name", 130.0, CLV_SORT_KEYABLE));

    listView->SetSelectionMessage(new BMessage(MSG_MEMBER_SELECT));
    listView->SetInvocationMessage(new BMessage(MSG_LIST_DESELECT));

    AddGroupMembers(listView);
    AddChild(listContView);
}
Example #7
0
void wxSheetCellBitmapRendererRefData::Draw(wxSheet& sheet,
        const wxSheetCellAttr& attr,
        wxDC& dc, const wxRect& rect_,
        const wxSheetCoords& coords,
        bool isSelected)
{
    wxSheetCellRendererRefData::Draw(sheet, attr, dc, rect_, coords, isSelected);

    wxRect rect(rect_);

    wxSize bmpSize;
    if (m_bitmap.Ok())
    {
        bmpSize.x = m_bitmap.GetWidth();
        bmpSize.y = m_bitmap.GetHeight();
    }

    wxSize txtSize(wxSheetCellStringRendererRefData::GetBestSize(sheet, attr, dc, coords));

    if ((txtSize.x == 0) && (bmpSize.x == 0))
        return;

    int margin = 2;

    if ((txtSize.x == 0) || (bmpSize.x == 0))
        margin = 0;


    int txt_align = attr.GetAlignment();
    int bmp_align = m_align;
    wxRect bmpRect(wxPoint(0,0), bmpSize);
    wxRect txtRect(wxPoint(0,0), txtSize);
    if (txtSize.x > 0) txtRect.Inflate(1);
    rect.Inflate(-1);
    AlignBmpTextRects(rect, bmp_align, txt_align, margin, bmpRect, txtRect);
    rect.Inflate(1);

    //dc.SetBrush(*wxTRANSPARENT_BRUSH);
    //dc.SetPen(*wxRED_PEN);
    //dc.DrawRectangle(txtRect);
    //dc.SetPen(*wxGREEN_PEN);
    //dc.DrawRectangle(bmpRect);

    if ((txtRect.width > 0) && (txtRect.height > 0))
        wxSheetCellStringRendererRefData::DoDraw(sheet, attr, dc, txtRect, coords, isSelected);

    if (m_bitmap.Ok() && (bmpRect.width > 0) && (bmpRect.height > 0))
    {
        dc.SetClippingRegion(rect);
        bmpRect.SetPosition(wxSheet::AlignInRect(m_align, bmpRect, bmpSize));
        dc.DrawBitmap(m_bitmap, bmpRect.x, bmpRect.y, true);
        dc.DestroyClippingRegion();
    }
}
ConsoleHeaderView::ConsoleHeaderView(BRect rect)
	: BView(rect, "ConsoleHeaderView", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW)
{
	rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
	SetViewColor(gray);

	BRect bmpRect(0.0, 0.0, 31.0, 31.0);
	icon = new BBitmap(bmpRect, B_CMAP8);
	BMimeType mime("application/x-vnd.BeServed-DomainManager");
	mime.GetIcon(icon, B_LARGE_ICON);
}
Example #9
0
HostInfoView::HostInfoView(BRect rect, const char *name, uint32 ipAddr)
	: BView(rect, "HostInfoView", B_FOLLOW_ALL, B_WILL_DRAW)
{
	address = ipAddr;

	hostInfo.cpus = 0;
	thread_id infoThread = spawn_thread(getHostInfo, "Get Host Info", B_NORMAL_PRIORITY, this);
	resume_thread(infoThread);

	rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
	SetViewColor(gray);

	BRect bmpRect(0.0, 0.0, 31.0, 31.0);
	icon = new BBitmap(bmpRect, B_CMAP8);

	BMimeType mime("application/x-vnd.BeServed-fileserver");
	mime.GetIcon(icon, B_LARGE_ICON);

	BRect r(40, 55, 230, 120);
	BListView *aliasList = new BListView(r, "Aliases", B_SINGLE_SELECTION_LIST);
	AddChild(new BScrollView("ScrollAliases", aliasList, B_FOLLOW_LEFT | B_FOLLOW_TOP,
		0, false, true));

	r.top = 145;
	r.bottom = 210;
	BListView *addressList = new BListView(r, "Addresses", B_SINGLE_SELECTION_LIST);
	AddChild(new BScrollView("ScrollAddresses", addressList, B_FOLLOW_LEFT | B_FOLLOW_TOP,
		0, false, true));

	r.top = 275;
	r.bottom = 305;
	r.left = 38;
	r.right = 245;
	status = new BStatusBar(r, "Connections");
	status->SetBarHeight(13.0);
	AddChild(status);

	ent = gethostbyaddr((char *) &ipAddr, sizeof(ipAddr), AF_INET);
	if (ent)
	{
		char buf[50];
		int i;
		for (i = 0; ent->h_aliases[i] != 0; i++)
			aliasList->AddItem(new BStringItem(ent->h_aliases[i]));

		for (i = 0; ent->h_addr_list[i] != 0; i++)
		{
			sprintf(buf, "%d.%d.%d.%d", (uint8) ent->h_addr_list[i][0], (uint8) ent->h_addr_list[i][1],
				(uint8) ent->h_addr_list[i][2], (uint8) ent->h_addr_list[i][3]);
			addressList->AddItem(new BStringItem(buf));
		}
	}
}
Example #10
0
		ResourceItem::ResourceItem(const char *text0, int type)
		: CLVEasyItem(0, false, false, 20.0)
		{
			// Here we're going to get the mini icon from a specific mime type
			BRect bmpRect(0.0, 0.0, 15.0, 15.0);
			BBitmap *icon = new BBitmap(bmpRect, B_CMAP8);

			BMimeType mime(type == BT_SHARED_FOLDER  ? "application/x-vnd.BeServed-fileshare"
				: "application/x-vnd.Be.printer");
			mime.GetIcon(icon, B_MINI_ICON);

			SetColumnContent(0, icon, 2.0);
			SetColumnContent(1, text0);
			SetColumnContent(2, type == BT_SHARED_FOLDER ? "Shared Files" : "Shared Printer");
		}
Example #11
0
		MountItem(const char *text0, const char *text1, const char *text2) :
		  CLVEasyItem(0, false, false, 20.0)
		{
			// Here we're going to get the mini icon from a specific mime type
			BRect bmpRect(0.0, 0.0, 15.0, 15.0);
			BBitmap *icon = new BBitmap(bmpRect, B_CMAP8);

			BMimeType mime("application/x-vnd.BeServed-fileshare");
			mime.GetIcon(icon, B_MINI_ICON);

			SetColumnContent(0, icon, 2.0);
			SetColumnContent(1, text0);
			SetColumnContent(2, text1);
			SetColumnContent(3, text2);
		}
Example #12
0
MyNetView::MyNetView(BRect rect)
	: BView(rect, "MyNetView", B_FOLLOW_TOP_BOTTOM | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW)
{
	list = new IconListView(Bounds(), "Other Computers");
	list->SetSelectionMessage(new BMessage(MSG_HOST_SELECT));
	list->SetInvocationMessage(new BMessage(MSG_HOST_INVOKE));

	// Here we're going to get the mini icon from a specific mime type
	BRect bmpRect(0.0, 0.0, 15.0, 15.0);
	fileIcon = new BBitmap(bmpRect, B_CMAP8);
	BMimeType mime("application/x-vnd.BeServed-fileserver");
	mime.GetIcon(fileIcon, B_MINI_ICON);

	thread_id hostThread = spawn_thread(getHosts, "Get Hosts", B_NORMAL_PRIORITY, this);
	resume_thread(hostThread);

	AddChild(new BScrollView("scroll", list, B_FOLLOW_ALL, 0, false, true));
}
Example #13
0
Bitmap *ImageFromData(const char *data, size_t len)
{
    int w, h;
    if (!WebPGetInfo((const uint8_t *)data, len, &w, &h))
        return nullptr;

    Bitmap bmp(w, h, PixelFormat32bppARGB);
    Rect bmpRect(0, 0, w, h);
    BitmapData bmpData;
    Status ok = bmp.LockBits(&bmpRect, ImageLockModeWrite, PixelFormat32bppARGB, &bmpData);
    if (ok != Ok)
        return nullptr;
    if (!WebPDecodeBGRAInto((const uint8_t *)data, len, (uint8_t *)bmpData.Scan0, bmpData.Stride * h, bmpData.Stride))
        return nullptr;
    bmp.UnlockBits(&bmpData);

    // hack to avoid the use of ::new (because there won't be a corresponding ::delete)
    return bmp.Clone(0, 0, w, h, PixelFormat32bppARGB);
}
Example #14
0
FileShareView::FileShareView(BRect rect, const char *name, uint32 ipAddr)
	: BView(rect, "FileShareView", B_FOLLOW_ALL, B_WILL_DRAW)
{
	strcpy(host, name);
	address = ipAddr;

	list = new IconListView(Bounds(), "File Shares");
	list->SetSelectionMessage(new BMessage(MSG_SHARE_SELECT));
	list->SetInvocationMessage(new BMessage(MSG_SHARE_INVOKE));

	// Here we're going to get the mini icon from a specific mime type
	BRect bmpRect(0.0, 0.0, 15.0, 15.0);
	fileIcon = new BBitmap(bmpRect, B_CMAP8);
	BMimeType mime("application/x-vnd.BeServed-fileshare");
	mime.GetIcon(fileIcon, B_MINI_ICON);
	printerIcon = new BBitmap(bmpRect, B_CMAP8);
	mime.SetTo("application/x-vnd.Be.printer");
	mime.GetIcon(printerIcon, B_MINI_ICON);

	thread_id shareThread = spawn_thread(getShares, "Get Shares", B_NORMAL_PRIORITY, this);
	resume_thread(shareThread);

	AddChild(new BScrollView("scroll", list, B_FOLLOW_ALL, 0, false, true));
}
Example #15
0
//@mFunc draws the listbox items in their proper state
void CQSLItemList::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

	QSLItemData itemData;
	GetItemData( lpDrawItemStruct->itemID, itemData );
	
#ifdef USECACHE
	RImage* pImage = GetCachedBitmap( lpDrawItemStruct->itemID ) ;
#else
	RImage* pImage = itemData.GetImage();

	if (!itemData.m_pImage)
	{
		itemData.m_pImage = pImage;
		SetItemData( lpDrawItemStruct->itemID, itemData );
	}

//	HBITMAP hBitmap = itemData.m_hBitmap ;
//	HPALETTE hPalette = itemData.m_hPalette ;
	
//	if (!itemData.m_pImage)
//	{
//		hBitmap = itemData.m_hBitmap = 
//			LoadBitmapPreview( lpDrawItemStruct->itemID, &itemData.m_hPalette ) ;
//		hPalette = itemData.m_hPalette;
//
//		// Save the new data into the control
//		SetItemData( lpDrawItemStruct->itemID, itemData );
//	}
//
//	// If we have a palette with the bitmap, realize it into the DC prior to painting.
//	if (hPalette != NULL)
//	{
//		CPalette palBitmap;
//		palBitmap.Attach( hPalette );
//		CPalette *pOldPal = pDC->SelectPalette( &palBitmap, TRUE );
//		pDC->RealizePalette();
//		pDC->SelectPalette( pOldPal, TRUE );
//		palBitmap.Detach();
//	}
#endif

	BITMAP  bm= { 0, 0, 0, 0, 0, 0, NULL };
	HBITMAP hBitmap = NULL;
	
	if (pImage)
	{
		hBitmap = (HBITMAP) pImage->GetSystemHandle();
		::GetObject( hBitmap, sizeof( bm ), &bm );
	}

	// Determine colors to use for drawing text and selection
	//
	COLORREF crFillColor = GetSysColor( COLOR_WINDOW ) ;
	COLORREF crTextColor = GetSysColor( COLOR_WINDOWTEXT ) ;

	if (lpDrawItemStruct->itemState & ODS_SELECTED)
	{
		crFillColor = GetSysColor( COLOR_HIGHLIGHT ) ;
		crTextColor = GetSysColor( COLOR_HIGHLIGHTTEXT ) ;
	}

	// Handle drawing according to action
	//

	// Setup DC
	COLORREF oldTextColor = pDC->SetTextColor( crTextColor );
	COLORREF oldBkColor   = pDC->SetBkColor( crFillColor );
	CFont* pOldFont = pDC->SelectObject( GetParent()->GetFont() );

	// Determine location to draw bitmap.  This information 
	// is needed for all drawing modes, so might as well
	// just determine it once, and in one place.
	CSize	  szExtent = pDC->GetTextExtent( itemData.m_strDesc );

	RIntRect  cellRect( lpDrawItemStruct->rcItem );
	cellRect.Inset( RIntSize( 4, 4 ) );
	cellRect.m_Bottom -= szExtent.cy + 2; // + 2 is for spacing between graphic & text

	RIntRect  imgRect( 0, 0, bm.bmWidth - 1, bm.bmHeight - 1 );
	imgRect.ShrinkToFit( cellRect );
	imgRect.CenterRectInRect( cellRect );

	CSize  szImage( imgRect.Width(), imgRect.Height() );
//	CPoint centerPt( cellRect.CenterPoint() );
//	CPoint ptTopLeft( centerPt.x - szImage.cx / 2, centerPt.y - szImage.cy / 2 - 2 );

	switch (lpDrawItemStruct->itemAction)
	{
	case ODA_DRAWENTIRE:
		{
		CDC memDC;
		memDC.CreateCompatibleDC( pDC );

		// Get the bitmap
		CBitmap* pBmp    = CBitmap::FromHandle( hBitmap );
		CBitmap* pOldBmp = memDC.SelectObject( pBmp );

		pDC->StretchBlt( imgRect.m_Left, imgRect.m_Top, imgRect.Width(), imgRect.Height(), 
			&memDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY );

		memDC.SelectObject( pOldBmp );

		if (!(lpDrawItemStruct->itemState & ODS_SELECTED))
		{
			break ;
		}

		// Fall through
		}

	case ODA_SELECT:
		{
		// Draw/Clear the highlight rect
//		CRect bmpRect( ptTopLeft.x, ptTopLeft.y, ptTopLeft.x + bm.bmWidth, ptTopLeft.y + bm.bmHeight);
		
		CRect bmpRect( imgRect );
		bmpRect.InflateRect( 2, 2 );

		CPen pen( PS_SOLID, 2, crFillColor );
		CPen* pOldPen = pDC->SelectObject( &pen );

		pDC->MoveTo( bmpRect.left, bmpRect.top );
		pDC->LineTo( bmpRect.right, bmpRect.top );
		pDC->LineTo( bmpRect.right, bmpRect.bottom );
		pDC->LineTo( bmpRect.left, bmpRect.bottom );
		pDC->LineTo( bmpRect.left, bmpRect.top );
		pDC->SelectObject( pOldPen );
		}

	} // switch

	// Draw the text
	CPoint ptText( cellRect.m_Left + (cellRect.Width() - szExtent.cx) / 2, cellRect.m_Bottom + 4 );
	pDC->TextOut( ptText.x, ptText.y, itemData.m_strDesc );

//	pDC->DrawText( itemData.m_strDesc, &textRect, DT_CALCRECT | DT_SINGLELINE  );
//	textRect.OffsetRect( -textRect.Width() / 2, 2 );
//	pDC->DrawText( itemData.m_strDesc, &textRect, DT_CENTER | DT_VCENTER );

	// restore DC
	pDC->SelectObject( pOldFont );
	pDC->SetTextColor( oldTextColor );
	pDC->SetBkColor( oldBkColor );
}
Example #16
0
Rect ToolFilter::applyFilter(ToolFilter::Info *fi, Rect *clip, bool once)
{
	Core::self->getGui()->setCursor(CURSOR_WAIT);

	int w = (int)( floor(fi->matrix.mxw / 2.0) );
	int h = (int)( floor(fi->matrix.mxh / 2.0) );

	int exw = fi->matrix.mxw + 1;
	int exh = fi->matrix.mxh + 1;

	UINT *src0, *bmp0;
	BitmapData srcData, bmpData;

	Bitmap *src = fi->bmpSource;
	Rect srcRect(0,0,src->GetWidth(),src->GetHeight());

	if( clip == NULL ){
		clip = &srcRect;
	}
	else {
		int maxx = max(clip->X - exw,0);
		int maxy = max(clip->Y - exh,0);
		int ext = 2;

		srcRect = Rect(
			maxx,
			maxy,
			min(clip->Width + ext * exw,(int)src->GetWidth() - maxx),
			min(clip->Height + ext * exh,(int)src->GetHeight() - maxy)
			);
	}

	int bmpWidth = clip->Width;
	int bmpHeight = clip->Height;
	if( fi->smooth == true ){
		bmpWidth += 4 * exw;
		bmpHeight += 4 * exh;
	}

	Bitmap *bmp = new Bitmap(
		bmpWidth,
		bmpHeight,
		src->GetPixelFormat()
		);
	Rect bmpRect(0,0,bmp->GetWidth(),bmp->GetHeight());

	src->LockBits(
			&srcRect,
			ImageLockModeRead,
			src->GetPixelFormat(),
			&srcData
			);
	bmp->LockBits(
			&bmpRect,
			ImageLockModeWrite,
			bmp->GetPixelFormat(),
			&bmpData
			);
	src0 = (UINT *)srcData.Scan0;
	bmp0 = (UINT *)bmpData.Scan0;

	int srcWidth = srcData.Width;
	int srcHeight = srcData.Height;

	for( int x = 0; x < bmpWidth; x++ ){
		for( int y = 0; y < bmpHeight; y++ ){
			bmp0[y * bmpData.Stride / 4 + x] = ToolFilter::filterPixel(fi,&srcData,x,y,w,h); 
		}
	}
	if( fi->edgeTrace == true && fi->filterValue > 0 ){
		ToolFilter::Matrix oldMatrix = fi->matrix;

		fi->matrix = ToolFilter::allocMatrixEdgetrace(fi->filterValue,1);
		for( int x = 0; x < bmpWidth; x++ ){
			for( int y = 0; y < bmpHeight; y++ ){
				bmp0[y * bmpData.Stride / 4 + x] += ToolFilter::filterPixel(fi,&srcData,x,y,w,h); 
			}
		}
		fi->matrix = ToolFilter::allocMatrixEdgetrace(fi->filterValue,2);
		for( int x = 0; x < bmpWidth; x++ ){
			for( int y = 0; y < bmpHeight; y++ ){
				bmp0[y * bmpData.Stride / 4 + x] += ToolFilter::filterPixel(fi,&srcData,x,y,w,h); 
			}
		}

		fi->matrix = oldMatrix;
	}
	src->UnlockBits(&srcData);
	bmp->UnlockBits(&bmpData);

	fi->bmpEffect = bmp;

	int refils = 0;
	switch(fi->filterId){
		case ID_FILTER_SHARPEN:
			if( fi->filterValue > SHARPENMAX/2 )
				refils = fi->filterValue - SHARPENMAX/2;
			break;
		case ID_FILTER_GAUSSIANBLUR:
			if( fi->filterValue > GAUSSMAX )
				refils = fi->filterValue - GAUSSMAX;
			break;
	}
	Bitmap *source = fi->bmpSource;

	if( refils > 0 && once == false ){
		for(int i = 0; i < refils; i++ ){
			fi->bmpSource = fi->bmpEffect;
			fi->bmpEffect = NULL;

			ToolFilter::applyFilter(fi,NULL,true);

			delete fi->bmpSource;
		}
	}
	fi->bmpSource = source;

	Rect gridClip(clip->X,clip->Y,clip->Width,clip->Height);

	clip->X -= exw;
	clip->Y -= exh;

	Core::self->getGui()->setCursor();

	return gridClip;
}
Example #17
0
void CWndImage::SetSourceRect(RECT const & r)
{
  CRect bmpRect(0,0, m_bmpSize.cx, m_bmpSize.cy);
  m_srcRect.IntersectRect(&r, &bmpRect);
  Recalc();
}