Subversion Repositories Kolibri OS

Rev

Rev 7331 | Rev 7434 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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