Rev 7422 | Rev 7437 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7422 | Rev 7434 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | // Notes v0.8 ALPHA |
1 | // Notes v0.9 Beta |
Line 2... | Line 2... | ||
2 | 2 | ||
3 | #define MEMSIZE 0xDAE80 |
3 | #define MEMSIZE 0xDAE80 |
4 | #include "..\lib\kolibri.h" |
4 | #include "..\lib\kolibri.h" |
5 | #include "..\lib\mem.h" |
5 | #include "..\lib\mem.h" |
Line 30... | Line 30... | ||
30 | ?define DELETE_TEXT "Delete"; |
30 | ?define DELETE_TEXT "Delete"; |
31 | #endif |
31 | #endif |
Line 32... | Line 32... | ||
32 | 32 | ||
33 | #define RED_LINE_X 22 |
33 | #define RED_LINE_X 22 |
34 | #define COL_RED_LINE 0xF3C9C9 |
34 | #define COL_RED_LINE 0xF3C9C9 |
35 | unsigned char edge[sizeof(file "edge.raw")]= FROM "edge.raw"; //292x6 |
35 | unsigned char edge[sizeof(file "img/edge.raw")]= FROM "img/edge.raw"; //292x6 |
36 | #define EDGE_H 6 |
36 | #define EDGE_H 6 |
37 | #define TITLE_H 24 |
37 | #define TITLE_H 24 |
38 | #define HEADER_HEIGHT TITLE_H+EDGE_H |
38 | #define HEADER_HEIGHT TITLE_H+EDGE_H |
Line 45... | Line 45... | ||
45 | #define DELETE_W sizeof(DELETE_TEXT)+2*6 |
45 | #define DELETE_W sizeof(DELETE_TEXT)+2*6 |
Line 46... | Line 46... | ||
46 | 46 | ||
Line 47... | Line 47... | ||
47 | #include "engine.h" |
47 | #include "engine.h" |
48 | 48 | ||
49 | dword ed_mouse; |
49 | dword ed_mouse; |
50 | edit_box notebox = {0,999,0,COL_BG_ACTIVE,0x94AECE,COL_BG_ACTIVE,0xffffff,0, |
50 | edit_box notebox = {NULL,NULL,NULL,COL_BG_ACTIVE,0x94AECE,COL_BG_ACTIVE,0xffffff,0, |
Line 51... | Line 51... | ||
51 | MAX_LINE_CHARS-1,NULL,#ed_mouse,ed_always_focus+ed_focus}; |
51 | MAX_LINE_CHARS-1,NULL,#ed_mouse,ed_always_focus+ed_focus}; |
52 | dword lists[] = { 0xEAEAEA, 0xCDCDCD, 0xF0F0F0, 0xD8D8D8, 0 }; |
52 | dword lists[] = { 0xEAEAEA, 0xCDCDCD, 0xF0F0F0, 0xD8D8D8, 0 }; |
Line 61... | Line 61... | ||
61 | //===================================================// |
61 | //===================================================// |
Line 62... | Line 62... | ||
62 | 62 | ||
63 | void main() |
63 | void main() |
64 | { |
64 | { |
- | 65 | int btn; |
|
65 | int btn; |
66 | bool first_redraw=true; |
66 | dword cur_line_offset; |
67 | dword cur_line_offset; |
Line 67... | Line 68... | ||
67 | load_dll(boxlib, #box_lib_init,0); |
68 | load_dll(boxlib, #box_lib_init,0); |
68 | 69 | ||
Line 69... | Line 70... | ||
69 | if (param) notes.OpenTxt(#param); else notes.OpenTxt(abspath("notes.txt")); |
70 | if (param) notes.OpenTxt(#param); else notes.OpenTxt(abspath("notes.txt")); |
Line 70... | Line 71... | ||
70 | notes.cur_y = -1; |
71 | //notes.cur_y = 0; |
71 | 72 | ||
72 | SetEventMask(0x27); |
73 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
73 | 74 | ||
Line 88... | Line 89... | ||
88 | EventDrawDeleteButton(); |
89 | EventDrawDeleteButton(); |
89 | } |
90 | } |
Line 90... | Line 91... | ||
90 | 91 | ||
91 | if (mouse.key&MOUSE_LEFT)&&(mouse.up) |
92 | if (mouse.key&MOUSE_LEFT)&&(mouse.up) |
- | 93 | && (notes.ProcessMouse(mouse.x, mouse.y)) { |
|
92 | && (notes.ProcessMouse(mouse.x, mouse.y)) { |
94 | notebox.pos = mouse.x - notebox.left / 6; |
93 | EventListRedraw(); |
95 | EventListRedraw(); |
94 | EventActivateLine(notes.cur_y); |
96 | EventActivateLine(notes.cur_y); |
Line 95... | Line 97... | ||
95 | } |
97 | } |
Line 105... | Line 107... | ||
105 | break; |
107 | break; |
106 | case DELETE_BTN: |
108 | case DELETE_BTN: |
107 | EventDeleteCurrentNode(); |
109 | EventDeleteCurrentNode(); |
108 | break; |
110 | break; |
109 | default: |
111 | default: |
110 | notes.lines[btn-CHECKBOX_ID].state ^= 1; |
112 | EventCheckBoxClick(btn-CHECKBOX_ID); |
111 | EventListRedraw(); |
- | |
112 | break; |
113 | break; |
113 | } |
114 | } |
114 | break; |
115 | break; |
Line 115... | Line 116... | ||
115 | 116 | ||
116 | case evKey: |
117 | case evKey: |
- | 118 | GetKeys(); |
|
- | 119 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) |
|
- | 120 | { |
|
- | 121 | if (key_scancode == SCAN_CODE_SPACE) |
|
- | 122 | { |
|
- | 123 | EventCheckBoxClick(notes.cur_y); |
|
- | 124 | } |
|
- | 125 | break; |
|
117 | GetKeys(); |
126 | } |
118 | switch(key_scancode) |
127 | switch(key_scancode) |
119 | { |
128 | { |
120 | case SCAN_CODE_ESC: |
129 | case SCAN_CODE_ESC: |
121 | EventExitApp(); |
130 | EventExitApp(); |
Line 135... | Line 144... | ||
135 | } |
144 | } |
136 | break; |
145 | break; |
Line 137... | Line 146... | ||
137 | 146 | ||
138 | case evReDraw: |
147 | case evReDraw: |
- | 148 | draw_window(); |
|
- | 149 | if (first_redraw) { |
|
- | 150 | first_redraw = false; |
|
- | 151 | EventActivateLine(0); |
|
139 | draw_window(); |
152 | } |
140 | } |
153 | } |
Line 141... | Line 154... | ||
141 | } |
154 | } |
142 | 155 | ||
Line 170... | Line 183... | ||
170 | 183 | ||
171 | void DrawEditBoxN() |
184 | void DrawEditBoxN() |
172 | { |
185 | { |
173 | notebox.width = notes.w-notes.x-8; |
186 | notebox.width = notes.w-notes.x-8; |
174 | notebox.left = notes.x+5; |
187 | notebox.left = notes.x+5; |
175 | notebox.pos = notebox.offset = notebox.shift = notebox.shift_old = 0; |
188 | notebox.offset = notebox.shift = notebox.shift_old = 0; |
176 | notebox.cl_curs_x = notebox.cl_curs_y = 0; |
189 | notebox.cl_curs_x = notebox.cl_curs_y = 0; |
- | 190 | notebox.size = strlen(notebox.text); |
|
177 | notebox.size = strlen(notebox.text); |
191 | if (notebox.pos > notebox.size) notebox.pos = notebox.size; |
178 | notebox.top = notes.cur_y*notes.item_h+4+notes.y; |
192 | notebox.top = notes.cur_y*notes.item_h+4+notes.y; |
179 | edit_box_draw stdcall(#notebox); |
193 | edit_box_draw stdcall(#notebox); |
Line 180... | Line 194... | ||
180 | } |
194 | } |
Line 210... | Line 224... | ||
210 | delete_active = true; |
224 | delete_active = true; |
211 | } |
225 | } |
Line 212... | Line 226... | ||
212 | 226 | ||
213 | void EventDeleteCurrentNode() |
227 | void EventDeleteCurrentNode() |
- | 228 | { |
|
214 | { |
229 | int t = notes.cur_y; |
215 | notes.lines[notes.cur_y].Delete(); |
230 | notes.lines[t].Delete(); |
216 | EventListRedraw(); |
231 | EventListRedraw(); |
Line 217... | Line 232... | ||
217 | } |
232 | } |
218 | 233 | ||
219 | void EventListRedraw() |
234 | void EventListRedraw() |
220 | { |
235 | { |
221 | delete_active = false; |
236 | delete_active = false; |
222 | DeleteButton(DELETE_BTN); |
237 | DeleteButton(DELETE_BTN); |
Line -... | Line 238... | ||
- | 238 | notes.DrawList(); |
|
- | 239 | } |
|
- | 240 | ||
- | 241 | void EventCheckBoxClick(int id) |
|
- | 242 | { |
|
- | 243 | notes.lines[id].state ^= 1; |
|
223 | notes.DrawList(); |
244 | EventListRedraw(); |