GTK+ IOStream  Beta
<< GTK+ >> add C++ IOStream operators to GTK+. Now with extra abilities ... like network serialisation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Scrolling.H
Go to the documentation of this file.
1 /* Copyright 2000-2013 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 
18 #ifndef SCROLLING_H_
19 #define SCROLLING_H_
20 
21 #include <gtk/gtk.h>
22 #include "X/Selection.H"
23 
26 class Scrolling {
27 protected:
28  GtkWidget *scrolling;
29 public:
30 
33  Scrolling(void) {
34  scrolling = gtk_scrolled_window_new(NULL, NULL);
35  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolling), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
36  }
37 
38 // /** \brief change the callback data to be returned with the callback.
39 // \param callback the callback function to be called upon selection change
40 // \param data the data to be returned with the selection changed callback.
41 // */
42 // void setCallbackAfter(GCallback callback, void *data){
43 // g_signal_connect_after(selection, "changed", G_CALLBACK(callback), data);
44 // }
45 
48  GtkWidget *getWidget(void) {
49  return scrolling;
50  }
51 
54  void show(void) {
55  gtk_widget_show_all(scrolling);
56  }
59  void hide(void) {
60  gtk_widget_hide(scrolling);
61  }
62 
63 
68  Scrolling & operator<<(Selection *selection) {
69  gtk_container_add(GTK_CONTAINER(scrolling), selection->getWidget());
70  /* Set vertical adjustment for the tree view */
71  GtkAdjustment *vscroll = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrolling));
72  gtk_tree_view_set_vadjustment(GTK_TREE_VIEW (selection->getWidget()), vscroll);
73  /* Set vertical adjustment for the tree view */
74  GtkAdjustment *hscroll = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scrolling));
75  gtk_tree_view_set_hadjustment(GTK_TREE_VIEW (selection->getWidget()), hscroll);
76  return *this;
77  }
78 
83  Scrolling & operator>>(GtkWidget *widget) {
84  gtk_container_remove(GTK_CONTAINER(scrolling), widget);
85  return *this;
86  }
87 };
88 #endif //SCROLLING_H_