Subversion Repositories Kolibri OS

Rev

Rev 6535 | Rev 6561 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6535 Rev 6560
Line 1... Line 1...
1
#ifndef KOLIBRI_FILEBROWSE_H
1
#ifndef KOLIBRI_FILEBROWSE_H
2
#define KOLIBRI_FILEBROWSE_H
2
#define KOLIBRI_FILEBROWSE_H
Line -... Line 3...
-
 
3
 
-
 
4
struct  __attribute__ ((__packed__)) fs_dirinfo {
-
 
5
    uint32_t    subfn; // 1 read dir
-
 
6
    uint32_t    start;
-
 
7
    uint32_t    flags;
-
 
8
    uint32_t    size;
-
 
9
    uint32_t    retval;
-
 
10
    union {
-
 
11
        struct __attribute__ ((__packed__)) {
-
 
12
            uint8_t zero;  // 0
-
 
13
            char*   ppath;
-
 
14
        };
-
 
15
        char path[5];  // up to 4096
-
 
16
    } ;
-
 
17
};
-
 
18
 
-
 
19
static inline
-
 
20
uint32_t sf_file(int subfn, struct fs_dirinfo* dinfo)
-
 
21
// retval 0 if ok
-
 
22
{
-
 
23
    uint32_t retval;
-
 
24
    dinfo->subfn = subfn;
-
 
25
 
-
 
26
    __asm__ __volatile__(
-
 
27
    "int $0x40 "
-
 
28
    :"=a"(retval)
-
 
29
    :"a"(70),"b"(dinfo)
-
 
30
    :);
-
 
31
 
-
 
32
    return retval;
-
 
33
};
-
 
34
 
-
 
35
 
-
 
36
struct fs_dirheader {
-
 
37
    uint32_t     version; // 1
-
 
38
    uint32_t     curn_blocks;  // number of read dir items (BDFE)
-
 
39
    uint32_t     totl_blocks;  // directory full size
-
 
40
    char         other[20]; // reserved 0
-
 
41
};
-
 
42
 
-
 
43
enum filetype
-
 
44
{
-
 
45
    fs_readonly = 1,
-
 
46
    fs_hidden = 2,
-
 
47
    fs_system = 4,
-
 
48
    fs_volumelabel = 8,
-
 
49
    fs_folder = 0x10,
-
 
50
    fs_nonarchived = 0x20
-
 
51
};
-
 
52
 
-
 
53
struct __attribute__ ((__packed__)) fs_filetime {
-
 
54
    uint8_t    sec;
-
 
55
    uint8_t    mm;
-
 
56
    uint8_t    hour;
-
 
57
    uint8_t    zero;
-
 
58
};
-
 
59
 
-
 
60
struct __attribute__ ((__packed__)) fs_filedate {
-
 
61
    uint8_t    day;
-
 
62
    uint8_t    month;
-
 
63
    uint16_t   year;
-
 
64
};
-
 
65
 
3
 
66
/// directory entry cp866
-
 
67
struct fsBDFE {
-
 
68
    uint32_t filetype;
-
 
69
    uint32_t encoding; // 0 - cp866, 1 - utf16le
-
 
70
    struct fs_filetime tm_created;
-
 
71
    struct fs_filedate dt_created;
-
 
72
    struct fs_filetime tm_accessed;
-
 
73
    struct fs_filedate dt_accessed;
-
 
74
    struct fs_filetime tm_modified;
-
 
75
    struct fs_filedate dt_modified;
-
 
76
    uint64_t size;
-
 
77
    char   fname[264];
-
 
78
}; // must be sized 304
-
 
79
 
-
 
