PIPS
xv_icons.c
Go to the documentation of this file.
1 /*
2 
3  $Id: xv_icons.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 #include <stdio.h>
28 #include <stdlib.h>
29 
30 #include <sys/time.h>
31 #include <sys/resource.h>
32 
33 #include "genC.h"
34 #include "misc.h"
35 
36 #undef test_undefined // also defined in glib included from gtk
37 #include <gtk/gtk.h>
38 #include "gpips.h"
39 
40 enum {
41  ICON_TEXT_HEIGHT = 20
42 };
43 
44 /* To store the negative image for a blinking icon in the interrupt
45  button: */
47 
48 static Server_image pips_icon_server_image[LAST_ICON];
49 
50 typedef struct {
51  char * name;
52  unsigned short int bitmap[256];
54 
55 static pips_icons_type pips_icons_data[LAST_ICON] = { { "pips", {
56 #include "pips.icon"
57  } }, { "ICFG", {
58 #include "ICFG.icon"
59  } }, { "callgraph", {
60 #include "callgraph.icon"
61  } }, { "parallel", {
62 #include "parallel.icon"
63  } }, { "sequential", {
64 #include "sequential.icon"
65  } }, { "user", {
66 #include "user.icon"
67  } } };
68 
69 /*#include "logo_pips_small.xpm"*/
70 #include "logo_pips_small.xbm"
71 
72 void create_icons() {
73  int i;
74 
75  for (i = 0; i < LAST_ICON; i++) {
76  pips_icon_server_image[i] = (Server_image) xv_create(NULL,
77  SERVER_IMAGE, XV_WIDTH, 64, XV_HEIGHT, 64, SERVER_IMAGE_BITS,
78  &pips_icons_data[i].bitmap[0], NULL);
79  }
80 
81  set_pips_icon(main_frame, "pips", "Wpips");
82 }
83 
85  /* To store the negative image for a blinking icon in the interrupt
86  button: */
87  char * inverted_pips_icon;
88  int i;
89  /* Pixmap logo_pips_small_pixmap;
90 
91  logo_pips_small_pixmap = XCreatePixmap((Display *) xv_get(main_frame,
92  XV_DISPLAY),
93  (Window) xv_get(main_frame,
94  XV_ID),
95  */
96  wpips_positive_server_image = (Server_image) xv_create(NULL, SERVER_IMAGE,
97  /*SERVER_IMAGE_PIXMAP,
98  logo_pips_small,
99  SERVER_IMAGE_X_BITS,
100  logo_pips_small,
101  SERVER_IMAGE_DEPTH, 8,
102  XV_WIDTH, 56,
103  XV_HEIGHT, 51,*/
104  SERVER_IMAGE_X_BITS, logo_pips_small_bits, XV_WIDTH, logo_pips_small_width,
105  XV_HEIGHT, logo_pips_small_height, NULL);
106 
107  inverted_pips_icon = (char *) malloc(sizeof(logo_pips_small_bits));
108  for (i = 0; i < sizeof(logo_pips_small_bits); i++)
109  inverted_pips_icon[i] = ~logo_pips_small_bits[i];
110  wpips_negative_server_image = (Server_image) xv_create(NULL, SERVER_IMAGE,
111  SERVER_IMAGE_X_BITS, inverted_pips_icon, XV_WIDTH,
112  logo_pips_small_width, XV_HEIGHT, logo_pips_small_height, NULL);
113  free(inverted_pips_icon);
114 
116 }
117 
118 void set_pips_icon(Frame frame, char * icon_name, char * icon_text) {
119  int i;
120  Server_image image = NULL;
121 
122  for (i = 0; i < LAST_ICON; i++) {
123  if (strcmp(icon_name, pips_icons_data[i].name) == 0) {
125  break;
126  }
127  }
128  if (image != NULL) {
129  /* Ok, the icon has been found */
130  Icon icon;
131  Rect image_rect, label_rect;
132  int height, width;
133 
134  width = xv_get(image, XV_WIDTH);
135  height = xv_get(image, XV_HEIGHT);
136 
137  rect_construct(&image_rect, 0, 0, width, height);
138  rect_construct(&label_rect, 0, height + 5, width, ICON_TEXT_HEIGHT);
139 
140  /* Hum... Is there a need to free the old icon ? */
141  /* Bug if we don't reuse an already existing frame's icon... */
142  icon = (Icon) xv_get(frame, FRAME_ICON);
143  /* fprintf(stderr, "0x%x\n", icon); */
144  if (icon != NULL) {
145  /* If the owner of the icon is not NULL, the behaviour is crazy !
146  RK, 16/06/94. */
147  xv_set(icon, ICON_IMAGE, image, XV_WIDTH, width, XV_HEIGHT, height
148  + ICON_TEXT_HEIGHT, ICON_IMAGE_RECT, &image_rect,
149  ICON_LABEL, icon_text, ICON_LABEL_RECT, &label_rect, NULL);
150  } else {
151  icon = (Icon) xv_create(NULL, ICON, ICON_IMAGE, image, XV_WIDTH,
152  width, XV_HEIGHT, height + ICON_TEXT_HEIGHT,
153  ICON_IMAGE_RECT, &image_rect, ICON_LABEL, icon_text,
154  ICON_LABEL_RECT, &label_rect, NULL);
155 
156  xv_set(frame, FRAME_ICON, icon, NULL);
157  }
158  /* If we want to place the icon on the screen :
159  rect.r_width= (int)xv_get(icon, XV_WIDTH);
160  rect.r_height= (int)xv_get(icon, XV_HEIGHT);
161  rect.r_left= 0;
162  rect.r_top= 0;
163 
164  xv_set(frame, FRAME_ICON, icon,
165  FRAME_CLOSED_RECT, &rect,
166  NULL);
167  */
168  }
169 }
void * malloc(YYSIZE_T)
void free(void *)
@ LAST_ICON
Definition: gpips-local.h:56
GtkWidget * main_frame
If we are in the Emacs mode, the log_frame is no longer really used:
Definition: gpips.c:60
static pips_icons_type pips_icons_data[LAST_ICON]
Definition: xv_icons.c:55
static Server_image pips_icon_server_image[LAST_ICON]
Definition: xv_icons.c:48
@ ICON_TEXT_HEIGHT
Definition: xv_icons.c:41
void set_pips_icon(Frame frame, char *icon_name, char *icon_text)
Definition: xv_icons.c:118
Server_image wpips_positive_server_image
To store the negative image for a blinking icon in the interrupt button:
Definition: xv_icons.c:46
Server_image create_status_window_pips_image()
Definition: xv_icons.c:84
void create_icons()
include "logo_pips_small.xpm"
Definition: xv_icons.c:72
Server_image wpips_negative_server_image
Definition: xv_icons.c:46
code taken from http://fast-edge.googlecode.com and adapted to c99
Definition: erode_dilate.c:33
char * name
Definition: xv_icons.c:51