📄 memopad_edit.c
字号:
#ifdef ENABLE_ZOOM case SHORTCUT_LARGE_FONT: font = lookupFont(current_memo->encoding, LARGE_FONT); current_font = font; editorSetFont(client_window, font, &clientWindowRect, NULL, 0); break; case SHORTCUT_MEDIUM_FONT: font = lookupFont(current_memo->encoding, MEDIUM_FONT); current_font = font; editorSetFont(client_window, font, &clientWindowRect, NULL, 0); break; case SHORTCUT_SMALL_FONT: font = lookupFont(current_memo->encoding, SMALL_FONT); current_font = font; editorSetFont(client_window, font, &clientWindowRect, NULL, 0); break;#endif case SHORTCUT_IME: #ifndef __uClinux__ { DESKTOP_CHANNEL channel; MSG msg; int msgLen; int row_height, nrp, ascent, descent; emtk_get_font_height(current_font, &ascent, &descent); row_height = ascent + descent; desktop_channel_connect(&channel); if (ime_state) { ime_state = 0; nrp = (clientWindowRect.h - 20) / row_height; msgLen = msg_command_input(0, &msg); } else { /* TODO: modify index */ if (current_memo->encoding) { if (strcmp(current_memo->encoding, "en_US") == 0) { nrp = (clientWindowRect.h - ime_heights[0]) / row_height; ime_state = INPUT_ENGLISH | LAYOUT2 | KEYBOARD; } else if (strcmp(current_memo->encoding, "zh_CN.GBK") == 0) { nrp = (clientWindowRect.h - ime_heights[1]) / row_height; ime_state = INPUT_CHINESE | LAYOUT3 | KEYBOARD; } else if (strcmp(current_memo->encoding, "th_TH.TACTIS") == 0) { nrp = (clientWindowRect.h - ime_heights[2]) / row_height; ime_state = INPUT_THAI | LAYOUT2 | KEYBOARD; } } else { ime_state = INPUT_ENGLISH | LAYOUT2 | KEYBOARD; nrp = (clientWindowRect.h - ime_heights[0]) / row_height; } msgLen = msg_command_input(ime_state, &msg); } emtk_text_set_height_info(text_id, row_height, nrp); desktop_channel_send(&channel, &msg, msgLen); desktop_channel_disconnect(&channel); } break; case SHORTCUT_IME_ENG: { int row_height, nrp, ascent, descent; emtk_get_font_height(current_font, &ascent, &descent); row_height = ascent + descent; if ((ime_state & INPUT_LANG_MASK) == INPUT_ENGLISH) { ime_state = 0; nrp = (clientWindowRect.h - 20) / row_height; } else { if ((ime_state & INPUT_LANG_MASK) == INPUT_THAI) { emtk_app_set_shortcut_button_toggle_state(thai_shortcut, FALSE); } nrp = (clientWindowRect.h - ime_heights[0]) / row_height; ime_state = INPUT_ENGLISH | LAYOUT2 | KEYBOARD; } emtk_text_set_height_info(text_id, row_height, nrp); launchIME(ime_state); } break; case SHORTCUT_IME_THAI: { int row_height, nrp, ascent, descent; emtk_get_font_height(current_font, &ascent, &descent); row_height = ascent + descent; if ((ime_state & INPUT_LANG_MASK) == INPUT_THAI) { ime_state = 0; nrp = (clientWindowRect.h - 20) / row_height; } else { if ((ime_state & INPUT_LANG_MASK) == INPUT_ENGLISH) { emtk_app_set_shortcut_button_toggle_state(eng_shortcut, FALSE); } nrp = (clientWindowRect.h - ime_heights[2]) / row_height; ime_state = INPUT_THAI | LAYOUT2 | KEYBOARD; } emtk_text_set_height_info(text_id, row_height, nrp); launchIME(ime_state); } break;#endif } }#endifstatic void menu_action_handler(int pid, void *data) { int action; action = (int) data;#ifndef FILEMODE switch(action) { case NEW_MEMO: emtk_app_close_window(memo_edit_window); openNewEditor(0, NULL); break; case DELETE_MEMO: show_confirm_dialog(0, NULL); break;#ifdef ENABLE_ZOOM case ACTION_LARGE_FONT: toolbar_handler(large_shortcut, (action - ACTION_SMALL_FONT), NULL); break; case ACTION_MEDIUM_FONT: toolbar_handler(medium_shortcut, (action - ACTION_SMALL_FONT), NULL); break; case ACTION_SMALL_FONT: toolbar_handler(small_shortcut, (action - ACTION_SMALL_FONT), NULL); /*editorSetFont(client_window, lookupFont(current_memo->encoding, (action - ACTION_SMALL_FONT)), &clientWindowRect, NULL, 0);*/ break;#endif }#endif}#ifndef FILEMODEstatic void dateChooserClosed(long long time) { struct tm tm_time; char buf[11]; localtime64_r(&time, &tm_time); g_date_set_dmy(&(current_memo->date), tm_time.tm_mday, tm_time.tm_mon + 1, tm_time.tm_year + 1900); g_date_strftime(buf, 11, "%Y/%m/%d", &(current_memo->date)); emtk_entry_set_value(date_entry, buf, strlen(buf)); current_memo->dirty = TRUE;}static void showCalendar(int bid, void *data) { int dialog; struct tm tm_time; WindowRect rect = { 0, 0, 320, 240 }; g_date_to_struct_tm(&(current_memo->date), &tm_time); dialog = date_chooser_new(_("Calendar"), &rect, mktime64(&tm_time), dateChooserClosed);}#endifstatic void drawFunc(int window, WindowRect *clientRect) { char buf[11]; client_window = window; memcpy(&clientWindowRect, clientRect, sizeof(WindowRect));#if (UI_LAYOUT_SCHEME==240160) clientWindowRect.h = clientRect->h - 16;#endif#ifndef FILEMODE date_entry = emtk_entry_new(window, 0, 15, 35, KEY_TYPE_ANY, 80, 10, lookupFont("en_US", SMALL_FONT), lookupFont("en_US", SMALL_FONT), _("Date")); emtk_entry_set_value_change_callback(date_entry, memoModified, NULL); g_date_strftime(buf, 11, "%Y/%m/%d", &(current_memo->date)); emtk_entry_set_value(date_entry, buf, strlen(buf)); emtk_window_add_object(window, date_entry); title_entry = emtk_entry_new(window, 0, 33, 35, KEY_TYPE_ANY, clientWindowRect.w - 35 - 10, 40, lookupFont("en_US", SMALL_FONT), lookupFont("en_US", SMALL_FONT), _("Title")); emtk_entry_set_value_change_callback(title_entry, memoModified, NULL); emtk_entry_set_value(title_entry, current_memo->title, strlen(current_memo->title)); emtk_window_add_object(window, title_entry); calendar_btn = emtk_button_new(window, 130, 1, 60, 16, lookupFont("en_US", SMALL_FONT), _("Calendar"), 0, showCalendar, NULL); emtk_window_add_object(window, calendar_btn);#endif current_font = lookupFont(current_memo->encoding, SMALL_FONT); editorSetFont(window, current_font, &clientWindowRect, current_memo->content, current_memo->content_len); done_id = emtk_button_new(window, 0, clientWindowRect.h - 20, 60, 20, FONT1, _("Done"), MWKEY_ESCAPE, done_handler, NULL); emtk_window_add_object(window, done_id);#ifndef FILEMODE delete_id = emtk_button_new(window, 65, clientWindowRect.h - 20, 60, 20, FONT1, _("Delete..."), 0, show_confirm_dialog, NULL); emtk_window_add_object(window, delete_id);#endif memo_ime_activate (TRUE); //emtk_window_key_handler_add(window, edit_key_pressed, NULL, KEY_TYPE_ANY);}int memopad_edit_new_window(char *title, Memo *memo, int db_context, MemopadCallBack *handlers) { //char *title;#ifndef FILEMODE int menu_id, font_id; WindowRect toolbarRect = {APP_WINDOW_W - 150, APP_WINDOW_Y, 130, 18};#endif database = db_context; callbacks = handlers; g_return_val_if_fail(memo != NULL, 0); current_memo = memo; //title = g_strdup_printf(EDIT_MEMO_TITLE, record, num_records); memo_edit_window = emtk_app_window_new(title, FONT2, drawFunc, close_editor, menu_action_handler);#ifndef FILEMODE ime_state = 0; menu_id = emtk_app_window_menu_add(memo_edit_window, _("Record"), 0); emtk_app_window_menu_item_add(menu_id, _("New Memo"), NEW_MEMO); emtk_app_window_menu_item_add(menu_id, _("Delete Memo"), DELETE_MEMO); #ifdef ENABLE_ZOOM font_id = emtk_app_window_menu_add(memo_edit_window, _("Font"), 0); emtk_app_window_menu_item_add(font_id, _("Small"), ACTION_SMALL_FONT); emtk_app_window_menu_item_add(font_id, _("Medium"), ACTION_MEDIUM_FONT); emtk_app_window_menu_item_add(font_id, _("Large"), ACTION_LARGE_FONT);#endif#if defined(ENABLE_ZOOM) || defined(__uClinux__) toolbar = emtk_app_window_add_shortcut_bar(memo_edit_window, &toolbarRect, toolbar_handler, SHORTCUT_BAR_HORIZONTAL);#endif#ifdef ENABLE_ZOOM large_shortcut = emtk_app_append_shortcut_button(toolbar, SHORTCUT_BUTTON_TOGGLE, "font_large_pressed.png", "font_large.png", 18, 18, 0, SHORTCUT_LARGE_FONT, NULL); medium_shortcut = emtk_app_append_shortcut_button(toolbar, SHORTCUT_BUTTON_TOGGLE, "font_medium_pressed.png", "font_medium.png", 18, 18, 0, SHORTCUT_MEDIUM_FONT, NULL); small_shortcut = emtk_app_append_shortcut_button(toolbar, SHORTCUT_BUTTON_TOGGLE, "font_small_pressed.png", "font_small.png", 18, 18, 0, SHORTCUT_SMALL_FONT, NULL); lastShortcutButton = small_shortcut;#endif#ifndef __uClinux__ ime_shortcut = emtk_app_append_shortcut_button(toolbar, SHORTCUT_BUTTON_TOGGLE, "key02.jpg", "key01.jpg", 25, 18, 0, SHORTCUT_IME, NULL); eng_shortcut = emtk_app_append_shortcut_button(toolbar, SHORTCUT_BUTTON_TOGGLE, "engkbd_on.png", "engkbd.png", 18, 18, 0, SHORTCUT_IME_ENG, NULL); thai_shortcut = emtk_app_append_shortcut_button(toolbar, SHORTCUT_BUTTON_TOGGLE, "thaikbd_on.png", "thaikbd.png", 18, 18, 0, SHORTCUT_IME_THAI, NULL);#endif#ifdef ENABLE_ZOOM emtk_app_set_shortcut_button_toggle_state(lastShortcutButton, TRUE);#endif#endif memo_ime_activate(TRUE); return memo_edit_window; //g_free(title);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -