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 #include <xview/xview.h>
33 #include <xview/panel.h>
34 #include <xview/text.h>
35 #include <xview/svrimage.h>
36 #include <xview/icon.h>
37 #include <X11/Xlib.h>
38 
39 #include "genC.h"
40 #include "misc.h"
41 
42 #include "wpips.h"
43 
44 enum {ICON_TEXT_HEIGHT = 20};
45 
46 /* To store the negative image for a blinking icon in the interrupt
47  button: */
50 
51 static Server_image pips_icon_server_image[LAST_ICON];
52 
53 
54 typedef struct {
55  char * name;
56  unsigned short int bitmap[256];
58 
60  {
61  "pips", {
62 #include "pips.icon"
63  }}, {
64  "ICFG", {
65 #include "ICFG.icon"
66  }}, {
67  "WP65_PE", {
68 #include "WP65_PE.icon"
69  }}, {
70  "WP65_bank", {
71 #include "WP65_bank.icon"
72  }}, {
73  "callgraph", {
74 #include "callgraph.icon"
75  }}, {
76  "parallel", {
77 #include "parallel.icon"
78  }}, {
79  "sequential", {
80 #include "sequential.icon"
81  }}, {
82  "user", {
83 #include "user.icon"
84  }}
85 };
86 
87 
88 /*#include "logo_pips_small.xpm"*/
89 #include "logo_pips_small.xbm"
90 
91 
93 {
94  int i;
95 
96  for(i = 0; i < LAST_ICON; i++) {
98  (Server_image) xv_create(NULL, SERVER_IMAGE,
99  XV_WIDTH, 64,
100  XV_HEIGHT, 64,
101  SERVER_IMAGE_BITS, &pips_icons_data[i].bitmap[0],
102  NULL);
103  }
104 
105  set_pips_icon(main_frame, "pips", "Wpips");
106 }
107 
108 
109 Server_image
111 {
112  /* To store the negative image for a blinking icon in the interrupt
113  button: */
114  char * inverted_pips_icon;
115  int i;
116  /* Pixmap logo_pips_small_pixmap;
117 
118  logo_pips_small_pixmap = XCreatePixmap((Display *) xv_get(main_frame,
119  XV_DISPLAY),
120  (Window) xv_get(main_frame,
121  XV_ID),
122  */
124  (Server_image) xv_create(NULL, SERVER_IMAGE,
125  /*SERVER_IMAGE_PIXMAP,
126  logo_pips_small,
127  SERVER_IMAGE_X_BITS,
128  logo_pips_small,
129  SERVER_IMAGE_DEPTH, 8,
130  XV_WIDTH, 56,
131  XV_HEIGHT, 51,*/
132  SERVER_IMAGE_X_BITS,
133  logo_pips_small_bits,
134  XV_WIDTH, logo_pips_small_width,
135  XV_HEIGHT, logo_pips_small_height,
136  NULL);
137 
138  inverted_pips_icon = (char *) malloc(sizeof(logo_pips_small_bits));
139  for (i = 0; i < sizeof(logo_pips_small_bits); i++)
140  inverted_pips_icon[i] = ~logo_pips_small_bits[i];
142  (Server_image) xv_create(NULL, SERVER_IMAGE,
143  SERVER_IMAGE_X_BITS,
144  inverted_pips_icon,
145  XV_WIDTH, logo_pips_small_width,
146  XV_HEIGHT, logo_pips_small_height,
147  NULL);
148  free(inverted_pips_icon);
149 
151 }
152 
153 
154 void
155 set_pips_icon(Frame frame,
156  char * icon_name,
157  char * icon_text)
158 {
159  int i;
160  Server_image image = NULL;
161 
162  for (i = 0; i < LAST_ICON; i++) {
163  if (strcmp(icon_name, pips_icons_data[i].name) == 0) {
165  break;
166  }
167  }
168  if (image != NULL) {
169  /* Ok, the icon has been found */
170  Icon icon;
171  Rect image_rect, label_rect;
172  int height, width;
173 
174  width = xv_get(image, XV_WIDTH);
175  height = xv_get(image, XV_HEIGHT);
176 
177  rect_construct(&image_rect, 0, 0, width, height);
178  rect_construct(&label_rect, 0, height + 5, width, ICON_TEXT_HEIGHT);
179 
180  /* Hum... Is there a need to free the old icon ? */
181  /* Bug if we don't reuse an already existing frame's icon... */
182  icon = (Icon) xv_get(frame, FRAME_ICON);
183  /* fprintf(stderr, "0x%x\n", icon); */
184  if (icon != NULL) {
185  /* If the owner of the icon is not NULL, the behaviour is crazy !
186  RK, 16/06/94. */
187  xv_set(icon,
188  ICON_IMAGE, image,
189  XV_WIDTH, width,
190  XV_HEIGHT, height + ICON_TEXT_HEIGHT,
191  ICON_IMAGE_RECT, &image_rect,
192  ICON_LABEL, icon_text,
193  ICON_LABEL_RECT, &label_rect,
194  NULL);
195  }
196  else {
197  icon = (Icon) xv_create(NULL, ICON,
198  ICON_IMAGE, image,
199  XV_WIDTH, width,
200  XV_HEIGHT, height + ICON_TEXT_HEIGHT,
201  ICON_IMAGE_RECT, &image_rect,
202  ICON_LABEL, icon_text,
203  ICON_LABEL_RECT, &label_rect,
204  NULL);
205 
206  xv_set(frame, FRAME_ICON, icon,
207  NULL);
208  }
209  /* If we want to place the icon on the screen :
210  rect.r_width= (int)xv_get(icon, XV_WIDTH);
211  rect.r_height= (int)xv_get(icon, XV_HEIGHT);
212  rect.r_left= 0;
213  rect.r_top= 0;
214 
215  xv_set(frame, FRAME_ICON, icon,
216  FRAME_CLOSED_RECT, &rect,
217  NULL);
218  */
219  }
220 }
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
@ 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
static pips_icons_type pips_icons_data[LAST_ICON]
Definition: xv_icons.c:59
static Server_image pips_icon_server_image[LAST_ICON]
Definition: xv_icons.c:51