Пример #1
0
void tst_QAbstractScrollArea::patternBackground()
{
    QWidget topLevel;
    QScrollArea scrollArea(&topLevel);
    scrollArea.resize(200, 200);
    QWidget widget;
    widget.resize(600, 600);
    scrollArea.setWidget(&widget);
    topLevel.show();

    QLinearGradient linearGrad(QPointF(250, 250), QPointF(300, 300));
    linearGrad.setColorAt(0, Qt::yellow);
    linearGrad.setColorAt(1, Qt::red);
    QBrush bg(linearGrad);
    scrollArea.viewport()->setPalette(QPalette(Qt::black, bg, bg, bg, bg, bg, bg, bg, bg));
    widget.setPalette(Qt::transparent);

    QTest::qWait(50);

    QImage image(200, 200, QImage::Format_ARGB32);
    scrollArea.render(&image);

    QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::yellow).rgb());

    QScrollBar *hbar = scrollArea.horizontalScrollBar();
    hbar->setValue(hbar->maximum());
    QScrollBar *vbar = scrollArea.verticalScrollBar();
    vbar->setValue(vbar->maximum());

    QTest::qWait(50);

    scrollArea.render(&image);
    QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb());
}
/*!
    Constructor
*/
NmEditorTextEdit::NmEditorTextEdit(QGraphicsItem *parent) :
    HbTextEdit(parent)
{
    NM_FUNCTION;
    
    HbStyleLoader::registerFilePath(FILE_PATH_WIDGETML);
    HbStyleLoader::registerFilePath(FILE_PATH_CSS_DEFAULT);

    mCustomTextColor = QPair<bool, QColor>(false, Qt::black);
    
    // Disable HbTextEdit scrolling. Background scroll area will handle scrolling.
    setScrollable(false);
    scrollArea()->setScrollDirections(0);

    // set background colour to plain white
    QPixmap whitePixmap(10,10);
    whitePixmap.fill(Qt::white);
    QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem (whitePixmap);
    setBackgroundItem(pixmapItem); 
    
    // Create custom palette based on the current one
    QPalette testPalette = QApplication::palette();

    // Sets the selection background colour
    testPalette.setColor(QPalette::Active, QPalette::Highlight, Qt::cyan);
    testPalette.setColor(QPalette::Inactive, QPalette::Highlight, Qt::cyan);

    // Sets the link and visited link colours
    testPalette.setColor(QPalette::Active, QPalette::Link, Qt::darkBlue);
    testPalette.setColor(QPalette::Inactive, QPalette::Link, Qt::darkBlue);
    testPalette.setColor(QPalette::Active, QPalette::LinkVisited, Qt::darkMagenta);
    testPalette.setColor(QPalette::Inactive, QPalette::LinkVisited, Qt::darkMagenta);

    // Update custom palette for this widget
    setPalette(testPalette);
}
Пример #3
0
static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	void *data;
	DWORD which;
	uintptr_t heldButtons = (uintptr_t) wParam;
	LRESULT lResult;

	data = getWindowData(hwnd, uMsg, wParam, lParam, &lResult);
	if (data == NULL)
		return lResult;
	switch (uMsg) {
	case WM_PAINT:
		paintArea(hwnd, data);
		return 0;
	case WM_ERASEBKGND:
		// don't draw a background; we'll do so when painting
		// this is to make things flicker-free; see http://msdn.microsoft.com/en-us/library/ms969905.aspx
		return 1;
	case WM_HSCROLL:
		scrollArea(hwnd, data, wParam, SB_HORZ);
		return 0;
	case WM_VSCROLL:
		scrollArea(hwnd, data, wParam, SB_VERT);
		return 0;
	case WM_SIZE:
		adjustAreaScrollbars(hwnd, data);
		return 0;
	case WM_ACTIVATE:
		// don't keep the double-click timer running if the user switched programs in between clicks
		areaResetClickCounter(data);
		return 0;
	case WM_MOUSEMOVE:
		areaMouseEvent(hwnd, data, 0, FALSE, heldButtons, lParam);
		return 0;
	case WM_LBUTTONDOWN:
		SetFocus(hwnd);
		areaMouseEvent(hwnd, data, 1, FALSE, heldButtons, lParam);
		return 0;
	case WM_LBUTTONUP:
		areaMouseEvent(hwnd, data, 1, TRUE, heldButtons, lParam);
		return 0;
	case WM_MBUTTONDOWN:
		SetFocus(hwnd);
		areaMouseEvent(hwnd, data, 2, FALSE, heldButtons, lParam);
		return 0;
	case WM_MBUTTONUP:
		areaMouseEvent(hwnd, data, 2, TRUE, heldButtons, lParam);
		return 0;
	case WM_RBUTTONDOWN:
		SetFocus(hwnd);
		areaMouseEvent(hwnd, data, 3, FALSE, heldButtons, lParam);
		return 0;
	case WM_RBUTTONUP:
		areaMouseEvent(hwnd, data, 3, TRUE, heldButtons, lParam);
		return 0;
	case WM_XBUTTONDOWN:
		SetFocus(hwnd);
		// values start at 1; we want them to start at 4
		which = (DWORD) GET_XBUTTON_WPARAM(wParam) + 3;
		heldButtons = (uintptr_t) GET_KEYSTATE_WPARAM(wParam);
		areaMouseEvent(hwnd, data, which, FALSE, heldButtons, lParam);
		return TRUE;		// XBUTTON messages are different!
	case WM_XBUTTONUP:
		which = (DWORD) GET_XBUTTON_WPARAM(wParam) + 3;
		heldButtons = (uintptr_t) GET_KEYSTATE_WPARAM(wParam);
		areaMouseEvent(hwnd, data, which, TRUE, heldButtons, lParam);
		return TRUE;
	case msgAreaKeyDown:
		return (LRESULT) areaKeyEvent(data, FALSE, wParam, lParam);
	case msgAreaKeyUp:
		return (LRESULT) areaKeyEvent(data, TRUE, wParam, lParam);
	case msgAreaSizeChanged:
		adjustAreaScrollbars(hwnd, data);
		repaintArea(hwnd, NULL);		// this calls for an update
		return 0;
	case msgAreaGetScroll:
		getScrollPos(hwnd, (int *) wParam, (int *) lParam);
		return 0;
	case msgAreaRepaint:
		repaintArea(hwnd, (RECT *) lParam);
		return 0;
	case msgAreaRepaintAll:
		repaintArea(hwnd, NULL);
		return 0;
	default:
		return DefWindowProcW(hwnd, uMsg, wParam, lParam);
	}
	xmissedmsg("Area", "areaWndProc()", uMsg);
	return 0;			// unreached
}