void ScrolledImage::init(bool sManageChild)
	{
	/* Get the style sheet: */
	const StyleSheet* ss=getStyleSheet();
	
	/* Set the compound widget's borders: */
	setBorderWidth(ss->textfieldBorderWidth);
	setBorderType(Widget::LOWERED);
	
	/* Disable the image's borders: */
	//image->setBorderWidth(image->getBorderWidth());
	//image->setBorderType(Widget::PLAIN);
	
	/* Initialize the horizontal scroll bar: */
	horizontalScrollBar->setPositionRange(0,image->getImage().getSize(0),image->getImage().getSize(0));
	horizontalScrollBar->getValueChangedCallbacks().add(this,&ScrolledImage::scrollBarCallback);
	
	/* Initialize the vertical scroll bar: */
	verticalScrollBar->setPositionRange(0,image->getImage().getSize(1),image->getImage().getSize(1));
	verticalScrollBar->getValueChangedCallbacks().add(this,&ScrolledImage::scrollBarCallback);
	
	/* Manage the children: */
	image->manageChild();
	horizontalScrollBar->manageChild();
	verticalScrollBar->manageChild();
	
	/* Manage me: */
	if(sManageChild)
		manageChild();
	}
Exemple #2
0
TextFieldSlider::TextFieldSlider(const char* sName,Container* sParent,GLint sCharWidth,GLfloat sShaftLength,bool sManageChild)
	:Container(sName,sParent,false),
	 textField(new TextField("TextField",this,sCharWidth,false)),
	 slider(new Slider("Slider",this,Slider::HORIZONTAL,sShaftLength,false)),
	 sliderMapping(LINEAR),valueType(FLOAT),
	 valueMin(0.0),valueMax(1000.0),valueIncrement(1.0),value(500.0)
	{
	/* Get the style sheet: */
	const StyleSheet* ss=getStyleSheet();
	
	/* Initialize the compound widget: */
	setBorderWidth(0.0f);
	setBorderType(PLAIN);
	spacing=ss->size;
	
	/* Initialize the text field: */
	textField->setEditable(true);
	textField->getValueChangedCallbacks().add(this,&TextFieldSlider::textFieldValueChangedCallback);
	
	/* Initialize the slider: */
	slider->getValueChangedCallbacks().add(this,&TextFieldSlider::sliderValueChangedCallback);
	
	/* Manage the children: */
	textField->manageChild();
	slider->manageChild();
	
	/* Manage me: */
	if(sManageChild)
		manageChild();
	}
Exemple #3
0
PopupWindow::PopupWindow(const char* sName,WidgetManager* sManager,const char* sTitleString)
	:Container(sName,0,false),manager(sManager),
	 titleBar(0),hideButton(0),closeButton(0),
	 resizableMask(0x3),
	 childBorderWidth(0.0f),
	 child(0),
	 isResizing(false)
	 #if GLMOTIF_POPUPWINDOW_USE_RENDERCACHE
	 ,version(1)
	 #endif
	{
	/* Get the style sheet: */
	const StyleSheet* ss=manager->getStyleSheet();
	
	/* Create the title bar widget: */
	titleBar=new TitleBar("TitleBar",this,sTitleString,false);
	
	/* Set the popup window's default layout: */
	setBorderWidth(0.0f);
	setBorderType(Widget::PLAIN);
	setBorderColor(ss->borderColor);
	setBackgroundColor(ss->bgColor);
	setForegroundColor(ss->fgColor);
	childBorderWidth=ss->popupWindowChildBorderWidth;
	
	titleBar->manageChild();
	
	/* Create the hide button by default: */
	setHideButton(true);
	}
Exemple #4
0
NewButton::NewButton(const char* sName,Container* sParent,const char* sLabel,bool sManageChild)
	:SingleChildContainer(sName,sParent,false),
	 isArmed(false)
	{
	/* Get the style sheet: */
	const StyleSheet* ss=getStyleSheet();
	
	/* Button defaults to raised border: */
	setBorderType(Widget::RAISED);
	setBorderWidth(ss->buttonBorderWidth);
	
	/* Set the armed background color: */
	armedBackgroundColor=ss->buttonArmedBackgroundColor;
	
	/* Create the label child widget: */
	Label* label=new Label("ButtonLabel",this,sLabel);
	label->setBorderType(Widget::PLAIN);
	label->setBorderWidth(0.0f);
	
	/* Button defaults to some margin: */
	label->setMarginWidth(ss->buttonMarginWidth);
	
	/* Button defaults to centered text: */
	label->setHAlignment(GLFont::Center);
	
	/* Manage me: */
	if(sManageChild)
		manageChild();
	}
ScrolledListBox::ScrolledListBox(const char* sName,Container* sParent,ListBox::SelectionMode sSelectionMode,int sPreferredWidth,int sPreferredPageSize,bool sManageChild)
	:Container(sName,sParent,false),
	 listBox(new ListBox("ListBox",this,sSelectionMode,sPreferredWidth,sPreferredPageSize,false)),
	 verticalScrollBar(new ScrollBar("VerticalScrollBar",this,ScrollBar::VERTICAL,true,false)),
	 horizontalScrollBar(0)
	{
	/* Get the style sheet: */
	const StyleSheet* ss=getStyleSheet();
	
	/* Set the compound widget's borders: */
	setBorderWidth(ss->textfieldBorderWidth);
	setBorderType(Widget::LOWERED);
	
	/* Initialize the list box: */
	listBox->setBorderWidth(0.0f);
	listBox->setBorderType(Widget::PLAIN);
	listBox->getPageChangedCallbacks().add(this,&ScrolledListBox::listBoxPageChangedCallback);
	
	/* Initialize the vertical scroll bar: */
	verticalScrollBar->setPositionRange(0,0,listBox->getPageSize());
	verticalScrollBar->getValueChangedCallbacks().add(this,&ScrolledListBox::scrollBarCallback);
	
	/* Manage the children: */
	listBox->manageChild();
	verticalScrollBar->manageChild();
	
	/* Manage me: */
	if(sManageChild)
		manageChild();
	}
DropdownBox::DropdownBox(const char* sName,Container* sParent,bool sManageChild)
	:Label(sName,sParent,"",false),
	 popup(0),items(0),isPopped(false),
	 foundChild(0),armedChild(0),
	 arrow(GlyphGadget::FANCY_ARROW_DOWN,GlyphGadget::IN,0.0f),
	 numItems(0),
	 selectedItem(-1)
	{
	const GLMotif::StyleSheet& ss=*getManager()->getStyleSheet();
	
	/* Dropdown box defaults to raised border: */
	setBorderType(Widget::RAISED);
	setBorderWidth(ss.buttonBorderWidth);
	
	/* Dropdown box defaults to some margin: */
	setMarginWidth(ss.buttonMarginWidth);
	
	/* Set the arrow sizes: */
	spacing=ss.buttonBorderWidth+2.0f*ss.buttonMarginWidth;
	arrow.setGlyphSize(ss.size*0.25f);
	arrow.setBevelSize(ss.size*0.25f);
	arrow.setGlyphColor(backgroundColor);
	popupExtrudeSize=ss.size*4.0f;
	
	/* Set the label insets: */
	setInsets(0.0f,arrow.getPreferredBoxSize()+spacing);
	
	/* Create a pop-up containing the item labels: */
	popup=new Popup("Popup",getManager());
	popup->setBorderWidth(ss.buttonBorderWidth);
	popup->setBorderType(Widget::PLAIN);
	popup->setBorderColor(borderColor);
	popup->setBackgroundColor(backgroundColor);
	popup->setForegroundColor(foregroundColor);
	popup->setMarginWidth(0.0f);
	
	/* Create a container for the item labels: */
	items=new RowColumn("Items",popup,false);
	items->setBorderWidth(0.0f);
	items->setOrientation(RowColumn::VERTICAL);
	items->setNumMinorWidgets(1);
	items->setMarginWidth(0.0f);
	items->setSpacing(ss.buttonBorderWidth);
	
	items->manageChild();
	
	/* Manage me: */
	if(sManageChild)
		manageChild();
	}
