Esempio n. 1
0
void CCell::initButton( QMainWindow * mWnd )
{
  Helper * help = Helper::Instance();
  button = new QPushButton( QIcon(":/" + help->GetItemNameByState( hextype )), "",  mWnd );
  button->setFixedWidth( GetButtonWidth() );
  button->setFixedHeight( GetButtonHeight() );
  button->setIconSize( QSize( GetButtonWidth(), GetButtonHeight() ) );
  button->setFlat( true );
  button->setCheckable(true);
}
    gfx::Size DialogClientView::GetPreferredSize()
    {
        gfx::Size prefsize = contents_view()->GetPreferredSize();
        int button_height = 0;
        if(has_dialog_buttons())
        {
            if(cancel_button_)
            {
                button_height = cancel_button_->height();
            }
            else
            {
                button_height = ok_button_->height();
            }
            // Account for padding above and below the button.
            button_height += kDialogButtonContentSpacing + kButtonVEdgeMargin;

            // Make sure the view is sized to the buttons's width if they are wider than
            // the contents.
            int width = 0;
            if(cancel_button_)
            {
                width += GetButtonWidth(ui::MessageBoxFlags::DIALOGBUTTON_CANCEL);
            }
            if(ok_button_)
            {
                width += GetButtonWidth(ui::MessageBoxFlags::DIALOGBUTTON_OK);
                if(cancel_button_)
                {
                    width += kRelatedButtonHSpacing;
                }
            }
            if(extra_view_)
            {
                width += extra_view_->GetPreferredSize().width();
                if(cancel_button_ || ok_button_)
                {
                    width += kRelatedButtonHSpacing;
                }
            }
            if(width > 0)
            {
                width += 2 * kButtonHEdgeMargin;
                prefsize.set_width(std::max(prefsize.width(), width));
            }
        }
        if(bottom_view_)
        {
            gfx::Size bottom_pref = bottom_view_->GetPreferredSize();
            prefsize.Enlarge(0, bottom_pref.height() + kButtonVEdgeMargin);
        }
        prefsize.Enlarge(0, button_height);
        return prefsize;
    }
 void DialogClientView::LayoutDialogButtons()
 {
     gfx::Rect lb = GetContentsBounds();
     gfx::Rect extra_bounds;
     int bottom_y = lb.bottom() - kButtonVEdgeMargin;
     int button_height = 0;
     if(bottom_view_)
     {
         gfx::Size bottom_pref = bottom_view_->GetPreferredSize();
         bottom_y -= bottom_pref.height() + kButtonVEdgeMargin + kButtonVEdgeMargin;
     }
     if(cancel_button_)
     {
         gfx::Size ps = cancel_button_->GetPreferredSize();
         int button_width = std::max(
             GetButtonWidth(ui::MessageBoxFlags::DIALOGBUTTON_CANCEL), ps.width());
         int button_x = lb.right() - button_width - kButtonHEdgeMargin;
         int button_y = bottom_y - ps.height();
         cancel_button_->SetBounds(button_x, button_y, button_width, ps.height());
         // The extra view bounds are dependent on this button.
         extra_bounds.set_width(std::max(0, cancel_button_->x()));
         extra_bounds.set_y(cancel_button_->y());
         button_height = std::max(button_height, ps.height());
     }
     if(ok_button_)
     {
         gfx::Size ps = ok_button_->GetPreferredSize();
         int button_width = std::max(
             GetButtonWidth(ui::MessageBoxFlags::DIALOGBUTTON_OK), ps.width());
         int ok_button_right = lb.right() - kButtonHEdgeMargin;
         if(cancel_button_)
         {
             ok_button_right = cancel_button_->x() - kRelatedButtonHSpacing;
         }
         int button_x = ok_button_right - button_width;
         int button_y = bottom_y - ps.height();
         ok_button_->SetBounds(button_x, button_y, ok_button_right-button_x,
             ps.height());
         // The extra view bounds are dependent on this button.
         extra_bounds.set_width(std::max(0, ok_button_->x()));
         extra_bounds.set_y(ok_button_->y());
         button_height = std::max(button_height, ps.height());
     }
     if(extra_view_)
     {
         gfx::Size ps = extra_view_->GetPreferredSize();
         extra_bounds.set_x(lb.x() + kButtonHEdgeMargin);
         int height = size_extra_view_height_to_buttons_ ?
             std::max(ps.height(), button_height) : ps.height();
         extra_bounds.set_height(height);
         extra_view_->SetBoundsRect(extra_bounds);
     }
 }
