// ====================================================================== // Below are the routines for building the GUI layout // ====================================================================== // Create and assemble all GUI components void createComponent(){ // Create the main window window = newWindow(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, "Color Display"); // Create and mount the RGB input panel int rgbX = MARGIN; int rgbY = MARGIN; int rgbW = FIELD_WIDTH; int rgbH = FIELD_HEIGHT*3; int rgbPanel = createRGBPanel(rgbX, rgbY, rgbW, rgbH); mountComponent(rgbPanel, window); // Create and mount the button panel int bpX = rgbX + FIELD_WIDTH + MARGIN; int bpY = MARGIN; int bpW = BUTTON_WIDTH; int bpH = BUTTON_HEIGHT*2; int buttonPanel = createButtonPanel(bpX, bpY, bpW, bpH); mountComponent(buttonPanel, window); // Create and mount the code input panel int codeX = bpX + BUTTON_WIDTH + MARGIN; int codeY = MARGIN + FIELD_HEIGHT; int codeW = FIELD_WIDTH; int codeH = FIELD_HEIGHT; int codePanel = createCodePanel(codeX, codeY, codeW, codeH); mountComponent(codePanel, window); // Create and mount the color display panel int dpX = MARGIN; int dpY = rgbY + rgbH + MARGIN; int dpW = DISPLAY_WIDTH; int dpH = DISPLAY_HEIGHT; displayPanel = newPanel(dpX, dpY, dpW, dpH, ""); mountComponent(displayPanel, window); } // Create the RED/GREEN/BLUE input panel int createRGBPanel(int x, int y, int width, int height){ int panel = newGridPanel(x, y, width, height, "", 3, 2); // RED label and field int redLabel = newTextLabel(0, 0, 0, 0, "RED ="); mountComponent(redLabel, panel); redField = newTextField(0, 0, 0, 0, ""); mountComponent(redField, panel); // GREEN label and field int greenLabel = newTextLabel(0, 0, 0, 0, "GREEN ="); mountComponent(greenLabel, panel); greenField = newTextField(0, 0, 0, 0, ""); mountComponent(greenField, panel); // BLUE label and field int blueLabel = newTextLabel(0, 0, 0, 0, "BLUE ="); mountComponent(blueLabel, panel); blueField = newTextField(0, 0, 0, 0, ""); mountComponent(blueField, panel); return panel; } // Create the CODE input panel int createCodePanel(int x, int y, int width, int height){ int panel = newGridPanel(x, y, width, height, "", 1, 2); int codeLabel = newTextLabel(0, 0, 0, 0, "CODE = #"); mountComponent(codeLabel, panel); codeField = newTextField(0, 0, 0, 0, ""); mountComponent(codeField, panel); return panel; } // Create the panel for the conversion buttons int createButtonPanel(int x, int y, int width, int height){ int panel = newGridPanel(x, y, width, height, "", 2, 1); rgbToCodeButton = newButton(0, 0, 0, 0, ">>"); mountComponent(rgbToCodeButton, panel); codeToRgbButton = newButton(0, 0, 0, 0, "<<"); mountComponent(codeToRgbButton, panel); return panel; }