void hCheckBox::draw(void) // Corrected bug: did'nt work correctly with another background color than the default { if(varType != HGUI_NO_VAR) syncWithVar(); hGui * gui = hGui::getInstance(); ofFill(); if(data->selected == false) { if(backgroundColor != -1) hSetHexColor(backgroundColor); else hSetHexColor(gui->fillColor); ofRect(x, y, w, h); } else { if(data->selectColor != -1) hSetHexColor(data->selectColor); else hSetHexColor(gui->checkBoxColor); ofRect(x, y, w, h); } hSetHexColor(gui->borderColor); hFrameRect(x, y, w, h); }
void hStatusBar::draw(void) { if(data->disabled == true) return; hGui * gui = hGui::getInstance(); w = ofGetWidth(); h = ofGetHeight(); y = h - 13; if(visibleBackground) { if(backgroundColor != -1) hSetHexColor(backgroundColor); else hSetHexColor(gui->backgroundColor); hPaintRect(x, y, w, h); } hSetHexColor(gui->borderColor); hLine(x, y, x+w, y); if(data->label.size() > 0) { hSetHexColor(gui->textColor); hDrawString(gui->ffont, data->label, x+2, y+gui->ftextHeight-2); } }
void hLabel::draw(void) { hGui * gui = hGui::getInstance(); if(data->label.size() > 0) { int yy = y; if(data->selected) { hSetHexColor(gui->labelSelColor); hPaintRect(x-1, y, w, h+2); hSetHexColor(gui->borderColor); hFrameRect(x-1, y, w, h+2); yy += 2; hSetHexColor(gui->labelSelTextColor); } else hSetHexColor(gui->textColor); if(fixedMode == true) { hDrawString(gui->ffont, data->label, x+4, yy+gui->ftextHeight); } else { if(warningMode == true){ hSetHexColor(gui->warningColor); hDrawString(gui->font, data->label, x+4, yy+gui->textHeight); } else hDrawString(gui->font, data->label, x+4, yy+gui->textHeight); } } }
void hWidget::draw(void) { hGui * gui = hGui::getInstance(); if(visibleBackground){ if(backgroundColor != -1) hSetHexColor(backgroundColor); else hSetHexColor(gui->backgroundColor); hPaintRect(x, y, w, h); } if(visibleBorder){ hSetHexColor(gui->borderColor); hFrameRect(x, y, w, h); } }
void hScrollBar::draw(void) { if(linkedListBox == NULL) return; int numItems = linkedListBox->getNumWidgets(); int numData = linkedListBox->getNumData(); if((numData - numItems) > 0) { hGui * gui = hGui::getInstance(); int hh = gui->scrollHandleHeight; int yy = (y + position) - (hh/2); /* NO MORE NECESSARY! #if defined( __WIN32__ ) || defined( _WIN32 ) hh-=1; #endif */ hSetHexColor(gui->fillColor); hPaintRect(x+1, y, w-2, h); hSetHexColor(gui->scrollHandleColor); hPaintRect(x+1, yy, w-2, hh); hSetHexColor(gui->borderColor); hFrameRect(x, y, w, h); hFrameRect(x+2, yy, w-4, hh); // Enable the drawing of the other small widgets linkedListBox->incButton->setEnabled(true); linkedListBox->decButton->setEnabled(true); } // (numData - numItems) > 0) else { // Disable the drawing of the other small widgets linkedListBox->incButton->setEnabled(false); linkedListBox->decButton->setEnabled(false); } }
void hCheckBox::draw(void) { if(varType != HGUI_NO_VAR) syncWithVar(); hGui * gui = hGui::getInstance(); ofFill(); if(backgroundColor != -1) hSetHexColor(backgroundColor); else hSetHexColor(gui->fillColor); ofRect(x, y, w, h); if(data->selected) { if(data->selectColor != -1) hSetHexColor(data->selectColor); else hSetHexColor(gui->checkBoxColor); ofRect(x, y, w, h); } hWidget::draw(); }
void hSlider::draw(void) { hGui * gui = hGui::getInstance(); if(varType != HGUI_NO_VAR) { syncWithVar(); setLinkedValues(); if(data->value < min) data->value = min; else if(data->value > max) data->value = max; double pRange = w - 2; double vRange = max - min; position = ((data->value - min) * pRange) / vRange; } hWidget::draw(); if(data->selectColor != -1) { if(data->disabled == false) hSetHexColor(data->selectColor); else hSetHexColor(gui->disableColor); } else { if(data->disabled == false) hSetHexColor(gui->sliderColor); else hSetHexColor(gui->disableColor); } hPaintRect(x+1, y+1, position, h-2); hSetHexColor(hGui::getInstance()->borderColor); hLine (x+position+1, y+1, x+position+1, y+h-1); if(owningLabel == true) { if(linkedLabel != NULL) linkedLabel->draw(); } }
void hTScrollBar::draw(void) // WARNING: draw it only if usable { if(linkedTextArea == NULL) return; int numItems = linkedTextArea->maxLines; int numData = linkedTextArea->lines.size(); if((numData - numItems) > 0) { hGui * gui = hGui::getInstance(); int hh = gui->scrollHandleHeight; int yy = (y + position) - (hh/2); /* #if defined( __WIN32__ ) || defined( _WIN32 ) hh-=1; #endif */ hSetHexColor(gui->fillColor); hPaintRect(x+1, y, w-2, h); hSetHexColor(gui->scrollHandleColor); hPaintRect(x+1, yy, w-2, hh); hSetHexColor(gui->borderColor); hFrameRect(x, y, w, h); hFrameRect(x+2, yy, w-4, hh); // Enable the drawing of the other small widgets linkedTextArea->incButton->setEnabled(true); linkedTextArea->decButton->setEnabled(true); }// (numData - numItems) > 0) else { // Disable the drawing of the other small widgets linkedTextArea->incButton->setEnabled(false); linkedTextArea->decButton->setEnabled(false); } }
void hCounterLabel::draw(void) { hGui * gui = hGui::getInstance(); if(varType != HGUI_NO_VAR) { syncWithVar(); setTime(data->value); } if(data->label.size() > 0) { hSetHexColor(gui->counterColor); hDrawString(gui->cfont, data->label, x, y+gui->ctextHeight); } }
void hDialog::draw(void) { hGui * gui = hGui::getInstance(); int hh; if((confirmButton != NULL) || (msgTextArea != NULL)) hh = (h - gui->buttonHeight) + 1; else hh = h; // Draw the dialog background if(visibleBackground){ if(backgroundColor != -1) hSetHexColor(backgroundColor); else hSetHexColor(gui->backgroundColor); hPaintRect(x, y, w, hh); } // Draw top bar content hSetHexColor(dialogColor); hPaintRect(x, y, w, gui->checkBoxSize); // Draw all widgets inside the dialog int size = widgets.size(); for(int i = 0; i < size; ++i) widgets[i]->draw(); // Frames have to be done last, in case they are recovered by something else // Draw the dialog frame if(visibleBorder){ hSetHexColor(gui->borderColor); hFrameRect(x, y, w, hh); } // Draw top bar frame hSetHexColor(gui->borderColor); hFrameRect(x, y, w, gui->checkBoxSize); #if defined( __WIN32__ ) || defined( _WIN32 ) hSetHexColor(dialogColor); hLine(x, y+gui->checkBoxSize-1, x+w-gui->checkBoxSize-1, y+gui->checkBoxSize-1); #endif }