CMS 3D CMS Logo

Public Member Functions | Private Attributes

Button Class Reference

#include <Button.h>

Inheritance diagram for Button:
WebElement

List of all members.

Public Member Functions

 Button (std::string the_url, std::string top, std::string left, std::string the_requestID, std::string the_name)
void printHTML (xgi::Output *out)
 ~Button ()

Private Attributes

std::string name
 the name that will appear on the button
std::string requestID
 the string connected to the callback, eg "Default"

Detailed Description

This is the class that should be instantiated in case the user wants to have a button on the web page, which is connected to a function defined in your web client. Pressing this button will result in the javascript function makeRequest being called and the request "/Request?RequestID=[Your request name]" being submitted to the server.

Definition at line 18 of file Button.h.


Constructor & Destructor Documentation

Button::Button ( std::string  the_url,
std::string  top,
std::string  left,
std::string  the_requestID,
std::string  the_name 
) [inline]

Definition at line 28 of file Button.h.

References name, and requestID.

    : WebElement(the_url, top, left)
    {
      name = the_name;
      requestID = the_requestID;
    }
Button::~Button ( ) [inline]

Definition at line 35 of file Button.h.

    {
    }

Member Function Documentation

void Button::printHTML ( xgi::Output *  out) [virtual]

Implements WebElement.

Definition at line 4 of file Button.cc.

References WebElement::get_pix_left(), WebElement::get_pix_top(), WebElement::get_url(), collect_tpl::input, name, position, and requestID.

{
  std::string position = "position:absolute; left:" + get_pix_left() + "; top:" + get_pix_top();
  *out << cgicc::div().set("style", position.c_str()) << std::endl;

  std::string js_command = "makeRequest('" + get_url() + "/" + "Request?RequestID=" + requestID + "', dummy)";
  *out << cgicc::input().set("type", "button")
    .set("value", name.c_str())
    .set("onclick", js_command.c_str()) << std::endl;

  *out << cgicc::div() << std::endl;
}

Member Data Documentation

std::string Button::name [private]

the name that will appear on the button

Definition at line 22 of file Button.h.

Referenced by Button(), and printHTML().

std::string Button::requestID [private]

the string connected to the callback, eg "Default"

Definition at line 24 of file Button.h.

Referenced by Button(), and printHTML().