-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscratchpad.pro
132 lines (104 loc) · 3.16 KB
/
scratchpad.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
;*************************************************************************
; Copyright (c) 2002 The University of Chicago, as Operator of Argonne
; National Laboratory.
; Copyright (c) 2002 The Regents of the University of California, as
; Operator of Los Alamos National Laboratory.
; This file is distributed subject to a Software License Agreement found
; in the file LICENSE that is included with this distribution.
;*************************************************************************
PRO SCRATCHPAD_MAIN13_Event, Event
COMMON SCRATCHPAD_BLOCK, scratchpad_id
WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
CASE Ev OF
'SCRATCHPAD_TEXT': BEGIN
END
'BUTTON5': BEGIN
WIDGET_CONTROL,scratchpad_id.base,/DESTROY
END
'BUTTON6': BEGIN
WIDGET_CONTROL,scratchpad_id.textID,GET_VALUE=st
file = dialog_pickfile(/write,filter='*',get_path=newp,group=event.top,$
path=scratchpad_id.path,title='ScratchPad save ...')
if strtrim(file,2) ne '' then begin
scratchpad_id.no = n_elements(st)
openw,unit,file,error=err,/get_lun
if err ne 0 then begin
res = dialog_message(/Error,'Failed to write the file')
return
end
for i=0,scratchpad_id.no-1 do begin
scratchpad_id.text(i) = st(i)
printf,unit,st(i)
end
close,unit
scratchpad_id.file = file
scratchpad_id.path = newp
endif else begin
res = dialog_message(/Info,'File name needed in order to save', $
dialog_parent=scratchpad_id.base)
end
END
'BUTTON7': BEGIN
file = dialog_pickfile(/read,filter='*',get_path=newp,group=event.top,$
path=scratchpad_id.path,title='ScratchPad Open ...')
if strtrim(file,2) ne '' then begin
scratchpad_id.file = file
scratchpad_id.path = newp
openr,unit,file,/get_lun,error=err
st = fstat(unit)
buff = make_array(st.size,/byte)
readu,unit,buff
close,unit
WIDGET_CONTROL,scratchpad_id.textID,SET_VALUE=string(buff)
end
END
ENDCASE
END
; DO NOT REMOVE THIS COMMENT: END SCRATCHPAD_MAIN13
; CODE MODIFICATIONS MADE BELOW THIS COMMENT WILL BE LOST.
PRO scratchpad, GROUP=Group
COMMON SCRATCHPAD_BLOCK, scratchpad_id
IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0
junk = { CW_PDMENU_S, flags:0, name:'' }
SCRATCHPAD_MAIN13 = WIDGET_BASE(GROUP_LEADER=Group, $
ROW=1, TITLE='ScratchPad', $
MAP=1, $
UVALUE='SCRATCHPAD_MAIN13')
BASE2 = WIDGET_BASE(SCRATCHPAD_MAIN13, $
COLUMN=1, $
MAP=1, $
UVALUE='BASE2')
TextVal406 = [ $
'' ]
TEXT3 = WIDGET_TEXT( BASE2,VALUE=TextVal406, $
ALL_EVENTS=1, $
EDITABLE=1, /SCROLL, $
NO_NEWLINE=1, $
UVALUE='SCRATCHPAD_TEXT', $
XSIZE=40, $
YSIZE=20)
BASE4 = WIDGET_BASE(BASE2, $
ROW=1, $
MAP=1, $
UVALUE='BASE4')
BUTTON7 = WIDGET_BUTTON( BASE4, $
UVALUE='BUTTON7', $
VALUE='Open ...')
BUTTON6 = WIDGET_BUTTON( BASE4, $
UVALUE='BUTTON6', $
VALUE='Save ...')
BUTTON5 = WIDGET_BUTTON( BASE4, $
UVALUE='BUTTON5', $
VALUE='Done')
WIDGET_CONTROL, SCRATCHPAD_MAIN13, /REALIZE
CD,CURRENT=p
scratchpad_id = { $
base: SCRATCHPAD_MAIN13, $
textID: TEXT3, $
no : 0, $
text: make_array(1000,/string), $
path : p, $
file: '' $
}
XMANAGER, 'SCRATCHPAD_MAIN13', SCRATCHPAD_MAIN13
END