/**** * * Implementation of spec-desogn-editor.h. * */ #include "label.h" #include "spec-design-editor.h" #include #include SpecDesignEditor::SpecDesignEditor(Screen* s) : View(s) { /* * Make this's window (inherited from View) a tray, which is the easiest * way to give the window an opaque background. */ w = new Tray(); /* * Allocate a dummy button state. This wont be used, but the string editor * and string browser constructors want one. */ ButtonState* bs = new ButtonState(); /* * Allocate the string editors, text editor, and string browser. */ nameed = new StringEditor(bs, " "); acced = new StringEditor(bs, " "); ched = new StringEditor(bs, " "); commed = new FullTextEditor(4, 40); clsb = new StringBrowser(bs, 7, 15); /* * Clear out the blank text in the string editors. The blank text argument * to the constructor was a convenient way to size the width of the string * editors, but we want them to be empty of characters when the UI starts * up, so we call the Message function to do this. */ nameed->Message(""); acced->Message(""); ched->Message(""); } void SpecDesignEditor::Compose() { VBox* namevb = new VBox(); // VBox for the name label and editor VBox* accvb = new VBox(); // VBox for the acc type label and editor VBox* chvb = new VBox(); // VBox for the child label and editor VBox* commvb = new VBox(); // VBox for the comment label and editor VBox* sbvb = new VBox(); // VBox for the class list label and browser VBox* edsvb = new VBox(); // VBox for the above 4 editors VBox* svb; // VBox to hold scrolling widgets HBox* clhb = new HBox(); // HBox for class str browser and scroll bar HBox* outerhb = new HBox(); // Outermost HBox for the editors and str // browser /* * Stick the class name label and editor together. Note the frame around * the string editor. By default, a string editor is borderless. */ namevb->Insert(new Label("Class name:")); namevb->Insert(new Frame(nameed)); /* * Do the same for the other labeled widgets (access type, child of, * comment, and class list. */ accvb->Insert(new Label("Access type:")); accvb->Insert(new Frame(acced)); chvb->Insert(new Label("Child of:")); chvb->Insert(new Frame(acced)); commvb->Insert(new Label("Comment: ")); commvb->Insert(new Frame(commed)); /* * Stick the name, access type, child of and comment editors in a vbox with * glue in between. The expression "round(0.2 * inch)" rounds 0.2 inches t * other nearest pixel, since pixel is the unit of measure used by the * VGlue constructor. */ edsvb->Insert(new VGlue(round(0.2 * inch)), nil, nil); edsvb->Insert(namevb); edsvb->Insert(new VGlue(round(0.2 * inch)), nil, nil); edsvb->Insert(accvb); edsvb->Insert(new VGlue(round(0.2 * inch)), nil, nil); edsvb->Insert(chvb); edsvb->Insert(new VGlue(round(0.2 * inch)), nil, nil); edsvb->Insert(commvb); edsvb->Insert(new VGlue(round(0.2 * inch)), nil, nil); /* * Allocate a veritcal scroller for the class string browser. Passing the * string browser into the scroller constructor logically attaches the * scroller to the string browser so that all the scrolling management will * be handled automatically by the toolkit. I.e., you don't have to write * any code to deal with communication between the scroller and the string * browser. * * Also, stick the string browser and its scroller in an HBox. By default, * a scroller and the interactor that its logically attached to do not have * to be phyiscally attached. This provides flexibility in how scrollers * are physically positioned with respect to the interactors they scroll. */ svb = new VBox( new UpMover(clsb, 1), new HBorder(), new VScroller(clsb), new HBorder(), new DownMover(clsb, 1) ); clhb->Insert(clsb); clhb->Insert(new VBorder()); clhb->Insert(svb); sbvb->Insert(new VGlue(round(0.2 * inch), nil, nil)); sbvb->Insert(new Label("Classes: ")); sbvb->Insert(new Frame(clhb)); sbvb->Insert(new VGlue(round(1.0 * inch))); /* * Stick the editors vbox zand the browser hbox into the outer hbox, with * some glue in between. */ outerhb->Align(Top); outerhb->Insert(new HGlue(round(0.2 * inch))); outerhb->Insert(edsvb); outerhb->Insert(new HGlue(round(0.2 * inch))); outerhb->Insert(sbvb); outerhb->Insert(new HGlue(round(0.2 * inch))); /* * Stick the outermost hbox in the window tray. */ ((Tray*) w)->Insert(outerhb); }