예제 #1
0
void CInspectorTreeCtrl::OnLButtonUp(UINT flags, CPoint point)
{
    DeactivateEIP();
    HTREEITEM hitItem = HitTest(point);
    if(hitItem && hitItem == GetSelectedItem())
    {
        CRect rect;
        GetItemRect(hitItem, &rect, FALSE);
        rect.left = getColumnWidth(0);
        rect.right = rect.left + getColumnWidth(1);
        if(rect.PtInRect(point)) ActivateEIP(hitItem, rect);        
    }   
    CTreeCtrl::OnLButtonUp(flags, point);
}
예제 #2
0
void CInspectorTreeCtrl::OnPaint()
{   
    CPaintDC dc(this); 

    CPropertyInspector * parent = static_cast <CPropertyInspector *> (GetParent());

    CRect rcClip;
    dc.GetClipBox( &rcClip );       
    rcClip.right = getColumnWidth(0);

    CRgn rgn;                   
    rgn.CreateRectRgnIndirect( &rcClip );
    dc.SelectClipRgn(&rgn);

    CWnd::DefWindowProc(WM_PAINT, reinterpret_cast <WPARAM> (dc.m_hDC), 0);     // let CTreeCtrl paint as normal
    rgn.DeleteObject();

    rcClip.right += parent->getColumnWidth(1);
    rgn.CreateRectRgnIndirect( &rcClip );
    dc.SelectClipRgn(&rgn);

    drawValues(dc);

    rgn.DeleteObject();
}
예제 #3
0
파일: Document.cpp 프로젝트: wibbe/zum
  static void setText(Index const& idx, std::string const& text, bool forceFormat = false)
  {
    Cell & cell = getCell(idx);

    if (forceFormat)
    {
      std::tie(cell.format, cell.text) = parseFormatAndValue(text);

      int width = getColumnWidth(idx.x);
      if (width < cell.text.size())
        currentDoc().columnWidth_[idx.x] = cell.text.size() + 1;
    }
    else
    {
      uint32_t format;
      std::tie(format, cell.text) = parseFormatAndValue(text);
    }

    if (currentDoc().width_ < (idx.x + 1))
      currentDoc().width_ = idx.x + 1;

    if (currentDoc().height_ < (idx.y + 1))
      currentDoc().height_ = (idx.y + 1);

    if (cell.text.front() == '=')
    {
      cell.hasExpression = true;
      cell.expression = parseExpression(cell.text.substr(1));
    }
    else
    {
      cell.hasExpression = false;
    }
  }
예제 #4
0
// This handles the WM_INITDIALOG message for the top-level dialog.
BOOL AP_Win32Dialog_InsertTable::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
{	
	const XAP_StringSet * pSS = m_pApp->getStringSet();
	char 	szValue[BUFSIZE];	
	m_hwndDlg = hWnd;
		
		
	// localize controls 
	_DSX(BTN_OK,		DLG_OK);
	_DSX(BTN_CANCEL,	DLG_Cancel);			
	_DS(TEXT_SIZE,		DLG_InsertTable_TableSize);		
	_DS(TEXT_COLUMN,	DLG_InsertTable_NumCols);		
	_DS(TEXT_ROW,		DLG_InsertTable_NumRows);		
	_DS(TEXT_AUTOFIT,	DLG_InsertTable_AutoFit);		
	_DS(RADIO_AUTO,		DLG_InsertTable_AutoColSize);		
	_DS(RADIO_FIXED,	DLG_InsertTable_FixedColSize);			
		
	// Localise caption
	SetWindowText(hWnd, pSS->getValue(AP_STRING_ID_DLG_InsertTable_TableTitle));

	// Set Spin range (TODO: check if the max value is correct, copied from the unix version)
	SendMessage(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTTABLE_SPIN_COLUMN),UDM_SETRANGE,(WPARAM)0,(LPARAM)MAKELONG((short)64,(short)1));
	SendMessage(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTTABLE_SPIN_ROW),UDM_SETRANGE,(WPARAM)0,(LPARAM)MAKELONG((short)500,(short)1));
	SendMessage(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTTABLE_SPIN_SIZE),UDM_SETRANGE,(WPARAM)0,(LPARAM)MAKELONG((short)9999,(short)1));
	
	// Limit to four chars
	SendMessage(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTTABLE_TEXT_COLUMN),EM_LIMITTEXT,(WPARAM)5,(WPARAM)0);
	SendMessage(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTTABLE_TEXT_ROW),EM_LIMITTEXT,(WPARAM)5,(WPARAM)0);
	SendMessage(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTTABLE_TEXT_SIZE),EM_LIMITTEXT,(WPARAM)5,(WPARAM)0);

	CheckRadioButton(hWnd, AP_RID_DIALOG_INSERTTABLE_RADIO_AUTO,
		AP_RID_DIALOG_INSERTTABLE_RADIO_FIXED, AP_RID_DIALOG_INSERTTABLE_RADIO_AUTO);
	
	
	SetFocus(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTTABLE_VAL_COLUMN));
	SendDlgItemMessage(hWnd, AP_RID_DIALOG_INSERTTABLE_VAL_COLUMN, EM_SETSEL, 0, -1);
	
	// Set default values		
	sprintf(szValue, "%u", getNumCols());
	SetDlgItemText(hWnd, AP_RID_DIALOG_INSERTTABLE_VAL_COLUMN, szValue);
		
	sprintf(szValue, "%u", getNumRows());
	SetDlgItemText(hWnd, AP_RID_DIALOG_INSERTTABLE_VAL_ROW, szValue);
				
	sprintf(szValue, "%02.2f", getColumnWidth());
	SetDlgItemText(hWnd, AP_RID_DIALOG_INSERTTABLE_VAL_SIZE, szValue);

	/* Units name*/
	SetDlgItemText(hWnd, AP_RID_DIALOG_INSERTTABLE_TEXT_UNITS, UT_dimensionName(m_dim));	

	/* Autosize by default*/
	EnableWindow(GetDlgItem(m_hwndDlg,AP_RID_DIALOG_INSERTTABLE_VAL_SIZE), FALSE);
	EnableWindow(GetDlgItem(m_hwndDlg,AP_RID_DIALOG_INSERTTABLE_SPIN_SIZE), FALSE);

	XAP_Win32DialogHelper::s_centerDialog(hWnd);	
	
	return 0; // 0 because we called SetFocus
}
예제 #5
0
LRESULT CInspectorTreeCtrl::WindowProc(UINT Msg, WPARAM wParam, LPARAM lParam)
{
    switch(Msg)
    {
    case MSG_EIP_RESIZE:
        HTREEITEM hitItem = GetSelectedItem();
        CRect rect;
        GetItemRect(hitItem, &rect, FALSE);
        rect.left = getColumnWidth(0);
        rect.right = rect.left + getColumnWidth(1);
        if(rect.Width() > 0)
            editCtrl.Resize(rect);
        else
            DeactivateEIP();
        return 0;
    }
    return CTreeCtrl::WindowProc(Msg, wParam, lParam);
}
예제 #6
0
파일: Document.cpp 프로젝트: wibbe/zum
  void increaseColumnWidth(int column)
  {
    if (currentDoc().readOnly_)
      return;

    int width = getColumnWidth(column);

    takeUndoSnapshot(EditAction::ColumnWidth, true);
    currentDoc().columnWidth_[column] = width + 1;
  }
