MiniGUI输入法模块mGi软键盘使用实例

来源:互联网 发布:网络写作平台17k 编辑:程序博客网 时间:2024/06/03 22:42

http://blog.csdn.net/force_eagle/article/details/7339070

 分类:
 


mGi 是飞漫软件提供的一个输入法组件,该组件目前提供了软键盘输入法和手写输入法框架,并提供给用户管理输入法的容器,通过这个容器,用户还可以添加自定义的输入法。此外,对于软键盘输入法,用户可以自定义显示的键盘位图,并可添加不同的输入翻译方式(自带中文全拼输入法)。

mGi 现在已随着MiniGUI 3.0.12 版本一起开源, 可以在http://www.minigui.org/downloads/index.html下载.

以下是测试实例代码, mGi 采用configure默认配置, 如果采用--enable-mgdesktop-version, 要注意自己手动ShowWindow.

[cpp] view plain copy
  1. #include <stdio.h>  
  2. #include <stdlib.h>  
  3. #include <minigui/common.h>  
  4. #include <minigui/minigui.h>  
  5. #include <minigui/gdi.h>  
  6. #include <minigui/window.h>  
  7. #include <minigui/control.h>  
  8. #include <mgi/mgi.h>  
  9.   
  10. #define IDC_BASE 20000  
  11. #ifndef IDC_STATIC  
  12. #define IDC_STATIC 21000  
  13. #endif  
  14. #define IDC_EDT_ADDR 21100  
  15.   
  16. HWND g_hIMEWnd = 0UL;  
  17.   
  18. static DLGTEMPLATE s_DlgBox_DlgPing =   
  19. {  
  20.     WS_BORDER | WS_CAPTION,  
  21.     WS_EX_NONE,  
  22.     200, 225, 400, 180,  
  23.     "Ping",  
  24.     0, 0,  
  25.     4,  
  26.     NULL,  
  27.     0  
  28. };  
  29.   
  30. static CTRLDATA s_DlgCtrl_DlgPing[] =   
  31. {  
  32.     {  
  33.         "button",  
  34.         WS_VISIBLE | WS_TABSTOP ,  
  35.         47, 91, 100, 28,  
  36.         IDOK,  
  37.         "确定",  
  38.         0  
  39.     },   
  40.     {  
  41.         "button",  
  42.         WS_VISIBLE | WS_TABSTOP ,  
  43.         217, 91, 100, 28,  
  44.         IDCANCEL,  
  45.         "取消",  
  46.         0  
  47.     },   
  48.     {  
  49.         "sledit",  
  50.         WS_VISIBLE | WS_TABSTOP | WS_BORDER,  
  51.         127, 40, 199, 30,  
  52.         IDC_EDT_ADDR,  
  53.         "",  
  54.         0  
  55.     },   
  56.     {  
  57.         "static",  
  58.         WS_VISIBLE | WS_TABSTOP ,  
  59.         42, 42, 70, 34,  
  60.         IDC_STATIC,  
  61.         "IP地址",  
  62.         0  
  63.     },   
  64. };  
  65.   
  66. static HWND sk_ime_hwnd;  
  67. static BOOL g_ime_opened = FALSE;   
  68. static void edit_notif_proc(HWND hDlg, int id, int nc, DWORD add_data)  
  69. {  
  70.     IME_TARGET_INFO ime_t_info;  
  71.     //edit控件的消息处理函数中打印caret的位置  
  72.     GetIMETargetInfo(&ime_t_info);  
  73.     printf("ime_t_info.ptCaret: (%d, %d)\n", ime_t_info.ptCaret.x, ime_t_info.ptCaret.y);  
  74. }  
  75.   
  76. void notify_ime_status(BOOL opened)  
  77. {  
  78.     g_ime_opened = opened;  
  79. }  
  80.   
  81. static int DialogBox_DlgPing_Proc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam)  
  82. {  
  83.     switch (message)  
  84.     {  
  85.         case MSG_INITDIALOG:  
  86.             g_hIMEWnd  = hDlg;  
  87.             SetNotificationCallback (GetDlgItem (hDlg, IDC_EDT_ADDR), edit_notif_proc);   
  88.             sk_ime_hwnd = mgiCreateSoftKeypad(notify_ime_status);   
  89.             SetFocusChild(GetDlgItem(hDlg, IDC_EDT_ADDR));  
  90.             //SetIMEStatus(IME_STATUS_AUTOTRACK, TRUE);   
  91.             SetIMEStatus(IME_STATUS_ENCODING, IME_ENCODING_LOCAL);   
  92.             SetIMEStatus(IME_STATUS_ENABLED, TRUE);  
  93.             return 1;  
  94.         case MSG_CLOSE:  
  95.             EndDialog(hDlg, IDCANCEL);  
  96.             break;  
  97.     }  
  98.   
  99.     return DefaultDialogProc(hDlg, message, wParam, lParam);  
  100. }  
  101.   
  102. int MiniGUIMain(int args, const char* arg[])  
  103. {  
  104.     s_DlgBox_DlgPing.controls = s_DlgCtrl_DlgPing;  
  105.       
  106.     SetDefaultWindowElementRenderer("skin");  
  107.       
  108.     DialogBoxIndirectParam(&s_DlgBox_DlgPing, HWND_DESKTOP, DialogBox_DlgPing_Proc, 0);  
  109.     return 0;  
  110. }  


Makefile

[plain] view plain copy
  1. CC=gcc  
  2. LD=gcc  
  3.   
  4. CFLAGS=-I/usr/local/include  
  5. LDFLAGS=-L/usr/local/lib/ -lminigui_ths -lmgi -lpng -lpthread -ldl -lfreetype -ljpeg  
  6.   
  7. TARGET=lcd  
  8.   
  9. all: lcd  
  10.   
  11. .c.o:  
  12.     $(CC) $(CFLAGS) -c $^ -o $@  
  13.   
  14. $(TARGET): skb_test.o  
  15.     $(LD) $(LDFLAGS) $^ -o $@  
  16.   
  17. clean:  
  18.     rm -f $(TARGET) *.o  

以下是显示效果图:




0
0
 
 

0 0
原创粉丝点击