Exemple #1
0
ColorField::ColorField(color_mode mode, float fixed_value)
	:
	BControl("color field", "", new BMessage(MSG_COLOR_FIELD),
		B_WILL_DRAW | B_FRAME_EVENTS),
	fColorMode(mode),
	fFixedValue(fixed_value),
	fMarkerPosition(BPoint(0.0, 0.0)),
	fLastMarkerPosition(BPoint(-1.0, -1.0)),
	fMouseDown(false),
	fUpdateThread(0),
	fUpdatePort(0)
{
	SetViewColor(B_TRANSPARENT_32_BIT);
	SetExplicitMinSize(BSize(COLOR_FIELD_WIDTH, COLOR_FIELD_HEIGHT));
	SetExplicitMaxSize(BSize(COLOR_FIELD_WIDTH, COLOR_FIELD_HEIGHT));

	for (int i = 0; i < 2; ++i) {
		fBgBitmap[i] = new BBitmap(COLOR_FIELD_RECT, B_RGB32, true, true);
		fBgBitmap[i]->Lock();

		fBgView[i] = new BView(COLOR_FIELD_RECT, "", B_FOLLOW_NONE, B_WILL_DRAW);
		fBgBitmap[i]->AddChild(fBgView[i]);
		fBgView[i]->SetOrigin(2.0, 2.0);

		fBgBitmap[i]->Unlock();
	}

	_DrawBorder();

	fUpdatePort = create_port(100, "color field update port");

	fUpdateThread = spawn_thread(&ColorField::_UpdateThread,
		"color field update thread", 10, this);
	resume_thread(fUpdateThread);
}
Exemple #2
0
// layout
BRect
ColorField::layout(BRect frame)
{
	MoveTo(frame.LeftTop());

	// reposition marker
	fMarkerPosition.x *= (frame.Width() - 4.0) / (Bounds().Width() - 4.0);
	fMarkerPosition.y *= (frame.Height() - 4.0) / (Bounds().Height() - 4.0);

	ResizeTo(frame.Width(), frame.Height());
	_DrawBorder();
	Update(3);
	return Frame();
}
Exemple #3
0
void CChart2D::_DrawBackground(CDC *pDC)
{
 if(memBkDC.GetSafeHdc() == NULL)
 {
  memBkDC.CreateCompatibleDC(pDC);
  m_bkBitmap.CreateCompatibleBitmap(pDC, m_ctlRect.Width(), m_ctlRect.Height());
 }

 mp_oldBkBitmap = (CBitmap*)memBkDC.SelectObject(&m_bkBitmap);
 _DrawBorder(&memBkDC);
 _DrawAxis(&memBkDC);
 _DrawGrid(&memBkDC);
 _DrawGridLabel(&memBkDC);
 _DrawChartTitle(&memBkDC);
}
Exemple #4
0
// constructor
ColorField::ColorField(BPoint offset_point, selected_color_mode mode,
					   float fixed_value, orientation orient)
	: BControl(BRect(0.0, 0.0, MAX_X + 4.0, MAX_Y + 4.0).OffsetToCopy(offset_point),
			   "ColorField", "", new BMessage(MSG_COLOR_FIELD),
			   B_FOLLOW_LEFT | B_FOLLOW_TOP,
			   B_WILL_DRAW | B_FRAME_EVENTS),
	  fMode(mode),
	  fFixedValue(fixed_value),
	  fOrientation(orient),
	  fMarkerPosition(0.0, 0.0),
	  fLastMarkerPosition(-1.0, -1.0),
	  fMouseDown(false),
	  fUpdateThread(B_ERROR),
	  fUpdatePort(B_ERROR)
{
	SetViewColor(B_TRANSPARENT_32_BIT);

	for (int i = 0; i < 2; ++i) {
		fBgBitmap[i] = new BBitmap(Bounds(), B_RGB32, true);

		fBgBitmap[i]->Lock();
		fBgView[i] = new BView(Bounds(), "", B_FOLLOW_NONE, B_WILL_DRAW);
		fBgBitmap[i]->AddChild(fBgView[i]);
		fBgView[i]->SetOrigin(2.0, 2.0);
		fBgBitmap[i]->Unlock();
	}

	_DrawBorder();

	fUpdatePort = create_port(100, "color field update port");

	fUpdateThread = spawn_thread(ColorField::_UpdateThread,
								 "color field update thread", 10, this);
	resume_thread(fUpdateThread);

//	Update(3);
}
LRESULT CALLBACK CCandidateWindow::_WindowProcCallback(_In_ HWND wndHandle, UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_CREATE:
        {
            HDC dcHandle = nullptr;

            dcHandle = GetDC(wndHandle);
            if (dcHandle)
            {
                HFONT hFontOld = (HFONT)SelectObject(dcHandle, Global::defaultlFontHandle);
                GetTextMetrics(dcHandle, &_TextMetric);

                _cxTitle = _TextMetric.tmMaxCharWidth * _wndWidth;
                SelectObject(dcHandle, hFontOld);
                ReleaseDC(wndHandle, dcHandle);
            }
        }
        return 0;

    case WM_DESTROY:
        _DeleteShadowWnd();
        return 0;

    case WM_WINDOWPOSCHANGED:
        {
            WINDOWPOS* pWndPos = (WINDOWPOS*)lParam;

            // move shadow
            if (_pShadowWnd)
            {
                _pShadowWnd->_OnOwnerWndMoved((pWndPos->flags & SWP_NOSIZE) == 0);
            }

            // move v-scroll
            if (_pVScrollBarWnd)
            {
                _pVScrollBarWnd->_OnOwnerWndMoved((pWndPos->flags & SWP_NOSIZE) == 0);
            }

            _FireMessageToLightDismiss(wndHandle, pWndPos);
        }
        break;

    case WM_WINDOWPOSCHANGING:
        {
            WINDOWPOS* pWndPos = (WINDOWPOS*)lParam;

            // show/hide shadow
            if (_pShadowWnd)
            {
                if ((pWndPos->flags & SWP_HIDEWINDOW) != 0)
                {
                    _pShadowWnd->_Show(FALSE);
                }

                // don't go behaind of shadow
                if (((pWndPos->flags & SWP_NOZORDER) == 0) && (pWndPos->hwndInsertAfter == _pShadowWnd->_GetWnd()))
                {
                    pWndPos->flags |= SWP_NOZORDER;
                }

                _pShadowWnd->_OnOwnerWndMoved((pWndPos->flags & SWP_NOSIZE) == 0);
            }

            // show/hide v-scroll
            if (_pVScrollBarWnd)
            {
                if ((pWndPos->flags & SWP_HIDEWINDOW) != 0)
                {
                    _pVScrollBarWnd->_Show(FALSE);
                }

                _pVScrollBarWnd->_OnOwnerWndMoved((pWndPos->flags & SWP_NOSIZE) == 0);
            }
        }
        break;

    case WM_SHOWWINDOW:
        // show/hide shadow
        if (_pShadowWnd)
        {
            _pShadowWnd->_Show((BOOL)wParam);
        }

        // show/hide v-scroll
        if (_pVScrollBarWnd)
        {
            _pVScrollBarWnd->_Show((BOOL)wParam);
        }
        break;

    case WM_PAINT:
        {
            HDC dcHandle = nullptr;
            PAINTSTRUCT ps;

            dcHandle = BeginPaint(wndHandle, &ps);
            _OnPaint(dcHandle, &ps);
            _DrawBorder(wndHandle, CANDWND_BORDER_WIDTH*2);
            EndPaint(wndHandle, &ps);
        }
        return 0;

    case WM_SETCURSOR:
        {
            POINT cursorPoint;

            GetCursorPos(&cursorPoint);
            MapWindowPoints(NULL, wndHandle, &cursorPoint, 1);

            // handle mouse message
            _HandleMouseMsg(HIWORD(lParam), cursorPoint);
        }
        return 1;

    case WM_MOUSEMOVE:
    case WM_LBUTTONDOWN:
    case WM_MBUTTONDOWN:
    case WM_RBUTTONDOWN:
    case WM_LBUTTONUP:
    case WM_MBUTTONUP:
    case WM_RBUTTONUP:
        {
            POINT point;

            POINTSTOPOINT(point, MAKEPOINTS(lParam));

            // handle mouse message
            _HandleMouseMsg(uMsg, point);
        }
        // we processes this message, it should return zero. 
        return 0;

    case WM_MOUSEACTIVATE:
        {
            WORD mouseEvent = HIWORD(lParam);
            if (mouseEvent == WM_LBUTTONDOWN || 
                mouseEvent == WM_RBUTTONDOWN || 
                mouseEvent == WM_MBUTTONDOWN) 
            {
                return MA_NOACTIVATE;
            }
        }
        break;

    case WM_POINTERACTIVATE:
        return PA_NOACTIVATE;

    case WM_VSCROLL:
        _OnVScroll(LOWORD(wParam), HIWORD(wParam));
        return 0;
    }

    return DefWindowProc(wndHandle, uMsg, wParam, lParam);
}