예제 #7
0
void
MFXEditableTable::editItem(FXTableItem* item, FXint how) {
    if (item == 0) {
        editEnd();
        return;
    }
    if (myWriteProtectedCols.find(myEditedCol) != myWriteProtectedCols.end()) {
        editEnd();
        return;
    }
    FXTableItem* it = item;
    myPreviousText = item->getText();
    FXint x = getColumnX(myEditedCol) + getRowHeader()->getWidth() + xpos;
    FXint y = getRowY(myEditedRow) + getColumnHeader()->getHeight() + ypos;
    FXIcon* icon = item->getIcon();
    if (icon) {
        x += icon->getWidth() + 4;
    }
    FXint vw = getViewportWidth();
    if (vertical->shown()) {
        vw -= vertical->getWidth();
    }
    if (vw > getColumnWidth(myEditedCol)) {
        vw = getColumnWidth(myEditedCol) + x;
    }
    myEditor->setText(it->getText());
    myEditor->move(x, y);
    myEditor->resize(vw - x + 1, getRowHeight(myEditedRow) + 1);
    myEditor->show();
    myEditor->raise();
    myEditor->setFocus();
    if (how == 'I') {
        myEditor->killSelection();
        myEditor->setCursorPos(0);
    } else if (how == 'A') {
        myEditor->killSelection();
        myEditor->setCursorPos(myEditor->getText().length());
    } else {
        myEditor->selectAll();
    }
    myEditedItem = it;
}
예제 #8
0
파일: wfxListCtrl.cpp 프로젝트: wxtnote/wfc
BOOL ListCtrl::calcCol()
{
	ULONG nOldStartCol = m_nStartCol;
	ULONG nOldEndCol = m_nEndCol;
	m_nStartCol = m_nEndCol = -1;
	Rect rcDraw = getClientRect();
	LONG nOffset = getHOffset();
	//TRACE(L"nOffset = %d", nOffset);
	ULONG nTotalCol = getTotalColumns();
	LONG nSumWidth = 0;
	LONG nColWidth = 0;
	for (ULONG nCol = 0; nCol < nTotalCol; nCol++)
	{
		nColWidth = getColumnWidth(nCol);
		nSumWidth += nColWidth;
		if (nSumWidth >= nOffset)
		{
			m_nStartCol = nCol;
			break;
		}
	}
	nSumWidth = 0;
	LONG nViewWidth = rcDraw.right - rcDraw.left;
	for (ULONG nCol = m_nStartCol; nCol < nTotalCol; nCol++)
	{
		nSumWidth += getColumnWidth(nCol);
		if (nSumWidth > nViewWidth)
		{
			m_nEndCol = nCol;
			break;
		}
	}
	if (nSumWidth < nViewWidth)
	{
		m_nEndCol = nTotalCol - 1;
	}
	//TRACE(L"m_nStartCol = %d", m_nStartCol);
	//TRACE(L"m_nEndCol = %d", m_nEndCol);
	return (m_nStartCol != nOldStartCol || m_nEndCol != nOldEndCol);
}
예제 #9
0
void CInspectorTreeCtrl::OnGetDispInfo(NMHDR* pNMHDR, LRESULT* pResult) 
{
    TV_DISPINFO * pTVDispInfo = reinterpret_cast <TV_DISPINFO *> (pNMHDR);

    CTreeListItem * tli = reinterpret_cast <CTreeListItem *> (pTVDispInfo->item.lParam);
    if(tli)
    {
        static char nameBuffer[256];

        IPropertyTree * ppTree = tli->getType() == TLT_root ? NULL : GetTreeListItem(GetParentItem(pTVDispInfo->item.hItem))->queryPropertyTree();
        int origlen = tli->getDisplayName(ppTree, nameBuffer , sizeof(nameBuffer));
        
        HTREEITEM parent = NULL;
        CDC * dc = GetDC();
        dc->SetViewportOrg(0, 0);
        dc->SelectObject(GetFont());
        int fit;
        CSize sz;
        CRect rect;
        if(GetItemRect(pTVDispInfo->item.hItem, &rect, TRUE))
        {
            rect.right = getColumnWidth(0);
            GetTextExtentExPoint(dc->m_hDC, nameBuffer, origlen, rect.Width() - 2, &fit, NULL, &sz);

            if(fit < origlen)
            {
                if(fit > 3)
                {
                    strcpy(&nameBuffer[fit - 3], "...");
                    pTVDispInfo->item.pszText = nameBuffer;
                }
                else
                {
                    pTVDispInfo->item.pszText = NULL;
                }
            }
            else
            {
                pTVDispInfo->item.pszText = nameBuffer; 
            }
        }
        else
        {
            pTVDispInfo->item.pszText = NULL;   
        }
        ReleaseDC(dc);
    }
    *pResult = 0;
}
예제 #10
0
파일: wfxListCtrl.cpp 프로젝트: wxtnote/wfc
void ListCtrl::calcVirtualSize( Size& sz )
{
	setVirtualSizeCached();
	sz.empty();
	int nTotalRow = getTotalRows();
	for (int i = 0; i < nTotalRow; i++)
	{
		sz.cy += getRowHeight(i);
	}
	int nTotalCol = getTotalColumns();
	for (int i = 0; i < nTotalCol; i++)
	{
		sz.cx += getColumnWidth(i);
	}
}
예제 #11
0
/**
 * Returns the preferred size of the TextArea.  This is the
 * maximum of the size needed to display the text and the
 * size requested for the viewport.
 *
 * @return the size
 */
