void LogListComponentGenerator::applyBordersAndBackground(Component* const TheComponent, List* const Parent, const std::string& Value, UInt32 Index, bool IsSelected, bool HasFocus) const { if(IsSelected && HasFocus) { if(getFocusedBorderHasPriority()) { TheComponent->setBorders(getFocusedBorder()); } else { TheComponent->setBorders(getSelectedBorder()); } if(getFocusedBackgroundHasPriority()) { TheComponent->setBackgrounds(getFocusedBackground()); } else { TheComponent->setBackgrounds(getSelectedBackground()); } } else if(IsSelected) { TheComponent->setBorders(getSelectedBorder()); TheComponent->setBackgrounds(getSelectedBackground()); } else if(HasFocus) { TheComponent->setBorders(getFocusedBorder()); TheComponent->setBackgrounds(getFocusedBackground()); } }
Border* AbstractWindow::getDrawnBorder(void) const { if(getDrawDecorations()) { if(getEnabled()) { if(getFocused()) { return getFocusedBorder(); } else if(_MouseInComponentLastMouse) { return getRolloverBorder(); } else { return getBorder(); } } else { return getDisabledBorder(); } } else { return NULL; } }
Border* Component::getDrawnBorder(void) const { if(getEnabled()) { if(getMouseOver()) { return getRolloverBorder(); } else if(getFocused()) { return getFocusedBorder(); } else { return getBorder(); } } else { return getDisabledBorder(); } }
void InternalWindow::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { if( ((whichField & FocusedFieldMask) || (whichField & TitlebarFieldMask))&& getTitlebar() != NULL && getDrawTitlebar() && !getTitlebar()->getEnabled()) { getTitlebar()->setEnabled(getFocused()); } if( (whichField & ActiveToolTipFieldMask) && getActiveToolTip() != NULL) { getActiveToolTip()->updateClipBounds(); } if( (whichField & ActivePopupMenusFieldMask) && getMFActivePopupMenus()->size() > 0) { _PopupConnections.clear(); for(UInt32 i(0) ; i<getMFActivePopupMenus()->size() ; ++i) { getActivePopupMenus(i)->setParentWindow(this); _PopupConnections[getActivePopupMenus(i)].push_back(boost::shared_ptr<boost::signals2::scoped_connection>(new boost::signals2::scoped_connection(getParentDrawingSurface()->getEventProducer()->connectMouseClicked(boost::bind(&InternalWindow::popupMenuMousePressed, this, _1))))); _PopupConnections[getActivePopupMenus(i)].push_back(boost::shared_ptr<boost::signals2::scoped_connection>(new boost::signals2::scoped_connection(getParentDrawingSurface()->getEventProducer()->connectMousePressed(boost::bind(&InternalWindow::popupMenuMousePressed, this, _1))))); _PopupConnections[getActivePopupMenus(i)].push_back(boost::shared_ptr<boost::signals2::scoped_connection>(new boost::signals2::scoped_connection(getParentDrawingSurface()->getEventProducer()->connectMouseReleased(boost::bind(&InternalWindow::popupMenuMouseReleased, this, _1))))); _PopupConnections[getActivePopupMenus(i)].push_back(boost::shared_ptr<boost::signals2::scoped_connection>(new boost::signals2::scoped_connection(getParentDrawingSurface()->getEventProducer()->connectKeyPressed(boost::bind(&InternalWindow::popupMenuKeyPressed, this, _1))))); _PopupConnections[getActivePopupMenus(i)].push_back(boost::shared_ptr<boost::signals2::scoped_connection>(new boost::signals2::scoped_connection(getParentDrawingSurface()->getEventProducer()->connectMouseMoved(boost::bind(&InternalWindow::popupMenuMouseMoved, this, _1))))); _PopupConnections[getActivePopupMenus(i)].push_back(boost::shared_ptr<boost::signals2::scoped_connection>(new boost::signals2::scoped_connection(getParentDrawingSurface()->getEventProducer()->connectMouseDragged(boost::bind(&InternalWindow::popupMenuMouseDragged, this, _1))))); } setLockInput(true); } if( (whichField & MenuBarFieldMask) && getMenuBar() != NULL) { getMenuBar()->setParentWindow(this); } if( (whichField & MenuBarFieldMask) || (whichField & TitlebarFieldMask)) { updateLayout(); } if( (whichField & TitleFieldMask) && getTitlebar() != NULL) { getTitlebar()->setTitle(getTitle()); } if( (whichField & TitlebarFieldMask) && getTitlebar() != NULL) { getTitlebar()->setParentWindow(this); } if((whichField & TitlebarFieldMask) || (whichField & BorderFieldMask) || (whichField & DisabledBorderFieldMask) || (whichField & FocusedBorderFieldMask) || (whichField & RolloverBorderFieldMask) || (whichField & DrawTitlebarFieldMask)) { TitlebarRefPtr TheTitlebar; if(getDrawTitlebar()) { TheTitlebar = getTitlebar(); } else { TheTitlebar = NULL; } if(getBorder() != NULL && getBorder()->getType().isDerivedFrom(WindowBorder::getClassType())) { dynamic_cast<WindowBorder*>(getBorder())->setTitlebar(TheTitlebar); } if(getDisabledBorder() != NULL && getDisabledBorder()->getType().isDerivedFrom(WindowBorder::getClassType())) { dynamic_cast<WindowBorder*>(getDisabledBorder())->setTitlebar(TheTitlebar); } if(getFocusedBorder() != NULL && getFocusedBorder()->getType().isDerivedFrom(WindowBorder::getClassType())) { dynamic_cast<WindowBorder*>(getFocusedBorder())->setTitlebar(TheTitlebar); } if(getRolloverBorder() != NULL && getRolloverBorder()->getType().isDerivedFrom(WindowBorder::getClassType())) { dynamic_cast<WindowBorder*>(getRolloverBorder())->setTitlebar(TheTitlebar); } } if( whichField & ClipBoundsFieldMask) { if(getTitlebar() != NULL) { getTitlebar()->updateClipBounds(); } } if( (whichField & TitlebarFieldMask) && getTitlebar() != NULL) { if(getTitlebar()->getTitleLabel() != NULL) { _TitleBarMousePressedConnection = getTitlebar()->getTitleLabel()->connectMousePressed(boost::bind(&InternalWindow::titlebarMousePressed, this, _1)); } if(getTitlebar()->getCloseButton() != NULL) { _CloseButtonActionConnection = getTitlebar()->getCloseButton()->connectActionPerformed(boost::bind(&InternalWindow::closeButtonAction, this, _1)); } if(getTitlebar()->getMaximizeButton() != NULL) { _MaximizeButtonActionConnection = getTitlebar()->getMaximizeButton()->connectActionPerformed(boost::bind(&InternalWindow::maximizeButtonAction, this, _1)); } if(getTitlebar()->getIconifyButton() != NULL) { _IconifyButtonActionConnection = getTitlebar()->getIconifyButton()->connectActionPerformed(boost::bind(&InternalWindow::iconifyButtonAction, this, _1)); } } if( (whichField & IconableFieldMask) && getTitlebar() != NULL) { getTitlebar()->setDrawIconify(getIconable()); } if( (whichField & MaximizableFieldMask) && getTitlebar() != NULL) { getTitlebar()->setDrawMaximize(getMaximizable()); } if( (whichField & ClosableFieldMask) && getTitlebar() != NULL) { getTitlebar()->setDrawClose(getClosable()); } Inherited::changed(whichField, origin, details); }
ComponentTransitPtr ColorChooserComboBoxComponentGenerator::getComboBoxComponent(ComboBox* const Parent, const boost::any& Value, UInt32 Index, bool IsSelected, bool HasFocus) { if(Value.empty()){ return ComponentTransitPtr(NULL); } PanelRefPtr TheComponent = Panel::create();//dynamic_pointer_cast<Component>(getDrawObjectPrototype()->shallowCopy()); TheComponent->setLayout(LayoutRefPtr(FlowLayout::create())); LabelRefPtr theColorLabel = Label::create(); //theColorLabel->setPreferredSize(Vec2f(50.0f,50.0f)); theColorLabel->setBorders(NULL); try { Color4f theColor = boost::any_cast<Color4f>(Value); if(theColor != NULL) { ColorLayerRefPtr theColorLabelBackground = ColorLayer::create(); theColorLabelBackground->setColor(theColor); theColorLabel->setBackgrounds(theColorLabelBackground); } } catch(boost::bad_any_cast &) { std::string ValueString; try { ValueString = lexical_cast(Value); } catch (boost::bad_lexical_cast &) { //Could not convert to string SWARNING << "ColorChooserComboBoxComponentGenerator::getComboBoxComponent - The elements should either be a Color4f value or a std::string\n"; } theColorLabel->setText(ValueString); if(IsSelected && HasFocus) { if(getFocusedTextColorHasPriority()) { theColorLabel->setTextColors(getFocusedTextColor()); } else { theColorLabel->setTextColors(getSelectedTextColor()); } } else if(IsSelected) { theColorLabel->setTextColors(getSelectedTextColor()); } else if(HasFocus) { theColorLabel->setTextColors(getFocusedTextColor()); } } TheComponent->pushToChildren(theColorLabel); if(IsSelected && HasFocus) { if(getFocusedBorderHasPriority()) { TheComponent->setBorders(getFocusedBorder()); } else { TheComponent->setBorders(getSelectedBorder()); } if(getFocusedBackgroundHasPriority()) { TheComponent->setBackgrounds(getFocusedBackground()); TheComponent->setForegrounds(getFocusedForeground()); } else { TheComponent->setBackgrounds(getSelectedBackground()); TheComponent->setForegrounds(getSelectedForeground()); } } else if(IsSelected) { TheComponent->setBorders(getSelectedBorder()); TheComponent->setBackgrounds(getSelectedBackground()); TheComponent->setForegrounds(getSelectedForeground()); } else if(HasFocus) { TheComponent->setBorders(getFocusedBorder()); TheComponent->setBackgrounds(getFocusedBackground()); TheComponent->setForegrounds(getFocusedForeground()); } return ComponentTransitPtr(TheComponent.get()); }
void InternalWindow::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { if( ((whichField & FocusedFieldMask) || (whichField & TitlebarFieldMask))&& getTitlebar() != NULL) { getTitlebar()->setEnabled(getFocused()); } if( (whichField & ActiveToolTipFieldMask) && getActiveToolTip() != NULL) { getActiveToolTip()->updateClipBounds(); } if( (whichField & ActivePopupMenusFieldMask) && getMFActivePopupMenus()->size() > 0) { for(UInt32 i(0) ; i<getMFActivePopupMenus()->size() ; ++i) { getActivePopupMenus(i)->setParentContainer(this); getActivePopupMenus(i)->setParentWindow(this); } getDrawingSurface()->getEventProducer()->addMouseListener(&_PopupMenuInteractionListener); getDrawingSurface()->getEventProducer()->addMouseMotionListener(&_PopupMenuInteractionListener); getDrawingSurface()->getEventProducer()->addKeyListener(&_PopupMenuInteractionListener); setLockInput(true); } if( (whichField & MenuBarFieldMask) && getMenuBar() != NULL) { getMenuBar()->setParentContainer(this); getMenuBar()->setParentWindow(this); } if( (whichField & MenuBarFieldMask) || (whichField & TitlebarFieldMask)) { updateLayout(); } if( (whichField & TitleFieldMask) && getTitlebar() != NULL) { getTitlebar()->setTitle(getTitle()); } if( (whichField & TitlebarFieldMask) && getTitlebar() != NULL) { getTitlebar()->setParentContainer(this); getTitlebar()->setParentWindow(this); } if((whichField & TitlebarFieldMask) || (whichField & BorderFieldMask) || (whichField & DisabledBorderFieldMask) || (whichField & FocusedBorderFieldMask) || (whichField & RolloverBorderFieldMask) || (whichField & DrawTitlebarFieldMask)) { TitlebarRefPtr TheTitlebar; if(getDrawTitlebar()) { TheTitlebar = getTitlebar(); } else { TheTitlebar = NULL; } if(getBorder() != NULL && getBorder()->getType().isDerivedFrom(WindowBorder::getClassType())) { dynamic_cast<WindowBorder*>(getBorder())->setTitlebar(TheTitlebar); } if(getDisabledBorder() != NULL && getDisabledBorder()->getType().isDerivedFrom(WindowBorder::getClassType())) { dynamic_cast<WindowBorder*>(getDisabledBorder())->setTitlebar(TheTitlebar); } if(getFocusedBorder() != NULL && getFocusedBorder()->getType().isDerivedFrom(WindowBorder::getClassType())) { dynamic_cast<WindowBorder*>(getFocusedBorder())->setTitlebar(TheTitlebar); } if(getRolloverBorder() != NULL && getRolloverBorder()->getType().isDerivedFrom(WindowBorder::getClassType())) { dynamic_cast<WindowBorder*>(getRolloverBorder())->setTitlebar(TheTitlebar); } } if( whichField & ClipBoundsFieldMask) { if(getTitlebar() != NULL) { getTitlebar()->updateClipBounds(); } } if( (whichField & TitlebarFieldMask) && getTitlebar() != NULL) { if(getTitlebar()->getTitleLabel() != NULL) { getTitlebar()->getTitleLabel()->addMouseListener(&_TitlebarStartDragListener); } if(getTitlebar()->getCloseButton() != NULL) { getTitlebar()->getCloseButton()->addActionListener(&_CloseButtonListener); } if(getTitlebar()->getMaximizeButton() != NULL) { getTitlebar()->getMaximizeButton()->addActionListener(&_MaximizeButtonListener); } if(getTitlebar()->getIconifyButton() != NULL) { getTitlebar()->getIconifyButton()->addActionListener(&_IconifyButtonListener); } } if( (whichField & IconableFieldMask) && getTitlebar() != NULL) { getTitlebar()->setDrawIconify(getIconable()); } if( (whichField & MaximizableFieldMask) && getTitlebar() != NULL) { getTitlebar()->setDrawMaximize(getMaximizable()); } if( (whichField & ClosableFieldMask) && getTitlebar() != NULL) { getTitlebar()->setDrawClose(getClosable()); } Inherited::changed(whichField, origin, details); }
void Button::drawInternal(Graphics* const TheGraphics, Real32 Opacity) const { Pnt2f TopLeft, BottomRight; getInsideBorderBounds(TopLeft, BottomRight); //If I have a DrawObject then Draw it UIDrawObjectCanvasRefPtr DrawnDrawObject = getDrawnDrawObject(); UIDrawObjectCanvasRefPtr BaseDrawObject = getBaseDrawObject(); if(DrawnDrawObject != NULL) { //Get the Draw Object Size Vec2f DrawObjectSize = DrawnDrawObject->getRequestedSize(); Vec2f BaseDrawObjectSize = BaseDrawObject->getRequestedSize(); if(getText() != "" && getFont() != NULL) { //Draw both the text and Draw Object //Get the Text Size Pnt2f TextTopLeft, TextBottomRight; getFont()->getBounds(getText(), TextTopLeft, TextBottomRight); Vec2f InternalsSize; if(getDrawObjectToTextAlignment() == ALIGN_DRAW_OBJECT_LEFT_OF_TEXT || getDrawObjectToTextAlignment() == ALIGN_DRAW_OBJECT_RIGHT_OF_TEXT) { InternalsSize.setValues((TextBottomRight.x()-TextTopLeft.x()) + DrawObjectSize.x() + getDrawObjectToTextPadding(), osgMax((TextBottomRight.y()-TextTopLeft.y()), DrawObjectSize.y())); } else { InternalsSize.setValues(osgMax((TextBottomRight.x()-TextTopLeft.x()), DrawObjectSize.x()), (TextBottomRight.y()-TextTopLeft.y()) + DrawObjectSize.y() + getDrawObjectToTextPadding()); } Pnt2f InternalAlignment; InternalAlignment = calculateAlignment(TopLeft, (BottomRight-TopLeft), InternalsSize,getAlignment().y(), getAlignment().x()); //Draw Object Alignment Pnt2f DrawObjectAlignedPosition; switch(getDrawObjectToTextAlignment()) { case ALIGN_DRAW_OBJECT_LEFT_OF_TEXT: DrawObjectAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, DrawObjectSize,0.5f, 0.0); break; case ALIGN_DRAW_OBJECT_RIGHT_OF_TEXT: DrawObjectAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, DrawObjectSize,0.5f, 1.0); break; case ALIGN_DRAW_OBJECT_ABOVE_TEXT: DrawObjectAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, DrawObjectSize,0.0f, 0.5); break; case ALIGN_DRAW_OBJECT_BELOW_TEXT: DrawObjectAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, DrawObjectSize,1.0f, 0.5); break; } //If active then translate the Text by the Active Offset DrawObjectAlignedPosition = DrawObjectAlignedPosition + getDrawnOffset(); DrawnDrawObject->setPosition( DrawObjectAlignedPosition ); //Text Alignment Pnt2f TextAlignedPosition; switch(getDrawObjectToTextAlignment()) { case ALIGN_DRAW_OBJECT_LEFT_OF_TEXT: TextAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, (TextBottomRight - TextTopLeft),0.5f, 1.0); break; case ALIGN_DRAW_OBJECT_RIGHT_OF_TEXT: TextAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, (TextBottomRight - TextTopLeft),0.5f, 0.0); break; case ALIGN_DRAW_OBJECT_ABOVE_TEXT: TextAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, (TextBottomRight - TextTopLeft),1.0f, 0.5); break; case ALIGN_DRAW_OBJECT_BELOW_TEXT: TextAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, (TextBottomRight - TextTopLeft),0.0f, 0.5); break; } drawText(TheGraphics, TextAlignedPosition, Opacity); } else { //Just Draw the Draw Object Pnt2f AlignedPosition; AlignedPosition = calculateAlignment(TopLeft, (BottomRight-TopLeft), BaseDrawObjectSize,getAlignment().y(), getAlignment().x()); //If active then translate the Text by the Active Offset AlignedPosition = AlignedPosition + getDrawnOffset(); DrawnDrawObject->setPosition( AlignedPosition ); } //Draw the DrawnDrawObject DrawnDrawObject->draw(TheGraphics, getOpacity()*Opacity); } else if(getText() != "" && getFont() != NULL) { //Just Draw the Text Pnt2f AlignedPosition; Pnt2f TextTopLeft, TextBottomRight; getFont()->getBounds(getText(), TextTopLeft, TextBottomRight); AlignedPosition = calculateAlignment(TopLeft, (BottomRight-TopLeft), (TextBottomRight - TextTopLeft),getAlignment().y(), getAlignment().x()); drawText(TheGraphics, AlignedPosition, Opacity); } //Focus Border if(getFocused() && getFocusedBorder() != NULL) { getFocusedBorder()->activateInternalDrawConstraints(TheGraphics,0,0,getSize().x(),getSize().y()); drawBorder(TheGraphics, getFocusedBorder(), Opacity); } }