MDI thing




Hi,

See, I'm collecting interfaces that have been discussed, so I can
implement them when the mood strikes. ;-)

Here is one I'm thinking of doing after finishing the gdk-pixbuf,
stock factory, and dialog patches.

It's a "pseudo-MDI" as described in the TODO list, if you've seen an
IDE lately most of them use a widget like this I think. It can be used
as a plain MDI widget by just using the center area, and not using any
of the slots on the sides the IDEs have.

Havoc

#ifndef __GTK_MULTI_VIEW_H__
#define __GTK_MULTI_VIEW_H__

#include <gtk/gtkcontainer.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/* Flags specifying where the child is allowed to go. */
typedef enum
{
  /* Lock child in its default slot. Child can't be dragged. This flag
     is mutually exclusive with all the other flags. */
  GTK_MULTI_VIEW_CHILD_LOCKED   = 1 << 0,

  /* Allow child to float */
  GTK_MULTI_VIEW_CHILD_FLOATING = 1 << 1,

  /* Center only */
  GTK_MULTI_VIEW_CHILD_CENTER   = 1 << 2,

  /* Right, left, top, bottom */
  GTK_MULTI_VIEW_CHILD_TOP      = 1 << 3,
  GTK_MULTI_VIEW_CHILD_BOTTOM   = 1 << 4,
  GTK_MULTI_VIEW_CHILD_LEFT     = 1 << 5,
  GTK_MULTI_VIEW_CHILD_RIGHT    = 1 << 6,

  /* Some convenience values, combining the other flags. */
  
  /* Left-right edges only */
  GTK_MULTI_VIEW_CHILD_HORIZONTAL = GTK_MULTI_VIEW_CHILD_LEFT |
  GTK_MULTI_VIEW_CHILD_RIGHT,

  /* top-bottom edges only */
  GTK_MULTI_VIEW_CHILD_VERTICAL   = GTK_MULTI_VIEW_CHILD_TOP |
  GTK_MULTI_VIEW_CHILD_BOTTOM,
  
  /* left/right/top/bottom edges */
  GTK_MULTI_VIEW_CHILD_EDGE = GTK_MULTI_VIEW_CHILD_HORIZONTAL |
  GTK_MULTI_VIEW_CHILD_VERTICAL,

  /* Allow movement to any position */
  GTK_MULTI_VIEW_CHILD_ANYWHERE = GTK_MULTI_VIEW_CHILD_CENTER |
  GTK_MULTI_VIEW_CHILD_EDGE | GTK_MULTI_VIEW_CHILD_FLOATING,

} GtkMultiViewChildFlags;

/* Enum representing where the child actually is. */
typedef enum
{
  GTK_MULTI_VIEW_POS_FLOATING,
  GTK_MULTI_VIEW_POS_CENTER,
  GTK_MULTI_VIEW_POS_LEFT,
  GTK_MULTI_VIEW_POS_RIGHT,
  GTK_MULTI_VIEW_POS_TOP,
  GTK_MULTI_VIEW_POS_BOTTOM
} GtkMultiViewPosType;

typedef enum
{
  /* Don't allow the user to move any widgets into the
     slot. */
  GTK_MULTI_VIEW_SLOT_EMPTY,

  /* Allow only one child in this slot */
  GTK_MULTI_VIEW_SLOT_EXCLUSIVE,
  
  /* Put children in a notebook if multiple children are in the same
     slot. */
  GTK_MULTI_VIEW_SLOT_TABS,
  
  /* Your app must provide a UI for cycling and moving the stacked
     widgets if you select this mode. For example a text editor might
     let you cycle widgets with C-x b as in Emacs, or you might
     provide a menu. */
  GTK_MULTI_VIEW_SLOT_NO_TABS
} GtkMultiViewSlotType;

#define GTK_TYPE_MULTI_VIEW             (gtk_multi_view_get_type ())
#define GTK_MULTI_VIEW(obj)             (GTK_CHECK_CAST ((obj),
#GTK_TYPE_MULTI_VIEW, GtkMultiView))
#define GTK_MULTI_VIEW_CLASS(klass)     (GTK_CHECK_CLASS_CAST
#((klass), GTK_TYPE_MULTI_VIEW, GtkMultiViewClass))
#define GTK_IS_MULTI_VIEW(obj)          (GTK_CHECK_TYPE ((obj),
#GTK_TYPE_MULTI_VIEW))
#define GTK_IS_MULTI_VIEW_CLASS(klass)  (GTK_CHECK_CLASS_TYPE
#((klass), GTK_TYPE_MULTI_VIEW))


typedef struct _GtkMultiView      GtkMultiView;
typedef struct _GtkMultiViewClass  GtkMultiViewClass;

struct _GtkMultiView
{
  GtkContainer container;
};

struct _GtkMultiViewClass
{
  GtkContainerClass parent_class;

  /* Child moved to a new slot. */
  void (* child_repositioned) (GtkMultiView *multi, GtkWidget *child,
                               GtkMultiViewPosType new_pos);

  /* Child was hidden, and is now on top of the stack, but
     probably isn't user-visible yet (it will be user-visible
     as soon as we enter the event loop) */
  void (* child_surfaced)    (GtkMultiView *multi, GtkWidget *child);

  /* Child is about to be stuck underneath another child. */
  void (* child_submerged)   (GtkMultiView *multi, GtkWidget *child);
  
};

GtkType        gtk_multi_view_get_type       (void);
GtkWidget*     gtk_multi_view_new            (void);


void           gtk_multi_view_add            (GtkMultiView *multi,
                                              GtkWidget    *child,
                                              GtkWidget    *tab_label,
                                              GtkMultiViewChildFlags
                                              type,
                                              GtkMultiViewPosType
                                              default_pos);

void           gtk_multi_view_set_stacking   (GtkMultiView *multi,
                                              GtkMultiViewPosType pos,
                                              GtkMultiViewSlotType
                                              stacking);

GtkMultiViewSlotType gtk_multi_view_get_stacking (GtkMultiView *multi,
                                                  GtkMultiViewPosType
                                                  pos);

gboolean gtk_multi_view_child_is_surfaced (GtkMultiView *multi,
                                           GtkWidget    *child);

/*
  These two functions bring the child to the top, or drop it below
  the top. 

  These may not emit child_surfaced or child_submerged if the child
  is already surfaced/submerged (i.e. they are not signal-emission
  functions).

  If a child is floating, surface_child does a raise/show on its
  window
  to try to uniconify it and circulate it upward. But you wan't get
  a child_surfaced signal, since all floating windows are considered
  to be surfaced.
*/
void gtk_multi_view_surface_child (GtkMultiView *multi,
                                   GtkWidget *child);

void gtk_multi_view_submerge_child (GtkMultiView *multi,
                                    GtkWidget *child);

GtkMultiViewPosType gtk_multi_view_get_child_position (GtkMultiView
*multi,
                                                       GtkWidget
*child);

void gtk_multi_view_set_child_position (GtkMultiView *multi,
                                        GtkWidget* child,
                                        GtkMultiViewPosType pos);

/* Children are returned sorted from top to bottom. i.e. the first
   child in the list is on top. Must free the return value. */
GList * gtk_multi_view_get_children_at_pos (GtkMultiView *multi,
                                            GtkMultiViewPosType pos);


/* Useful to load/save children from a file. */
gchar * gtk_multi_view_serialize_child_state (GtkMultiView *multi,
                                              GtkWidget    *child);
void    gtk_multi_view_restore_child_state (GtkMultiView *multi,
                                            GtkWidget    *child,
                                            const gchar  *serialization);

#ifdef __cplusplus
}
#endif /* __cplusplus */


#endif /* __GTK_MULTI_VIEW_H__ */



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