| 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 |
#include <gtk/gtk.h> |
| 30 |
#include <gdk/gdkkeysyms.h> |
| 31 |
#include <cairo.h> |
| 32 |
#include <errno.h> |
| 33 |
#include <glib.h> |
| 34 |
#include <glib/gstdio.h> |
| 35 |
|
| 36 |
#include "common.h" |
| 37 |
#include "qxw.h" |
| 38 |
#include "filler.h" |
| 39 |
#include "dicts.h" |
| 40 |
#include "treatment.h" |
| 41 |
#include "gui.h" |
| 42 |
#include "draw.h" |
| 43 |
#include "alphabets.h" |
| 44 |
|
| 45 |
#define MAINWWIDTH 800 |
| 46 |
#define MAINWHEIGHT 628 |
| 47 |
#define FLISTWIDTH 218 |
| 48 |
|
| 49 |
int selmode=0; |
| 50 |
int nsel=0; |
| 51 |
int pxsq; |
| 52 |
int zoomf=8; |
| 53 |
int zoompx[]={18,20,22,24, 26,28,30,33, 36,39,43,47, 52,57,62,67, 72}; |
| 54 |
int curmf=1; |
| 55 |
|
| 56 |
static char*gtypedesc[NGTYPE]={ |
| 57 |
"Plain rectangular", |
| 58 |
"Hex with vertical lights", |
| 59 |
"Hex with horizontal lights", |
| 60 |
"Circular", |
| 61 |
"Circular with half-cell offset", |
| 62 |
"Join left and right edges", |
| 63 |
"Join top and bottom edges", |
| 64 |
"Join left and right edges with flip", |
| 65 |
"Join top and bottom edges with flip", |
| 66 |
"Torus", |
| 67 |
"Klein bottle (left and right edges joined with flip, top and bottom without)", |
| 68 |
"Klein bottle (top and bottom edges joined with flip, left and right without)", |
| 69 |
"Projective plane (both pairs of edges joined with flip)", |
| 70 |
}; |
| 71 |
|
| 72 |
static int spropdia(int g); |
| 73 |
static int lpropdia(int g); |
| 74 |
static int mvldia(int v); |
| 75 |
static int alphadia(void); |
| 76 |
static int dictldia(void); |
| 77 |
static int dstatsdia(void); |
| 78 |
static int treatdia(void); |
| 79 |
static int gpropdia(void); |
| 80 |
static int ccontdia(void); |
| 81 |
static int editlightdia(void); |
| 82 |
|
| 83 |
static int prefsdia(void); |
| 84 |
static int statsdia(void); |
| 85 |
static int filedia(char*res,char*but,char*ext,char*filetype,int write); |
| 86 |
static void gridchangen(void); |
| 87 |
static void syncsymmmenu(void); |
| 88 |
static void syncselmenu(void); |
| 89 |
static void syncifamenu(void); |
| 90 |
|
| 91 |
|
| 92 |
static GtkWidget *grid_da; |
| 93 |
static GtkItemFactory *item_factory; |
| 94 |
static GtkWidget *mainw,*grid_sw,*paned,*list_sw,*poss_label,*clist; |
| 95 |
static GtkWidget*stats=NULL; |
| 96 |
static GtkWidget *hist_da; |
| 97 |
static GtkWidget*(st_te[MXLE+2][5]),*(st_r[10]); |
| 98 |
|
| 99 |
static char*treat_lab[NATREAT][NMSG]={ |
| 100 |
{0, 0, }, |
| 101 |
{"Keyword: ", 0, }, |
| 102 |
{"Encode ABC...Z as: ", 0, }, |
| 103 |
{"Key character/word: ", 0, }, |
| 104 |
{"Encodings of A: ", 0, }, |
| 105 |
{"Correct characters: ", "Incorrect characters: " }, |
| 106 |
{"Characters to delete: ", 0, }, |
| 107 |
{"Characters to delete: ", 0, }, |
| 108 |
{"Characters to insert: ", 0, }, |
| 109 |
{"Message 1: ", "Message 2: " }, |
| 110 |
{"Correct characters: ", 0, }, |
| 111 |
{"Incorrect characters: ", 0 }, |
| 112 |
}; |
| 113 |
static int treatpermok[NATREAT][NMSG]={ |
| 114 |
{0,0}, |
| 115 |
{0,0}, |
| 116 |
{0,0}, |
| 117 |
{0,0}, |
| 118 |
{1,0}, |
| 119 |
{0,0}, |
| 120 |
{1,0}, |
| 121 |
{1,0}, |
| 122 |
{1,0}, |
| 123 |
{1,1}, |
| 124 |
{1,0}, |
| 125 |
{1,0}, |
| 126 |
}; |
| 127 |
static char*tnames[NATREAT]={ |
| 128 |
" None", |
| 129 |
" Playfair cipher", |
| 130 |
" Substitution cipher", |
| 131 |
" Fixed Caesar/Vigenère cipher", |
| 132 |
" Variable Caesar cipher", |
| 133 |
" Misprint (general, clue order)", |
| 134 |
" Delete single occurrence of character", |
| 135 |
" Letters latent: delete all occurrences of character", |
| 136 |
" Insert single character", |
| 137 |
" Custom plug-in", |
| 138 |
" Misprint (correct characters specified)", |
| 139 |
" Misprint (incorrect characters specified)", |
| 140 |
}; |
| 141 |
|
| 142 |
static char*mklabel[NGTYPE][MAXNDIR*2]={ |
| 143 |
{"NW mark: ","NE mark: ","SE mark: ","SW mark: "}, |
| 144 |
{"NW mark: ","NE mark: ","E mark: ", "SE mark: ","SW mark: ","W mark: "}, |
| 145 |
{"NW mark: ","N mark: ","NE mark: ", "SE mark: ","S mark: ","SW mark: "}, |
| 146 |
{"First mark: ","Second mark: ","Third mark: ","Fourth mark: "}, |
| 147 |
{"First mark: ","Second mark: ","Third mark: ","Fourth mark: "}, |
| 148 |
{"NW mark: ","NE mark: ","SE mark: ","SW mark: "}, |
| 149 |
{"NW mark: ","NE mark: ","SE mark: ","SW mark: "}, |
| 150 |
{"NW mark: ","NE mark: ","SE mark: ","SW mark: "}, |
| 151 |
{"NW mark: ","NE mark: ","SE mark: ","SW mark: "}, |
| 152 |
{"NW mark: ","NE mark: ","SE mark: ","SW mark: "}, |
| 153 |
{"NW mark: ","NE mark: ","SE mark: ","SW mark: "}, |
| 154 |
{"NW mark: ","NE mark: ","SE mark: ","SW mark: "}, |
| 155 |
{"NW mark: ","NE mark: ","SE mark: ","SW mark: "}, |
| 156 |
}; |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
static void setwintitle() {char t[SLEN*3]; |
| 162 |
sprintf(t,"Qxw: %s",titlebyauthor()); |
| 163 |
gtk_window_set_title(GTK_WINDOW(mainw),t); |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
void setfilenamebase(char*s) { |
| 168 |
strncpy(filenamebase,s,SLEN-1);filenamebase[SLEN-1]='\0'; |
| 169 |
if(strlen(filenamebase)>=4&&!strcmp(filenamebase+strlen(filenamebase)-4,".qxw")) filenamebase[strlen(filenamebase)-4]='\0'; |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
static int box(int type,const char*t,const char*u,const char*v) { |
| 174 |
GtkWidget*dia; |
| 175 |
int i; |
| 176 |
|
| 177 |
dia=gtk_message_dialog_new( |
| 178 |
GTK_WINDOW(mainw), |
| 179 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
| 180 |
type, |
| 181 |
GTK_BUTTONS_NONE, |
| 182 |
"%s",t |
| 183 |
); |
| 184 |
gtk_dialog_add_buttons(GTK_DIALOG(dia),u,GTK_RESPONSE_ACCEPT,v,GTK_RESPONSE_REJECT,NULL); |
| 185 |
i=gtk_dialog_run(GTK_DIALOG(dia)); |
| 186 |
gtk_widget_destroy(dia); |
| 187 |
return i==GTK_RESPONSE_ACCEPT; |
| 188 |
} |
| 189 |
|
| 190 |
|
| 191 |
static void okbox(const char*t) {box(GTK_MESSAGE_INFO,t,GTK_STOCK_CLOSE,0);} |
| 192 |
|
| 193 |
|
| 194 |
void repwarn(const char*s) { |
| 195 |
if(usegui) |
| 196 |
box(GTK_MESSAGE_WARNING,s,GTK_STOCK_CLOSE,0); |
| 197 |
else { |
| 198 |
fprintf(stderr,"Warning: %s\n",s); |
| 199 |
} |
| 200 |
} |
| 201 |
|
| 202 |
|
| 203 |
void reperr(const char*s) { |
| 204 |
if(usegui) |
| 205 |
box(GTK_MESSAGE_ERROR,s,GTK_STOCK_CLOSE,0); |
| 206 |
else { |
| 207 |
fprintf(stderr,"Error: %s\n",s); |
| 208 |
exit(16); |
| 209 |
} |
| 210 |
} |
| 211 |
|
| 212 |
void fsgerr() {reperr("A filing system error occurred");} |
| 213 |
|
| 214 |
void fserror() {char s[SLEN],t[SLEN*2]; |
| 215 |
#ifdef _WIN32 |
| 216 |
if(strerror_s(s,SLEN,errno)) strcpy(s,"general error"); |
| 217 |
#else |
| 218 |
if(strerror_r(errno,s,SLEN)) strcpy(s,"general error"); |
| 219 |
#endif |
| 220 |
sprintf(t,"Filing system error: %s",s); |
| 221 |
reperr(t); |
| 222 |
} |
| 223 |
|
| 224 |
static int areyousure(char*action) { |
| 225 |
char s[1000]; |
| 226 |
sprintf(s,"\n Your work is not saved. \n Are you sure you want to %s? \n",action); |
| 227 |
return box(GTK_MESSAGE_QUESTION,s," Proceed ",GTK_STOCK_CANCEL); |
| 228 |
} |
| 229 |
|
| 230 |
GtkWidget*fipdia; |
| 231 |
static volatile int killfdflag=0; |
| 232 |
|
| 233 |
static int fiptimeout(gpointer data) { |
| 234 |
DEB_GU {printf("<fiptimeout> fipdia=%p %d\n",(void*)fipdia,killfdflag); fflush(stdout);} |
| 235 |
if(killfdflag==0) return 1; |
| 236 |
killfdflag=2; |
| 237 |
gtk_dialog_response(GTK_DIALOG(fipdia),GTK_RESPONSE_ACCEPT); |
| 238 |
return 1; |
| 239 |
} |
| 240 |
|
| 241 |
static void createfipdia() { |
| 242 |
DEB_GU printf("entering createfipdia()...\n"); |
| 243 |
killfdflag=0; |
| 244 |
fipdia=gtk_message_dialog_new(GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_INFO,GTK_BUTTONS_NONE,"\n Filling in progress \n"); |
| 245 |
DEB_GU printf("fipdia=%p\n",(void*)fipdia); |
| 246 |
gtk_dialog_add_buttons(GTK_DIALOG(fipdia)," Stop ",GTK_RESPONSE_ACCEPT,NULL); |
| 247 |
gtk_widget_show_now(fipdia); |
| 248 |
while(gtk_events_pending()) gtk_main_iteration_do(0); |
| 249 |
} |
| 250 |
|
| 251 |
static void runfipdia() { |
| 252 |
int id; |
| 253 |
DEB_GU printf("entering runfipdia %p...\n",(void*)fipdia); |
| 254 |
id=g_timeout_add(100,fiptimeout,0); |
| 255 |
gtk_dialog_run(GTK_DIALOG(fipdia)); |
| 256 |
DEB_GU printf("leaving runfipdia %p...\n",(void*)fipdia); |
| 257 |
g_source_remove(id); |
| 258 |
gtk_widget_destroy(fipdia); |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
void killfipdia(void) { |
| 263 |
if(!usegui) return; |
| 264 |
DEB_GU printf("killfipdia()\n"); |
| 265 |
killfdflag=1; |
| 266 |
} |
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
static int checkoverwrite() {FILE*fp; |
| 273 |
fp=q_fopen(filename,"r"); |
| 274 |
if(!fp) return 1; |
| 275 |
fclose(fp); |
| 276 |
return box(GTK_MESSAGE_QUESTION,"\n That file already exists. \n Overwrite it? \n"," Overwrite ",GTK_STOCK_CANCEL); |
| 277 |
} |
| 278 |
|
| 279 |
static void m_filenew(GtkWidget*w,gpointer data) { |
| 280 |
if(!unsaved||areyousure("start again")) { |
| 281 |
a_filenew((intptr_t)data); |
| 282 |
strcpy(filenamebase,""); |
| 283 |
setwintitle(); |
| 284 |
syncgui(); |
| 285 |
compute(0); |
| 286 |
} |
| 287 |
} |
| 288 |
|
| 289 |
static void m_fileopen(GtkWidget*w,gpointer data) { |
| 290 |
if(!unsaved||areyousure("proceed")) if(filedia(0,"Open",".qxw","Qxw",0)) { |
| 291 |
a_load(); |
| 292 |
setwintitle(); |
| 293 |
syncgui(); |
| 294 |
compute(0); |
| 295 |
} |
| 296 |
} |
| 297 |
|
| 298 |
static void m_filesaveas(GtkWidget*w,gpointer data) { |
| 299 |
if(filedia(0,"Save",".qxw","Qxw",1)&&checkoverwrite()) { |
| 300 |
a_save(); |
| 301 |
setwintitle(); |
| 302 |
} |
| 303 |
} |
| 304 |
|
| 305 |
static void m_filesave(GtkWidget*w,gpointer data) { |
| 306 |
|
| 307 |
if(havesavefn&&strcmp(filenamebase,"")) { |
| 308 |
strcpy(filename,filenamebase); |
| 309 |
strcat(filename,".qxw"); |
| 310 |
a_save(); |
| 311 |
} |
| 312 |
else m_filesaveas(w,data); |
| 313 |
} |
| 314 |
|
| 315 |
static void m_exportvls(GtkWidget*w,gpointer data) {char t[SLEN+50]; if(filedia(t,"Export free light paths",".fl.txt","Plain text",1)) a_exportvls(t);} |
| 316 |
static void m_importvls(GtkWidget*w,gpointer data) {char t[SLEN+50]; if(filedia(t,"Import free light paths",".fl.txt","Plain text",0)) a_importvls(t);} |
| 317 |
|
| 318 |
static void m_filequit(void) {if(!unsaved||areyousure("quit")) gtk_main_quit();} |
| 319 |
static void m_undo(GtkWidget*w,gpointer data) {if((uhead+UNDOS-1)%UNDOS==utail) return;undo_pop();gridchangen();syncgui();} |
| 320 |
static void m_redo(GtkWidget*w,gpointer data) {if(uhead==uhwm) return;uhead=(uhead+2)%UNDOS;undo_pop();gridchangen();syncgui();} |
| 321 |
static void m_editgprop(GtkWidget*w,gpointer data) {gpropdia();} |
| 322 |
static void m_dsprop(GtkWidget*w,gpointer data) {spropdia(1);} |
| 323 |
static void m_sprop(GtkWidget*w,gpointer data) {spropdia(0);} |
| 324 |
static void m_dlprop(GtkWidget*w,gpointer data) {lpropdia(1);} |
| 325 |
static void m_lprop(GtkWidget*w,gpointer data) {lpropdia(0);} |
| 326 |
static void m_cellcont(GtkWidget*w,gpointer data) {ccontdia();} |
| 327 |
static void m_editlight(GtkWidget*w,gpointer data) {editlightdia();} |
| 328 |
|
| 329 |
static void m_afctreat(GtkWidget*w,gpointer data) {treatdia();} |
| 330 |
static void m_editprefs(GtkWidget*w,gpointer data) {prefsdia();} |
| 331 |
static void m_showstats(GtkWidget*w,gpointer data) {statsdia();} |
| 332 |
|
| 333 |
static void m_symmclr(void) {symmr=1; symmm=0; symmd=0; syncsymmmenu();} |
| 334 |
static void m_symm0(GtkWidget*w,gpointer data) {symmr=(intptr_t)data&0xff;} |
| 335 |
static void m_symm1(GtkWidget*w,gpointer data) {symmm=(intptr_t)data&0xff;} |
| 336 |
static void m_symm2(GtkWidget*w,gpointer data) {symmd=(intptr_t)data&0xff;} |
| 337 |
|
| 338 |
static void m_ifamode(GtkWidget*w,gpointer data) { |
| 339 |
ifamode=(intptr_t)data&0xff; |
| 340 |
if(ifamode==0) gtk_paned_set_position(GTK_PANED(paned),mainw->allocation.width+100); |
| 341 |
else gtk_paned_set_position(GTK_PANED(paned),mainw->allocation.width-FLISTWIDTH); |
| 342 |
gridchangen(); |
| 343 |
} |
| 344 |
|
| 345 |
static void m_zoom(GtkWidget*w,gpointer data) {int u; |
| 346 |
u=(intptr_t)data; |
| 347 |
if(u==-1) zoomf++; |
| 348 |
else if(u==-2) zoomf--; |
| 349 |
else zoomf=u*4; |
| 350 |
if(zoomf<0) zoomf=0; |
| 351 |
if(zoomf>16) zoomf=16; |
| 352 |
pxsq=zoompx[zoomf]; |
| 353 |
syncgui(); |
| 354 |
compute(0); |
| 355 |
} |
| 356 |
|
| 357 |
static void m_fileexport(GtkWidget*w,gpointer data) { |
| 358 |
switch((intptr_t)data) { |
| 359 |
case 0x401: if(filedia(0,"Export blank grid as EPS",".blank.eps","Encapsulated PostScript",1)) a_exportg(filename,4,0);break; |
| 360 |
case 0x402: if(filedia(0,"Export blank grid as SVG",".blank.svg","Scalable Vector Graphics",1)) a_exportg(filename,4,1);break; |
| 361 |
case 0x403: if(filedia(0,"Export blank grid as PNG",".blank.png","Portable Network Graphics",1)) a_exportg(filename,4,2);break; |
| 362 |
case 0x404: |
| 363 |
if(gshape[gtype]!=0) break; |
| 364 |
if(filedia(0,"Export blank grid as HTML",".blank.html","HyperText Markup Language",1)) a_exportgh(0x05,""); |
| 365 |
break; |
| 366 |
case 0x411: if(filedia(0,"Export filled grid as EPS",".eps","Encapsulated PostScript",1)) a_exportg(filename,lnis?6:2,0);break; |
| 367 |
case 0x412: if(filedia(0,"Export filled grid as SVG",".svg","Scalable Vector Graphics",1)) a_exportg(filename,lnis?6:2,1);break; |
| 368 |
case 0x413: if(filedia(0,"Export filled grid as PNG",".png","Portable Network Graphics",1)) a_exportg(filename,lnis?6:2,2);break; |
| 369 |
case 0x414: |
| 370 |
if(gshape[gtype]!=0) break; |
| 371 |
if(filedia(0,"Export filled grid as HTML",".html","HyperText Markup Language",1)) a_exportgh(lnis?7:3,""); |
| 372 |
break; |
| 373 |
case 0x420: if(filedia(0,"Export answers as plain text",".ans.txt","Plain text",1)) a_exporta(0);break; |
| 374 |
case 0x423: if(filedia(0,"Export answers as HTML",".ans.html","HyperText Markup Language",1)) a_exporta(1);break; |
| 375 |
case 0x433: |
| 376 |
if(gshape[gtype]!=0) break; |
| 377 |
if(filedia(0,"Export puzzle as HTML",".html","HyperText Markup Language",1)) a_exportgh(0x0d,""); |
| 378 |
break; |
| 379 |
case 0x434:if(filedia(0,"Export puzzle as HTML+SVG",".html","HyperText Markup Language",1)) a_exporthp(0,4,1);break; |
| 380 |
case 0x435:if(filedia(0,"Export puzzle as HTML+PNG",".html","HyperText Markup Language",1)) a_exporthp(0,4,2);break; |
| 381 |
case 0x443: |
| 382 |
if(gshape[gtype]!=0) break; |
| 383 |
if(filedia(0,"Export solution as HTML",".html","HyperText Markup Language",1)) a_exportgh(lnis?0x17:0x13,""); |
| 384 |
break; |
| 385 |
case 0x444:if(filedia(0,"Export solution as HTML+SVG",".html","HyperText Markup Language",1)) a_exporthp(1,lnis?6:2,1);break; |
| 386 |
case 0x445:if(filedia(0,"Export solution as HTML+PNG",".html","HyperText Markup Language",1)) a_exporthp(1,lnis?6:2,2);break; |
| 387 |
case 0x451: |
| 388 |
if(gshape[gtype]!=0) break; |
| 389 |
if(filedia(0,"Export as Crossword Compiler XML","-ccw.xml","Crossword Compiler Extensible Markup Language",1)) a_exportccwxml(filename); |
| 390 |
break; |
| 391 |
default: assert(0); |
| 392 |
} |
| 393 |
} |
| 394 |
|
| 395 |
static void selchange(void) {int i,j,d; |
| 396 |
nsel=0; |
| 397 |
if (selmode==0) for(i=0;i<width;i++) for(j=0;j<height;j++) {if(gsq[i][j].fl&16) nsel++;} |
| 398 |
else if(selmode==1) for(i=0;i<width;i++) for(j=0;j<height;j++) for(d=0;d<ndir[gtype];d++) {if(isstartoflight(i,j,d)&&(gsq[i][j].dsel&(1<<d))) nsel++;} |
| 399 |
else if(selmode==2) for(i=0;i<nvl;i++) {if(vls[i].sel) nsel++;} |
| 400 |
syncselmenu(); |
| 401 |
refreshsel(); |
| 402 |
} |
| 403 |
|
| 404 |
static void selcell(int x,int y,int f) {int i,l,gx[MXCL],gy[MXCL]; |
| 405 |
l=getmergegroup(gx,gy,x,y); |
| 406 |
if(f) f=16; |
| 407 |
for(i=0;i<l;i++) gsq[gx[i]][gy[i]].fl=(gsq[gx[i]][gy[i]].fl&~16)|f; |
| 408 |
} |
| 409 |
|
| 410 |
static void selnocells() {int i,j; |
| 411 |
for(i=0;i<width;i++) for(j=0;j<height;j++) gsq[i][j].fl&=~16; |
| 412 |
} |
| 413 |
|
| 414 |
static void selnolights() {int i,j; |
| 415 |
for(i=0;i<width;i++) for(j=0;j<height;j++) gsq[i][j].dsel=0; |
| 416 |
} |
| 417 |
|
| 418 |
static void selnovls() {int i; |
| 419 |
for(i=0;i<nvl;i++) vls[i].sel=0; |
| 420 |
} |
| 421 |
|
| 422 |
|
| 423 |
static void m_selnone(GtkWidget*w,gpointer data) { |
| 424 |
selnolights(); |
| 425 |
selnocells(); |
| 426 |
selnovls(); |
| 427 |
selchange(); |
| 428 |
} |
| 429 |
|
| 430 |
|
| 431 |
static void m_selinv(GtkWidget*w,gpointer data) {int d,i,j; |
| 432 |
for(i=0;i<width;i++) for(j=0;j<height;j++) { |
| 433 |
if (selmode==0) {if(isclear(i,j)) gsq[i][j].fl^=16;} |
| 434 |
else if(selmode==1) for(d=0;d<ndir[gtype];d++) {if(isstartoflight(i,j,d)) gsq[i][j].dsel^=1<<d;} |
| 435 |
else if(selmode==2) for(i=0;i<nvl;i++) vls[i].sel=!vls[i].sel; |
| 436 |
} |
| 437 |
selchange(); |
| 438 |
} |
| 439 |
|
| 440 |
|
| 441 |
static void m_selall(GtkWidget*w,gpointer data) {int d,i,j; |
| 442 |
for(i=0;i<width;i++) for(j=0;j<height;j++) { |
| 443 |
if (selmode==0) {if(isclear(i,j)) gsq[i][j].fl|=16;} |
| 444 |
else if(selmode==1) {for(d=0;d<ndir[gtype];d++) if(isstartoflight(i,j,d)) gsq[i][j].dsel|=1<<d;} |
| 445 |
} |
| 446 |
if(selmode==2) for(i=0;i<nvl;i++) vls[i].sel=1; |
| 447 |
selchange(); |
| 448 |
} |
| 449 |
|
| 450 |
|
| 451 |
static void sel_tol(void) {int d,i,j; |
| 452 |
if(selmode==1||selmode==2) return; |
| 453 |
DEB_GU printf("seltol()\n"); |
| 454 |
selnolights(); |
| 455 |
for(i=0;i<width;i++) for(j=0;j<height;j++) if(gsq[i][j].fl&16) for(d=0;d<ndir[gtype];d++) { |
| 456 |
DEB_GU printf(" %d %d %d\n",i,j,d); |
| 457 |
sellight(i,j,d,1); |
| 458 |
} |
| 459 |
selmode=1; |
| 460 |
} |
| 461 |
|
| 462 |
|
| 463 |
static void sel_toc(void) {int i,j,d,k,l,m,n,gx[MXCL],gy[MXCL],lx[MXCL],ly[MXCL]; |
| 464 |
DEB_GU printf("seltoc()\n"); |
| 465 |
if(selmode==0) return; |
| 466 |
selnocells(); |
| 467 |
if(selmode==1) { |
| 468 |
for(i=0;i<width;i++) for(j=0;j<height;j++) for(d=0;d<ndir[gtype];d++) |
| 469 |
if(isstartoflight(i,j,d)&&issellight(i,j,d)) { |
| 470 |
DEB_GU printf(" %d %d %d\n",i,j,d); |
| 471 |
l=getlight(lx,ly,i,j,d); |
| 472 |
for(k=0;k<l;k++) { |
| 473 |
m=getmergegroup(gx,gy,lx[k],ly[k]); |
| 474 |
for(n=0;n<m;n++) gsq[gx[n]][gy[n]].fl|=16; |
| 475 |
} |
| 476 |
} |
| 477 |
} |
| 478 |
else if(selmode==2) { |
| 479 |
for(i=0;i<nvl;i++) for(j=0;j<vls[i].l;j++) { |
| 480 |
m=getmergegroup(gx,gy,vls[i].x[j],vls[i].y[j]); |
| 481 |
for(n=0;n<m;n++) gsq[gx[n]][gy[n]].fl|=16; |
| 482 |
} |
| 483 |
} |
| 484 |
selmode=0; |
| 485 |
} |
| 486 |
|
| 487 |
|
| 488 |
static void m_sellight(GtkWidget*w,gpointer data) { |
| 489 |
if(curdir>=100) { |
| 490 |
if(curdir>=100+nvl) return; |
| 491 |
if(selmode!=2) m_selnone(w,data); |
| 492 |
selmode=2; |
| 493 |
vls[curdir-100].sel=!vls[curdir-100].sel; |
| 494 |
} |
| 495 |
else { |
| 496 |
if(selmode!=1) m_selnone(w,data); |
| 497 |
selmode=1; |
| 498 |
sellight(curx,cury,curdir,!issellight(curx,cury,curdir)); |
| 499 |
} |
| 500 |
selchange(); |
| 501 |
} |
| 502 |
|
| 503 |
|
| 504 |
static void m_sellpar(GtkWidget*w,gpointer data) {int f,i,j; |
| 505 |
if(curdir>=100) return; |
| 506 |
if(selmode!=1) m_selnone(w,data); |
| 507 |
selmode=1; |
| 508 |
f=issellight(curx,cury,curdir); |
| 509 |
for(i=0;i<width;i++) for(j=0;j<height;j++) if(isstartoflight(i,j,curdir)) sellight(i,j,curdir,!f); |
| 510 |
selchange(); |
| 511 |
} |
| 512 |
|
| 513 |
|
| 514 |
static void m_selcell(GtkWidget*w,gpointer data) {int f; |
| 515 |
if(selmode!=0) m_selnone(w,data); |
| 516 |
selmode=0; |
| 517 |
if(!isclear(curx,cury)) return; |
| 518 |
f=(~gsq[curx][cury].fl)&16; |
| 519 |
selcell(curx,cury,f); |
| 520 |
selchange(); |
| 521 |
} |
| 522 |
|
| 523 |
static void m_selcover(GtkWidget*w,gpointer data) {int i,j; |
| 524 |
if(selmode!=0) m_selnone(w,data); |
| 525 |
selmode=0; |
| 526 |
for(i=0;i<width;i++) for(j=0;j<height;j++) |
| 527 |
if(isownmergerep(i,j)) selcell(i,j,gsq[i][j].sp.spor); |
| 528 |
selchange(); |
| 529 |
} |
| 530 |
|
| 531 |
static void m_selcunch(GtkWidget*w,gpointer data) {int i,j,k,nd; |
| 532 |
if(selmode!=0) m_selnone(w,data); |
| 533 |
selmode=0; |
| 534 |
for(i=0;i<width;i++) for(j=0;j<height;j++) |
| 535 |
if(isownmergerep(i,j)) { |
| 536 |
if(getdech(i,j)) nd=ndir[gtype]; |
| 537 |
else nd=1; |
| 538 |
for(k=0;k<nd;k++) { |
| 539 |
if(gsq[i][j].ctlen[k]>0&&gsq[i][j].ents[k][0]!=0) { |
| 540 |
selcell(i,j,gsq[i][j].ents[k][0]->checking==1); |
| 541 |
break; |
| 542 |
} |
| 543 |
} |
| 544 |
} |
| 545 |
selchange(); |
| 546 |
} |
| 547 |
|
| 548 |
static void m_selctreat(GtkWidget*w,gpointer data) {int i,j; |
| 549 |
if(selmode!=0) m_selnone(w,data); |
| 550 |
selmode=0; |
| 551 |
for(i=0;i<width;i++) for(j=0;j<height;j++) |
| 552 |
if(isownmergerep(i,j)) selcell(i,j,gsq[i][j].sp.spor?gsq[i][j].sp.ten:dsp.ten); |
| 553 |
selchange(); |
| 554 |
} |
| 555 |
|
| 556 |
static void m_sellover(GtkWidget*w,gpointer data) {int d,i,j; |
| 557 |
if(selmode!=1) m_selnone(w,data); |
| 558 |
selmode=1; |
| 559 |
for(i=0;i<width;i++) for(j=0;j<height;j++) for(d=0;d<ndir[gtype];d++) |
| 560 |
if(isstartoflight(i,j,d)) sellight(i,j,d,gsq[i][j].lp[d].lpor); |
| 561 |
selchange(); |
| 562 |
} |
| 563 |
|
| 564 |
static void m_selltreat(GtkWidget*w,gpointer data) {int d,i,j; |
| 565 |
if(selmode!=1) m_selnone(w,data); |
| 566 |
selmode=1; |
| 567 |
for(i=0;i<width;i++) for(j=0;j<height;j++) for(d=0;d<ndir[gtype];d++) |
| 568 |
if(isstartoflight(i,j,d)) sellight(i,j,d,getlprop(i,j,d)->ten); |
| 569 |
selchange(); |
| 570 |
} |
| 571 |
|
| 572 |
|
| 573 |
static void m_selviol(GtkWidget*w,gpointer data) {int d,i,j,v; |
| 574 |
if(selmode!=1) m_selnone(w,data); |
| 575 |
selmode=1; |
| 576 |
v=(intptr_t)data; |
| 577 |
DEB_GU printf("selviol(%d)\n",v); |
| 578 |
for(i=0;i<width;i++) for(j=0;j<height;j++) for(d=0;d<ndir[gtype];d++) |
| 579 |
if(isstartoflight(i,j,d)) sellight(i,j,d,!!(gsq[i][j].vflags[d]&v)); |
| 580 |
selchange(); |
| 581 |
} |
| 582 |
|
| 583 |
static int issqinvl(int x,int y,int v) {int cx,cy,gx,gy,j; |
| 584 |
getmergerep(&cx,&cy,x,y); |
| 585 |
for(j=0;j<vls[v].l;j++) { |
| 586 |
getmergerep(&gx,&gy,vls[v].x[j],vls[v].y[j]); |
| 587 |
if(cx==gx&&cy==gy) return 1; |
| 588 |
} |
| 589 |
return 0; |
| 590 |
} |
| 591 |
|
| 592 |
static void m_selfvl(GtkWidget*w,gpointer data) {int i,j; |
| 593 |
if(nvl==0) {reperr("No free lights\nhave been defined");return;} |
| 594 |
if(selmode!=2) { |
| 595 |
m_selnone(w,data); |
| 596 |
for(i=0;i<nvl;i++) if(issqinvl(curx,cury,i)) break; |
| 597 |
j=i%nvl; |
| 598 |
} |
| 599 |
else { |
| 600 |
j=-1; |
| 601 |
for(i=0;i<nvl;i++) if(vls[i].sel) j=i; |
| 602 |
j=(j+1)%nvl; |
| 603 |
} |
| 604 |
for(i=0;i<nvl;i++) vls[i].sel=0; |
| 605 |
vls[j].sel=1; |
| 606 |
selmode=2; |
| 607 |
selchange(); |
| 608 |
} |
| 609 |
|
| 610 |
static void m_selmode(GtkWidget*w,gpointer data) { |
| 611 |
if(selmode==0) sel_tol(); |
| 612 |
else sel_toc(); |
| 613 |
selchange(); |
| 614 |
} |
| 615 |
|
| 616 |
static void curmoved(void) { |
| 617 |
static int odir=0; |
| 618 |
refreshcur(); |
| 619 |
if(odir>=100||curdir>=100) refreshsel(); |
| 620 |
odir=curdir; |
| 621 |
curmf=1; |
| 622 |
} |
| 623 |
|
| 624 |
static void gridchangen(void) { |
| 625 |
int d,i,j; |
| 626 |
|
| 627 |
for(i=0;i<width;i++) for(j=0;j<height;j++) for(d=0;d<ndir[gtype];d++) if(!isstartoflight(i,j,d)) gsq[i][j].dsel&=~(1<<d); |
| 628 |
selchange(); |
| 629 |
curmoved(); |
| 630 |
donumbers(); |
| 631 |
refreshnum(); |
| 632 |
compute(0); |
| 633 |
} |
| 634 |
|
| 635 |
static void gridchange(void) { |
| 636 |
gridchangen(); |
| 637 |
undo_push(); |
| 638 |
} |
| 639 |
|
| 640 |
static void chkresetat() {int i,j; |
| 641 |
for(i=0;i<NMSG;i++) if(treatorder[i]>0&&treat_lab[treatmode][i]) for(j=0;j<MXFL;j++) if(treatcstr[i][j]!=ABM_ALL) goto ew0; |
| 642 |
return; |
| 643 |
ew0: |
| 644 |
if(box(GTK_MESSAGE_QUESTION,"\n Reset answer \n treatment constraints? \n",GTK_STOCK_YES,GTK_STOCK_NO)==0) return; |
| 645 |
for(i=0;i<NMSG;i++) if(treatorder[i]>0&&treat_lab[treatmode][i]) for(j=0;j<MXFL;j++) treatcstr[i][j]=ABM_ALL; |
| 646 |
} |
| 647 |
|
| 648 |
static void m_eraseall(void) {int i,j; |
| 649 |
for(i=0;i<width;i++) for(j=0;j<height;j++) {clrcont(i,j); refreshsqmg(i,j);} |
| 650 |
chkresetat(); |
| 651 |
gridchange(); |
| 652 |
} |
| 653 |
|
| 654 |
static void m_erasesel(void) {int i,j; |
| 655 |
if(selmode!=0) { |
| 656 |
sel_toc(); |
| 657 |
selchange(); |
| 658 |
} |
| 659 |
for(i=0;i<width;i++) for(j=0;j<height;j++) {if(gsq[i][j].fl&16) {clrcont(i,j);refreshsqmg(i,j);}} |
| 660 |
chkresetat(); |
| 661 |
gridchange(); |
| 662 |
} |
| 663 |
|
| 664 |
static void m_dictionaries(GtkWidget*w,gpointer data) {dictldia();} |
| 665 |
static void m_dstats(GtkWidget*w,gpointer data) {dstatsdia();} |
| 666 |
static void m_alphabet(GtkWidget*w,gpointer data) {alphadia();} |
| 667 |
|
| 668 |
|
| 669 |
static void m_accept(GtkWidget*w,gpointer data) { |
| 670 |
int de,nd,f,i,j,x,y; |
| 671 |
ABM m; |
| 672 |
struct entry*e; |
| 673 |
ABM b; |
| 674 |
|
| 675 |
DEB_GU printf("m_accept\n"); |
| 676 |
for(x=0;x<width;x++) for(y=0;y<height;y++) { |
| 677 |
|
| 678 |
|
| 679 |
de=getdech(x,y); |
| 680 |
if(de==0) nd=1,de=1; else nd=ndir[gtype]; |
| 681 |
for(i=0;i<nd;i++) { |
| 682 |
for(j=0;j<gsq[x][y].ctlen[i];j++) { |
| 683 |
if(gsq[x][y].ents[i][j]!=0) m=gsq[x][y].ents[i][j]->flbmh; |
| 684 |
else m=0; |
| 685 |
|
| 686 |
if(onebit(m)) gsq[x][y].ctbm[i][j]=m; |
| 687 |
} |
| 688 |
} |
| 689 |
refreshsqmg(x,y); |
| 690 |
|
| 691 |
} |
| 692 |
f=0; |
| 693 |
for(i=0;i<NMSG;i++) if(treatorder[i]>0&&treat_lab[treatmode][i]) for(j=0;j<MXFL;j++) { |
| 694 |
e=treatmsge0[i][j]; |
| 695 |
if(e) { |
| 696 |
b=treatcstr[i][j]&e->flbmh; |
| 697 |
if(b!=treatcstr[i][j]) treatcstr[i][j]=b,f=1; |
| 698 |
} |
| 699 |
} |
| 700 |
if(f) {okbox("\n Answer treatment \n constraints updated \n");} |
| 701 |
gridchange(); |
| 702 |
} |
| 703 |
|
| 704 |
static void m_unban(GtkWidget*w,gpointer data) { |
| 705 |
int i; |
| 706 |
for(i=0;i<atotal;i++) ansp[i]->banned=0; |
| 707 |
gridchange(); |
| 708 |
} |
| 709 |
|
| 710 |
|
| 711 |
static void m_autofill(GtkWidget*w,gpointer data) { |
| 712 |
int mode; |
| 713 |
if(filler_status==0) return; |
| 714 |
mode=(intptr_t)data; |
| 715 |
if(mode==2&&selmode!=0) { |
| 716 |
sel_toc(); |
| 717 |
selchange(); |
| 718 |
} |
| 719 |
createfipdia(); |
| 720 |
if(compute(mode)) { reperr("Could not start filler"); return; } |
| 721 |
runfipdia(); |
| 722 |
DEB_GU printf("stopping filler...\n"); |
| 723 |
filler_stop(); |
| 724 |
DEB_GU printf("stopped filler, status=%d\n",filler_status); |
| 725 |
setposslabel(""); |
| 726 |
switch(filler_status) { |
| 727 |
case -4: |
| 728 |
case -3: reperr("Error generating lists of feasible lights");break; |
| 729 |
case -2: reperr("Out of stack space");break; |
| 730 |
case -1: reperr("Out of memory");break; |
| 731 |
case 1: reperr("No fill found");break; |
| 732 |
} |
| 733 |
} |
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
static void editblock (int x,int y,int adv) { symmdo(a_editblock ,0,x,y,0); if(adv&&curdir<100) stepforwmifingrid(&curx,&cury,curdir); gridchange();} |
| 738 |
static void editempty (int x,int y,int adv) {clrcont(x,y);symmdo(a_editempty ,0,x,y,0); if(adv&&curdir<100) stepforwmifingrid(&curx,&cury,curdir); gridchange();} |
| 739 |
static void editcutout(int x,int y,int adv) { symmdo(a_editcutout,0,x,y,0); if(adv&&curdir<100) stepforwmifingrid(&curx,&cury,curdir); gridchange();} |
| 740 |
|
| 741 |
|
| 742 |
static void m_editblock (GtkWidget*w,gpointer data) {editblock (curx,cury,1);} |
| 743 |
static void m_editempty (GtkWidget*w,gpointer data) {editempty (curx,cury,1);} |
| 744 |
static void m_editcutout(GtkWidget*w,gpointer data) {editcutout(curx,cury,1);} |
| 745 |
|
| 746 |
|
| 747 |
static void m_editbarb(GtkWidget*w,gpointer data) { |
| 748 |
if(curdir>=100) return; |
| 749 |
symmdo(a_editbar,!isbar(curx,cury,curdir+ndir[gtype]),curx,cury,curdir+ndir[gtype]); |
| 750 |
gridchange(); |
| 751 |
} |
| 752 |
|
| 753 |
|
| 754 |
static void m_editmerge(GtkWidget*w,gpointer data) { |
| 755 |
if(curdir>=100) return; |
| 756 |
symmdo(a_editmerge,!ismerge(curx,cury,curdir),curx,cury,curdir); |
| 757 |
gridchange(); |
| 758 |
} |
| 759 |
|
| 760 |
static void m_insrow(GtkWidget*w,gpointer data) {int i,j,y; |
| 761 |
y=cury+(intptr_t)data; |
| 762 |
if(height>=MXSZ) return; |
| 763 |
for(j=height;j>y;j--) for(i=0;i<width;i++) gsq[i][j]=gsq[i][j-1]; |
| 764 |
for(i=0;i<width;i++) initsquare(i,y); |
| 765 |
for(i=0;i<nvl;i++) for(j=0;j<vls[i].l;j++) if(vls[i].y[j]>=y) vls[i].y[j]++; |
| 766 |
height++; |
| 767 |
if((intptr_t)data==0) {cury++; curmoved();} |
| 768 |
gridchange(); |
| 769 |
syncgui(); |
| 770 |
} |
| 771 |
|
| 772 |
static void m_inscol(GtkWidget*w,gpointer data) {int i,j,x; |
| 773 |
x=curx+(intptr_t)data; |
| 774 |
if(width>=MXSZ) return; |
| 775 |
for(i=width;i>x;i--) for(j=0;j<height;j++) gsq[i][j]=gsq[i-1][j]; |
| 776 |
for(j=0;j<height;j++) initsquare(x,j); |
| 777 |
for(i=0;i<nvl;i++) for(j=0;j<vls[i].l;j++) if(vls[i].x[j]>=x) vls[i].x[j]++; |
| 778 |
width++; |
| 779 |
if((intptr_t)data==0) {curx++; curmoved();} |
| 780 |
gridchange(); |
| 781 |
syncgui(); |
| 782 |
} |
| 783 |
|
| 784 |
static void m_delrow(GtkWidget*w,gpointer data) {int bm,i,j,i0,j0; |
| 785 |
if(height<2) return; |
| 786 |
if(gtype==1) bm=4; |
| 787 |
else if(gtype==2) bm=6; |
| 788 |
else bm=2; |
| 789 |
if(cury<height-1) for(i=0;i<width;i++) gsq[i][cury+1].bars|=gsq[i][cury].bars&bm; |
| 790 |
for(j=cury;j<height-1;j++) for(i=0;i<width;i++) gsq[i][j]=gsq[i][j+1]; |
| 791 |
for(i=0,i0=0;i<nvl;i++) { |
| 792 |
for(j=0,j0=0;j<vls[i].l;j++) { |
| 793 |
if(vls[i].y[j]<cury) vls[i0].y[j0++]=vls[i].y[j]; |
| 794 |
else if(vls[i].y[j]>cury) vls[i0].y[j0++]=vls[i].y[j]-1; |
| 795 |
} |
| 796 |
vls[i0].l=j0; |
| 797 |
if(j0>0) i0++; |
| 798 |
} |
| 799 |
nvl=i0; |
| 800 |
height--; |
| 801 |
gridchange(); |
| 802 |
syncgui(); |
| 803 |
} |
| 804 |
|
| 805 |
static void m_delcol(GtkWidget*w,gpointer data) {int bm,i,j,i0,j0; |
| 806 |
if(width<2) return; |
| 807 |
if(gtype==1) bm=3; |
| 808 |
else bm=1; |
| 809 |
if(curx<width-1) for(j=0;j<height;j++) gsq[curx+1][j].bars|=gsq[curx][j].bars&bm; |
| 810 |
for(i=curx;i<width-1;i++) for(j=0;j<height;j++) gsq[i][j]=gsq[i+1][j]; |
| 811 |
for(i=0,i0=0;i<nvl;i++) { |
| 812 |
for(j=0,j0=0;j<vls[i].l;j++) { |
| 813 |
if(vls[i].x[j]<curx) vls[i0].x[j0++]=vls[i].x[j]; |
| 814 |
else if(vls[i].x[j]>curx) vls[i0].x[j0++]=vls[i].x[j]-1; |
| 815 |
} |
| 816 |
vls[i0].l=j0; |
| 817 |
if(j0>0) i0++; |
| 818 |
} |
| 819 |
nvl=i0; |
| 820 |
width--; |
| 821 |
gridchange(); |
| 822 |
syncgui(); |
| 823 |
} |
| 824 |
|
| 825 |
|
| 826 |
static void m_editflip(GtkWidget*w,gpointer data) {int i,j,k,t;struct square s;struct lprop l;ABM p[MXCT]; |
| 827 |
if(gshape[gtype]>2) return; |
| 828 |
for(i=0;i<MXSZ;i++) for(j=i+1;j<MXSZ;j++) {s=gsq[j][i];gsq[j][i]=gsq[i][j];gsq[i][j]=s;} |
| 829 |
for(i=0;i<MXSZ;i++) for(j=0;j<MXSZ;j++) { |
| 830 |
t=gsq[i][j].bars; |
| 831 |
if(gshape[gtype]==0) t=((t&1)<<1)|((t&2)>>1); |
| 832 |
else t=((t&1)<<2)|( t&2 )|((t&4)>>2); |
| 833 |
gsq[i][j].bars=t; |
| 834 |
t=gsq[i][j].merge; |
| 835 |
if(gshape[gtype]==0) t=((t&1)<<1)|((t&2)>>1); |
| 836 |
else t=((t&1)<<2)|( t&2 )|((t&4)>>2); |
| 837 |
gsq[i][j].merge=t; |
| 838 |
t=gsq[i][j].dsel; |
| 839 |
if(gshape[gtype]==0) t=((t&1)<<1)|((t&2)>>1); |
| 840 |
else t=((t&1)<<2)|( t&2 )|((t&4)>>2); |
| 841 |
gsq[i][j].dsel=t; |
| 842 |
k=(gshape[gtype]==0)?1:2; |
| 843 |
l=gsq[i][j].lp[0];gsq[i][j].lp[0]=gsq[i][j].lp[k];gsq[i][j].lp[k]=l; |
| 844 |
|
| 845 |
if(getdech(i,j)) { |
| 846 |
memcpy(p,gsq[i][j].ctbm[0],sizeof(p)); |
| 847 |
memcpy(gsq[i][j].ctbm[0],gsq[i][j].ctbm[k],sizeof(p)); |
| 848 |
memcpy(gsq[i][j].ctbm[k],p,sizeof(p)); |
| 849 |
t=gsq[i][j].ctlen[0]; gsq[i][j].ctlen[0]=gsq[i][j].ctlen[k]; gsq[i][j].ctlen[k]=t; |
| 850 |
} |
| 851 |
} |
| 852 |
for(i=0;i<nvl;i++) for(j=0;j<vls[i].l;j++) t=vls[i].x[j],vls[i].x[j]=vls[i].y[j],vls[i].y[j]=t; |
| 853 |
t=height;height=width;width=t; |
| 854 |
if(symmm==1||symmm==2) symmm=3-symmm; |
| 855 |
if(symmd==1||symmd==2) symmd=3-symmd; |
| 856 |
if (gtype== 1) gtype= 2; |
| 857 |
else if(gtype== 2) gtype= 1; |
| 858 |
else if(gtype== 5) gtype= 6; |
| 859 |
else if(gtype== 6) gtype= 5; |
| 860 |
else if(gtype== 7) gtype= 8; |
| 861 |
else if(gtype== 8) gtype= 7; |
| 862 |
else if(gtype==10) gtype=11; |
| 863 |
else if(gtype==11) gtype=10; |
| 864 |
gridchange(); |
| 865 |
syncgui(); |
| 866 |
} |
| 867 |
|
| 868 |
|
| 869 |
static void m_editrot(GtkWidget*w,gpointer data) {int i,j; struct square t,u; |
| 870 |
if(gshape[gtype]<3) return; |
| 871 |
if((intptr_t)data==0xf001) |
| 872 |
for(j=0;j<height;j++) {t=gsq[width-1][j];for(i= 0;i<width;i++) u=gsq[i][j],gsq[i][j]=t,t=u;} |
| 873 |
else |
| 874 |
for(j=0;j<height;j++) {t=gsq[ 0][j];for(i=width-1;i>=0 ;i--) u=gsq[i][j],gsq[i][j]=t,t=u;} |
| 875 |
gridchange(); |
| 876 |
syncgui(); |
| 877 |
} |
| 878 |
|
| 879 |
static void m_vlnew(GtkWidget*w,gpointer data) { |
| 880 |
if(nvl>=NVL) {reperr("Limit on number of\nfree lights reached");return;} |
| 881 |
m_selnone(w,data); |
| 882 |
selmode=2; |
| 883 |
vls[nvl].x[0]=curx; |
| 884 |
vls[nvl].y[0]=cury; |
| 885 |
vls[nvl].l=1; |
| 886 |
vls[nvl].sel=1; |
| 887 |
resetlp(&vls[nvl].lp); |
| 888 |
nvl++; |
| 889 |
gridchange(); |
| 890 |
} |
| 891 |
|
| 892 |
static int getselvl() {int i; |
| 893 |
if(selmode!=2) return -1; |
| 894 |
if(nsel!=1) return -1; |
| 895 |
for(i=0;i<nvl;i++) if(vls[i].sel) return i; |
| 896 |
return -1; |
| 897 |
} |
| 898 |
|
| 899 |
static void m_vlextend(GtkWidget*w,gpointer data) {int i; |
| 900 |
i=getselvl(); |
| 901 |
if(i==-1) return; |
| 902 |
if(vls[i].l>=MXCL) {reperr("Limit on length of\nfree light reached");return;} |
| 903 |
vls[i].x[vls[i].l]=curx; |
| 904 |
vls[i].y[vls[i].l]=cury; |
| 905 |
vls[i].l++; |
| 906 |
DEB_GU printf("VL %d l=%d\n",i,vls[i].l); |
| 907 |
gridchange(); |
| 908 |
} |
| 909 |
|
| 910 |
static void m_vldelete(GtkWidget*w,gpointer data) {int i,j,d; |
| 911 |
if(selmode!=2) return; |
| 912 |
d=-1; |
| 913 |
for(i=0,j=0;i<nvl;i++) |
| 914 |
if(!vls[i].sel) { |
| 915 |
if(i+100==curdir) d=j; |
| 916 |
memmove(vls+j,vls+i,sizeof(struct vl)),j++; |
| 917 |
} |
| 918 |
if(curdir>=100) { |
| 919 |
if(d>=0) curdir=d+100; |
| 920 |
else curdir=0; |
| 921 |
} |
| 922 |
nvl=j; |
| 923 |
gridchange(); |
| 924 |
} |
| 925 |
|
| 926 |
static void m_vlcurtail(GtkWidget*w,gpointer data) {int i; |
| 927 |
i=getselvl(); |
| 928 |
if(i==-1) return; |
| 929 |
if(vls[i].l<2) {m_vldelete(w,data);return;} |
| 930 |
vls[i].l--; |
| 931 |
DEB_GU printf("VL %d l=%d\n",i,vls[i].l); |
| 932 |
gridchange(); |
| 933 |
} |
| 934 |
|
| 935 |
static void m_vlmodify(GtkWidget*w,gpointer data) {int i; |
| 936 |
i=getselvl(); |
| 937 |
if(i==-1) return; |
| 938 |
mvldia(i); |
| 939 |
} |
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
static void m_helpabout(GtkWidget*w,gpointer data) {char s[4000]; |
| 945 |
sprintf(s, |
| 946 |
"Qxw release %s\n\n" |
| 947 |
"Copyright 2011-2020 Mark Owen; Windows port by Peter Flippant\n" |
| 948 |
"\n" |
| 949 |
"This program is free software; you can redistribute it and/or modify " |
| 950 |
"it under the terms of version 2 of the GNU General Public License as " |
| 951 |
"published by the Free Software Foundation.\n" |
| 952 |
"\n" |
| 953 |
"This program is distributed in the hope that it will be useful, " |
| 954 |
"but WITHOUT ANY WARRANTY; without even the implied warranty of " |
| 955 |
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " |
| 956 |
"GNU General Public License for more details.\n" |
| 957 |
"\n" |
| 958 |
"You should have received a copy of the GNU General Public License along " |
| 959 |
"with this program; if not, write to the Free Software Foundation, Inc., " |
| 960 |
"51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n" |
| 961 |
"\n" |
| 962 |
"Visit http://www.quinapalus.com/ for more information and to download " |
| 963 |
"the PDF manual.\n" |
| 964 |
"\n" |
| 965 |
"Please e-mail [email protected] with bug reports and suggestions." |
| 966 |
,RELEASE); |
| 967 |
okbox(s);} |
| 968 |
|
| 969 |
static int w_destroy(void) {gtk_main_quit();return 0;} |
| 970 |
static int w_delete(void) {return !(!unsaved||areyousure("quit"));} |
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
static void moveleft(int*x,int*y) { |
| 978 |
switch(gtype) { |
| 979 |
case 0:case 1:case 2:case 6:case 8:(*x)--;break; |
| 980 |
case 7:case 10:case 12: |
| 981 |
if(*x==0) *y=height-1-*y; |
| 982 |
case 3:case 4:case 5:case 9:case 11: |
| 983 |
*x=(*x+width-1)%width; |
| 984 |
break; |
| 985 |
} |
| 986 |
} |
| 987 |
|
| 988 |
static void moveright(int*x,int*y) { |
| 989 |
switch(gtype) { |
| 990 |
case 0:case 1:case 2:case 6:case 8:(*x)++;break; |
| 991 |
case 7:case 10:case 12: |
| 992 |
if(*x==width-1) *y=height-1-*y; |
| 993 |
case 3:case 4:case 5:case 9:case 11: |
| 994 |
*x=(*x+1)%width; |
| 995 |
break; |
| 996 |
} |
| 997 |
} |
| 998 |
|
| 999 |
static void moveup(int*x,int*y) { |
| 1000 |
switch(gtype) { |
| 1001 |
case 0:case 1:case 2:case 3:case 4:case 5:case 7:(*y)--;break; |
| 1002 |
case 8:case 11:case 12: |
| 1003 |
if(*y==0) *x=width-1-*x; |
| 1004 |
case 6:case 9:case 10: |
| 1005 |
*y=(*y+height-1)%height; |
| 1006 |
break; |
| 1007 |
} |
| 1008 |
} |
| 1009 |
|
| 1010 |
static void movedown(int*x,int*y) { |
| 1011 |
switch(gtype) { |
| 1012 |
case 0:case 1:case 2:case 3:case 4:case 5:case 7:(*y)++;break; |
| 1013 |
case 8:case 11:case 12: |
| 1014 |
if(*y==height-1) *x=width-1-*x; |
| 1015 |
case 6:case 9:case 10: |
| 1016 |
*y=(*y+1)%height; |
| 1017 |
break; |
| 1018 |
} |
| 1019 |
} |
| 1020 |
|
| 1021 |
static void movehome(int*x,int*y) {int l,lx[MXCL],ly[MXCL]; |
| 1022 |
l=getlight(lx,ly,*x,*y,curdir); |
| 1023 |
if(l<1) return; |
| 1024 |
*x=lx[0];*y=ly[0]; |
| 1025 |
} |
| 1026 |
|
| 1027 |
static void moveend(int*x,int*y) {int l,lx[MXCL],ly[MXCL]; |
| 1028 |
l=getlight(lx,ly,*x,*y,curdir); |
| 1029 |
if(l<1) return; |
| 1030 |
*x=lx[l-1];*y=ly[l-1]; |
| 1031 |
} |
| 1032 |
|
| 1033 |
static void nextdir() { |
| 1034 |
int m; |
| 1035 |
if(ismux(curx,cury,curdir)) { |
| 1036 |
m=getmaxmux(curx,cury,curdir); |
| 1037 |
if(m>1) { |
| 1038 |
curmux++; |
| 1039 |
if(curmux<m) return; |
| 1040 |
} |
| 1041 |
} |
| 1042 |
do{ |
| 1043 |
curdir++; |
| 1044 |
curmux=0; |
| 1045 |
if(curdir==ndir[gtype]) curdir=100; |
| 1046 |
if(curdir>=100+nvl) curdir=0; |
| 1047 |
if(curdir<ndir[gtype]) return; |
| 1048 |
} while(!issqinvl(curx,cury,curdir-100)); |
| 1049 |
} |
| 1050 |
|
| 1051 |
static void prevdir() { |
| 1052 |
int m; |
| 1053 |
if(ismux(curx,cury,curdir)) { |
| 1054 |
m=getmaxmux(curx,cury,curdir); |
| 1055 |
if(m>1) { |
| 1056 |
curmux--; |
| 1057 |
if(curmux>=m) {curmux=m-1; return;} |
| 1058 |
if(curmux>=0) return; |
| 1059 |
} |
| 1060 |
} |
| 1061 |
do{ |
| 1062 |
curdir--; |
| 1063 |
curmux=0; |
| 1064 |
if(curdir<0) curdir=100+nvl-1; |
| 1065 |
if(curdir==99) curdir=ndir[gtype]-1; |
| 1066 |
if(ismux(curx,cury,curdir)) { |
| 1067 |
m=getmaxmux(curx,cury,curdir); |
| 1068 |
if(m>1) curmux=m-1; |
| 1069 |
} |
| 1070 |
if(curdir<ndir[gtype]) return; |
| 1071 |
} while(!issqinvl(curx,cury,curdir-100)); |
| 1072 |
} |
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
static void entericc(int i) { |
| 1079 |
if(seteicc(curx,cury,curdir,i)) ccontdia(); |
| 1080 |
refreshsqmg(curx,cury); |
| 1081 |
refreshnum(); |
| 1082 |
if(curdir<100) stepforwmifingrid(&curx,&cury,curdir); |
| 1083 |
undo_push(); |
| 1084 |
} |
| 1085 |
|
| 1086 |
static int tryuchar(uchar uc) { |
| 1087 |
int i; |
| 1088 |
if(!ISUGRAPH(uc)) return 0; |
| 1089 |
if(isdisallowed(uc)) return 0; |
| 1090 |
for(i=1;i<MAXICC;i++) if(icctouchar[i]==uc) {entericc(i); return 1;} |
| 1091 |
return 0; |
| 1092 |
} |
| 1093 |
|
| 1094 |
static void curleft () {int x,y; if(curdir>=100) curdir=0; x=curx;y=cury;moveleft (&x,&y);if(isingrid(x,y)) curx=x,cury=y;} |
| 1095 |
static void curright() {int x,y; if(curdir>=100) curdir=0; x=curx;y=cury;moveright(&x,&y);if(isingrid(x,y)) curx=x,cury=y;} |
| 1096 |
static void curup () {int x,y; if(curdir>=100) curdir=0; x=curx;y=cury;moveup (&x,&y);if(isingrid(x,y)) curx=x,cury=y;} |
| 1097 |
static void curdown () {int x,y; if(curdir>=100) curdir=0; x=curx;y=cury;movedown (&x,&y);if(isingrid(x,y)) curx=x,cury=y;} |
| 1098 |
|
| 1099 |
|
| 1100 |
static int keypress(GtkWidget *widget, GdkEventKey *event) { |
| 1101 |
int k,x,y; |
| 1102 |
uchar uc; |
| 1103 |
k=event->keyval; |
| 1104 |
uc=gdk_keyval_to_unicode(k); |
| 1105 |
if(tryuchar(uc)) goto done; |
| 1106 |
if(tryuchar(TOUUPPER(uc))) goto done; |
| 1107 |
if(tryuchar(TOULOWER(uc))) goto done; |
| 1108 |
if((event->state&12)!=0) return 0; |
| 1109 |
|
| 1110 |
if(k==' ' ) {if(curdir<100) stepforwmifingrid(&curx,&cury,curdir);} |
| 1111 |
else if(k==GDK_Tab ) {clrcont(curx,cury); refreshsqmg(curx,cury);refreshnum(); stepforwmifingrid(&curx,&cury,curdir); undo_push();} |
| 1112 |
else if(k==GDK_ISO_Left_Tab ) {if(stepbackmifingrid(&curx,&cury,curdir)) {clrcont(curx,cury); refreshsqmg(curx,cury);refreshnum(); undo_push();}} |
| 1113 |
else if(k==GDK_Left ) curleft (); |
| 1114 |
else if(k==GDK_Right ) curright(); |
| 1115 |
else if(k==GDK_Up ) curup (); |
| 1116 |
else if(k==GDK_Down ) curdown (); |
| 1117 |
|
| 1118 |
else if(k==GDK_Home ) {x=curx;y=cury;movehome (&x,&y);if(isingrid(x,y)) curx=x,cury=y;} |
| 1119 |
else if(k==GDK_End ) {x=curx;y=cury;moveend (&x,&y);if(isingrid(x,y)) curx=x,cury=y;} |
| 1120 |
|
| 1121 |
else if((k==GDK_Page_Up )) {prevdir();} |
| 1122 |
else if((k==GDK_Page_Down||k=='/')) {nextdir();} |
| 1123 |
|
| 1124 |
else if(k=='.' ) {editempty (curx,cury,1);} |
| 1125 |
else if(k==',' ) {editblock (curx,cury,1);} |
| 1126 |
|
| 1127 |
else if(k==GDK_BackSpace ) {if(curdir<100) stepbackifingrid(&curx,&cury,curdir);} |
| 1128 |
else return 0; |
| 1129 |
done: |
| 1130 |
curmoved(); |
| 1131 |
compute(0); |
| 1132 |
return 1; |
| 1133 |
} |
| 1134 |
|
| 1135 |
|
| 1136 |
static void ptrtosq(int*x,int*y,int*k,int x0,int y0) {double u,v,u0,v0,r=0,t=0,xa=0,ya=0,xb=0,yb=0;int i,j; |
| 1137 |
u0=((double)x0-bawdpx)/pxsq;v0=((double)y0-bawdpx)/pxsq; |
| 1138 |
*k=0; |
| 1139 |
switch(gshape[gtype]) { |
| 1140 |
case 0: |
| 1141 |
i=(int)floor(u0);u=u0-i; |
| 1142 |
j=(int)floor(v0);v=v0-j; |
| 1143 |
*x=i;*y=j; |
| 1144 |
break; |
| 1145 |
case 1: |
| 1146 |
i=(int)floor(u0/1.2);u=u0-i*1.2; |
| 1147 |
if((i&1)==0) { |
| 1148 |
j=(int)floor(v0/1.4);v=v0-j*1.4; |
| 1149 |
if(u>=0.4) {*x=i;*y=j;break;} |
| 1150 |
if( 0.7*u+0.4*v<0.28) {*x=i-1;*y=j-1;break;} |
| 1151 |
if(-0.7*u+0.4*v>0.28) {*x=i-1;*y=j; break;} |
| 1152 |
*x=i;*y=j;break; |
| 1153 |
} else { |
| 1154 |
j=(int)floor((v0-0.7)/1.4);v=v0-0.7-j*1.4; |
| 1155 |
if(u>=0.4) {*x=i;*y=j;break;} |
| 1156 |
if( 0.7*u+0.4*v<0.28) {*x=i-1;*y=j; break;} |
| 1157 |
if(-0.7*u+0.4*v>0.28) {*x=i-1;*y=j+1;break;} |
| 1158 |
*x=i;*y=j;break; |
| 1159 |
} |
| 1160 |
case 2: |
| 1161 |
j=(int)floor(v0/1.2);v=v0-j*1.2; |
| 1162 |
if((j&1)==0) { |
| 1163 |
i=(int)floor(u0/1.4);u=u0-i*1.4; |
| 1164 |
if(v>=0.4) {*y=j;*x=i;break;} |
| 1165 |
if( 0.7*v+0.4*u<0.28) {*y=j-1;*x=i-1;break;} |
| 1166 |
if(-0.7*v+0.4*u>0.28) {*y=j-1;*x=i; break;} |
| 1167 |
*y=j;*x=i;break; |
| 1168 |
} else { |
| 1169 |
i=(int)floor((u0-0.7)/1.4);u=u0-0.7-i*1.4; |
| 1170 |
if(v>=0.4) {*y=j;*x=i;break;} |
| 1171 |
if( 0.7*v+0.4*u<0.28) {*y=j-1;*x=i; break;} |
| 1172 |
if(-0.7*v+0.4*u>0.28) {*y=j-1;*x=i+1;break;} |
| 1173 |
*y=j;*x=i;break; |
| 1174 |
} |
| 1175 |
case 3:case 4: |
| 1176 |
u=u0-height;v=v0-height; |
| 1177 |
r=sqrt(u*u+v*v); |
| 1178 |
if(r<1e-3) {*x=-1;*y=-1;return;} |
| 1179 |
r=height-r; |
| 1180 |
t=atan2(u,-v)*width/2/PI; |
| 1181 |
if(gtype==4) t+=.5; |
| 1182 |
if(t<0) t+=width; |
| 1183 |
*x=(int)floor(t); |
| 1184 |
*y=(int)floor(r); |
| 1185 |
break; |
| 1186 |
} |
| 1187 |
switch(gshape[gtype]) { |
| 1188 |
case 0:case 1:case 2: |
| 1189 |
for(i=0;i<ndir[gtype]*2;i++) { |
| 1190 |
edgecoords(&xa,&ya,&xb,&yb,*x,*y,i); |
| 1191 |
xb-=xa;yb-=ya; |
| 1192 |
r=sqrt(xb*xb+yb*yb);xb/=r;yb/=r; |
| 1193 |
xa=u0-xa;ya=v0-ya; |
| 1194 |
if(fabs(xb*ya-xa*yb)<PXEDGE) *k|=1<<i; |
| 1195 |
} |
| 1196 |
break; |
| 1197 |
case 3:case 4: |
| 1198 |
if(r-*y>1-PXEDGE ) *k|=2; |
| 1199 |
if(r-*y< PXEDGE ) *k|=8; |
| 1200 |
r=height-r; |
| 1201 |
if(t-*x>1-PXEDGE/((r<2)?1:(r-1))) *k|=1; |
| 1202 |
if(t-*x< PXEDGE/((r<2)?1:(r-1))) *k|=4; |
| 1203 |
break; |
| 1204 |
} |
| 1205 |
} |
| 1206 |
|
| 1207 |
int dragflag=-1; |
| 1208 |
|
| 1209 |
static void mousel(int x,int y) { |
| 1210 |
if(selmode!=0) m_selnone(0,0); |
| 1211 |
selmode=0; |
| 1212 |
if(dragflag==-1) dragflag=gsq[x][y].fl&16; |
| 1213 |
if((gsq[x][y].fl&16)==dragflag) { |
| 1214 |
selcell(x,y,!dragflag); |
| 1215 |
selchange(); |
| 1216 |
} |
| 1217 |
} |
| 1218 |
|
| 1219 |
static void mouser(int x,int y) { |
| 1220 |
if(curdir>=100) return; |
| 1221 |
if(selmode!=1) m_selnone(0,0); |
| 1222 |
selmode=1; |
| 1223 |
if(dragflag==-1) dragflag=issellight(x,y,curdir); |
| 1224 |
if(issellight(x,y,curdir)==dragflag) { |
| 1225 |
sellight(x,y,curdir,!dragflag); |
| 1226 |
selchange(); |
| 1227 |
} |
| 1228 |
} |
| 1229 |
|
| 1230 |
|
| 1231 |
static gint mousemove(GtkWidget*widget,GdkEventMotion*event) { |
| 1232 |
int e,k,x,y; |
| 1233 |
ptrtosq(&x,&y,&e,(int)floor(event->x+.5),(int)floor(event->y)); |
| 1234 |
k=(int)(event->state); |
| 1235 |
|
| 1236 |
if(!isingrid(x,y)) return 0; |
| 1237 |
if((k&GDK_SHIFT_MASK)==0) {dragflag=-1;return 0;} |
| 1238 |
if (k&GDK_BUTTON3_MASK) mouser(x,y); |
| 1239 |
else if(k&GDK_BUTTON1_MASK) mousel(x,y); |
| 1240 |
else dragflag=-1; |
| 1241 |
return 0; |
| 1242 |
} |
| 1243 |
|
| 1244 |
|
| 1245 |
static gint button_press_event(GtkWidget*widget,GdkEventButton*event) { |
| 1246 |
int b,e,ee,k,x,y; |
| 1247 |
ptrtosq(&x,&y,&e,(int)floor(event->x+.5),(int)floor(event->y)); |
| 1248 |
k=event->state; |
| 1249 |
DEB_RF printf("button press event (%f,%f) -> (%d,%d) e=%02x button=%08x type=%08x state=%08x\n",event->x,event->y,x,y,e,(int)event->button,(int)event->type,k); |
| 1250 |
if(event->type==GDK_BUTTON_RELEASE) dragflag=-1; |
| 1251 |
if(event->type!=GDK_BUTTON_PRESS) goto ew0; |
| 1252 |
if(k&GDK_SHIFT_MASK) { |
| 1253 |
if (event->button==3) mouser(x,y); |
| 1254 |
else if(event->button==1) mousel(x,y); |
| 1255 |
return 0; |
| 1256 |
} |
| 1257 |
if(event->button!=1) goto ew0; |
| 1258 |
if(!isingrid(x,y)) goto ew0; |
| 1259 |
ee=!!(e&(e-1)); |
| 1260 |
|
| 1261 |
if(clickblock&&ee) { |
| 1262 |
if((gsq[x][y].fl&1)==0) {editblock(x,y,0);goto ew1;} |
| 1263 |
else {editempty(x,y,0);goto ew1;} |
| 1264 |
} |
| 1265 |
else if(clickbar&&e&&!ee) { |
| 1266 |
b=logbase2(e); |
| 1267 |
DEB_RF printf(" x=%d y=%d e=%d b=%d isbar(x,y,b)=%d\n",x,y,e,b,isbar(x,y,b)); |
| 1268 |
symmdo(a_editbar,!isbar(x,y,b),x,y,b); |
| 1269 |
gridchange(); |
| 1270 |
goto ew1; |
| 1271 |
} |
| 1272 |
|
| 1273 |
if(x==curx&&y==cury) nextdir(); |
| 1274 |
else { |
| 1275 |
curx=x; cury=y; |
| 1276 |
if(curdir>=100) curdir=0; |
| 1277 |
} |
| 1278 |
curmoved(); |
| 1279 |
gridchangen(); |
| 1280 |
|
| 1281 |
ew1: |
| 1282 |
gtk_window_set_focus(GTK_WINDOW(mainw),grid_da); |
| 1283 |
ew0: |
| 1284 |
DEB_RF printf("Exiting button_press_event()\n"); |
| 1285 |
return FALSE; |
| 1286 |
} |
| 1287 |
|
| 1288 |
|
| 1289 |
static gint mousescroll(GtkWidget*widget,GdkEventScroll*event) { |
| 1290 |
int d,k; |
| 1291 |
k=(int)(event->state); |
| 1292 |
d=event->direction; |
| 1293 |
if(k&GDK_CONTROL_MASK) { |
| 1294 |
if(d==GDK_SCROLL_UP ) m_zoom(0,(void*)-1); |
| 1295 |
if(d==GDK_SCROLL_DOWN ) m_zoom(0,(void*)-2); |
| 1296 |
} |
| 1297 |
return 0; |
| 1298 |
} |
| 1299 |
|
| 1300 |
|
| 1301 |
static int selrow(GtkWidget*widget,gint row,gint column, GdkEventButton*event,gpointer data) { |
| 1302 |
int i,l,l0,lx[MXCL],ly[MXCL],nc; |
| 1303 |
ABM*abmp[MXLE]; |
| 1304 |
DEB_RF printf("row select event\n"); |
| 1305 |
if(llistem&EM_JUM) return 1; |
| 1306 |
l=getlight(lx,ly,curx,cury,curdir); |
| 1307 |
if(l<2) return 1; |
| 1308 |
nc=getlightbmp(abmp,curx,cury,curdir,curmux); |
| 1309 |
if(nc<2) return 1; |
| 1310 |
if(!llistp) return 1; |
| 1311 |
if(row<0||row>=llistn) return 1; |
| 1312 |
if(llistp[row]>=ltotal) return 1; |
| 1313 |
l0=strlen(lts[llistp[row]].s); |
| 1314 |
if(lts[llistp[row]].tagged) l0-=NMSG; |
| 1315 |
if(l0!=nc) return 1; |
| 1316 |
for(i=0;i<nc;i++) *abmp[i]=ICCTOABM((int)(lts[llistp[row]].s[i])); |
| 1317 |
for(i=0;i<l;i++) refreshsqmg(lx[i],ly[i]); |
| 1318 |
gridchange(); |
| 1319 |
gtk_window_set_focus(GTK_WINDOW(mainw),grid_da); |
| 1320 |
return 1; |
| 1321 |
} |
| 1322 |
|
| 1323 |
static char lookupuri[NLOOKUP][SLEN+1]; |
| 1324 |
|
| 1325 |
static int banword(GtkWidget*menuitem,gpointer data) { |
| 1326 |
int u; |
| 1327 |
u=(int)(intptr_t)data; |
| 1328 |
|
| 1329 |
if(u>=0&&u<atotal) ansp[u]->banned=1; |
| 1330 |
gridchange(); |
| 1331 |
gtk_window_set_focus(GTK_WINDOW(mainw),grid_da); |
| 1332 |
return 1; |
| 1333 |
} |
| 1334 |
|
| 1335 |
static int copyword(GtkWidget*menuitem,gpointer data) { |
| 1336 |
int u; |
| 1337 |
u=(int)(intptr_t)data; |
| 1338 |
if(u>=0&&u<atotal) gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),ansp[u]->cf,-1); |
| 1339 |
gtk_window_set_focus(GTK_WINDOW(mainw),grid_da); |
| 1340 |
return 1; |
| 1341 |
} |
| 1342 |
|
| 1343 |
static int lookupword(GtkWidget*menuitem,gpointer data) { |
| 1344 |
char*p=(char*)data; |
| 1345 |
DEB_GU printf("Lookup %s\n",p); |
| 1346 |
if(!STRSTARTS(p,"http://")&&!STRSTARTS(p,"https://")) { |
| 1347 |
reperr("Only http:// and https:// URIs can be opened.\nPlease check your Preferences settings."); |
| 1348 |
return 1; |
| 1349 |
} |
| 1350 |
#ifdef _WIN32 |
| 1351 |
{ |
| 1352 |
wchar_t sw[SLEN]; |
| 1353 |
MultiByteToWideChar(CP_UTF8, 0, p, -1, sw, SLEN); |
| 1354 |
ShellExecuteW(0,L"open",sw,0,0,SW_SHOWNORMAL); |
| 1355 |
} |
| 1356 |
#else |
| 1357 |
gtk_show_uri(NULL,p,GDK_CURRENT_TIME,NULL); |
| 1358 |
#endif |
| 1359 |
gtk_window_set_focus(GTK_WINDOW(mainw),grid_da); |
| 1360 |
gdk_window_set_cursor(mainw->window,NULL); |
| 1361 |
return 1; |
| 1362 |
} |
| 1363 |
|
| 1364 |
static int clist_button(GtkWidget*widget,GdkEventButton*event,gpointer data) { |
| 1365 |
int row,col,i,j,k; |
| 1366 |
char s[SLEN*3],*p,*t; |
| 1367 |
GtkWidget*menu,*mi,*mi0[NLOOKUP]; |
| 1368 |
|
| 1369 |
if(event->button!=3) return 0; |
| 1370 |
if(gtk_clist_get_selection_info(GTK_CLIST(clist),(int)floor(event->x+.5),(int)floor(event->y),&row,&col)==0) return 1; |
| 1371 |
|
| 1372 |
if(!llistp) return 1; |
| 1373 |
if(row<0||row>=llistn) return 1; |
| 1374 |
if(llistp[row]>=ltotal) return 1; |
| 1375 |
|
| 1376 |
|
| 1377 |
menu=gtk_menu_new(); |
| 1378 |
sprintf(s,"Ban \"%s\"",ansp[lts[llistp[row]].ans]->cf); |
| 1379 |
mi=gtk_menu_item_new_with_label(s); |
| 1380 |
g_signal_connect(mi,"activate",GTK_SIGNAL_FUNC(banword),(gpointer)(intptr_t)lts[llistp[row]].ans); |
| 1381 |
gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi); |
| 1382 |
mi=gtk_menu_item_new_with_label("Copy"); |
| 1383 |
g_signal_connect(mi,"activate",GTK_SIGNAL_FUNC(copyword),(gpointer)(intptr_t)lts[llistp[row]].ans); |
| 1384 |
gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi); |
| 1385 |
t=ansp[lts[llistp[row]].ans]->cf; |
| 1386 |
if(t&&strlen(t)<SLEN) { |
| 1387 |
for(i=0;i<NLOOKUP;i++) { |
| 1388 |
mi0[i]=gtk_menu_item_new_with_label(lookupname(i)); |
| 1389 |
for(j=0,k=0;lookup(i)[j];) { |
| 1390 |
if(lookup(i)[j]=='%') { |
| 1391 |
j++; |
| 1392 |
if(lookup(i)[j]=='s') { |
| 1393 |
j++; |
| 1394 |
if(k+strlen(t)*3>SLEN*3-10) goto skip; |
| 1395 |
for(p=t;*p;p++) |
| 1396 |
if(isalnum((unsigned char)*p)) lookupuri[i][k++]=*p; |
| 1397 |
else sprintf(lookupuri[i]+k,"%%%02X",(unsigned char)*p),k+=3; |
| 1398 |
continue; |
| 1399 |
} |
| 1400 |
} |
| 1401 |
lookupuri[i][k++]=lookup(i)[j++]; |
| 1402 |
if(k>=SLEN*3-1) break; |
| 1403 |
} |
| 1404 |
lookupuri[i][k]=0; |
| 1405 |
DEB_GU printf("lookupuri[%d]=%s\n",i,lookupuri[i]); |
| 1406 |
g_signal_connect(mi0[i],"activate",GTK_SIGNAL_FUNC(lookupword),lookupuri[i]); |
| 1407 |
gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi0[i]); |
| 1408 |
skip: ; |
| 1409 |
} |
| 1410 |
} |
| 1411 |
gtk_widget_show_all(menu); |
| 1412 |
gtk_menu_popup(GTK_MENU(menu),NULL,NULL,NULL,NULL,event->button,gdk_event_get_time((GdkEvent*)event)); |
| 1413 |
return 1; |
| 1414 |
} |
| 1415 |
|
| 1416 |
|
| 1417 |
static gint configure_event(GtkWidget*widget,GdkEventConfigure*event) { |
| 1418 |
DEB_RF printf("config event: new w=%d h=%d\n",widget->allocation.width,widget->allocation.height); |
| 1419 |
return 1; |
| 1420 |
} |
| 1421 |
|
| 1422 |
|
| 1423 |
static gint expose_event(GtkWidget*widget,GdkEventExpose*event) {double u,v; |
| 1424 |
cairo_t*cr; |
| 1425 |
DEB_RF printf("expose event x=%d y=%d w=%d h=%d\n",event->area.x,event->area.y,event->area.width,event->area.height),fflush(stdout); |
| 1426 |
if(widget==grid_da) { |
| 1427 |
cr=gdk_cairo_create(widget->window); |
| 1428 |
cairo_rectangle(cr,event->area.x,event->area.y,event->area.width,event->area.height); |
| 1429 |
cairo_clip(cr); |
| 1430 |
repaint(cr); |
| 1431 |
cairo_destroy(cr); |
| 1432 |
if(curmf) { |
| 1433 |
mgcentre(&u,&v,curx,cury,0,1); |
| 1434 |
DEB_RF printf("curmoved: %f %f %d %d\n",u,v,pxsq,bawdpx); |
| 1435 |
gtk_adjustment_clamp_page(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(grid_sw)),(u-.5)*pxsq+bawdpx-3,(u+.5)*pxsq+bawdpx+3); |
| 1436 |
gtk_adjustment_clamp_page(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(grid_sw)),(v-.5)*pxsq+bawdpx-3,(v+.5)*pxsq+bawdpx+3); |
| 1437 |
curmf=0; |
| 1438 |
} |
| 1439 |
} |
| 1440 |
return FALSE; |
| 1441 |
} |
| 1442 |
|
| 1443 |
void invaldarect(int x0,int y0,int x1,int y1) {GdkRectangle r; |
| 1444 |
if(!usegui) return; |
| 1445 |
r.x=x0; r.y=y0; r.width=x1-x0; r.height=y1-y0; |
| 1446 |
DEB_RF printf("invalidate(%d,%d - %d,%d)\n",x0,y0,x1,y1); |
| 1447 |
gdk_window_invalidate_rect(grid_da->window,&r,0); |
| 1448 |
} |
| 1449 |
|
| 1450 |
void invaldaall() { |
| 1451 |
DEB_RF printf("invalidate all\n"); |
| 1452 |
if(!usegui) return; |
| 1453 |
gdk_window_invalidate_rect(grid_da->window,0,0); |
| 1454 |
} |
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
static int filedia(char*res,char*but,char*ext,char*filetype,int write) { |
| 1465 |
GtkWidget*dia; |
| 1466 |
int i; |
| 1467 |
char*p,t[SLEN+50]; |
| 1468 |
GtkFileFilter*filt0,*filt1; |
| 1469 |
|
| 1470 |
if(!res) res=filename; |
| 1471 |
filt0=gtk_file_filter_new(); |
| 1472 |
if(!filt0) return 0; |
| 1473 |
gtk_file_filter_add_pattern(filt0,"*"); |
| 1474 |
gtk_file_filter_set_name(filt0,"All files"); |
| 1475 |
filt1=gtk_file_filter_new(); |
| 1476 |
if(!filt1) return 0; |
| 1477 |
strcpy(t,"*"); |
| 1478 |
strcat(t,strrchr(ext,'.')); |
| 1479 |
|
| 1480 |
gtk_file_filter_add_pattern(filt1,t); |
| 1481 |
for(i=1;t[i];i++) t[i]=toupper(t[i]); |
| 1482 |
|
| 1483 |
gtk_file_filter_add_pattern(filt1,t); |
| 1484 |
strcpy(t,filetype); |
| 1485 |
strcat(t," files"); |
| 1486 |
gtk_file_filter_set_name(filt1,t); |
| 1487 |
|
| 1488 |
dia=gtk_file_chooser_dialog_new(but,0, |
| 1489 |
write?GTK_FILE_CHOOSER_ACTION_SAVE:GTK_FILE_CHOOSER_ACTION_OPEN, |
| 1490 |
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
| 1491 |
GTK_STOCK_OK, GTK_RESPONSE_OK, |
| 1492 |
NULL); |
| 1493 |
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dia),filt1); |
| 1494 |
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dia),filt0); |
| 1495 |
if(strcmp(filenamebase,"")) strcpy(res,filenamebase); |
| 1496 |
else strcpy(res,"untitled"); |
| 1497 |
strcat(res,ext); |
| 1498 |
strcpy(t,res); |
| 1499 |
if(write) gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dia),t); |
| 1500 |
ew0: |
| 1501 |
i=gtk_dialog_run(GTK_DIALOG(dia)); |
| 1502 |
i=i==GTK_RESPONSE_OK; |
| 1503 |
if(i) { |
| 1504 |
p=gtk_file_chooser_get_filename((GtkFileChooser*)dia); |
| 1505 |
if(strlen(p)>SLEN) {reperr("Filename too long");goto ew0;} |
| 1506 |
strcpy(res,p); |
| 1507 |
} |
| 1508 |
else strcpy(res,""); |
| 1509 |
gtk_widget_destroy(dia); |
| 1510 |
return i; |
| 1511 |
} |
| 1512 |
|
| 1513 |
|
| 1514 |
static int ccontdia() { |
| 1515 |
GtkWidget*dia,*vb,*l0,*m[MAXNDIR],*lm[MAXNDIR],*e[MAXNDIR]; |
| 1516 |
int i,u,x,y; |
| 1517 |
char s[100],t[MXCT*(MAXICC*16+4)]; |
| 1518 |
|
| 1519 |
x=curx; y=cury; |
| 1520 |
getmergerep(&x,&y,x,y); |
| 1521 |
if(!isclear(x,y)) {reperr("Please place the cursor on a cell\nthat can contain characters");return 1;} |
| 1522 |
|
| 1523 |
dia=gtk_dialog_new_with_buttons("Cell contents", |
| 1524 |
GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT, |
| 1525 |
GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OK,GTK_RESPONSE_OK,NULL); |
| 1526 |
gtk_dialog_set_default_response(GTK_DIALOG(dia),GTK_RESPONSE_OK); |
| 1527 |
vb=gtk_vbox_new(0,2); |
| 1528 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox),vb,TRUE,TRUE,0); |
| 1529 |
|
| 1530 |
u=getdech(x,y); |
| 1531 |
if(u) { |
| 1532 |
l0=gtk_label_new("Contribution from cell"); |
| 1533 |
gtk_misc_set_alignment(GTK_MISC(l0),0,0.5); |
| 1534 |
gtk_box_pack_start(GTK_BOX(vb),l0,TRUE,TRUE,0); |
| 1535 |
} |
| 1536 |
for(i=0;i<ndir[gtype];i++) { |
| 1537 |
m[i]=gtk_hbox_new(0,2); |
| 1538 |
if(u) sprintf(s,"to %s lights: ",dname[gtype][i]); |
| 1539 |
else sprintf(s,"Contents of cell: "); |
| 1540 |
lm[i]=gtk_label_new(s); |
| 1541 |
gtk_label_set_width_chars(GTK_LABEL(lm[i]),20); |
| 1542 |
gtk_misc_set_alignment(GTK_MISC(lm[i]),1,0.5); |
| 1543 |
gtk_box_pack_start(GTK_BOX(m[i]),lm[i],FALSE,FALSE,0); |
| 1544 |
e[i]=gtk_entry_new(); |
| 1545 |
gtk_entry_set_width_chars(GTK_ENTRY(e[i]),30); |
| 1546 |
gtk_entry_set_max_length(GTK_ENTRY(e[i]),sizeof(t)); |
| 1547 |
abmstostr(t,gsq[x][y].ctbm[i],gsq[x][y].ctlen[i],0); |
| 1548 |
gtk_entry_set_text(GTK_ENTRY(e[i]),t); |
| 1549 |
gtk_box_pack_start(GTK_BOX(m[i]),e[i],FALSE,FALSE,0); |
| 1550 |
gtk_box_pack_start(GTK_BOX(vb),m[i],TRUE,TRUE,0); |
| 1551 |
if(i==curdir) gtk_window_set_focus(GTK_WINDOW(dia),e[i]); |
| 1552 |
gtk_entry_set_activates_default(GTK_ENTRY(e[i]),1); |
| 1553 |
if(!u) break; |
| 1554 |
} |
| 1555 |
l0=gtk_label_new("(use '.' for any characters yet to be filled or enter a pattern)"); |
| 1556 |
gtk_box_pack_start(GTK_BOX(vb),l0,TRUE,TRUE,0); |
| 1557 |
|
| 1558 |
gtk_widget_show_all(dia); |
| 1559 |
i=gtk_dialog_run(GTK_DIALOG(dia)); |
| 1560 |
if(i==GTK_RESPONSE_OK) { |
| 1561 |
for(i=0;i<ndir[gtype];i++) { |
| 1562 |
gsq[x][y].ctlen[i]=strtoabms(gsq[x][y].ctbm[i],MXCT,(char*)gtk_entry_get_text(GTK_ENTRY(e[i])),0); |
| 1563 |
if(!u) break; |
| 1564 |
} |
| 1565 |
gridchange(); |
| 1566 |
} |
| 1567 |
gtk_widget_destroy(dia); |
| 1568 |
refreshsqmg(x,y); |
| 1569 |
return 1; |
| 1570 |
} |
| 1571 |
|
| 1572 |
|
| 1573 |
static int editlightdia() { |
| 1574 |
ABM*abmp[MXLE]; |
| 1575 |
GtkWidget*dia,*vb,*l0,*m,*lm,*e; |
| 1576 |
int i,u; |
| 1577 |
char*p,t[MXLE*(MAXICC*16+4)]; |
| 1578 |
ABM b[MXLE]; |
| 1579 |
|
| 1580 |
nc=getlightbmp(abmp,curx,cury,curdir,curmux); |
| 1581 |
if(nc<2) { reperr("Please point the cursor along a light"); return 1; } |
| 1582 |
if(nc>MXLE) { reperr("Light is too long"); return 1; } |
| 1583 |
t[0]=0; |
| 1584 |
for(i=0,p=t;i<nc;i++) { |
| 1585 |
abmtostr(p,*(abmp[i]),0); |
| 1586 |
p+=strlen(p); |
| 1587 |
} |
| 1588 |
dia=gtk_dialog_new_with_buttons("Light contents", |
| 1589 |
GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT, |
| 1590 |
GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OK,GTK_RESPONSE_OK,NULL); |
| 1591 |
gtk_dialog_set_default_response(GTK_DIALOG(dia),GTK_RESPONSE_OK); |
| 1592 |
vb=gtk_vbox_new(0,2); |
| 1593 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox),vb,TRUE,TRUE,0); |
| 1594 |
|
| 1595 |
m=gtk_hbox_new(0,2); |
| 1596 |
lm=gtk_label_new("Contents of light: "); |
| 1597 |
gtk_box_pack_start(GTK_BOX(m),lm,FALSE,FALSE,5); |
| 1598 |
e=gtk_entry_new(); |
| 1599 |
gtk_entry_set_width_chars(GTK_ENTRY(e),60); |
| 1600 |
gtk_entry_set_max_length(GTK_ENTRY(e),sizeof(t)); |
| 1601 |
gtk_entry_set_text(GTK_ENTRY(e),t); |
| 1602 |
gtk_box_pack_start(GTK_BOX(m),e,FALSE,FALSE,0); |
| 1603 |
gtk_box_pack_start(GTK_BOX(vb),m,TRUE,TRUE,0); |
| 1604 |
gtk_window_set_focus(GTK_WINDOW(dia),e); |
| 1605 |
gtk_entry_set_activates_default(GTK_ENTRY(e),1); |
| 1606 |
|
| 1607 |
l0=gtk_label_new("(use '.' or enter a pattern for any characters yet to be filled)"); |
| 1608 |
gtk_box_pack_start(GTK_BOX(vb),l0,TRUE,TRUE,0); |
| 1609 |
|
| 1610 |
gtk_widget_show_all(dia); |
| 1611 |
i=gtk_dialog_run(GTK_DIALOG(dia)); |
| 1612 |
if(i==GTK_RESPONSE_OK) { |
| 1613 |
u=strtoabms(b,nc,(char*)gtk_entry_get_text(GTK_ENTRY(e)),0); |
| 1614 |
for(i=u;i<nc;i++) b[i]=ABM_NRM; |
| 1615 |
for(i=0;i<nc;i++) { |
| 1616 |
*(abmp[i])=b[i]; |
| 1617 |
} |
| 1618 |
gridchange(); |
| 1619 |
} |
| 1620 |
gtk_widget_destroy(dia); |
| 1621 |
refreshall(); |
| 1622 |
return 1; |
| 1623 |
} |
| 1624 |
|
| 1625 |
|
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
|
| 1650 |
|
| 1651 |
|
| 1652 |
|
| 1653 |
|
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
|
| 1670 |
|
| 1671 |
|
| 1672 |
|
| 1673 |
|
| 1674 |
|
| 1675 |
|
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
|
| 1682 |
|
| 1683 |
|
| 1684 |
|
| 1685 |
|
| 1686 |
|
| 1687 |
|
| 1688 |
|
| 1689 |
|
| 1690 |
|
| 1691 |
|
| 1692 |
|
| 1693 |
|
| 1694 |
|
| 1695 |
|
| 1696 |
|
| 1697 |
|
| 1698 |
|
| 1699 |
|
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
|
| 1707 |
|
| 1708 |
|
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
|
| 1718 |
|
| 1719 |
|
| 1720 |
|
| 1721 |
|
| 1722 |
|
| 1723 |
|
| 1724 |
|
| 1725 |
|
| 1726 |
|
| 1727 |
|
| 1728 |
|
| 1729 |
|
| 1730 |
static GtkWidget*sprop_cbg,*sprop_cfg,*sprop_cmk,*sprop_l0,*sprop_l1,*sprop_l2,*sprop_l3,*sprop_l4,*sprop_tr,*sprop_w20,*sprop_w21,*sprop_or; |
| 1731 |
static GtkWidget*sprop_mkl[MAXNDIR*2],*sprop_mke[MAXNDIR*2]; |
| 1732 |
static int sprop_g; |
| 1733 |
|
| 1734 |
int sprop_setactive() {int i,k; |
| 1735 |
k=sprop_g||gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sprop_or)); |
| 1736 |
gtk_widget_set_sensitive(sprop_cbg,k); |
| 1737 |
gtk_widget_set_sensitive(sprop_cfg,k); |
| 1738 |
gtk_widget_set_sensitive(sprop_cmk,k); |
| 1739 |
gtk_widget_set_sensitive(sprop_l0,k); |
| 1740 |
gtk_widget_set_sensitive(sprop_l1,k); |
| 1741 |
gtk_widget_set_sensitive(sprop_l2,k); |
| 1742 |
gtk_widget_set_sensitive(sprop_l3,k); |
| 1743 |
gtk_widget_set_sensitive(sprop_l4,k); |
| 1744 |
gtk_widget_set_sensitive(sprop_w20,k); |
| 1745 |
gtk_widget_set_sensitive(sprop_tr,k); |
| 1746 |
gtk_widget_set_sensitive(sprop_w21,k); |
| 1747 |
for(i=0;i<ndir[gtype]*2;i++) { |
| 1748 |
gtk_widget_set_sensitive(sprop_mkl[i],k); |
| 1749 |
gtk_widget_set_sensitive(sprop_mke[i],k); |
| 1750 |
} |
| 1751 |
return 1; |
| 1752 |
} |
| 1753 |
|
| 1754 |
static int spropdia(int g) { |
| 1755 |
GtkWidget*dia,*w,*vb; |
| 1756 |
GdkColor gcbg,gcfg,gcmk; |
| 1757 |
struct sprop*sps[MXSZ*MXSZ]; |
| 1758 |
int nsps; |
| 1759 |
int d,i,j; |
| 1760 |
|
| 1761 |
sprop_g=g; |
| 1762 |
nsps=0; |
| 1763 |
if(g) {sps[0]=&dsp;nsps=1;} |
| 1764 |
else { |
| 1765 |
for(j=0;j<height;j++) for(i=0;i<width;i++) if(gsq[i][j].fl&16) sps[nsps++]=&gsq[i][j].sp; |
| 1766 |
if(selmode!=0||nsps==0) {reperr("Please select one or more cells\nwhose properties you wish to change");return 1;} |
| 1767 |
} |
| 1768 |
i=sps[0]->bgcol; |
| 1769 |
gcbg.red =((i>>16)&255)*257; |
| 1770 |
gcbg.green=((i>> 8)&255)*257; |
| 1771 |
gcbg.blue =((i )&255)*257; |
| 1772 |
i=sps[0]->fgcol; |
| 1773 |
gcfg.red =((i>>16)&255)*257; |
| 1774 |
gcfg.green=((i>> 8)&255)*257; |
| 1775 |
gcfg.blue =((i )&255)*257; |
| 1776 |
i=sps[0]->mkcol; |
| 1777 |
gcmk.red =((i>>16)&255)*257; |
| 1778 |
gcmk.green=((i>> 8)&255)*257; |
| 1779 |
gcmk.blue =((i )&255)*257; |
| 1780 |
|
| 1781 |
dia=gtk_dialog_new_with_buttons(g?"Default cell properties":"Selected cell properties", |
| 1782 |
GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT, |
| 1783 |
GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_APPLY,GTK_RESPONSE_OK,NULL); |
| 1784 |
vb=gtk_vbox_new(0,2); |
| 1785 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox),vb,TRUE,TRUE,0); |
| 1786 |
|
| 1787 |
if(!g) { |
| 1788 |
sprop_or=gtk_check_button_new_with_mnemonic("_Override default cell properties"); |
| 1789 |
gtk_box_pack_start(GTK_BOX(vb),sprop_or,TRUE,TRUE,0); |
| 1790 |
gtk_signal_connect(GTK_OBJECT(sprop_or),"clicked",GTK_SIGNAL_FUNC(sprop_setactive),0); |
| 1791 |
w=gtk_hseparator_new(); |
| 1792 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1793 |
} |
| 1794 |
|
| 1795 |
w=gtk_hbox_new(0,2); |
| 1796 |
sprop_l0=gtk_label_new("Background colour: "); |
| 1797 |
gtk_label_set_width_chars(GTK_LABEL(sprop_l0),18); |
| 1798 |
gtk_misc_set_alignment(GTK_MISC(sprop_l0),1,0.5); |
| 1799 |
gtk_box_pack_start(GTK_BOX(w),sprop_l0,FALSE,FALSE,0); |
| 1800 |
sprop_cbg=gtk_color_button_new_with_color(&gcbg); |
| 1801 |
gtk_box_pack_start(GTK_BOX(w),sprop_cbg,FALSE,FALSE,0); |
| 1802 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1803 |
|
| 1804 |
w=gtk_hbox_new(0,2); |
| 1805 |
sprop_l1=gtk_label_new("Foreground colour: "); |
| 1806 |
gtk_label_set_width_chars(GTK_LABEL(sprop_l1),18); |
| 1807 |
gtk_misc_set_alignment(GTK_MISC(sprop_l1),1,0.5); |
| 1808 |
gtk_box_pack_start(GTK_BOX(w),sprop_l1,FALSE,FALSE,0); |
| 1809 |
sprop_cfg=gtk_color_button_new_with_color(&gcfg); |
| 1810 |
gtk_box_pack_start(GTK_BOX(w),sprop_cfg,FALSE,FALSE,0); |
| 1811 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1812 |
|
| 1813 |
w=gtk_hbox_new(0,2); gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1814 |
sprop_l2=gtk_label_new("Font style: "); gtk_box_pack_start(GTK_BOX(w),sprop_l2,FALSE,FALSE,0); |
| 1815 |
gtk_label_set_width_chars(GTK_LABEL(sprop_l2),18); |
| 1816 |
gtk_misc_set_alignment(GTK_MISC(sprop_l2),1,0.5); |
| 1817 |
sprop_w20=gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(w),sprop_w20,FALSE,FALSE,0); |
| 1818 |
gtk_combo_box_append_text(GTK_COMBO_BOX(sprop_w20),"Normal"); |
| 1819 |
gtk_combo_box_append_text(GTK_COMBO_BOX(sprop_w20),"Bold"); |
| 1820 |
gtk_combo_box_append_text(GTK_COMBO_BOX(sprop_w20),"Italic"); |
| 1821 |
gtk_combo_box_append_text(GTK_COMBO_BOX(sprop_w20),"Bold italic"); |
| 1822 |
i=sps[0]->fstyle; |
| 1823 |
if(i<0) i=0; |
| 1824 |
if(i>3) i=3; |
| 1825 |
gtk_combo_box_set_active(GTK_COMBO_BOX(sprop_w20),i); |
| 1826 |
|
| 1827 |
w=gtk_hseparator_new(); |
| 1828 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1829 |
|
| 1830 |
w=gtk_hbox_new(0,2); |
| 1831 |
sprop_l4=gtk_label_new("Mark colour: "); |
| 1832 |
gtk_label_set_width_chars(GTK_LABEL(sprop_l4),18); |
| 1833 |
gtk_misc_set_alignment(GTK_MISC(sprop_l4),1,0.5); |
| 1834 |
gtk_box_pack_start(GTK_BOX(w),sprop_l4,FALSE,FALSE,0); |
| 1835 |
sprop_cmk=gtk_color_button_new_with_color(&gcmk); |
| 1836 |
gtk_box_pack_start(GTK_BOX(w),sprop_cmk,FALSE,FALSE,0); |
| 1837 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1838 |
|
| 1839 |
for(i=0;i<2;i++) { |
| 1840 |
w=gtk_hbox_new(0,2); |
| 1841 |
for(j=0;j<ndir[gtype];j++) { |
| 1842 |
if(i==0) d=j; |
| 1843 |
else d=ndir[gtype]*2-j-1; |
| 1844 |
sprop_mkl[d]=gtk_label_new(mklabel[gtype][d]); |
| 1845 |
gtk_label_set_width_chars(GTK_LABEL(sprop_mkl[d]),12); |
| 1846 |
gtk_misc_set_alignment(GTK_MISC(sprop_mkl[d]),1,0.5); |
| 1847 |
gtk_box_pack_start(GTK_BOX(w),sprop_mkl[d],FALSE,FALSE,0); |
| 1848 |
sprop_mke[d]=gtk_entry_new(); |
| 1849 |
gtk_entry_set_max_length(GTK_ENTRY(sprop_mke[d]),5); |
| 1850 |
gtk_entry_set_width_chars(GTK_ENTRY(sprop_mke[d]),5); |
| 1851 |
gtk_entry_set_text(GTK_ENTRY(sprop_mke[d]),sps[0]->mk[d]); |
| 1852 |
gtk_box_pack_start(GTK_BOX(w),sprop_mke[d],FALSE,FALSE,0); |
| 1853 |
} |
| 1854 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1855 |
} |
| 1856 |
|
| 1857 |
w=gtk_hseparator_new(); |
| 1858 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1859 |
|
| 1860 |
sprop_tr=gtk_check_button_new_with_mnemonic("_Flag for answer treatment"); |
| 1861 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sprop_tr),sps[0]->ten); |
| 1862 |
gtk_box_pack_start(GTK_BOX(vb),sprop_tr,TRUE,TRUE,0); |
| 1863 |
|
| 1864 |
w=gtk_hseparator_new(); |
| 1865 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1866 |
|
| 1867 |
w=gtk_hbox_new(0,2); gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1868 |
sprop_l3=gtk_label_new("Lights intersecting here "); gtk_box_pack_start(GTK_BOX(w),sprop_l3,FALSE,FALSE,0); |
| 1869 |
gtk_misc_set_alignment(GTK_MISC(sprop_l3),1,0.5); |
| 1870 |
sprop_w21=gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(w),sprop_w21,FALSE,FALSE,0); |
| 1871 |
gtk_combo_box_append_text(GTK_COMBO_BOX(sprop_w21),"must agree"); |
| 1872 |
gtk_combo_box_append_text(GTK_COMBO_BOX(sprop_w21),"need not agree: horizontal display"); |
| 1873 |
gtk_combo_box_append_text(GTK_COMBO_BOX(sprop_w21),"need not agree: vertical display"); |
| 1874 |
i=sps[0]->dech; |
| 1875 |
if(i<0) i=0; |
| 1876 |
if(i>2) i=2; |
| 1877 |
gtk_combo_box_set_active(GTK_COMBO_BOX(sprop_w21),i); |
| 1878 |
|
| 1879 |
if(!g) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sprop_or),(sps[0]->spor)&1); |
| 1880 |
sprop_setactive(); |
| 1881 |
|
| 1882 |
gtk_widget_show_all(dia); |
| 1883 |
i=gtk_dialog_run(GTK_DIALOG(dia)); |
| 1884 |
if(i==GTK_RESPONSE_OK) { |
| 1885 |
gtk_color_button_get_color(GTK_COLOR_BUTTON(sprop_cbg),&gcbg); |
| 1886 |
gtk_color_button_get_color(GTK_COLOR_BUTTON(sprop_cfg),&gcfg); |
| 1887 |
gtk_color_button_get_color(GTK_COLOR_BUTTON(sprop_cmk),&gcmk); |
| 1888 |
for(j=0;j<nsps;j++) { |
| 1889 |
if(!g) sps[j]->spor=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sprop_or)); |
| 1890 |
sps[j]->bgcol= |
| 1891 |
(((gcbg.red >>8)&255)<<16)+ |
| 1892 |
(((gcbg.green>>8)&255)<< 8)+ |
| 1893 |
(((gcbg.blue >>8)&255) ); |
| 1894 |
sps[j]->fgcol= |
| 1895 |
(((gcfg.red >>8)&255)<<16)+ |
| 1896 |
(((gcfg.green>>8)&255)<< 8)+ |
| 1897 |
(((gcfg.blue >>8)&255) ); |
| 1898 |
sps[j]->mkcol= |
| 1899 |
(((gcmk.red >>8)&255)<<16)+ |
| 1900 |
(((gcmk.green>>8)&255)<< 8)+ |
| 1901 |
(((gcmk.blue >>8)&255) ); |
| 1902 |
i=gtk_combo_box_get_active(GTK_COMBO_BOX(sprop_w20)); if(i>=0&&i<4) sps[j]->fstyle=i; |
| 1903 |
sps[j]->ten=!!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sprop_tr)); |
| 1904 |
i=gtk_combo_box_get_active(GTK_COMBO_BOX(sprop_w21)); if(i>=0&&i<3) sps[j]->dech=i; |
| 1905 |
for(d=0;d<ndir[gtype]*2;d++) { |
| 1906 |
strncpy(sps[j]->mk[d],gtk_entry_get_text(GTK_ENTRY(sprop_mke[d])),MXMK); |
| 1907 |
sps[j]->mk[d][MXMK]=0; |
| 1908 |
} |
| 1909 |
} |
| 1910 |
gridchange(); |
| 1911 |
} |
| 1912 |
gtk_widget_destroy(dia); |
| 1913 |
refreshall(); |
| 1914 |
return 1; |
| 1915 |
} |
| 1916 |
|
| 1917 |
|
| 1918 |
static void getdfname(char*s,int d,int l) { |
| 1919 |
if(strlen(dfnames[d])==0) { |
| 1920 |
if(strlen(dafilters[d])==0) strcat(s,"<empty>"); |
| 1921 |
else { |
| 1922 |
strcat(s,"\""); |
| 1923 |
if((int)strlen(dafilters[d])>l) {strncat(s,dafilters[d],l-3); strcat(s,"...");} |
| 1924 |
else strcat(s,dafilters[d]); |
| 1925 |
strcat(s,"\""); |
| 1926 |
} |
| 1927 |
} |
| 1928 |
else { |
| 1929 |
if((int)strlen(dfnames[d])>l) {strcat(s,"...");strcat(s,dfnames[d]+strlen(dfnames[d])-l+3);} |
| 1930 |
else strcat(s,dfnames[d]); |
| 1931 |
} |
| 1932 |
} |
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
static GtkWidget*lprop_e[MAXNDICTS],*lprop_f[NLEM],*lprop_or,*lprop_tr,*lprop_nn,*lprop_mux; |
| 1937 |
static int lprop_g; |
| 1938 |
|
| 1939 |
static int lprop_setactive() {int i,k; |
| 1940 |
k=lprop_g||gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lprop_or)); |
| 1941 |
for(i=0;i<MAXNDICTS;i++) gtk_widget_set_sensitive(lprop_e[i],k); |
| 1942 |
for(i=0;i<NLEM;i++) gtk_widget_set_sensitive(lprop_f[i],k); |
| 1943 |
gtk_widget_set_sensitive(lprop_tr,k); |
| 1944 |
gtk_widget_set_sensitive(lprop_nn,k); |
| 1945 |
gtk_widget_set_sensitive(lprop_mux,k); |
| 1946 |
return 1; |
| 1947 |
} |
| 1948 |
|
| 1949 |
static int lpropdia(int g) { |
| 1950 |
GtkWidget*dia,*w,*vb; |
| 1951 |
struct lprop*lps[MXLT]; |
| 1952 |
int nlps; |
| 1953 |
int d,i,j; |
| 1954 |
char s[SLEN]; |
| 1955 |
|
| 1956 |
lprop_g=g; |
| 1957 |
nlps=0; |
| 1958 |
if(g) {lps[0]=&dlp;nlps=1;} |
| 1959 |
else { |
| 1960 |
if(selmode==1) |
| 1961 |
for(d=0;d<ndir[gtype];d++) for(j=0;j<height;j++) for(i=0;i<width;i++) if(isstartoflight(i,j,d)&&issellight(i,j,d)) lps[nlps++]=&gsq[i][j].lp[d]; |
| 1962 |
if(selmode==2) |
| 1963 |
for(i=0;i<nvl;i++) if(vls[i].sel) lps[nlps++]=&vls[i].lp; |
| 1964 |
if(selmode==0||nlps==0) {reperr("Please select one or more lights\nwhose properties you wish to change");return 1;} |
| 1965 |
} |
| 1966 |
dia=gtk_dialog_new_with_buttons(g?"Default light properties":"Selected light properties", |
| 1967 |
GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT, |
| 1968 |
GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_APPLY,GTK_RESPONSE_OK,NULL); |
| 1969 |
vb=gtk_vbox_new(0,2); |
| 1970 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox),vb,TRUE,TRUE,0); |
| 1971 |
|
| 1972 |
if(!g) { |
| 1973 |
lprop_or=gtk_check_button_new_with_mnemonic("_Override default light properties"); |
| 1974 |
gtk_box_pack_start(GTK_BOX(vb),lprop_or,TRUE,TRUE,0); |
| 1975 |
gtk_signal_connect(GTK_OBJECT(lprop_or),"clicked",GTK_SIGNAL_FUNC(lprop_setactive),0); |
| 1976 |
w=gtk_hseparator_new(); |
| 1977 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1978 |
} |
| 1979 |
for(i=0;i<MAXNDICTS;i++) { |
| 1980 |
sprintf(s,"Use dictionary _%d (",i+1); |
| 1981 |
getdfname(s+strlen(s),i,25); |
| 1982 |
|
| 1983 |
strcat(s,")"); |
| 1984 |
lprop_e[i]=gtk_check_button_new_with_mnemonic(s); |
| 1985 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lprop_e[i]),((lps[0]->dmask)>>i)&1); |
| 1986 |
gtk_box_pack_start(GTK_BOX(vb),lprop_e[i],TRUE,TRUE,0); |
| 1987 |
} |
| 1988 |
w=gtk_hseparator_new(); |
| 1989 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1990 |
lprop_tr=gtk_check_button_new_with_mnemonic("_Enable answer treatment"); |
| 1991 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lprop_tr),lps[0]->ten); |
| 1992 |
gtk_box_pack_start(GTK_BOX(vb),lprop_tr,TRUE,TRUE,0); |
| 1993 |
|
| 1994 |
w=gtk_hseparator_new(); |
| 1995 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 1996 |
for(i=0;i<NLEM;i++) { |
| 1997 |
sprintf(s,"Allow light to be entered _%s",lemdescADVP[i]); |
| 1998 |
lprop_f[i]=gtk_check_button_new_with_mnemonic(s); |
| 1999 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lprop_f[i]),((lps[0]->emask)>>i)&1); |
| 2000 |
gtk_box_pack_start(GTK_BOX(vb),lprop_f[i],TRUE,TRUE,0); |
| 2001 |
} |
| 2002 |
w=gtk_hseparator_new(); |
| 2003 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 2004 |
lprop_nn=gtk_check_button_new_with_mnemonic("Light _does not receive a number"); |
| 2005 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lprop_nn),lps[0]->dnran); |
| 2006 |
gtk_box_pack_start(GTK_BOX(vb),lprop_nn,TRUE,TRUE,0); |
| 2007 |
|
| 2008 |
w=gtk_hseparator_new(); |
| 2009 |
gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 2010 |
lprop_mux=gtk_check_button_new_with_mnemonic("_Multiplex"); |
| 2011 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lprop_mux),lps[0]->mux); |
| 2012 |
gtk_box_pack_start(GTK_BOX(vb),lprop_mux,TRUE,TRUE,0); |
| 2013 |
|
| 2014 |
if(!g) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lprop_or),(lps[0]->lpor)&1); |
| 2015 |
lprop_setactive(); |
| 2016 |
gtk_widget_show_all(dia); |
| 2017 |
i=gtk_dialog_run(GTK_DIALOG(dia)); |
| 2018 |
if(i==GTK_RESPONSE_OK) { |
| 2019 |
for(j=0;j<nlps;j++) { |
| 2020 |
if(!g) lps[j]->lpor=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lprop_or)); |
| 2021 |
lps[j]->dmask=0; |
| 2022 |
for(i=0;i<MAXNDICTS;i++) if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lprop_e[i]))) lps[j]->dmask|=1<<i; |
| 2023 |
lps[j]->emask=0; |
| 2024 |
for(i=0;i<NLEM;i++) if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lprop_f[i]))) lps[j]->emask|=1<<i; |
| 2025 |
lps[j]->ten=!!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lprop_tr)); |
| 2026 |
lps[j]->dnran=!!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lprop_nn)); |
| 2027 |
lps[j]->mux=!!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lprop_mux)); |
| 2028 |
if(lps[j]->emask==0) { |
| 2029 |
reperr("No entry methods selected:\nthis would make fill impossible.\nAllowing lights to be entered normally."); |
| 2030 |
lps[j]->emask=EM_FWD; |
| 2031 |
} |
| 2032 |
} |
| 2033 |
gridchange(); |
| 2034 |
} |
| 2035 |
gtk_widget_destroy(dia); |
| 2036 |
return 1; |
| 2037 |
} |
| 2038 |
|
| 2039 |
|
| 2040 |
|
| 2041 |
static GtkWidget*treat_a[NMSG],*treat_f,*treat_c,*treat_m[NMSG],*treat_lm[NMSG],*treat_bpiname,*treat_b1[NMSG],*treat_b2[NMSG],*treat_btambaw; |
| 2042 |
|
| 2043 |
static int treatcomboorder[NATREAT]={0,1,2,3,4,10,11,5,6,7,8,9}; |
| 2044 |
|
| 2045 |
static int treat_browse(GtkWidget*w,gpointer p) { |
| 2046 |
GtkWidget*dia; |
| 2047 |
DEB_GU {printf("w=%p p=%p\n",(void*)w,(void*)p);fflush(stdout);} |
| 2048 |
dia=gtk_file_chooser_dialog_new("Choose a treatment plug-in",0, |
| 2049 |
GTK_FILE_CHOOSER_ACTION_OPEN, |
| 2050 |
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
| 2051 |
GTK_STOCK_OPEN, GTK_RESPONSE_OK, |
| 2052 |
NULL); |
| 2053 |
if(gtk_dialog_run(GTK_DIALOG(dia))==GTK_RESPONSE_OK) |
| 2054 |
gtk_entry_set_text(GTK_ENTRY(treat_f),gtk_file_chooser_get_filename((GtkFileChooser*)dia)); |
| 2055 |
gtk_widget_destroy(dia); |
| 2056 |
return 1; |
| 2057 |
} |
| 2058 |
|
| 2059 |
|
| 2060 |
static char*gettreatlab(int n,int m) { |
| 2061 |
static char s[1000]; |
| 2062 |
int i,j,j0,j1; |
| 2063 |
if(n==2&&m==0) { |
| 2064 |
if(iccgroupstart[2]-iccgroupstart[0]==0) return "Alphabet substitutions: "; |
| 2065 |
strcpy(s,"Encode "); |
| 2066 |
for(i=0;i<2;i++) { |
| 2067 |
j0=iccgroupstart[i]; |
| 2068 |
j1=iccgroupstart[i+1]; |
| 2069 |
if(j0==j1) continue; |
| 2070 |
if(j1-j0<7) for(j=j0;j<j1;j++) strcat(s,icctoutf8[(int)iccused[j]]); |
| 2071 |
else { |
| 2072 |
for(j=j0;j<j0+3;j++) strcat(s,icctoutf8[(int)iccused[j]]); |
| 2073 |
strcat(s,"..."); |
| 2074 |
strcat(s,icctoutf8[(int)iccused[j1-1]]); |
| 2075 |
} |
| 2076 |
if(i==0&&iccgroupstart[2]!=j1) strcat(s,", "); |
| 2077 |
} |
| 2078 |
strcat(s," as: "); |
| 2079 |
return s; |
| 2080 |
} |
| 2081 |
if(n==4&&m==0) { |
| 2082 |
if(iccgroupstart[2]-iccgroupstart[0]==0) return "Encoding offsets: "; |
| 2083 |
strcpy(s,"Encodings of "); |
| 2084 |
for(i=0;i<2;i++) { |
| 2085 |
j0=iccgroupstart[i]; |
| 2086 |
j1=iccgroupstart[i+1]; |
| 2087 |
if(j0==j1) continue; |
| 2088 |
strcat(s,icctoutf8[(int)iccused[j0]]); |
| 2089 |
if(i==0&&iccgroupstart[2]!=j1) strcat(s,", "); |
| 2090 |
} |
| 2091 |
strcat(s,": "); |
| 2092 |
return s; |
| 2093 |
} |
| 2094 |
return treat_lab[n][m]; |
| 2095 |
} |
| 2096 |
|
| 2097 |
static int treat_setactive() {int i,j,k,l; |
| 2098 |
k=treatcomboorder[gtk_combo_box_get_active(GTK_COMBO_BOX(treat_c))]; |
| 2099 |
for(i=0;i<NMSG;i++) { |
| 2100 |
j=treat_lab[k][i]!=NULL; |
| 2101 |
l=gtk_combo_box_get_active(GTK_COMBO_BOX(treat_a[i])); |
| 2102 |
gtk_widget_set_sensitive(treat_m[i],j); |
| 2103 |
gtk_widget_set_sensitive(treat_b1[i],treatpermok[k][i]); |
| 2104 |
gtk_widget_set_sensitive(treat_b2[i],l>0&&treatpermok[k][i]); |
| 2105 |
gtk_label_set_text(GTK_LABEL(treat_lm[i]),gettreatlab(j?k:TREAT_PLUGIN,i)); |
| 2106 |
} |
| 2107 |
gtk_widget_set_sensitive(treat_bpiname,k==TREAT_PLUGIN); |
| 2108 |
gtk_widget_set_sensitive(treat_btambaw,k!=0); |
| 2109 |
return 1; |
| 2110 |
} |
| 2111 |
|
| 2112 |
static int treatdia(void) { |
| 2113 |
GtkWidget*dia,*e[NMSG],*c[NMSG],*l,*b,*vb; |
| 2114 |
int i,j; |
| 2115 |
char s[(MAXICC*16+4)*MXFL+1]; |
| 2116 |
|
| 2117 |
filler_stop(); |
| 2118 |
dia=gtk_dialog_new_with_buttons("Answer treatment",GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_APPLY,GTK_RESPONSE_OK,NULL); |
| 2119 |
vb=gtk_vbox_new(0,2); |
| 2120 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox),vb,TRUE,TRUE,0); |
| 2121 |
|
| 2122 |
treat_c=gtk_combo_box_new_text(); |
| 2123 |
for(i=0;i<NATREAT;i++) gtk_combo_box_append_text(GTK_COMBO_BOX(treat_c),tnames[treatcomboorder[i]]); |
| 2124 |
|
| 2125 |
gtk_box_pack_start(GTK_BOX(vb),treat_c,FALSE,FALSE,0); |
| 2126 |
|
| 2127 |
for(i=0;i<NMSG;i++) { |
| 2128 |
treat_m[i]=gtk_hbox_new(0,2); |
| 2129 |
treat_lm[i]=gtk_label_new(" "); |
| 2130 |
gtk_label_set_width_chars(GTK_LABEL(treat_lm[i]),25); |
| 2131 |
gtk_misc_set_alignment(GTK_MISC(treat_lm[i]),1,0.5); |
| 2132 |
gtk_box_pack_start(GTK_BOX(treat_m[i]),treat_lm[i],FALSE,FALSE,0); |
| 2133 |
e[i]=gtk_entry_new(); |
| 2134 |
gtk_entry_set_width_chars(GTK_ENTRY(e[i]),30); |
| 2135 |
gtk_entry_set_max_length(GTK_ENTRY(e[i]),sizeof(treatmsg[0])-1); |
| 2136 |
gtk_entry_set_text(GTK_ENTRY(e[i]),treatmsg[i]); |
| 2137 |
gtk_box_pack_start(GTK_BOX(treat_m[i]),e[i],FALSE,FALSE,0); |
| 2138 |
gtk_box_pack_start(GTK_BOX(vb),treat_m[i],TRUE,TRUE,0); |
| 2139 |
|
| 2140 |
treat_b1[i]=gtk_hbox_new(0,2); |
| 2141 |
l=gtk_label_new("Allocate characters "); |
| 2142 |
gtk_label_set_width_chars(GTK_LABEL(l),25); |
| 2143 |
gtk_misc_set_alignment(GTK_MISC(l),1,0.5); |
| 2144 |
gtk_box_pack_start(GTK_BOX(treat_b1[i]),l,FALSE,FALSE,0); |
| 2145 |
treat_a[i]=gtk_combo_box_new_text(); |
| 2146 |
gtk_combo_box_append_text(GTK_COMBO_BOX(treat_a[i]),"in clue order, first come first served"); |
| 2147 |
gtk_combo_box_append_text(GTK_COMBO_BOX(treat_a[i]),"in clue order, at discretion of filler"); |
| 2148 |
gtk_combo_box_append_text(GTK_COMBO_BOX(treat_a[i]),"in any order, at discretion of filler"); |
| 2149 |
gtk_box_pack_start(GTK_BOX(treat_b1[i]),treat_a[i],FALSE,FALSE,0); |
| 2150 |
gtk_box_pack_start(GTK_BOX(vb),treat_b1[i],TRUE,TRUE,0); |
| 2151 |
|
| 2152 |
treat_b2[i]=gtk_hbox_new(0,2); |
| 2153 |
l=gtk_label_new("subject to constraints "); |
| 2154 |
gtk_label_set_width_chars(GTK_LABEL(l),25); |
| 2155 |
gtk_misc_set_alignment(GTK_MISC(l),1,0.5); |
| 2156 |
gtk_box_pack_start(GTK_BOX(treat_b2[i]),l,FALSE,FALSE,0); |
| 2157 |
c[i]=gtk_entry_new(); |
| 2158 |
gtk_entry_set_width_chars(GTK_ENTRY(c[i]),30); |
| 2159 |
gtk_entry_set_max_length(GTK_ENTRY(c[i]),sizeof(s)); |
| 2160 |
abmstostr(s,treatcstr[i],MXFL,1); |
| 2161 |
j=strlen(s); |
| 2162 |
while(j>0&&s[j-1]=='?') j--; |
| 2163 |
s[j]=0; |
| 2164 |
gtk_entry_set_text(GTK_ENTRY(c[i]),s); |
| 2165 |
gtk_box_pack_start(GTK_BOX(treat_b2[i]),c[i],FALSE,FALSE,0); |
| 2166 |
|
| 2167 |
gtk_box_pack_start(GTK_BOX(vb),treat_b2[i],TRUE,TRUE,0); |
| 2168 |
} |
| 2169 |
|
| 2170 |
treat_bpiname=gtk_hbox_new(0,2); |
| 2171 |
l=gtk_label_new("Treatment plug-in: "); |
| 2172 |
gtk_label_set_width_chars(GTK_LABEL(l),25); |
| 2173 |
gtk_misc_set_alignment(GTK_MISC(l),1,0.5); |
| 2174 |
gtk_box_pack_start(GTK_BOX(treat_bpiname),l,FALSE,FALSE,0); |
| 2175 |
treat_f=gtk_entry_new(); |
| 2176 |
gtk_entry_set_max_length(GTK_ENTRY(treat_f),SLEN-1); |
| 2177 |
gtk_entry_set_text(GTK_ENTRY(treat_f),tpifname); |
| 2178 |
gtk_box_pack_start(GTK_BOX(treat_bpiname),treat_f,FALSE,FALSE,0); |
| 2179 |
b=gtk_button_new_with_label(" Browse... "); |
| 2180 |
gtk_box_pack_start(GTK_BOX(treat_bpiname),b,FALSE,FALSE,0); |
| 2181 |
gtk_signal_connect(GTK_OBJECT(b),"clicked",GTK_SIGNAL_FUNC(treat_browse),0); |
| 2182 |
gtk_box_pack_start(GTK_BOX(vb),treat_bpiname,TRUE,TRUE,0); |
| 2183 |
treat_btambaw=gtk_check_button_new_with_mnemonic("Treated answer _must be a word"); |
| 2184 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(treat_btambaw),tambaw); |
| 2185 |
gtk_box_pack_start(GTK_BOX(vb),treat_btambaw,TRUE,TRUE,0); |
| 2186 |
|
| 2187 |
gtk_signal_connect(GTK_OBJECT(treat_c),"changed",GTK_SIGNAL_FUNC(treat_setactive),0); |
| 2188 |
for(i=0;i<NATREAT;i++) if(treatcomboorder[i]==treatmode) gtk_combo_box_set_active(GTK_COMBO_BOX(treat_c),i); |
| 2189 |
for(i=0;i<NMSG;i++) { |
| 2190 |
gtk_signal_connect(GTK_OBJECT(treat_a[i]),"changed",GTK_SIGNAL_FUNC(treat_setactive),0); |
| 2191 |
gtk_combo_box_set_active(GTK_COMBO_BOX(treat_a[i]),treatorder[i]); |
| 2192 |
} |
| 2193 |
gtk_widget_show_all(dia); |
| 2194 |
i=gtk_dialog_run(GTK_DIALOG(dia)); |
| 2195 |
if(i==GTK_RESPONSE_OK) { |
| 2196 |
strncpy(tpifname,gtk_entry_get_text(GTK_ENTRY(treat_f)),SLEN-1); |
| 2197 |
tpifname[SLEN-1]=0; |
| 2198 |
treatmode=treatcomboorder[gtk_combo_box_get_active(GTK_COMBO_BOX(treat_c))]; |
| 2199 |
for(i=0;i<NMSG;i++) { |
| 2200 |
strncpy(treatmsg[i],gtk_entry_get_text(GTK_ENTRY(e[i])),sizeof(treatmsg[0])-1); |
| 2201 |
treatmsg[i][sizeof(treatmsg[0])-1]=0; |
| 2202 |
treatorder[i]=gtk_combo_box_get_active(GTK_COMBO_BOX(treat_a[i])); |
| 2203 |
if(treatorder[i]<0) treatorder[i]=0; |
| 2204 |
if(treatorder[i]>2) treatorder[i]=2; |
| 2205 |
if(!treatpermok[treatmode][i]) treatorder[i]=0; |
| 2206 |
j=strtoabms(treatcstr[i],MXFL,(char*)gtk_entry_get_text(GTK_ENTRY(c[i])),1); |
| 2207 |
for(;j<MXFL;j++) treatcstr[i][j]=ABM_ALL; |
| 2208 |
} |
| 2209 |
tambaw=!!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(treat_btambaw)); |
| 2210 |
if(treatmode<0||treatmode>=NATREAT) treatmode=0; |
| 2211 |
reloadtpi(); |
| 2212 |
} |
| 2213 |
gridchange(); |
| 2214 |
gtk_widget_destroy(dia); |
| 2215 |
return 1; |
| 2216 |
} |
| 2217 |
|
| 2218 |
|
| 2219 |
|
| 2220 |
|
| 2221 |
|
| 2222 |
static GtkWidget*dictl_e[MAXNDICTS]; |
| 2223 |
|
| 2224 |
static int dictl_browse(GtkWidget*w,gpointer p) { |
| 2225 |
GtkWidget*dia; |
| 2226 |
DEB_GU {printf("w=%p p=%p\n",(void*)w,(void*)p);fflush(stdout);} |
| 2227 |
dia=gtk_file_chooser_dialog_new("Choose a dictionary",0, |
| 2228 |
GTK_FILE_CHOOSER_ACTION_OPEN, |
| 2229 |
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
| 2230 |
GTK_STOCK_OPEN, GTK_RESPONSE_OK, |
| 2231 |
NULL); |
| 2232 |
if(gtk_dialog_run(GTK_DIALOG(dia))==GTK_RESPONSE_OK) |
| 2233 |
gtk_entry_set_text(GTK_ENTRY(dictl_e[(intptr_t)p]),gtk_file_chooser_get_filename((GtkFileChooser*)dia)); |
| 2234 |
gtk_widget_destroy(dia); |
| 2235 |
return 1; |
| 2236 |
} |
| 2237 |
|
| 2238 |
static int dictldia(void) { |
| 2239 |
GtkWidget*dia,*l,*b,*t,*f0[MAXNDICTS],*f1[MAXNDICTS]; |
| 2240 |
int d,i,j; |
| 2241 |
unsigned int m,m0; |
| 2242 |
char s[SLEN]; |
| 2243 |
|
| 2244 |
filler_stop(); |
| 2245 |
dia=gtk_dialog_new_with_buttons("Dictionaries",GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_APPLY,GTK_RESPONSE_OK,NULL); |
| 2246 |
t=gtk_table_new(MAXNDICTS+1,5,0); |
| 2247 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox),t,TRUE,TRUE,0); |
| 2248 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>File</b>" ); gtk_table_attach(GTK_TABLE(t),l,1,2,0,1,0,0,0,0); |
| 2249 |
l=gtk_label_new(""); gtk_table_attach(GTK_TABLE(t),l,3,4,0,1,0,0,10,0); |
| 2250 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>File filter</b>" ); gtk_table_attach(GTK_TABLE(t),l,4,5,0,1,0,0,0,0); |
| 2251 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>Answer filter</b>"); gtk_table_attach(GTK_TABLE(t),l,5,6,0,1,0,0,0,0); |
| 2252 |
for(i=0;i<MAXNDICTS;i++) { |
| 2253 |
sprintf(s,"<b>%d</b>",i+1); |
| 2254 |
l=gtk_label_new(NULL); |
| 2255 |
gtk_label_set_markup(GTK_LABEL(l),s); |
| 2256 |
gtk_table_attach(GTK_TABLE(t),l,0,1,i+1,i+2,0,0,5,0); |
| 2257 |
dictl_e[i]=gtk_entry_new(); |
| 2258 |
gtk_entry_set_max_length(GTK_ENTRY(dictl_e[i]),SLEN-1); |
| 2259 |
gtk_entry_set_text(GTK_ENTRY(dictl_e[i]),dfnames[i]); |
| 2260 |
gtk_table_attach(GTK_TABLE(t),dictl_e[i],1,2,i+1,i+2,0,0,0,0); |
| 2261 |
b=gtk_button_new_with_label(" Browse... "); |
| 2262 |
gtk_table_attach(GTK_TABLE(t),b,2,3,i+1,i+2,0,0,0,0); |
| 2263 |
f0[i]=gtk_entry_new(); |
| 2264 |
gtk_entry_set_max_length(GTK_ENTRY(f0[i]),SLEN-1); |
| 2265 |
gtk_entry_set_text(GTK_ENTRY(f0[i]),dsfilters[i]); |
| 2266 |
gtk_table_attach(GTK_TABLE(t),f0[i],4,5,i+1,i+2,0,0,5,0); |
| 2267 |
f1[i]=gtk_entry_new(); |
| 2268 |
gtk_entry_set_max_length(GTK_ENTRY(f1[i]),SLEN-1); |
| 2269 |
gtk_entry_set_text(GTK_ENTRY(f1[i]),dafilters[i]); |
| 2270 |
gtk_table_attach(GTK_TABLE(t),f1[i],5,6,i+1,i+2,0,0,5,0); |
| 2271 |
gtk_signal_connect(GTK_OBJECT(b),"clicked",GTK_SIGNAL_FUNC(dictl_browse),(void*)(intptr_t)i); |
| 2272 |
} |
| 2273 |
gtk_widget_show_all(dia); |
| 2274 |
|
| 2275 |
j=gtk_dialog_run(GTK_DIALOG(dia)); |
| 2276 |
if(j==GTK_RESPONSE_CANCEL||j==GTK_RESPONSE_DELETE_EVENT) goto ew0; |
| 2277 |
for(j=0;j<MAXNDICTS;j++) { |
| 2278 |
strncpy(dfnames[j],gtk_entry_get_text(GTK_ENTRY(dictl_e[j])),SLEN-1); |
| 2279 |
dfnames[j][SLEN-1]=0; |
| 2280 |
strncpy(dsfilters[j],gtk_entry_get_text(GTK_ENTRY(f0[j])),SLEN-1); |
| 2281 |
dsfilters[j][SLEN-1]=0; |
| 2282 |
strncpy(dafilters[j],gtk_entry_get_text(GTK_ENTRY(f1[j])),SLEN-1); |
| 2283 |
dafilters[j][SLEN-1]=0; |
| 2284 |
} |
| 2285 |
loaddicts(0); |
| 2286 |
|
| 2287 |
|
| 2288 |
m=0; |
| 2289 |
for(d=0;d<ndir[gtype];d++) for(j=0;j<height;j++) for(i=0;i<width;i++) if(isstartoflight(i,j,d)) m|=getlprop(i,j,d)->dmask; |
| 2290 |
for(d=0;d<nvl;d++) m|=getvlprop(d)->dmask; |
| 2291 |
m=dusedmask&~m; |
| 2292 |
if(m) { |
| 2293 |
if(onebit((ABM)m)) sprintf(s,"No lights have properties set to use\nwords from dictionary %d",logbase2((ABM)m)+1); |
| 2294 |
else { |
| 2295 |
sprintf(s,"No lights have properties set to use\nwords from dictionaries "); |
| 2296 |
while(m) { |
| 2297 |
m0=m&~(m-1); |
| 2298 |
sprintf(s+strlen(s),"%d",logbase2((ABM)m0)+1); |
| 2299 |
m&=~m0; |
| 2300 |
if(m) { |
| 2301 |
if(onebit((ABM)m)) strcat(s," or "); |
| 2302 |
else strcat(s,", "); |
| 2303 |
} |
| 2304 |
} |
| 2305 |
} |
| 2306 |
repwarn(s); |
| 2307 |
} |
| 2308 |
|
| 2309 |
ew0: |
| 2310 |
gridchange(); |
| 2311 |
gtk_widget_destroy(dia); |
| 2312 |
return 1; |
| 2313 |
} |
| 2314 |
|
| 2315 |
|
| 2316 |
static int dstatsdia(void) { |
| 2317 |
int d,i,j,k,n; |
| 2318 |
GtkWidget*dia,*nb,*w0,*vb0[MAXNDICTS],*vb,*l0; |
| 2319 |
char s[SLEN]; |
| 2320 |
|
| 2321 |
dia=gtk_dialog_new_with_buttons("Dictionary statistics",GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT,GTK_STOCK_OK,GTK_RESPONSE_OK,NULL); |
| 2322 |
vb=gtk_vbox_new(0,3); |
| 2323 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox),vb,TRUE,TRUE,0); |
| 2324 |
|
| 2325 |
nb=gtk_notebook_new(); |
| 2326 |
gtk_box_pack_start(GTK_BOX(vb),nb,FALSE,TRUE,0); |
| 2327 |
for(d=0;d<MAXNDICTS;d++) { |
| 2328 |
|
| 2329 |
w0=gtk_scrolled_window_new(0,0); |
| 2330 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w0),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); |
| 2331 |
gtk_widget_set_size_request(w0,-1,300); |
| 2332 |
|
| 2333 |
sprintf(s,"Dictionary %d",d+1); |
| 2334 |
gtk_notebook_append_page(GTK_NOTEBOOK(nb),w0,gtk_label_new(s)); |
| 2335 |
|
| 2336 |
vb0[d]=gtk_vbox_new(0,3); |
| 2337 |
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(w0),vb0[d]); |
| 2338 |
|
| 2339 |
sprintf(s," Name: "); getdfname(s,d,80); l0=gtk_label_new(s); gtk_misc_set_alignment(GTK_MISC(l0),0,0.5); gtk_box_pack_start(GTK_BOX(vb0[d]),l0,FALSE,TRUE,0); |
| 2340 |
if(strlen(dfnames[d])==0&&strlen(dafilters[d])==0) continue; |
| 2341 |
sprintf(s," Usable entries: %d",dst_lines[d]); l0=gtk_label_new(s); gtk_misc_set_alignment(GTK_MISC(l0),0,0.5); gtk_box_pack_start(GTK_BOX(vb0[d]),l0,FALSE,TRUE,0); |
| 2342 |
sprintf(s," After file filter: %d",dst_lines_f[d]); l0=gtk_label_new(s); gtk_misc_set_alignment(GTK_MISC(l0),0,0.5); gtk_box_pack_start(GTK_BOX(vb0[d]),l0,FALSE,TRUE,0); |
| 2343 |
sprintf(s," After answer filter: %d",dst_lines_fa[d]); l0=gtk_label_new(s); gtk_misc_set_alignment(GTK_MISC(l0),0,0.5); gtk_box_pack_start(GTK_BOX(vb0[d]),l0,FALSE,TRUE,0); |
| 2344 |
for(i=0,n=0;i<MAXUCHAR;i++) { |
| 2345 |
if(!ISUGRAPH(i)) continue; |
| 2346 |
if(dst_u_rejline_count[d][i]) n++; |
| 2347 |
} |
| 2348 |
if(n==0) { |
| 2349 |
l0=gtk_label_new(" No Unicode characters were rejected"); gtk_misc_set_alignment(GTK_MISC(l0),0,0.5); gtk_box_pack_start(GTK_BOX(vb0[d]),l0,FALSE,TRUE,0); |
| 2350 |
} |
| 2351 |
else { |
| 2352 |
sprintf(s," Rejected Unicode character%s:",n==1?"":"s"); l0=gtk_label_new(s); gtk_misc_set_alignment(GTK_MISC(l0),0,0.5); gtk_box_pack_start(GTK_BOX(vb0[d]),l0,FALSE,TRUE,0); |
| 2353 |
k=0; |
| 2354 |
for(i=0;i<MAXUCHAR;i++) { |
| 2355 |
if(!ISUGRAPH(i)) continue; |
| 2356 |
j=dst_u_rejline_count[d][i]; |
| 2357 |
if(j==0) continue; |
| 2358 |
sprintf(s," U+%04X (",i); |
| 2359 |
uchartoutf8(s+strlen(s),i); |
| 2360 |
strcat(s,"): "); |
| 2361 |
if(dst_u_rejline[d][i]) { |
| 2362 |
if(j==1) sprintf(s+strlen(s)," one occurrence, at line %d",dst_u_rejline[d][i]); |
| 2363 |
else sprintf(s+strlen(s)," %d occurrences, first at line %d",j,dst_u_rejline[d][i]); |
| 2364 |
} |
| 2365 |
else { |
| 2366 |
if(j==1) sprintf(s+strlen(s)," one occurrence"); |
| 2367 |
else sprintf(s+strlen(s)," %d occurrences",j); |
| 2368 |
} |
| 2369 |
l0=gtk_label_new(s); gtk_misc_set_alignment(GTK_MISC(l0),0,0.5); gtk_box_pack_start(GTK_BOX(vb0[d]),l0,FALSE,TRUE,0); |
| 2370 |
k++; |
| 2371 |
|
| 2372 |
} |
| 2373 |
|
| 2374 |
|
| 2375 |
|
| 2376 |
} |
| 2377 |
} |
| 2378 |
gtk_widget_show_all(dia); |
| 2379 |
gtk_dialog_run(GTK_DIALOG(dia)); |
| 2380 |
gtk_widget_destroy(dia); |
| 2381 |
return 1; |
| 2382 |
} |
| 2383 |
|
| 2384 |
static GtkWidget*alpha_r[MAXICC],*alpha_a[MAXICC],*alpha_vs[MAXICC],*alpha_cs[MAXICC],*alpha_sq[MAXICC],*alpha_iccl[MAXICC]; |
| 2385 |
static GtkWidget*al_w20,*al_w21; |
| 2386 |
static int aldiamode=0; |
| 2387 |
static int rowtoicc[MAXICC]; |
| 2388 |
|
| 2389 |
|
| 2390 |
static void ucharstostr(char*q,const uchar*p) { |
| 2391 |
int j; |
| 2392 |
*q=0; |
| 2393 |
for(j=0;p[j];j++) { |
| 2394 |
if(j>0) strcat(q," "); |
| 2395 |
sprintf(q+strlen(q),"U+%04X",p[j]); |
| 2396 |
} |
| 2397 |
} |
| 2398 |
|
| 2399 |
|
| 2400 |
static void ustrtouchars(uchar*q,const char*p,int l) { |
| 2401 |
int i; |
| 2402 |
unsigned int u; |
| 2403 |
*q=0; i=0; |
| 2404 |
for(i=0;i<l-1;i++) { |
| 2405 |
while(*p&&!isxdigit(*p)) p++; |
| 2406 |
if(!*p) return; |
| 2407 |
u=strtoul(p,(char**)&p,16); |
| 2408 |
if(ISUPRINT(u)) q[i]=u; |
| 2409 |
q[i+1]=0; |
| 2410 |
} |
| 2411 |
} |
| 2412 |
|
| 2413 |
|
| 2414 |
static int emchanged(GtkWidget*w,gpointer p) { |
| 2415 |
int i; |
| 2416 |
uchar s[MAXEQUIV+1]; |
| 2417 |
char t[MAXEQUIV*11+1]; |
| 2418 |
|
| 2419 |
i=gtk_combo_box_get_active(GTK_COMBO_BOX(al_w21)); |
| 2420 |
if(i==aldiamode) return 1; |
| 2421 |
switch(i) { |
| 2422 |
case 0: |
| 2423 |
for(i=1;i<MAXICC;i++) { |
| 2424 |
ustrtouchars(s,gtk_entry_get_text(GTK_ENTRY(alpha_r[i])),3); |
| 2425 |
ucharstoutf8(t,s); |
| 2426 |
gtk_entry_set_max_length(GTK_ENTRY(alpha_r[i]),2); |
| 2427 |
gtk_entry_set_text(GTK_ENTRY(alpha_r[i]),t); |
| 2428 |
ustrtouchars(s,gtk_entry_get_text(GTK_ENTRY(alpha_a[i])),MAXEQUIV+1); |
| 2429 |
ucharstoutf8(t,s); |
| 2430 |
gtk_entry_set_max_length(GTK_ENTRY(alpha_a[i]),MAXEQUIV); |
| 2431 |
gtk_entry_set_text(GTK_ENTRY(alpha_a[i]),t); |
| 2432 |
aldiamode=0; |
| 2433 |
} |
| 2434 |
break; |
| 2435 |
case 1: |
| 2436 |
for(i=1;i<MAXICC;i++) { |
| 2437 |
utf8touchars(s,gtk_entry_get_text(GTK_ENTRY(alpha_r[i])),3); |
| 2438 |
ucharstostr(t,s); |
| 2439 |
gtk_entry_set_max_length(GTK_ENTRY(alpha_r[i]),21); |
| 2440 |
gtk_entry_set_text(GTK_ENTRY(alpha_r[i]),t); |
| 2441 |
utf8touchars(s,gtk_entry_get_text(GTK_ENTRY(alpha_a[i])),MAXEQUIV+1); |
| 2442 |
ucharstostr(t,s); |
| 2443 |
gtk_entry_set_max_length(GTK_ENTRY(alpha_a[i]),MAXEQUIV*11); |
| 2444 |
gtk_entry_set_text(GTK_ENTRY(alpha_a[i]),t); |
| 2445 |
aldiamode=1; |
| 2446 |
} |
| 2447 |
break; |
| 2448 |
} |
| 2449 |
return 1; |
| 2450 |
} |
| 2451 |
|
| 2452 |
static int alphainit(GtkWidget*w,gpointer data) { |
| 2453 |
int i; |
| 2454 |
struct alphaentry*a; |
| 2455 |
i=gtk_combo_box_get_active(GTK_COMBO_BOX(al_w20))-1; |
| 2456 |
if(i<0||i>=NALPHAINIT) return 1; |
| 2457 |
a=alphainitdata[i]; |
| 2458 |
for(i=1;i<MAXICC;i++) { |
| 2459 |
if(a[i].rep) gtk_entry_set_text(GTK_ENTRY(alpha_r[i]),a[i].rep); |
| 2460 |
else gtk_entry_set_text(GTK_ENTRY(alpha_r[i]),""); |
| 2461 |
if(a[i].eqv) gtk_entry_set_text(GTK_ENTRY(alpha_a[i]),a[i].eqv); |
| 2462 |
else gtk_entry_set_text(GTK_ENTRY(alpha_a[i]),""); |
| 2463 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_vs[i]),a[i].vow); |
| 2464 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_cs[i]),a[i].con); |
| 2465 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_sq[i]),a[i].seq); |
| 2466 |
} |
| 2467 |
aldiamode=0; |
| 2468 |
emchanged(0,0); |
| 2469 |
gtk_combo_box_set_active(GTK_COMBO_BOX(al_w20),0); |
| 2470 |
return 1; |
| 2471 |
} |
| 2472 |
|
| 2473 |
static int al_insrow(GtkWidget*w,gpointer data) { |
| 2474 |
int i,j; |
| 2475 |
i=(GtkWidget**)data-alpha_r; |
| 2476 |
for(j=MAXICC-2;j>=i;j--) { |
| 2477 |
gtk_entry_set_text(GTK_ENTRY(alpha_r[j+1]),gtk_entry_get_text(GTK_ENTRY(alpha_r[j]))); |
| 2478 |
gtk_entry_set_text(GTK_ENTRY(alpha_a[j+1]),gtk_entry_get_text(GTK_ENTRY(alpha_a[j]))); |
| 2479 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_vs[j+1]),gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_vs[j]))); |
| 2480 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_cs[j+1]),gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_cs[j]))); |
| 2481 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_sq[j+1]),gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_sq[j]))); |
| 2482 |
} |
| 2483 |
gtk_entry_set_text(GTK_ENTRY(alpha_r[i]),""); |
| 2484 |
gtk_entry_set_text(GTK_ENTRY(alpha_a[i]),""); |
| 2485 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_vs[i]),0); |
| 2486 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_cs[i]),0); |
| 2487 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_sq[i]),0); |
| 2488 |
return 1; |
| 2489 |
} |
| 2490 |
|
| 2491 |
static int al_shfrow(GtkWidget*w,gpointer data) { |
| 2492 |
int i,j; |
| 2493 |
char s[MAXEQUIV*100+1]; |
| 2494 |
i=(GtkWidget**)data-alpha_r; |
| 2495 |
if(i<1||i>=MAXICC-1) return 1; |
| 2496 |
strcpy(s,gtk_entry_get_text(GTK_ENTRY(alpha_r[i]))); gtk_entry_set_text(GTK_ENTRY(alpha_r[i]),gtk_entry_get_text(GTK_ENTRY(alpha_r[i+1]))); gtk_entry_set_text(GTK_ENTRY(alpha_r[i+1]),s); |
| 2497 |
strcpy(s,gtk_entry_get_text(GTK_ENTRY(alpha_a[i]))); gtk_entry_set_text(GTK_ENTRY(alpha_a[i]),gtk_entry_get_text(GTK_ENTRY(alpha_a[i+1]))); gtk_entry_set_text(GTK_ENTRY(alpha_a[i+1]),s); |
| 2498 |
j=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_vs[i])); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_vs[i]),gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_vs[i+1]))); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_vs[i+1]),j); |
| 2499 |
j=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_cs[i])); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_cs[i]),gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_cs[i+1]))); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_cs[i+1]),j); |
| 2500 |
j=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_sq[i])); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_sq[i]),gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_sq[i+1]))); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_sq[i+1]),j); |
| 2501 |
return 1; |
| 2502 |
} |
| 2503 |
|
| 2504 |
static int al_delrow(GtkWidget*w,gpointer data) { |
| 2505 |
int i,j; |
| 2506 |
i=(GtkWidget**)data-alpha_r; |
| 2507 |
for(j=i;j<MAXICC-1;j++) { |
| 2508 |
gtk_entry_set_text(GTK_ENTRY(alpha_r[j]),gtk_entry_get_text(GTK_ENTRY(alpha_r[j+1]))); |
| 2509 |
gtk_entry_set_text(GTK_ENTRY(alpha_a[j]),gtk_entry_get_text(GTK_ENTRY(alpha_a[j+1]))); |
| 2510 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_vs[j]),gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_vs[j+1]))); |
| 2511 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_cs[j]),gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_cs[j+1]))); |
| 2512 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_sq[j]),gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_sq[j+1]))); |
| 2513 |
} |
| 2514 |
i=MAXICC-1; |
| 2515 |
gtk_entry_set_text(GTK_ENTRY(alpha_r[i]),""); |
| 2516 |
gtk_entry_set_text(GTK_ENTRY(alpha_a[i]),""); |
| 2517 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_vs[i]),0); |
| 2518 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_cs[i]),0); |
| 2519 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_sq[i]),0); |
| 2520 |
return 1; |
| 2521 |
} |
| 2522 |
|
| 2523 |
static int doiccls(GtkWidget*w,gpointer data) { |
| 2524 |
int f1,f2,i,j; |
| 2525 |
char s[20]; |
| 2526 |
uchar t[3]; |
| 2527 |
for(i=1,j=1;i<MAXICC;i++) { |
| 2528 |
if(aldiamode==0) utf8touchars(t,gtk_entry_get_text(GTK_ENTRY(alpha_r[i])),3); |
| 2529 |
else ustrtouchars(t,gtk_entry_get_text(GTK_ENTRY(alpha_r[i])),3); |
| 2530 |
f1=(ISUPRINT(t[0])&&t[1]==0); |
| 2531 |
f2=(ISUPRINT(t[0])&&ISUPRINT(t[1])&&t[2]==0); |
| 2532 |
|
| 2533 |
sprintf(s,"<b>%d</b>",j); |
| 2534 |
rowtoicc[i]=j; |
| 2535 |
j++; |
| 2536 |
|
| 2537 |
|
| 2538 |
|
| 2539 |
|
| 2540 |
|
| 2541 |
|
| 2542 |
|
| 2543 |
|
| 2544 |
|
| 2545 |
|
| 2546 |
|
| 2547 |
|
| 2548 |
gtk_label_set_markup(GTK_LABEL(alpha_iccl[i]),s); |
| 2549 |
gtk_widget_set_sensitive(alpha_iccl[i],f1); |
| 2550 |
gtk_widget_set_sensitive(alpha_vs[i],f1); |
| 2551 |
gtk_widget_set_sensitive(alpha_cs[i],f1); |
| 2552 |
gtk_widget_set_sensitive(alpha_sq[i],f1); |
| 2553 |
gtk_widget_set_sensitive(alpha_a [i],f1||f2); |
| 2554 |
} |
| 2555 |
return 1; |
| 2556 |
} |
| 2557 |
|
| 2558 |
static int alphadia(void) { |
| 2559 |
GtkWidget*dia,*l,*t,*b,*w0; |
| 2560 |
GtkRequisition sr; |
| 2561 |
int i,j,u; |
| 2562 |
char s[SLEN]; |
| 2563 |
|
| 2564 |
filler_stop(); |
| 2565 |
if(stats!=NULL) gtk_widget_destroy(stats); |
| 2566 |
stats=NULL; |
| 2567 |
dia=gtk_dialog_new_with_buttons("Alphabet",GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_APPLY,GTK_RESPONSE_OK,NULL); |
| 2568 |
|
| 2569 |
t=gtk_table_new(MAXICC+2,6,0); |
| 2570 |
|
| 2571 |
|
| 2572 |
|
| 2573 |
|
| 2574 |
al_w20=gtk_combo_box_new_text(); gtk_table_attach(GTK_TABLE(t),al_w20,0,1,0,1,0,0,5,5); |
| 2575 |
gtk_combo_box_append_text(GTK_COMBO_BOX(al_w20),"Initialise from language default..."); |
| 2576 |
for(i=0;i<NALPHAINIT;i++) gtk_combo_box_append_text(GTK_COMBO_BOX(al_w20),alphaname[i][0]); |
| 2577 |
gtk_combo_box_set_active(GTK_COMBO_BOX(al_w20),0); |
| 2578 |
gtk_signal_connect(GTK_OBJECT(al_w20),"changed",GTK_SIGNAL_FUNC(alphainit),NULL); |
| 2579 |
|
| 2580 |
|
| 2581 |
|
| 2582 |
|
| 2583 |
|
| 2584 |
al_w21=gtk_combo_box_new_text(); gtk_table_attach(GTK_TABLE(t),al_w21,3,4,0,1,0,0,5,5); |
| 2585 |
gtk_combo_box_append_text(GTK_COMBO_BOX(al_w21),"Edit as printable characters"); |
| 2586 |
gtk_combo_box_append_text(GTK_COMBO_BOX(al_w21),"Edit as Unicode code points"); |
| 2587 |
gtk_signal_connect(GTK_OBJECT(al_w21),"changed",GTK_SIGNAL_FUNC(emchanged),NULL); |
| 2588 |
|
| 2589 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox),t,TRUE,TRUE,0); |
| 2590 |
|
| 2591 |
w0=gtk_scrolled_window_new(0,0); |
| 2592 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w0),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); |
| 2593 |
gtk_widget_set_size_request(w0,-1,350); |
| 2594 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox),w0,TRUE,TRUE,0); |
| 2595 |
t=gtk_table_new(MAXICC+2,9,0); |
| 2596 |
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(w0),t); |
| 2597 |
|
| 2598 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>Entry</b>" ); gtk_table_attach(GTK_TABLE(t),l,1,2,1,2,0,0,5,5); |
| 2599 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>Equivalents in dictionary files</b>"); gtk_table_attach(GTK_TABLE(t),l,2,3,1,2,0,0,5,5); |
| 2600 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>In @ set?</b>" ); gtk_table_attach(GTK_TABLE(t),l,3,4,1,2,0,0,5,5); |
| 2601 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>In # set?</b>" ); gtk_table_attach(GTK_TABLE(t),l,4,5,1,2,0,0,5,5); |
| 2602 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>Sequence\ncontinues?</b>" ); gtk_table_attach(GTK_TABLE(t),l,5,6,1,2,0,0,5,5); |
| 2603 |
|
| 2604 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>Edit rows</b>" ); gtk_table_attach(GTK_TABLE(t),l,6,9,1,2,0,0,5,5); |
| 2605 |
|
| 2606 |
for(i=1;i<MAXICC;i++) { |
| 2607 |
sprintf(s,"<b>%d</b>",i); |
| 2608 |
alpha_iccl[i]=gtk_label_new(NULL); gtk_table_attach(GTK_TABLE(t),alpha_iccl[i],0,1,i+1,i+2,0,0,5,0); |
| 2609 |
alpha_r[i]=gtk_entry_new(); |
| 2610 |
gtk_entry_set_width_chars(GTK_ENTRY(alpha_r[i]),10); |
| 2611 |
gtk_entry_set_alignment(GTK_ENTRY(alpha_r[i]),.5); gtk_table_attach(GTK_TABLE(t),alpha_r[i] ,1,2,i+1,i+2,0,0,0,0); |
| 2612 |
gtk_entry_set_max_length(GTK_ENTRY(alpha_r[i]),2); |
| 2613 |
if(icctouchar[i]==0x3f) gtk_entry_set_text(GTK_ENTRY(alpha_r[i]),""); |
| 2614 |
else gtk_entry_set_text(GTK_ENTRY(alpha_r[i]),icctoutf8[i]); |
| 2615 |
gtk_signal_connect(GTK_OBJECT(alpha_r[i]),"changed",GTK_SIGNAL_FUNC(doiccls),NULL); |
| 2616 |
|
| 2617 |
alpha_a[i]=gtk_entry_new(); |
| 2618 |
gtk_entry_set_width_chars(GTK_ENTRY(alpha_a[i]),50); gtk_table_attach(GTK_TABLE(t),alpha_a[i] ,2,3,i+1,i+2,0,0,0,0); |
| 2619 |
gtk_entry_set_max_length(GTK_ENTRY(alpha_a[i]),MAXEQUIV); |
| 2620 |
gtk_entry_set_text(GTK_ENTRY(alpha_a[i]),iccequivs[i]); |
| 2621 |
|
| 2622 |
alpha_vs[i]=gtk_check_button_new(); |
| 2623 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_vs[i]),!!(ICCTOABM(i)&abm_vow)); gtk_table_attach(GTK_TABLE(t),alpha_vs[i] ,3,4,i+1,i+2,0,0,0,0); |
| 2624 |
alpha_cs[i]=gtk_check_button_new(); |
| 2625 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_cs[i]),!!(ICCTOABM(i)&abm_con)); gtk_table_attach(GTK_TABLE(t),alpha_cs[i] ,4,5,i+1,i+2,0,0,0,0); |
| 2626 |
alpha_sq[i]=gtk_check_button_new(); |
| 2627 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alpha_sq[i]),iccseq[i]); gtk_table_attach(GTK_TABLE(t),alpha_sq[i] ,5,6,i+1,i+2,0,0,0,0); |
| 2628 |
|
| 2629 |
if(i<MAXICC-1) { |
| 2630 |
b=gtk_button_new_with_label("+"); gtk_widget_set_tooltip_text(b,"Insert new row"); gtk_table_attach(GTK_TABLE(t),b,6,7,i+1,i+2,0,0,2,0); ⁁⏷↧⇐⇵∇⇅ |
| 2631 |
gtk_signal_connect(GTK_OBJECT(b),"clicked",GTK_SIGNAL_FUNC(al_insrow),(void*)&alpha_r[i]); |
| 2632 |
b=gtk_button_new_with_label("⇅"); gtk_widget_set_tooltip_text(b,"Shuffle row down"); gtk_table_attach(GTK_TABLE(t),b,7,8,i+1,i+2,0,0,2,0); |
| 2633 |
gtk_signal_connect(GTK_OBJECT(b),"clicked",GTK_SIGNAL_FUNC(al_shfrow),(void*)&alpha_r[i]); |
| 2634 |
b=gtk_button_new_with_label("✕"); gtk_widget_set_tooltip_text(b,"Delete row"); gtk_table_attach(GTK_TABLE(t),b,8,9,i+1,i+2,0,0,2,0); |
| 2635 |
gtk_signal_connect(GTK_OBJECT(b),"clicked",GTK_SIGNAL_FUNC(al_delrow),(void*)&alpha_r[i]); |
| 2636 |
} |
| 2637 |
} |
| 2638 |
|
| 2639 |
doiccls(0,0); |
| 2640 |
gtk_combo_box_set_active(GTK_COMBO_BOX(al_w21),0); |
| 2641 |
|
| 2642 |
gtk_widget_show_all(dia); |
| 2643 |
gtk_widget_hide(alpha_sq[MAXICC-1]); |
| 2644 |
gtk_widget_get_requisition(t,&sr); |
| 2645 |
gtk_widget_set_size_request(w0,sr.width+40,450); |
| 2646 |
gtk_window_set_focus(GTK_WINDOW(dia),NULL); |
| 2647 |
j=gtk_dialog_run(GTK_DIALOG(dia)); |
| 2648 |
if(j==GTK_RESPONSE_CANCEL||j==GTK_RESPONSE_DELETE_EVENT) goto ew0; |
| 2649 |
gtk_combo_box_set_active(GTK_COMBO_BOX(al_w21),0); |
| 2650 |
clearalphamap(); |
| 2651 |
for(i=1,j=0;i<MAXICC;i++) { |
| 2652 |
if(rowtoicc[i]>=0) { |
| 2653 |
u=addalphamapentry(rowtoicc[i], |
| 2654 |
(char*)gtk_entry_get_text(GTK_ENTRY(alpha_r[i])), |
| 2655 |
(char*)gtk_entry_get_text(GTK_ENTRY(alpha_a[i])), |
| 2656 |
!!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_vs[i])), |
| 2657 |
!!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_cs[i])), |
| 2658 |
!!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alpha_sq[i]))); |
| 2659 |
j|=1<<u; |
| 2660 |
} |
| 2661 |
} |
| 2662 |
if(j&2) reperr("Entries may not be space characters or\nany of the following: . - ? , [ ] ^ \""); |
| 2663 |
if(j&4) reperr("Space characters and the following: . - ? , [ ] ^ \"\nare always ignored in dictionary files"); |
| 2664 |
DEB_AL { |
| 2665 |
for(i=0;i<niccused;i++) { |
| 2666 |
u=iccused[i]; |
| 2667 |
printf("%2d ICC:%2d %05x g%d\n",i,u,icctouchar[u],iccusedtogroup[i]); |
| 2668 |
} |
| 2669 |
printf("%d",iccgroupstart[0]); |
| 2670 |
for(i=1;i<MAXICCGROUP;i++) printf("-%d",iccgroupstart[i]); |
| 2671 |
printf("\n"); |
| 2672 |
} |
| 2673 |
initcodeword(); |
| 2674 |
loaddicts(0); |
| 2675 |
reloadtpi(); |
| 2676 |
gridchange(); |
| 2677 |
refreshall(); |
| 2678 |
unsaved=1; |
| 2679 |
ew0: |
| 2680 |
gtk_widget_destroy(dia); |
| 2681 |
return 1; |
| 2682 |
} |
| 2683 |
|
| 2684 |
|
| 2685 |
|
| 2686 |
static GtkWidget*gprop_lx,*gprop_ly,*gprop_w20; |
| 2687 |
|
| 2688 |
static int gtchanged(GtkWidget*w,gpointer p) { |
| 2689 |
int i; |
| 2690 |
|
| 2691 |
i=gtk_combo_box_get_active(GTK_COMBO_BOX(gprop_w20)); |
| 2692 |
switch(gshape[i]) { |
| 2693 |
case 0: case 1: case 2: |
| 2694 |
gtk_label_set_text(GTK_LABEL(gprop_lx)," columns"); |
| 2695 |
gtk_label_set_text(GTK_LABEL(gprop_ly)," rows"); |
| 2696 |
break; |
| 2697 |
case 3: case 4: |
| 2698 |
gtk_label_set_text(GTK_LABEL(gprop_lx)," radii"); |
| 2699 |
gtk_label_set_text(GTK_LABEL(gprop_ly)," annuli"); |
| 2700 |
break; |
| 2701 |
} |
| 2702 |
return 1; |
| 2703 |
} |
| 2704 |
|
| 2705 |
static int gpropdia(void) { |
| 2706 |
GtkWidget*dia,*l,*w,*w30,*w31,*vb,*t,*ttl,*aut; |
| 2707 |
int i,j,i0,j0,m,nw,nh; |
| 2708 |
dia=gtk_dialog_new_with_buttons("Grid properties",GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT, |
| 2709 |
GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_APPLY,GTK_RESPONSE_OK,NULL); |
| 2710 |
vb=gtk_vbox_new(0,3); |
| 2711 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox),vb,TRUE,TRUE,0); |
| 2712 |
|
| 2713 |
t=gtk_table_new(2,2,0); gtk_box_pack_start(GTK_BOX(vb),t,TRUE,TRUE,0); |
| 2714 |
l=gtk_label_new("Title: "); gtk_table_attach(GTK_TABLE(t),l,0,1,0,1,0,0,0,0); |
| 2715 |
gtk_label_set_width_chars(GTK_LABEL(l),10); |
| 2716 |
gtk_misc_set_alignment(GTK_MISC(l),1,0.5); |
| 2717 |
ttl=gtk_entry_new(); gtk_table_attach(GTK_TABLE(t),ttl,1,2,0,1,0,0,0,0); |
| 2718 |
gtk_entry_set_max_length(GTK_ENTRY(ttl),SLEN-1); |
| 2719 |
gtk_entry_set_text(GTK_ENTRY(ttl),gtitle); |
| 2720 |
l=gtk_label_new("Author: "); gtk_table_attach(GTK_TABLE(t),l,0,1,1,2,0,0,0,0); |
| 2721 |
gtk_label_set_width_chars(GTK_LABEL(l),10); |
| 2722 |
gtk_misc_set_alignment(GTK_MISC(l),1,0.5); |
| 2723 |
aut=gtk_entry_new(); gtk_table_attach(GTK_TABLE(t),aut,1,2,1,2,0,0,0,0); |
| 2724 |
gtk_entry_set_max_length(GTK_ENTRY(aut),SLEN-1); |
| 2725 |
gtk_entry_set_text(GTK_ENTRY(aut),gauthor); |
| 2726 |
|
| 2727 |
w=gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 2728 |
w=gtk_hbox_new(0,2); gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 2729 |
l=gtk_label_new("Grid type: "); gtk_box_pack_start(GTK_BOX(w),l,FALSE,FALSE,0); |
| 2730 |
gtk_label_set_width_chars(GTK_LABEL(l),10); |
| 2731 |
gtk_misc_set_alignment(GTK_MISC(l),1,0.5); |
| 2732 |
gprop_w20=gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(w),gprop_w20,FALSE,FALSE,0); |
| 2733 |
for(i=0;i<NGTYPE;i++) gtk_combo_box_append_text(GTK_COMBO_BOX(gprop_w20),gtypedesc[i]); |
| 2734 |
|
| 2735 |
w=gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 2736 |
w=gtk_hbox_new(0,2); gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 2737 |
l=gtk_label_new("Size: "); gtk_box_pack_start(GTK_BOX(w),l,FALSE,FALSE,0); |
| 2738 |
gtk_label_set_width_chars(GTK_LABEL(l),10); |
| 2739 |
gtk_misc_set_alignment(GTK_MISC(l),1,0.5); |
| 2740 |
w30=gtk_spin_button_new_with_range(1,MXSZ,1); gtk_box_pack_start(GTK_BOX(w),w30,FALSE,FALSE,0); |
| 2741 |
gprop_lx=gtk_label_new(" "); gtk_box_pack_start(GTK_BOX(w),gprop_lx,FALSE,FALSE,0); |
| 2742 |
w=gtk_hbox_new(0,2); gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 2743 |
l=gtk_label_new("by "); gtk_box_pack_start(GTK_BOX(w),l,FALSE,FALSE,0); |
| 2744 |
gtk_label_set_width_chars(GTK_LABEL(l),10); |
| 2745 |
gtk_misc_set_alignment(GTK_MISC(l),1,0.5); |
| 2746 |
w31=gtk_spin_button_new_with_range(1,MXSZ,1); gtk_box_pack_start(GTK_BOX(w),w31,FALSE,FALSE,0); |
| 2747 |
gprop_ly=gtk_label_new(" "); gtk_box_pack_start(GTK_BOX(w),gprop_ly,FALSE,FALSE,0); |
| 2748 |
w=gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vb),w,TRUE,TRUE,0); |
| 2749 |
|
| 2750 |
gtk_signal_connect(GTK_OBJECT(gprop_w20),"changed",GTK_SIGNAL_FUNC(gtchanged),NULL); |
| 2751 |
|
| 2752 |
|
| 2753 |
gtk_combo_box_set_active(GTK_COMBO_BOX(gprop_w20),gtype); |
| 2754 |
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w30),width); |
| 2755 |
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w31),height); |
| 2756 |
|
| 2757 |
gtk_widget_show_all(dia); |
| 2758 |
|
| 2759 |
i=gtk_dialog_run(GTK_DIALOG(dia)); |
| 2760 |
if(i==GTK_RESPONSE_OK) { |
| 2761 |
|
| 2762 |
i=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w30)); if(i>=1&&i<=MXSZ) nw=i; else nw=width; |
| 2763 |
i=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w31)); if(i>=1&&i<=MXSZ) nh=i; else nh=height; |
| 2764 |
for(i=0;i<nw;i++) for(j=0;j<nh;j++) if(i>=width||j>=height) initsquare(i,j); |
| 2765 |
width=nw; height=nh; |
| 2766 |
|
| 2767 |
for(i=0,i0=0;i<nvl;i++) { |
| 2768 |
for(j=0,j0=0;j<vls[i].l;j++) if(vls[i].x[j]<width&&vls[i].y[j]<height) vls[i0].x[j0]=vls[i].x[j],vls[i0].y[j0]=vls[i].y[j],j0++; |
| 2769 |
vls[i0].l=j0; |
| 2770 |
if(j0>0) i0++; |
| 2771 |
} |
| 2772 |
nvl=i0; |
| 2773 |
|
| 2774 |
i=gtk_combo_box_get_active(GTK_COMBO_BOX(gprop_w20)); if(i>=0&&i<NGTYPE) gtype=i; |
| 2775 |
strncpy(gtitle ,gtk_entry_get_text(GTK_ENTRY(ttl)),SLEN-1); gtitle [SLEN-1]=0; |
| 2776 |
strncpy(gauthor,gtk_entry_get_text(GTK_ENTRY(aut)),SLEN-1); gauthor[SLEN-1]=0; |
| 2777 |
gridchange(); |
| 2778 |
} |
| 2779 |
|
| 2780 |
gtk_widget_destroy(dia); |
| 2781 |
draw_init(); |
| 2782 |
m=symmrmask(); if(((1<<symmr)&m)==0) symmr=1; |
| 2783 |
m=symmmmask(); if(((1<<symmm)&m)==0) symmm=0; |
| 2784 |
m=symmdmask(); if(((1<<symmd)&m)==0) symmd=0; |
| 2785 |
syncgui(); |
| 2786 |
return 1; |
| 2787 |
} |
| 2788 |
|
| 2789 |
|
| 2790 |
static int mvldia(int v) { |
| 2791 |
GtkWidget*dia,*vb,*v0,*w0,*l; |
| 2792 |
GtkTextBuffer*tbuf; |
| 2793 |
char*p,*q,s[MXLE*10+1]; |
| 2794 |
int x[MXCL],y[MXCL]; |
| 2795 |
int i; |
| 2796 |
|
| 2797 |
dia=gtk_dialog_new_with_buttons("Modify free light path",GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT, |
| 2798 |
GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_APPLY,GTK_RESPONSE_OK,NULL); |
| 2799 |
vb=gtk_vbox_new(0,3); |
| 2800 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox),vb,TRUE,TRUE,0); |
| 2801 |
l=gtk_label_new(" Enter a coordinate pair for each cell in the path on a "); gtk_box_pack_start(GTK_BOX(vb),l,FALSE,TRUE,0); |
| 2802 |
gtk_misc_set_alignment(GTK_MISC(l),0,0.5); |
| 2803 |
l=gtk_label_new(" separate line. Coordinates are counted from zero. "); gtk_box_pack_start(GTK_BOX(vb),l,FALSE,TRUE,0); |
| 2804 |
gtk_misc_set_alignment(GTK_MISC(l),0,0.5); |
| 2805 |
for(i=0,p=s;i<vls[v].l;i++) sprintf(p,"%d,%d\n",vls[v].x[i],vls[v].y[i]),p+=strlen(p); |
| 2806 |
w0=gtk_scrolled_window_new(0,0); |
| 2807 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w0),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); |
| 2808 |
gtk_box_pack_start(GTK_BOX(vb),w0,TRUE,TRUE,0); |
| 2809 |
v0=gtk_text_view_new(); |
| 2810 |
gtk_widget_set_size_request(v0,-1,200); |
| 2811 |
tbuf=gtk_text_view_get_buffer(GTK_TEXT_VIEW(v0)); |
| 2812 |
gtk_text_buffer_set_text(tbuf,s,-1); |
| 2813 |
gtk_container_add(GTK_CONTAINER(w0),v0); |
| 2814 |
|
| 2815 |
gtk_widget_show_all(dia); |
| 2816 |
|
| 2817 |
ew0: |
| 2818 |
i=gtk_dialog_run(GTK_DIALOG(dia)); |
| 2819 |
if(i==GTK_RESPONSE_OK) { |
| 2820 |
GtkTextIter i0,i1; |
| 2821 |
gtk_text_buffer_get_start_iter(tbuf,&i0); |
| 2822 |
gtk_text_buffer_get_end_iter (tbuf,&i1); |
| 2823 |
p=gtk_text_buffer_get_text(tbuf,&i0,&i1,FALSE); |
| 2824 |
for(i=0;i<=MXCL;i++) { |
| 2825 |
while(isspace((unsigned char)*p)) p++; |
| 2826 |
if(*p==0) break; |
| 2827 |
if(!isdigit((unsigned char)*p)) goto err0; |
| 2828 |
if(i==MXCL) goto err1; |
| 2829 |
x[i]=strtol(p,&q,10); |
| 2830 |
if(x[i]<0) x[i]=0; |
| 2831 |
if(x[i]>=MXSZ) x[i]=MXSZ-1; |
| 2832 |
if(q==p) goto err0; |
| 2833 |
p=q; |
| 2834 |
while(isspace((unsigned char)*p)||*p==',') p++; |
| 2835 |
y[i]=strtol(p,&q,10); |
| 2836 |
if(y[i]<0) y[i]=0; |
| 2837 |
if(y[i]>=MXSZ) y[i]=MXSZ-1; |
| 2838 |
if(q==p) goto err0; |
| 2839 |
p=q; |
| 2840 |
} |
| 2841 |
if(i>0) { |
| 2842 |
vls[v].l=i; |
| 2843 |
memcpy(vls[v].x,x,i*sizeof(int)); |
| 2844 |
memcpy(vls[v].y,y,i*sizeof(int)); |
| 2845 |
} |
| 2846 |
gridchange(); |
| 2847 |
} |
| 2848 |
gtk_widget_destroy(dia); |
| 2849 |
return 1; |
| 2850 |
|
| 2851 |
err0: reperr("Each line must contain\ntwo numeric coordinate values\nseparated by a comma or space"); goto ew0; |
| 2852 |
err1: reperr("Free light length limit reached"); goto ew0; |
| 2853 |
} |
| 2854 |
|
| 2855 |
GtkWidget*dictl_e1; |
| 2856 |
|
| 2857 |
static int ddict_browse(GtkWidget*w,gpointer p) { |
| 2858 |
GtkWidget*dia; |
| 2859 |
dia=gtk_file_chooser_dialog_new("Choose a dictionary",0, |
| 2860 |
GTK_FILE_CHOOSER_ACTION_OPEN, |
| 2861 |
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
| 2862 |
GTK_STOCK_OPEN, GTK_RESPONSE_OK, |
| 2863 |
NULL); |
| 2864 |
if(gtk_dialog_run(GTK_DIALOG(dia))==GTK_RESPONSE_OK) |
| 2865 |
gtk_entry_set_text(GTK_ENTRY(dictl_e1),gtk_file_chooser_get_filename((GtkFileChooser*)dia)); |
| 2866 |
gtk_widget_destroy(dia); |
| 2867 |
return 1; |
| 2868 |
} |
| 2869 |
|
| 2870 |
|
| 2871 |
static int prefsdia(void) { |
| 2872 |
GtkWidget*dia,*l,*w,*w30,*w31,*w32,*w00,*w01,*w02,*w20,*w21,*w10,*w11,*w12,*w14,*t,*le0[NLOOKUP],*le1[NLOOKUP],*vb,*nb,*dal,*b,*f01,*f11; |
| 2873 |
int i; |
| 2874 |
char s[SLEN+1]; |
| 2875 |
dia=gtk_dialog_new_with_buttons("Preferences",GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT, |
| 2876 |
GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_APPLY,GTK_RESPONSE_OK,NULL); |
| 2877 |
nb=gtk_notebook_new(); |
| 2878 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox),nb,FALSE,TRUE,0); |
| 2879 |
|
| 2880 |
vb=gtk_vbox_new(0,3); |
| 2881 |
gtk_notebook_append_page(GTK_NOTEBOOK(nb),vb,gtk_label_new("Export")); |
| 2882 |
|
| 2883 |
|
| 2884 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>Export preferences</b>"); gtk_box_pack_start(GTK_BOX(vb),l,FALSE,FALSE,0); |
| 2885 |
w=gtk_hbox_new(0,3); gtk_box_pack_start(GTK_BOX(vb),w,FALSE,FALSE,0); |
| 2886 |
l=gtk_label_new(" EPS/SVG export square size: "); gtk_box_pack_start(GTK_BOX(w),l,FALSE,FALSE,0); |
| 2887 |
w30=gtk_spin_button_new_with_range(10,72,1); gtk_box_pack_start(GTK_BOX(w),w30,FALSE,FALSE,0); |
| 2888 |
l=gtk_label_new(" points"); gtk_box_pack_start(GTK_BOX(w),l,FALSE,FALSE,0); |
| 2889 |
w=gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vb),w,FALSE,FALSE,0); |
| 2890 |
w=gtk_hbox_new(0,3); gtk_box_pack_start(GTK_BOX(vb),w,FALSE,FALSE,0); |
| 2891 |
l=gtk_label_new(" HTML/PNG export square size: "); gtk_box_pack_start(GTK_BOX(w),l,FALSE,FALSE,0); |
| 2892 |
w31=gtk_spin_button_new_with_range(10,72,1); gtk_box_pack_start(GTK_BOX(w),w31,FALSE,FALSE,0); |
| 2893 |
l=gtk_label_new(" pixels"); gtk_box_pack_start(GTK_BOX(w),l,FALSE,FALSE,0); |
| 2894 |
w=gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vb),w,FALSE,FALSE,0); |
| 2895 |
w32=gtk_check_button_new_with_label("Include numbers in filled grids"); gtk_box_pack_start(GTK_BOX(vb),w32,FALSE,FALSE,0); |
| 2896 |
|
| 2897 |
vb=gtk_vbox_new(0,3); |
| 2898 |
gtk_notebook_append_page(GTK_NOTEBOOK(nb),vb,gtk_label_new("Editing")); |
| 2899 |
|
| 2900 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>Editing preferences</b>"); gtk_box_pack_start(GTK_BOX(vb),l,FALSE,FALSE,0); |
| 2901 |
w00=gtk_check_button_new_with_label("Clicking corners makes blocks"); gtk_box_pack_start(GTK_BOX(vb),w00,FALSE,FALSE,0); |
| 2902 |
w=gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vb),w,FALSE,FALSE,0); |
| 2903 |
w01=gtk_check_button_new_with_label("Clicking edges makes bars"); gtk_box_pack_start(GTK_BOX(vb),w01,FALSE,FALSE,0); |
| 2904 |
w=gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vb),w,FALSE,FALSE,0); |
| 2905 |
w02=gtk_check_button_new_with_label("Show numbers while editing"); gtk_box_pack_start(GTK_BOX(vb),w02,FALSE,FALSE,0); |
| 2906 |
|
| 2907 |
vb=gtk_vbox_new(0,3); |
| 2908 |
gtk_notebook_append_page(GTK_NOTEBOOK(nb),vb,gtk_label_new("Statistics")); |
| 2909 |
|
| 2910 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>Statistics preferences</b>"); gtk_box_pack_start(GTK_BOX(vb),l,FALSE,FALSE,0); |
| 2911 |
l=gtk_label_new(" Desirable checking ratios");gtk_misc_set_alignment(GTK_MISC(l),0,0.5); gtk_box_pack_start(GTK_BOX(vb),l,FALSE,FALSE,0); |
| 2912 |
w=gtk_hbox_new(0,3); gtk_box_pack_start(GTK_BOX(vb),w,FALSE,FALSE,0); |
| 2913 |
l=gtk_label_new(" Minimum: "); gtk_box_pack_start(GTK_BOX(w),l,FALSE,FALSE,0); |
| 2914 |
w20=gtk_spin_button_new_with_range(0,100,1); gtk_box_pack_start(GTK_BOX(w),w20,FALSE,FALSE,0); |
| 2915 |
l=gtk_label_new("% Maximum: "); gtk_box_pack_start(GTK_BOX(w),l,FALSE,FALSE,0); |
| 2916 |
w21=gtk_spin_button_new_with_range(0,100,1); gtk_box_pack_start(GTK_BOX(w),w21,FALSE,FALSE,0); |
| 2917 |
l=gtk_label_new("% plus one cell "); gtk_box_pack_start(GTK_BOX(w),l,FALSE,FALSE,0); |
| 2918 |
|
| 2919 |
vb=gtk_vbox_new(0,3); |
| 2920 |
gtk_notebook_append_page(GTK_NOTEBOOK(nb),vb,gtk_label_new("Autofill")); |
| 2921 |
|
| 2922 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>Autofill preferences</b>"); gtk_box_pack_start(GTK_BOX(vb),l,FALSE,FALSE,0); |
| 2923 |
w10=gtk_radio_button_new_with_label_from_widget(NULL,"Deterministic"); gtk_box_pack_start(GTK_BOX(vb),w10,FALSE,FALSE,0); |
| 2924 |
w11=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(w10),"Slightly randomised"); gtk_box_pack_start(GTK_BOX(vb),w11,FALSE,FALSE,0); |
| 2925 |
w12=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(w11),"Highly randomised"); gtk_box_pack_start(GTK_BOX(vb),w12,FALSE,FALSE,0); |
| 2926 |
w=gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vb),w,FALSE,FALSE,0); |
| 2927 |
w14=gtk_check_button_new_with_label("Prevent duplicate answers and lights"); gtk_box_pack_start(GTK_BOX(vb),w14,FALSE,FALSE,0); |
| 2928 |
|
| 2929 |
vb=gtk_vbox_new(0,3); |
| 2930 |
gtk_notebook_append_page(GTK_NOTEBOOK(nb),vb,gtk_label_new("Lookup")); |
| 2931 |
|
| 2932 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>Lookup preferences</b>"); gtk_box_pack_start(GTK_BOX(vb),l,FALSE,FALSE,0); |
| 2933 |
|
| 2934 |
t=gtk_table_new(NLOOKUP+1,3,0); gtk_box_pack_start(GTK_BOX(vb),t,FALSE,FALSE,0); |
| 2935 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>Name</b>"); gtk_table_attach(GTK_TABLE(t),l,1,2,0,1,0,0,0,0); |
| 2936 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>URI (must start \"http://\" or \"https://\")</b>"); gtk_table_attach(GTK_TABLE(t),l,2,3,0,1,0,0,0,0); |
| 2937 |
for(i=0;i<NLOOKUP;i++) { |
| 2938 |
sprintf(s,"<b>%d</b>",i+1); |
| 2939 |
l=gtk_label_new(NULL); |
| 2940 |
gtk_label_set_markup(GTK_LABEL(l),s); |
| 2941 |
gtk_table_attach(GTK_TABLE(t),l,0,1,i+1,i+2,0,0,5,0); |
| 2942 |
le0[i]=gtk_entry_new(); |
| 2943 |
gtk_entry_set_max_length(GTK_ENTRY(le0[i]),SLEN-1); |
| 2944 |
gtk_entry_set_width_chars(GTK_ENTRY(le0[i]),30); |
| 2945 |
gtk_entry_set_text(GTK_ENTRY(le0[i]),lookupname(i)); |
| 2946 |
gtk_table_attach(GTK_TABLE(t),le0[i],1,2,i+1,i+2,0,0,0,0); |
| 2947 |
le1[i]=gtk_entry_new(); |
| 2948 |
gtk_entry_set_max_length(GTK_ENTRY(le1[i]),SLEN-1); |
| 2949 |
gtk_entry_set_width_chars(GTK_ENTRY(le1[i]),50); |
| 2950 |
gtk_entry_set_text(GTK_ENTRY(le1[i]),lookup(i)); |
| 2951 |
gtk_table_attach(GTK_TABLE(t),le1[i],2,3,i+1,i+2,0,0,5,0); |
| 2952 |
} |
| 2953 |
|
| 2954 |
vb=gtk_vbox_new(0,3); |
| 2955 |
gtk_notebook_append_page(GTK_NOTEBOOK(nb),vb,gtk_label_new("Startup")); |
| 2956 |
|
| 2957 |
l=gtk_label_new(NULL);gtk_label_set_markup(GTK_LABEL(l),"<b>Startup preferences</b>"); gtk_box_pack_start(GTK_BOX(vb),l,FALSE,FALSE,0); |
| 2958 |
|
| 2959 |
t=gtk_table_new(4,3,0); gtk_box_pack_start(GTK_BOX(vb),t,FALSE,FALSE,0); |
| 2960 |
l=gtk_label_new(" Default dictionary in slot 1 at startup: "); gtk_table_attach(GTK_TABLE(t),l,0,1,0,1,0,0,0,0); |
| 2961 |
dictl_e1=gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(dictl_e1),SLEN-1); gtk_table_attach(GTK_TABLE(t),dictl_e1,1,2,0,1,0,0,0,0); |
| 2962 |
gtk_entry_set_text(GTK_ENTRY(dictl_e1),startup_dict1); |
| 2963 |
b=gtk_button_new_with_label(" Browse... "); gtk_table_attach(GTK_TABLE(t),b,2,3,0,1,0,0,0,0); |
| 2964 |
l=gtk_label_new(" Default file filter: "); gtk_misc_set_alignment(GTK_MISC(l),1.0,0.5); gtk_table_attach(GTK_TABLE(t),l,0,1,1,2,0,0,0,0); |
| 2965 |
f01=gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(f01),SLEN-1); gtk_table_attach(GTK_TABLE(t),f01,1,2,1,2,0,0,0,0); |
| 2966 |
gtk_entry_set_text(GTK_ENTRY(f01),startup_ff1); |
| 2967 |
l=gtk_label_new(" Default answer filter: "); gtk_table_attach(GTK_TABLE(t),l,0,1,2,3,0,0,0,0); |
| 2968 |
f11=gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(f11),SLEN-1); gtk_table_attach(GTK_TABLE(t),f11,1,2,2,3,0,0,0,0); |
| 2969 |
gtk_entry_set_text(GTK_ENTRY(f11),startup_af1); |
| 2970 |
|
| 2971 |
gtk_signal_connect(GTK_OBJECT(b),"clicked",GTK_SIGNAL_FUNC(ddict_browse),0); |
| 2972 |
|
| 2973 |
w=gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vb),w,FALSE,FALSE,0); |
| 2974 |
|
| 2975 |
w=gtk_hbox_new(0,3); gtk_box_pack_start(GTK_BOX(vb),w,FALSE,FALSE,0); |
| 2976 |
l=gtk_label_new(" Default alphabet at startup: "); gtk_box_pack_start(GTK_BOX(w),l,FALSE,FALSE,0); |
| 2977 |
dal=gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(w),dal,FALSE,FALSE,0); |
| 2978 |
for(i=0;i<NALPHAINIT;i++) gtk_combo_box_append_text(GTK_COMBO_BOX(dal),alphaname[i][0]); |
| 2979 |
gtk_combo_box_set_active(GTK_COMBO_BOX(dal),startup_al); |
| 2980 |
|
| 2981 |
|
| 2982 |
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w30),eptsq); |
| 2983 |
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w31),hpxsq); |
| 2984 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w32),lnis); |
| 2985 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w00),clickblock); |
| 2986 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w01),clickbar); |
| 2987 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w02),shownums); |
| 2988 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w14),afunique); |
| 2989 |
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w20),mincheck); |
| 2990 |
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w21),maxcheck); |
| 2991 |
if(afrandom==0) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w10),1); |
| 2992 |
if(afrandom==1) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w11),1); |
| 2993 |
if(afrandom==2) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w12),1); |
| 2994 |
|
| 2995 |
gtk_widget_show_all(dia); |
| 2996 |
i=gtk_dialog_run(GTK_DIALOG(dia)); |
| 2997 |
if(i==GTK_RESPONSE_OK) { |
| 2998 |
|
| 2999 |
eptsq=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w30)); |
| 3000 |
if(eptsq<10) eptsq=10; |
| 3001 |
if(eptsq>72) eptsq=72; |
| 3002 |
hpxsq=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w31)); |
| 3003 |
if(hpxsq<10) hpxsq=10; |
| 3004 |
if(hpxsq>72) hpxsq=72; |
| 3005 |
lnis=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w32))&1; |
| 3006 |
clickblock=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w00))&1; |
| 3007 |
clickbar=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w01))&1; |
| 3008 |
shownums=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w02))&1; |
| 3009 |
mincheck=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w20)); |
| 3010 |
if(mincheck< 0) mincheck= 0; |
| 3011 |
if(mincheck>100) mincheck=100; |
| 3012 |
maxcheck=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w21)); |
| 3013 |
if(maxcheck< 0) maxcheck= 0; |
| 3014 |
if(maxcheck>100) maxcheck=100; |
| 3015 |
afunique=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w14)); |
| 3016 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w10))) afrandom=0; |
| 3017 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w11))) afrandom=1; |
| 3018 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w12))) afrandom=2; |
| 3019 |
for(i=0;i<NLOOKUP;i++) { |
| 3020 |
strncpy(lookupname(i),gtk_entry_get_text(GTK_ENTRY(le0[i])),SLEN-1); lookupname(i)[SLEN]=0; |
| 3021 |
strncpy(lookup(i) ,gtk_entry_get_text(GTK_ENTRY(le1[i])),SLEN-1); lookup (i)[SLEN]=0; |
| 3022 |
} |
| 3023 |
strncpy(startup_dict1,gtk_entry_get_text(GTK_ENTRY(dictl_e1)),SLEN-1); startup_dict1[SLEN]=0; |
| 3024 |
strncpy(startup_ff1 ,gtk_entry_get_text(GTK_ENTRY(f01 )),SLEN-1); startup_ff1 [SLEN]=0; |
| 3025 |
strncpy(startup_af1 ,gtk_entry_get_text(GTK_ENTRY(f11 )),SLEN-1); startup_af1 [SLEN]=0; |
| 3026 |
startup_al=gtk_combo_box_get_active(GTK_COMBO_BOX(dal)); |
| 3027 |
if(startup_al<0||startup_al>=NALPHAINIT) startup_al=ALPHABET_AZ09; |
| 3028 |
saveprefs(); |
| 3029 |
} |
| 3030 |
gtk_widget_destroy(dia); |
| 3031 |
refreshall(); |
| 3032 |
compute(0); |
| 3033 |
return 1; |
| 3034 |
} |
| 3035 |
|
| 3036 |
|
| 3037 |
|
| 3038 |
|
| 3039 |
|
| 3040 |
void stats_upd(void) { |
| 3041 |
int i,j; |
| 3042 |
char s[SLEN]; |
| 3043 |
|
| 3044 |
if(!usegui) return; |
| 3045 |
if(!stats) return; |
| 3046 |
for(i=2;i<=MXLE;i++) { |
| 3047 |
if(st_lc[i]>0) { |
| 3048 |
sprintf(s,"%d",i); gtk_label_set_text(GTK_LABEL(st_te[i][0]),s); |
| 3049 |
sprintf(s,"%d",st_lc[i]); gtk_label_set_text(GTK_LABEL(st_te[i][1]),s); |
| 3050 |
sprintf(s,st_lucc[i]?"%d (%.1f%%)":" ",st_lucc[i],100.0*st_lucc[i]/st_lc[i]); gtk_label_set_text(GTK_LABEL(st_te[i][2]),s); |
| 3051 |
sprintf(s,st_locc[i]?"%d (%.1f%%)":" ",st_locc[i],100.0*st_locc[i]/st_lc[i]); gtk_label_set_text(GTK_LABEL(st_te[i][3]),s); |
| 3052 |
sprintf(s,st_lc[i]?"%.2f:%.2f:%.2f":" " ,1.0*st_lmnc[i]/i,1.0*st_lsc[i]/st_lc[i]/i,1.0*st_lmxc[i]/i); gtk_label_set_text(GTK_LABEL(st_te[i][4]),s); |
| 3053 |
for(j=0;j<5;j++) gtk_widget_show(st_te[i][j]); |
| 3054 |
} |
| 3055 |
else for(j=0;j<5;j++) {gtk_label_set_text(GTK_LABEL(st_te[i][j])," ");gtk_widget_hide(st_te[i][j]);} |
| 3056 |
} |
| 3057 |
sprintf(s," Total lights: %d",nw0); gtk_label_set_text(GTK_LABEL(st_r[0]),s); |
| 3058 |
if(nw0>0) sprintf(s," Mean length: %.1f",(double)nc/nw0); |
| 3059 |
else strcpy (s," Mean length: -"); |
| 3060 |
gtk_label_set_text(GTK_LABEL(st_r[1]),s); |
| 3061 |
if(nc>0 ) sprintf(s," Checked light characters: %d/%d (%.1f%%)",st_sc,nc,100.0*st_sc/nc); |
| 3062 |
else strcpy (s," Checked light characters: -"); |
| 3063 |
gtk_label_set_text(GTK_LABEL(st_r[2]),s); |
| 3064 |
if(ne0>0) sprintf(s," Checked grid cells: %d/%d (%.1f%%)",st_ce,ne0,100.0*st_ce/ne0); |
| 3065 |
else strcpy (s," Checked grid cells: -"); |
| 3066 |
gtk_label_set_text(GTK_LABEL(st_r[3]),s); |
| 3067 |
sprintf(s," Lights with double unches: %d",st_2u-st_3u); gtk_label_set_text(GTK_LABEL(st_r[4]),s); |
| 3068 |
sprintf(s," Lights with triple, quadruple etc. unches: %d",st_3u); gtk_label_set_text(GTK_LABEL(st_r[5]),s); |
| 3069 |
sprintf(s," Lights too long for filler: %d",st_tlf); gtk_label_set_text(GTK_LABEL(st_r[6]),s); |
| 3070 |
sprintf(s," Total free lights: %d",nvl); gtk_label_set_text(GTK_LABEL(st_r[7]),s); |
| 3071 |
sprintf(s," Free lights too long for filler: %d",st_vltlf); gtk_label_set_text(GTK_LABEL(st_r[8]),s); |
| 3072 |
if(st_tmtlf) sprintf(s," There are too many treated lights to use filler discretionary modes"); |
| 3073 |
else sprintf(s," "); |
| 3074 |
gtk_label_set_text(GTK_LABEL(st_r[9]),s); |
| 3075 |
if(hist_da->window) gdk_window_invalidate_rect(hist_da->window,0,0); |
| 3076 |
} |
| 3077 |
|
| 3078 |
|
| 3079 |
static gint hist_configure_event(GtkWidget*widget,GdkEventConfigure*event) { |
| 3080 |
DEB_RF printf("hist config event: new w=%d h=%d\n",widget->allocation.width,widget->allocation.height); |
| 3081 |
return TRUE; |
| 3082 |
} |
| 3083 |
|
| 3084 |
#define HBARW 12 // width of bar |
| 3085 |
#define HBARG 4 // gap between bars |
| 3086 |
|
| 3087 |
|
| 3088 |
static void drawhist(cairo_t*cr) { |
| 3089 |
int x=5,y0=224,w=HBARW; |
| 3090 |
int c,g,h,i,m,u,v,mni,mxi; |
| 3091 |
char s[SLEN]; |
| 3092 |
|
| 3093 |
for(i=0,u=0;i<niccused;i++) u+=st_hist[(int)iccused[i]]; |
| 3094 |
if(u==0) return; |
| 3095 |
for(i=0,m=1;i<niccused;i++) if(st_hist[(int)iccused[i]]>m) m=st_hist[(int)iccused[i]]; |
| 3096 |
|
| 3097 |
for(g=0;g<MAXICCGROUP;g++) { |
| 3098 |
mni=iccgroupstart[g]; |
| 3099 |
mxi=iccgroupstart[g+1]; |
| 3100 |
if(mni==mxi) continue; |
| 3101 |
for(v=0,i=mni;i<mxi;i++) v+=st_hist[(int)iccused[i]]; |
| 3102 |
if(v==0) continue; |
| 3103 |
|
| 3104 |
for(i=mni;i<mxi;i++) { |
| 3105 |
c=iccused[i]; |
| 3106 |
v=st_hist[c]; |
| 3107 |
h=(v*150)/m; |
| 3108 |
cairo_rectangle(cr,x,y0,w,-h); |
| 3109 |
cairo_set_source_rgb(cr,0,0,0); |
| 3110 |
cairo_stroke_preserve(cr); |
| 3111 |
if(g==0) cairo_set_source_rgb(cr,0,1,0); |
| 3112 |
else if(g==1) cairo_set_source_rgb(cr,0,1,1); |
| 3113 |
else cairo_set_source_rgb(cr,1,1,0); |
| 3114 |
cairo_fill(cr); |
| 3115 |
if(v) { |
| 3116 |
cairo_set_source_rgb(cr,0,0,0); |
| 3117 |
gsave(cr); |
| 3118 |
cairo_translate(cr,x+w/2+4,y0-h-4); |
| 3119 |
cairo_rotate(cr,-PI/2); |
| 3120 |
sprintf(s,"%d (%.1f%%)",v,(v*100.0)/u); |
| 3121 |
ltext(cr,s,10,0); |
| 3122 |
grestore(cr); |
| 3123 |
} |
| 3124 |
else cairo_set_source_rgb(cr,1,0,0); |
| 3125 |
ctext(cr,icctoutf8[c],x+w/2,y0+20,16,0,0); |
| 3126 |
x+=HBARW+HBARG; |
| 3127 |
} |
| 3128 |
|
| 3129 |
} |
| 3130 |
|
| 3131 |
} |
| 3132 |
|
| 3133 |
|
| 3134 |
|
| 3135 |
static gint hist_expose_event(GtkWidget*widget,GdkEventExpose*event) { |
| 3136 |
cairo_t*cr; |
| 3137 |
DEB_RF printf("hist expose event x=%d y=%d w=%d h=%d\n",event->area.x,event->area.y,event->area.width,event->area.height),fflush(stdout); |
| 3138 |
if(widget==hist_da) { |
| 3139 |
cr=gdk_cairo_create(widget->window); |
| 3140 |
cairo_rectangle(cr,event->area.x,event->area.y,event->area.width,event->area.height); |
| 3141 |
cairo_clip(cr); |
| 3142 |
gscale=1; |
| 3143 |
drawhist(cr); |
| 3144 |
cairo_destroy(cr); |
| 3145 |
} |
| 3146 |
return FALSE; |
| 3147 |
} |
| 3148 |
|
| 3149 |
|
| 3150 |
static void stats_init(void) { |
| 3151 |
int i,j; |
| 3152 |
GtkWidget*w0,*w1,*nb,*vb0,*vb1; |
| 3153 |
|
| 3154 |
for(i=0;i<MXLE+2;i++) for(j=0;j<5;j++) st_te[i][j]=0; |
| 3155 |
stats=gtk_dialog_new_with_buttons("Statistics",GTK_WINDOW(mainw),GTK_DIALOG_DESTROY_WITH_PARENT,GTK_STOCK_CLOSE,GTK_RESPONSE_ACCEPT,NULL); |
| 3156 |
gtk_window_set_policy(GTK_WINDOW(stats),FALSE,FALSE,TRUE); |
| 3157 |
nb=gtk_notebook_new(); |
| 3158 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(stats)->vbox),nb,FALSE,TRUE,0); |
| 3159 |
|
| 3160 |
vb0=gtk_vbox_new(0,3); |
| 3161 |
gtk_notebook_append_page(GTK_NOTEBOOK(nb),vb0,gtk_label_new("General")); |
| 3162 |
w0=gtk_table_new(MXLE+2,5,FALSE); |
| 3163 |
st_te[0][0]=gtk_label_new(" Length "); |
| 3164 |
st_te[0][1]=gtk_label_new(" Count "); |
| 3165 |
st_te[0][2]=gtk_label_new(" Underchecked "); |
| 3166 |
st_te[0][3]=gtk_label_new(" Overchecked "); |
| 3167 |
st_te[0][4]=gtk_label_new(" Check ratio min:mean:max "); |
| 3168 |
for(j=0;j<5;j++) gtk_widget_show(st_te[0][j]); |
| 3169 |
w1=gtk_hseparator_new();gtk_table_attach_defaults(GTK_TABLE(w0),w1,0,5,1,2);gtk_widget_show(w1); |
| 3170 |
for(i=2;i<=MXLE;i++) for(j=0;j<5;j++) st_te[i][j]=gtk_label_new(""); |
| 3171 |
for(i=0;i<=MXLE;i++) for(j=0;j<5;j++) if(st_te[i][j]) gtk_table_attach_defaults(GTK_TABLE(w0),st_te[i][j],j,j+1,i,i+1); |
| 3172 |
w1=gtk_hseparator_new();gtk_table_attach_defaults(GTK_TABLE(w0),w1,0,5,MXLE+1,MXLE+2);gtk_widget_show(w1); |
| 3173 |
gtk_box_pack_start(GTK_BOX(vb0),w0,FALSE,TRUE,0);gtk_widget_show(w0); |
| 3174 |
for(j=0;j<10;j++) { |
| 3175 |
st_r[j]=gtk_label_new(" "); |
| 3176 |
gtk_misc_set_alignment(GTK_MISC(st_r[j]),0,0.5); |
| 3177 |
gtk_box_pack_start(GTK_BOX(vb0),st_r[j],FALSE,TRUE,0); |
| 3178 |
gtk_widget_show(st_r[j]); |
| 3179 |
} |
| 3180 |
|
| 3181 |
vb1=gtk_vbox_new(0,3); |
| 3182 |
gtk_notebook_append_page(GTK_NOTEBOOK(nb),vb1,gtk_label_new("Entry histogram")); |
| 3183 |
|
| 3184 |
|
| 3185 |
hist_da=gtk_drawing_area_new(); |
| 3186 |
gtk_drawing_area_size(GTK_DRAWING_AREA(hist_da),niccused*(HBARW+HBARG)+7,250); |
| 3187 |
gtk_widget_set_events(hist_da,GDK_EXPOSURE_MASK); |
| 3188 |
gtk_signal_connect(GTK_OBJECT(hist_da),"expose_event",GTK_SIGNAL_FUNC(hist_expose_event),NULL); |
| 3189 |
gtk_signal_connect(GTK_OBJECT(hist_da),"configure_event",GTK_SIGNAL_FUNC(hist_configure_event),NULL); |
| 3190 |
gtk_box_pack_start(GTK_BOX(vb1),hist_da,FALSE,TRUE,0);gtk_widget_show(hist_da); |
| 3191 |
|
| 3192 |
gtk_widget_show(hist_da); |
| 3193 |
gtk_widget_show(vb1); |
| 3194 |
gtk_widget_show(vb0); |
| 3195 |
gtk_widget_show(nb); |
| 3196 |
} |
| 3197 |
|
| 3198 |
|
| 3199 |
static void stats_quit(GtkDialog*w,int i0,void*p0) { |
| 3200 |
DEB_RF printf("stats_quit()\n"),fflush(stdout); |
| 3201 |
if(i0!=GTK_RESPONSE_DELETE_EVENT&&stats!=NULL) gtk_widget_destroy(stats); |
| 3202 |
stats=NULL; |
| 3203 |
DEB_RF printf("stats_quit()\n"),fflush(stdout); |
| 3204 |
} |
| 3205 |
|
| 3206 |
|
| 3207 |
static int statsdia(void) { |
| 3208 |
if(!stats) stats_init(); |
| 3209 |
stats_upd(); |
| 3210 |
gtk_widget_show(stats); |
| 3211 |
gtk_signal_connect(GTK_OBJECT(stats),"response",GTK_SIGNAL_FUNC(stats_quit),NULL); |
| 3212 |
return 0; |
| 3213 |
} |
| 3214 |
|
| 3215 |
void setposslabel(char*s) { |
| 3216 |
if(!usegui) return; |
| 3217 |
gtk_label_set_text(GTK_LABEL(poss_label),s); |
| 3218 |
} |
| 3219 |
|
| 3220 |
|
| 3221 |
void updatefeas(void) { |
| 3222 |
int i; |
| 3223 |
char t0[MXFL*10+100],t1[MXLE+50],*u[2],p0[MAXICC+1],p1[MAXICC*16+SLEN]; |
| 3224 |
DEB_RF printf("updatefeas()\n"); |
| 3225 |
if(!usegui) return; |
| 3226 |
if(ifamode==0) {setposslabel(""); return;} |
| 3227 |
u[0]=t0; |
| 3228 |
u[1]=t1; |
| 3229 |
p1[0]='\0'; |
| 3230 |
gtk_clist_freeze(GTK_CLIST(clist)); |
| 3231 |
gtk_clist_clear(GTK_CLIST(clist)); |
| 3232 |
if(!isclear(curx,cury)) goto ew0; |
| 3233 |
for(i=0;i<llistn;i++) { |
| 3234 |
ansform(t0,sizeof(t0),llistp[i],llistwlen,llistdm); |
| 3235 |
DEB_RF { printf("ansform : <"); printICCs(lts[llistp[i]].s); printf("> -> <%s>\n",t0); } |
| 3236 |
if(lts[llistp[i]].ans<0) strcpy(t1,""); |
| 3237 |
else sprintf(t1,"%+.1f",log10(ansp[lts[llistp[i]].ans]->score)); |
| 3238 |
DEB_RF printf("gtk_clist_append( <%s> <%s> )\n",u[0],u[1]); |
| 3239 |
gtk_clist_append(GTK_CLIST(clist),u); |
| 3240 |
DEB_RF {int j; for(j=0;t0[j];j++) printf("<%02X>",(unsigned char)t0[j]); printf("\n");} |
| 3241 |
} |
| 3242 |
if(curent>=0&&curword>=0&&words[curword].fe==0) { |
| 3243 |
if(entries[curent].flbm==0) strcpy(p0,""); |
| 3244 |
else getposs(entries+curent,p0,0,0); |
| 3245 |
if(strlen(p0)==0) sprintf(p1," No feasible characters"); |
| 3246 |
else { |
| 3247 |
sprintf(p1," Feasible character%s: ",(strlen(p0)==1)?"":"s"); |
| 3248 |
for(i=0;p0[i];i++) strcat(p1,icctoutf8[(unsigned int)p0[i]]); |
| 3249 |
} |
| 3250 |
} else p1[0]=0; |
| 3251 |
ew0: |
| 3252 |
gtk_clist_thaw(GTK_CLIST(clist)); |
| 3253 |
DEB_RF printf("Setting poss label to >%s<\n",p1); |
| 3254 |
setposslabel(p1); |
| 3255 |
return; |
| 3256 |
} |
| 3257 |
|
| 3258 |
static void syncselmenu() { |
| 3259 |
DEB_GU printf("syncselmenu mode=%d,n=%d\n",selmode,nsel); |
| 3260 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0xf100),selmode==0&&nsel>0); |
| 3261 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0xf201),selmode==2&&nsel==1); |
| 3262 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0xf202),selmode==2&&nsel==1); |
| 3263 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0xf203),selmode==2&&nsel==1); |
| 3264 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0xf204),selmode==2&&nsel>0); |
| 3265 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0xf300),selmode==0&&nsel>0); |
| 3266 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0xf301),(selmode==1||selmode==2)&&nsel>0); |
| 3267 |
} |
| 3268 |
|
| 3269 |
static void syncsymmmenu() {int i,m; |
| 3270 |
gtk_menu_item_activate((GtkMenuItem*)gtk_item_factory_get_widget_by_action(item_factory,0x100+symmr)); |
| 3271 |
gtk_menu_item_activate((GtkMenuItem*)gtk_item_factory_get_widget_by_action(item_factory,0x200+symmm)); |
| 3272 |
gtk_menu_item_activate((GtkMenuItem*)gtk_item_factory_get_widget_by_action(item_factory,0x300+symmd)); |
| 3273 |
m=symmrmask(); for(i=1;i<=12;i++) gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0x100+i),(m>>i)&1); |
| 3274 |
m=symmmmask(); for(i=0;i<= 3;i++) gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0x200+i),(m>>i)&1); |
| 3275 |
m=symmdmask(); for(i=0;i<= 3;i++) gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0x300+i),(m>>i)&1); |
| 3276 |
i=(gshape[gtype]==3||gshape[gtype]==4); |
| 3277 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0xf000),!i); |
| 3278 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0xf001), i); |
| 3279 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0xf002), i); |
| 3280 |
i=(gshape[gtype]>0); |
| 3281 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0x404),!i); |
| 3282 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0x414),!i); |
| 3283 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0x433),!i); |
| 3284 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0x443),!i); |
| 3285 |
gtk_widget_set_sensitive((GtkWidget*)gtk_item_factory_get_widget_by_action(item_factory,0x451),!i); |
| 3286 |
} |
| 3287 |
|
| 3288 |
static void syncifamenu() { |
| 3289 |
gtk_menu_item_activate((GtkMenuItem*)gtk_item_factory_get_widget_by_action(item_factory,0x0500+ifamode)); |
| 3290 |
} |
| 3291 |
|
| 3292 |
|
| 3293 |
void syncgui(void) { |
| 3294 |
if(!usegui) return; |
| 3295 |
if(!isingrid(curx,cury)) {curx=0,cury=0;} |
| 3296 |
if(curdir>=ndir[gtype]&&curdir<100) curdir=0; |
| 3297 |
if(curdir>=100+nvl) curdir=0; |
| 3298 |
gtk_drawing_area_size(GTK_DRAWING_AREA(grid_da),dawidth()+3,daheight()+3); |
| 3299 |
gtk_widget_show(grid_da); |
| 3300 |
syncsymmmenu(); |
| 3301 |
syncselmenu(); |
| 3302 |
syncifamenu(); |
| 3303 |
setwintitle(); |
| 3304 |
draw_init(); |
| 3305 |
refreshall(); |
| 3306 |
curmoved(); |
| 3307 |
} |
| 3308 |
|
| 3309 |
|
| 3310 |
static GtkItemFactoryEntry menu_items[] = { |
| 3311 |
{ "/_File", 0, 0, 0, "<Branch>", 0 }, |
| 3312 |
{ "/File/_New", 0, 0, 0, "<Branch>", 0 }, |
| 3313 |
{ "/File/New/Current shape and size", "<control>N", m_filenew, 0, "<StockItem>", GTK_STOCK_NEW }, |
| 3314 |
{ "/File/New/Blank 9x9", 0, m_filenew, 0x090980, 0, 0 }, |
| 3315 |
{ "/File/New/Blank 10x10", 0, m_filenew, 0x0a0a80, 0, 0 }, |
| 3316 |
{ "/File/New/Blank 11x11", 0, m_filenew, 0x0b0b80, 0, 0 }, |
| 3317 |
{ "/File/New/Blank 11x13", 0, m_filenew, 0x0b0d80, 0, 0 }, |
| 3318 |
{ "/File/New/Blank 12x12", 0, m_filenew, 0x0c0c80, 0, 0 }, |
| 3319 |
{ "/File/New/Blank 13x11", 0, m_filenew, 0x0d0b80, 0, 0 }, |
| 3320 |
{ "/File/New/Blank 13x13", 0, m_filenew, 0x0d0d80, 0, 0 }, |
| 3321 |
{ "/File/New/Blank 14x14", 0, m_filenew, 0x0e0e80, 0, 0 }, |
| 3322 |
{ "/File/New/Blank 15x15", 0, m_filenew, 0x0f0f80, 0, 0 }, |
| 3323 |
{ "/File/New/Blocked 13x13 template", 0, 0, 0, "<Branch>", 0 }, |
| 3324 |
{ "/File/New/Blocked 13x13 template/No unches on edges", 0, m_filenew, 0x0d0d00, 0, 0 }, |
| 3325 |
{ "/File/New/Blocked 13x13 template/Unches left and right", 0, m_filenew, 0x0d0d01, 0, 0 }, |
| 3326 |
{ "/File/New/Blocked 13x13 template/Unches top and bottom", 0, m_filenew, 0x0d0d02, 0, 0 }, |
| 3327 |
{ "/File/New/Blocked 13x13 template/Unches on all edges", 0, m_filenew, 0x0d0d03, 0, 0 }, |
| 3328 |
{ "/File/New/Blocked 15x15 template", 0, 0, 0, "<Branch>", 0 }, |
| 3329 |
{ "/File/New/Blocked 15x15 template/No unches on edges", 0, m_filenew, 0x0f0f00, 0, 0 }, |
| 3330 |
{ "/File/New/Blocked 15x15 template/Unches left and right", 0, m_filenew, 0x0f0f01, 0, 0 }, |
| 3331 |
{ "/File/New/Blocked 15x15 template/Unches top and bottom", 0, m_filenew, 0x0f0f02, 0, 0 }, |
| 3332 |
{ "/File/New/Blocked 15x15 template/Unches on all edges", 0, m_filenew, 0x0f0f03, 0, 0 }, |
| 3333 |
{ "/File/New/Blocked 17x17 template", 0, 0, 0, "<Branch>", 0 }, |
| 3334 |
{ "/File/New/Blocked 17x17 template/No unches on edges", 0, m_filenew, 0x111100, 0, 0 }, |
| 3335 |
{ "/File/New/Blocked 17x17 template/Unches left and right", 0, m_filenew, 0x111101, 0, 0 }, |
| 3336 |
{ "/File/New/Blocked 17x17 template/Unches top and bottom", 0, m_filenew, 0x111102, 0, 0 }, |
| 3337 |
{ "/File/New/Blocked 17x17 template/Unches on all edges", 0, m_filenew, 0x111103, 0, 0 }, |
| 3338 |
{ "/File/New/Blocked 19x19 template", 0, 0, 0, "<Branch>", 0 }, |
| 3339 |
{ "/File/New/Blocked 19x19 template/No unches on edges", 0, m_filenew, 0x131300, 0, 0 }, |
| 3340 |
{ "/File/New/Blocked 19x19 template/Unches left and right", 0, m_filenew, 0x131301, 0, 0 }, |
| 3341 |
{ "/File/New/Blocked 19x19 template/Unches top and bottom", 0, m_filenew, 0x131302, 0, 0 }, |
| 3342 |
{ "/File/New/Blocked 19x19 template/Unches on all edges", 0, m_filenew, 0x131303, 0, 0 }, |
| 3343 |
{ "/File/New/Blocked 21x21 template", 0, 0, 0, "<Branch>", 0 }, |
| 3344 |
{ "/File/New/Blocked 21x21 template/No unches on edges", 0, m_filenew, 0x151500, 0, 0 }, |
| 3345 |
{ "/File/New/Blocked 21x21 template/Unches left and right", 0, m_filenew, 0x151501, 0, 0 }, |
| 3346 |
{ "/File/New/Blocked 21x21 template/Unches top and bottom", 0, m_filenew, 0x151502, 0, 0 }, |
| 3347 |
{ "/File/New/Blocked 21x21 template/Unches on all edges", 0, m_filenew, 0x151503, 0, 0 }, |
| 3348 |
{ "/File/New/Blocked 23x23 template", 0, 0, 0, "<Branch>", 0 }, |
| 3349 |
{ "/File/New/Blocked 23x23 template/No unches on edges", 0, m_filenew, 0x171700, 0, 0 }, |
| 3350 |
{ "/File/New/Blocked 23x23 template/Unches left and right", 0, m_filenew, 0x171701, 0, 0 }, |
| 3351 |
{ "/File/New/Blocked 23x23 template/Unches top and bottom", 0, m_filenew, 0x171702, 0, 0 }, |
| 3352 |
{ "/File/New/Blocked 23x23 template/Unches on all edges", 0, m_filenew, 0x171703, 0, 0 }, |
| 3353 |
{ "/File/New/Blocked 25x25 template", 0, 0, 0, "<Branch>", 0 }, |
| 3354 |
{ "/File/New/Blocked 25x25 template/No unches on edges", 0, m_filenew, 0x191900, 0, 0 }, |
| 3355 |
{ "/File/New/Blocked 25x25 template/Unches left and right", 0, m_filenew, 0x191901, 0, 0 }, |
| 3356 |
{ "/File/New/Blocked 25x25 template/Unches top and bottom", 0, m_filenew, 0x191902, 0, 0 }, |
| 3357 |
{ "/File/New/Blocked 25x25 template/Unches on all edges", 0, m_filenew, 0x191903, 0, 0 }, |
| 3358 |
{ "/File/sep0", 0, 0, 0, "<Separator>", 0 }, |
| 3359 |
{ "/File/_Open...", "<control>O", m_fileopen, 0, "<StockItem>", GTK_STOCK_OPEN }, |
| 3360 |
{ "/File/_Save", "<control>S", m_filesave, 0, "<StockItem>", GTK_STOCK_SAVE }, |
| 3361 |
{ "/File/Save _as...", 0, m_filesaveas, 0, "<StockItem>", GTK_STOCK_SAVE_AS }, |
| 3362 |
{ "/File/sep1", 0, 0, 0, "<Separator>", 0 }, |
| 3363 |
{ "/File/Export _blank grid image", 0, 0, 0, "<Branch>", 0 }, |
| 3364 |
{ "/File/Export blank grid image/as _EPS...", 0, m_fileexport, 0x401, 0, 0 }, |
| 3365 |
{ "/File/Export blank grid image/as _SVG...", 0, m_fileexport, 0x402, 0, 0 }, |
| 3366 |
{ "/File/Export blank grid image/as _PNG...", 0, m_fileexport, 0x403, 0, 0 }, |
| 3367 |
{ "/File/Export blank grid image/as _HTML...", 0, m_fileexport, 0x404, 0, 0 }, |
| 3368 |
{ "/File/Export _filled grid image", 0, 0, 0, "<Branch>", 0 }, |
| 3369 |
{ "/File/Export filled grid image/as _EPS...", 0, m_fileexport, 0x411, 0, 0 }, |
| 3370 |
{ "/File/Export filled grid image/as _SVG...", 0, m_fileexport, 0x412, 0, 0 }, |
| 3371 |
{ "/File/Export filled grid image/as _PNG...", 0, m_fileexport, 0x413, 0, 0 }, |
| 3372 |
{ "/File/Export filled grid image/as _HTML...", 0, m_fileexport, 0x414, 0, 0 }, |
| 3373 |
{ "/File/Export ans_wers", 0, 0, 0, "<Branch>", 0 }, |
| 3374 |
{ "/File/Export answers/As _text...", 0, m_fileexport, 0x420, 0, 0 }, |
| 3375 |
{ "/File/Export answers/As _HTML...", 0, m_fileexport, 0x423, 0, 0 }, |
| 3376 |
{ "/File/Export _puzzle", 0, 0, 0, "<Branch>", 0 }, |
| 3377 |
{ "/File/Export puzzle/As _HTML...", 0, m_fileexport, 0x433, 0, 0 }, |
| 3378 |
{ "/File/Export puzzle/As HTML+_SVG...", 0, m_fileexport, 0x434, 0, 0 }, |
| 3379 |
{ "/File/Export puzzle/As HTML+_PNG...", 0, m_fileexport, 0x435, 0, 0 }, |
| 3380 |
{ "/File/Export so_lution", 0, 0, 0, "<Branch>", 0 }, |
| 3381 |
{ "/File/Export solution/As _HTML...", 0, m_fileexport, 0x443, 0, 0 }, |
| 3382 |
{ "/File/Export solution/As HTML+_SVG...", 0, m_fileexport, 0x444, 0, 0 }, |
| 3383 |
{ "/File/Export solution/As HTML+_PNG...", 0, m_fileexport, 0x445, 0, 0 }, |
| 3384 |
{ "/File/Export o_ther format", 0, 0, 0, "<Branch>", 0 }, |
| 3385 |
{ "/File/Export other format/_Crossword Compiler XML...", 0, m_fileexport, 0x451, 0, 0 }, |
| 3386 |
{ "/File/sep2", 0, 0, 0, "<Separator>", 0 }, |
| 3387 |
{ "/File/I_mport free light paths", 0, m_importvls, 0, 0, 0 }, |
| 3388 |
{ "/File/E_xport free light paths", 0, m_exportvls, 0, 0, 0 }, |
| 3389 |
{ "/File/sep3", 0, 0, 0, "<Separator>", 0 }, |
| 3390 |
{ "/File/_Quit", "<control>Q", m_filequit, 0, "<StockItem>", GTK_STOCK_QUIT }, |
| 3391 |
{ "/_Edit", 0, 0, 0, "<Branch>", 0 }, |
| 3392 |
{ "/Edit/_Undo", "<control>Z", m_undo, 0, "<StockItem>", GTK_STOCK_UNDO }, |
| 3393 |
{ "/Edit/_Redo", "<control>Y", m_redo, 0, "<StockItem>", GTK_STOCK_REDO }, |
| 3394 |
{ "/Edit/sep1", 0, 0, 0, "<Separator>", 0 }, |
| 3395 |
{ "/Edit/_Solid block", "Insert", m_editblock, 0, 0, 0 }, |
| 3396 |
{ "/Edit/_Bar before", "Return", m_editbarb, 0, 0, 0 }, |
| 3397 |
{ "/Edit/_Empty", "Delete", m_editempty, 0, 0, 0 }, |
| 3398 |
{ "/Edit/_Cutout", "<control>C", m_editcutout, 0, 0, 0 }, |
| 3399 |
{ "/Edit/_Merge with next", "<control>M", m_editmerge, 0, 0, 0 }, |
| 3400 |
{ "/Edit/sep2", 0, 0, 0, "<Separator>", 0 }, |
| 3401 |
{ "/Edit/Cell c_ontents...", "<control>I", m_cellcont, 0, 0, 0 }, |
| 3402 |
{ "/Edit/_Light contents...", "<control>L", m_editlight, 0, 0, 0 }, |
| 3403 |
{ "/Edit/Clear _all cells", "<control>X", m_eraseall, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
| 3404 |
{ "/Edit/C_lear selected cells", "<shift><control>X", m_erasesel, 0xf100, "<StockItem>", GTK_STOCK_CLEAR }, |
| 3405 |
{ "/Edit/sep3", 0, 0, 0, "<Separator>", 0 }, |
| 3406 |
|
| 3407 |
|
| 3408 |
|
| 3409 |
{ "/Edit/_Free light", 0, 0, 0, "<Branch>", 0 }, |
| 3410 |
{ "/Edit/Free light/_Start new", 0, m_vlnew, 0xf200, 0, 0 }, |
| 3411 |
{ "/Edit/Free light/_Extend selected", "<control>E", m_vlextend, 0xf201, 0, 0 }, |
| 3412 |
{ "/Edit/Free light/_Shorten selected", "<control>D", m_vlcurtail, 0xf202, 0, 0 }, |
| 3413 |
{ "/Edit/Free light/_Modify selected", 0, m_vlmodify, 0xf203, 0, 0 }, |
| 3414 |
{ "/Edit/Free light/_Delete selected", 0, m_vldelete, 0xf204, 0, 0 }, |
| 3415 |
{ "/Edit/sep6", 0, 0, 0, "<Separator>", 0 }, |
| 3416 |
{ "/Edit/Flip in main dia_gonal", 0, m_editflip, 0xf000, 0, 0 }, |
| 3417 |
{ "/Edit/Rotate cloc_kwise", "greater", m_editrot, 0xf001, 0, 0 }, |
| 3418 |
{ "/Edit/Rotate a_nticlockwise", "less", m_editrot, 0xf002, 0, 0 }, |
| 3419 |
{ "/Edit/_Delete", 0, 0, 0, "<Branch>", 0 }, |
| 3420 |
{ "/Edit/Delete/_Row or annulus", 0, m_delrow, 0, 0, 0 }, |
| 3421 |
{ "/Edit/Delete/_Column or radius", 0, m_delcol, 0, 0, 0 }, |
| 3422 |
{ "/Edit/_Insert", 0, 0, 0, "<Branch>", 0 }, |
| 3423 |
{ "/Edit/Insert/Row _above or outer annulus", 0, m_insrow, 0, 0, 0 }, |
| 3424 |
{ "/Edit/Insert/Row _below or inner annulus", 0, m_insrow, 1, 0, 0 }, |
| 3425 |
{ "/Edit/Insert/Column to _left or previous radius", 0, m_inscol, 0, 0, 0 }, |
| 3426 |
{ "/Edit/Insert/Column to _right or next radius", 0, m_inscol, 1, 0, 0 }, |
| 3427 |
{ "/Edit/sep7", 0, 0, 0, "<Separator>", 0 }, |
| 3428 |
{ "/Edit/_Zoom", 0, 0, 0, "<Branch>", 0 }, |
| 3429 |
{ "/Edit/Zoom/_Out", "<control>minus", m_zoom, -2, 0, 0 }, |
| 3430 |
{ "/Edit/Zoom/_1 50%", "<control>8", m_zoom, 0, 0, 0 }, |
| 3431 |
{ "/Edit/Zoom/_2 71%", "<control>9", m_zoom, 1, 0, 0 }, |
| 3432 |
{ "/Edit/Zoom/_3 100%", "<control>0", m_zoom, 2, 0, 0 }, |
| 3433 |
{ "/Edit/Zoom/_4 141%", "<control>1", m_zoom, 3, 0, 0 }, |
| 3434 |
{ "/Edit/Zoom/_5 200%", "<control>2", m_zoom, 4, 0, 0 }, |
| 3435 |
{ "/Edit/Zoom/_In", "<control>plus", m_zoom, -1, 0, 0 }, |
| 3436 |
{ "/Edit/Show s_tatistics", 0, m_showstats, 0, 0, 0 }, |
| 3437 |
{ "/Edit/_Preferences...", 0, m_editprefs, 0, "<StockItem>", GTK_STOCK_PREFERENCES }, |
| 3438 |
{ "/_Properties", 0, 0, 0, "<Branch>", 0 }, |
| 3439 |
{ "/Properties/_Grid properties...", 0, m_editgprop, 0, "<StockItem>", GTK_STOCK_PROPERTIES }, |
| 3440 |
{ "/Properties/Default _cell properties...", 0, m_dsprop, 0, 0, 0 }, |
| 3441 |
{ "/Properties/Selected c_ell properties...", 0, m_sprop, 0xf300, 0, 0 }, |
| 3442 |
{ "/Properties/Default _light properties...", 0, m_dlprop, 0, 0, 0 }, |
| 3443 |
{ "/Properties/Selected l_ight properties...", 0, m_lprop, 0xf301, 0, 0 }, |
| 3444 |
{ "/_Select", 0, 0, 0, "<Branch>", 0 }, |
| 3445 |
{ "/Select/Current _cell", "<shift>C", m_selcell, 0, 0, 0 }, |
| 3446 |
{ "/Select/Current _light", "<shift>L", m_sellight, 0, 0, 0 }, |
| 3447 |
{ "/Select/Cell _mode <> light mode", "<shift>M", m_selmode, 0, 0, 0 }, |
| 3448 |
{ "/Select/_Free light", "<shift>F", m_selfvl, 0, 0, 0 }, |
| 3449 |
{ "/Select/sep0", 0, 0, 0, "<Separator>", 0 }, |
| 3450 |
{ "/Select/_All", "<shift>A", m_selall, 0, 0, 0 }, |
| 3451 |
{ "/Select/_Invert", "<shift>I", m_selinv, 0, 0, 0 }, |
| 3452 |
{ "/Select/_Nothing", "<shift>N", m_selnone, 0, 0, 0 }, |
| 3453 |
{ "/Select/sep1", 0, 0, 0, "<Separator>", 0 }, |
| 3454 |
{ "/Select/Cell_s", 0, 0, 0, "<Branch>", 0 }, |
| 3455 |
{ "/Select/Cells/overriding default _properties", 0, m_selcover, 0, 0, 0 }, |
| 3456 |
{ "/Select/Cells/flagged for _answer treatment", 0, m_selctreat, 0, 0, 0 }, |
| 3457 |
{ "/Select/Cells/that are _unchecked", 0, m_selcunch, 0, 0, 0 }, |
| 3458 |
{ "/Select/Li_ghts", 0, 0, 0, "<Branch>", 0 }, |
| 3459 |
{ "/Select/Lights/_in current direction", 0, m_sellpar, 0, 0, 0 }, |
| 3460 |
{ "/Select/Lights/overriding default _properties", 0, m_sellover, 0, 0, 0 }, |
| 3461 |
{ "/Select/Lights/with answer treatment _enabled", 0, m_selltreat, 0, 0, 0 }, |
| 3462 |
{ "/Select/Lights/with _double or more unches", 0, m_selviol, 1, 0, 0 }, |
| 3463 |
{ "/Select/Lights/with _triple or more unches", 0, m_selviol, 2, 0, 0 }, |
| 3464 |
{ "/Select/Lights/that are _underchecked", 0, m_selviol, 4, 0, 0 }, |
| 3465 |
{ "/Select/Lights/that are _overchecked", 0, m_selviol, 8, 0, 0 }, |
| 3466 |
{ "/Sy_mmetry", 0, 0, 0, "<Branch>", 0 }, |
| 3467 |
{ "/Symmetry/_None", 0, m_symmclr, 0, 0, 0 }, |
| 3468 |
{ "/Symmetry/sep1", 0, 0, 0, "<Separator>", 0 }, |
| 3469 |
{ "/Symmetry/N_o rotational", 0, m_symm0, 0x0101, "<RadioItem>", 0 }, |
| 3470 |
{ "/Symmetry/_Twofold rotational", 0, m_symm0, 0x0102, "/Symmetry/No rotational" , 0 }, |
| 3471 |
{ "/Symmetry/Threefold rotational", 0, m_symm0, 0x0103, "/Symmetry/Twofold rotational" , 0 }, |
| 3472 |
{ "/Symmetry/_Fourfold rotational", 0, m_symm0, 0x0104, "/Symmetry/Threefold rotational" , 0 }, |
| 3473 |
{ "/Symmetry/Fivefold rotational", 0, m_symm0, 0x0105, "/Symmetry/Fourfold rotational" , 0 }, |
| 3474 |
{ "/Symmetry/Sixfold rotational", 0, m_symm0, 0x0106, "/Symmetry/Fivefold rotational" , 0 }, |
| 3475 |
{ "/Symmetry/Sevenfold rotational", 0, m_symm0, 0x0107, "/Symmetry/Sixfold rotational" , 0 }, |
| 3476 |
{ "/Symmetry/Eightfold rotational", 0, m_symm0, 0x0108, "/Symmetry/Sevenfold rotational" , 0 }, |
| 3477 |
{ "/Symmetry/Ninefold rotational", 0, m_symm0, 0x0109, "/Symmetry/Eightfold rotational" , 0 }, |
| 3478 |
{ "/Symmetry/Tenfold rotational", 0, m_symm0, 0x010a, "/Symmetry/Ninefold rotational" , 0 }, |
| 3479 |
{ "/Symmetry/Elevenfold rotational", 0, m_symm0, 0x010b, "/Symmetry/Tenfold rotational" , 0 }, |
| 3480 |
{ "/Symmetry/Twelvefold rotational", 0, m_symm0, 0x010c, "/Symmetry/Elevenfold rotational", 0 }, |
| 3481 |
{ "/Symmetry/sep2", 0, 0, 0, "<Separator>", 0 }, |
| 3482 |
{ "/Symmetry/No mirror", 0, m_symm1, 0x0200, "<RadioItem>", 0 }, |
| 3483 |
{ "/Symmetry/Left-right mirror", 0, m_symm1, 0x0201, "/Symmetry/No mirror", 0 }, |
| 3484 |
{ "/Symmetry/Up-down mirror", 0, m_symm1, 0x0202, "/Symmetry/Left-right mirror", 0 }, |
| 3485 |
{ "/Symmetry/Both", 0, m_symm1, 0x0203, "/Symmetry/Up-down mirror", 0 }, |
| 3486 |
{ "/Symmetry/sep3", 0, 0, 0, "<Separator>", 0 }, |
| 3487 |
{ "/Symmetry/No duplication", 0, m_symm2, 0x0300, "<RadioItem>", 0 }, |
| 3488 |
{ "/Symmetry/Left-right duplication", 0, m_symm2, 0x0301, "/Symmetry/No duplication", 0 }, |
| 3489 |
{ "/Symmetry/Up-down duplication", 0, m_symm2, 0x0302, "/Symmetry/Left-right duplication", 0 }, |
| 3490 |
{ "/Symmetry/Both", 0, m_symm2, 0x0303, "/Symmetry/Up-down duplication", 0 }, |
| 3491 |
{ "/_Autofill", 0, 0, 0, "<Branch>", 0 }, |
| 3492 |
{ "/Autofill/_Dictionaries...", 0, m_dictionaries, 0, 0, 0 }, |
| 3493 |
{ "/Autofill/Anal_yse dictionaries...", 0, m_dstats, 0, 0, 0 }, |
| 3494 |
{ "/Autofill/_Alphabet...", 0, m_alphabet, 0, 0, 0 }, |
| 3495 |
{ "/Autofill/Answer _treatment...", 0, m_afctreat, 0, 0, 0 }, |
| 3496 |
{ "/Autofill/sep1", 0, 0, 0, "<Separator>", 0 }, |
| 3497 |
{ "/Autofill/Auto_fill", "<control>G", m_autofill, 1, "<StockItem>", GTK_STOCK_EXECUTE }, |
| 3498 |
{ "/Autofill/Autofill _selected cells", "<shift><control>G", m_autofill, 2, "<StockItem>", GTK_STOCK_EXECUTE }, |
| 3499 |
{ "/Autofill/sep2", 0, 0, 0, "<Separator>", 0 }, |
| 3500 |
{ "/Autofill/_Interactive assistance", 0, 0, 0, "<Branch>", 0 }, |
| 3501 |
{ "/Autofill/Interactive assistance/_Off", 0, m_ifamode, 0x0500, "<RadioItem>", 0 }, |
| 3502 |
{ "/Autofill/Interactive assistance/_Light only", 0, m_ifamode, 0x0501, "/Autofill/Interactive assistance/Off", 0 }, |
| 3503 |
{ "/Autofill/Interactive assistance/_Entire grid", 0, m_ifamode, 0x0502, "/Autofill/Interactive assistance/Light only", 0 }, |
| 3504 |
{ "/Autofill/Accept _hints", "<control>A", m_accept, 0, 0, 0 }, |
| 3505 |
{ "/Autofill/sep2", 0, 0, 0, "<Separator>", 0 }, |
| 3506 |
{ "/Autofill/_Unban all answers", 0, m_unban, 0, 0, 0 }, |
| 3507 |
{ "/_Help", 0, 0, 0, "<LastBranch>", 0 }, |
| 3508 |
{ "/Help/_About", 0, m_helpabout, 0, "<StockItem>", GTK_STOCK_ABOUT }, |
| 3509 |
}; |
| 3510 |
|
| 3511 |
|
| 3512 |
void startgtk(void) { |
| 3513 |
GtkAccelGroup*accel_group; |
| 3514 |
GtkWidget *vbox,*hbox,*menubar,*zmin,*zmout; |
| 3515 |
int w,h; |
| 3516 |
|
| 3517 |
pxsq=zoompx[zoomf]; |
| 3518 |
|
| 3519 |
mainw=gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 3520 |
gtk_widget_set_name(mainw,"Qxw"); |
| 3521 |
w=gdk_screen_get_width (gdk_display_get_default_screen(gdk_display_get_default())); |
| 3522 |
h=gdk_screen_get_height(gdk_display_get_default_screen(gdk_display_get_default())); |
| 3523 |
if(h<300||h>MAINWHEIGHT) h=MAINWHEIGHT; |
| 3524 |
if(w<400||w>MAINWWIDTH ) w=MAINWWIDTH ; |
| 3525 |
gtk_window_set_default_size(GTK_WINDOW(mainw),w,h); |
| 3526 |
gtk_window_set_title(GTK_WINDOW(mainw),"Qxw"); |
| 3527 |
gtk_window_set_position(GTK_WINDOW(mainw),GTK_WIN_POS_CENTER); |
| 3528 |
|
| 3529 |
|
| 3530 |
vbox=gtk_vbox_new(FALSE,0); |
| 3531 |
gtk_container_add(GTK_CONTAINER(mainw),vbox); |
| 3532 |
|
| 3533 |
|
| 3534 |
accel_group=gtk_accel_group_new(); |
| 3535 |
item_factory=gtk_item_factory_new(GTK_TYPE_MENU_BAR,"<main>",accel_group); |
| 3536 |
gtk_item_factory_create_items(item_factory,sizeof(menu_items)/sizeof(menu_items[0]),menu_items,NULL); |
| 3537 |
gtk_window_add_accel_group(GTK_WINDOW(mainw),accel_group); |
| 3538 |
menubar=gtk_item_factory_get_widget(item_factory,"<main>"); |
| 3539 |
gtk_box_pack_start(GTK_BOX(vbox),menubar,FALSE,TRUE,0); |
| 3540 |
|
| 3541 |
|
| 3542 |
paned=gtk_hpaned_new(); |
| 3543 |
gtk_box_pack_start(GTK_BOX(vbox),paned,TRUE,TRUE,0); |
| 3544 |
|
| 3545 |
|
| 3546 |
grid_sw=gtk_scrolled_window_new(NULL,NULL); |
| 3547 |
gtk_container_set_border_width(GTK_CONTAINER(grid_sw),10); |
| 3548 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(grid_sw),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); |
| 3549 |
gtk_paned_pack1(GTK_PANED(paned),grid_sw,1,1); |
| 3550 |
|
| 3551 |
list_sw=gtk_scrolled_window_new(NULL,NULL); |
| 3552 |
gtk_container_set_border_width(GTK_CONTAINER(list_sw),10); |
| 3553 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(list_sw),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); |
| 3554 |
gtk_paned_pack2(GTK_PANED(paned),list_sw,0,1); |
| 3555 |
gtk_paned_set_position(GTK_PANED(paned),MAINWWIDTH-FLISTWIDTH); |
| 3556 |
|
| 3557 |
|
| 3558 |
grid_da=gtk_drawing_area_new(); |
| 3559 |
gtk_drawing_area_size(GTK_DRAWING_AREA(grid_da),100,100); |
| 3560 |
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(grid_sw),grid_da); |
| 3561 |
GTK_WIDGET_SET_FLAGS(grid_da,GTK_CAN_FOCUS); |
| 3562 |
gtk_widget_set_events(grid_da,GDK_EXPOSURE_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_KEY_PRESS_MASK|GDK_POINTER_MOTION_MASK|GDK_SCROLL_MASK); |
| 3563 |
|
| 3564 |
|
| 3565 |
|
| 3566 |
clist=gtk_clist_new(1); |
| 3567 |
gtk_clist_set_column_width(GTK_CLIST(clist),0,FLISTWIDTH-38); |
| 3568 |
|
| 3569 |
gtk_clist_set_column_title(GTK_CLIST(clist),0,"Feasible words"); |
| 3570 |
|
| 3571 |
gtk_clist_column_titles_passive(GTK_CLIST(clist)); |
| 3572 |
gtk_clist_column_titles_show(GTK_CLIST(clist)); |
| 3573 |
gtk_clist_set_selection_mode(GTK_CLIST(clist),GTK_SELECTION_SINGLE); |
| 3574 |
gtk_container_add(GTK_CONTAINER(list_sw),clist); |
| 3575 |
|
| 3576 |
g_signal_connect(clist,"button-press-event",GTK_SIGNAL_FUNC(clist_button),NULL); |
| 3577 |
|
| 3578 |
|
| 3579 |
hbox=gtk_hbox_new(FALSE,0); |
| 3580 |
zmout=gtk_button_new(); gtk_button_set_image(GTK_BUTTON(zmout),gtk_image_new_from_stock(GTK_STOCK_ZOOM_OUT,GTK_ICON_SIZE_MENU)); gtk_box_pack_start(GTK_BOX(hbox),zmout,FALSE,FALSE,0); |
| 3581 |
gtk_signal_connect(GTK_OBJECT(zmout),"clicked",GTK_SIGNAL_FUNC(m_zoom),(gpointer)-2); |
| 3582 |
zmin =gtk_button_new(); gtk_button_set_image(GTK_BUTTON(zmin ),gtk_image_new_from_stock(GTK_STOCK_ZOOM_IN ,GTK_ICON_SIZE_MENU)); gtk_box_pack_start(GTK_BOX(hbox),zmin ,FALSE,FALSE,0); |
| 3583 |
gtk_signal_connect(GTK_OBJECT(zmin ),"clicked",GTK_SIGNAL_FUNC(m_zoom),(gpointer)-1); |
| 3584 |
poss_label=gtk_label_new(" Feasible characters:"); |
| 3585 |
gtk_box_pack_start(GTK_BOX(hbox),poss_label,FALSE,FALSE,0); |
| 3586 |
gtk_box_pack_end(GTK_BOX(vbox),hbox,FALSE,FALSE,0); |
| 3587 |
|
| 3588 |
gtk_signal_connect(GTK_OBJECT(grid_da),"expose_event",GTK_SIGNAL_FUNC(expose_event),NULL); |
| 3589 |
gtk_signal_connect(GTK_OBJECT(grid_da),"configure_event",GTK_SIGNAL_FUNC(configure_event),NULL); |
| 3590 |
gtk_signal_connect(GTK_OBJECT(clist),"select_row",GTK_SIGNAL_FUNC(selrow),NULL); |
| 3591 |
|
| 3592 |
gtk_signal_connect(GTK_OBJECT(grid_da),"button_press_event",GTK_SIGNAL_FUNC(button_press_event),NULL); |
| 3593 |
gtk_signal_connect(GTK_OBJECT(grid_da),"button_release_event",GTK_SIGNAL_FUNC(button_press_event),NULL); |
| 3594 |
gtk_signal_connect_after(GTK_OBJECT(grid_da),"key_press_event",GTK_SIGNAL_FUNC(keypress),NULL); |
| 3595 |
gtk_signal_connect(GTK_OBJECT(grid_da),"motion_notify_event",GTK_SIGNAL_FUNC(mousemove),NULL); |
| 3596 |
gtk_signal_connect(GTK_OBJECT(grid_da),"scroll-event",GTK_SIGNAL_FUNC(mousescroll),NULL); |
| 3597 |
|
| 3598 |
gtk_signal_connect(GTK_OBJECT(mainw),"delete_event",GTK_SIGNAL_FUNC(w_delete),NULL); |
| 3599 |
gtk_signal_connect(GTK_OBJECT(mainw),"destroy",GTK_SIGNAL_FUNC(w_destroy),NULL); |
| 3600 |
|
| 3601 |
gtk_widget_show_all(mainw); |
| 3602 |
gtk_window_set_focus(GTK_WINDOW(mainw),grid_da); |
| 3603 |
} |
| 3604 |
|
| 3605 |
void stopgtk(void) { |
| 3606 |
} |
| 3607 |
|
| 3608 |
|