void WebHandler::addFormColor(std::string& buff, bool includeAlternate) {
    buff << "<br/>Color: ";
    addRadioButton(buff, "color", displayColorGreen, "green", !includeAlternate);
    addRadioButton(buff, "color", displayColorRed, "red", false);
    addRadioButton(buff, "color", displayColorYellow, "yellow", false);
    if (includeAlternate)  addRadioButton(buff, "color", displayColorAlternate, "alternate", true);
}
void WebHandler::addFormFont(std::string& buff) {
  buff << "<br/>Font: ";
  addRadioButton(buff, "font", font5x4, "5x4", true);
  addRadioButton(buff, "font", font8x4, "8x4", false);
  addRadioButton(buff, "font", font7x5, "7x5", false);
  addRadioButton(buff, "font", font8x6, "8x6", false);
  addRadioButton(buff, "font", font16x8, "16x8", false);
}
  virtual HandleRequestReply process(const RequestInfo& requestInfo, RequestOutput& requestOutput) {
    std::string buff(contentStart);

    buff << "<form action='/dictionary' method='post'>"
	 << "<h1>Global Dictionary Config</h1><p>";

    buff << "<br/>Operation: ";
    addRadioButton(buff, dictionaryParamOperation, dictionaryParamOperationSet, dictionaryParamOperationSet, false);
    addRadioButton(buff, dictionaryParamOperation, dictionaryParamOperationAdd, dictionaryParamOperationAdd, true);
    addRadioButton(buff, dictionaryParamOperation, dictionaryParamOperationDel, dictionaryParamOperationDel, false);

    buff << "<br/>Key: <input type='text' size='30' name='" << dictionaryParamKey << "'>";
    buff << "<br/>Data: <input type='text' size='30' name='" << dictionaryParamData << "'>";

    buff << "<br/>Timeout (sec): ";
    addRadioButton(buff, dictionaryParamTimeout, "3000", "3", false);
    addRadioButton(buff, dictionaryParamTimeout, "10000", "10", false);
    addRadioButton(buff, dictionaryParamTimeout, "60000", "60", true);
    addRadioButton(buff, dictionaryParamTimeout, "300000", "300", false);
    addRadioButton(buff, dictionaryParamTimeout, "-1", "never", false);

    buff << "</p><input type='submit' value='Submit'/></form>";

    ADD_BODY(buff + contentStop);
    return replyOk;
  }
 /* Wrapper for adding different children: */
 void addWidget(QWidget *pWidget, const QVariant &data)
 {
     /* Add radio-button: */
     if (QRadioButton *pRadioButton = qobject_cast<QRadioButton*>(pWidget))
         addRadioButton(pRadioButton, data);
     /* Add check-box: */
     if (QCheckBox *pCheckBox = qobject_cast<QCheckBox*>(pWidget))
         addCheckBox(pCheckBox, data);
 }
  virtual HandleRequestReply process(const RequestInfo& requestInfo, RequestOutput& requestOutput) {
    std::string buff(contentStart);

    buff << "<form action='/imgBackground' method='post'>"
	 << "<h1>Background Img</h1><p>";

    buff << "<br/>Index (0-";
    INT2BUFF(BACKGROUND_IMG_COUNT - 1);
    buff << "): <input type='range' min='0' max='";
    INT2BUFF(BACKGROUND_IMG_COUNT - 1);
    buff << "' value=0 name='index'>";

#ifdef BG_IMG_ART_SELECT_BY_NUMBER
    buff << "<br/>ImgArt Number (0-"; INT2BUFF(imgArtLast - 1);
    buff << "): <input type='range' min='0' max='"; INT2BUFF(imgArtLast - 1);
    buff << "' value=0 name='imgArt'>";
#else   // ifdef BG_IMG_ART_SELECT_BY_NUMBER
    buff << "<br/>ImgArt Name: ";
    addRadioButton(buff, "imgArt", -1, "default", true);
    for (int i=0; i < imgArtLast; ++i) {
      addRadioButton(buff, "imgArt", i, imgArtStr[i] + imgArtStrUniqueOffset, false);
    }
#endif  // ifdef BG_IMG_ART_SELECT_BY_NUMBER
    
    buff << "<br/>Enabled: ";
    addCheckBox(buff, "enabled", "yes", "", true);
    buff << "  Clear all: ";
    addCheckBox(buff, "clearAll", "yes", "", false);

    addFormColor(buff, false /*includeAlternate*/);
    addXYCoordinatesInput(buff);
    addAnimationStepInput(buff);
    
    buff << "</p><input type='submit' value='Submit'/></form>";

    ADD_BODY(buff + contentStop);
    return replyOk;
  }
  virtual HandleRequestReply process(const RequestInfo& requestInfo, RequestOutput& requestOutput) {
    std::string buff(contentStart);

    buff << "<form action='/msgMode' method='post'>"
	 << "<h1>Display Message</h1><p>"
	 << "<input type='text' size='";
    INT2BUFF(FORM_MSG_BOX_LEN);  // not the max len of content, just size of form
    buff << "' name='msg'><br/>";
    addFormFont(buff);
    buff << "<br/>Alternate font: ";
    addCheckBox(buff, "alternateFont", "yes", "", false);

    buff << "<br/>Confetti: ";
    addCheckBox(buff, "confetti", "15", "", false);

    buff << "<br/>Bounce: ";
    addCheckBox(buff, "bounce", "yes", "", false);

    buff << "<br/>NoScroll: ";
    addCheckBox(buff, "noScroll", "yes", "", false);

    buff << "<br/>Blink: ";
    addCheckBox(buff, "blink", "yes", "", false);

    addFormColor(buff, true /*includeAlternate*/);
    
    buff << "<br/>Scroll Repeat: ";
    addRadioButton(buff, "repeats", "0", "none", false);
    addRadioButton(buff, "repeats", "5", "5", false);
    addRadioButton(buff, "repeats", "10", "10", false);
    addRadioButton(buff, "repeats", "100", "100", true);

    buff << "<br/>Timeout (sec): ";
    addRadioButton(buff, "timeout", "3", "3", false);
    addRadioButton(buff, "timeout", "10", "10", false);
    addRadioButton(buff, "timeout", "60", "60", true);
    addRadioButton(buff, "timeout", "300", "300", false);
    
    addXYCoordinatesInput(buff);

    buff << "</p><input type='submit' value='Submit'/></form>";

    ADD_BODY(buff + contentStop);
    return replyOk;
  }
