/**********************************************************************
 *
 *   FreeDoko a Doppelkopf-Game
 *    
 *   Copyright (C) 2001-2004  by Diether Knof and Borg Enders
 *
 *   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 2 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 can find this license in the file 'gpl.txt'.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 *   MA  02111-1307  USA
 *
 *  Contact:
 *    Diether Knof dknof@gmx.de
 *    Borg Enders  borg@borgsoft.de
 *
 *********************************************************************/

#include "constants.h"

#ifdef USE_UI_GTK

#include "XGtkLabelButton.h"

#include "../../../misc/language.h"

namespace GTK_DOKO
{

  /*****************************************************************************
   *
   * XGtkLabelButton::XGtkLabelButton(string const& text)
   *
   * Parameters:	text - text for the label
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	Constructor
   *
   ****************************************************************************/
  XGtkLabelButton::XGtkLabelButton(string const& text) :
    XGtkLabelEntry(text)
    {
      DEBUG_CALLING(INFO_GTK_WIDGET && INFO_GTK_INIT,
		    "XGtkLabelButton::XGtkLabelButton()");

      gtk_widget_destroy(this->entry_p);
      this->entry_p = gtk_button_new_with_label("");

      gtk_box_pack_end(GTK_BOX(widget()),
		       entry(),
		       TRUE, TRUE, 0);

      gtk_object_set_data(GTK_OBJECT(this->entry()),
			  "text",
			  new string(text));

      // set the text of the label widget
      language_update();

      // show all widgets
      gtk_widget_show_all(widget());

      DEBUG_RETURNING(VOID,
		      INFO_GTK_WIDGET && INFO_GTK_INIT,
		      "XGtkLabelButton::XGtkLabelButton()");
    } // XGtkLabelButton::XGtkLabelButton()

  /*****************************************************************************
   *
   * XGtkLabelButton::~XGtkLabelButton()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	Destructor
   *
   ****************************************************************************/
  XGtkLabelButton::~XGtkLabelButton()
  {
    DEBUG_CALLING(INFO_GTK_WIDGET && INFO_GTK_INIT,
		  "XGtkLabelButton::~XGtkLabelButton()");

    DEBUG_RETURNING(VOID,
		    INFO_GTK_WIDGET && INFO_GTK_INIT,
		    "XGtkLabelButton::~XGtkLabelButton()");
  } // XGtkLabelButton::XGtkLabelButton()


  /*****************************************************************************
   *
   * GtkWidget* XGtkLabelButton::button()
   *
   * Parameters:	-
   *
   * Result:	the button
   *
   * Version:	0.4.2
   *
   * Description:	Result
   *
   ****************************************************************************/
  GtkWidget*
    XGtkLabelButton::button()
    {
      DEBUG_CALLING(INFO_GTK_WIDGET && INFO_GTK_VALUE,
		    "XGtkLabelButton::button()");

      DEBUG_RETURNING(this->entry(),
		      INFO_GTK_WIDGET && INFO_GTK_VALUE,
		      "XGtkLabelButton::button()");
    } // GtkWidget* XGtkLabelButton::button()

  /*****************************************************************************
   *
   * string XGtkLabelButton::entry_text()
   *
   * Parameters:	-
   *
   * Result:	the text of the entry
   *
   * Version:	0.4.2
   *
   * Description:	Result
   *
   ****************************************************************************/
  string
    XGtkLabelButton::entry_text()
    {
      DEBUG_CALLING(INFO_GTK_WIDGET && INFO_GTK_VALUE,
		    "XGtkLabelButton::entry_text()");

      char* text_p;

      gtk_label_get(GTK_LABEL(GTK_BIN(this->button())->child),
		    &text_p);

      DEBUG_RETURNING(string(text_p),
		      INFO_GTK_WIDGET && INFO_GTK_VALUE,
		      "XGtkLabelButton::entry_text()");
    } // string XGtkLabelButton::entry_text()

  /*****************************************************************************
   *
   * void XGtkLabelButton::entry_text_set(string const& string)
   *
   * Parameters:	string - new string for the entry
   *
   * Result:	-
   *
   * Version:	0.4.2
   *
   * Description:	sets the text of the entry
   *
   ****************************************************************************/
  void
    XGtkLabelButton::entry_text_set(string const& string)
    {
      DEBUG_CALLING(INFO_GTK_WIDGET && INFO_GTK_UPDATE,
		    "XGtkLabelButton::entry_text_set()");

      gtk_label_set_text(GTK_LABEL(GTK_BIN(this->button())->child),
			 string.c_str());

      DEBUG_RETURNING(VOID,
		      INFO_GTK_WIDGET && INFO_GTK_UPDATE,
		      "XGtkLabelButton::entry_text_set()");
    } // void XGtkLabelButton::entry_text(string const& string)

}
#endif
