using namespace std;
TearOff::TearOff (Widget& c, bool allow_resize)
- : contents (c),
- own_window (Gtk::WINDOW_TOPLEVEL),
- tearoff_arrow (ARROW_DOWN, SHADOW_OUT),
- close_arrow (ARROW_UP, SHADOW_OUT)
+ : contents (c)
+ , own_window (Gtk::WINDOW_TOPLEVEL)
+ , tearoff_arrow (ARROW_DOWN, SHADOW_OUT)
+ , close_arrow (ARROW_UP, SHADOW_OUT)
+ , dragging (false)
+ , _visible (true)
+ , _torn (false)
+ , _can_be_torn_off (true)
+
{
- dragging = false;
- _visible = true;
- _can_be_torn_off = true;
own_window_width = 0;
own_window_height = 0;
own_window_xpos = 0;
tearoff_event_box.set_events (BUTTON_PRESS_MASK|BUTTON_RELEASE_MASK);
tearoff_event_box.signal_button_release_event().connect (mem_fun (*this, &TearOff::tearoff_click));
+ tearoff_event_box.set_tooltip_text (_("Click to tear this into its own window"));
+
close_event_box.add (close_arrow);
close_event_box.set_events (BUTTON_PRESS_MASK|BUTTON_RELEASE_MASK);
close_event_box.signal_button_release_event().connect (mem_fun (*this, &TearOff::close_click));
-
+
+ close_event_box.set_tooltip_text (_("Click to put this back in the main window"));
VBox* box1;
box1 = manage (new VBox);
VBox* box2;
box2 = manage (new VBox);
- box2->pack_start (tearoff_event_box, false, false, 2);
+ box2->pack_start (tearoff_event_box, false, false);
pack_start (contents);
- pack_start (*box2, false, false, 2);
+ pack_start (*box2, false, false);
}
TearOff::~TearOff ()
}
void
-TearOff::set_visible (bool yn)
+TearOff::set_visible (bool yn, bool force)
{
/* don't change visibility if torn off */
- if (own_window.is_visible()) {
+ if (_torn) {
return;
}
- if (_visible != yn) {
+ if (_visible != yn || force) {
_visible = yn;
if (yn) {
show_all();
window_box.pack_start (contents);
own_window.set_name (get_name());
close_event_box.set_name (get_name());
+ if (own_window_width == 0) {
+ own_window.set_position (WIN_POS_MOUSE);
+ }
own_window.show_all ();
own_window.present ();
hide ();
+
+ _torn = true;
+
Detach ();
}
reorder_child (contents, 0);
own_window.hide ();
show_all ();
+
+ _torn = false;
+
Attach ();
}
bool
TearOff::torn_off() const
{
- return own_window.is_visible();
+ return _torn;
}
void
TearOff::add_state (XMLNode& node) const
{
- node.add_property ("tornoff", (own_window.is_visible() ? "yes" : "no"));
+ node.add_property ("tornoff", (_torn ? "yes" : "no"));
if (own_window_width > 0) {
char buf[32];
}
if (prop->value() == "yes") {
- cerr << "Tearing off " << node.name() << endl;
tear_it_off ();
} else {
- cerr << "Putting back " << node.name() << endl;
put_it_back ();
}
void
TearOff::own_window_realized ()
{
- cerr << "tearoff realized\n";
-
own_window.get_window()->set_decorations (WMDecoration (DECOR_BORDER|DECOR_RESIZEH));
if (own_window_width > 0) {