Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) ShinyButtonWidget

 

shinybuttonwidget.h

 

//---------------------------------------------------------------------------
/*
ShinyButtonWidget, widget for the ShinyButton class
Copyright (C) 2011 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/CppShinyButtonWidget.htm
//---------------------------------------------------------------------------
#ifndef SHINYBUTTONWIDGET_H
#define SHINYBUTTONWIDGET_H
//---------------------------------------------------------------------------
#include <boost/scoped_ptr.hpp>
//---------------------------------------------------------------------------
#include "widget.h"
//---------------------------------------------------------------------------
struct ShinyButton;
//---------------------------------------------------------------------------
struct ShinyButtonWidget : public Widget
{
  ShinyButtonWidget(
    const double color,
    const double gradient,
    const std::string& text = "");

  ///Obtain a read-and-write pointer to ShinyButton
  ShinyButton * GetShinyButton() { return m_button.get(); }

  ///Obtain a read-only pointer to ShinyButton
  const ShinyButton * GetShinyButton() const { return m_button.get(); }

  ///Respond to the user clicking on this class
  void Click(const int x, const int y);

  ///Obtain the version of this class
  static const std::string GetVersion();

  ///Obtain the version history of this class
  static const std::vector<std::string> GetVersionHistory();

  private:
  boost::scoped_ptr<ShinyButton> m_button;

  friend std::ostream& operator<<(std::ostream& os, const ShinyButtonWidget& button);
};
//---------------------------------------------------------------------------
std::ostream& operator<<(std::ostream& os, const ShinyButtonWidget& button);
//---------------------------------------------------------------------------
#endif // SHINYBUTTONWIDGET_H

 

 

 

 

 

shinybuttonwidget.cpp

 

//---------------------------------------------------------------------------
/*
ShinyButtonWidget, widget for the ShinyButton class
Copyright (C) 2011 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/CppShinyButtonWidget.htm
//---------------------------------------------------------------------------
#include "shinybutton.h"
#include "shinybuttonwidget.h"
#include "trace.h"
//---------------------------------------------------------------------------
ShinyButtonWidget::ShinyButtonWidget(
  const double color,
  const double gradient,
  const std::string& text)
  : m_button(new ShinyButton(color,gradient,text))
{

}
//---------------------------------------------------------------------------
const std::string ShinyButtonWidget::GetVersion()
{
  return "1.0";
}
//---------------------------------------------------------------------------
const std::vector<std::string> ShinyButtonWidget::GetVersionHistory()
{
  std::vector<std::string> v;
  v.push_back("YYYY-MM-DD: version X.Y: [description]");
  v.push_back("2011-09-21: version 1.0: initial version");
  return v;
}
//---------------------------------------------------------------------------
std::ostream& operator<<(std::ostream& os, const ShinyButtonWidget& button)
{
  os
    << "<ShinyButtonWidget>"
    << *button.m_button
    << button.GetGeometry()
    << "</ShinyButtonWidget>";
  return os;
}
//---------------------------------------------------------------------------


 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml