4 * Handling the Template Window Menu
6 * © 1994-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * This file is part of Straylight's Glass.
13 * Glass is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
18 * Glass is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with Glass. If not, write to the Free Software Foundation,
25 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 /*----- Header files ------------------------------------------------------*/
31 * ANSI standard headers
44 #include "steel/Steel.h"
46 #include "steel/buttons.h"
47 #include "steel/choices.h"
48 #include "steel/bbc.h"
49 #include "steel/buffer.h"
50 #include "steel/tearoff.h"
71 /*----- Private data ------------------------------------------------------*/
73 static int window__menuX; /* x-position of pointer on menu click */
74 static int window__menuY; /* y-position of pointer on menu click */
75 static int window__newIcons; /* Number of new icon types defined */
77 static glass_windPointer* window__menuWin; /* Which window owns the menu */
79 static tearoff window__mRoot; /* Root of menu structure */
80 static tearoff window__mMisc; /* Misc submenu */
81 static tearoff window__mSelect; /* Select submenu */
82 static tearoff window__mButton; /* Button type submenu */
83 static tearoff window__mIcon; /* Icon submenu */
84 static tearoff window__mCreate; /* Icon types submenu */
85 static tearoff window__mGuide; /* Guides submenu */
87 /*----- Main code ---------------------------------------------------------*/
90 * glass_windPointer *window__menuOwner(void)
93 * Returns which window currently owns the menu.
96 * A pointer to the window's anchor block.
99 glass_windPointer *window__menuOwner(void)
101 return (window__menuWin);
105 * void window__doTable(unsigned short *p,int s,unsigned int f,tearoff t)
108 * Updates a tearoff menu using the given table.
111 * unsigned short *p == pointer to shade flags table
112 * int s == number of items in table
113 * unsigned int f == which flags to use to mask with
114 * tearoff t == which tearoff menu to play with
117 static void window__doTable(const unsigned short *p,
118 int s,unsigned int f,tearoff t)
120 unsigned int *tbl=(unsigned int *)p;
125 w = (i&1 ? w>>16 : *tbl++);
126 tearoff_shadeItem(t,i+1,(w & f)!=0);
131 * void window__updateMenu(glass_windPointer *w)
134 * Updates the menu attached to the main window.
137 * glass_windPointer *w == pointer to owning menu
140 void window__updateMenu(glass_windPointer *w)
145 glass_windPointer *wso=window_selectionOwner();
147 /* --- Redesign --- *
149 * Based on the Sapphire idea, we define a number of shade flags,
150 * and a big table which says which items need to be shaded when.
152 * The table is carefully organised so as not to give clues about how
153 * to implement test mode. This isn't important.
156 #define s_all (1<<15)
158 #define s_guide (1<<0 | s_all)
159 #define s_gsel (1<<1 | s_all)
160 #define s_sel (1<<2 | s_all)
161 #define s_icon (1<<3 | s_all)
162 #define s_ren (1<<4 | s_all)
163 #define s_copy (1<<5 | s_all)
164 #define s_grid (1<<6 | s_all)
167 #define s_test (1<<7 | s_all)
169 #define s_test (s_all)
172 #define s_qs (s_test | s_ren)
173 #define s_s (s_sel | s_qs)
175 /* --- Shading table --- *
177 * Each entry packed into a single byte. This is quite good, for C ;-)
180 const static unsigned short root[]=
181 { s_all, s_all, s_test, s_qs, s_qs, s_qs, s_qs };
183 const static unsigned short misc[]=
184 { s_all, s_qs, s_ren, s_qs, s_qs, s_all };
186 const static unsigned short select[]=
187 { s_icon|s_qs, s_s, s_qs|s_copy, s_s,
188 s_sel|s_test, s_s, s_s, s_s, s_s,
192 const static unsigned short icon[]=
193 { s_qs, s_qs, s_qs };
195 const static unsigned short guide[]=
196 { s_qs|s_guide, s_qs|s_gsel, s_qs|s_gsel, s_qs, s_qs };
198 /* --- Build the mask word --- */
206 /* --- Work out guide status --- */
209 for (i=0;i<glass_GUIDELIMIT;i++)
211 if (w->guide[i].active)
213 if (w->guide[i].selected)
217 /* --- Now set flags appropriately --- */
219 if (!(gflags & 1)) sflags|=s_guide & ~s_all;
220 if (!(gflags & 2)) sflags|=s_gsel & ~s_all;
221 if (!w->selno) sflags|=s_sel & ~s_all;
222 if (!w->def->desc.w.nicons) sflags|=s_icon & ~s_all;
223 if (w->renumber) sflags|=s_ren & ~s_all;
224 if (!wso || !wso->selno) sflags|=s_copy & ~s_all;
225 if (!w->gridLock) sflags|=s_grid & ~s_all;
228 if (w->testMode) sflags|=s_test & ~s_all;
232 /* --- Now shade all the items --- */
234 window__doTable(root,sizeof(root)/2,sflags,window__mRoot);
235 window__doTable(misc,sizeof(misc)/2,sflags,window__mMisc);
236 window__doTable(select,sizeof(select)/2,sflags,window__mSelect);
237 window__doTable(icon,sizeof(icon)/2,sflags,window__mIcon);
238 window__doTable(guide,sizeof(guide)/2,sflags,window__mGuide);
241 tearoff_shadeItem(window__mButton,i+1,(s_s & sflags)!=0);
243 for (i=0;i<window__newIcons;i++)
244 tearoff_shadeItem(window__mCreate,i+1,(s_qs & sflags)!=0);
246 /* --- Tick the items that need it --- */
249 tearoff_selectItem(window__mMisc,glass_TWMTEST,w && w->testMode);
251 tearoff_selectItem(window__mSelect,glass_TWSORDER,w && w->renumber);
253 /* --- That's it, then --- *
255 * We need to remember which window all of this applies to so that the
256 * user doesn't get all confused.
263 * void window__gridBox(glass_windPointer *w)
266 * Displays and processes a grid dialogue box
269 static void window__gridBox(glass_windPointer *w)
273 buttons_simpleArrow sa={0,999,FALSE};
279 if (d=dbox_create("grid"),!d)
281 dbox_selecticon(d,glass_GDISP,w->gridShow);
282 dbox_selecticon(d,glass_GLOCK,w->gridLock);
283 dbox_setfield(d,glass_GWWRITE,"%i",w->gridx);
284 dbox_setfield(d,glass_GHWRITE,"%i",w->gridy);
285 shade=!(w->gridShow || w->gridLock);
286 dbox_shadeicon(d,glass_GWUP,shade);
287 dbox_shadeicon(d,glass_GWDOWN,shade);
288 dbox_shadeicon(d,glass_GWWRITE,shade);
289 dbox_shadeicon(d,glass_GHUP,shade);
290 dbox_shadeicon(d,glass_GHDOWN,shade);
291 dbox_shadeicon(d,glass_GHWRITE,shade);
292 dbox_display(d,dbox_MENU_OVERPTR);
296 switch (f=dbox_fillin(d),f)
302 dbox_clickicon(d,glass_GOK);
303 w->gridShow=dbox_selecticon(d,glass_GDISP,dbox_READSTATE);
304 w->gridLock=dbox_selecticon(d,glass_GLOCK,dbox_READSTATE);
305 dbox_scanfield(d,glass_GWWRITE,"%d",&w->gridx);
306 dbox_scanfield(d,glass_GHWRITE,"%d",&w->gridy);
307 wimpt_noerr(wimp_get_wind_state(w->h,&s));
310 r.box.x1=r.box.x0+s.o.box.x1-s.o.box.x0;
312 r.box.y0=r.box.y1+s.o.box.y0-s.o.box.y1;
313 wimpt_noerr(wimp_force_redraw(&r));
314 window__updateMenu(w);
315 if (!dbox_wasAdjustClick())
318 if (!dbox_wasAdjustClick())
323 shade=!(dbox_selecticon(d,glass_GDISP,dbox_READSTATE) ||
324 dbox_selecticon(d,glass_GLOCK,dbox_READSTATE));
325 dbox_shadeicon(d,glass_GWUP,shade);
326 dbox_shadeicon(d,glass_GWDOWN,shade);
327 dbox_shadeicon(d,glass_GWWRITE,shade);
328 dbox_shadeicon(d,glass_GHUP,shade);
329 dbox_shadeicon(d,glass_GHDOWN,shade);
330 dbox_shadeicon(d,glass_GHWRITE,shade);
333 buttons_arrow(d,f,d,glass_GWWRITE,0,+1,&sa);
336 buttons_arrow(d,f,d,glass_GWWRITE,0,-1,&sa);
339 buttons_arrow(d,f,d,glass_GHWRITE,0,+1,&sa);
342 buttons_arrow(d,f,d,glass_GHWRITE,0,-1,&sa);
350 * void window__thHelp(char *prefix,int hit)
353 * Does help for a tearoff menu.
356 * char *prefix == pointer to prefix string
357 * int hit == which item
360 static void window__thHelp(char *prefix,int hit)
362 char *p=buffer_find();
363 sprintf(p,"%s%i",prefix,hit);
365 help_addLine(msgs_lookup(p));
370 * void window__mhRoot(tearoff_message m,int hit,void *handle)
373 * Handles events on the root menu
376 * tearoff_message m == what happened
377 * int hit == what item it happened to
378 * void *handle == nothing interesting
381 static void window__mhRoot(tearoff_message m,int hit,void *handle)
383 glass_windPointer *w=handle ? handle : window__menuWin;
389 window__thHelp("wmhRT",hit);
391 case tearoff_SELECTION:
392 case tearoff_SUBMENU:
404 if (w && !w->renumber && !w->testMode)
407 if (w && !w->renumber)
417 * void window__mhMisc(tearoff_message m,int hit,void *handle)
420 * Handles events on the misc submenu
423 * tearoff_message m == what happened
424 * int hit == what item it happened to
425 * void *handle == nothing interesting
428 static void window__mhMisc(tearoff_message m,int hit,void *handle)
430 glass_windPointer *w=handle ? handle : window__menuWin;
443 glass_windPointer *wso=window_selectionOwner();
451 window__thHelp("wmhMSC",hit);
453 case tearoff_SELECTION:
454 case tearoff_SUBMENU:
461 case glass_TWMEDITWIN:
466 checked=!gPrefs_current()->cTest;
471 if (!warning(msgs_lookup("wdTCEP"),msgs_lookup("wdTCE")))
477 for (i=0;i<w->def->desc.w.nicons;i++)
479 if (w->def->i[i].edit)
483 if (!warning(msgs_lookup("wdTCEP"),msgs_lookup("wdTCE")))
490 if (w->testMode) /* Are we coming out of test mode? */
492 for (i=0;i<w->def->desc.w.nicons;i++)
494 wimpt_noerr(wimp_get_icon_info(w->h,i,&icn));
495 if (memcmp(&icn,&w->def->i[i].i,sizeof(wimp_icon)))
497 tfile_markAsAltered(w->t);
502 w->testMode=!w->testMode;
503 if (whand=window__recreate(w),!whand)
505 w->testMode=!w->testMode;
508 wimpt_noerr(wimp_get_wind_state(w->h,&s));
511 win_removeIdleClaimer(window__winIdles,w);
512 window__setPtrShape(window__SELECT);
514 wimpt_noerr(wimp_close_wind(w->h)); /* Closed, guv'nor */
515 win_register_event_handler(w->h,0,0); /* Won't need this now */
516 wimpt_noerr(wimp_delete_wind(w->h)); /* Delete the window */
518 win_register_event_handler(w->h,
519 w->testMode ? window__testEvents : window__events,w);
522 window__toggleTest(w);
523 wimpt_noerr(wimp_open_wind(&s.o));
526 window__setToolBarPositions(0);
529 if (window__selectedIcon()!=-1)
530 tearEdit_update(0,-1);
536 c.x=w->def->desc.w.ex.x0-50;
540 wimpt_noerr(wimp_set_caret_pos(&c));
541 tearEdit_update(w,window__selectedIcon());
544 window__updateMenu(w);
546 /* --- Our good mate the Window Manager --- *
548 * Because the RISC OS 3 Window Manager is about as braindead as
549 * it's possible to get without being written by Microsoft, it
550 * decides that it would be a simply super idea to move our window
551 * back on the screen at this point, screwing up the cached window
555 wimpt_noerr(wimp_get_wind_state(w->h,&s));
556 if (memcmp(&s.o.box,&w->def->desc.w,24))
558 w->def->desc.w.box=s.o.box;
559 w->def->desc.w.scx=s.o.x;
560 w->def->desc.w.scy=s.o.y;
562 tfile_markAsAltered(w->t);
567 case glass_TWMREMDEL:
568 stop=w->def->desc.w.nicons-1;
570 for (i=0;i<=stop;i++)
572 if (w->def->i[i].i.flags & wimp_IDELETED)
574 window_renumber(w,i--,stop--);
580 window__removeTrailingDeleted(w);
581 tfile_markAsAltered(w->t);
584 case glass_TWMBRINGBK:
585 for (i=0;i<w->def->desc.w.nicons;i++)
587 window_boundingBox(w,i,&b);
589 if (b.x0<w->def->desc.w.ex.x0)
590 xoff=w->def->desc.w.ex.x0-b.x0;
591 if (b.x1>w->def->desc.w.ex.x1)
592 xoff=w->def->desc.w.ex.x1-b.x1;
593 if (b.y0<w->def->desc.w.ex.y0)
594 yoff=w->def->desc.w.ex.y0-b.y0;
595 if (b.y1>w->def->desc.w.ex.y1)
596 yoff=w->def->desc.w.ex.y1-b.y1;
603 window_setBox(w,i,&b);
604 tfile_markAsAltered(w->t);
609 event_clear_current_menu();
618 * void window__mhSelect(tearoff_message m,int hit,void *handle)
621 * Handles events on the select submenu
624 * tearoff_message m == what happened
625 * int hit == what item it happened to
626 * void *handle == nothing interesting
629 static void window__mhSelect(tearoff_message m,int hit,void *handle)
631 glass_windPointer *w=handle ? handle : window__menuWin;
643 window__thHelp("wmhSEL",hit);
645 case tearoff_SELECTION:
646 case tearoff_SUBMENU:
650 window__gainSelection(w);
651 for (i=0;i<w->def->desc.w.nicons;i++)
652 window__select(w,i,TRUE);
653 window__updateMenu(w);
656 window__gainSelection(w);
657 for (i=0;i<w->def->desc.w.nicons;i++)
658 window__select(w,i,FALSE);
659 window__updateMenu(w);
662 window__copyIcons(w);
663 window__updateMenu(w);
666 if (gPrefs_current()->cDelIcon)
668 if (!warning(msgs_lookup("wdCDIP"),msgs_lookup("wdCDI")))
672 while (i<w->def->desc.w.nicons)
674 if (w->def->i[i].selected)
675 window_deleteIcon(w,i);
679 window__updateMenu(w);
682 stop=w->def->desc.w.nicons-1;
683 for (i=0;i<=stop;i++)
685 if (w->def->i[i].selected)
687 window_renumber(w,i,w->def->desc.w.nicons-1);
692 tfile_markAsAltered(w->t);
695 if (w->def->i[w->def->desc.w.nicons - 1].selected) {
699 for (i=w->def->desc.w.nicons - 1; i >= 0; i--) {
700 if (w->def->i[i].selected)
701 window_renumber(w, i, i + 1);
703 tfile_markAsAltered(w->t);
706 if (w->def->i[0].selected) {
710 for (i = 0; i < w->def->desc.w.nicons ;i++) {
711 if (w->def->i[i].selected)
712 window_renumber(w, i, i - 1);
714 tfile_markAsAltered(w->t);
718 for (i=w->def->desc.w.nicons-1;i>=stop;i--)
720 if (w->def->i[i].selected)
722 window_renumber(w,i,0);
727 tfile_markAsAltered(w->t);
730 checked=!gPrefs_current()->cTest;
735 if (!warning(msgs_lookup("wdTCRP"),msgs_lookup("wdTCR")))
741 for (i=0;i<w->def->desc.w.nicons;i++)
743 if (w->def->i[i].edit)
747 if (!warning(msgs_lookup("wdTCRP"),msgs_lookup("wdTCR")))
754 window__renumber(w,!w->renumber);
755 window__updateMenu(w);
758 for (i=0;i<w->def->desc.w.nicons;i++)
760 if (w->def->i[i].selected)
762 window_boundingBox(w,i,&b);
765 window__align(w,&b.x0,&b.y1);
768 window_setBox(w,i,&b);
769 tfile_markAsAltered(w->t);
777 for (i=0;i<w->def->desc.w.nicons;i++)
779 if (w->def->i[i].selected)
789 * void window__mhButton(tearoff_message m,int hit,void *handle)
792 * Handles events on the foo submenu
795 * tearoff_message m == what happened
796 * int hit == what item it happened to
797 * void *handle == nothing interesting
800 static void window__mhButton(tearoff_message m,int hit,void *handle)
802 glass_windPointer *w=handle ? handle : window__menuWin;
810 window__thHelp("wmhBUT",hit);
812 case tearoff_SELECTION:
813 case tearoff_SUBMENU:
816 for (i=0;i<w->def->desc.w.nicons;i++)
818 if (w->def->i[i].selected)
820 w->def->i[i].i.flags&=~0x0000f000;
821 w->def->i[i].i.flags|=(hit-1)<<12;
822 tfile_markAsAltered(w->t);
831 * void window__newIcon(int which,glass_windPointer *w)
834 * Creates a new icon in the window.
837 * int which == which icon type to use
838 * glass_windPointer *w == the window to build it in
841 static void window__newIcon(int which,glass_windPointer *w)
848 const static wimp_icon defidef={0,0,200,48,0x0f00603f,"<Untitled>"};
850 if (i=window__createIcon(w),i==-1)
852 wdef=&template_find("default")->window;
853 idef=(wimp_icon *)(wdef+1);
854 switch (wdef->nicons)
857 w->def->i[i].i=defidef;
860 w->def->i[i].i=idef[which];
863 if (!iconData_handleFont(w,&w->def->i[i].i.flags))
864 werr(FALSE,msgs_lookup("wdFERCI"));
865 if (!iconData_processIcon(w,i,0,TRUE,0))
867 werr(FALSE,msgs_lookup("wdNEMCI"));
868 w->def->i[i].i.flags&=~wimp_INDIRECT;
869 window_deleteIcon(w,i);
872 window_boundingBox(w,i,&b);
873 xoff=window__menuX-b.x0;
874 yoff=window__menuY-b.y1;
876 window__align(w,&xoff,&yoff);
877 w->def->i[i].i.box.x0+=xoff;
878 w->def->i[i].i.box.x1+=xoff;
879 w->def->i[i].i.box.y0+=yoff;
880 w->def->i[i].i.box.y1+=yoff;
881 window_redrawIcon(w,i);
882 tfile_markAsAltered(w->t);
883 window__menuX+=w->gridx;
884 window__menuY-=w->gridy;
888 * void window__mhIcon(tearoff_message m,int hit,void *handle)
891 * Handles events on the icon submenu
894 * tearoff_message m == what happened
895 * int hit == what item it happened to
896 * void *handle == nothing interesting
899 static void window__mhIcon(tearoff_message m,int hit,void *handle)
901 glass_windPointer *w=handle ? handle : window__menuWin;
907 window__thHelp("wmhICN",hit);
909 case tearoff_SELECTION:
910 case tearoff_SUBMENU:
914 window__newIcon(0,w);
915 window__updateMenu(w);
918 window__showPalette();
921 window_grab(window__grabIcon,w);
929 * void window__mhCreate(tearoff_message m,int hit,void *handle)
932 * Handles events on the new icon submenu
935 * tearoff_message m == what happened
936 * int hit == what item it happened to
937 * void *handle == nothing interesting
940 static void window__mhCreate(tearoff_message m,int hit,void *handle)
942 glass_windPointer *w=handle ? handle : window__menuWin;
955 help_addLine(msgs_lookup("wmhNI"));
958 case tearoff_SELECTION:
959 case tearoff_SUBMENU:
962 window__newIcon(hit-1,w);
963 window__updateMenu(w);
970 * void window__mhGuide(tearoff_message m,int hit,void *handle)
973 * Handles events on the guide submenu
976 * tearoff_message m == what happened
977 * int hit == what item it happened to
978 * void *handle == nothing interesting
981 static void window__mhGuide(tearoff_message m,int hit,void *handle)
983 glass_windPointer *w=handle ? handle : window__menuWin;
991 window__thHelp("wmhGD",hit);
993 case tearoff_SELECTION:
994 case tearoff_SUBMENU:
997 case glass_TWGSELALL:
998 window__gainSelection(w);
999 for (i=0;i<glass_GUIDELIMIT;i++)
1001 if (w->guide[i].active && !w->guide[i].selected)
1003 w->guide[i].selected=TRUE;
1004 window__redrawGuide(w,i);
1007 window__updateMenu(w);
1009 case glass_TWGCLRSEL:
1010 for (i=0;i<glass_GUIDELIMIT;i++)
1012 if (w->guide[i].active && w->guide[i].selected)
1014 w->guide[i].selected=FALSE;
1015 window__redrawGuide(w,i);
1018 window__updateMenu(w);
1020 case glass_TWGHORIZ:
1021 for (i=0;i<glass_GUIDELIMIT;i++)
1023 if (!w->guide[i].active)
1025 w->guide[i].active=TRUE;
1026 w->guide[i].horiz=TRUE;
1027 w->guide[i].coord=window__menuY;
1028 w->guide[i].selected=FALSE;
1029 window__redrawGuide(w,i);
1030 window__menuY-=w->gridy;
1034 if (i==glass_GUIDELIMIT)
1035 note(msgs_lookup("wdTMG"),glass_GUIDELIMIT);
1036 window__updateMenu(w);
1039 for (i=0;i<glass_GUIDELIMIT;i++)
1041 if (!w->guide[i].active)
1043 w->guide[i].active=TRUE;
1044 w->guide[i].horiz=FALSE;
1045 w->guide[i].coord=window__menuX;
1046 w->guide[i].selected=FALSE;
1047 window__redrawGuide(w,i);
1048 window__menuX+=w->gridx;
1052 if (i==glass_GUIDELIMIT)
1053 note(msgs_lookup("wdTMG"),glass_GUIDELIMIT);
1054 window__updateMenu(w);
1057 for (i=0;i<glass_GUIDELIMIT;i++)
1059 if (w->guide[i].active && w->guide[i].selected)
1061 w->guide[i].active=w->guide[i].selected=FALSE;
1062 window__redrawGuide(w,i);
1065 window__updateMenu(w);
1073 * void window__simMenu(glass_windPointer *w,int hit1,int hit2)
1076 * Simulates a menu hit on the specified item. Gives a beep if the item
1077 * is unavailable. Otherwise, the hit is sent to the current selection
1078 * owner. [fixed to allow which window is used rather than only the
1079 * selection owner, 1 November 1993]
1082 * glass_windPointer *w == the window in which to simulate the event
1083 * int hit1 == first hit in the sequence
1084 * int hit2 == second hit in the sequence
1087 void window__simMenu(glass_windPointer *w,int hit1,int hit2)
1089 /* --- A bit of a hack(tm) --- *
1091 * The old Wimp-menu based code used to simulate menu events to try to
1092 * do key shortcuts and the button bar. We try to emulate the old
1093 * behaviour, although the implementation is a /little/ different. The
1094 * old code used to peek about in the menu blocks to find submenus.
1095 * We can't do this any more, because the tearoff structure is hidden,
1096 * so we keep a big table of our own to help us find our way around.
1097 * Actually, this makes the code /much/ smaller.
1102 tearoff_selectProc p;
1105 table[]={ window__mhRoot, &window__mRoot, /* Funny entry for root menu */
1106 window__mhMisc, &window__mMisc,
1108 window__mhSelect, &window__mSelect,
1109 window__mhIcon, &window__mIcon,
1111 window__mhButton, &window__mButton };
1117 if (table[hit1].t && !tearoff_isShaded(*table[hit1].t,hit2))
1118 table[hit1].p(tearoff_SELECTION,hit2,w);
1124 * void window__showMenu(int x,int y,glass_windPointer *w)
1127 * Displays the Template Window Menu
1130 * int x,int y == the (window) position to display the menu
1131 * glass_windPointer *w == the window to display the menu for
1134 void window__showMenu(int x,int y,glass_windPointer *w)
1138 window__updateMenu(w);
1139 tearoff_displayMenu(window__mRoot,w);
1143 * void window__menuInit(void)
1146 * Initialises the create icon menu
1149 void window__menuInit(void)
1157 /* --- First set up the create menu --- */
1159 template_readfile(choices_name("Defaults.Templates",FALSE));
1160 wdef=&template_find("default")->window;
1161 idef=(wimp_icon *)(wdef+1);
1162 window__newIcons=wdef->nicons;
1163 switch (wdef->nicons)
1169 for (i=0;i<wdef->nicons;i++)
1171 if (idef[i].flags & wimp_INDIRECT)
1173 p=idef[i].data.indirecttext.buffer;
1174 utils_ctermToNterm(p);
1177 if (window__mCreate)
1178 window__mCreate=tearoff_extendMenu(window__mCreate,p);
1180 window__mCreate=tearoff_create(msgs_lookup("wdCRTMT"),
1181 p,TRUE,window__mhCreate,800,0);
1185 idef[i].data.indirecttext.bufflen=1;
1190 memcpy(buff,idef[i].data.text,12);
1191 utils_ctermToNterm(buff);
1196 if (window__mCreate)
1197 window__mCreate=tearoff_extendMenu(window__mCreate,p);
1199 window__mCreate=tearoff_create(msgs_lookup("wdCRTMT"),
1200 p,TRUE,window__mhCreate,800,0);
1208 /* --- Create the main menu tree --- */
1210 window__mRoot=tearoff_create(msgs_lookup("wdWMT"),
1211 msgs_lookup("wdWM"),
1212 TRUE,window__mhRoot,0,0);
1214 window__mMisc=tearoff_create(msgs_lookup("wdMISCMT"),
1215 msgs_lookup("wdMISCM"),
1216 FALSE,window__mhMisc,0,0);
1218 window__mSelect=tearoff_create(msgs_lookup("wdSELMT"),
1219 msgs_lookup("wdSELM"),
1220 TRUE,window__mhSelect,0,0);
1222 window__mIcon=tearoff_create(msgs_lookup("wdICNMT"),
1223 msgs_lookup("wdICNM"),
1224 FALSE,window__mhIcon,0,0);
1226 window__mGuide=tearoff_create(msgs_lookup("wdGDEMT"),
1227 msgs_lookup("wdGDEM"),
1228 TRUE,window__mhGuide,0,0);
1230 window__mButton=tearoff_create(msgs_lookup("eiBTMT"),
1231 msgs_lookup("eiBTYPE0"),
1239 sprintf(p,"eiBTYPE%i",i);
1240 window__mButton=tearoff_extendMenu(window__mButton,msgs_lookup(p));
1243 tearoff_attachSubMenu(window__mRoot,glass_TWMISC,window__mMisc);
1244 tearoff_attachSubMenu(window__mRoot,glass_TWSELECT,window__mSelect);
1245 tearoff_attachSubMenu(window__mRoot,glass_TWICON,window__mIcon);
1246 tearoff_attachSubMenu(window__mRoot,glass_TWGDE,window__mGuide);
1247 tearoff_attachSubMenu(window__mSelect,glass_TWSBTYPE,window__mButton);
1248 if (window__mCreate)
1249 tearoff_attachSubMenu(window__mIcon,glass_TWINEW,window__mCreate);