/*public*/ Dimension getPreferredSize() {
    Dimension d = super.getPreferredSize();
    d = (d == NULL) ? new Dimension(400,400) : d;
    Insets insets = getInsets();

    if (columns != 0) {
        d.width = Math.max(d.width, columns * getColumnWidth() +
                insets.left + insets.right);
    }
    if (rows != 0) {
        d.height = Math.max(d.height, rows * getRowHeight() +
                            insets.top + insets.bottom);
    }
    return d;
}
예제 #12
0
파일: wfxListCtrl.cpp 프로젝트: wxtnote/wfc
void ListCtrl::calcCellRect()
{
	WFX_CONDITION(m_nStartRow != -1);
	WFX_CONDITION(m_nEndRow != -1);
	WFX_CONDITION(m_nStartCol != -1);
	WFX_CONDITION(m_nEndCol != -1);
	WFX_CONDITION(m_nEndRow >= m_nStartRow);
	WFX_CONDITION(m_nEndCol >= m_nEndCol);
	m_rgRectFast.clear();
	m_rgRect.clear();
	m_rgRowNumRect.clear();
	ULONG nTotalRow = getTotalRows();
	ULONG nTotalCol = getTotalColumns();
	ULONG nSeqBarWidth = getRowNumBarWidth();
	ULONG nHeadHeight = getHeadHeight();
	Rect rcWid = getClientRect();
	Rect rcCell = rcWid;
	Rect rcRowNum = rcWid;
	ULONG nWidth = 0;
	ULONG nHeight = 0;
	rcRowNum.right = rcRowNum.left + nSeqBarWidth;
	rcCell.left += nSeqBarWidth + 1;
	rcCell.top += nHeadHeight + 1;
	m_rgRectFast.resize(m_nEndRow - m_nStartRow + 1);
	for (LONG nRow = m_nStartRow; nRow <= m_nEndRow; nRow++)
	{
		nHeight = getRowHeight(nRow);
		rcCell.bottom = rcCell.top + nHeight;
		rcRowNum.top = rcCell.top;
		rcRowNum.bottom = rcCell.bottom;
		m_rgRowNumRect.push_back(rcRowNum);
		if (rcCell.bottom > rcWid.bottom)
			rcCell.bottom = rcWid.bottom;
		m_rgRectFast[nRow - m_nStartRow].resize(m_nEndCol - m_nStartCol + 1);
		for (LONG nCol = m_nStartCol; nCol <= m_nEndCol; nCol++)
		{
			nWidth = getColumnWidth(nCol);
			rcCell.right = rcCell.left + nWidth;
			m_rgRect.insert(std::make_pair(CellID(nRow, nCol), rcCell));
			m_rgRectFast[nRow - m_nStartRow][nCol - m_nStartCol] = rcCell;
			rcCell.left += rcCell.right - rcCell.left;
		}
		rcCell.left = rcWid.left + nSeqBarWidth + 1;
		rcCell.top += rcCell.bottom - rcCell.top;
	}
}
예제 #13
0
파일: table.cpp 프로젝트: Ablu/invertika
int GuiTable::getColumnForX(int x) const
{
    int column;
    int delta = 0;

    for (column = 0; column < mModel->getColumns(); column++)
    {
        delta += getColumnWidth(column);
        if (x <= delta)
            break;
    }

    if (column < 0 || column >= mModel->getColumns())
        return -1;
    else
        return column;
}
예제 #14
0
    void MultiListBox::updateColumns()
    {
        size_t countStars = 0;
        size_t lastIndexStar = ITEM_NONE;

        int allColumnsWidth = updateWidthColumns(countStars, lastIndexStar);
        int clientWidth = mClient->getWidth();
        int separatorsWidth = mVectorColumnInfo.empty() ? 0 : (mVectorColumnInfo.size() - 1) * mWidthSeparator;
        int freeSpace = clientWidth - separatorsWidth - allColumnsWidth;
        int starWidth = (countStars != 0 && freeSpace > 0) ? (freeSpace / countStars) : 0;

        mWidthBar = 0;
        for (size_t index = 0; index < mVectorColumnInfo.size(); ++ index)
        {
            ColumnInfo& info = mVectorColumnInfo[index];

            int columnWidth = getColumnWidth(index, freeSpace, countStars, lastIndexStar, starWidth);

            if (mHeaderPlace != nullptr)
            {
                info.item->setCoord(mWidthBar, 0, columnWidth, mClient->getHeight());
            }
            else
            {
                info.item->setCoord(mWidthBar, mHeightButton, columnWidth, mClient->getHeight() - mHeightButton);
            }

            info.button->setCoord(mWidthBar, 0, columnWidth, getButtonHeight());
            info.button->_setInternalData(index);

            mWidthBar += columnWidth;

            // промежуток между листами
            Widget* separator = getSeparator(index);
            if (separator)
            {
                separator->setCoord(mWidthBar, 0, mWidthSeparator, mClient->getHeight());
            }

            mWidthBar += mWidthSeparator;
        }

        redrawButtons();
        updateOnlyEmpty();
    }
