示例#1
0
文件: zoomview.cpp 项目: PyroOS/Pyro
/*
 * Creates a new (empty) pixel buffer, and fills it.
 */
void ZoomView::resizeZoom()
{
	Rect		bounds = GetBounds();

	if(m_Bitmap) {
		// If the window is smaller, there's no need
		// to reallocate the bitmap.
		// Comment out this to save memory. (by freeing unused
		// bitmap space, though it will make resizing slower).
		if(bounds.Width() <= m_Bitmap->GetBounds().Width() &&
		   bounds.Height() <= m_Bitmap->GetBounds().Height()) {
			return;	// No reallocation necessary
		}

		delete m_Bitmap;
	}

	m_Bitmap = new Bitmap((int)(bounds.Width())+1, (int)(bounds.Height())+1, m_ColSpace, Bitmap::SHARE_FRAMEBUFFER);
	// Note: The +1's are necessary, since the Bitmap constructor creates
	// a bitmap that is 1 pixel smaller in both directions, for some reason.
	// (Bitmap->GetBounds().Width() returns 1 less than the width you ask
	// for, same with ...Height()).

	fetchPixels();
}
示例#2
0
/*----------------------------------------------------------------------------------------------
	Move/resize the edit and button windows.
	@param rcClip
----------------------------------------------------------------------------------------------*/
void AfDeFeEdBoxBut::MoveWnd(const Rect & rcClip)
{
	::MoveWindow(m_hwnd, rcClip.left + 2, rcClip.top + 1,
		rcClip.Width() - 2, rcClip.Height() - 1, true);
	Rect rc;
	::GetClientRect(m_hwnd, &rc);
	rc.left = rc.right - 16;
	rc.bottom = rc.top + Min((int)rc.bottom - (int)rc.top, (int)kdxpButtonHeight);
	::MoveWindow(m_hwndButton, rc.left, rc.top, rc.Width(), rc.Height(), true);

#if 1-1
	// Now resize the edit window so it doesn't actually include the button, just for laughs.
	::MoveWindow(m_hwnd, rcClip.left + 2, rcClip.top + 1,
		rcClip.Width() - 20, rcClip.Height() - 1,	// width - 2 (for margin) - 18 (for button)
		true);
#endif
#if 99-99
	Rect rcEditNew;
	Rect rcEditNewClient;
	Rect rcBut;
	Rect rcButClient;
	::GetWindowRect(m_hwnd, &rcEditNew);
	::GetClientRect(m_hwnd, &rcEditNewClient);
	::GetWindowRect(m_hwndButton, &rcBut);
	::GetClientRect(m_hwndButton, &rcButClient);
#endif
}
示例#3
0
CliWindow::CliWindow (const Rect& bounds)
	: _offset(bounds.TopLeft())
	, _background(BLACK)
	, _foreground(WHITE)
	, _canvas(new uint16_t[bounds.Width()*bounds.Height()], bounds.Width(), bounds.Height())
{
}
			void GuiTableComposition::UpdateCellBounds()
			{
				rowOffsets.Resize(rows);
				rowSizes.Resize(rows);
				columnOffsets.Resize(columns);
				columnSizes.Resize(columns);

				vint rowTotal = (rows - 1) * cellPadding;
				vint columnTotal = (columns - 1) * cellPadding;
				vint rowTotalWithPercentage = rowTotal;
				vint columnTotalWithPercentage = columnTotal;

				UpdateCellBoundsInternal(
					rowSizes,
					rowTotal,
					rowTotalWithPercentage,
					rowOptions,
					&GuiTableComposition::rows,
					&GuiTableComposition::columns,
					&Y,
					&RL,
					&RS,
					&First,
					&Second,
					1
				);
				UpdateCellBoundsInternal(
					columnSizes,
					columnTotal,
					columnTotalWithPercentage,
					columnOptions,
					&GuiTableComposition::columns,
					&GuiTableComposition::rows,
					&X,
					&CL,
					&CS,
					&Second,
					&First,
					1
				);

				Rect area = GetCellArea();
				UpdateCellBoundsPercentages(rowSizes, rowTotal, area.Height(), rowOptions);
				UpdateCellBoundsPercentages(columnSizes, columnTotal, area.Width(), columnOptions);
				rowExtending = UpdateCellBoundsOffsets(rowOffsets, rowSizes, area.Height());
				columnExtending = UpdateCellBoundsOffsets(columnOffsets, columnSizes, area.Width());

				for (vint i = 0; i < rows; i++)
				{
					for (vint j = 0; j < columns; j++)
					{
						vint index = GetSiteIndex(rows, columns, i, j);
						cellBounds[index] = Rect(Point(columnOffsets[j], rowOffsets[i]), Size(columnSizes[j], rowSizes[i]));
					}
				}

				tableContentMinSize = Size(columnTotalWithPercentage, rowTotalWithPercentage);
				InvokeOnCompositionStateChanged();
			}
