|
csGridBagConstraint Class ReferencecsGridBagLayout is the most flexible layout class. More...
Inheritance diagram for csGridBagConstraint:
Detailed DescriptioncsGridBagLayout is the most flexible layout class.Here is how it works: A grid is laid over the layout components canvas. This yields rows and columns (oh, really ?) which cross in cells. Each cell is able to hold a single component (which again can be layout components). You are able to define whether a cell should span one or more columns and same with rows. Furthermore you can define how additional space is distributed among columns/rows if the layout is resized and becomes larger or smaller. A component in a cell is not set to fit a priori. You must tell if it should be resized to cover the cell canvas. If you choose to not resize the component in a cell you can set a relative position within the cell like: CENTER ... center the component in the middle of the cell NORTH ... center the component horizontally and put it at top of cell For more variations see below. To make sure there is space at left/right and/or top/bottom between cell borders and the components edges use ipadx and ipady. The grids cells are filled from left to right and top to bottom in the sequence components with the csGridBagLayout as parent are created. The filling starts at cell (0,0). To mark the last cell in a row simply set gridwidth to REMAINDER. The next component added is set in the next rows first cell. You can temporary break the filling sequence by setting gridx and/or gridy to a particular value. To continue the normal filling process set gridx/gridy to RELATIVE.
csGridBagLayout *gb = new csGridBagLayout (window);
window->SendCommand (cscmdWindowSetClient, (void*)gb);
gb->c.fill = csGridBagConstraint::NONE; // dont resize components gb->c.weightx = 1.0; // scale cell horizontally only gb->c.weighty = 0.0; // align component within cell gb->c.anchor = csGridBagConstraint::SOUTHWEST; gb->c.ipady = 5; // distance to listbox below csStatic *label = new csStatic (gb, NULL, "Message history"); label->SetSize (300, 20);
gb->c.ipady = 0; csSpinBox *spb = new csSpinBox (gb); spb->SetSize (80,20); spb->SetLimits (1, 1000); spb->SetValue (200);
gb->c.ipady = 5; gb->c.weightx = 1.0; gb->c.weighty = 0.0; gb->c.anchor = csGridBagConstraint::SOUTHWEST; gb->c.gridwidth = csGridBagConstraint::REMAINDER; // last component in row gb->label = new csStatic (gb, NULL, "Players"); gb->label->SetSize (300, 20);
// add a listbox that shows the last few messages sent gb->c.gridwidth = 2; gb->c.fill = csGridBagConstraint::BOTH; gb->c.weightx = 1.0; gb->c.weighty = 0.0; gb->c.insets.xmin = 0; gb->c.ipady = 0; csListBox *hist = new csListBox (gb, CSLBS_VSCROLL); hist->SetSize (100, 100); hist->SetState (CSS_SELECTABLE, false);
gb->c.fill = csGridBagConstraint::BOTH; gb->c.weightx = 0.0; gb->c.weighty = 1.0; gb->c.gridwidth = csGridBagConstraint::REMAINDER; // add a listbox for the players in the arena csListBox *playerlist = new csListBox (gb); playerlist->SetSize (100, 100);
// add a editline for sending HOST - messages gb->c.fill = csGridBagConstraint::NONE; gb->c.gridx = csGridBagConstraint::RELATIVE; gb->c.gridwidth = 2; gb->c.gridheight = csGridBagConstraint::REMAINDER;; gb->c.weighty = 0.1; gb->c.weightx = 1.0; gb->c.anchor = csGridBagConstraint::NORTH; gb->c.insets.xmin = 20; csInputLine *msgline = new csInputLine (gb); msgline->SetSize (300, 20); msgline->SetText ("Test Test"); msgline->SetSelection (0,999);
gb->c.fill = csGridBagConstraint::BOTH; gb->c.gridwidth = csGridBagConstraint::REMAINDER; gb->c.weighty = 1.0; csFlowLayout *flow = new csFlowLayout (gb); flow->SetSize (100, 100); CreateButton (flow, 7000, "Kick", 0, 0); CreateButton (flow, 7001, "Observe", 10, 0); CreateButton (flow, 7002, "Fly w/", 20, 0); CreateButton (flow, 7003, "Fool", 30, 0); CreateButton (flow, 7004, "Strip Weapons", 40, 0);
... void CreateButton (csComponent *parent, int id, const char *text, int xpos, int ypos) { csButton *b= new csButton (parent, id); b->SetPos (xpos, ypos); b->SetSuggestedSize (0, 0); b->SetText (text); }
Member Data Documentation
The documentation for this class was generated from the following file: Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000 |