80
/// directory entry UTF16LE
4
typedef struct {
81
struct fsBDFE_16 {
-
 
82
    uint32_t filetype;
-
 
83
    uint32_t encoding; // 0 - cp866, 1 - utf16le
-
 
84
    struct fs_filetime tm_created;
-
 
85
    struct fs_filedate dt_created;
-
 
86
    struct fs_filetime tm_accessed;
-
 
87
    struct fs_filedate dt_accessed;
-
 
88
    struct fs_filetime tm_modified;
-
 
89
    struct fs_filedate dt_modified;
-
 
90
    uint64_t size;
-
 
91
    wchar_t   fname[260];
-
 
92
}; // must be sized 560
-
 
93
 
-
 
94
 
-
 
95
typedef struct __attribute__ ((__packed__)) {
5
	uint32_t type;
96
	uint32_t type;  // unused
6
	uint32_t x_w;  // 10, 400
97
	uint32_t x_w;  // 10, 400
7
	uint32_t y_h; // 45, 550
98
	uint32_t y_h; // 45, 550
8
	uint32_t icon_size_xy;  // x_y (16, 16)
99
	uint32_t icon_size_xy;  // x_y (16, 16)
9
	uint16_t line_size_x;
100
	uint16_t line_size_x;  // not used
10
	uint16_t line_size_y;  // 18 or 17  - âûñîòà ëèíèè
101
	uint16_t line_size_y;  // 18 or 17  - âûñîòà ëèíèè - ñòðîêè ñ ôàéëîì
11
	uint16_t type_size_x;
102
	uint16_t type_size_x;  // not used
12
	uint16_t size_size_x;
103
	uint16_t size_size_x;  // not used
13
	uint16_t date_size_x;
104
	uint16_t date_size_x;  // not used
14
	uint16_t attributes_size_x;
105
	uint16_t attributes_size_x; // not used
15
	uint32_t icon_assoc_area;
106
	uint32_t icon_assoc_area;  // not used
16
	uint32_t icon_raw_area;   // z_icons.png
107
	void* icon_raw_area;   // z_icons.png
17
	uint32_t icon_resolution_raw;  // ...
108
	uint32_t icon_resolution_raw;  // ...
18
	uint32_t palette_raw;      // ...
109
	void* icon_palette_raw;      // ...
19
	uint32_t directory_path_area;
110
	uint32_t directory_path_area;  // not used
20
	uint32_t file_name_area;
111
	uint32_t file_name_area;  // not used
21
	uint32_t select_flag;
112
	uint32_t select_flag;  // widget have focus, set auto on mouseclick
22
	color_t background_color;  // 0xffffff
113
	color_t background_color;  // self explained, 0xffffff
23
	color_t select_color; // 0xbbddff
114
	color_t select_color; // self explained, 0xbbddff
24
    color_t select_text_color;
115
    color_t select_text_color; // self explained
25
    color_t text_color;
116
    color_t text_color; // self explained
26
    color_t reduct_text_color; // 0xff0000
117
    color_t reduct_text_color; // 0xff0000  - spec color for cutted filenames
27
    color_t marked_text_color;
118
    color_t marked_text_color; // not used
28
    uint32_t max_panel_line;            // // moved to scrollbar->cur_area, - ìàêñèìàëüíîå ÷èñëî ñòðîê â îêíå
119
    uint32_t max_panel_line;    // moved to scrollbar->cur_area, - ìàêñèìàëüíîå ÷èñëî ñòðîê â îêíå, àâòîðàñ÷èòûâàåòñÿ
29
	uint32_t select_panel_counter;  // 1 if focused
120
	uint32_t select_panel_counter;  // !=0 if want to draw multiselection ???
30
	uint32_t folder_block;   //  êîëè÷åñòâî áëîêîâ äàííûõ âõîäà êàòàëîãà (ÁÄÂÊ) ????? format BDVK == bdfe,, // moved to scrollbar->max_area
121
	uint32_t folder_block;   // auto formed, êîëè÷åñòâî áëîêîâ äàííûõ âõîäà êàòàëîãà (ÁÄÂÊ) ????? format BDVK == bdfe,, // moved to scrollbar->max_area
31
	uint32_t start_draw_line;       // moved to scrollbar->position and back
122
	uint32_t start_draw_line;    // internal - top showed file n. moved to scrollbar->position and back
32
	uint16_t start_draw_cursor_line;
123
	uint16_t start_draw_cursor_line;  //internal
33
    void* folder_data;      // ??? format 32 byte - header, +4 = number, +32 - bdvk[], size of rec(bdvk cp866) = 304byte
124
    void* folder_data;      // 32 byte - dir_header, +4 = number, +32 - bdvk[], size of rec(bdvk cp866) = 304byte
34
    uint32_t temp_counter;
125
    uint32_t temp_counter; //internal
35
    uint32_t file_name_length;
126
    uint32_t file_name_length; //internal
36
    uint32_t marked_file;
127
    uint32_t marked_file;  // have a mark 0/1 ?
37
    uint32_t extension_size;
128
    uint32_t extension_size;  //internal
38
    uint32_t extension_start;
129
    uint32_t extension_start;  //internal
39
    void* type_table; //dd features_table ; +122   ? table format
130
    void* type_table; // type buffer
40
    char* ini_file_start;   // icons.ini
131
    char* ini_file_start;   // icons.ini contens - file<>icon association
41
    char* ini_file_end;     // start + filesize
132
    char* ini_file_end;     // start + filesize
42
    uint32_t draw_scroll_bar;  // 1 = need redraw sb after key()
133
    uint32_t draw_scroll_bar;  // 1 = need redraw sb after key(), user - resetted
43
    uint32_t font_size_xy;  // x_y	(6, 9)
134
    uint32_t font_size_xy;  // x_y	(6, 9)
44
    uint32_t mouse_keys;
135
    uint32_t mouse_keys;  // saved internal
45
    uint32_t mouse_keys_old;
136
    uint32_t mouse_keys_old; // saved internal
46
    uint32_t mouse_pos;
137
    uint32_t mouse_pos; // saved internal
47
    uint32_t mouse_keys_delta;
138
    uint32_t mouse_keys_delta; // saved internal
48
    uint32_t mouse_key_delay; // 50
139
    uint32_t mouse_key_delay; // 50
49
    uint32_t mouse_keys_tick;
140
    uint32_t mouse_keys_tick; // internal timer
50
    uint16_t start_draw_cursor_line_2;
141
    uint16_t start_draw_cursor_line_2;  // internal cursor line
51
    uint32_t all_redraw;         // 1 - force draw, 2 - ????
142
    uint32_t all_redraw;         // 0 - skip draw contens, 1 - force draw, 2 - no draw selection (but draw icons), used when scroll
52
    uint32_t selected_BDVK_adress;
143
    struct fsBDFE* selected_BDVK_adress;  // pointer to selected
53
    uint16_t key_action;   // fill before key(), 1..12, wiki
144
    uint16_t key_action;   // fill before key(), 1..12, wiki
54
    uint16_t key_action_num; // fill before key()  fn2 >> 8
145
    uint16_t key_action_num; // fill before key()  fn2 >> 8
55
    char* name_temp_area 		dd name_temp_area ;+180
146
    char* name_temp_area;       // temporary string format buffer
56
    uint32_t max_name_temp_size;
147
    uint32_t max_name_temp_size;  // sizeof ^
57
    uint32_t display_name_max_length;
148
    uint32_t display_name_max_length;  // autocounted
58
    uint32_t draw_panel_selection_flag;
149
    uint32_t draw_panel_selection_flag;  // flag internal showing selected item
59
    uint32_t mouse_pos_old;
150
    uint32_t mouse_pos_old;  // saved internal
-
 
151
    uint32_t marked_counter;  // number of marked files
-
 
152
    char* keymap_pointer;  // keyboard layout map
-
 
153
 
-
 
154
} filebrowser;
-
 
155
 
-
 
156
static inline filebrowser* kolibri_filebrowser(filebrowser* fb, uint32_t x_w, uint32_t y_h, uint32_t font_size_xy, uint32_t icon_size_xy, void* icon_raw_area, void* icon_palette_raw, uint32_t icon_res,
-
 
157
                                         char* ini_file_start, char* ini_file_end,
-
 
158
                                         color_t font_select, color_t bk_select, color_t font_color, color_t bgcolor, color_t reduct_color)
-
 
159
{
-
 
160
    static char name_temp_area[256];
-
 
161
    static char keymap_area[128];
-
 
162
    static char type_table[128] = " 1023b 00.00.00 00:00     temp1.asm";
-
 
163
 
-
 
164
    memset(fb, 0, sizeof(filebrowser));
-
 
165
    fb->x_w = x_w;
-
 
166
    fb->y_h = y_h;
-
 
167
    fb->font_size_xy = font_size_xy;
-
 
168
 
-
 
169
    fb->icon_size_xy = icon_size_xy;
-
 
170
    fb->icon_raw_area = icon_raw_area;
-
 
171
    fb->icon_palette_raw = icon_palette_raw;
-
 
172
    fb->icon_resolution_raw = icon_res;
-
 
173
 
-
 
174
    fb->line_size_y = (icon_size_xy & 0xFFFF) + 2;
-
 
175
 
-
 
176
    // constants
-
 
177
    fb->type_table = type_table;
-
 
178
    fb->mouse_key_delay = 50;
-
 
179
    fb->name_temp_area = name_temp_area;
60
    uint32_t marked_counter;
180
//    fb->max_name_temp_size = sizeof name_temp_area - 1;
61
    char* keymap_pointer 		dd keymap_area ;+204
181
    fb->keymap_pointer = keymap_area;
-
 
182
 
-
 
183
    // careful - font sizes may be encoded in colors as SysFn4
-
 
184
    fb->background_color = bgcolor;  // self explained, 0xffffff
-
 
185
	fb->select_color = bk_select; // self explained, 0xbbddff
-
 
186
    fb->select_text_color = font_select; // self explained
-
 
187
    fb->text_color = font_color; // self explained
Line 62... Line 188...
62
 
188
    fb->reduct_text_color = reduct_color; // 0xff0000  - spec color for cutted filenames
-
 
189
 
63
 
190
    fb->ini_file_start = ini_file_start;
64
} file_browser;
-
 
65
/*
-
 
66
features_table:
-
 
67
.type_table:
-
 
68
	db ' '
-
 
69
;---------------------------------------------------------------------
-
 
70
.size_table:
-
 
71
	db '1023b '
-
 
72
;---------------------------------------------------------------------
-
 
73
.date_table:
-
 
74
	db '00.00.00 00:00 '
-
 
75
;---------------------------------------------------------------------
-
 
76
.year_table:
-
 
77
	db '    '
-
 
78
 
-
 
79
name_temp_area:
-
 
80
	rb 256
-
 
81
 
-
 
82
keymap_area:
-
 
83
	rb 128
191
    fb->ini_file_end = ini_file_end;
84
 
192
/*
85
inline frame* kolibri_filebrowser(frame* f, uint32_t x_w, uint32_t y_h, color_t ext_col, color_t int_col, char *text, uint32_t text_position, color_t font_color, color_t font_bgcolor)
-
 
86
{
-
 
87
    f->type = 0;
-
 
88
    f->x_w = x_w;
-
 
89
    f->y_h = y_h;
-
 
90
    f->ext_col = ext_col;
-
 
91
    f->int_col = int_col;
-
 
92
    f->draw_text_flag = text != NULL;
-
 
93
    f->text_pointer = text;
-
 
94
    f->text_position = text_position;
-
 
95
    f->font_number = 0;  // 0 == font 6x9, 1==8x16
-
 
96
    f->font_size_y = 9;
-
 
97
    f->font_color = font_color | 0x80000000;
-
 
98
    f->font_bg_color = font_bgcolor;
193
    void* folder_data;      // 32 byte - dir_header, +4 = number, +32 - bdvk[], size of rec(bdvk cp866) = 304byte
99
 
194
*/
Line 100... Line 195...
100
    return f;
195
    return fb;
-
 
196
}
-
 