示例#5
0
	virtual void Paint(Draw& w, const Rect& r, const Value& q,
		               Color ink, Color paper, dword style) const
	{
		Font fnt = Font(q, r.Height() - 2);
		String txt = Font::GetFaceName(q);
		w.DrawRect(r, paper);
		w.DrawText(r.left + 2, r.top + (r.Height() - GetTextSize(txt, fnt).cy) / 2, txt, fnt, ink);
	}
示例#6
0
	virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const {
		ValueArray va = q;
		String txt = va[0];
		Image icon = va[1];
		w.DrawRect(r, paper);
		w.DrawImage(r.left, r.top + (r.Height() - 16) / 2, IsNull(icon) ? IdeImg::Package() : icon);
		w.DrawText(r.left + 20, r.top + (r.Height() - Draw::GetStdFontCy()) / 2, txt, fnt, ink);
	}
void Checkbox::RenderCheck(Rect& rectArea)
{
    Rect rectBox = rectArea;

    int iBoxMargin = int(rectArea.Height() * 0.2);
    int iBoxMarginRight = int(rectArea.Height() * 0.8 * 0.75);

    rectBox.Left(rectBox.Left() + iBoxMargin);
    rectBox.Right(rectBox.Left() + iBoxMarginRight);
    rectBox.Top(rectBox.Top() + iBoxMargin);
    rectBox.Bottom(rectBox.Bottom() - iBoxMargin);

    OpenGL::PushedAttributes attr(GL_ENABLE_BIT | GL_LINE_BIT | GL_POINT_BIT);

    glDisable(GL_TEXTURE_2D);
    glEnable(GL_LINE_SMOOTH);
    glEnable(GL_POINT_SMOOTH);

    Color cBox = GetAttrAsColor(CheckboxAttr::BoxColor);
    glColor4ubv(cBox.m_color);
    glLineWidth(2.0);
    glBegin(GL_LINE_LOOP);
    glVertex2i(rectBox.Left(), rectBox.Bottom());
    glVertex2i(rectBox.Right(), rectBox.Bottom());
    glVertex2i(rectBox.Right(), rectBox.Top());
    glVertex2i(rectBox.Left(), rectBox.Top());
    glEnd();

    if (IsChecked())
    {
        double iCheckUnit = rectBox.Height() * 0.1;

        Point point1(int(rectBox.Left() + 3 * iCheckUnit), int(rectBox.Bottom() - 6 * iCheckUnit));
        Point point2(int(rectBox.Left() + 6 * iCheckUnit), int(rectBox.Bottom() - 3 * iCheckUnit));
        Point point3(int(rectBox.Left() + 11* iCheckUnit), int(rectBox.Bottom() - 11* iCheckUnit));

        Color cCheck = GetAttrAsColor(CheckboxAttr::CheckColor);
        glColor4ubv(cCheck.m_color);
        glLineWidth(4.0);
        glBegin(GL_LINES);
        glVertex2i(point1.X(), point1.Y());
        glVertex2i(point2.X(), point2.Y());
        glVertex2i(point2.X(), point2.Y());
        glVertex2i(point3.X(), point3.Y());
        glEnd();

        glPointSize(3.0);
        glBegin(GL_POINTS);
        glVertex2i(point1.X(), point1.Y());
        glVertex2i(point2.X(), point2.Y());
        glVertex2i(point3.X(), point3.Y());
        glEnd();
    }

    // adjust rect for size of checkbox
    int iOffset = int(rectArea.Height() * 1.1);
    rectArea.Left(rectArea.Left() + iOffset);
}
示例#8
0
//-----------------------------------------------------------------------------------------------------------------------------------------------------
Ptr<Image> Context::ReadFrameBuffer(Rect R)
{
  Image* pImage = new Image( R.Width(), R.Height() );

	glReadPixels( R.left, R.top, R.Width(), R.Height(), GL_BGRA, GL_UNSIGNED_BYTE, (Color*)(*pImage) );
  VerifyOpenGLErrorState();
  
  return pImage;
}
示例#9
0
//-----------------------------------------------------------------------------------------------------------------------------------------------------
Ptr<ImageF> Context::ReadFloatFrameBuffer(Rect R)
{
  ImageF* pImage = new ImageF( R.Width(), R.Height() );

	glReadPixels( R.left, R.top, R.Width(), R.Height(), GL_RGBA, GL_FLOAT, (ColorF*)(*pImage) );
  VerifyOpenGLErrorState();
 
  return pImage;
}
示例#10
0
LRESULT     Trackbar::OnCustomDraw(NMCUSTOMDRAW& customDraw)
{
    switch (customDraw.dwDrawStage)
    {
    case CDDS_PREPAINT:
        return CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTERASE;
    }

    switch (customDraw.dwItemSpec)
    {
    case TBCD_CHANNEL:  // seems to be the most reliable place to draw the background
        {
            Rect clientRect = this->ClientRect();
            if (::GetBkMode(customDraw.hdc) != TRANSPARENT)
            {
                HBRUSH brush = ::CreateSolidBrush(Color::SystemColor(COLOR_BTNFACE));
                ::FillRect(customDraw.hdc, &(RECT)clientRect, brush);
                ::DeleteObject(brush);
            }
            
            // windows doesn't automatically center the track vertically if no ticks
            // are visible on the trackbar.
            if (this->tickFrequency == 0)
            {
                Rect channelRect = customDraw.rc;
                //             
                channelRect.location.y = (clientRect.Height() - channelRect.Height()) / 2;
                customDraw.rc = channelRect;
            }

            short topOffset = this->trackHeight / 2;
            customDraw.rc.top -= (topOffset);
            customDraw.rc.bottom += (this->trackHeight - topOffset);
        }
        break;
    case TBCD_THUMB:
        {
            // center the thumb vertically if no ticks are visible
            if (this->tickFrequency == 0)
            {
                Rect clientRect = this->ClientRect();
                Rect channelRect = customDraw.rc;

                channelRect.location.y = (clientRect.Height() - channelRect.Height()) / 2;
                customDraw.rc = channelRect;
            }
        }

        break;
    case TBCD_TICS:
        break;
    }

    return CDRF_DODEFAULT;
}
			void GuiSolidLabelElementRenderer::Render(Rect bounds)
			{
				if(cairoContext)
				{
					cairo_save(cairoContext);
					Color color = element->GetColor();
					FontProperties font = element->GetFont();

					cairo_set_source_rgba(cairoContext, 
							1.0 * color.r / 255, 
							1.0 * color.g / 255, 
							1.0 * color.b / 255,
							1.0 * color.a / 255
							);

					if(element->GetWrapLine()) pango_layout_set_width(layout, bounds.Width() * PANGO_SCALE);
					pango_cairo_update_layout(cairoContext, layout);
					int layoutWidth, layoutHeight;
					int plotX1, plotY1;

					pango_layout_get_pixel_size( layout, &layoutWidth, &layoutHeight);
					switch(element->GetHorizontalAlignment())
					{
					case Alignment::Left:
						plotX1 = bounds.x1;
						break;
					case Alignment::Center:
						plotX1 = bounds.x1 + (bounds.Width() - layoutWidth) / 2;
						break;
					case Alignment::Right:
						plotX1 = bounds.x1 + (bounds.Width() - layoutWidth);
						break;
					}

					switch(element->GetVerticalAlignment())
					{
					case Alignment::Top:
						plotY1 = bounds.y1;
						break;
					case Alignment::Center:
						plotY1 = bounds.y1 + (bounds.Height() - layoutHeight) / 2;
						break;
					case Alignment::Bottom:
						plotY1 = bounds.y1 + (bounds.Height() - layoutHeight);
						break;
					}

					cairo_move_to(cairoContext, plotX1, plotY1);

					pango_cairo_layout_path(cairoContext, layout);
					cairo_fill(cairoContext);

					cairo_restore(cairoContext);
				}
			}
示例#12
0
void Dow::Handle::CenterOverScreen (int xOff, int yOff)
{
	Dow::Handle hScreen (GetDesktopWindow ());
	Rect screenRect;
	hScreen.GetWindowRect (screenRect);
	Rect myRect;
	GetWindowRect (myRect);
	int x = xOff + (screenRect.Width () - myRect.Width ()) / 2;
	int y = yOff + (screenRect.Height () - myRect.Height ()) / 2;
	MoveDelayPaint (x, y, myRect.Width (), myRect.Height ());
}
示例#13
0
void ListControl::OnPaint(DibBitmap *pbm)
{
	Rect rcForm;
	m_pfrm->GetRect(&rcForm);

	Rect rc;
    Rect rcScrollPos;
	GetSubRects(&rc, NULL, NULL, &rcScrollPos);
	rc.Offset(rcForm.left, rcForm.top);
	rcScrollPos.Offset(rcForm.left, rcForm.top);

	Size sizArrow;
	s_ptbmScrollUpUp->GetSize(&sizArrow);

	int cliDraw = GetVisibleItemCount();
	int cx = rc.Width();
	int x = rc.left;
	int y = rc.top;
	int xArrow = rc.left + ((cx - sizArrow.cx) / 2);

	// Walk through the list to the item that should be displayed first

	ListItem *pli;
	int ili = 0;
	for (pli = m_pliFirst; ili < m_iliTop; pli = pli->pliNext, ili++);

    int cliDrawn = 0;
	for (; pli != NULL && cliDraw > 0;
                pli = pli->pliNext, y += m_cyItem, cliDraw--) {
		DrawItem(pbm, pli, x, y, cx, m_cyItem);
        cliDrawn++;
    }

    bool fNeedsScrollUp = NeedsScrollUpArrow();
    bool fNeedsScrollDown = NeedsScrollDownArrow();

    if (m_wf & kfLstcScrollPosition) {
        if (fNeedsScrollUp || fNeedsScrollDown) {
            pbm->Shadow(rcScrollPos.left, rcScrollPos.top, rcScrollPos.Width(),
                    rcScrollPos.Height());
            pbm->Shadow(rcScrollPos.left, rcScrollPos.top, rcScrollPos.Width(),
                    rcScrollPos.Height());
            int y1 = rcScrollPos.Height() * m_iliTop / m_cli;
            int y2 = rcScrollPos.Height() * (m_iliTop + cliDrawn) / m_cli;
            pbm->Fill(rcScrollPos.left, rcScrollPos.top + y1,
                    rcScrollPos.Width(), y2 - y1,
#if 0
                    m_fPenDown ? GetColor(kiclrWhite) :
                    GetColor(m_iclrScrollPos));
#else
                    GetColor(m_iclrScrollPos));
#endif
        }
    } else {
示例#14
0
	virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const {
		ValueArray va = q;
		String txt = va[0];
		Image icon = va[1];
		if(IsNull(icon))
			icon = IdeImg::Package();
		else
			icon = DPI(icon, 16);
		w.DrawRect(r, paper);
		w.DrawImage(r.left, r.top + (r.Height() - icon.GetHeight()) / 2, icon);
		w.DrawText(r.left + Zx(20), r.top + (r.Height() - Draw::GetStdFontCy()) / 2, txt, fnt, ink);
	}
示例#15
0
   static void Apply( GenericImage<P>& image, const FFTConvolution& F )
   {
      Rect r = image.SelectedRectangle();

      if ( F.m_h.IsNull() )
         if ( !F.m_filter.IsNull() )
            F.m_h = Initialize( *F.m_filter, r.Width(), r.Height(), F.IsParallelProcessingEnabled(), F.MaxProcessors() );
         else
            F.m_h = Initialize( F.m_image, r.Width(), r.Height(), F.IsParallelProcessingEnabled(), F.MaxProcessors() );

      Convolve( image, *F.m_h, F.IsParallelProcessingEnabled(), F.MaxProcessors() );
   }
示例#16
0
void Ctrl::Create0(Ctrl::CreateBox *cr)
{
	GuiLock __;
	ASSERT(IsMainThread());
	LLOG("Ctrl::Create(parent = " << (void *)parent << ") in " <<UPP::Name(this) << BeginIndent);
	ASSERT(!IsChild() && !IsOpen());
	Rect r = GetRect();
	AdjustWindowRectEx(r, cr->style, FALSE, cr->exstyle);
	isopen = true;
	top = new Top;
	ASSERT(!cr->parent || IsWindow(cr->parent));
	if(!IsWinXP())
		cr->dropshadow = false;
#ifdef PLATFORM_WINCE
		if(parent)
			top->hwnd = CreateWindowExW(cr->exstyle,
			                            cr->savebits ? cr->dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W"
			                                         : cr->dropshadow ? L"UPP-CLASS-DS-W"    : L"UPP-CLASS-W",
			                            L"", cr->style, r.left, r.top, r.Width(), r.Height(),
			                            cr->parent, NULL, hInstance, this);
		else
			top->hwnd = CreateWindowW(L"UPP-CLASS-W",
			                          L"", WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
			                          cr->parent, NULL, hInstance, this);
#else
	if(IsWinNT() && (!cr->parent || IsWindowUnicode(cr->parent)))
		top->hwnd = CreateWindowExW(cr->exstyle,
		                            cr->savebits ? cr->dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W"
		                                         : cr->dropshadow ? L"UPP-CLASS-DS-W"    : L"UPP-CLASS-W",
		                            L"", cr->style, r.left, r.top, r.Width(), r.Height(),
		                            cr->parent, NULL, hInstance, this);
	else
		top->hwnd = CreateWindowEx(cr->exstyle,
		                           cr->savebits ? cr->dropshadow ? "UPP-CLASS-SB-DS-A" : "UPP-CLASS-SB-A"
		                                        : cr->dropshadow ? "UPP-CLASS-DS-A"    : "UPP-CLASS-A",
		                           "", cr->style, r.left, r.top, r.Width(), r.Height(),
		                           cr->parent, NULL, hInstance, this);
#endif

	inloop = false;

	ASSERT(top->hwnd);

	::ShowWindow(top->hwnd, visible ? cr->show : SW_HIDE);
//	::UpdateWindow(hwnd);
	StateH(OPEN);
	LLOG(EndIndent << "//Ctrl::Create in " <<UPP::Name(this));
	RegisterDragDrop(top->hwnd, (LPDROPTARGET) (top->dndtgt = NewUDropTarget(this)));
	CancelMode();
	RefreshLayoutDeep();
}
示例#17
0
void StdDisplayClass::Paint0(Draw& w, const Rect& r, const Value& q,
                             Color ink, Color paper, dword s) const {
	LLOG("StdDisplay::Paint0: " << q << " ink:" << ink << " paper:" << paper);
	WString txt;
	Font font = StdFont();
	int a = align;
	int x = r.left;
	int width = r.GetWidth();
	if(IsType<AttrText>(q)) {
		const AttrText& t = ValueTo<AttrText>(q);
		txt = t.text;
		font = t.font;
		if(!IsNull(t.paper))
			paper = t.paper;
		if(!IsNull(t.ink))
			ink = t.ink;
		if(!IsNull(t.normalink) && !(s & (CURSOR|SELECT|READONLY)))
			ink = t.normalink;
		if(!IsNull(t.normalpaper) && !(s & (CURSOR|SELECT|READONLY)))
			paper = t.normalpaper;
		if(!IsNull(t.align))
			a = t.align;
		if(!IsNull(t.img)) {
			Size isz = t.img.GetSize();
			w.DrawImage(x, r.top + max((r.Height() - isz.cy) / 2, 0), t.img);
			x += isz.cx + t.imgspc;
		}
	}
	else
		txt = IsString(q) ? q : StdConvert().Format(q);
	Size tsz = GetTLTextSize(txt, font);
	if(a == ALIGN_RIGHT)
		x = r.right - tsz.cx;
	if(a == ALIGN_CENTER)
		x += (width - tsz.cx) / 2;
	int tcy = GetTLTextHeight(txt, font);
	int tt = r.top + max((r.Height() - tcy) / 2, 0);
	if(tsz.cx > width) {
		Size isz = DrawImg::threedots().GetSize();
		int wd = width - isz.cx;
		w.Clip(r.left, r.top, wd, r.GetHeight());
		DrawTLText(w, x, tt, width, txt, font, ink);
		w.End();
		w.DrawImage(r.left + wd, tt + font.Info().GetAscent() - isz.cy, DrawImg::threedots(), ink);
	}
	else
		DrawTLText(w, x, tt, width, txt, font, ink);
}
示例#18
0
文件: HexView.cpp 项目: PyroOS/Pyro
void HexView::SizeHScrollBar(const Rect &cOrigFrame, Rect *pcFrame)
{
	Point cIVSize = m_pcInner->GetPreferredSize(false);
	Point cHSBSize = m_pcHScroll->GetPreferredSize(false);
	
	if( cIVSize.x <= pcFrame->Width() )
	{
		if( m_pcHScroll->IsVisible() )
			m_pcHScroll->Hide();
	}
	else
	{
		m_pcHScroll->SetMinMax(0, cIVSize.x - pcFrame->Width());
		m_pcHScroll->SetProportion(pcFrame->Width() / cIVSize.x);
		m_pcHScroll->SetSteps(1, cIVSize.x / 10);
		if( ! m_pcHScroll->IsVisible() )
			m_pcHScroll->Show(true);

		if( pcFrame->Height() == cOrigFrame.Height() )
		{
			pcFrame->bottom -= cHSBSize.y;
			
			SizeVScrollBar(cOrigFrame, pcFrame);
		}
	}
}
示例#19
0
/*----------------------------------------------------------------------------------------------
	This "subclasses" an existing edit control. It actually destroys the old control and
	creates a new view window. It copies the text, style, position, and z-order of the original
	control.
	@param dwStyleExtra additional styles to AND with those from the dialog resource.
----------------------------------------------------------------------------------------------*/
void TssEdit::SubclassEdit(HWND hwndDlg, int cid, ILgWritingSystemFactory * pwsf, int ws,
	DWORD dwStyleExtra)
{
	AssertPtr(pwsf);
	m_fInDialog = true;
	// Set margins to leave room for sunken border effect, plus one pixel white space.
	// Yet one more pixel on the leading edge keeps the IP clear of the border.
	SIZE sizeMargins = { ::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE) };
	m_dxpMarginLeft = sizeMargins.cx + 2;
	m_dxpMarginRight = sizeMargins.cx + 1;
	m_dypMarginTop = sizeMargins.cy + 1;

	HWND hwndOld = ::GetDlgItem(hwndDlg, cid);

	// Get window coordinates relative to the dialog.
	Rect rc;
	::GetWindowRect(hwndOld, &rc);
	::MapWindowPoints(NULL, hwndDlg, (POINT *)&rc, 2);

	const int kcchMax = 2048;
	achar rgch[kcchMax];
	::GetDlgItemText(hwndDlg, cid, rgch, kcchMax);

	// Get information on old window.
	HWND hwndPrev = ::GetWindow(hwndOld, GW_HWNDPREV);
	DWORD dwStyleEx = ::GetWindowLong(hwndOld, GWL_EXSTYLE);
	DWORD dwStyle = ::GetWindowLong(hwndOld, GWL_STYLE);
	::DestroyWindow(hwndOld);

	// Create the new window and set the styles appropriately.
	Create(hwndDlg, cid, dwStyle, NULL, rgch, pwsf, ws, NULL);
	::SetWindowLong(m_hwnd, GWL_EXSTYLE, dwStyleEx | dwStyleExtra);
	::SetWindowPos(m_hwnd, hwndPrev, rc.left, rc.top, rc.Width(), rc.Height(), 0);
}
示例#20
0
   template <class P> static
   void Apply( GenericImage<P>& image, const HistogramTransformation& H )
   {
      if ( image.IsEmptySelection() )
         return;

      image.SetUnique();

      Rect r = image.SelectedRectangle();
      int h = r.Height();

      int numberOfThreads = H.IsParallelProcessingEnabled() ? Min( H.MaxProcessors(), pcl::Thread::NumberOfThreads( h, 1 ) ) : 1;
      int rowsPerThread = h/numberOfThreads;

      H.UpdateFlags();

      size_type N = image.NumberOfSelectedSamples();
      if ( image.Status().IsInitializationEnabled() )
         image.Status().Initialize( "Histogram transformation", N );

      ThreadData<P> data( image, H, N );

      PArray<Thread<P> > threads;
      for ( int i = 0, j = 1; i < numberOfThreads; ++i, ++j )
         threads.Add( new Thread<P>( data, i*rowsPerThread, (j < numberOfThreads) ? j*rowsPerThread : h ) );

      AbstractImage::RunThreads( threads, data );
      threads.Destroy();

      image.Status() = data.status;
   }
