RE: [gtkmm] How can I make floating Toolbar in Gtkmm2 such as in Windows programs?



At 17:51 2003.05.09 +0200, Murray Cumming Comneon com wrote:
> From: Darius [mailto:dariuzk centras lt]
> I am new to Gtkmm2 programing and so I don't know,
> how can I make floating Toolbar in Gtkmm2 such as in Windows programs?
> Any ideas? Any tips? Or just where can I find such info?

I think a HandleBox might be what you want. I don't think it's difficult.
Regexxer does it, so you could look at the source:
http://regexxer.sourceforge.net/pix/regexxer-0.4.png

Our toolbar example doesn't do it, so it would be nice to have a patch for
that.

Murray Cumming
murrayc usa net
www.murrayc.com

Hi,
many thanks for you all,
finaly I got the idea...
I used HandleBox and I has a nice floating toolbar now :)

>Our toolbar example doesn't do it, so it would be nice to have a patch for
>that.
So I attached my program hope it could serve us example for floating toolbar (and screenshots too).

Buy
Darius Kucinskas
dariuzk centras lt

P.S.
It's nice to have mailing list witch is working!


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

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

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

  return 0;
}
#include <iostream>
#include "examplewindow.h"

ExampleWindow::ExampleWindow()
: m_Button_Close("Close")
{ 
	set_title("Gtk: floating toolbar");
	add(m_VBox_Main);
	
	m_VBox_Main.pack_start(m_Toolbar_Handle, Gtk::PACK_SHRINK);
	m_ButtonBox.set_border_width(5);
	m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
	m_VBox_Main.pack_end(m_ButtonBox);
	
	//Add close button
	m_ButtonBox.pack_start(m_Button_Close, Gtk::PACK_SHRINK);
	m_Button_Close.signal_clicked().connect( SigC::slot(*this, &ExampleWindow::on_button_close) );
  
	//Add the toolbar items:
	{
		using namespace Gtk::Toolbar_Helpers;
		
		m_Toolbar.tools().push_back( ButtonElem("Click me", SigC::slot(*this, &ExampleWindow::on_toolbar_item), "Toolbar item") );
		m_Toolbar.tools().push_back( Space() );
		
		m_Toolbar.tools().push_back( StockElem(Gtk::Stock::SAVE, SigC::slot(*this, &ExampleWindow::on_toolbar_item)) );
		m_Toolbar.tools().push_back( ToggleElem("Toggle me", SigC::slot(*this, &ExampleWindow::on_toolbar_item), "toggle duh") );
		
		Gtk::RadioButton::Group group;
		m_Toolbar.tools().push_back( RadioElem(group, "Radio 1") );
		m_Toolbar.tools().push_back( RadioElem(group, "Radio 2") );
		m_Toolbar.tools().push_back( RadioElem(group, "Radio 3") );	
	}
	//Set minimum size (good thing then toolbar is disjoined for main window)
	m_Toolbar_Handle.add(m_Toolbar);
	m_Toolbar.set_size_request(400, -1);
	
	show_all_children();
}

ExampleWindow::~ExampleWindow()
{
}

void ExampleWindow::on_button_close()
{
  hide();
}

void ExampleWindow::on_toolbar_item()
{
  std::cout << "Toolbar item clicked." << std::endl;
}
#ifndef GTKMM_EXAMPLEWINDOW_H
#define GTKMM_EXAMPLEWINDOW_H

#include <gtkmm.h>

class ExampleWindow : public Gtk::Window
{
public:
  ExampleWindow();
  virtual ~ExampleWindow();

protected:
  //Signal handlers:
  virtual void on_button_close();
  virtual void on_toolbar_item();

  //Child widgets:
  Gtk::VBox        m_VBox_Main;
  Gtk::HandleBox   m_Toolbar_Handle;
  Gtk::Toolbar     m_Toolbar;
  Gtk::HButtonBox  m_ButtonBox;
  Gtk::Button      m_Button_Close;
};

#endif //GTKMM_EXAMPLEWINDOW_H

Attachment: deattached.png
Description: PNG image

Attachment: attached.png
Description: PNG image



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