Exemple #7
0
ScaleBar::ScaleBar(const char* sName,GLMotif::WidgetManager* sManager)
	:GLMotif::Widget(sName,0,false),manager(sManager),
	 targetLength(getDisplaySize()*Scalar(0.2)),
	 currentMantissa(1),currentExponent(0),currentNavLength(1),currentScale(1),
	 lengthLabel(0),scaleLabel(0),
	 currentPhysLength(0)
	{
	/* Set widget parameters: */
	setBorderWidth(0.0f);
	setBorderType(GLMotif::Widget::PLAIN);
	
	/* Set default background and foreground colors: */
	Color bgColor=Vrui::getBackgroundColor();
	bgColor[3]=0.0f;
	Color fgColor;
	for(int i=0;i<3;++i)
		fgColor[i]=1.0f-bgColor[i];
	fgColor[3]=1.0f;
	setBorderColor(bgColor);
	setBackgroundColor(bgColor);
	setForegroundColor(fgColor);
	
	/* Create the initial scale bar length label: */
	if(getCoordinateManager()->getUnit().unit!=Geometry::LinearUnit::UNKNOWN)
		{
		char labelText[10];
		snprintf(labelText,sizeof(labelText),"1 %s",getCoordinateManager()->getUnit().getAbbreviation());
		lengthLabel=new GLLabel(labelText,*getUiFont());
		}
	else
		lengthLabel=new GLLabel("1",*getUiFont());
	lengthLabel->setBackground(bgColor);
	lengthLabel->setForeground(fgColor);
	scaleLabel=new GLLabel("1:1",*getUiFont());
	scaleLabel->setBackground(bgColor);
	scaleLabel->setForeground(fgColor);
	
	/* Calculate the initial navigation-space scale bar length: */
	calcSize(getNavigationTransformation());
	
	/* Resize the widget: */
	GLMotif::Vector newSize=calcNaturalSize();
	GLMotif::Vector newOrigin=GLMotif::Vector(0.0f,0.0f,0.0f);
	newOrigin[0]=-newSize[0]*0.5f;
	resize(GLMotif::Box(newOrigin,newSize));
	
	/* Register a navigation change callback with the Vrui kernel: */
	getNavigationTransformationChangedCallbacks().add(this,&ScaleBar::navigationChangedCallback);
	}
Exemple #8
0
Popup::Popup(const char* sName,WidgetManager* sManager)
	:Container(sName,0,false),manager(sManager),
	 title(0),child(0)
	{
	/* Get the style sheet: */
	const StyleSheet* ss=manager->getStyleSheet();
	
	/* Set the popup window's default layout: */
	marginWidth=ss->popupMarginWidth;
	titleSpacing=ss->popupTitleSpacing;
	
	setBorderWidth(0.0f);
	setBorderType(Widget::PLAIN);
	setBorderColor(ss->borderColor);
	setBackgroundColor(ss->bgColor);
	setForegroundColor(ss->fgColor);
	}
Exemple #9
0
NewButton::NewButton(const char* sName,Container* sParent,bool sManageChild)
	:SingleChildContainer(sName,sParent,false),
	 isArmed(false)
	{
	/* Get the style sheet: */
	const StyleSheet* ss=getStyleSheet();
	
	/* Button defaults to raised border: */
	setBorderType(Widget::RAISED);
	setBorderWidth(ss->buttonBorderWidth);
	
	/* Set the armed background color: */
	armedBackgroundColor=ss->buttonArmedBackgroundColor;
	
	/* Manage me: */
	if(sManageChild)
		manageChild();
	}
