diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2009-07-04 12:21:26 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2009-07-04 12:21:26 (GMT) | 
| commit | a60e81ac70b3d829f486ce7b6534005a9d025206 (patch) | |
| tree | 0e3b284a12a1f8f4932f5cd05247a556cf8c5bf9 /src/gtkext | |
| parent | b6893c7b85c34f7a3c65ac76bfd9d95b1c4ebf55 (diff) | |
Defined general rendering options using a GLib object.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@89 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext')
| -rw-r--r-- | src/gtkext/gtkblockview.c | 14 | ||||
| -rw-r--r-- | src/gtkext/gtkblockview.h | 2 | ||||
| -rw-r--r-- | src/gtkext/gtkgraphview.c | 10 | ||||
| -rw-r--r-- | src/gtkext/gtklinkrenderer.c | 141 | ||||
| -rw-r--r-- | src/gtkext/gtklinkrenderer.h | 59 | 
5 files changed, 213 insertions, 13 deletions
| diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c index f0ee0dd..19510cb 100644 --- a/src/gtkext/gtkblockview.c +++ b/src/gtkext/gtkblockview.c @@ -41,7 +41,7 @@ struct _GtkBlockView  {      GtkBinView parent;                      /* A laisser en premier        */ -    LinesMainOwner owner;                   /* Support final des lignes    */ +    MainRendering rendering;                /* Support final des lignes    */      bool show_vaddress;                     /* Affichage des adresses ?    */      bool show_code;                         /* Affichage du code brut ?    */ @@ -122,7 +122,7 @@ G_DEFINE_TYPE(GtkBlockView, gtk_block_view, GTK_TYPE_BIN_VIEW)  /******************************************************************************  *                                                                             * -*  Paramètres  : owner = support effectif des lignes au final.                * +*  Paramètres  : rendering = support effectif des lignes au final.            *  *                                                                             *  *  Description : Crée un nouveau composant pour l'affichage en block.         *  *                                                                             * @@ -132,13 +132,13 @@ G_DEFINE_TYPE(GtkBlockView, gtk_block_view, GTK_TYPE_BIN_VIEW)  *                                                                             *  ******************************************************************************/ -GtkWidget * gtk_block_view_new(LinesMainOwner owner) +GtkWidget * gtk_block_view_new(MainRendering rendering)  {      GtkBlockView *result;      result = gtk_type_new(gtk_block_view_get_type()); -    result->owner = owner; +    result->rendering = rendering;      return GTK_WIDGET(result); @@ -402,7 +402,7 @@ gtk_block_view_paint(GtkBlockView *view)      {          g_rendering_line_draw(iter, GDK_DRAWABLE(widget->window), GTK_BIN_VIEW(view)->gc,                                MARGIN_SPACE, 2 * MARGIN_SPACE + view->line_height, -                              y, view->line_height, view->owner); +                              y, view->line_height, view->rendering);          y += view->line_height; @@ -529,7 +529,7 @@ static void gtk_block_view_set_rendering_lines(GtkBlockView *view, GRenderingLin      }      g_rendering_line_update_bin_len(GTK_BIN_VIEW(view)->lines, -                                    GTK_BIN_VIEW(view)->last, view->owner); +                                    GTK_BIN_VIEW(view)->last, view->rendering);      gtk_block_view_recompute_size_request(view); @@ -558,7 +558,7 @@ void gtk_block_view_recompute_size_request(GtkBlockView *view)      g_rendering_line_get_size(GTK_BIN_VIEW(view)->lines,                                GTK_BIN_VIEW(view)->last, -                              view->owner, +                              view->rendering,                                &width, &height, &view->line_height);      gtk_widget_set_size_request(GTK_WIDGET(view), diff --git a/src/gtkext/gtkblockview.h b/src/gtkext/gtkblockview.h index 43561b1..ed958d0 100644 --- a/src/gtkext/gtkblockview.h +++ b/src/gtkext/gtkblockview.h @@ -55,7 +55,7 @@ typedef struct _GtkBlockViewClass GtkBlockViewClass;  GType gtk_block_view_get_type(void);  /* Crée un nouveau composant pour l'affichage en block. */ -GtkWidget *gtk_block_view_new(LinesMainOwner); +GtkWidget *gtk_block_view_new(MainRendering); diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c index 03693d5..14cd5b2 100644 --- a/src/gtkext/gtkgraphview.c +++ b/src/gtkext/gtkgraphview.c @@ -241,7 +241,7 @@ static void gtk_graph_view_set_rendering_lines(GtkGraphView *view, GRenderingLin      view->childs = (GtkBinView **)calloc(2, sizeof(GtkBinView *));      view->childs_count = 2; -    view->childs[0] = GTK_BIN_VIEW(gtk_block_view_new(LMO_GRAPH)); +    view->childs[0] = GTK_BIN_VIEW(gtk_block_view_new(MRD_GRAPH));      gtk_widget_show(GTK_WIDGET(view->childs[0]));      gtk_fixed_put(GTK_FIXED(view), GTK_WIDGET(view->childs[0]), 50, 50); @@ -256,7 +256,7 @@ static void gtk_graph_view_set_rendering_lines(GtkGraphView *view, GRenderingLin      printf("mainl : %p\n", mainl); -    view->childs[1] = GTK_BIN_VIEW(gtk_block_view_new(LMO_GRAPH)); +    view->childs[1] = GTK_BIN_VIEW(gtk_block_view_new(MRD_GRAPH));      gtk_widget_show(GTK_WIDGET(view->childs[1]));      gtk_fixed_put(GTK_FIXED(view), GTK_WIDGET(view->childs[1]), 100, 450); @@ -405,7 +405,7 @@ static GtkBinView **gtk_graph_view_load_nodes(openida_binary *binary, GRendering          {              result = (GtkBinView **)realloc(result, ++(*count) * sizeof(GtkBinView *)); -            result[*count - 1] = GTK_BIN_VIEW(gtk_block_view_new(LMO_GRAPH)); +            result[*count - 1] = GTK_BIN_VIEW(gtk_block_view_new(MRD_GRAPH));              gtk_widget_show(GTK_WIDGET(result[*count - 1]));              gtk_bin_view_show_border(result[*count - 1], true); @@ -422,7 +422,7 @@ static GtkBinView **gtk_graph_view_load_nodes(openida_binary *binary, GRendering          {              result = (GtkBinView **)realloc(result, ++(*count) * sizeof(GtkBinView *)); -            result[*count - 1] = GTK_BIN_VIEW(gtk_block_view_new(LMO_GRAPH)); +            result[*count - 1] = GTK_BIN_VIEW(gtk_block_view_new(MRD_GRAPH));              gtk_widget_show(GTK_WIDGET(result[*count - 1]));              gtk_bin_view_show_border(result[*count - 1], true); @@ -438,7 +438,7 @@ static GtkBinView **gtk_graph_view_load_nodes(openida_binary *binary, GRendering      {          result = (GtkBinView **)realloc(result, ++(*count) * sizeof(GtkBinView *)); -        result[*count - 1] = GTK_BIN_VIEW(gtk_block_view_new(LMO_GRAPH)); +        result[*count - 1] = GTK_BIN_VIEW(gtk_block_view_new(MRD_GRAPH));          gtk_widget_show(GTK_WIDGET(result[*count - 1]));          gtk_bin_view_show_border(result[*count - 1], true); diff --git a/src/gtkext/gtklinkrenderer.c b/src/gtkext/gtklinkrenderer.c new file mode 100644 index 0000000..9332860 --- /dev/null +++ b/src/gtkext/gtklinkrenderer.c @@ -0,0 +1,141 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * gtklinkrenderer.c - liens graphiques entre différents morceaux de code + * + * Copyright (C) 2009 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA 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 General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "gtklinkrenderer.h" + + + +/* Lien entre morceaux de code (instance) */ +struct _GtkLinkRenderer +{ +    GtkObject parent;                       /* A laisser en premier        */ + +    GdkPoint *points;                       /* Points de la ligne dessinée */ +    size_t count;                           /* Quantité de ces points      */ + +}; + + +/* Lien entre morceaux de code (classe) */ +struct _GtkLinkRendererClass +{ +    GtkObjectClass parent;                  /* A laisser en premier        */ + +}; + + +/* Initialise la classe générique des liens graphiques. */ +static void gtk_link_renderer_class_init(GtkLinkRendererClass *); + +/* Initialise une instance de lien graphique entre codes. */ +static void gtk_link_renderer_init(GtkLinkRenderer *); + + + + +/* Détermine le type du moteur de rendu pour les liens graphiques. */ +G_DEFINE_TYPE(GtkLinkRenderer, gtk_link_renderer, GTK_TYPE_OBJECT) + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : class = classe GTK à initialiser.                            * +*                                                                             * +*  Description : Initialise la classe générique des liens graphiques.         * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void gtk_link_renderer_class_init(GtkLinkRendererClass *class) +{ + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : view = instance GTK à initialiser.                           * +*                                                                             * +*  Description : Initialise une instance de lien graphique entre codes.       * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void gtk_link_renderer_init(GtkLinkRenderer *view) +{ + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : points = points consituant la ligne à représenter.           * +*                count  = nombre de ces points.                               * +*                                                                             * +*  Description : Crée un nouveau moteur de rendu pour les liens graphiques.   * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GtkObject *gtk_link_renderer_new(GdkPoint *points, size_t count) +{ +    GtkLinkRenderer *result;                /* Moteur de rendu à retourner */ + +    result = g_object_new(GTK_TYPE_LINK_RENDERER, NULL); + +    result->points = points; +    result->count = count; + +    return GTK_OBJECT(result); + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : renderer = moteur de rendu à manipuler.                      * +*                drawable = surface de rendu à utiliser.                      * +*                gc       = contexte graphique du dessin.                     * +*                                                                             * +*  Description : Dessine les liens graphiques enregistrés dans le moteur.     * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void gtk_link_renderer_draw(const GtkLinkRenderer *renderer, GdkDrawable *drawable, GdkGC *gc) +{ +    gdk_draw_lines(drawable, gc, renderer->points, renderer->count); + +} diff --git a/src/gtkext/gtklinkrenderer.h b/src/gtkext/gtklinkrenderer.h new file mode 100644 index 0000000..d662454 --- /dev/null +++ b/src/gtkext/gtklinkrenderer.h @@ -0,0 +1,59 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * gtklinkrenderer.h - prototypes pour les liens graphiques entre différents morceaux de code + * + * Copyright (C) 2009 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA 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 General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _GTKEXT_GTKLINKRENDERER_H +#define _GTKEXT_GTKLINKRENDERER_H + + +#include <gdk/gdk.h> +#include <gtk/gtkobject.h> + + + +#define GTK_TYPE_LINK_RENDERER                  (gtk_link_renderer_get_type()) +#define GTK_LINK_RENDERER(obj)                  (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_LINK_RENDERER, GtkLinkRenderer)) +#define GTK_LINK_RENDERER_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_LINK_RENDERER, GtkLinkRendererClass)) +#define GTK_IS_LINK_RENDERER(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_LINK_RENDERER)) +#define GTK_IS_LINK_RENDERER_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_LINK_RENDERER)) +#define GTK_LINK_RENDERER_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_LINK_RENDERER, GtkLinkRendererClass)) + + +/* Lien entre morceaux de code (instance) */ +typedef struct _GtkLinkRenderer GtkLinkRenderer; + +/* Lien entre morceaux de code (classe) */ +typedef struct _GtkLinkRendererClass GtkLinkRendererClass; + + +/* Détermine le type du moteur de rendu pour les liens graphiques. */ +GType gtk_link_renderer_get_type(void); + +/* Crée un nouveau moteur de rendu pour les liens graphiques. */ +GtkObject *gtk_link_renderer_new(GdkPoint *, size_t); + +/* Dessine les liens graphiques enregistrés dans le moteur. */ +void gtk_link_renderer_draw(const GtkLinkRenderer *, GdkDrawable *, GdkGC *); + + + +#endif  /* _GTKEXT_GTKLINKRENDERER_H */ | 
