/* $Id: packer.gen_h,v 1.47 2000/08/21 19:24:37 kenelson Exp $ */ /* packer.h * * Copyright (C) 1998-1999 The Gtk-- Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <gtk--/container.h> #include <gtk/gtkpacker.h> namespace Gtk { // gtk_packer_add lacks a default flag void gtkmm_packer_add(GtkPacker*,GtkWidget*,GtkSideType,GtkAnchorType,guint,guint,guint,guint,guint,guint); // using ~0 instead of 0xffffffff will be better with non 32-bit guint's // and typo-safe #define GTKMM_PACKER_DEFAULT (~((guint)0)) namespace Packer_Helpers { class Child : protected _GtkPackerChild { public: inline _GtkPackerChild* gtkobj() {return (this);} inline const _GtkPackerChild* gtkobj() const {return (this);} private: Child& operator=(const Child&); Child(const Child&); protected: Child(void* do_not_derive_this); inline GtkPacker* parent() {return (GtkPacker*)(gtkobj()->widget->parent);} void redraw(); public: Widget* get_widget() const; GtkSideType get_side() const; GtkAnchorType get_anchor() const; guint get_options() const; guint get_border_width() const; guint get_pad_x() const; guint get_pad_y() const; guint get_ipad_x() const; guint get_ipad_y() const; void set_packing(GtkSideType s, GtkAnchorType a, guint o, guint b=GTKMM_PACKER_DEFAULT, guint x=GTKMM_PACKER_DEFAULT, guint y=GTKMM_PACKER_DEFAULT, guint ix=GTKMM_PACKER_DEFAULT, guint iy=GTKMM_PACKER_DEFAULT); // These are our own void set_side(GtkSideType s); void set_anchor(GtkAnchorType a); void set_options(guint o); void set_border_width(guint b); void set_pad(guint x,guint y); void set_ipad(guint x,guint y); }; class PackerList; class Element { friend class PackerList; private: Widget* child_; GtkSideType side_; GtkAnchorType anchor_; guint options_; guint border_width_; guint pad_x_; guint pad_y_; guint i_pad_x_; guint i_pad_y_; public: Element(Widget &child, GtkSideType side, GtkAnchorType anchor = GTK_ANCHOR_CENTER, guint options=(guint)0, guint border_width=GTKMM_PACKER_DEFAULT, guint pad_x=GTKMM_PACKER_DEFAULT, guint pad_y=GTKMM_PACKER_DEFAULT, guint i_pad_x=GTKMM_PACKER_DEFAULT, guint i_pad_y=GTKMM_PACKER_DEFAULT); }; class PackerList { public: typedef Child* value_type; typedef value_type & reference; typedef const value_type & const_reference; typedef G_List_Iterator<value_type> iterator; typedef G_List_ConstIterator<iterator> const_iterator; typedef G_List_ReverseIterator<iterator> reverse_iterator; typedef G_List_ConstIterator<reverse_iterator> const_reverse_iterator; typedef size_t difference_type; typedef size_t size_type; private: friend class Gtk::Packer; Gtk::Packer *parent_; explicit PackerList(Packer* parent): parent_(parent) {} GList*& glist() const; // front of list iterator begin_() const; iterator end_() const; public: ~PackerList() {} inline iterator begin() {return begin_();} inline iterator end() {return end_();} inline const_iterator begin() const { return const_iterator(begin_()); } inline const_iterator end() const { return const_iterator(end_()); } inline reverse_iterator rbegin() { return reverse_iterator(end_()); } inline reverse_iterator rend() { return reverse_iterator(begin_()); } inline const_reverse_iterator rbegin() const { return const_reverse_iterator(reverse_iterator(end_())); } inline const_reverse_iterator rend() const { return const_reverse_iterator(reverse_iterator(begin_())); } size_type size(void) const; inline size_type max_size(void) { return size_type(-1); } inline bool empty(void) { return glist() == 0; } iterator insert(iterator position, const Element& e); template <class InputIterator> inline void insert(iterator position, InputIterator first, InputIterator last) { for (;first!=last;++first) position=insert(position,*first); } inline void push_front(const Element& e) { insert(begin(), e); } inline void push_back(const Element& e) { insert(end(), e); } inline void pop_front() { erase(begin()); } inline void pop_back() { erase(--end()); } void clear(); iterator erase(iterator); void erase(iterator start, iterator stop); void remove(const_reference); void remove(Widget& w); iterator find(const_reference c); iterator find(Widget&); // Non-standard void reorder(iterator loc,iterator pos); }; }; //: Gtk_Packer is easy-to-use container widget. class Packer : public Container { public: typedef Packer CppObjectType; typedef GtkPacker BaseObjectType; public: //: Returns the underlaying gtk+ object. GtkPacker* gtkobj(); const GtkPacker* gtkobj() const; //: Returns true if object is this type. static bool isA(Gtk::Object *object); virtual ~Packer(); private: public: typedef Packer_Helpers::PackerList PackerList; typedef PackerList::iterator iterator; Packer(); /* this overrides the virtual function */ //void add_impl(Gtk_Widget *child) { add(*child, GTK_SIDE_TOP); } //: Add a widget with specified location //- {\var options}: {\enum GTK_PACK_EXPAND, GTK_FILL_X, GTK_FILL_Y} //- //- {\var side}: {\enum GTK_SIDE_TOP(default), GTK_SIDE_BOTTOM //- GTK_SIDE_LEFT, GTK_SIDE_RIGHT} //- //- {\var anchor}: {\enum GTK_ANCHOR_CENTER, //- GTK_ANCHOR_NORTH | GTK_ANCHOR_N, //- GTK_ANCHOR_NORTH_WEST | GTK_ANCHOR_NW, //- GTK_ANCHOR_NORTH_EAST | GTK_ANCHOR_NE, //- GTK_ANCHOR_SOUTH | GTK_ANCHOR_S, //- GTK_ANCHOR_SOUTH_WEST | GTK_ANCHOR_SW, //- GTK_ANCHOR_SOUTH_EAST | GTK_ANCHOR_SE, //- GTK_ANCHOR_WEST | GTK_ANCHOR_W, //- GTK_ANCHOR_EAST | GTK_ANCHOR_E} // // the default values of GTKMM_PACKER_DEFAULT will be transformed to real // default values inside the method -- hack to overcome c++'s // nice restriction... void add(Gtk::Widget& child,GtkSideType side,GtkAnchorType anchor=GTK_ANCHOR_CENTER,guint options=(guint)0,guint border_width=GTKMM_PACKER_DEFAULT,guint pad_x=GTKMM_PACKER_DEFAULT,guint pad_y=GTKMM_PACKER_DEFAULT,guint i_pad_x=GTKMM_PACKER_DEFAULT,guint i_pad_y=GTKMM_PACKER_DEFAULT); guint get_spacing() const; guint get_default_border_width() const; guint get_default_pad_x() const; guint get_default_pad_y() const; guint get_default_ipad_x() const; guint get_default_ipad_y() const; void set_spacing(guint spacing); void set_default_border_width(guint border); void set_default_pad(guint pad_x,guint pad_y); void set_default_ipad(guint i_pad_x,guint i_pad_y); // Fancy access PackerList& children() {return reinterpret_cast<PackerList&>(widget_self); } const PackerList& children() const {return reinterpret_cast<const PackerList&>(widget_self); } protected: // impl functions }; //+ PROPERTIES(Gtk_Packer) //. name: children //. type: GPackerList* //. get: //. set: //. desc: //. name: spacing //. type: guint //. get: //. set: //. desc: //. name: default_border_width //. type: guint:16 //. get: //. set: //. desc: //. name: default_pad_x //. type: guint:16 //. get: //. set: //. desc: //. name: default_pad_y //. type: guint:16 //. get: //. set: //. desc: //. name: default_i_pad_x //. type: guint:16 //. get: //. set: //. desc: //. name: default_i_pad_y //. type: guint:16 //. get: //. set: //. desc: }