Exemple #10
0
Button::Button(const char* sName,Container* sParent,const char* sLabel,bool sManageChild)
	:Label(sName,sParent,sLabel,false),
	 isArmed(false)
	{
	/* Get the style sheet: */
	const StyleSheet* ss=getStyleSheet();
	
	/* Button defaults to raised border: */
	setBorderType(Widget::RAISED);
	setBorderWidth(ss->buttonBorderWidth);
	
	/* Button defaults to some margin: */
	setMarginWidth(ss->buttonMarginWidth);
	
	/* Button defaults to centered text: */
	setHAlignment(GLFont::Center);
	
	/* Set the armed background color: */
	armedBackgroundColor=ss->buttonArmedBackgroundColor;
	
	/* Manage me: */
	if(sManageChild)
		manageChild();
	}
Exemple #11
0
NewButton::NewButton(const char* sName,Container* sParent,const Vector& preferredSize,bool sManageChild)
	:SingleChildContainer(sName,sParent,false),
	 isArmed(false)
	{
	/* Get the style sheet: */
	const StyleSheet* ss=getStyleSheet();
	
	/* Button defaults to raised border: */
	setBorderType(Widget::RAISED);
	setBorderWidth(ss->buttonBorderWidth);
	
	/* Set the armed background color: */
	armedBackgroundColor=ss->buttonArmedBackgroundColor;
	
	/* Create the blind child: */
	Blind* blind=new Blind("ButtonBlind",this);
	blind->setBorderType(Widget::PLAIN);
	blind->setBorderWidth(0.0f);
	blind->setPreferredSize(preferredSize);
	
	/* Manage me: */
	if(sManageChild)
		manageChild();
	}
DropdownBox::DropdownBox(const char* sName,Container* sParent,const std::vector<std::string>& sItems,bool sManageChild)
	:Label(sName,sParent,sItems[0].c_str(),false),
	 popup(0),items(0),isPopped(false),
	 foundChild(0),armedChild(0),
	 arrow(GlyphGadget::FANCY_ARROW_DOWN,GlyphGadget::IN,0.0f),
	 numItems(sItems.size()),
	 selectedItem(0)
	{
	const GLMotif::StyleSheet& ss=*getManager()->getStyleSheet();
	
	/* Dropdown box defaults to raised border: */
	setBorderType(Widget::RAISED);
	setBorderWidth(ss.buttonBorderWidth);
	
	/* Dropdown box defaults to some margin: */
	setMarginWidth(ss.buttonMarginWidth);
	
	/* Set the arrow sizes: */
	spacing=ss.buttonBorderWidth+2.0f*ss.buttonMarginWidth;
	arrow.setGlyphSize(ss.size*0.25f);
	arrow.setBevelSize(ss.size*0.25f);
	arrow.setGlyphColor(backgroundColor);
	popupExtrudeSize=ss.size*4.0f;
	
	/* Set the label insets: */
	setInsets(0.0f,arrow.getPreferredBoxSize()+spacing);
	
	/* Create a pop-up containing the item labels: */
	popup=new Popup("Popup",getManager());
	popup->setBorderWidth(ss.buttonBorderWidth);
	popup->setBorderType(Widget::PLAIN);
	popup->setBorderColor(borderColor);
	popup->setBackgroundColor(backgroundColor);
	popup->setForegroundColor(foregroundColor);
	popup->setMarginWidth(0.0f);
	
	/* Create a container for the item labels: */
	items=new RowColumn("Items",popup,false);
	items->setBorderWidth(0.0f);
	items->setOrientation(RowColumn::VERTICAL);
	items->setNumMinorWidgets(1);
	items->setMarginWidth(0.0f);
	items->setSpacing(ss.buttonBorderWidth);
	
	/* Create a button for each list item: */
	for(int i=0;i<numItems;++i)
		{
		char itemButtonName[40];
		snprintf(itemButtonName,sizeof(itemButtonName),"ItemButton%d",i);
		Button* button=new Button(itemButtonName,items,sItems[i].c_str());
		button->setBorderType(Widget::PLAIN);
		button->setBorderWidth(0.0f);
		button->setHAlignment(GLFont::Left);
		button->getSelectCallbacks().add(itemSelectedCallbackWrapper,this);
		}
	
	items->manageChild();
	
	/* Manage me: */
	if(sManageChild)
		manageChild();
	}