예제 #15
0
파일: table.cpp 프로젝트: Ablu/invertika
void GuiTable::recomputeDimensions()
{
    int rows_nr = mModel->getRows();
    int columns_nr = mModel->getColumns();
    int width = 0;
    int height = 0;

    if (mSelectedRow >= rows_nr)
        mSelectedRow = rows_nr - 1;

    if (mSelectedColumn >= columns_nr)
        mSelectedColumn = columns_nr - 1;

    for (int i = 0; i < columns_nr; i++)
        width += getColumnWidth(i);

    height = getRowHeight() * rows_nr;

    setWidth(width);
    setHeight(height);
}
예제 #16
0
void GuiTable::recomputeDimensions()
{
    if (!mModel)
        return;

    const int rows_nr = mModel->getRows();
    const int columns_nr = mModel->getColumns();
    int width = 0;

    if (mSelectable)
    {
        if (mSelectedRow >= rows_nr)
            mSelectedRow = rows_nr - 1;

        if (mSelectedColumn >= columns_nr)
            mSelectedColumn = columns_nr - 1;
    }

    for (int i = 0; i < columns_nr; i++)
        width += getColumnWidth(i);

    setWidth(width);
    setHeight(getRowHeight() * rows_nr);
}
예제 #17
0
void GuiTable::safeDraw(Graphics *const graphics)
{
    if (!getRowHeight())
        return;

    BLOCK_START("GuiTable::draw")
    if (settings.guiAlpha != mAlpha)
        mAlpha = settings.guiAlpha;

    const Rect &rect = mDimension;
    const int width = rect.width;
    const int height = rect.height;
    const int y = rect.y;
    if (mOpaque)
    {
        mBackgroundColor.a = CAST_U32(mAlpha * 255.0F);
        graphics->setColor(mBackgroundColor);
        graphics->fillRectangle(Rect(0, 0, width, height));
    }

    // First, determine how many rows we need to draw,
    // and where we should start.
    int rHeight = getRowHeight();
    if (!rHeight)
        rHeight = 1;
    int first_row = -(y / rHeight);

    if (first_row < 0)
        first_row = 0;

    unsigned int rows_nr = CAST_U32(
        1 + height / rHeight);  // May overestimate by one.
    unsigned int max_rows_nr;
    if (mModel->getRows() < first_row)
    {
        max_rows_nr = 0;
    }
    else
    {
        max_rows_nr = CAST_U32(
            mModel->getRows() - first_row);  // clip if neccessary:
    }
    if (max_rows_nr < rows_nr)
        rows_nr = max_rows_nr;

    // Now determine the first and last column
    // Take the easy way out; these are usually bounded and all visible.
    const unsigned int first_column = 0;
    const unsigned int last_column1 = CAST_U32(
        mModel->getColumns());

    int y_offset = first_row * rHeight;

    for (unsigned int r = CAST_U32(first_row);
         r < CAST_U32(first_row + CAST_S32(rows_nr));
         ++r)
    {
        int x_offset = 0;

        for (unsigned c = first_column; c + 1 <= last_column1; ++c)
        {
            Widget *const widget = mModel->getElementAt(CAST_S32(r),
                CAST_S32(c));
            const int cWidth = CAST_S32(getColumnWidth(
                CAST_S32(c)));
            if (widget)
            {
                Rect bounds(x_offset, y_offset, cWidth, rHeight);

                if (widget == mTopWidget)
                {
                    bounds.height = widget->getHeight();
                    bounds.width = widget->getWidth();
                }

                widget->setDimension(bounds);

                if (mSelectedRow > -1)
                {
                    mHighlightColor.a = CAST_U32(
                        mAlpha * 255.0F);
                    graphics->setColor(mHighlightColor);

                    if (mLinewiseMode && r == CAST_U32(
                        mSelectedRow) && c == 0)
                    {
                        graphics->fillRectangle(Rect(0, y_offset,
                            width, rHeight));
                    }
                    else if (!mLinewiseMode && mSelectedColumn > 0
                             && c == CAST_U32(mSelectedColumn)
                             && r == CAST_U32(mSelectedRow))
                    {
                        graphics->fillRectangle(Rect(
                            x_offset, y_offset, cWidth, rHeight));
                    }
                }
                graphics->pushClipArea(bounds);
                widget->safeDraw(graphics);
                graphics->popClipArea();
            }

            x_offset += cWidth;
        }

        y_offset += rHeight;
    }

    if (mTopWidget)
    {
        const Rect &bounds = mTopWidget->getDimension();
        graphics->pushClipArea(bounds);
        mTopWidget->safeDraw(graphics);
        graphics->popClipArea();
    }
    BLOCK_END("GuiTable::draw")
}
예제 #18
0
파일: table.cpp 프로젝트: Ablu/invertika
// -- widget ops
void GuiTable::draw(gcn::Graphics* graphics)
{
    if (!mModel)
        return;

    if (config.getFloatValue("guialpha") != mAlpha)
        mAlpha = config.getFloatValue("guialpha");

    if (mOpaque)
    {
        graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND,
                (int)(mAlpha * 255.0f)));
        graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
    }

    // First, determine how many rows we need to draw, and where we should start.
    int first_row = -(getY() / getRowHeight());

    if (first_row < 0)
        first_row = 0;

    int rows_nr = 1 + (getHeight() / getRowHeight()); // May overestimate by one.

    int max_rows_nr = mModel->getRows() - first_row; // clip if neccessary:
    if (max_rows_nr < rows_nr)
        rows_nr = max_rows_nr;

    // Now determine the first and last column
    // Take the easy way out; these are usually bounded and all visible.
    int first_column = 0;
    int last_column = mModel->getColumns() - 1;

    // Set up everything for drawing
    int height = getRowHeight();
    int y_offset = first_row * height;

    for (int r = first_row; r < first_row + rows_nr; ++r)
    {
        int x_offset = 0;

        for (int c = first_column; c <= last_column; ++c)
        {
            gcn::Widget *widget = mModel->getElementAt(r, c);
            int width = getColumnWidth(c);
            if (widget)
            {
                gcn::Rectangle bounds(x_offset, y_offset, width, height);

                if (widget == mTopWidget)
                {
                    bounds.height = widget->getHeight();
                    bounds.width = widget->getWidth();
                }

                widget->setDimension(bounds);

                graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT,
                                                      (int)(mAlpha * 255.0f)));

                if (mLinewiseMode && r == mSelectedRow && c == 0)
                {
                    graphics->fillRectangle(gcn::Rectangle(0, y_offset,
                                                           getWidth(), height));
                }
                else if (!mLinewiseMode &&
                          c == mSelectedColumn && r == mSelectedRow)
                {
                    graphics->fillRectangle(gcn::Rectangle(x_offset, y_offset,
                                                           width, height));
                }

                graphics->pushClipArea(bounds);
                widget->draw(graphics);
                graphics->popClipArea();
            }

            x_offset += width;
        }

        y_offset += height;
    }

    if (mTopWidget)
    {
        gcn::Rectangle bounds = mTopWidget->getDimension();
        graphics->pushClipArea(bounds);
        mTopWidget->draw(graphics);
        graphics->popClipArea();
    }
}
예제 #19
0
void CInspectorTreeCtrl::drawValues(CPaintDC & dc)
{
    CRect rect;
    GetWindowRect(rect);

    dc.SetViewportOrg(0, 0);
    dc.SelectObject(linePen);
    dc.SetBkMode(TRANSPARENT);
    dc.SelectObject(GetFont());
    dc.SetTextColor(color_windowtext);  

    DRAWLINE(0, 0, rect.right, 0);

    int cWid0 = getColumnWidth(0);
    int cWid1 = getColumnWidth(1);

    int height = 0;
    HTREEITEM hItemFocus = GetSelectedItem();
    HTREEITEM hItem = GetFirstVisibleItem();
    while(hItem && height < rect.Height())
    {
        CRect iRect;
        GetItemRect(hItem, &iRect, FALSE);

        DRAWLINE(0, iRect.bottom, rect.right, iRect.bottom);
        height += iRect.Height();

        CTreeListItem * itemData = GetTreeListItem(hItem);
        if(itemData)
        {
            iRect.left = cWid0 + 6;
            iRect.right = cWid0 + cWid1;
            
            if(hItem == hItemFocus)
            {
                CRect whitespaceRect;
                GetItemRect(hItem, &whitespaceRect, TRUE);

                if(whitespaceRect.right < cWid0)
                {
                    whitespaceRect.left = whitespaceRect.right;
                    whitespaceRect.right = cWid0;
                
                    CWnd * focusWnd = GetFocus();
                    if(focusWnd && (focusWnd->m_hWnd == m_hWnd))        // I have focus             
                        dc.FillRect(whitespaceRect, &whitespaceHighlightBrush_Focused);                 
                    else                
                        dc.FillRect(whitespaceRect, &whitespaceHighlightBrush_Unfocused);                                   
                }               
                CString xpath;
                getTypeText(itemData->getType(), xpath, true);
                if(getFullXPath(hItem, xpath)) 
                {
                    CRect itemRect, r;
                    GetItemRect(hItem, &itemRect, FALSE);
                    r.UnionRect(&itemRect, &whitespaceRect);
                    tooltipCtrl->DelTool(this, TREE_TOOLTIP_ID);
                    tooltipCtrl->AddTool(this, xpath, r, TREE_TOOLTIP_ID);
                }
            }
            dc.DrawText(itemData->getValue(), &iRect, DT_SINGLELINE | DT_LEFT);
        }
        hItem = GetNextVisibleItem(hItem);      
    }
    DRAWLINE(cWid0, 0, cWid0, height);
}
예제 #20
0
/**
 * @brief       This method has been reimplemented. It manages the following actions:
 *               - Column resizing
 *               - Header button
 *
 * @param[in]   event       Mouse event
 *
 * @return      Nothing.
 */
void AbstractTableView::mouseMoveEvent(QMouseEvent* event)
{
    int wColIndex = getColumnIndexFromX(event->x());
    int wStartPos = getColumnPosition(wColIndex); // Position X of the start of column
    int wEndPos = getColumnPosition(wColIndex) + getColumnWidth(wColIndex); // Position X of the end of column
    bool wHandle = ((wColIndex != 0) && (event->x() >= wStartPos) && (event->x() <= (wStartPos + 2))) || ((event->x() <= wEndPos) && (event->x() >= (wEndPos - 2)));
    if(wColIndex == getColumnCount() - 1 && event->x() > viewport()->width()) //last column
        wHandle = false;

    switch(mGuiState)
    {
    case AbstractTableView::NoState:
    {
        if(event->buttons() == Qt::NoButton)
        {
            bool wHasCursor = cursor().shape() == Qt::SplitHCursor ? true : false;

            if((wHandle == true) && (wHasCursor == false))
            {
                setCursor(Qt::SplitHCursor);
                mColResizeData.splitHandle = true;
                mGuiState = AbstractTableView::ReadyToResize;
            }
            if((wHandle == false) && (wHasCursor == true))
            {
                unsetCursor();
                mColResizeData.splitHandle = false;
                mGuiState = AbstractTableView::NoState;
            }
        }
        else
        {
            QWidget::mouseMoveEvent(event);
        }
    }
    break;

    case AbstractTableView::ReadyToResize:
    {
        if(event->buttons() == Qt::NoButton)
        {
            if((wHandle == false) && (mGuiState == AbstractTableView::ReadyToResize))
            {
                unsetCursor();
                mColResizeData.splitHandle = false;
                mGuiState = AbstractTableView::NoState;
            }
        }
    }
    break;

    case AbstractTableView::ResizeColumnState:
    {
        int delta = event->x() - mColResizeData.lastPosX;
        bool bCanResize = (getColumnWidth(mColResizeData.index) + delta) >= 20;
        if(bCanResize)
        {
            int wNewSize = getColumnWidth(mColResizeData.index) + delta;
            setColumnWidth(mColResizeData.index, wNewSize);
            mColResizeData.lastPosX = event->x();
            updateViewport();
        }
    }
    break;

    case AbstractTableView::HeaderButtonPressed:
    {
        int wColIndex = getColumnIndexFromX(event->x());

        if((wColIndex == mHeader.activeButtonIndex) && (event->y() <= getHeaderHeight()) && (event->y() >= 0))
        {
            mColumnList[mHeader.activeButtonIndex].header.isMouseOver = true;
        }
        else
        {
            mColumnList[mHeader.activeButtonIndex].header.isMouseOver = false;
        }
    }
    break;

    default:
        break;
    }
}
예제 #21
0
/**
 * @brief       This method has been reimplemented. It paints the whole table.
 *
 * @param[in]   event       Paint event
 *
 * @return      Nothing.
 */
void AbstractTableView::paintEvent(QPaintEvent* event)
{
    if(!mAllowPainting)
        return;
    if(getColumnCount()) //make sure the last column is never smaller than the window
    {
        int totalWidth = 0;
        for(int i = 0; i < getColumnCount(); i++)
            totalWidth += getColumnWidth(i);
        int lastWidth = 0;
        for(int i = 0; i < getColumnCount() - 1; i++)
            lastWidth += getColumnWidth(i);
        int width = this->viewport()->width();
        lastWidth = width > lastWidth ? width - lastWidth : 0;
        int last = getColumnCount() - 1;
        if(totalWidth < width)
            setColumnWidth(last, lastWidth);
        else
            setColumnWidth(last, getColumnWidth(last));
    }

    Q_UNUSED(event);
    QPainter wPainter(this->viewport());
    int wViewableRowsCount = getViewableRowsCount();

    int scrollValue = -horizontalScrollBar()->value();

    int x = scrollValue;
    int y = 0;

    // Reload data if needed
    if(mPrevTableOffset != mTableOffset || mShouldReload == true)
    {
        prepareData();
        mPrevTableOffset = mTableOffset;
        mShouldReload = false;
    }

    // Paints background
    wPainter.fillRect(wPainter.viewport(), QBrush(backgroundColor));

    // Paints header
    if(mHeader.isVisible == true)
    {
        for(int i = 0; i < getColumnCount(); i++)
        {
            QStyleOptionButton wOpt;
            if((mColumnList[i].header.isPressed == true) && (mColumnList[i].header.isMouseOver == true))
                wOpt.state = QStyle::State_Sunken;
            else
                wOpt.state = QStyle::State_Enabled;

            wOpt.rect = QRect(x, y, getColumnWidth(i), getHeaderHeight());

            mHeaderButtonSytle.style()->drawControl(QStyle::CE_PushButton, &wOpt, &wPainter, &mHeaderButtonSytle);

            wPainter.setPen(headerTextColor);
            wPainter.drawText(QRect(x + 4, y, getColumnWidth(i) - 8, getHeaderHeight()), Qt::AlignVCenter | Qt::AlignLeft, mColumnList[i].title);

            x += getColumnWidth(i);
        }
    }

    x = scrollValue;
    y = getHeaderHeight();

    // Iterate over all columns and cells
    for(int j = 0; j < getColumnCount(); j++)
    {
        for(int i = 0; i < wViewableRowsCount; i++)
        {
            //  Paints cell contents
            if(i < mNbrOfLineToPrint)
            {
                // Don't draw cells if the flag is set, and no process is running
                //if(!mDrawDebugOnly || DbgIsDebugging())
                if(true)
                {
                    QString wStr = paintContent(&wPainter, mTableOffset, i, j, x, y, getColumnWidth(j), getRowHeight());

                    if(wStr.length())
                    {
                        wPainter.setPen(textColor);
                        wPainter.drawText(QRect(x + 4, y, getColumnWidth(j) - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr);
                    }
                }
            }

            // Paints cell right borders
            wPainter.setPen(separatorColor);
            wPainter.drawLine(x + getColumnWidth(j) - 1, y, x + getColumnWidth(j) - 1, y + getRowHeight() - 1);

            // Update y for the next iteration
            y += getRowHeight();
        }

        y = getHeaderHeight();
        x += getColumnWidth(j);
    }
    //emit repainted();
}