File: jpc_coloredit.c

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (190 lines) | stat: -rw-r--r-- 4,550 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/* Copyright (C) 1998 Chancelier Jean-Philippe */

#include "wf_fig.h"
#include "wf_figx.h"
#include "wf_resources.h"
#include "wf_mode.h"
#include "wf_w_drawprim.h"
#include "wf_w_util.h"
#include "wf_w_setup.h"

#include <string.h> /* in case of dmalloc */ 

#ifdef __STDC__
#include <stdlib.h>
#else
#include <malloc.h>
#endif

#include "../machine.h"
#include "All-extern.h"
#include "All-extern-x1.h" 

static void set_std_color  __PARAMS((Widget w, XtPointer number, XButtonEvent *ev));  
static void choice_panel_cancel  __PARAMS((Widget w, char *dum, XButtonEvent *ev));  
static void set_color_ok  __PARAMS((Widget w, int number, XButtonEvent *ev));  

DeclareStaticArgs(20);

/* width/height of the standard color cells */
#define STD_COL_W	20
#define STD_COL_H	20
#define MAXCOLS 32 
#define x_color(i) i 
/** XXXXXX **/

void popup_choice_panel(tool) 
     Widget tool;
{
  Widget choice_popup,form,cancel,ok_button;
  NextArg(XtNresize, False);
  NextArg(XtNresizable, False);
  NextArg(XtNtitle, "View Colormap");
  /** XXXXX   NextArg(XtNcolormap, tool_cm); **/

  choice_popup = XtCreatePopupShell("ColorView",
				    transientShellWidgetClass, tool,
				    Args, ArgCount);
  
  form = XtCreateManagedWidget("form", formWidgetClass, choice_popup, NULL, 0);

  FirstArg(XtNlabel, "Cancel");
  NextArg(XtNresize, False);
  NextArg(XtNresizable, False);
  NextArg(XtNheight, 32);
  NextArg(XtNborderWidth, INTERNAL_BW);
  cancel = XtCreateManagedWidget("cancel", commandWidgetClass,
				 form, Args, ArgCount);

  XtAddEventHandler(cancel, ButtonReleaseMask, (Boolean) 0,
		    (XtEventHandler)choice_panel_cancel, (XtPointer) NULL);

  /* make the OK button */
  FirstArg(XtNlabel, "  Ok  ");
  NextArg(XtNheight, 30);
  NextArg(XtNfromHoriz, cancel);
  NextArg(XtNborderWidth, INTERNAL_BW);
  ok_button = XtCreateManagedWidget("set_color_ok", commandWidgetClass,
				    form, Args, ArgCount);
  XtAddEventHandler(ok_button, ButtonReleaseMask, (Boolean) 0,
		    (XtEventHandler) set_color_ok, (XtPointer) NULL);
  
  create_color_panel(form,cancel);
  XtPopup(choice_popup, XtGrabExclusive);
  /** XXXXX : a rajouter **/
  /**(void) XSetWMProtocols(XtDisplay(choice_popup), XtWindow(choice_popup),
    &wm_delete_window, 1);
    **/
}


void create_color_panel(form,cancel)
     Widget		 form,  cancel;
{
  int screencolor=0;
  int		 i;
  XColor	 col;
  Widget		 below=NULL, beside=NULL, stdForm, stdLabel;
  /********************************/
  /* now the standard color panel */
  /********************************/

  FirstArg(XtNlabel, "Standard Colors");
  NextArg(XtNfromVert,cancel);
  stdLabel = XtCreateManagedWidget("stdLabel", labelWidgetClass,
				   form, Args, ArgCount);

  /* put them in a form just to make a nice border */
  FirstArg(XtNfromVert, stdLabel);
  NextArg(XtNvertDistance, 0);
  stdForm = XtCreateManagedWidget("stdForm", formWidgetClass,
				  form, Args, ArgCount);

  /* create the standard color buttons */
  for (i = 0; i < MAXCOLS;  i++) 
    {
      int choice ;
      FirstArg(XtNheight, STD_COL_H);
      choice = i;
      /* check for new row of buttons */
	if (i % 10 == 0) {
	  if (i == 0)
	    below = NULL;
	  else
	    below = beside;
	  beside = NULL;
	}
      /* standard color menu */
	getcolordef(&screencolor);
	if (screencolor)
	  {
	    char num_col[4];
	    col.pixel = x_color(i);
	    /* set same so we don't get white or black when click on color */
	    NextArg(XtNforeground, 0);
	    NextArg(XtNbackground, x_color(i));
	    sprintf(num_col,"%d",i);
	    NextArg(XtNlabel, num_col);
	  } 
	NextArg(XtNwidth, STD_COL_W);
	NextArg(XtNfromVert, below);
	NextArg(XtNfromHoriz, beside);
	NextArg(XtNresize, False);
	NextArg(XtNresizable, False);
	beside = XtCreateManagedWidget("stdColor", commandWidgetClass,
				       stdForm, Args, ArgCount);
	XtAddEventHandler(beside, ButtonReleaseMask, (Boolean) 0,
			  (XtEventHandler) set_std_color, (XtPointer) i );
    }
}


/* come here when cancel is pressed.  This is in addition to the 
   cancel callback routine that gets called in w_indpanel.c */

void
cancel_color_popup(w, dum1, dum2)
     Widget	w;
     XtPointer dum1, dum2;
{

}



/* ok button */

static void
set_std_color(w, number, ev)
     Widget		 w;
     XtPointer number;
     XButtonEvent	*ev;
{
  sciprint("%d",(int) number);
}




/* ok button */

static void
choice_panel_cancel(w, dum, ev)
     Widget		 w;
     char		*dum;
     XButtonEvent	*ev;
{

}


/* ok button */

static void
set_color_ok(w, number, ev)
     Widget		 w;
     XButtonEvent	*ev;
{

}