197
 
101
}
198
static inline filebrowser* kolibri_new_filebrowser(uint32_t x_w, uint32_t y_h, uint32_t font_size_xy, uint32_t icon_size_xy, void* icon_raw_area, void* icon_palette_raw, uint32_t icon_bpp,
102
 
199
                                         char* ini_file_start, char* ini_file_end,
103
inline frame* kolibri_new_frame(uint32_t x_w, uint32_t y_h, color_t ext_col, color_t int_col, char *text, uint32_t text_position, color_t font_color, color_t font_bgcolor)
200
                                         color_t font_select, color_t bk_select, color_t font_color, color_t bgcolor, color_t reduct_color)
-
 
201
{
104
{
202
    filebrowser *new_fb = (filebrowser *)malloc(sizeof(filebrowser));
Line -... Line 203...
-
 
203
    return kolibri_filebrowser(new_fb, x_w, y_h, font_size_xy, icon_size_xy, icon_raw_area, icon_palette_raw, icon_bpp, ini_file_start, ini_file_end,
105
    frame *new_frame = (frame *)malloc(sizeof(frame));
204
                                         font_select, bk_select, font_color, bgcolor, reduct_color);
106
    return kolibri_frame(new_frame, x_w, y_h, ext_col, int_col, text, text_position, font_color, font_bgcolor);
205
}
-
 
206
 
-
 
207
/* loading files leads to link functions even if no using filebrowser
-
 
208
inline filebrowser* kolibri_filebrowser_def(filebrowser* fb, uint32_t x_w, uint32_t y_h)
-
 
209
{
-
 
210
    // load default icons and icon association
-
 
211
    char icons_ini[]       = "/rd/1/File managers/icons.ini";
107
}
212
    char icons16img[]       = "/rd/1/File managers/z_icons.png";
108
 
213
 
-
 
214
    return kolibri_filebrowser(fb, x_w, y_h, X_Y(9, 16), X_Y(16, 16), icon_raw_area, icon_palette_raw, icon_res,
109
inline frame* kolibri_frame_def(frame* f, uint32_t x_w, uint32_t y_h, char *text)
215
                                         ini_file_start, ini_file_end,
110
{
216
                                         0x000000, 0xbbddff, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area, 0xff0000);
111
    return kolibri_frame(f, x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
217
}
112
}
218
*/
113
 
219
/*
114
inline frame* kolibri_new_frame_def(uint32_t x_w, uint32_t y_h, char *text)
220
inline frame* kolibri_new_frame_def(uint32_t x_w, uint32_t y_h, char *text)
115
{
221
{
116
    return kolibri_new_frame(x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
222
    return kolibri_new_frame(x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
117
}
223
}
118
 
224
*/
Line 119... Line 225...
119
inline void gui_add_frame(kolibri_window *wnd, frame* f)
225
inline void gui_add_filebrowser(kolibri_window *wnd, filebrowser* f)
120
{
226
{
121
    kolibri_window_add_element(wnd, KOLIBRI_FRAME, f);
227
    kolibri_window_add_element(wnd, KOLIBRI_FILEBROWSE, f);
Line 122... Line -...
122
}
-
 
123
 
-
 
124
FileBrowser_draw - ðèñîâàíèå ýëåìåíòà
228
}