bool KWindow::updateInsets() { /* * called by Menu assign to detect appropriate * client insets */ RECT rcl, rclc; GetClientRect( hwnd, &rclc); rcl.left = rclc.left; rcl.top = rclc.top; rcl.right = rclc.right; rcl.bottom = rclc.bottom; #if !defined(UNDER_CE) AdjustWindowRectEx( &rclc, GetWindowLong( hwnd, GWL_STYLE), (GetMenu( hwnd) != NULL), 0); #else AdjustWindowRectEx( &rclc, GetWindowLong( hwnd, GWL_STYLE), 0, 0); if ( hbar ) rclc.top += CommandBar_Height( hbar); #endif setInsets( rcl.left-rclc.left, rcl.top-rclc.top, rclc.right-rcl.right, rclc.bottom-rcl.bottom, false ); return TRUE; }
void Component::setBorder(border::Border* b) { // delete current border, and assign new border. border = b; if(border != 0) { setInsets(border->getBorderInsets()); } invalidate(); }
KWindow( HWND parent, TCHAR* title, int style, int x, int y, int width, int height) { RECT rcl = { x, y, x+width, y+height }; style |= WS_CLIPCHILDREN; AdjustWindowRectEx( &rcl, style, FALSE, 0); setInsets( x-rcl.left, y-rcl.top, rcl.right-x-width, rcl.bottom-y-height, true); hwnd = CreateWindow( TEXT("window"), title, style, x, y, width, height, parent, (HMENU)0, NULL, NULL); defWndProc = (WNDPROC)DefWindowProc; #if defined(UNDER_CE) hbar = NULL; #endif }
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(); }
void DropdownBox::setArrowSize(GLfloat newArrowSize) { /* Adjust the arrow glyph: */ arrow.setGlyphSize(newArrowSize); /* Adjust the label position: */ setInsets(0.0f,arrow.getPreferredBoxSize()+spacing); /* Try adjusting the widget size to accomodate the new setting: */ if(isManaged) parent->requestResize(this,calcNaturalSize()); else resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize())); }
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(); }