Rev 6567 | Rev 6570 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6567 | Rev 6568 | ||
---|---|---|---|
1 | #ifndef AUTOBUILD |
1 | #ifndef AUTOBUILD |
2 | ?include "lang.h--" |
2 | ?include "lang.h--" |
3 | #endif |
3 | #endif |
4 | 4 | ||
5 | #define MEMSIZE 0xDFE800 |
5 | #define MEMSIZE 0xDFE800 |
6 | #include "..\lib\mem.h" |
6 | #include "..\lib\mem.h" |
7 | #include "..\lib\strings.h" |
7 | #include "..\lib\strings.h" |
8 | #include "..\lib\list_box.h" |
8 | #include "..\lib\list_box.h" |
9 | #include "..\lib\clipboard.h" |
9 | #include "..\lib\clipboard.h" |
10 | #include "..\lib\gui.h" |
10 | #include "..\lib\gui.h" |
11 | #include "..\lib\obj\box_lib.h" |
11 | #include "..\lib\obj\box_lib.h" |
12 | 12 | ||
13 | 13 | ||
14 | //===================================================// |
14 | //===================================================// |
15 | // // |
15 | // // |
16 | // DATA // |
16 | // DATA // |
17 | // // |
17 | // // |
18 | //===================================================// |
18 | //===================================================// |
19 | 19 | ||
20 | ?define WINDOW_HEADER "Clipboard viewer v1.0" |
20 | ?define WINDOW_HEADER "Clipboard viewer v1.01" |
21 | ?define T_DELETE_LAST_SLOT "Delete last slot" |
21 | ?define T_DELETE_LAST_SLOT "Delete last slot" |
22 | ?define T_DELETE_ALL_SLOTS "Delete all slots" |
22 | ?define T_DELETE_ALL_SLOTS "Delete all slots" |
23 | ?define T_RESET_BUFFER_LOCK "Reset the lock buffer" |
23 | ?define T_RESET_BUFFER_LOCK "Reset the lock buffer" |
24 | ?define T_COLUMNS_TITLE "# | Data size | Data type | Contents" |
24 | ?define T_COLUMNS_TITLE "# | Data size | Data type | Contents" |
25 | ?define T_COLUMN_VIEW "View" |
25 | ?define T_COLUMN_VIEW "View" |
26 | ?define T_VIEW_OPTIONS "TEXT HEX" |
26 | ?define T_VIEW_OPTIONS "TEXT HEX" |
27 | ?define T_CLIPBOARD_IS_EMPTY "Clipboard is empty" |
27 | ?define T_CLIPBOARD_IS_EMPTY "Clipboard is empty" |
28 | ?define DEFAULT_SAVE_PATH "/tmp0/1/clipview.tmp" |
28 | ?define DEFAULT_SAVE_PATH "/tmp0/1/clipview.tmp" |
29 | char *data_type[] = { "Text", "Image", "RAW", "Unknown" }; |
29 | char *data_type[] = { "Text", "Image", "RAW", "Unknown" }; |
30 | 30 | ||
31 | enum { |
31 | enum { |
32 | BT_DELETE_LAST_SLOT = 10, |
32 | BT_DELETE_LAST_SLOT = 10, |
33 | BT_DELETE_ALL_SLOTS, |
33 | BT_DELETE_ALL_SLOTS, |
34 | BT_UNLOCK |
34 | BT_UNLOCK |
35 | }; |
35 | }; |
36 | 36 | ||
37 | 37 | ||
38 | #define PANEL_TOP_H 20 |
38 | #define PANEL_TOP_H 20 |
39 | #define PANEL_BOTTOM_H 30 |
39 | #define PANEL_BOTTOM_H 30 |
40 | #define LIST_PADDING 12 |
40 | #define LIST_PADDING 12 |
41 | 41 | ||
42 | llist list; |
42 | llist list; |
43 | 43 | ||
44 | proc_info Form; |
44 | proc_info Form; |
45 | 45 | ||
46 | Clipboard clipboard; |
46 | Clipboard clipboard; |
47 | 47 | ||
48 | scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
48 | scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
49 | 49 | ||
50 | 50 | ||
51 | //===================================================// |
51 | //===================================================// |
52 | // // |
52 | // // |
53 | // CODE // |
53 | // CODE // |
54 | // // |
54 | // // |
55 | //===================================================// |
55 | //===================================================// |
56 | 56 | ||
57 | void main() |
57 | void main() |
58 | { |
58 | { |
59 | int id; |
59 | int id; |
60 | 60 | ||
61 | list.SetFont(8, 14, 0x90); |
61 | list.SetFont(8, 14, 0x90); |
62 | list.no_selection = true; |
62 | list.no_selection = true; |
63 | SetEventMask(0x27); |
63 | SetEventMask(0x27); |
64 | load_dll(boxlib, #box_lib_init,0); |
64 | load_dll(boxlib, #box_lib_init,0); |
65 | loop() |
65 | loop() |
66 | { |
66 | { |
67 | WaitEventTimeout(10); |
67 | WaitEventTimeout(10); |
68 | switch(EAX & 0xFF) |
68 | switch(EAX & 0xFF) |
69 | { |
69 | { |
70 | case evMouse: |
70 | case evMouse: |
71 | if (!CheckActiveProcess(Form.ID)) break; |
71 | if (!CheckActiveProcess(Form.ID)) break; |
72 | mouse.get(); |
72 | mouse.get(); |
73 | scrollbar_v_mouse (#scroll1); |
73 | scrollbar_v_mouse (#scroll1); |
74 | if (list.first != scroll1.position) |
74 | if (list.first != scroll1.position) |
75 | { |
75 | { |
76 | list.first = scroll1.position; |
76 | list.first = scroll1.position; |
77 | Draw_List(); |
77 | Draw_List(); |
78 | break; |
78 | break; |
79 | } |
79 | } |
80 | if (mouse.vert) && (list.MouseScroll(mouse.vert)) Draw_List(); |
80 | if (mouse.vert) && (list.MouseScroll(mouse.vert)) Draw_List(); |
81 | break; |
81 | break; |
82 | 82 | ||
83 | 83 | ||
84 | case evButton: |
84 | case evButton: |
85 | id=GetButtonID(); |
85 | id=GetButtonID(); |
86 | if (id==1) ExitProcess(); |
86 | if (id==1) ExitProcess(); |
87 | if (id==BT_DELETE_LAST_SLOT) EventDeleteLastSlot(); |
87 | if (id==BT_DELETE_LAST_SLOT) EventDeleteLastSlot(); |
88 | if (id==BT_DELETE_ALL_SLOTS) EventDeleteAllSlots(); |
88 | if (id==BT_DELETE_ALL_SLOTS) EventDeleteAllSlots(); |
89 | if (id==BT_UNLOCK) EventResetBufferLock(); |
89 | if (id==BT_UNLOCK) EventResetBufferLock(); |
90 | if (id>=100) && (id<300) EventOpenAsText(id-100); |
90 | if (id>=100) && (id<300) EventOpenAsText(id-100); |
91 | if (id>=300) EventOpenAsHex(id-300); |
91 | if (id>=300) EventOpenAsHex(id-300); |
92 | break; |
92 | break; |
93 | 93 | ||
94 | case evKey: |
94 | case evKey: |
95 | GetKeys(); |
95 | GetKeys(); |
96 | if (list.ProcessKey(key_scancode)) Draw_List(); |
96 | if (list.ProcessKey(key_scancode)) Draw_List(); |
97 | break; |
97 | break; |
98 | 98 | ||
99 | case evReDraw: |
99 | case evReDraw: |
100 | system.color.get(); |
100 | system.color.get(); |
101 | DefineAndDrawWindow(screen.width-700/2,80,700,454+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0); |
101 | DefineAndDrawWindow(screen.width-700/2,80,700,454+skin_height,0x73,0xE4DFE1,WINDOW_HEADER,0); |
102 | GetProcessInfo(#Form, SelfInfo); |
102 | GetProcessInfo(#Form, SelfInfo); |
103 | IF (Form.status_window>=2) break; |
103 | IF (Form.status_window>=2) break; |
104 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } |
104 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } |
105 | if (Form.width < 570) { MoveSize(OLD,OLD,570,OLD); break; } |
105 | if (Form.width < 570) { MoveSize(OLD,OLD,570,OLD); break; } |
106 | list.SetSizes(LIST_PADDING, LIST_PADDING+PANEL_TOP_H, Form.cwidth-LIST_PADDING-LIST_PADDING-scroll1.size_x, |
106 | list.SetSizes(LIST_PADDING, LIST_PADDING+PANEL_TOP_H, Form.cwidth-LIST_PADDING-LIST_PADDING-scroll1.size_x, |
107 | Form.cheight-PANEL_BOTTOM_H-PANEL_TOP_H-LIST_PADDING-LIST_PADDING, 20); |
107 | Form.cheight-PANEL_BOTTOM_H-PANEL_TOP_H-LIST_PADDING-LIST_PADDING, 20); |
108 | DrawWindowContent(); |
108 | DrawWindowContent(); |
109 | Draw_List(); |
109 | Draw_List(); |
110 | break; |
110 | break; |
111 | 111 | ||
112 | default: |
112 | default: |
113 | if (clipboard.GetSlotCount() > list.count) Draw_List(); |
113 | if (clipboard.GetSlotCount() > list.count) Draw_List(); |
114 | break; |
114 | break; |
115 | } |
115 | } |
116 | } |
116 | } |
117 | } |
117 | } |
118 | 118 | ||
119 | void DrawWindowContent() |
119 | void DrawWindowContent() |
120 | { |
120 | { |
121 | int button_x = list.x; |
121 | int button_x = list.x; |
122 | DrawBar(0,0, Form.cwidth, PANEL_TOP_H, system.color.work); |
122 | DrawBar(0,0, Form.cwidth, PANEL_TOP_H, system.color.work); |
123 | DrawBar(0,Form.cheight-PANEL_BOTTOM_H, Form.cwidth, PANEL_BOTTOM_H, system.color.work); |
123 | DrawBar(0,Form.cheight-PANEL_BOTTOM_H, Form.cwidth, PANEL_BOTTOM_H, system.color.work); |
124 | DrawRectangle3D(list.x-2, list.y-2, list.w+3+scroll1.size_x, list.h+3, system.color.work_dark, system.color.work_light); |
124 | DrawRectangle3D(list.x-2, list.y-2, list.w+3+scroll1.size_x, list.h+3, system.color.work_dark, system.color.work_light); |
125 | DrawWideRectangle(list.x-LIST_PADDING, list.y-LIST_PADDING, LIST_PADDING*2+list.w+scroll1.size_x, LIST_PADDING*2+list.h, LIST_PADDING-2, system.color.work); |
125 | DrawWideRectangle(list.x-LIST_PADDING, list.y-LIST_PADDING, LIST_PADDING*2+list.w+scroll1.size_x, LIST_PADDING*2+list.h, LIST_PADDING-2, system.color.work); |
126 | button_x += DrawStandartCaptButton(button_x, list.y + list.h + 8, BT_DELETE_LAST_SLOT, system.color.work_button, system.color.work_button_text, T_DELETE_LAST_SLOT); |
126 | button_x += DrawStandartCaptButton(button_x, list.y + list.h + 8, BT_DELETE_LAST_SLOT, system.color.work_button, system.color.work_button_text, T_DELETE_LAST_SLOT); |
127 | button_x += DrawStandartCaptButton(button_x, list.y + list.h + 8, BT_DELETE_ALL_SLOTS, system.color.work_button, system.color.work_button_text, T_DELETE_ALL_SLOTS); |
127 | button_x += DrawStandartCaptButton(button_x, list.y + list.h + 8, BT_DELETE_ALL_SLOTS, system.color.work_button, system.color.work_button_text, T_DELETE_ALL_SLOTS); |
128 | button_x += DrawStandartCaptButton(button_x, list.y + list.h + 8, BT_UNLOCK, system.color.work_button, system.color.work_button_text, T_RESET_BUFFER_LOCK); |
128 | button_x += DrawStandartCaptButton(button_x, list.y + list.h + 8, BT_UNLOCK, system.color.work_button, system.color.work_button_text, T_RESET_BUFFER_LOCK); |
129 | DrawRectangle(list.x-1, list.y-1, list.w+1+scroll1.size_x, list.h+1, system.color.work_graph); |
129 | DrawRectangle(list.x-1, list.y-1, list.w+1+scroll1.size_x, list.h+1, system.color.work_graph); |
130 | WriteText(list.x+12, list.y - 23, list.font_type, system.color.work_text, T_COLUMNS_TITLE); |
130 | WriteText(list.x+12, list.y - 23, list.font_type, system.color.work_text, T_COLUMNS_TITLE); |
131 | WriteText(list.x+list.w-68, list.y - 23, list.font_type, system.color.work_text, T_COLUMN_VIEW); |
131 | WriteText(list.x+list.w-68, list.y - 23, list.font_type, system.color.work_text, T_COLUMN_VIEW); |
132 | } |
132 | } |
133 | 133 | ||
134 | void DrawScroller() |
134 | void DrawScroller() |
135 | { |
135 | { |
136 | scroll1.bckg_col = MixColors(system.color.work, 0xBBBbbb, 80); |
136 | scroll1.bckg_col = MixColors(system.color.work, 0xBBBbbb, 80); |
137 | scroll1.frnt_col = MixColors(system.color.work,0xFFFfff,120); |
137 | scroll1.frnt_col = MixColors(system.color.work,0xFFFfff,120); |
138 | scroll1.line_col = system.color.work_graph; |
138 | scroll1.line_col = system.color.work_graph; |
139 | 139 | ||
140 | scroll1.max_area = list.count; |
140 | scroll1.max_area = list.count; |
141 | scroll1.cur_area = list.visible; |
141 | scroll1.cur_area = list.visible; |
142 | scroll1.position = list.first; |
142 | scroll1.position = list.first; |
143 | 143 | ||
144 | scroll1.all_redraw=1; |
144 | scroll1.all_redraw=1; |
145 | scroll1.start_x = list.x + list.w; |
145 | scroll1.start_x = list.x + list.w; |
146 | scroll1.start_y = list.y-1; |
146 | scroll1.start_y = list.y-1; |
147 | scroll1.size_y = list.h+2; |
147 | scroll1.size_y = list.h+2; |
148 | 148 | ||
149 | scrollbar_v_draw(#scroll1); |
149 | scrollbar_v_draw(#scroll1); |
150 | } |
150 | } |
151 | 151 | ||
152 | 152 | ||
153 | void Draw_List() |
153 | void Draw_List() |
154 | { |
154 | { |
155 | int i, yyy, list_last, slot_data_type_number; |
155 | int i, yyy, list_last, slot_data_type_number; |
156 | dword text_color = 0x000000; |
156 | dword text_color = 0x000000; |
157 | char line_text[512]; |
157 | char line_text[512]; |
158 | dword size_kb; |
158 | dword size_kb; |
159 | 159 | ||
160 | list.count = clipboard.GetSlotCount(); |
160 | list.count = clipboard.GetSlotCount(); |
161 | list.CheckDoesValuesOkey(); |
161 | list.CheckDoesValuesOkey(); |
162 | 162 | ||
163 | 163 | ||
164 | if (list.count > list.visible) list_last = list.visible; else list_last = list.count; |
164 | if (list.count > list.visible) list_last = list.visible; else list_last = list.count; |
165 | 165 | ||
166 | for (i=0; i |
166 | for (i=0; i |
167 | for (i=0; i |
167 | for (i=0; i |
168 | 168 | ||
169 | for (i=0; i |
169 | for (i=0; i |
170 | { |
170 | { |
171 | clipboard.GetSlotData(list.first + i); |
171 | clipboard.GetSlotData(list.first + i); |
172 | yyy = i*list.item_h+list.y; |
172 | yyy = i*list.item_h+list.y; |
173 | DrawBar(list.x,yyy,list.w, list.item_h, 0xFFFfff); |
173 | DrawBar(list.x,yyy,list.w, list.item_h, 0xFFFfff); |
174 | WriteText(list.x+12, yyy+list.text_y, list.font_type, text_color, itoa(list.first + i)); |
174 | WriteText(list.x+12, yyy+list.text_y, list.font_type, text_color, itoa(list.first + i)); |
175 | //WriteText(list.x+44, yyy+list.text_y, list.font_type, text_color, itoa(clipboard.slot_data.size)); |
175 | //WriteText(list.x+44, yyy+list.text_y, list.font_type, text_color, itoa(clipboard.slot_data.size)); |
176 | size_kb = ConvertSizeToKb(clipboard.slot_data.size); |
176 | size_kb = ConvertSizeToKb(clipboard.slot_data.size); |
177 | WriteText(list.x+44, yyy+list.text_y, list.font_type, text_color, size_kb); |
177 | WriteText(list.x+44, yyy+list.text_y, list.font_type, text_color, size_kb); |
178 | slot_data_type_number = clipboard.slot_data.type; |
178 | slot_data_type_number = clipboard.slot_data.type; |
179 | WriteText(list.x+140, yyy+list.text_y, list.font_type, text_color, data_type[slot_data_type_number]); |
179 | WriteText(list.x+140, yyy+list.text_y, list.font_type, text_color, data_type[slot_data_type_number]); |
180 | WriteText(list.x+list.w - 88, yyy+list.text_y, list.font_type, 0x006597, T_VIEW_OPTIONS); |
180 | WriteText(list.x+list.w - 88, yyy+list.text_y, list.font_type, 0x006597, T_VIEW_OPTIONS); |
181 | DefineButton(list.x+list.w - 95, yyy, 50, list.item_h, 100+i+BT_HIDE, NULL); |
181 | DefineButton(list.x+list.w - 95, yyy, 50, list.item_h, 100+i+BT_HIDE, NULL); |
182 | DefineButton(list.x+list.w - 95 + 51, yyy, 40, list.item_h, 300+i+BT_HIDE, NULL); |
182 | DefineButton(list.x+list.w - 95 + 51, yyy, 40, list.item_h, 300+i+BT_HIDE, NULL); |
183 | 183 | ||
184 | strlcpy(#line_text, clipboard.slot_data.content, list.w-236 - 95/list.font_w-3); |
184 | strlcpy(#line_text, clipboard.slot_data.content, list.w-236 - 95/list.font_w-3); |
185 | WriteText(list.x+236, yyy+list.text_y, list.font_type, text_color, #line_text); |
185 | WriteText(list.x+236, yyy+list.text_y, list.font_type, text_color, #line_text); |
186 | } |
186 | } |
187 | DrawBar(list.x,i*list.item_h+list.y, list.w, -i*list.item_h+ list.h, 0xFFFfff); |
187 | DrawBar(list.x,i*list.item_h+list.y, list.w, -i*list.item_h+ list.h, 0xFFFfff); |
188 | if (!list.count) WriteText(-strlen(T_CLIPBOARD_IS_EMPTY)*list.font_w + list.w / 2 + list.x + 1, list.h / 2 - 8 + list.y, list.font_type, 0x999999, T_CLIPBOARD_IS_EMPTY); |
188 | if (!list.count) WriteText(-strlen(T_CLIPBOARD_IS_EMPTY)*list.font_w + list.w / 2 + list.x + 1, list.h / 2 - 8 + list.y, list.font_type, 0x999999, T_CLIPBOARD_IS_EMPTY); |
189 | DrawScroller(); |
189 | DrawScroller(); |
190 | } |
190 | } |
191 | 191 | ||
192 | int SaveSlotContents(int slot_id) { |
192 | int SaveSlotContents(int slot_id) { |
193 | clipboard.GetSlotData(slot_id); |
193 | clipboard.GetSlotData(slot_id); |
194 | EAX = WriteFile(clipboard.slot_data.size, clipboard.slot_data.content, DEFAULT_SAVE_PATH); |
194 | EAX = WriteFile(clipboard.slot_data.size, clipboard.slot_data.content, DEFAULT_SAVE_PATH); |
195 | if (!EAX) |
195 | if (!EAX) |
196 | { |
196 | { |
197 | return true; |
197 | return true; |
198 | } |
198 | } |
199 | else { |
199 | else { |
200 | notify("'Can not create /tmp0/1/clipview.tmp\nPreview function is not available.' -E"); |
200 | notify("'Can not create /tmp0/1/clipview.tmp\nPreview function is not available.' -E"); |
201 | return false; |
201 | return false; |
202 | } |
202 | } |
203 | } |
203 | } |
204 | 204 | ||
205 | //===================================================// |
205 | //===================================================// |
206 | // // |
206 | // // |
207 | // EVENTS // |
207 | // EVENTS // |
208 | // // |
208 | // // |
209 | //===================================================// |
209 | //===================================================// |
210 | 210 | ||
211 | void EventDeleteLastSlot() |
211 | void EventDeleteLastSlot() |
212 | { |
212 | { |
213 | clipboard.DelLastSlot(); |
213 | clipboard.DelLastSlot(); |
214 | Draw_List(); |
214 | Draw_List(); |
215 | } |
215 | } |
216 | 216 | ||
217 | void EventDeleteAllSlots() |
217 | void EventDeleteAllSlots() |
218 | { |
218 | { |
219 | while (clipboard.GetSlotCount()) clipboard.DelLastSlot(); |
219 | while (clipboard.GetSlotCount()) clipboard.DelLastSlot(); |
220 | Draw_List(); |
220 | Draw_List(); |
221 | } |
221 | } |
222 | 222 | ||
223 | void EventResetBufferLock() { |
223 | void EventResetBufferLock() { |
224 | clipboard.ResetBlockingBuffer(); |
224 | clipboard.ResetBlockingBuffer(); |
225 | Draw_List(); |
225 | Draw_List(); |
226 | } |
226 | } |
227 | 227 | ||
228 | void EventOpenAsText(int slot_id) { |
228 | void EventOpenAsText(int slot_id) { |
229 | if (SaveSlotContents(slot_id)) RunProgram("/sys/tinypad", DEFAULT_SAVE_PATH); |
229 | if (SaveSlotContents(slot_id)) RunProgram("/sys/tinypad", DEFAULT_SAVE_PATH); |
230 | } |
230 | } |
231 | 231 | ||
232 | void EventOpenAsHex(int slot_id) { |
232 | void EventOpenAsHex(int slot_id) { |
233 | if (SaveSlotContents(slot_id)) RunProgram("/sys/develop/heed", DEFAULT_SAVE_PATH); |
233 | if (SaveSlotContents(slot_id)) RunProgram("/sys/develop/heed", DEFAULT_SAVE_PATH); |
234 | } |
234 | } |
235 | 235 | ||
236 | stop:>>300)> |
236 | stop:>>300)> |