Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::UI::Widget::UnitMenu Class Reference

A drop down menu for choosing unit types. More...

#include <unit-menu.h>

Inheritance diagram for Inkscape::UI::Widget::UnitMenu:
Inkscape::UI::Widget::DropDownList Inkscape::UI::Widget::PrefUnit

Public Member Functions

 UnitMenu ()
 Construct a UnitMenu.
 
 UnitMenu (DropDown::BaseObjectType *cobject, Glib::RefPtr< Gtk::Builder > const &)
 
 ~UnitMenu () override
 
bool setUnitType (UnitType unit_type, bool svg_length=false)
 Adds the unit type to the widget.
 
bool resetUnitType (UnitType unit_type, bool svg_length=false)
 Removes all unit entries, then adds the unit type to the widget.
 
void addUnit (Unit const &u)
 Adds a unit, possibly user-defined, to the menu.
 
bool setUnit (Glib::ustring const &unit)
 Sets the dropdown widget to the given unit abbreviation.
 
Unit const * getUnit () const
 Returns the Unit object corresponding to the current selection in the dropdown widget.
 
Glib::ustring getUnitAbbr () const
 Returns the abbreviated unit name of the selected unit.
 
UnitType getUnitType () const
 Returns the UnitType of the selected unit.
 
double getUnitFactor () const
 Returns the unit factor for the selected unit.
 
int getDefaultDigits () const
 Returns the recommended number of digits for displaying numbers of this unit type.
 
double getDefaultStep () const
 Returns the recommended step size in spin buttons displaying units of this type.
 
double getDefaultPage () const
 Returns the recommended page size (when hitting pgup/pgdn) in spin buttons displaying units of this type.
 
double getConversion (Glib::ustring const &new_unit_abbr, Glib::ustring const &old_unit_abbr="no_unit") const
 Returns the conversion factor required to convert values of the currently selected unit into units of type new_unit_abbr.
 
bool isAbsolute () const
 Returns true if the selected unit is not dimensionless (false for %, true for px, pt, cm, etc).
 
bool isRadial () const
 Returns true if the selected unit is radial (deg or rad).
 
Glib::SignalProxyProperty signal_changed ()
 
virtual void on_changed ()
 
- Public Member Functions inherited from Inkscape::UI::Widget::DropDownList
 DropDownList ()
 
 DropDownList (BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &builder)
 
unsigned int append (const Glib::ustring &item)
 
Glib::ustring get_string (unsigned int position) const
 
unsigned int get_item_count () const
 
void remove_all ()
 
Glib::SignalProxyProperty signal_changed ()
 
void enable_search (bool enable=true)
 
void set_row_separator_func (std::function< bool(unsigned int)> callback)
 

Private Member Functions

Glib::ustring get_selected_string () const
 

Private Attributes

UnitType _type
 

Detailed Description

A drop down menu for choosing unit types.

Definition at line 30 of file unit-menu.h.

Constructor & Destructor Documentation

◆ UnitMenu() [1/2]

Inkscape::UI::Widget::UnitMenu::UnitMenu ( )

Construct a UnitMenu.

Definition at line 17 of file unit-menu.cpp.

References on_changed().

◆ UnitMenu() [2/2]

Inkscape::UI::Widget::UnitMenu::UnitMenu ( DropDown::BaseObjectType *  cobject,
Glib::RefPtr< Gtk::Builder > const &   
)

◆ ~UnitMenu()

Inkscape::UI::Widget::UnitMenu::~UnitMenu ( )
overridedefault

Member Function Documentation

◆ addUnit()

void Inkscape::UI::Widget::UnitMenu::addUnit ( Unit const &  u)

Adds a unit, possibly user-defined, to the menu.

Definition at line 58 of file unit-menu.cpp.

References Inkscape::Util::UnitTable::addUnit(), Inkscape::UI::Widget::DropDownList::append(), and Inkscape::Util::UnitTable::get().

Referenced by Inkscape::UI::Widget::StrokeStyle::StrokeStyle().