void WebHandler::addAnimationStepInput(std::string& buff) {
    buff << "<br/>Animation: ";
    addRadioButton(buff, "animationStep", animationStepNone, "none", true);  
    addRadioButton(buff, "animationStep", animationStepFast, "fast", false);
    addRadioButton(buff, "animationStep", animationStep250ms, "250ms", false);
    addRadioButton(buff, "animationStep", animationStep500ms, "500ms", false);
    addRadioButton(buff, "animationStep", animationStep1sec, "1sec", false);
    addRadioButton(buff, "animationStep", animationStep5sec, "5sec", false);
    
    buff << "<br/>phase (0-255): <input type='range' size=3 min=0 max=255 value=2 name='animationPhase'>"
	 << " value (0-254): <input type='range' size=3 min=0 max=254 value=0 name='animationPhaseValue'>";
}
  virtual HandleRequestReply process(const RequestInfo& requestInfo, RequestOutput& requestOutput) {
    std::string buff(contentStart);

    buff << "<form action='/ledStrip' method='post'>"
	 << "<h1>Led Strip Config</h1><p>";

    buff << "Pixels (0 to "; INT2BUFF(LedStrip::numberOfLeds - 1);
    buff << ") formatting:" << "<input type='text' size='";
    INT2BUFF(FORM_MSG_BOX_LEN);  // not the max len of content, just size of form
    buff << "' name='rawFormat'> e.g: pixels 3,4,5 with color R,G,B and pixel 9 with a 21bit color ==> 3-5:127,45,0 ; 9:762";

    buff << "<br/>Extra Param: <input type='text' size='5' name='" << ledStripParamExtra << "'>";

    buff << "<br/>Clear all Pixels: ";
    addCheckBox(buff, ledStripParamClearAllPixels, "yes", "", false);

    buff << "<br/> Mode: ";
    LedStrip& ledStrip = LedStrip::bind();
    for (int i=0; i < ledStripModeCount; ++i) {
      addRadioButton(buff, ledStripParamLedStripMode, i, ledStrip.getLedStripModeStr( (LedStripMode)i ), i == ledStripModeManual);
    }
    
    buff << "<p>Default Color (used whan it was not specified in pixel format):"
	 << "<br/>"
	 << "Red (0-127): <input type='range' size=3 min=0 max=127 value=0 name='red'>"
	 << "  Green (0-127): <input type='range' size=3 min=0 max=127 value=0 name='green'>"
	 << "  Blue (0-127): <input type='range' size=3 min=0 max=127 value=0 name='blue'>";
    
    buff << "<br/>Timeout (sec): ";
    addRadioButton(buff, ledStripParamTimeout, "3", "3", true);
    addRadioButton(buff, ledStripParamTimeout, "10", "10", false);
    addRadioButton(buff, ledStripParamTimeout, "60", "60", false);
    addRadioButton(buff, ledStripParamTimeout, "300", "300", false);
    addRadioButton(buff, ledStripParamTimeout, "-1", "never", false);

    buff << "</p><input type='submit' value='Submit'/></form>";
    
    ADD_BODY(buff + contentStop);
    return replyOk;
  }
void WebHandler::addRadioButton(std::string& buff, const char* name, int valAutoInt,
				const char* label, bool selected) {
  char value[CHAR2INTMAXSIZE];
  snprintf(value, CHAR2INTMAXSIZE, "%d", valAutoInt);
  addRadioButton(buff, name, value, label, selected);
}