//Set a MinHeight so that the Expando won't get any shorter than this void ExpandoTextCtrl::SetMinHeight(const int &h) { if(minHeight != h) { minHeight = h; RequestResize(); } }
void Table::Attach( const Widget::Ptr& widget, const sf::Rect<sf::Uint32>& rect, int x_options, int y_options, const sf::Vector2f& padding ) { assert( rect.width > 0 ); assert( rect.height > 0 ); // Store widget in a table cell object. priv::TableCell cell( widget, rect, x_options, y_options, padding ); m_cells.push_back( cell ); // Check if we need to enlarge rows/columns. if( rect.left + rect.width >= m_columns.size() ) { std::size_t old_size( m_columns.size() ); m_columns.resize( rect.left + rect.width ); // Set default spacings. for( std::size_t col_index = old_size; col_index < m_columns.size(); ++col_index ) { m_columns[col_index].spacing = m_general_spacings.x; } } if( rect.top + rect.height >= m_rows.size() ) { std::size_t old_size( m_rows.size() ); m_rows.resize( rect.top + rect.height ); // Set default spacings. for( std::size_t row_index = old_size; row_index < m_rows.size(); ++row_index ) { m_rows[row_index].spacing = m_general_spacings.y; } } // Add widget to container. Add( widget ); // Request new size. RequestResize(); }
void CTabItem_Normal::SetCaption(LPCTSTR lpszCaption) { m_strCaption = lpszCaption; CTabItem::SetCaption(lpszCaption); if (IsDynDesireLength()) RequestResize(); }
void Widget::RequestResize() { m_requisition = CalculateRequisition(); if( m_custom_requisition ) { if( m_custom_requisition->x > 0.f ) { m_requisition.x = std::max( m_custom_requisition->x, m_requisition.x ); } if( m_custom_requisition->y > 0.f ) { m_requisition.y = std::max( m_custom_requisition->y, m_requisition.y ); } } HandleRequisitionChange(); auto parent = m_parent.lock(); // Notify observers. GetSignals().Emit( OnSizeRequest ); if( parent ) { parent->RequestResize(); } else { sf::FloatRect allocation( GetAllocation().left, GetAllocation().top, std::max( GetAllocation().width, m_requisition.x ), std::max( GetAllocation().height, m_requisition.y ) ); SetAllocation( allocation ); } }
void ComboBox::RemoveItem( IndexType index ) { if( index >= m_entries.size() ) { return; } m_entries.erase( m_entries.begin() + index ); // Make sure active item index keeps valid. if( m_active_item != NONE ) { if( m_active_item == index ) { m_active_item = NONE; } else if( m_active_item > index ) { m_active_item = m_entries.size() == 0 ? NONE : m_active_item - 1; } } if( IsMouseInWidget() ) { SetState( PRELIGHT ); } else { SetState( NORMAL ); } RequestResize(); }
FilePickerDialog::Ptr FilePickerDialog::Create( boost::filesystem::path initial_path ) { auto ptr = Ptr( new FilePickerDialog( initial_path ) ); ptr->Add(ptr->m_main_box); ptr->m_main_box->PackEnd(ptr->m_panel_box, true, true); ptr->m_main_box->PackEnd(ptr->m_buttons_box, false, true); ptr->m_panel_box->PackEnd(ptr->m_locations_listbox, false, true); ptr->m_panel_box->PackEnd(ptr->m_directory_box, true, true); ptr->m_directory_box->PackEnd(ptr->m_directory_entry_box, false, true); ptr->m_directory_box->PackEnd(ptr->m_directory_paths_listbox, true, true); ptr->m_directory_box->PackEnd(ptr->m_filename_box, false, true); ptr->m_directory_entry_box->PackEnd(ptr->m_current_directory_entry, true, true); ptr->m_directory_entry_box->PackEnd(ptr->m_new_directory_button, false, true); ptr->m_filename_box->PackEnd(ptr->m_filename_entry, true, true); ptr->m_buttons_box->PackEnd(ptr->m_ok_button, true, true); ptr->m_buttons_box->PackEnd(ptr->m_cancel_button, false, true); ptr->RequestResize(); ptr->m_locations_listbox->RequestResize(); ptr->m_new_directory_button->RequestResize(); ptr->m_current_directory_entry->RequestResize(); ptr->m_directory_paths_listbox->RequestResize(); ptr->m_filename_entry->RequestResize(); ptr->m_ok_button->RequestResize(); ptr->m_cancel_button->RequestResize(); return ptr; }
void ComboBox::ChangeItem( IndexType index, const sf::String& text ) { if( index >= m_entries.size() ) { return; } m_entries[index] = text; RequestResize(); }
void ComboBox::PrependItem( const sf::String& text ) { m_entries.insert( m_entries.begin(), text ); if( m_active_item != NONE ) { ++m_active_item; } RequestResize(); }
void ComboBox::InsertItem( IndexType index, const sf::String& text ) { m_entries.insert( m_entries.begin() + index, text ); if( m_active_item != NONE && m_active_item >= index ) { ++m_active_item; } RequestResize(); }
void Window::HandleAdd( Widget::Ptr child ) { Bin::HandleAdd( child ); if( GetChild() ) { // Reset allocation so the window will be as large as required. SetAllocation( sf::FloatRect( GetAllocation().left, GetAllocation().top, 1.f, 1.f ) ); RequestResize(); } }
void Container::Remove( const Widget::Ptr& widget ) { WidgetsList::iterator iter( std::find( m_children.begin(), m_children.end(), widget ) ); if( iter != m_children.end() ) { m_children.erase( iter ); RequestResize(); HandleRemove( widget ); } }
void Label::SetText( const sf::String& text ) { m_text = text; if( m_wrap ) { WrapText(); } RequestResize(); Invalidate(); }
void Table::SetRowSpacings( float spacing ) { for( std::size_t row_index = 0; row_index < m_rows.size(); ++row_index ) { m_rows[row_index].spacing = spacing; } m_general_spacings.y = spacing; UpdateRequisitions(); RequestResize(); }
bool ExpandoTextCtrl::SetStyle(long start, long end, const wxTextAttr &style) { bool success = InputBox::SetStyle(start, end, style); //Force resize check RequestResize(); return success; }
void Table::SetColumnSpacings( float spacing ) { for( std::size_t column_index = 0; column_index < m_columns.size(); ++column_index ) { m_columns[column_index].spacing = spacing; } m_general_spacings.x = spacing; UpdateRequisitions(); RequestResize(); }
void Table::SetRowSpacing( std::size_t index, float spacing ) { if( index >= m_rows.size() ) { return; } m_rows[index].spacing = spacing; UpdateRequisitions(); RequestResize(); }
void Widget::SetRequisition( const sf::Vector2f& requisition ) { if( requisition.x > 0.f || requisition.y > 0.f ) { m_custom_requisition.reset( new sf::Vector2f( requisition ) ); } else { m_custom_requisition.reset(); } RequestResize(); }
void Container::RemoveAll() { while( !m_children.empty() ) { Widget::Ptr widget = m_children.back(); m_children.pop_back(); widget->SetParent( Widget::Ptr() ); HandleRemove( widget ); } RequestResize(); }
bool Window::HandleAdd( Widget::Ptr child ) { if( !Bin::HandleAdd( child ) ) { return false; } // Reset allocation so the window will be as large as required. SetAllocation( sf::FloatRect( GetAllocation().left, GetAllocation().top, 1.f, 1.f ) ); RequestResize(); return true; }
void ComboBox::AppendItem( const sf::String& text ) { m_entries.push_back( text ); if( IsMouseInWidget() ) { SetState( State::PRELIGHT ); } else { SetState( State::NORMAL ); } RequestResize(); }
void Widget::SetRequisition( const sf::Vector2f& requisition ) { if( requisition.x > 0.f || requisition.y > 0.f ) { delete m_custom_requisition; m_custom_requisition = new sf::Vector2f( requisition ); } else { delete m_custom_requisition; m_custom_requisition = 0; } RequestResize(); }
void Container::Add( const Widget::Ptr& widget ) { if( IsChild( widget ) ) { return; } m_children.push_back( widget ); HandleAdd( widget ); // Check if HandleAdd still wants the little boy. if( IsChild( widget ) ) { widget->SetParent( shared_from_this() ); RequestResize(); } }
void Window::SetStyle( std::uint8_t style ) { m_style = style; // Make sure dragging and resizing operations are cancelled. m_dragging = false; m_resizing = false; RequestResize(); Invalidate(); if( GetChild() ) { GetChild()->SetAllocation( GetClientRect() ); } }
void Label::HandleRequisitionChange() { if( m_wrap ) { WrapText(); } static auto calculate_y_requisition = false; if( !calculate_y_requisition ) { calculate_y_requisition = true; RequestResize(); } else { calculate_y_requisition = false; } }
void ComboBox::PrependItem( const sf::String& text ) { m_entries.insert( m_entries.begin(), text ); if( m_active_item != NONE ) { ++m_active_item; } if( IsMouseInWidget() ) { SetState( State::PRELIGHT ); } else { SetState( State::NORMAL ); } RequestResize(); }
void ComboBox::InsertItem( IndexType index, const sf::String& text ) { m_entries.insert( m_entries.begin() + index, text ); if( m_active_item != NONE && m_active_item >= index ) { ++m_active_item; } if( IsMouseInWidget() ) { SetState( State::PRELIGHT ); } else { SetState( State::NORMAL ); } RequestResize(); }
void ComboBox::ChangeItem( IndexType index, const sf::String& text ) { if( index >= m_entries.size() ) { return; } m_entries[index] = text; if( IsMouseInWidget() ) { SetState( PRELIGHT ); } else { SetState( NORMAL ); } RequestResize(); }
void Image::SetImage( const sf::Image& image ) { if( !image.getSize().x || !image.getSize().y ) { return; } if( m_image.getSize() == image.getSize() ) { m_image = image; sfg::Renderer::Get().UpdateImage( m_texture_offset, image ); } else { m_image = image; RequestResize(); Invalidate(); } }
void Label::HandleSizeChange() { if( !m_wrap || ( GetAllocation().width <= 0 ) ) { return; } WrapText(); static auto calculate_y_requisition = false; if( !calculate_y_requisition ) { calculate_y_requisition = true; RequestResize(); } else { calculate_y_requisition = false; } }
void Widget::Show( bool show ) { if( show == IsLocallyVisible() ) { return; } auto old_global_visibility = IsGloballyVisible(); // Flip the visible bit since we know show != IsLocallyVisible() m_visible = !m_visible; HandleLocalVisibilityChange(); if( old_global_visibility != IsGloballyVisible() ) { HandleGlobalVisibilityChange(); } RequestResize(); }