Exemplo n.º 1
0
void PlatformScrollbar::paint(GraphicsContext* graphicsContext, const IntRect& damageRect)
{
    if (controlSize() != RegularScrollbar) {
        m_opt.state |= QStyle::State_Mini;
    } else {
        m_opt.state &= ~QStyle::State_Mini;
    }
    m_opt.orientation = (orientation() == VerticalScrollbar) ? Qt::Vertical : Qt::Horizontal;
    QStyle *s = QApplication::style();
    if (orientation() == HorizontalScrollbar) {
        m_opt.rect.setHeight(horizontalScrollbarHeight(controlSize()));
        m_opt.state |= QStyle::State_Horizontal;
    } else {
        m_opt.rect.setWidth(verticalScrollbarWidth(controlSize()));
        m_opt.state &= ~QStyle::State_Horizontal;
    }

    if (graphicsContext->paintingDisabled() || !m_opt.rect.isValid())
        return;

    QRect clip = m_opt.rect.intersected(damageRect);
    // Don't paint anything if the scrollbar doesn't intersect the damage rect.
    if (clip.isEmpty())
        return;

    QPainter *p = graphicsContext->platformContext();
    p->save();
    p->setClipRect(clip);
    m_opt.sliderValue = value();
    m_opt.sliderPosition = value();
    m_opt.pageStep = m_visibleSize;
    m_opt.singleStep = m_lineStep;
    m_opt.minimum = 0;
    m_opt.maximum = qMax(0, m_totalSize - m_visibleSize);
    if (m_pressedPart != QStyle::SC_None) {
        m_opt.activeSubControls = m_pressedPart;
    } else {
        m_opt.activeSubControls = m_hoveredPart;
    }

    const QPoint topLeft = m_opt.rect.topLeft();
#ifdef Q_WS_MAC
    QApplication::style()->drawComplexControl(QStyle::CC_ScrollBar, &m_opt, p, 0);
#else
    p->translate(topLeft);
    m_opt.rect.moveTo(QPoint(0, 0));

    // The QStyle expects the background to be already filled
    p->fillRect(m_opt.rect, m_opt.palette.background());

    QApplication::style()->drawComplexControl(QStyle::CC_ScrollBar, &m_opt, p, 0);
    m_opt.rect.moveTo(topLeft);
#endif
    p->restore();
}
// ---------------------------------------------------------------------------
// CAknPointerEventModifier::ModifyEvent
// ---------------------------------------------------------------------------
//
TBool CAknPointerEventModifier::ModifyEvent( TStackItem& aItem, 
    TPointerEvent& aEvent, CCoeControl*& aDestination )
    {
    TBool wasModified = EFalse;
    
    // Control window's existence has been checked already in 
    // CAknPointerEventModifier::Push.
    if ( !aItem.iControl->DrawableWindow()->IsFaded() )
        {
        TBool isVertical = ( aItem.iControl->Size().iHeight > aItem.iControl->Size().iWidth );
        
        if ( aDestination == aItem.iParent )
            {
            // calculate hit area
            TRect hitArea( aItem.iControl->Position() + 
                aItem.iExtensionArea.iTl, aItem.iExtensionArea.Size() );
            TSize controlSize( aItem.iControl->Size() );

            if ( hitArea.Contains( aEvent.iPosition ) )
                {
                if ( aItem.iControl->OwnsWindow() )
                    {
                    aDestination = aItem.iControl;
                    
                    if ( isVertical )
                        {
                        aEvent.iPosition.iX = controlSize.iWidth >> 1;
                        aEvent.iPosition.iY -= aItem.iControl->Position().iY;
                        }
                    else
                        {
                        aEvent.iPosition.iX -= aItem.iControl->Position().iX;
                        aEvent.iPosition.iY = controlSize.iHeight >> 1;
                        }
                    }
int Scrollbar::scrollbarThickness() const
{
    int thickness = orientation() == HorizontalScrollbar ? height() : width();
    if (!thickness || !m_hostWindow)
        return thickness;
    return m_hostWindow->windowToViewportScalar(m_theme.scrollbarThickness(controlSize()));
}
Exemplo n.º 4
0
void HintControl::SetText(const WideString &hintMessage)
{
    Size2i requestedSize = hintText->GetFont()->GetStringSize(hintMessage);
    Vector2 controlSize((float32)requestedSize.dx + 20.f, (float32)requestedSize.dy + 10.f);
    hintText->SetRect(Rect(0, 0, controlSize.dx, controlSize.dy));
    this->SetSize(controlSize);

    hintText->SetText(hintMessage);
}
Exemplo n.º 5
0
// Constructor
DialEntryPanel::DialEntryPanel(wxWindow* parent, const wxPoint& pos, const wxSize& size) :
   wxPanel(parent, IDR_DIAL_ENTRY_PANEL, pos, size, wxTAB_TRAVERSAL, "DialEntryPanel"),
   mpSizer(NULL),
   mpComboBox(NULL),
   mpOutline(NULL),
   mpListener(NULL)
{

    wxColor* pPanelColor = & (sipXezPhoneSettings::getInstance().getBackgroundColor());
    SetBackgroundColour(*pPanelColor);

    wxPoint origin(0,0);
    mpOutline = new wxStaticBox(this, -1, "Dial", origin, size);
    mpOutline->SetBackgroundColour(*pPanelColor);

    mpSizer = new wxStaticBoxSizer(mpOutline, wxHORIZONTAL);

    wxSize controlSize(150, 20);
    mpComboBox = new wxComboBox(this, IDR_DIAL_ENTRY_TEXT, "", wxDefaultPosition, controlSize);
        mpComboBox->SetBackgroundColour(*pPanelColor);
    mpSizer->Add(mpComboBox);
    // init the combo
    UtlDList& list = sipXezPhoneSettings::getInstance().getRecentNumberList();
    UtlDListIterator iterator(list);
    UtlString* pTemp;
    while (pTemp = (UtlString*)iterator())
    {
        mpComboBox->Append(pTemp->data());
    }


    mpSizer->Add(10, 20); // add a spacer

    controlSize.SetWidth(30);
    controlSize.SetHeight(30);
    wxBitmap bitmap("res/dial.bmp", wxBITMAP_TYPE_BMP );
    bitmap.SetMask(new wxMask(bitmap, * (wxTheColourDatabase->FindColour("RED"))));

    wxColor* wxLightBlue = wxTheColourDatabase->FindColour("LIGHT BLUE");
    mpDialButton = new wxBitmapButton(this, IDR_DIAL_ENTRY_BUTTON, bitmap, wxDefaultPosition, controlSize);
    mpDialButton->SetBackgroundColour(*wxLightBlue);
    mpSizer->Add(mpDialButton);

    SetSizer(mpSizer, true);
    SetAutoLayout(TRUE);
    Layout();

    // add a state machine observer
    mpListener = new DialEntryPhoneStateMachineObserver(this);
    PhoneStateMachine::getInstance().addObserver(mpListener);
}
Exemplo n.º 6
0
// ---------------------------------------------------------
// CMsgHeader::SetAndGetSizeL
//
// Calculates and sets the size for the header and returns new size as reference
// aSize. If aInit == ETrue, sets also size for the controls by calling their
// SetAndGetSizeL functions.
// ---------------------------------------------------------
//
void CMsgHeader::SetAndGetSizeL( TSize& aSize, TBool aInit )
    {
    aSize = MsgEditorCommons::MsgHeaderPane().Size();

    TInt numberOfControls( iControls->Count() );
    iMargins.iTop = 0;
    iMargins.iBottom = numberOfControls ? MsgEditorCommons::MsgBaseLineDelta() : 
                                          0;
                                          
    TInt marginsDeltaHeight = iMargins.iTop + iMargins.iBottom;
    TInt marginsDeltaWidth = iMargins.iLeft + iMargins.iRight;
    TSize headerSize( aSize.iWidth, marginsDeltaHeight );
    TSize controlSize( 0, 0 );

    controlSize.iWidth = aSize.iWidth - marginsDeltaWidth;
    CMsgBaseControl* control = NULL;
    TInt minimumHeigth = marginsDeltaHeight;

    for ( TInt cc = 0; cc < numberOfControls; cc++ )
        {
        controlSize.iHeight = aSize.iHeight;
        control = (*iControls)[cc];

        if ( aInit )
            {
            control->SetAndGetSizeL( controlSize );
            }
        else
            {
            controlSize = control->Size();
            }

        headerSize.iHeight += control->DistanceFromComponentAbove() + controlSize.iHeight /* + 1 */;
        minimumHeigth += control->DistanceFromComponentAbove() + control->MinimumSize().iHeight /* + 1 */;

        //MEBLOGGER_WRITEF(_L("MEB: CMsgHeader::SetAndGetSizeL: headerSize.iHeight %d "), headerSize.iHeight);
        }

    if ( minimumHeigth < marginsDeltaHeight )
        // make top margin higher if there is no space for the icon
        {
        TInt additionalTopMargin = marginsDeltaHeight - minimumHeigth;
        headerSize.iHeight += additionalTopMargin;
        iMargins.iTop += additionalTopMargin;
        }

    SetSizeWithoutNotification( headerSize );
    aSize = headerSize;
    }
Exemplo n.º 7
0
int PlatformScrollbar::height() const
{
    return orientation() == HorizontalScrollbar ?
        horizontalScrollbarHeight(controlSize()) : Widget::height();
}
Exemplo n.º 8
0
int PlatformScrollbar::width() const
{
    return orientation() == VerticalScrollbar ?
        verticalScrollbarWidth(controlSize()) : Widget::width();
}
Exemplo n.º 9
0
void Simulable::checkControlSize(const ConsistentVector &control) const {
  if (control.size() != controlSize()) {
    throw std::runtime_error("Control size must correspond.");
  }
}