◆ get_selected_string()

Glib::ustring Inkscape::UI::Widget::UnitMenu::get_selected_string ( ) const
private

Definition at line 164 of file unit-menu.cpp.

References Inkscape::UI::Widget::DropDownList::get_string().

Referenced by getUnit(), and getUnitAbbr().

◆ getConversion()

double Inkscape::UI::Widget::UnitMenu::getConversion ( Glib::ustring const &  new_unit_abbr,
Glib::ustring const &  old_unit_abbr = "no_unit" 
) const

◆ getDefaultDigits()

int Inkscape::UI::Widget::UnitMenu::getDefaultDigits ( ) const

Returns the recommended number of digits for displaying numbers of this unit type.


Definition at line 110 of file unit-menu.cpp.

References getUnit().

Referenced by Inkscape::UI::Widget::ScalarUnit::initScalar().

◆ getDefaultPage()

double Inkscape::UI::Widget::UnitMenu::getDefaultPage ( ) const

Returns the recommended page size (when hitting pgup/pgdn) in spin buttons displaying units of this type.

Definition at line 121 of file unit-menu.cpp.

References getDefaultStep().

Referenced by Inkscape::UI::Widget::ScalarUnit::initScalar().

◆ getDefaultStep()

double Inkscape::UI::Widget::UnitMenu::getDefaultStep ( ) const

Returns the recommended step size in spin buttons displaying units of this type.

Definition at line 115 of file unit-menu.cpp.

References getUnit().

Referenced by getDefaultPage(), and Inkscape::UI::Widget::ScalarUnit::initScalar().

◆ getUnit()

◆ getUnitAbbr()

◆ getUnitFactor()

double Inkscape::UI::Widget::UnitMenu::getUnitFactor ( ) const

Returns the unit factor for the selected unit.

Definition at line 105 of file unit-menu.cpp.

References getUnit().

◆ getUnitType()

UnitType Inkscape::UI::Widget::UnitMenu::getUnitType ( ) const

Returns the UnitType of the selected unit.

Definition at line 100 of file unit-menu.cpp.

References getUnit().

Referenced by Inkscape::UI::Widget::ScalarUnit::getUnitType(), isAbsolute(), and isRadial().

◆ isAbsolute()

bool Inkscape::UI::Widget::UnitMenu::isAbsolute ( ) const

◆ isRadial()

bool Inkscape::UI::Widget::UnitMenu::isRadial ( ) const

Returns true if the selected unit is radial (deg or rad).

Definition at line 151 of file unit-menu.cpp.

References getUnitType().

Referenced by Inkscape::UI::Dialog::Transformation::applyPageSkew().

◆ on_changed()

void Inkscape::UI::Widget::UnitMenu::on_changed ( )
virtual

Reimplemented in Inkscape::UI::Widget::PrefUnit.

Definition at line 160 of file unit-menu.cpp.

Referenced by UnitMenu().

◆ resetUnitType()

bool Inkscape::UI::Widget::UnitMenu::resetUnitType ( UnitType  unit_type,
bool  svg_length = false 
)

Removes all unit entries, then adds the unit type to the widget.

This extracts the corresponding units from the unit map matching the given type, and appends them to the dropdown widget. It causes the primary unit for the given unit_type to be selected.

Definition at line 51 of file unit-menu.cpp.

References Inkscape::UI::Widget::DropDownList::remove_all(), and setUnitType().

Referenced by Inkscape::UI::Widget::ScalarUnit::resetUnitType().

◆ setUnit()

◆ setUnitType()

bool Inkscape::UI::Widget::UnitMenu::setUnitType ( UnitType  unit_type,
bool  svg_length = false 
)

◆ signal_changed()

Member Data Documentation

◆ _type

UnitType Inkscape::UI::Widget::UnitMenu::_type
private

Definition at line 140 of file unit-menu.h.

Referenced by getUnit(), and setUnitType().


The documentation for this class was generated from the following files: