/**********************************************************************
 *
 *   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 "XGtkLabelOptionmenu.h"

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

namespace GTK_DOKO
{

  /*****************************************************************************
   *
   * XGtkLabelOptionmenu::XGtkLabelOptionmenu(string const& text)
   *
   * Parameters:	text - text for the label
   *
   * Result:	-
   * 
   * Version:	0.4.3
   *
   * Description:	Constructor
   *
   ****************************************************************************/
  XGtkLabelOptionmenu::XGtkLabelOptionmenu(string const& text) :
    XGtkLabelWidget(text),
  menu_p(gtk_option_menu_new()) // the menu
  {
    DEBUG_CALLING(INFO_GTK_WIDGET && INFO_GTK_INIT,
		  "XGtkLabelOptionmenu::XGtkLabelOptionmenu()");

#if 0
    gtk_object_set_data(GTK_OBJECT(this->label()),
			"text",
			new string(text));

    GtkWidget* alignment = gtk_alignment_new(1, 0.5, 0, 0);
    // pack the widgets in the container
    gtk_box_pack_start(GTK_BOX(widget()),
		       alignment,
		       TRUE, TRUE, 0);
    gtk_container_add(GTK_CONTAINER(alignment),
		      this->label());
    gtk_box_pack_start(GTK_BOX(widget()),
		       menu(),
		       FALSE, FALSE, 0);
#endif
    gtk_box_pack_end(GTK_BOX(this->container()),
		     this->menu(),
		     FALSE, FALSE, 0);

    // set the text of the label widget
    this->language_update();

    // show all widgets
    gtk_widget_show_all(this->widget());

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

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

    gtk_widget_destroy(this->menu());

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

  /*****************************************************************************
   *
   * GtkWidget* XGtkLabelOptionmenu::menu()
   *
   * Parameters:	-
   *
   * Result:	the menu
   *
   * Version:	0.4.3
   *
   * Description:	Result
   *
   ****************************************************************************/
  GtkWidget*
    XGtkLabelOptionmenu::menu()
    {
      DEBUG_CALLING(INFO_GTK_WIDGET && INFO_GTK_VALUE,
		    "XGtkLabelOptionmenu::menu()");

      DEBUG_ASSERTION((this->menu_p != NULL),
		      "XGtkLabelOptionmenu::menu()\n"
		      "  `menu_p` == NULL");

      DEBUG_RETURNING(this->menu_p,
		      INFO_GTK_WIDGET && INFO_GTK_VALUE,
		      "XGtkLabelOptionmenu::menu()");
    } // GtkWidget* XGtkLabelOptionmenu::menu()

}
#endif