Esempio n. 4
0
void COXCalendarEdit::OnDropButton()
{
	CRect rect;
	GetClientRect(rect);
	ClientToScreen(rect);
	rect.right += GetButtonWidth();
	CRect rectParent = rect;
	rect.top = rect.bottom;
	rect.left = rect.right;

	// Get the size of the calendar control
	RECT rectSize;
	m_Calendar.GetMinReqRect(&rectSize);
	rect.left -= rectSize.right;
	rect.bottom += rectSize.bottom;
	
	// Read the initial date
	CString strText;
	GetWindowText(strText);
	COleDateTime dtInitialDate = GetDateFromString(strText);
	if (dtInitialDate.GetStatus() != COleDateTime::valid)
		dtInitialDate = COleDateTime::GetCurrentTime();

	// Display the calendar popup window
	COleDateTime dtPickedDate;
	BOOL bDatePicked = m_Calendar.Pick(rect, rectParent, dtInitialDate, dtPickedDate);
	if (bDatePicked)
		SetWindowText(GetStringFromDate(dtPickedDate));
}
void COXListEdit::OnDropButton()
{
	CRect rect;
	GetClientRect(rect);
	ClientToScreen(rect);
	rect.right += GetButtonWidth();
	CRect rectParent = rect;
	rect.top = rect.bottom;

	// Determine the height of the list box
	int iItemsMax = m_DropList.GetCount();
	if (iItemsMax > 20)
		iItemsMax = 20;

	rect.bottom += iItemsMax * (m_DropList.GetItemHeight(0) + 1);
	if (iItemsMax == 1)
		rect.bottom += 1;

	// Display the drop list
	::SetFocus(NULL);
	int iSel = m_DropList.Pick(rect, rectParent);
	if (iSel != -1)
	{
		CString strText;
		m_DropList.GetText(iSel, strText);
		SetWindowText(strText);
		m_pPropertiesWnd->FinishEditing();
	}
}
Esempio n. 6
0
CRect CEnEdit::GetButtonRectByIndex(int nBtn) const
{
	int nOffset = 0;

	for (int nIndex = 0; nIndex < nBtn; nIndex++)
		nOffset += GetButtonWidth(nIndex);

	CRect rButton;
	GetClientRect(rButton);

	rButton.left = rButton.right + nOffset;
	rButton.right += nOffset + GetButtonWidth(nBtn);
	rButton.top -= m_nTopBorder;
	rButton.bottom += m_nBottomBorder;

	ClientToScreen(rButton);

	return rButton;
}
Esempio n. 7
0
void CEnEdit::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) 
{
	if (!(GetStyle() & ES_MULTILINE))
	{
		if (bCalcValidRects)
		{
			m_bFirstShow = FALSE; // in case we get here before OnNcPaint()
		
			int nBtn = m_aButtons.GetSize();

			while (nBtn--)
				lpncsp->rgrc[0].right -= GetButtonWidth(nBtn);

			lpncsp->rgrc[0].top += m_nTopBorder;
			lpncsp->rgrc[0].bottom -= m_nBottomBorder;
		}
	}
	
	CMaskEdit::OnNcCalcSize(bCalcValidRects, lpncsp);
}
CRect COXCoolComboBox::GetButtonRect() const 
{
    CRect rect(0,0,0,0);
	BOOL bSimpleCombo=((GetStyle()&0x000f)==CBS_SIMPLE);
	if(bSimpleCombo)
		return rect;

    GetClientRect(&rect);

    int nRightMargin=GetRightMargin();
	int nTopMargin=GetTopMargin();
	int nBottomMargin=GetBtmMargin();
	int nButtonWidth=GetButtonWidth();

    rect.left=rect.right-nRightMargin-::GetSystemMetrics(SM_CXVSCROLL);
    rect.top+=nTopMargin;
    rect.right=rect.left+nButtonWidth;
    rect.bottom-=nBottomMargin;

    if(rect.left<0)
        rect.left=0;

    return rect;
}
void COXCoolComboBox::OnPaint() 
{
	if(!IsInCoolState())
	{
		Default();
		return;
	}

	// set up all the pens we are likely to need
    HPEN penDefault=(HPEN)GetStockObject(BLACK_PEN);
    static CPen penHilite(PS_SOLID,1,GetSysColor(COLOR_3DHIGHLIGHT));
    static CPen penShadow(PS_SOLID,1,GetSysColor(COLOR_3DSHADOW));
    static CPen penFace3D(PS_SOLID,1,GetSysColor(COLOR_3DFACE));
    static CPen penDkShad3D(PS_SOLID,1,GetSysColor(COLOR_3DDKSHADOW));

    // store margins for future use
    int nLeftMargin=GetLeftMargin(); 
	int nRightMargin=GetRightMargin();
	int nTopMargin=GetTopMargin();
	int nBottomMargin=GetBtmMargin();
    CRect button_rect=GetButtonRect();

	const BOOL bSimpleCombo=((GetStyle()&0x000f)==CBS_SIMPLE);
    const BOOL bIsEnabled=IsWindowEnabled();
	const BOOL bIsHot=IsInHotState() & bIsEnabled;

    // paint background
    CPaintDC paintdc(this);
    CDC* dc=&paintdc;

    CRect rect, rectClient, rectInternal; // temp rect, client rect, internal rect respectively

    GetClientRect(rectClient);
	rectClient.right-=::GetSystemMetrics(SM_CXVSCROLL)-GetButtonWidth();

	if(bSimpleCombo)
	{
		ASSERT(::IsWindow(m_edit.GetSafeHwnd()));
		CRect rectEdit;
		m_edit.GetWindowRect(rectEdit);
		rectClient.bottom=rectClient.top+rectEdit.Height()+5;
	}

    // set up internal rectangle
    rectInternal=rectClient;
    rectInternal.left+=nLeftMargin;
    rectInternal.top+=nTopMargin;
    rectInternal.right-=nRightMargin;
    rectInternal.bottom-=nBottomMargin;

    rect=rectInternal;
	if(!button_rect.IsRectEmpty())
		rect.right=button_rect.left;
    if(!bIsEnabled)
        ::FillRect(dc->m_hDC,&rect,GetSysColorBrush(COLOR_3DFACE));
    else
        ::FillRect(dc->m_hDC,&rect,GetSysColorBrush(COLOR_WINDOW));

    // do default painting
    if(!::IsWindow(m_edit.GetSafeHwnd()))
    {
        DRAWITEMSTRUCT dis={ sizeof(&dis) };
        dis.CtlType=ODT_COMBOBOX;
        dis.CtlID=GetWindowLongPtr(m_hWnd, GWL_ID);
        dis.itemID=GetCurSel();
        dis.itemAction=ODA_DRAWENTIRE;
        dis.hwndItem=m_hWnd;
        dis.hDC=dc->m_hDC;
        dis.rcItem=CRect(nLeftMargin+1,nTopMargin+1, 
			button_rect.left-1,rectClient.bottom-nBottomMargin-1);
        dis.itemData=GetItemData(GetCurSel());
        dis.itemState=((::GetFocus()==GetSafeHwnd() && !IsDroppedDown()) ? 
			ODS_FOCUS : 0);

        DrawItem(&dis);
    }

    // now do our painting - first borderect...
    // but first exclude the 'real' client area from the DC
    dc->SelectClipRgn(NULL);   // from drawing background
    dc->ExcludeClipRect(&rectInternal);

    // draw border
	if(!bIsHot)
	{
		// now paint background 
	    if(bSimpleCombo)
			FillRect(dc->m_hDC, &rectClient, ::GetSysColorBrush(COLOR_WINDOW));
		else
			FillRect(dc->m_hDC, &rectClient, ::GetSysColorBrush(COLOR_3DFACE));

		// fill in small area to the left of edit window in appropriate colour, 
		// to make window look bigger
		rect=rectClient;
		rect.top+=nTopMargin;
		rect.left+=nLeftMargin-1;
		rect.right=rect.left+1;
		rect.bottom-=nBottomMargin;

		if(bIsEnabled)
			FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_WINDOW));
		else
			FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_3DFACE));
	}
	else
	{
		// HOT case - difficult to describe, but reasonably obvious
		rect=rectClient;
		rect.left++;
		rect.right--;
		rect.top++;
		rect.bottom-=1+EXTRA_BOTTOM_MARGIN;            

		// paint background 
		FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_3DFACE));

		// and border
		rect=rectClient;
		SelectObject(dc->m_hDC,penShadow);
		dc->MoveTo(0,0);
		dc->LineTo(rect.right,0);
		dc->MoveTo(0,0);
		dc->LineTo(0,rect.bottom-1-EXTRA_BOTTOM_MARGIN);

		SelectObject(dc->m_hDC,penHilite);
		dc->LineTo(rect.right-1,rect.bottom-1-EXTRA_BOTTOM_MARGIN);
		dc->LineTo(rect.right-1,rect.top);

		// and paint extra margin
		if(EXTRA_BOTTOM_MARGIN)
		{
			rect=rectClient;
			rect.top=rect.bottom-EXTRA_BOTTOM_MARGIN;        

			FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_3DFACE));
		}
	}

    // unselect the clip region
    SelectClipRgn(dc->m_hDC, NULL);

    // now draw highlight border, if disabled
    if(!bIsEnabled)
    {
        SelectObject(dc->m_hDC, GetStockObject(NULL_BRUSH));
        SelectObject(dc->m_hDC, penHilite);
        dc->Rectangle(rectInternal.left-1, rectInternal.top-1, 
			rectInternal.right+1, rectInternal.bottom+1);
    }

    // and now for the button
    BOOL pressed=IsDroppedDown();
    rect=button_rect;

    // do the background
    if(bIsHot)
    {
        rect.bottom--;
        rect.right++;
    }

    if(bIsHot || pressed || !bIsEnabled)
    {
        ::FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_3DFACE));
    }
    else
    {
		if(bIsEnabled)
		{
			// cold and unpressed
			SelectObject(dc->m_hDC, penHilite);
			SelectObject(dc->m_hDC, GetSysColorBrush(COLOR_3DFACE));
			::Rectangle(dc->m_hDC, rect.left, rect.top, rect.right, rect.bottom);
		}
    }

    rect=button_rect; // set again

    if(bIsHot || pressed)
    {
        if(pressed)
        {
            SelectObject(dc->m_hDC, penShadow);
            dc->MoveTo(rect.left , rect.top);
            dc->LineTo(rect.right, rect.top);
            dc->MoveTo(rect.left , rect.top);
            dc->LineTo(rect.left , rect.bottom);
        }
        else
        {
            SelectObject(dc->m_hDC, penHilite);
            dc->MoveTo(rect.right,  rect.top);
            dc->LineTo(rect.left+1, rect.top);
            dc->LineTo(rect.left+1, rect.bottom);
            SelectObject(dc->m_hDC, penFace3D);
            dc->MoveTo(rect.left, rect.top);
            dc->LineTo(rect.left, rect.bottom);
            SelectObject(dc->m_hDC, penShadow);
            dc->MoveTo(rect.left , rect.bottom - 1);
            dc->LineTo(rect.right-1, rect.bottom - 1);
            dc->LineTo(rect.right-1, rect.top);
        }

        SelectObject(dc->m_hDC, penDefault);
    }

    // now draw shadowy arrow
    SelectObject(dc->m_hDC, penDkShad3D);
    SelectObject(dc->m_hDC, ::GetSysColorBrush(COLOR_3DDKSHADOW));

    POINT p[3];

    p[0].x=rect.left +((rect.right - rect.left) / 3);
    p[1].x=rect.left +(2 *(rect.right - rect.left) / 3) + 1;
    p[2].x=(p[0].x + p[1].x) / 2;

    if(((p[1].x - p[0].x) % 2))
        p[1].x--;

    p[0].y=(rect.top + rect.bottom / 2) -(p[1].x - p[0].x) / 4 - 1;
    p[1].y=p[0].y;
    p[2].y=p[0].y +(p[1].x - p[0].x) / 2;

    if(pressed)    // offset by a pixel
    {
        p[0].x++;
        p[0].y++;
        p[1].x++;
        p[1].y++;
        p[2].x++;
        p[2].y++;
    }

    Polygon(dc->m_hDC, p, 3);

}
Esempio n. 10
0
void GroupLayout::AddSkinHeader( SkinHeader & skin_header )
{
    assert( m_Group && m_Screen );
    int oldBW = GetButtonWidth();


    bool saveFitWidth = m_FitWidthFlag;
    bool saveSameLine = m_SameLineFlag;


    vector< VspButton* > buttons;

    // Size of Set label buttons
    int setW = 25;
    // Size of Equal label button
    int eqW = 20;

    // Width of choice
    int cw = m_ChoiceButtonWidth + m_SliderWidth;

    m_FitWidthFlag = true;

    // Gap width
    int gw = FitWidth( 2 * setW + eqW + oldBW + 2 * cw, 2 * m_ButtonWidth )/2;

    m_FitWidthFlag = false;
    m_SameLineFlag = true;

    Choice* cont_choice = new Choice();
    cont_choice->AddItem( "C0" );
    cont_choice->AddItem( "C1" );
    cont_choice->AddItem( "C2" );
    AddChoice( *cont_choice, "Enforce" );

    AddX( gw );

    //==== Left Set Button ====//
    SetButtonWidth( setW );
    buttons.push_back( AddParmButton( "Set" ) );

    AddX( oldBW );

    //==== Equal Button ====//
    SetButtonWidth( eqW );
    buttons.push_back( AddParmButton( "=" ) );

    //==== Right Set Button ====//
    SetButtonWidth( setW );
    buttons.push_back( AddParmButton( "Set" ) );

    NewLineX();

    m_FitWidthFlag = saveFitWidth;
    m_SameLineFlag = saveSameLine;

    skin_header.Init( m_Screen, cont_choice, buttons );

    ForceNewLine();

    SetButtonWidth( oldBW );
}