示例#21
0
void STFSliders::RebuildGradient()
{
   Rect r = BoundsRect();
   int w = r.Width();
   int h = r.Height();

   gradient = Bitmap( w, h, BitmapFormat::RGB32 );

   Graphics g( gradient );

   bool c0 = channel == 0 || channel == 3 || !rgb && channel == 0;
   bool c1 = channel == 1 || channel == 3 || !rgb && channel == 0;
   bool c2 = channel == 2 || channel == 3 || !rgb && channel == 0;

   GradientBrush::stop_list stops;
   stops.Add( GradientBrush::Stop( 0.0, RGBAColor( float( c0 ? v0 : 0.0 ), float( c1 ? v0 : 0.0 ), float( c2 ? v0 : 0.0 ) ) ) );
   stops.Add( GradientBrush::Stop( 1.0, RGBAColor( float( c0 ? v1 : 0.0 ), float( c1 ? v1 : 0.0 ), float( c2 ? v1 : 0.0 ) ) ) );

   g.FillRect( r, LinearGradientBrush( 0, 0, w, 0, stops ) );

   g.SetPen( RGBAColor( 0, 0, 0 ) );
   g.SetBrush( Brush::Null() );
   g.DrawRect( r );

   if ( !rgb && channel > 0 )
   {
      Bitmap b( ScaledResource( ":/browser/disabled.png" ) );
      int d = (h - b.Height()) >> 1;
      g.DrawBitmap( d, d, b );
   }
示例#22
0
文件: atheos.cpp 项目: Gingar/port
void ath_get_size(struct graphics_device *dev)
{
	Rect r = lv(dev)->GetBounds();
	dev->size.x1 = dev->size.y1 = 0;
	dev->size.x2 = (int)r.Width() + 1;
	dev->size.y2 = (int)r.Height() + 1;
}
示例#23
0
文件: ToolTip.cpp 项目: pedia/raidget
void QTFPopUp::PopUp(Ctrl *parent) {
	Close();
	Rect r = Rect(0, 0, width, maxheight);
	GetFrame().FrameLayout(r);
	int cy = min(maxheight, GetHeight(r.Width()) + maxheight - r.Height());
	Rect area = GetWorkArea();
	Point p = GetMousePos();
	r.top = max(area.top, p.y + 16);
	r.bottom = r.top + cy;
	if(r.bottom > area.bottom) {
		r.bottom = area.bottom;
		r.top = r.bottom - cy;
	}
	r.left = max(area.left, p.x - width / 2);
	r.right = r.left + width;
	if(r.right > area.right) {
		r.right = area.right;
		r.left = r.right - width;
	}
	open = false;
	SetRect(r);
	Ctrl::PopUp(parent);
	SetFocus();
	open = true;
}
示例#24
0
			Rect GuiAxis::VirtualRectToRealRect(Size realFullSize, Rect rect)
			{
				realFullSize=RealSizeToVirtualSize(realFullSize);
				vint x1=rect.x1;
				vint x2=realFullSize.x-rect.x2;
				vint y1=rect.y1;
				vint y2=realFullSize.y-rect.y2;
				vint w=rect.Width();
				vint h=rect.Height();
				switch(axisDirection)
				{
				case AxisDirection::LeftDown:
					return Rect(Point(x2, y1), Size(w, h));
				case AxisDirection::RightDown:
					return Rect(Point(x1, y1), Size(w, h));
				case AxisDirection::LeftUp:
					return Rect(Point(x2, y2), Size(w, h));
				case AxisDirection::RightUp:
					return Rect(Point(x1, y2), Size(w, h));
				case AxisDirection::DownLeft:
					return Rect(Point(y2, x1), Size(h, w));
				case AxisDirection::DownRight:
					return Rect(Point(y1, x1), Size(h, w));
				case AxisDirection::UpLeft:
					return Rect(Point(y2, x2), Size(h, w));
				case AxisDirection::UpRight:
					return Rect(Point(y1, x2), Size(h, w));
				}
				return rect;
			}
示例#25
0
void BorderFrame::FramePaint(Draw& draw, const Rect& r)
{
	Size sz = r.GetSize();
	int n = (int)(intptr_t)*border;
	if(sz.cx >= 2 * n && sz.cy >= 2 * n)
		DrawBorder(draw, r.left, r.top, r.Width(), r.Height(), border);
}
			void GuiPolygonElementRenderer::Render(Rect bounds)
			{
				cairo_save(cairoContext);

				Color bg = element->GetBackgroundColor();
				Color border = element->GetBorderColor();

				//Actual left-top point of the shape
				int ptx = bounds.x1 + (bounds.Width() - element->GetSize().x) / 2;
				int pty = bounds.y1 + (bounds.Height() - element->GetSize().y) / 2;

				cairo_move_to(cairoContext, 0.5 + ptx + element->GetPoint(0).x, 0.5 + pty + element->GetPoint(0).y);
				for(int i = 1; i < element->GetPointCount(); i++)
				{
					cairo_line_to(cairoContext, 0.5 + ptx + element->GetPoint(i).x, 0.5 + pty + element->GetPoint(i).y);
				}
				cairo_close_path(cairoContext);

				helpers::ColorSet(cairoContext, bg);
				cairo_fill_preserve(cairoContext);

				helpers::PathStroke(cairoContext, border, 1.0);

				cairo_restore(cairoContext);

			}
示例#27
0
void Dow::Handle::CenteredOverScreen (bool topMost)
{
	Dow::Handle hScreen (GetDesktopWindow ());
	Rect screenRect;
	hScreen.GetWindowRect (screenRect);
	Rect myRect;
	GetWindowRect (myRect);
	int x = (screenRect.Width () - myRect.Width ()) / 2;
	int y = (screenRect.Height () - myRect.Height ()) / 2;
	::SetWindowPos (H (),
					topMost ? HWND_TOPMOST :	// Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
							  HWND_NOTOPMOST,	// Places the window above all non-topmost windows (that is, behind all topmost windows).
					x, y,
					0, 0,
					SWP_NOSIZE);	// Retain the current window size (ignores cx and cy parameters)
}
示例#28
0
IconList::InnerView::InnerView( Rect cFrame ) : View( cFrame, "icon_list_inner_view", CF_FOLLOW_ALL )
{
	m_cSize.x = cFrame.Width();
	m_cSize.y = cFrame.Height();

	m_nSelected = -1;
}
示例#29
0
void DropGrid::Close()
{
	Rect r = list.GetRect();
	list_width = r.Width();
	list_height = r.Height();
	SetFocus();
}
示例#30
0
文件: aboutwin.cpp 项目: PyroOS/Pyro
AboutWindow::AboutWindow(const Rect & r)
	:Window(r, "AboutAlbert", MSG_ABOUTWND_TITLE,
//	WND_NO_CLOSE_BUT | WND_NO_ZOOM_BUT | WND_NO_DEPTH_BUT |
//	WND_NO_BORDER | WND_NO_TITLE |
	WND_NOT_RESIZABLE,
	CURRENT_DESKTOP)
{
	os::Resources cRes(get_image_id());
	os::ResStream* pcStream = cRes.GetResourceStream("Calculator.png");
	if(pcStream == NULL)
		throw(os::errno_exception("Can't find resource Calculator.png!"));

	m_pcImage = new BitmapImage( pcStream );
	BitmapView* imv = new BitmapView( m_pcImage->GetBounds(), "bitmap", m_pcImage );
	AddChild(imv);

	Rect	frame = m_pcImage->GetBounds();
	Desktop	desktop;
	Point offset(desktop.GetResolution());

	offset.x = offset.x/2 - frame.Width()/2;
	offset.y = offset.y/2 - frame.Height()/2;

	SetFrame(frame + offset);
	
	delete pcStream;
}