can we override the drawing method of Gtk::Style



I do not want the widgets to be drawn in default way... so i want to have my own function which handle the drawing of widgets
This can be done in gtk+ by overriding method of GtkStyle
 
I tried doing the same with Gtk::Style class, so i make a class derive it from Gtk::Style & override one of the methods.
Then i set the style of one button with object of my class.
 
But my function is never overridden
 
Can we redefine the widget drawing function as in gtk+, or is there something wrong in the way i m trying to do it
 
i have atatched the source code files

--
Thanks
Yogesh

Dont be intimidated by impossibillity.... be motivated by possibillity!
//$Id: helloworld.cc,v 1.3 2004/11/16 20:02:21 murrayc Exp $ -*- c++ -*-

/* gtkmm example Copyright (C) 2002 gtkmm development team
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation.
 *
 * 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#include "helloworld.h"
#include "NewStyle.h"
#include <iostream>

HelloWorld::HelloWorld()
: m_button("Hello World")   // creates a new button with the label "Hello World".
{
  // Sets the border width of the window.
  set_border_width(10);

  // When the button receives the "clicked" signal, it will call the
  // on_button_clicked() method. The on_button_clicked() method is defined below.
  m_button.signal_clicked().connect(sigc::mem_fun(*this, &HelloWorld::on_button_clicked));

  // This packs the button into the Window (a container).
  add(m_button);

	NewStyle  *style = new NewStyle();
	m_button.set_style(Glib::RefPtr<Style>(style));
  // The final step is to display this newly created widget...
  m_button.show();

  
}

HelloWorld::~HelloWorld()
{
}

void HelloWorld::on_button_clicked()
{
  std::cout << "Hello World" << std::endl;
}

Attachment: helloworld.h
Description: Binary data

//$Id: main.cc,v 1.1.1.1 2003/01/21 13:41:32 murrayc Exp $ -*- c++ -*-

/* gtkmm example Copyright (C) 2002 gtkmm development team
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation.
 *
 * 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#include <gtkmm/main.h>
#include "helloworld.h"

int main (int argc, char *argv[])
{
  Gtk::Main kit(argc, argv);

  HelloWorld helloworld;
  Gtk::Main::run(helloworld); //Shows the window and returns when it is closed.

  return 0;
}

Attachment: NewStyle.cpp
Description: Binary data

Attachment: NewStyle.h
Description: Binary data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]