1;;; idlw-toolbar.el --- a debugging toolbar for IDLWAVE
2
3;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
4;;   Free Software Foundation, Inc.
5
6;; Author: Carsten Dominik <dominik@astro.uva.nl>
7;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>
8;; Version: 6.1_em22
9;; Keywords: processes
10
11;; This file is part of GNU Emacs.
12
13;; GNU Emacs 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)
16;; any later version.
17
18;; GNU Emacs 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.
22
23;; You should have received a copy of the GNU General Public License
24;; along with GNU Emacs; see the file COPYING.  If not, write to the
25;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26;; Boston, MA 02110-1301, USA.
27
28;;; Commentary:
29
30;; This file implements a debugging toolbar for IDLWAVE.  It requires
31;; Emacs or XEmacs with toolbar and xpm support.
32
33;; New versions of IDLWAVE, documentation, and more information
34;; available from:
35;;                 http://idlwave.org
36
37
38;;; Code:
39
40(eval-when-compile (require 'cl))
41
42(defun idlwave-toolbar-make-button (image)
43  (if (featurep 'xemacs)
44      (toolbar-make-button-list image)
45    (list 'image :type 'xpm :data image)))
46
47(defvar idlwave-toolbar)
48(defvar default-toolbar)
49(defvar idlwave-toolbar-is-possible)
50
51(if (not (or (and (featurep 'xemacs)                ; This is XEmacs
52		  (featurep 'xpm)                   ; need xpm
53		  (featurep 'toolbar))              ; ... and the toolbar
54	     (and (not (featurep 'xemacs))          ; This is Emacs
55		  (boundp 'tool-bar-button-margin)   ; need toolbar
56		  (fboundp 'image-type-available-p) ; need image stuff
57		  (image-type-available-p 'xpm))    ; need xpm
58	     ))
59    ;; oops - cannot do the toolbar
60    (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs")
61;; OK, we can define a toolbar
62
63(defconst idlwave-toolbar-is-possible t
64  "When defined, indicates that a toolbar is possible with this Emacs.")
65(defvar idlwave-toolbar-compile-icon
66  (idlwave-toolbar-make-button
67   "/* XPM */
68static char * file[] = {
69\"28 28 2 1\",
70\" 	c None s backgroundToolBarColor\",
71\".	c #000000000000\",
72\"                            \",
73\"                            \",
74\"                            \",
75\"             .              \",
76\"       ..   ...   ..        \",
77\"       .... ... ....        \",
78\"       .............        \",
79\"        ...........         \",
80\"    ...................     \",
81\"    ........   ........     \",
82\"     .....    ........      \",
83\"      ....  .........       \",
84\"    .....  .. ... .....     \",
85\"   ...... ..   .. ......    \",
86\"    ..... ... ..  .....     \",
87\"      .........  ....       \",
88\"     ........    .....      \",
89\"    ........   ........     \",
90\"    ...................     \",
91\"        ...........         \",
92\"       .............        \",
93\"       .... ... ....        \",
94\"       ..   ...   ..        \",
95\"             .              \",
96\"                            \",
97\"                            \",
98\"                            \",
99\"                            \"};")
100  "The compile icon.")
101
102(defvar idlwave-toolbar-next-error-icon
103  (idlwave-toolbar-make-button
104   "/* XPM */
105static char * file[] = {
106\"28 28 3 1\",
107\" 	c None s backgroundToolBarColor\",
108\".	c #000000000000\",
109\"R	c #FFFF00000000\",
110\"                            \",
111\"                            \",
112\"             R              \",
113\"       RR   RRR   RR        \",
114\"       RRRR RRR RRRR        \",
115\"       RRRRRRRRRRRRR        \",
116\"        RRRRRRRRRRR         \",
117\"    RRRRRRRRRRRRRRRRRRR     \",
118\"    RRRRRRRR                \",
119\"     RRRRR                  \",
120\"      RRRR                  \",
121\"               ........     \",
122\"              ........      \",
123\"            .........       \",
124\"    .....  .. ... .....     \",
125\"   ...... ..   .. ......    \",
126\"    ..... ... ..  .....     \",
127\"      .........  ....       \",
128\"     ........    .....      \",
129\"    ........   ........     \",
130\"    ...................     \",
131\"        ...........         \",
132\"       .............        \",
133\"       .... ... ....        \",
134\"       ..   ...   ..        \",
135\"             .              \",
136\"                            \",
137\"                            \"};")
138  "The Next Error icon.")
139
140(defvar idlwave-toolbar-stop-at-icon
141  (idlwave-toolbar-make-button
142   "/* XPM */
143static char * file[] = {
144\"28 28 3 1\",
145\" 	c None s backgroundToolBarColor\",
146\".	c #000000000000\",
147\"R	c #FFFF00000000\",
148\"                            \",
149\"                            \",
150\"                            \",
151\"                            \",
152\"          ........          \",
153\"         .RRRRRRRR.         \",
154\"        .RRRRRRRRRR.        \",
155\"       .RRRRRRRRRRRR.       \",
156\"      .RRRRRRRRRRRRRR.      \",
157\"     .RRRRRRRRRRRRRRRR.     \",
158\"    .RRRRRRRRRRRRRRRRRR.    \",
159\"    .RRRRRRRRRRRRRRRRRR.    \",
160\"    .RRRRRRRRRRRRRRRRRR.    \",
161\"    .RRRRRRRRRRRRRRRRRR.    \",
162\"    .RRRRRRRRRRRRRRRRRR.    \",
163\"    .RRRRRRRRRRRRRRRRRR.    \",
164\"    .RRRRRRRRRRRRRRRRRR.    \",
165\"    .RRRRRRRRRRRRRRRRRR.    \",
166\"     .RRRRRRRRRRRRRRRR.     \",
167\"      .RRRRRRRRRRRRRR.      \",
168\"       .RRRRRRRRRRRR.       \",
169\"        .RRRRRRRRRR.        \",
170\"         .RRRRRRRR.         \",
171\"          ........          \",
172\"                            \",
173\"                            \",
174\"                            \",
175\"                            \"};")
176  "The Stop At icon.")
177
178
179(defvar idlwave-toolbar-clear-at-icon
180  (idlwave-toolbar-make-button
181   "/* XPM */
182static char * file[] = {
183\"28 28 3 1\",
184\" 	c None s backgroundToolBarColor\",
185\".	c #000000000000\",
186\"R	c #FFFF00000000\",
187\"                            \",
188\"                            \",
189\"                            \",
190\"  ...                  ...  \",
191\"   ...    ........    ...   \",
192\"    ...  .RRRRRRRR.  ...    \",
193\"     ....RRRRRRRRRR....     \",
194\"      ...RRRRRRRRRR...      \",
195\"      ....RRRRRRRR....      \",
196\"     .RR...RRRRRR...RR.     \",
197\"    .RRRR...RRRR...RRRR.    \",
198\"    .RRRRR...RR...RRRRR.    \",
199\"    .RRRRRR......RRRRRR.    \",
200\"    .RRRRRRR....RRRRRRR.    \",
201\"    .RRRRRRR....RRRRRRR.    \",
202\"    .RRRRRR......RRRRRR.    \",
203\"    .RRRRR...RR...RRRRR.    \",
204\"    .RRRR...RRRR...RRRR.    \",
205\"     .RR...RRRRRR...RR.     \",
206\"      ....RRRRRRRR....      \",
207\"      ...RRRRRRRRRR...      \",
208\"     ....RRRRRRRRRR....     \",
209\"    ...  .RRRRRRRR.  ...    \",
210\"   ...    ........    ...   \",
211\"  ...                  ...  \",
212\"                            \",
213\"                            \",
214\"                            \"};")
215  "The Clear At icon.")
216
217(defvar idlwave-toolbar-clear-all-icon
218  (idlwave-toolbar-make-button
219   "/* XPM */
220static char * file[] = {
221\"28 28 4 1\",
222\" 	c None s backgroundToolBarColor\",
223\".	c #000000000000\",
224\"X	c #FFFFFFFFFFFF\",
225\"R	c #FFFF00000000\",
226\"                            \",
227\"                            \",
228\"                            \",
229\"  .. ....         .... ..   \",
230\"  ...RRRR.       .RRRR...   \",
231\"   ...RRRR.     .RRRR...    \",
232\"  .R...RRRR.   .RRRR...R.   \",
233\"  .RR...RRR.   .RRR...RR.   \",
234\"  .RRR...RR.   .RR...RRR.   \",
235\"  .RRRR...R.   .R...RRRR.   \",
236\"   .RRRR...     ...RRRR.    \",
237\"    .RRRR...   ...RRRR.     \",
238\"     .... ... ... ....      \",
239\"           .....            \",
240\"            ...             \",
241\"     ....  .....  ....      \",
242\"    .RRRR.... ....RRRR.     \",
243\"   .RRRRR...   ...RRRRR.    \",
244\"  .RRRRR....   ....RRRRR.   \",
245\"  .RRRR...R.   .R...RRRR.   \",
246\"  .RRR...RR.   .RR...RRR.   \",
247\"  .RR...RRR.   .RRR...RR.   \",
248\"   ....RRR.     .RRR....    \",
249\"   ...RRR.       .RRR...    \",
250\"  .......         .......   \",
251\"                            \",
252\"                            \",
253\"                            \"};")
254  "The Clear-All icon.")
255
256(defvar idlwave-toolbar-stop-beginning-icon
257  (idlwave-toolbar-make-button
258   "/* XPM */
259static char * file[] = {
260\"28 28 4 1\",
261\" 	c None s backgroundToolBarColor\",
262\".	c #000000000000\",
263\"X	c #FFFF00000000\",
264\"_	c #FFFFFFFFFFFF\",
265\"                            \",
266\"                            \",
267\"                            \",
268\"                            \",
269\"          ........          \",
270\"         .XXXXXXXX.         \",
271\"        .XXXXXXXXXX.        \",
272\"       .XXXXXXXXXXXX.       \",
273\"      .XX..XXXXXXXXXX.      \",
274\"     .XX.XX.X______XXX.     \",
275\"    .XXX.XX.X______XXXX.    \",
276\"    .XXXX..XXXXXXXXXXXX.    \",
277\"    .XXXXXXXXXX____XXXX.    \",
278\"    .XXXXXXXXXX____XXXX.    \",
279\"    .XXXXXXXXXXXXXXXXXX.    \",
280\"    .XXXXXXXXXX____XXXX.    \",
281\"    .XXXXXXXXXX____XXXX.    \",
282\"    .XXXXXXXXXXXXXXXXXX.    \",
283\"     .XXXXXXXXX____XXX.     \",
284\"      .XXXXXXXX____XX.      \",
285\"       .XXXXXXXXXXXX.       \",
286\"        .XXXXXXXXXX.        \",
287\"         .XXXXXXXX.         \",
288\"          ........          \",
289\"                            \",
290\"                            \",
291\"                            \",
292\"                            \"};")
293  "The Stop at Beginning icon.")
294
295(defvar idlwave-toolbar-stop-in-icon
296  (idlwave-toolbar-make-button
297   "/* XPM */
298static char * file[] = {
299\"28 28 4 1\",
300\" 	c None s backgroundToolBarColor\",
301\"_	c #FFFFFFFFFFFF\",
302\".	c #000000000000\",
303\"R	c #FFFF00000000\",
304\"                            \",
305\"                            \",
306\"                            \",
307\"                            \",
308\"          ........          \",
309\"         .RRRRRRRR.         \",
310\"        .RRRRRRRRRR.        \",
311\"       .RRRRRRRRRRRR.       \",
312\"      .RRR___RR___RRR.      \",
313\"     .RRRR__RRRR__RRRR.     \",
314\"    .RRRRR__RRRR__RRRRR.    \",
315\"    .RRRRR__RRRR__RRRRR.    \",
316\"    .RRRRR__RRRR__RRRRR.    \",
317\"    .RRRR__RRRRRR__RRRR.    \",
318\"    .RRRRR__RRRR__RRRRR.    \",
319\"    .RRRRR__RRRR__RRRRR.    \",
320\"    .RRRRR__RRRR__RRRRR.    \",
321\"    .RRRRR__RRRR__RRRRR.    \",
322\"     .RRRR___RR___RRRR.     \",
323\"      .RRRRRRRRRRRRRR.      \",
324\"       .RRRRRRRRRRRR.       \",
325\"        .RRRRRRRRRR.        \",
326\"         .RRRRRRRR.         \",
327\"          ........          \",
328\"                            \",
329\"                            \",
330\"                            \",
331\"                            \"};")
332  "The Stop in icon.")
333
334(defvar idlwave-toolbar-edit-cmd-icon
335  (idlwave-toolbar-make-button
336   "/* XPM */
337static char * file[] = {
338\"28 28 2 1\",
339\" 	c None s backgroundToolBarColor\",
340\".	c #000000000000\",
341\"                            \",
342\"                            \",
343\"                            \",
344\"                            \",
345\"                            \",
346\"                            \",
347\"                            \",
348\"                            \",
349\"                            \",
350\"                            \",
351\"                            \",
352\"   ..                       \",
353\"    ..                      \",
354\"     ..                     \",
355\"    ..                      \",
356\"   ..                       \",
357\"                            \",
358\"                            \",
359\"        .................   \",
360\"                            \",
361\"                            \",
362\"                            \",
363\"                            \",
364\"                            \",
365\"                            \",
366\"                            \",
367\"                            \",
368\"                            \"};")
369  "The edit-cmd icon")
370
371(defvar idlwave-toolbar-run-icon
372  (idlwave-toolbar-make-button
373   "/* XPM */
374static char * file[] = {
375\"28 28 3 1\",
376\" 	c None s backgroundToolBarColor\",
377\".	s FgColor c #000000000000\",
378\"G	c #0000BBBB0000\",
379\"                            \",
380\"                            \",
381\"                            \",
382\"                            \",
383\"     .....                  \",
384\"     .GGG.                  \",
385\"     .GGG.                  \",
386\"     .GGG.       .......    \",
387\"     .GGG.                  \",
388\"     .GGG.                  \",
389\"     .GGG.       .......    \",
390\"     .GGG.                  \",
391\"  ....GGG....               \",
392\"   .GGGGGGG.     .......    \",
393\"    .GGGGG.                 \",
394\"     .GGG.                  \",
395\"      .G.        .......    \",
396\"       .                    \",
397\"                            \",
398\"                 .......    \",
399\"                            \",
400\"                            \",
401\"                 .......    \",
402\"                            \",
403\"                            \",
404\"                            \",
405\"                            \",
406\"                            \"};")
407  "The Run icon.")
408
409(defvar idlwave-toolbar-cont-icon
410  (idlwave-toolbar-make-button
411   "/* XPM */
412static char * file[] = {
413\"28 28 3 1\",
414\" 	c None s backgroundToolBarColor\",
415\".	s FgColor c #000000000000\",
416\"G	c #0000BBBB0000\",
417\"                            \",
418\"                            \",
419\"                            \",
420\"                 .......    \",
421\"                            \",
422\"       .......              \",
423\"      .GGGGGG.   .......    \",
424\"     .GGGGGGG.              \",
425\"     .GGG.....              \",
426\"     .GGG.       .......    \",
427\"     .GGG.                  \",
428\"     .GGG.                  \",
429\"     .GGG.       .......    \",
430\"     .GGG.                  \",
431\"  ....GGG....               \",
432\"   .GGGGGGG.     .......    \",
433\"    .GGGGG.                 \",
434\"     .GGG.                  \",
435\"      .G.        .......    \",
436\"       .                    \",
437\"                            \",
438\"                 .......    \",
439\"                            \",
440\"                            \",
441\"                            \",
442\"                            \",
443\"                            \",
444\"                            \"};")
445  "The Cont icon.")
446
447(defvar idlwave-toolbar-to-here-icon
448  (idlwave-toolbar-make-button
449   "/* XPM */
450static char * file[] = {
451\"28 28 4 1\",
452\" 	c None s backgroundToolBarColor\",
453\".	c #000000000000\",
454\"G	c #0000BBBB0000\",
455\"R	c #FFFF00000000\",
456\"                            \",
457\"                            \",
458\"                            \",
459\"                            \",
460\"                            \",
461\"                            \",
462\"      .....   ........      \",
463\"     .GGGG.                 \",
464\"    .GGGGG.                 \",
465\"    .GG....   ........      \",
466\"    .GG.                    \",
467\"    .GG. .                  \",
468\"    .GG. ..                 \",
469\"    .GG. .G.    ......      \",
470\"    .GG...GG.               \",
471\"    .GGGGGGGG.  RRRRRR      \",
472\"    .GGGGGGGGG. RRRRRR      \",
473\"     .GGGGGGG.  RRRRRR      \",
474\"      ....GG.               \",
475\"         .G.    ......      \",
476\"         ..                 \",
477\"         .                  \",
478\"                            \",
479\"                            \",
480\"                            \",
481\"                            \",
482\"                            \",
483\"                            \"};")
484  "The Cont-to-here icon.")
485
486(defvar idlwave-toolbar-step-over-icon
487  (idlwave-toolbar-make-button
488   "/* XPM */
489static char * file[] = {
490\"28 28 3 1\",
491\" 	c None s backgroundToolBarColor\",
492\".	c #000000000000\",
493\"G	c #0000BBBB0000\",
494\"                            \",
495\"                            \",
496\"                            \",
497\"                            \",
498\"                            \",
499\"                            \",
500\"      .....                 \",
501\"     .GGGG.      .......    \",
502\"    .GGGGG.                 \",
503\"    .GG....                 \",
504\"    .GG.         .......    \",
505\"    .GG. .                  \",
506\"    .GG. ..                 \",
507\"    .GG. .G.     .......    \",
508\"    .GG...GG.               \",
509\"    .GGGGGGGG.              \",
510\"    .GGGGGGGGG.  .......    \",
511\"     .GGGGGGG.              \",
512\"      ....GG.               \",
513\"         .G.     .......    \",
514\"         ..                 \",
515\"         .                  \",
516\"                 .......    \",
517\"                            \",
518\"                            \",
519\"                            \",
520\"                            \",
521\"                            \"};")
522  "The Step Over icon.")
523
524(defvar idlwave-toolbar-step-into-icon
525  (idlwave-toolbar-make-button
526   "/* XPM */
527static char * file[] = {
528\"28 28 3 1\",
529\" 	c None s backgroundToolBarColor\",
530\".	c #000000000000\",
531\"G	c #0000BBBB0000\",
532\"                            \",
533\"                            \",
534\"                            \",
535\"                            \",
536\"                            \",
537\"                            \",
538\"      .....   .......       \",
539\"     .GGGG.                 \",
540\"    .GGGGG.                 \",
541\"    .GG....   ........      \",
542\"    .GG.                    \",
543\"    .GG. .                  \",
544\"    .GG. ..                 \",
545\"    .GG. .G.                \",
546\"    .GG...GG.    .......    \",
547\"    .GGGGGGGG.              \",
548\"    .GGGGGGGGG.             \",
549\"     .GGGGGGG.   .......    \",
550\"      ....GG.               \",
551\"         .G.                \",
552\"         ..      .......    \",
553\"         .                  \",
554\"                            \",
555\"                            \",
556\"                            \",
557\"                            \",
558\"                            \",
559\"                            \"};")
560  "The Step Into icon.")
561
562(defvar idlwave-toolbar-step-out-icon
563  (idlwave-toolbar-make-button
564   "/* XPM */
565static char * file[] = {
566\"28 28 3 1\",
567\" 	c None s backgroundToolBarColor\",
568\".	c #000000000000\",
569\"G	c #0000BBBB0000\",
570\"                            \",
571\"                            \",
572\"                            \",
573\"                            \",
574\"                            \",
575\"                            \",
576\"         .                  \",
577\"         ..     ........    \",
578\"         .G.                \",
579\"      ....GG.               \",
580\"     .GGGGGGG.  ........    \",
581\"    .GGGGGGGGG.             \",
582\"    .GGGGGGGG.              \",
583\"    .GG...GG.   ........    \",
584\"    .GG. .G.                \",
585\"    .GG. ..                 \",
586\"    .GG. .                  \",
587\"    .GG.                    \",
588\"    .GG.......    .......   \",
589\"    .GGGGGGGG.              \",
590\"     .GGGGGGG.              \",
591\"      ........    .......   \",
592\"                            \",
593\"                            \",
594\"                            \",
595\"                            \",
596\"                            \",
597\"                            \"};")
598  "The Step up icon.")
599
600
601(defvar idlwave-toolbar-eval-icon
602  (idlwave-toolbar-make-button
603   "/* XPM */
604static char * file[] = {
605\"28 28 2 1\",
606\" 	c None s backgroundToolBarColor\",
607\".	c #000000000000\",
608\"                            \",
609\"                            \",
610\"                            \",
611\"                            \",
612\"                            \",
613\"                            \",
614\"                            \",
615\"                            \",
616\"                            \",
617\"                            \",
618\"                            \",
619\"         ....               \",
620\"         .. ..  ......      \",
621\"         .. ..  ......      \",
622\"         .. ..              \",
623\"         .. ..  ......      \",
624\"         .. ..  ......      \",
625\"         ....               \",
626\"         ..                 \",
627\"         ..                 \",
628\"                            \",
629\"                            \",
630\"                            \",
631\"                            \",
632\"                            \",
633\"                            \",
634\"                            \",
635\"                            \"};")
636  "The Evaluate icon.")
637
638(defvar idlwave-toolbar-stack-up-icon
639  (idlwave-toolbar-make-button
640   "/* XPM */
641static char * file[] = {
642\"28 28 5 1\",
643\" 	c None s backgroundToolBarColor\",
644\".	s FgColor c #000000000000\",
645\"_	c #FFFFFFFFFFFF\",
646\"G	c #0000BBBB0000\",
647\"R	c #FFFF00000000\",
648\"                            \",
649\"                            \",
650\"                            \",
651\"                            \",
652\"                            \",
653\"      ........     .        \",
654\"      .______.    ...       \",
655\"      .______.   .....      \",
656\"      .______.  .......     \",
657\"      .______.    ...       \",
658\"      .______.    ...       \",
659\"      ........    ...       \",
660\"      .GGGGGG.    ...       \",
661\"      .GGGGGG.    ...       \",
662\"      .GGGGGG.              \",
663\"      .GGGGGG.              \",
664\"      .GGGGGG.              \",
665\"      ........              \",
666\"      .RRRRRR.              \",
667\"      .RRRRRR.              \",
668\"      .RRRRRR.              \",
669\"      .RRRRRR.              \",
670\"      .RRRRRR.              \",
671\"      ........              \",
672\"                            \",
673\"                            \",
674\"                            \",
675\"                            \"};")
676  "The Stack Up icon.")
677
678(defvar idlwave-toolbar-stack-down-icon
679  (idlwave-toolbar-make-button
680   "/* XPM */
681static char * file[] = {
682\"28 28 5 1\",
683\" 	c None s backgroundToolBarColor\",
684\".	s FgColor c #000000000000\",
685\"_	c #FFFFFFFFFFFF\",
686\"G	c #0000BBBB0000\",
687\"R	c #FFFF00000000\",
688\"                            \",
689\"                            \",
690\"                            \",
691\"                            \",
692\"                            \",
693\"      ........              \",
694\"      .______.              \",
695\"      .______.              \",
696\"      .______.              \",
697\"      .______.              \",
698\"      .______.              \",
699\"      ........              \",
700\"      .GGGGGG.              \",
701\"      .GGGGGG.              \",
702\"      .GGGGGG.              \",
703\"      .GGGGGG.    ...       \",
704\"      .GGGGGG.    ...       \",
705\"      ........    ...       \",
706\"      .RRRRRR.    ...       \",
707\"      .RRRRRR.    ...       \",
708\"      .RRRRRR.  .......     \",
709\"      .RRRRRR.   .....      \",
710\"      .RRRRRR.    ...       \",
711\"      ........     .        \",
712\"                            \",
713\"                            \",
714\"                            \",
715\"                            \"};")
716  "The Stack Down icon.")
717
718(defvar idlwave-toolbar-reset-icon
719  (idlwave-toolbar-make-button
720   "/* XPM */
721static char * file[] = {
722\"28 28 3 1\",
723\" 	c None s backgroundToolBarColor\",
724\"G	c #0000BBBB0000\",
725\". 	c #000000000000\",
726\"                            \",
727\"                            \",
728\"                            \",
729\"     .                      \",
730\"    .G.     .               \",
731\"   .GGG..  .G.              \",
732\"   .GGGGG..GG.              \",
733\"    ..GGGGGGGG.             \",
734\"      ..GGGGGG.             \",
735\"        ..GGGGG.            \",
736\"        .GGGGGG.            \",
737\"        .G......            \",
738\"                            \",
739\"                 .....      \",
740\"               .........    \",
741\"               .........    \",
742\"               .........    \",
743\"               . ..... .    \",
744\"               .       .    \",
745\"               .       .    \",
746\"               .       .    \",
747\"               .       .    \",
748\"               .       .    \",
749\"               ..     ..    \",
750\"                .......     \",
751\"                 .....      \",
752\"                            \",
753\"                            \"};")
754  "The Reset icon.")
755
756(defvar idlwave-toolbar-electric-debug-icon
757  (idlwave-toolbar-make-button
758   "/* XPM */
759static char * file[] = {
760\"28 28 8 1\",
761\" 	c None s backgroundToolBarColor\",
762\".	c #CFC854\",
763\"+	c #EEDB0E\",
764\"@	c #D2C739\",
765\"#	c #A39C54\",
766\"$	c #CDC020\",
767\"%	c #020202\",
768\"&	c #D60E36\",
769\"                            \",
770\"                            \",
771\"      ..                    \",
772\"   +++++@                   \",
773\"   ++++++                   \",
774\"    +++++@                  \",
775\"     +++++                  \",
776\"     #++++@                 \",
777\"      $+++@       %% %%     \",
778\"     ++++++$       % %      \",
779\"     #+++++$       % %      \",
780\"      #++$#        %%%      \",
781\"      #+++       %%%%%%%    \",
782\"       .++     %%%%%%%%%%%  \",
783\"        ++$$   %%%%%%%%%%%  \",
784\"        .+@#   &&%%%%%%%&&  \",
785\"      .++++#  &&&&&%%%&&&&& \",
786\"      +++++$  &&%%&&&&&%%&& \",
787\"       $+++$  &&%%&&&&&%%&& \",
788\"        $++@  &&&&&&%&&&&&& \",
789\"         $+@  &&&&&&%&&&&&& \",
790\"          @+  &&%%&&&&&%%&& \",
791\"           ++. &%%&&%&&%%&  \",
792\"            +. &&&&%%%&&&&  \",
793\"            .+  &&%%%%%&&   \",
794\"             ++  %%%%%%%    \",
795\"              .    %%%      \",
796\"                            \"};")
797  "The electric debug icon.")
798
799(defvar idlwave-toolbar
800  '(
801    [idlwave-toolbar-compile-icon
802     idlwave-shell-save-and-compile
803     t
804     "Save and Compile this file (or recompile last)"]
805    [idlwave-toolbar-next-error-icon
806     idlwave-shell-goto-next-error
807     t
808     "Goto Next Error"]
809    [idlwave-toolbar-stop-at-icon
810     idlwave-shell-break-here
811     (eq major-mode 'idlwave-mode)
812     "Set Breakpoint at selected position"]
813    [idlwave-toolbar-clear-at-icon
814     idlwave-shell-clear-current-bp
815     t
816     "Clear Breakpoint at selected position"]
817    [idlwave-toolbar-clear-all-icon
818     idlwave-shell-clear-all-bp
819     t
820     "Clear all Breakpoints"]
821    [idlwave-toolbar-stop-beginning-icon
822     idlwave-shell-break-this-module
823     (eq major-mode 'idlwave-mode)
824     "Stop at beginning of enclosing Routine"]
825    [idlwave-toolbar-stop-in-icon
826     idlwave-shell-break-in
827     t
828     "Stop in Routine with name near point"]
829    [idlwave-toolbar-edit-cmd-icon
830     idlwave-shell-edit-default-command-line
831     t
832     "Edit Default Command Line"]
833    [idlwave-toolbar-run-icon
834     idlwave-shell-execute-default-command-line
835     t
836     "Reset, then Execute Default Command Line"]
837    [idlwave-toolbar-cont-icon
838     idlwave-shell-cont
839     t
840     "Continue Current Program"]
841    [idlwave-toolbar-to-here-icon
842     idlwave-shell-to-here
843     (eq major-mode 'idlwave-mode)
844     "Continue to Here (cursor position)"]
845    [idlwave-toolbar-step-over-icon
846     idlwave-shell-stepover
847     t
848     "Step Over (aka next)"]
849    [idlwave-toolbar-step-into-icon
850     idlwave-shell-step
851     t
852     "Step Into (aka step)"]
853    [idlwave-toolbar-step-out-icon
854     idlwave-shell-out
855     t
856     "Step Out (of subroutine)"]
857    [idlwave-toolbar-eval-icon
858     idlwave-shell-print
859     t
860     "Print Expression at or before Point"]
861    [idlwave-toolbar-stack-up-icon
862     idlwave-shell-stack-up
863     t
864     "Stack Up (towards \"cooler\" - less recently visited - frames)"]
865    [idlwave-toolbar-stack-down-icon
866     idlwave-shell-stack-down
867     t
868     "Stack Down (towards \"warmer\" - more recently visited - frames)"]
869    [idlwave-toolbar-reset-icon
870     idlwave-shell-reset
871     t
872     "Reset IDL (RETALL & CLOSE,/ALL and more)"]
873    [idlwave-toolbar-electric-debug-icon
874     idlwave-shell-electric-debug-mode
875     (eq major-mode 'idlwave-mode)
876     "Toggle Electric Debug Mode"]
877    ))
878
879;; When the shell exits, arrange to remove the special toolbar everywhere.
880(add-hook 'idlwave-shell-cleanup-hook
881	  'idlwave-toolbar-remove-everywhere)
882);; End can define toolbar
883
884(defun idlwave-toolbar-add ()
885  "Add the IDLWAVE toolbar if appropriate."
886  (if (and (featurep 'xemacs)    ; This is a noop on Emacs
887	   (boundp 'idlwave-toolbar-is-possible)
888	   (or (eq major-mode 'idlwave-mode)
889	       (eq major-mode 'idlwave-shell-mode)))
890      (set-specifier default-toolbar (cons (current-buffer)
891					   idlwave-toolbar))))
892
893(defun idlwave-toolbar-remove ()
894  "Add the IDLWAVE toolbar if appropriate."
895  (if (and (featurep 'xemacs)    ; This is a noop on Emacs
896	   (boundp 'idlwave-toolbar-is-possible)
897	   (or (eq major-mode 'idlwave-mode)
898	       (eq major-mode 'idlwave-shell-mode)))
899      (remove-specifier default-toolbar (current-buffer))))
900
901(defvar idlwave-shell-mode-map)
902(defvar idlwave-mode-map)
903(defvar idlwave-toolbar-visible nil)
904(defun idlwave-toolbar-add-everywhere ()
905  "Add the toolbar in all appropriate buffers."
906  (when (boundp 'idlwave-toolbar-is-possible)
907
908    ;; First make sure new buffers will get the toolbar
909    (add-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
910    ;; Then add it to all existing buffers
911    (if (featurep 'xemacs)
912	;; For XEmacs, map over all buffers to add toolbar
913	(save-excursion
914	  (mapcar (lambda (buf)
915		    (set-buffer buf)
916		    (idlwave-toolbar-add))
917		  (buffer-list)))
918      ;; For Emacs, add the key definitions to the mode maps
919      (mapcar (lambda (x)
920		(let* ((icon (aref x 0))
921		       (func (aref x 1))
922		       (show (aref x 2))
923		       (help (aref x 3))
924		       (key (vector 'tool-bar func))
925		       (def (list 'menu-item
926				  "a"
927				  func
928				  :image (symbol-value icon)
929				  :visible show
930				  :help help)))
931		  (define-key idlwave-mode-map key def)
932		  (define-key idlwave-shell-mode-map key def)))
933	      (reverse idlwave-toolbar)))
934    (setq idlwave-toolbar-visible t)))
935
936(defun idlwave-toolbar-remove-everywhere ()
937  "Remove the toolbar in all appropriate buffers."
938  ;; First make sure new buffers won't get the toolbar
939  (when idlwave-toolbar-is-possible
940    (remove-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
941    ;; Then remove it in all existing buffers.
942    (if (featurep 'xemacs)
943	;; For XEmacs, map over all buffers to remove toolbar
944	(save-excursion
945	  (mapcar (lambda (buf)
946		    (set-buffer buf)
947		    (idlwave-toolbar-remove))
948		  (buffer-list)))
949      ;; For Emacs, remove the key definitions from the mode maps
950      (mapcar (lambda (x)
951		(let* (;;(icon (aref x 0))
952		       (func (aref x 1))
953		       ;;(show (aref x 2))
954		       ;;(help (aref x 3))
955		       (key (vector 'tool-bar func)))
956		  (define-key idlwave-mode-map key nil)
957		  (define-key idlwave-shell-mode-map key nil)))
958	      idlwave-toolbar))
959    (setq idlwave-toolbar-visible nil)))
960
961(defun idlwave-toolbar-toggle (&optional force-on)
962  (interactive)
963  (if idlwave-toolbar-visible
964      (or force-on (idlwave-toolbar-remove-everywhere))
965    (idlwave-toolbar-add-everywhere))
966  ;; Now make sure this
967  (if (featurep 'xemacs)
968      nil ; no action necessary, toolbar gets updated automatically
969    ;; On Emacs, redraw the frame to make sure the Toolbar is updated.
970    (redraw-frame (selected-frame))))
971
972(provide 'idlw-toolbar)
973(provide 'idlwave-toolbar)
974
975;; arch-tag: ec9a3717-c44c-4716-9bda-cdacbe5ddb62
976;;; idlw-toolbar.el ends here
977