Rev 7422 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7331 | leency | 1 | #define LINES_COUNT 13 |
2 | #define MAX_LINE_CHARS 256 |
||
3 | |||
4 | #define CHBOX 12 |
||
5 | #define CHECKBOX_ID 50 |
||
6 | unsigned char checkbox[sizeof(file "checkbox.raw")]= FROM "checkbox.raw"; |
||
7 | |||
8 | #define COL_BG_ACTIVE 0xFFE56B |
||
9 | #define COL_BG_INACTIVE 0xFFFFFF |
||
10 | |||
11 | //===================================================// |
||
12 | // // |
||
13 | // LINE // |
||
14 | // // |
||
15 | //===================================================// |
||
16 | |||
17 | struct NOTE_LINE |
||
18 | { |
||
19 | bool state; |
||
20 | char data[MAX_LINE_CHARS]; |
||
21 | }; |
||
22 | |||
23 | //===================================================// |
||
24 | // // |
||
25 | // LIST // |
||
26 | // // |
||
27 | //===================================================// |
||
28 | |||
29 | struct NOTES { |
||
30 | llist list; |
||
31 | char txt_path[4096]; |
||
32 | char txt_data[MAX_LINE_CHARS*LINES_COUNT]; |
||
33 | |||
34 | NOTE_LINE lines[LINES_COUNT]; |
||
35 | |||
36 | char edit_active; |
||
37 | int OpenTxt(); |
||
38 | int SaveTxt(); |
||
39 | void DeleteCurrentNode(); |
||
40 | void DrawList(); |
||
41 | dword DrawLine(int line_n, draw_h); |
||
42 | } notes; |
||
43 | |||
44 | |||
45 | int NOTES::OpenTxt(dword file_path) |
||
46 | { |
||
47 | int i=0, linepos=0; |
||
48 | int item_n=-1; |
||
49 | |||
50 | strcpy(#txt_path, file_path); |
||
51 | ReadFile(0, 4096, #txt_data, #txt_path); |
||
52 | if (!txt_data) || (strncmp(#txt_data, "notes", 5)!=0) |
||
53 | { |
||
54 | notify("'Notes\nData file does not exists or is not valid' -tE"); |
||
55 | return 0; |
||
56 | } |
||
57 | else |
||
58 | { |
||
59 | i+=5; //skip "notes" indefinier |
||
60 | while (txt_data[i]) |
||
61 | { |
||
62 | if (txt_data[i]=='\n') { |
||
63 | item_n++; |
||
64 | i+=2; |
||
65 | if (txt_data[i]=='-') lines[item_n].state=false; else lines[item_n].state=true; |
||
66 | i+=2; |
||
67 | linepos = 0; |
||
68 | continue; |
||
69 | } |
||
70 | if (linepos |
||
71 | linepos++; |
||
72 | i++; |
||
73 | } |
||
74 | list.count = item_n; |
||
75 | return 1; |
||
76 | } |
||
77 | } |
||
78 | |||
79 | int NOTES::SaveTxt() |
||
80 | { |
||
81 | int i; |
||
82 | dword tm; |
||
83 | strcpy(#txt_data, "notes"); |
||
84 | for (i=0; i<=list.count; i++) |
||
85 | { |
||
86 | if (lines[i].state==false) strcat(#txt_data, "\n- "); else strcat(#txt_data, "\n+ "); |
||
87 | tm = #lines[i].data; |
||
88 | strcat(#txt_data, #lines[i].data); |
||
89 | } |
||
90 | WriteFile(0, strlen(#txt_data), #txt_data, #txt_path); |
||
91 | } |
||
92 | |||
93 | void NOTES::DeleteCurrentNode() |
||
94 | { |
||
95 | return; |
||
96 | } |
||
97 | |||
98 | void NOTES::DrawList() |
||
99 | { |
||
100 | int i; |
||
101 | for (i=0; i |
||
102 | } |
||
103 | |||
104 | |||
105 | dword NOTES::DrawLine(int line_n, draw_h) { |
||
106 | dword |
||
107 | COL_BOTTOM_LINE=0xE8EFF4, |
||
108 | COL_BG, |
||
109 | cur_text; |
||
110 | char line_text[4096]; |
||
111 | if (line_n<0) return; |
||
112 | if (line_n==list.cur_y) COL_BG = COL_BG_ACTIVE; else COL_BG = COL_BG_INACTIVE; |
||
113 | DrawBar(list.x, line_n*list.item_h+list.y, RED_LINE_X, draw_h-1, COL_BG_INACTIVE); |
||
114 | DrawBar(list.x+RED_LINE_X+1, line_n*list.item_h+list.y, list.w-RED_LINE_X-1, draw_h-1, COL_BG); |
||
115 | |||
116 | cur_text = #lines[line_n].data; |
||
117 | |||
118 | if (draw_h!=list.item_h) |
||
119 | { |
||
120 | COL_BOTTOM_LINE=COL_BG; |
||
121 | } |
||
122 | else |
||
123 | { |
||
124 | DefineButton(RED_LINE_X-CHBOX/2+list.x, list.item_h*line_n+5+list.y, CHBOX-1,CHBOX-1, CHECKBOX_ID+line_n+BT_HIDE, 0); //checkbox |
||
125 | _PutImage(RED_LINE_X-CHBOX/2+list.x, list.item_h*line_n+5+list.y, CHBOX,CHBOX, lines[line_n].state*CHBOX*CHBOX*3+#checkbox); |
||
126 | if (cur_text) WriteText(list.x+RED_LINE_X+6, list.item_h*line_n+7+list.y, 0x80, lines[line_n].state*0x777777, cur_text); |
||
127 | if (lines[line_n].state == true) DrawBar(list.x+RED_LINE_X+6, list.item_h*line_n+11+list.y, strlen(cur_text)*6, 1, 0x444444); //strike |
||
128 | } |
||
129 | DrawBar(list.x, line_n*list.item_h+draw_h-1+list.y, list.w, 1, COL_BOTTOM_LINE); |
||
130 | DrawBar(list.x+RED_LINE_X, line_n*list.item_h+list.y, 1, draw_h, COL_RED_LINE); |
||
131 | return cur_text; |
||
132 | }0)>=list.count;> |