static void notepad_add_continued(const char *name, void* UNUSED(data)) { int i = nr_notes++; int potential_id, next_id = 0; if (i >= note_list_size) increase_note_storage(); for (potential_id = 0; potential_id < nr_notes; potential_id++) { int test_id; int found_id = 0; for (test_id=0; test_id<nr_notes; test_id++) { widget_list *w = widget_find(main_note_tab_id, note_list[test_id].button_id); if (w && w->id == potential_id) { found_id = 1; break; } } if (!found_id) { next_id = potential_id; break; } } init_note (i, name, NULL); note_button_add (i, next_id); open_note_tab_continued (i); }
void fill_notepad_window() { int i, tmp; widget_list *wnew; widget_list *wsave; int note_tabs_width = notepad_win_x_len; int note_tabs_height = notepad_win_y_len - 5; note_button_scroll_height = note_tabs_height - 55 - 20; // -20 for the tab tags note_button_width = (note_tabs_width - note_button_scroll_width - note_button_x_space - 15) / 2; set_window_handler(notepad_win, ELW_HANDLER_DISPLAY, &display_notepad_handler); set_window_handler(notepad_win, ELW_HANDLER_CLICK, &click_buttonwin_handler); note_tabcollection_id = tab_collection_add (notepad_win, NULL, 0, 5, note_tabs_width, note_tabs_height, 20); widget_set_size (notepad_win, note_tabcollection_id, 0.7); widget_set_color (notepad_win, note_tabcollection_id, 0.77f, 0.57f, 0.39f); main_note_tab_id = tab_add (notepad_win, note_tabcollection_id, tab_main, 0, 0, 0); widget_set_color (notepad_win, main_note_tab_id, 0.77f, 0.57f, 0.39f); set_window_handler(main_note_tab_id, ELW_HANDLER_CLICK, &click_buttonwin_handler); // Add Category new_note_button_id = button_add(main_note_tab_id, NULL, button_new_category, 0, 0); widget_set_OnClick(main_note_tab_id, new_note_button_id, notepad_add_category); widget_set_color(main_note_tab_id, new_note_button_id, 0.77f, 0.57f, 0.39f); // Save Notes save_notes_button_id = button_add(main_note_tab_id, NULL, button_save_notes, 0, 0); widget_set_OnClick(main_note_tab_id, save_notes_button_id, click_save_handler); widget_set_color(main_note_tab_id, save_notes_button_id, 0.77f, 0.57f, 0.39f); // align the buttons wnew = widget_find(main_note_tab_id, new_note_button_id); wsave = widget_find(main_note_tab_id, save_notes_button_id); tmp = (notepad_win_x_len - note_button_scroll_width)/2; widget_move(main_note_tab_id, new_note_button_id, (tmp - wnew->len_x)/2, 10); widget_move(main_note_tab_id, save_notes_button_id, tmp + (tmp - wsave->len_x)/2, 10); notepad_load_file (); init_ipu (&popup_str, main_note_tab_id, NOTE_NAME_LEN*DEFAULT_FONT_X_LEN, 100, NOTE_NAME_LEN, 1, NULL, notepad_add_continued); popup_str.x = (notepad_win_x_len - popup_str.popup_x_len) / 2; popup_str.y = (notepad_win_y_len - popup_str.popup_y_len) / 2; note_button_scroll_id = vscrollbar_add (main_note_tab_id, NULL, note_tabs_width - note_button_scroll_width - 5, 50, note_button_scroll_width, note_button_scroll_height); widget_set_OnClick (main_note_tab_id, note_button_scroll_id, note_button_scroll_handler); widget_set_OnDrag (main_note_tab_id, note_button_scroll_id, note_button_scroll_handler); // Add the note selection buttons and their scroll bar for(i = 0; i < nr_notes; i++) note_button_add (i, i); update_note_button_scrollbar (0); }