MiniGUI

Ŀ ¼

  1. MiniGUI
    1. Ìåϵ½á¹¹
      1. ¸ÅÀÀ
        1. ÒýÑÔ
        2. POSIX Ïß³Ì
        3. »ùÓÚ PThread µÄ΢¿Í»§/·þÎñÆ÷½á¹¹
        4. ¶àÏß³ÌͨѶµÄ¹Ø¼üÊý¾Ý½á¹¹¡ª¡ªÏûÏ¢¶ÓÁÐ
        5. ÃæÏò¶ÔÏó¼¼ÊõÔÚ MiniGUI ÖеÄÓ¦ÓÃ
        6. δÀ´¿¼ÂÇ
      2. ¶à´°¿Ú¹ÜÀíºÍ¿Ø¼þ¼°¿Ø¼þÀà
        1. ÒýÑÔ
        2. ´°¿ÚZÐò
        3. ´°¿Ú¼ôÇÐËã·¨
        4. Ö÷´°¿ÚºÍ¿Ø¼þ¡¢¿Ø¼þÀà
        5. ÊäÈ뷨ģ¿éµÄÉè¼Æ
        6. С½á
      3. Âß¼­×ÖÌåÒÔ¼°¶à×ÖÌåºÍ¶à×Ö·û¼¯ÊµÏÖ
        1. ÒýÑÔ
        2. Âß¼­×ÖÌå¡¢É豸×ÖÌåÒÔ¼°×Ö·û¼¯Ö®¼äµÄ¹Øϵ
        3. MiniGUIÖеÄ×Ö·û¼¯Ö§³Ö3.1×Ö·û¼¯²Ù×÷¼¯
        4. MiniGUIÖеÄ×ÖÌåÖ§³Ö
        5. С½á
      4. ͼÐγéÏó²ãºÍÊäÈë³éÏó²ã¼°NativeµÄʵÏÖ
        1. ÒýÑÔ
        2. MiniGUIµÄGALºÍIAL¶¨Òå
        3. NativeͼÐÎÒýÇæµÄʵÏÖ
        4. NativeÊäÈëÒýÇæµÄʵÏÖ
        5. Ìض¨Ç¶ÈëʽϵͳÉÏͼÐÎÒýÇæºÍÊäÈëÒýÇæʵÏÖ
        6. С½á
    2. ¿ª·¢Ö¸ÄÏ
      1. Ñ¡ÔñMiniGUI-Threads»òÕßMiniGUI-Lite
      2. ÏûϢѭ»·ºÍ´°¿Ú¹ý³Ì
      3. ¶Ô»°¿òºÍ¿Ø¼þ±à³Ì
      4. ʹÓÃGDIº¯Êý
      5. MiniGUI 1.1.0ÒýÈëµÄÐÂGDI¹¦Äܺͺ¯Êý£¨1£©
      6. MiniGUI 1.1.0ÒýÈëµÄÐÂGDI¹¦Äܺͺ¯Êý£¨2£©
      7. MiniGUI ÌṩµÄ·Ç GUI/GDI ½Ó¿Ú
      8. MiniGUI ºÍÆäËûǶÈëʽ Linux ÉϵÄͼÐμ°Í¼ÐÎÓû§½çÃæϵͳ
    3. LiteµÄиĽø
    4. °²×°ÊÖ²á


MiniGUI

[Ŀ¼]


Ìåϵ½á¹¹

    ΪÁË°ïÖú¸ü¶àÈí¼þ¿ª·¢ÈËÔ±Àí½â MiniGUI¼°Æä±à³Ì£¬Í¬Ê±°ïÖú¸ü¶àµÄ×ÔÓÉÈí¼þ¿ª·¢ÈËÔ±¼ÓÈë MiniGUI µÄ¿ª·¢£¬ÎÒÃǽ«×«Ð´Ò»ÏµÁÐÎÄÕ½éÉÜ MiniGUI µÄÌåϵ½á¹¹¡£±¾ÎÄÊÇϵÁÐÎÄÕµĵÚһƪ£¬½«ÔÚÕûÌåÉÏ¶Ô MiniGUI µÄÌåϵ½á¹¹×÷Ò»½éÉÜ¡£ÆäÖÐÖ÷Òª°üÀ¨£ºÏ̵߳Ļù±¾¸ÅÄ»ùÓÚ POSIX Thread µÄ΢¿Í»§/·þÎñÆ÷½á¹¹£»ÓÃÀ´Í¬²½Î¢¿Í»§/·þÎñÆ÷¶¯×÷µÄ¹Ø¼üÊý¾Ý½á¹¹¨D¨DÏûÏ¢¶ÓÁУ»ÃæÏò¶ÔÏó¼¼ÊõÔÚ MiniGUI ÖеÄÓ¦Óõȵȡ£×îºó£¬ÎÄÕÂÕ¹ÍûÁËÎÒÃǼƻ®ÔÚ MiniGUI 2.0 °æ¿ª·¢ÖвÉÓõÄÌåϵ½á¹¹¡£
[Ŀ¼]


¸ÅÀÀ

    µ½Ä¿Ç°ÎªÖ¹£¬MiniGUI µÄ×îз¢²¼°æ±¾ÊÇ 0.9.96¡£ÎÒÃǽ« 0.9.xx ϵÁа汾¶¨Î»Îª MiniGUI 1.0 °æ±¾µÄÔ¤ÀÀ°æ¡£ÔÚ 0.9.xx °æ±¾×ã¹»Îȶ¨Ê±£¬ÎÒÃǽ«·¢²¼ MiniGUI 1.0 °æ±¾£¬Í¬Ê±£¬Ä¿Ç°µÄ´úÂë²»»áÔÙ½øÐÐÖØ´óµ÷Õû¡£ÔÚ MiniGUI 1.0 °æ±¾·¢²¼Ö®ºó£¬ÎÒÃǽ«Á¢¼´×ÅÊÖ¿ª·¢ MiniGUI 2.0 °æ±¾¡£¸Ã°æ±¾Ô¤ÆÚ½«ÔÚÌåϵ½á¹¹ÉϽøÐÐÖØ´óµ÷Õû¡£
[Ŀ¼]


ÒýÑÔ

1 ÒýÑÔ
    ΪÁËÎüÒý¸ü¶àµÄ×ÔÓÉÈí¼þ³ÌÐòÔ±¼ÓÈë MiniGUI 2.0 µÄ¿ª·¢£¬Ò²ÎªÁ˸üºÃµØ°ïÖú MiniGUI ³ÌÐòÔ±½øÐгÌÐò¿ª·¢£¬ÎÒÃǽ«×«Ð´Ò»ÏµÁеÄÎÄÕ½éÉÜ MiniGUI 1.0 °æ±¾µÄÌåϵ½á¹¹£¬Öصã·ÖÎöÆäÖеÄһЩȱµãÒÔ¼°ÐèÒªÔÚ 2.0 °æ±¾µ±ÖнøÐÐÓÅ»¯ºÍ¸ÄÔìµÄµØ·½¡£½éÉÜÌåϵ½á¹¹µÄÎÄÕ¼ƻ®ÈçÏ£º

    ·Ìåϵ½á¹¹¸ÅÀÀ£¨±¾ÎÄ£©¡£½«ÔÚÕûÌåÉÏ¶Ô MiniGUI 1.0 µÄÌåϵ½á¹¹½øÐнéÉÜ¡£Öصã°üÀ¨£ºÏ̵߳Ļù±¾¸ÅÄ¶àÏ̵߳Ä΢¿Í»§/·þÎñÆ÷Ìåϵ¡¢¶àÏß³ÌͨѶµÄ¹Ø¼üÊý¾Ý½á¹¹¨D¨DÏûÏ¢¶ÓÁУ»ÃæÏò¶ÔÏó¼¼ÊõÔÚ MiniGUI ÖеÄÓ¦Óõȵȡ£
    ·MiniGUI µÄ¶à´°¿Ú¹ÜÀí¡£½«½éÉÜ MiniGUI µÄ¶à´°¿Ú»úÖÆÒÔ¼°Ïà¹ØµÄ´°¿ÚÀ༼Êõ¡£ÆäÖÐÉæ¼°µ½´°¿Ú¼ôÇд¦ÀíºÍ Z Ðò£¬ÏûÏ¢´«µÝ£¬¿Ø¼þÀàÉè¼ÆºÍÊäÈ뷨ģ¿éÉè¼ÆµÈµÈ¡£
    ·MiniGUI µÄͼÐÎÉ豸¹ÜÀí¡£Öصã½éÉÜ MiniGUI ÊÇÈçºÎ´¦Àí´°¿Ú»æÖƵġ£ÆäÖÐÖ÷Òª°üÀ¨Í¼ÐÎÉÏÏÂÎĵĸÅÄ×ø±êÓ³É䣬ͼÐÎÉÏÏÂÎĵľֲ¿¡¢È«¾ÖºÍÓÐЧ¼ôÇÐÓòµÄ¸ÅÄîµÈµÈ¡£
    ·Í¼ÐγéÏó²ãºÍÊäÈë³éÏó²ã¡£Í¼ÐγéÏó²ã£¨GAL£©ºÍÊäÈë³éÏó²ã£¨IAL£©´ó´óÌá¸ßÁË MiniGUI µÄ¿ÉÒÆÖ²ÐÔ£¬²¢½«µ×²ãͼÐÎÉ豸ºÍÉϲã½Ó¿Ú·ÖÀ뿪À´¡£ÕâÀォÖصã½éÉÜ MiniGUI µÄ GAL ºÍ IAL ½Ó¿Ú£¬²¢ÒÔ EP7211 µÈǶÈëʽϵͳΪÀý£¬ËµÃ÷ÈçºÎ½« MiniGUI ÒÆÖ²µ½ÐµÄǶÈëʽƽ̨ÉÏ¡£
    ·¶à×ÖÌåºÍ¶à×Ö·û¼¯Ö§³Ö¡£MiniGUI ²ÉÓÃÂß¼­×ÖÌåʵÏÖ¶à×ÖÌåºÍ¶à×Ö·û¼¯´¦Àí¡£ÕâÒ»¼¼Êõ³É¹¦Ó¦ÓÃÁËÃæÏò¶ÔÏó¼¼Êõ£¬Í¨¹ýµ¥Ò»µÄÂß¼­½Ó¿Ú£¬¿ÉÒÔʵÏÖ¶Ô¸÷ÖÖ×Ö·û¼¯ÒÔ¼°¸÷ÖÖ×ÖÌåµÄÖ§³Ö¡£

[Ŀ¼]


POSIX Ïß³Ì

2 POSIX Ïß³Ì

    MiniGUI ÊÇÒ»¸ö»ùÓÚÏ̵߳Ĵ°¿Úϵͳ¡£ÎªÁËÀí½â MiniGUI µÄÌåϵ½á¹¹£¬ÎÒÃÇÓбØÒªÊ×ÏȶÔÏß³Ì×÷Ò»·¬Á˽⡣

2.1 ʲôÊÇÏß³Ì
    Ïß³Ìͨ³£±»¶¨ÒåΪһ¸ö½ø³ÌÖдúÂëµÄ²»Í¬Ö´ÐзÏß¡£Ò²¾ÍÊÇ˵£¬Ò»¸ö½ø³ÌÖУ¬¿ÉÒÔÓжà¸ö²»Í¬µÄ´úÂë·ÏßÔÚͬʱִÐС£ÀýÈ磬³£¼ûµÄ×Ö´¦Àí³ÌÐòÖУ¬Ö÷Ï̴߳¦ÀíÓû§ÊäÈ룬¶øÆäËû²¢ÐÐÔËÐеÄÏß³ÌÔÚ±ØҪʱ¿ÉÔÚºǫ́±£´æÓû§µÄÎĵµ¡£ÎÒÃÇÒ²¿ÉÒÔ˵Ïß³ÌÊÇ¡°ÇáÁ¿¼¶½ø³Ì¡±¡£ÔÚ Linux ÖУ¬Ã¿¸ö½ø³ÌÓÉÎå¸ö»ù±¾µÄ²¿·Ö×é³É£º´úÂë¡¢Êý¾Ý¡¢Õ»¡¢ÎļþI/O ºÍÐÅºÅ±í¡£Òò´Ë£¬ÏµÍ³¶Ô½ø³ÌµÄ´¦ÀíÒª»¨·Ñ¸ü¶àµÄ¿ªÖ§£¬ÓÈÆäÔÚ½øÐнø³Ìµ÷¶ÈºÍÈÎÎñÇл»Ê±¡£´ÓÕâ¸öÒâÒåÉÏ£¬ÎÒÃÇ¿ÉÒÔ½«Ò»°ãµÄ½ø³ÌÀí½âΪÖØÁ¿¼¶½ø³Ì¡£ÔÚÖØÁ¿¼¶½ø³ÌÖ®¼ä£¬Èç¹ûÐèÒª¹²ÏíÐÅÏ¢£¬Ò»°ãÖ»ÄܲÉÓùܵÀ»òÕß¹²ÏíÄÚ´æµÄ·½Ê½ÊµÏÖ¡£Èç¹ûÖØÁ¿¼¶½ø³Ìͨ¹ý fork() ÅÉÉúÁË×Ó½ø³Ì£¬Ôò¸¸×Ó½ø³ÌÖ®¼äÖ»ÓдúÂëÊǹ²ÏíµÄ¡£

    ¶øÎÒÃÇÕâÀïÌáµ½µÄỊ̈߳¬Ôòͨ¹ý¹²ÏíһЩ»ù±¾²¿·Ö¶ø¼õÇáÁ˲¿·Öϵͳ¿ªÖ§¡£Í¨¹ý¹²ÏíÕâЩ»ù±¾×é³É²¿·Ö£¬¿ÉÒÔ´ó´óÌá¸ßÈÎÎñÇл»Ð§ÂÊ£¬Í¬Ê±Êý¾ÝµÄ¹²ÏíÒ²²»ÔÙÀ§ÄѨD¨DÒòΪ¼¸ºõËùÓеĶ«Î÷¶¼¿ÉÒÔ¹²Ïí¡£

    ´ÓʵÏÖ·½Ê½ÉÏ»®·Ö£¬Ïß³ÌÓÐÁ½ÖÖÀàÐÍ£º¡°Óû§¼¶Ï̡߳±ºÍ¡°Äں˼¶Ï̡߳±¡£

    Óû§Ïß³ÌÖ¸²»ÐèÒªÄÚºËÖ§³Ö¶øÔÚÓû§³ÌÐòÖÐʵÏÖµÄỊ̈߳¬ÕâÖÖÏß³ÌÉõÖÁÔÚÏó DOS ÕâÑùµÄ²Ù×÷ϵͳÖÐÒ²¿ÉʵÏÖ£¬µ«Ï̵߳ĵ÷¶ÈÐèÒªÓû§³ÌÐòÍê³É£¬ÕâÓÐЩÀàËÆ Windows 3.x µÄЭ×÷ʽ¶àÈÎÎñ¡£ÁíÍâÒ»ÖÖÔòÐèÒªÄں˵IJÎÓ룬ÓÉÄÚºËÍê³ÉÏ̵߳ĵ÷¶È¡£ÕâÁ½ÖÖÄ£Ð͸÷ÓÐÆäºÃ´¦ºÍȱµã¡£Óû§Ï̲߳»ÐèÒª¶îÍâµÄÄں˿ªÖ§£¬µ«Êǵ±Ò»¸öÏß³ÌÒò I/O ¶ø´¦Óڵȴý״̬ʱ£¬Õû¸ö½ø³Ì¾Í»á±»µ÷¶È³ÌÐòÇл»ÎªµÈ´ý״̬£¬ÆäËûÏ̵߳ò»µ½ÔËÐеĻú»á£»¶øÄÚºËÏß³ÌÔòûÓи÷¸öÏÞÖÆ£¬µ«È´Õ¼ÓÃÁ˸ü¶àµÄϵͳ¿ªÖ§¡£

    Linux Ö§³ÖÄں˼¶µÄ¶àỊ̈߳¬Í¬Ê±£¬Ò²¿ÉÒÔ´Ó Internet ÉÏÏÂÔØһЩ Linux ÉϵÄÓû§¼¶µÄÏ߳̿⡣Linux µÄÄÚºËÏ̺߳ÍÆäËû²Ù×÷ϵͳµÄÄÚºËʵÏÖ²»Í¬£¬Ç°Õ߸üºÃһЩ¡£´ó¶àÊý²Ù×÷ϵͳµ¥¶À¶¨ÒåỊ̈߳¬´Ó¶øÔö¼ÓÁËÄں˺͵÷¶È³ÌÐòµÄ¸´ÔÓÐÔ£»¶ø Linux Ôò½«Ï̶߳¨ÒåΪ¡°Ö´ÐÐÉÏÏÂÎÄ¡±£¬Ëüʵ¼ÊÖ»Êǽø³ÌµÄÁíÍâÒ»¸öÖ´ÐÐÉÏÏÂÎĶøÒÑ¡£ÕâÑù£¬Linux ÄÚºËÖ»ÐèÇø·Ö½ø³Ì£¬Ö»ÐèÒªÒ»¸ö½ø³Ì/Ïß³ÌÊý×飬¶øµ÷¶È³ÌÐòÈÔÈ»Êǽø³ÌµÄµ÷¶È³ÌÐò¡£Linux µÄ clone ϵͳµ÷ÓÿÉÓÃÀ´½¨Á¢ÐµÄÏ̡߳£

2.2 POSIX Ïß³Ì
    POSIX ±ê×¼¶¨ÒåÁËÏ̲߳Ù×÷µÄ C ÓïÑÔ½Ó¿Ú¡£ÎÒÃÇ¿ÉÒÔ½« POSIX Ï̵߳Ľӿڻ®·ÖÈçÏ£º

    ·Ï̵߳Ľ¨Á¢ºÍÏú»Ù¡£ÓÃÀ´´´½¨Ị̈߳¬È¡ÏûỊ̈߳¬ÖÆÔìÏß³ÌÈ¡ÏûµãµÈµÈ¡£
    ·»¥³âÁ¿²Ù×÷½Ó¿Ú¡£Ìṩ»ù±¾µÄ¹²Ïí¶ÔÏ󻥳â·ÃÎÊ»úÖÆ¡£
    ·ÐźÅÁ¿²Ù×÷½Ó¿Ú¡£Ìṩ»ù±¾µÄ»ùÓÚÐźÅÁ¿µÄͬ²½»úÖÆ¡£²»ÄÜÓë System V IPC »úÖƵÄÐźÅÁ¿Ïà»ìÏý¡£
    ·Ìõ¼þÁ¿²Ù×÷½Ó¿Ú¡£Ìṩ»ù±¾µÄ»ùÓÚÌõ¼þÁ¿µÄͬ²½»úÖÆ¡£¾¡¹ÜÐźÅÁ¿ºÍÌõ¼þÁ¿¾ù¿ÉÒÔ»®·ÖΪͬ²½»úÖÆ£¬µ«Ìõ¼þÁ¿±ÈÐźÅÁ¿¸üΪÁé»îһЩ£¬±ÈÈç¿ÉÒÔ½øÐй㲥£¬ÉèÖõȴý³¬Ê±µÈµÈ¡£µ«Ìõ¼þÁ¿µÄ²Ù×÷±È½Ï¸´ÔÓ¡£
    ·ÐźŲÙ×÷½Ó¿Ú¡£´¦ÀíÏ̼߳äµÄÐźŷ¢ËͺÍÏß³ÌÐźÅÑÚÂë¡£
    ·ÆäËû¡£°üÀ¨Ïֲ߳̾¿´æ´¢¡¢Ò»´ÎÐÔº¯ÊýµÈµÈ¡£

    Ä¿Ç°£¬Linux ÉϼæÈÝ POSIX µÄÏ߳̿â³ÆΪ LinuxThreads£¬ËüÒѾ­×÷Ϊ glibc µÄÒ»²¿·Ö¶ø·¢²¼¡£ÕâЩº¯ÊýµÄÃû³Æ¾ùÒÔ pthread_ ¿ªÍ·£¨ÐźÅÁ¿²Ù×÷º¯ÊýÒÔ sem_ ¿ªÍ·£©¡£

    ΪÁ˶ÔÏß³ÌÓÐһЩ¸ÐÐÔÈÏʶ£¬ÎÒÃÇÔÚÕâÀï¾ÙÁ½¸öÀý×Ó¡£

    µÚÒ»¸öÀý×ÓÔÚ½øÈë main () º¯ÊýÖ®ºó£¬µ÷Óà pthread_create º¯Êý½¨Á¢ÁËÁíÒ»¸öÏ̡߳£pthread_create µÄ²ÎÊýÖ÷ÒªÓÐÁ½¸ö£¬Ò»¸öÊÇÐÂÏ̵߳ÄÈë¿Úº¯Êý£¨thread_entry£©£¬ÁíÒ»¸öÊÇ´«µÝ¸øÈë¿Úº¯ÊýµÄ²ÎÊý£¨data£©£¬¶øÐÂÏ̵߳ıêʶ·ûͨ¹ýÒýÓòÎÊý·µ»Ø£¨new_thread£©¡£¼ûÇåµ¥ 1¡£

Çåµ¥ 1  ÐÂÏ̵߳Ĵ´½¨

void* thread_entry (void* data)
{
      ...    // do something.
     return NULL;
}

int main (void)
{

    pthread_t  new_thread;
    int data = 2;

    pthread_create (&new_thread, NULL, thread_entry, &data);
    pthread_join (new_thread, NULL);
}

    main () º¯ÊýÔÚ½¨Á¢ÁËÐÂÏß³ÌÖ®ºó£¬µ÷Óà pthread_join º¯ÊýµÈ´ýÐÂÏß³ÌÖ´ÐнáÊø¡£pthread_join ÀàËƽø³Ì¼¶µÄ wait ϵͳµ÷Óᣵ±ËùµÈ´ýµÄÏß³ÌÖ´ÐнáÊøÖ®ºó£¬¸Ãº¯Êý·µ»Ø¡£ÀûÓà pthread_join ¿ÉÓÃÀ´ÊµÏÖһЩ¼òµ¥µÄÏß³Ìͬ²½¡£×¢ÒâÔÚÉÏÃæµÄÀý×ÓÖУ¬ÎÒÃǺöÂÔÁ˺¯Êýµ÷Ó÷µ»ØÖµµÄ´íÎó¼ì²é¡£

    µÚ¶þ¸öÀý×ÓÊÇÀûÓÃÐźÅÁ¿½øÐÐͬ²½µÄÁ½¸öÏ̡߳£ÕâÀïËùʹÓõÄÀý×ÓÀûÓÃÐźÅÁ¿½â¾öÁ˾­µäµÄ¡°Éú²úÕß/Ïû·ÑÕß¡±ÎÊÌ⣨Çåµ¥ 2£©¡£ÎÒÃÇÊ×ÏȽâÊÍÐźÅÁ¿µÄ»ù±¾¸ÅÄî¡£

    ÐźÅÁ¿µÄ¸ÅÄîÓÉ E. W. Dijkstra ÓÚ 1965 ÄêÊ×´ÎÌá³ö¡£ÐźÅÁ¿Êµ¼ÊÊÇÒ»¸öÕûÊý£¬½ø³Ì£¨Ò²¿ÉÒÔÊÇỊ̈߳©ÔÚÐźÅÁ¿ÉϵIJÙ×÷·ÖÁ½ÖÖ£¬Ò»ÖÖ³ÆΪ DOWN£¬¶øÁíÍâÒ»ÖÖ³ÆΪ UP¡£DOWN ²Ù×÷µÄ½á¹ûÊÇÈÃÐźÅÁ¿µÄÖµ¼õ 1£¬UP ²Ù×÷µÄ½á¹ûÊÇÈÃÐźÅÁ¿µÄÖµ¼Ó 1¡£ÔÚ½øÐÐʵ¼ÊµÄ²Ù×÷֮ǰ£¬½ø³ÌÊ×Ïȼì²éÐźÅÁ¿µÄµ±Ç°Öµ£¬Èç¹ûµ±Ç°Öµ´óÓÚ 0£¬Ôò¿ÉÒÔÖ´ÐÐ DOWN ²Ù×÷£¬·ñÔò½ø³ÌÐÝÃߣ¬µÈ´ýÆäËû½ø³ÌÔÚ¸ÃÐźÅÁ¿É쵀 UP ²Ù×÷£¬ÒòΪÆäËû½ø³ÌµÄ UP ²Ù×÷½«ÈÃÐźÅÁ¿µÄÖµÔö¼Ó£¬´Ó¶øËüµÄ DOWN ²Ù×÷¿ÉÒԳɹ¦Íê³É¡£Ä³ÐźÅÁ¿ÔÚ¾­¹ýij¸ö½ø³ÌµÄ³É¹¦²Ù×÷Ö®ºó£¬ÆäËûÐÝÃßÔÚ¸ÃÐźÅÁ¿ÉϵĽø³Ì¾ÍÓпÉÄܳɹ¦Íê³É×Ô¼ºµÄ²Ù×÷£¬Õâʱ£¬ÏµÍ³¸ºÔð¼ì²éÐÝÃß½ø³ÌÊÇ·ñ¿ÉÒÔÍê³É×Ô¼ºµÄ²Ù×÷¡£

    ΪÁËÀí½âÐźÅÁ¿£¬ÎÒÃÇÏëÏóij»úƱ¶¨¹ºÏµÍ³¡£×î³õÂÿÍÔÚ¶¨Æ±Ê±£¬Ò»°ãÓÐ×ã¹»µÄƱÊý¿ÉÒÔÂú×㶨ƱÁ¿¡£µ±Ê£ÓàµÄ»úƱÊýΪ 1£¬¶øij¸öÂÿÍÏÖÔÚÐèÒª¶¨Á½ÕÅƱʱ£¬¾ÍÎÞ·¨Âú×ã¸Ã¹Ë¿ÍµÄÐèÇó£¬ÕâʱÊÛƱС½ãÈÃÕâ¸öÂÿÍÁôÏÂËûµÄµç»°ºÅÂ룬Èç¹ûÆäËûÈËÍËƱ£¬¾Í¿ÉÒÔÓÅÏÈÈÃÕâ¸öÂÿͶ¨Æ±¡£Èç¹û×îÖÕÓÐÈËÍËƱ£¬ÔòÊÛƱС½ã´òµç»°Í¨ÖªÉÏÊöÒª¶¨Á½ÕÅƱµÄÂÿͣ¬Õâʱ£¬¸ÃÂÿ;ÍÄܹ»¶¨µ½×Ô¼ºµÄƱ¡£

    ÎÒÃÇ¿ÉÒÔ½«ÂÿͿ´³ÉÊǽø³Ì£¬¶ø¶¨Æ±¿É¿´³ÉÊÇÐźÅÁ¿É쵀 DOWN ²Ù×÷£¬ÍËƱ¿É¿´³ÉÊÇÐźÅÁ¿É쵀 UP ²Ù×÷£¬¶øÐźÅÁ¿µÄ³õʼֵΪ»úƱ×ÜÊý£¬ÊÛƱС½ãÔòÏ൱ÓÚ²Ù×÷ϵͳµÄÐźÅÁ¿¹ÜÀíÆ÷£¬ÓÉËý£¨²Ù×÷ϵͳ£©¾ö¶¨Âÿͣ¨½ø³Ì£©Äܲ»ÄÜÍê³É²Ù×÷£¬²¢ÇÒÔÚеÄÌõ¼þ³ÉÊìʱ£¬¸ºÔð֪ͨ£¨»½ÐÑ£©µÇ¼ÇµÄ£¨ÐÝÃߵģ©Âÿͣ¨½ø³Ì£©¡£

    ÔÚ²Ù×÷ϵͳÖУ¬ÐźÅÁ¿µÄ×î¼òµ¥ÐÎʽÊÇÒ»¸öÕûÊý£¬¶à¸ö½ø³Ì¿É¼ì²é²¢ÉèÖÃÐźÅÁ¿µÄÖµ¡£ÕâÖÖ¼ì²é²¢ÉèÖòÙ×÷ÊDz»¿É±»Öжϵģ¬Ò²³ÆΪ¡°Ô­×Ó¡±²Ù×÷¡£¼ì²é²¢ÉèÖòÙ×÷µÄ½á¹ûÊÇÐźÅÁ¿µÄµ±Ç°ÖµºÍÉèÖÃÖµÏà¼ÓµÄ½á¹û£¬¸ÃÉèÖÃÖµ¿ÉÒÔÊÇÕýÖµ£¬Ò²¿ÉÒÔÊǸºÖµ¡£¸ù¾Ý¼ì²éºÍÉèÖòÙ×÷µÄ½á¹û£¬½øÐвÙ×÷µÄ½ø³Ì¿ÉÄÜ»á½øÈëÐÝÃß״̬£¬¶øµ±ÆäËû½ø³ÌÍê³É×Ô¼ºµÄ¼ì²é²¢ÉèÖòÙ×÷ºó£¬ÓÉϵͳ¼ì²éÇ°Ò»¸öÐÝÃß½ø³ÌÊÇ·ñ¿ÉÒÔÔÚÐÂÐźÅÁ¿ÖµµÄÌõ¼þÏÂÍê³ÉÏàÓ¦µÄ¼ì²éºÍÉèÖòÙ×÷¡£ÕâÑù£¬Í¨¹ýÐźÅÁ¿£¬¾Í¿ÉÒÔЭµ÷¶à¸ö½ø³ÌµÄ²Ù×÷¡£

    ÐźÅÁ¿¿ÉÓÃÀ´ÊµÏÖËùνµÄ¡°¹Ø¼ü¶Î¡±¡£¹Ø¼ü¶Îָͬһʱ¿ÌÖ»ÄÜÓÐÒ»¸ö½ø³ÌÖ´ÐÐÆäÖдúÂëµÄ´úÂë¶Î¡£Ò²¿ÉÓÃÐźÅÁ¿½â¾ö¾­µäµÄ¡°Éú²úÕß/Ïû·ÑÕß¡±ÎÊÌ⣬¡°Éú²úÕß/Ïû·ÑÕß¡±ÎÊÌâºÍÉÏÊöµÄ¶¨Æ±ÎÊÌâÀàËÆ¡£ÕâÒ»ÎÊÌâ¿ÉÒÔÃèÊöÈçÏ£º

    Á½¸ö½ø³Ì¹²ÏíÒ»¸ö¹«¹²µÄ¡¢¹Ì¶¨´óСµÄ»º³åÇø¡£ÆäÖеÄÒ»¸ö½ø³Ì£¬¼´Éú²úÕߣ¬Ïò»º³åÇø·ÅÈëÐÅÏ¢£¬ÁíÍâÒ»¸ö½ø³Ì£¬¼´Ïû·ÑÕߣ¬´Ó»º³åÇøÖÐÈ¡×ßÐÅÏ¢£¨¸ÃÎÊÌâÒ²¿ÉÒÔÒ»°ã»¯Îª m ¸öÉú²úÕßºÍ n ¸öÏû·ÑÕߣ©¡£µ±Éú²úÕßÏò»º³åÇø·ÅÈëÐÅϢʱ£¬Èç¹û»º³åÇøÊÇÂúµÄ£¬ÔòÉú²úÕß½øÈëÐÝÃߣ¬¶øµ±Ïû·ÑÕß´Ó»º³åÇøÖÐÄÃ×ßÐÅÏ¢ºó£¬¿É»½ÐÑÉú²úÕߣ»µ±Ïû·ÑÕß´Ó»º³åÇøÖÐÈ¡ÐÅϢʱ£¬Èç¹û»º³åÇøΪ¿Õ£¬ÔòÏû·ÑÕß½øÈëÐÝÃߣ¬¶øµ±Éú²úÕßÏò»º³åÇøдÈëÐÅÏ¢ºó£¬¿É»½ÐÑÏû·ÑÕß¡£

Çåµ¥ 2 ÖеÄÀý×Óʵ¼ÊÊÇ¡°Éú²úÕß/Ïû·ÑÕß¡±ÎÊÌâµÄḬ̈߳汾¡£

Çåµ¥ 2 ÀûÓÃÐźÅÁ¿½â¾ö¡°Éú²úÕß/Ïû·ÑÕß¡±ÎÊÌâ

/* The classic producer-consumer example, implemented with semaphores.
   All integers between 0 and 9999 should be printed exactly twice,
   once to the right of the arrow and once to the left. */

#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>

#define BUFFER_SIZE 16

/* Circular buffer of integers. */

struct prodcons {
  int buffer[BUFFER_SIZE];      /*  ʵ¼ÊÊý¾Ý */
  int readpos, writepos;        /* ¶ÁÈ¡ºÍдÈëµÄλÖà */
  sem_t sem_read;               /* ¿É¶ÁÈ¡µÄÔªËظöÊý */
  sem_t sem_write;              /* ¿ÉдÈëµÄ¿Õλ¸öÊý */
};


/* ³õʼ»¯»º³åÇø */
void init(struct prodcons * b)
{
  sem_init(&b->sem_write, 0, BUFFER_SIZE - 1);
  sem_init(&b->sem_read, 0, 0);
  b->readpos = 0;
  b->writepos = 0;
}


/* ÔÚ»º³åÇøÖб£´æÒ»¸öÕûÊý  */
void put(struct prodcons * b, int data)
{
  /* Wait until buffer is not full */
  sem_wait(&b->sem_write);
  /* Write the data and advance write pointer */
  b->buffer[b->writepos] = data;
  b->writepos++;
  if (b->writepos >= BUFFER_SIZE) b->writepos = 0;
  /* Signal that the buffer contains one more element for reading */
  sem_post(&b->sem_read);
}

/* ´Ó»º³åÇø¶ÁÈ¡²¢É¾³ýÊý¾Ý  */
int get(struct prodcons * b)
{
  int data;
  /* Wait until buffer is not empty */
  sem_wait(&b->sem_read);
  /* Read the data and advance read pointer */
  data = b->buffer[b->readpos];
  b->readpos++;
  if (b->readpos >= BUFFER_SIZE) b->readpos = 0;
  /* Signal that the buffer has now one more location for writing */
  sem_post(&b->sem_write);
  return data;
}

/* ²âÊÔ³ÌÐò: Ò»¸öÏ̲߳åÈë 1 µ½ 10000 µÄÕûÊý£¬ÁíÒ»¸öÏ̶߳ÁÈ¡²¢´òÓ¡¡£*/
#define OVER (-1)

struct prodcons buffer;

void * producer(void * data)
{
  int n;
  for (n = 0; n < 10000; n++) {
    printf("%d --->\n", n);
    put(&buffer, n);
  }
  put(&buffer, OVER);
  return NULL;
}

void * consumer(void * data)
{
  int d;
  while (1) {
    d = get(&buffer);
    if (d == OVER) break;
    printf("---> %d\n", d);
  }
  return NULL;
}

int main(void)
{
  pthread_t th_a, th_b;
  void * retval;

  init(&buffer);

  /* ½¨Á¢Éú²úÕߺÍÏû·ÑÕßÏ̡߳£*/
  pthread_create(&th_a, NULL, producer, 0);
  pthread_create(&th_b, NULL, consumer, 0);

  /* µÈ´ýÉú²úÕߺÍÏû·ÑÕß½áÊø¡£ */
  pthread_join(th_a, &retval);
  pthread_join(th_b, &retval);
  return 0;
}

    ÔÚÇåµ¥ 2 ÖУ¬³ÌÐòÊ×ÏȽ¨Á¢ÁËÁ½¸öÏ̷ֱ߳ð°çÑÝÉú²úÕߺÍÏû·ÑÕߵĽÇÉ«¡£Éú²úÕ߸ºÔ𽫠1 µ½ 1000 µÄÕûÊýдÈ뻺³åÇø£¬¶øÏû·ÑÕ߸ºÔð´Óͬһ¸ö»º³åÇøÖжÁÈ¡²¢É¾³ýÓÉÉú²úÕßдÈëµÄÕûÊý¡£ÒòΪÉú²úÕߺÍÏû·ÑÕßÊÇÁ½¸öͬʱÔËÐеÄỊ̈߳¬²¢ÇÒҪʹÓÃͬһ¸ö»º³åÇø½øÐÐÊý¾Ý½»»»£¬Òò´Ë±ØÐëÀûÓÃÒ»ÖÖ»úÖƽøÐÐͬ²½¡£Çåµ¥ 2 ÖеijÌÐò¾ÍÀûÓÃÐźÅÁ¿ÊµÏÖÁËͬ²½¡£

    Æð³õ³ÌÐò³õʼ»¯ÁËÁ½¸öÐźÅÁ¿£¨init()º¯Êý£©£¬·Ö±ð±íʾ¿É¶ÁÈ¡µÄÔªËØÊýÄ¿£¨sem_read£©ºÍ¿ÉдÈëµÄ¿Õλ¸öÊý£¨sem_write£©£¬²¢·Ö±ð³õʼ»¯Îª 0 ºÍ»º³åÇø´óС¼õ1¡£ÔÚÉú²úÕßµ÷Óà put() º¯ÊýдÈëʱ£¬ËüÊ×ÏÈ¶Ô sem_write ½øÐÐDOWN ²Ù×÷£¨¼´ sem_wait µ÷Óã©£¬¿´ÊÇ·ñÄܹ»Ð´È룬Èç¹û´Ëʱ sem_write ÐźÅÁ¿µÄÖµ´óÓÚÁ㣬Ôò sem_wait ¿ÉÒÔÁ¢¼´·µ»Ø£¬·ñÔòÉú²úÕß½«Ôڸà sem_write ÐźÅÁ¿Éϵȴý¡£Éú²úÕßÔÚ½«Êý¾ÝдÈëÖ®ºó£¬ÔÚ sem_read ÐźÅÁ¿ÉϽøÐÐ UP ²Ù×÷£¨¼´sem_postµ÷Óã©¡£´ËʱÈç¹ûÓÐÏû·ÑÕߵȴýÔÚ sem_read ÐźÅÁ¿ÉÏ£¬Ôò¿ÉÒÔ±»ÏµÍ³»½ÐѶø¼ÌÐøÔËÐС£Ïû·ÑÕßÏ̵߳IJÙ×÷Ç¡Ç¡Ïà·´£¬¸ÃÏ̵߳÷Óà get() º¯Êýʱ£¬Ê×ÏÈÔÚ sem_read ÉϽøÐÐ DOWN ²Ù×÷£¬µ±¶ÁÈ¡Êý¾Ý²¢É¾³ýÖ®ºó£¬ÔÚ sem_write ÐźÅÁ¿ÉϽøÐÐ UP ²Ù×÷¡£

    ͨ¹ýÉÏÃæµÄÁ½¸öÀý×Ó£¬¶ÁÕß¿ÉÒÔ¶ÔÏß³ÌÖ®¼äµÄ»¥²Ù×÷ÓÐÒ»¸ö´ó¸ÅÁ˽⡣Èç¹û¶ÁÕß¶Ô System V IPC »úÖƱȽÏÊìϤµÄ»°£¬Ò²¿ÉÒÔ×÷Ò»·¬±È½Ï¡£¿ÉÒÔ¿´µ½£¬¶àÏ̵߳Ä×î´óºÃ´¦ÊÇ£¬³ý¶ÑÕ»Ö®Í⣬¼¸ºõËùÓеÄÊý¾Ý¾ùÊǹ²ÏíµÄ£¬Òò´ËÏ̼߳äµÄͨѶЧÂÊ×î¸ß£»µ«×î´ó»µ´¦ÊÇ£¬ÒòΪ¹²ÏíËùÓÐÊý¾Ý£¬´Ó¶ø·Ç³£ÈÝÒ×µ¼ÖÂÏß³ÌÖ®¼ä»¥ÏàÆÆ»µÊý¾Ý¡£

2.3 MiniGUI ºÍ¶àÏß³Ì
    MiniGUI 1.0 °æ±¾²ÉÓÃÁ˶àÏ̻߳úÖÆ£¬Ò²¾ÍÊÇ˵£¬MiniGUI ÒÔ¼°ÔËÐÐÔÚ MiniGUI Ö®ÉϵÄËùÓÐÓ¦ÓóÌÐò¾ùÔËÐÐÔÚͬһ¸öµØÖ·¿Õ¼äÖ®ÄÚ¡£±ÈÆðÆäËû»ùÓÚ½ø³ÌµÄ GUI ϵͳÀ´Ëµ£¬ËäȻȱÉÙÁ˵ØÖ·±£»¤£¬µ«ÔËÐÐЧÂÊÈ´ÊÇ×î¸ßµÄ¡£

[Ŀ¼]


»ùÓÚ PThread µÄ΢¿Í»§/·þÎñÆ÷½á¹¹

3 »ùÓÚ PThread µÄ΢¿Í»§/·þÎñÆ÷½á¹¹

3.1 ¶àÏ̵߳ķֲãÉè¼Æ
    ´ÓÕûÌå½á¹¹ÉÏ¿´£¬MiniGUI ÊÇ·Ö²ãÉè¼ÆµÄ£¬²ã´Î½á¹¹¼ûͼ 1¡£ÔÚ×îµ×²ã£¬GAL ºÍ IAL Ìṩµ×²ãͼÐνӿÚÒÔ¼°Êó±êºÍ¼üÅ̵ÄÇý¶¯£»Öмä²ãÊÇ MiniGUI µÄºËÐIJ㣬ÆäÖаüÀ¨ÁË´°¿Úϵͳ±Ø²»¿ÉÉٵĸ÷¸öÄ£¿é£»×²ãÊÇ API£¬¼´±à³Ì½Ó¿Ú¡£

    GAL ºÍ IAL Ϊ MiniGUI ÌṩÁ˵ײãµÄ Linux ¿ØÖÆ̨»òÕß X Window ÉϵÄͼÐνӿÚÒÔ¼°ÊäÈë½Ó¿Ú£¬¶ø Pthread ÊÇÓÃÓÚÌṩÄں˼¶Ïß³ÌÖ§³ÖµÄ C º¯Êý¿â¡£

MiniGUI ±¾ÉíÔËÐÐÔÚ¶àÏß³ÌģʽÏ£¬ËüµÄÐí¶àÄ£¿é¶¼ÒÔµ¥¶ÀµÄÏß³ÌÔËÐУ¬Í¬Ê±£¬MiniGUI »¹ÀûÓÃÏß³ÌÀ´Ö§³Ö¶à´°¿Ú¡£´Ó±¾ÖÊÉϽ²£¬Ã¿¸öÏß³ÌÓÐÒ»¸öÏûÏ¢¶ÓÁУ¬ÏûÏ¢¶ÓÁÐÊÇʵÏÖÏß³ÌÊý¾Ý½»»»ºÍͬ²½µÄ¹Ø¼üÊý¾Ý½Ó¿Ú¡£Ò»¸öÏß³ÌÏòÏûÏ¢¶ÓÁÐÖз¢ËÍÏûÏ¢£¬¶øÁíÒ»¸öÏ̴߳ÓÕâ¸öÏûÏ¢¶ÓÁÐÖлñÈ¡ÏûÏ¢£¬Í¬Ò»¸öÏß³ÌÖд´½¨µÄ´°¿Ú¿É¹²Ïíͬһ¸öÏûÏ¢¶ÓÁС£ÀûÓÃÏûÏ¢¶ÓÁкͶàÏß³ÌÖ®¼äµÄͬ²½»úÖÆ£¬¿ÉÒÔʵÏÖÏÂÃæÒª½²µ½µÄ΢¿Í»§/·þÎñÆ÷»úÖÆ¡£

    ¶àÏß³ÌÓÐÆäÒ»¶¨µÄºÃ´¦£¬µ«²»·½±ãµÄÊDz»Í¬µÄÏ̹߳²ÏíÁËͬһ¸öµØÖ·¿Õ¼ä£¬Òò´Ë£¬¿Í»§Ï߳̿ÉÄÜ»áÆÆ»µÏµÍ³·þÎñÆ÷Ï̵߳ÄÊý¾Ý£¬µ«ÓÐÒ»¸öÖØÒªµÄÓÅÊÆÊÇ£¬ÓÉÓÚ¹²ÏíµØÖ·¿Õ¼ä£¬Ïß³ÌÖ®¼ä¾ÍûÓжîÍâµÄÊý¾Ý¸´ÖÆ¿ªÏú¡£

    ÓÉÓÚ MiniGUI ÊÇÃæÏòǶÈëʽ»òʵʱ¿ØÖÆϵͳµÄ£¬Òò´Ë£¬ÕâÖÖÓ¦Óû·¾³ÏµÄÓ¦ÓóÌÐòÍùÍù¾ßÓе¥Ò»µÄ¹¦ÄÜ£¬´Ó¶øʹµÃ²ÉÓöàÏ̶߳ø·Ç¶à½ø³ÌģʽʵÏÖͼÐνçÃæÓÐÁËÒ»¶¨µÄʵ¼ÊÒâÒ壬Ҳ¸ü¼Ó·ûºÏ MiniGUI Ö®¡°mini¡±µÄÌØÉ«¡£

3.2 ΢¿Í»§/·þÎñÆ÷½á¹¹
    ÔÚ¶àÏ̻߳·¾³ÖУ¬Óë¶à½ø³Ì¼äµÄͨѶ»úÖÆÀàËÆ£¬Ïß³ÌÖ®¼äÒ²Óн»»¥ºÍͬ²½µÄÐèÇó¡£±ÈÈ磬ÓÃÀ´¹ÜÀí´°¿ÚµÄÏß³Ìά³ÖÈ«¾ÖµÄ´°¿ÚÁÐ±í£¬¶øÆäËûÏ̲߳»ÄÜÖ±½ÓÐÞ¸ÄÕâЩȫ¾ÖµÄÊý¾Ý½á¹¹£¬¶ø±ØÐëÒÀ¾Ý¡°ÏÈÀ´ÏÈ·þÎñ¡±µÄÔ­Ôò£¬ÒÀ´Î´¦Àíÿ¸öÏ̵߳ÄÇëÇó£¬Õâ¾ÍÊÇÒ»°ãÐԵĿͻ§/·þÎñÆ÷ģʽ¡£MiniGUI ÀûÓÃÏß³ÌÖ®¼äµÄͬ²½²Ù×÷ʵÏÖÁË¿Í»§Ï̺߳ͷþÎñÆ÷Ïß³ÌÖ®¼äµÄ΢¿Í»§/·þÎñÆ÷»úÖÆ£¬Ö®ËùÒÔÕâÑùÃüÃû£¬ÊÇÒòΪ¿Í»§ºÍ·þÎñÆ÷ÊÇͬһ½ø³ÌÖеIJ»Í¬Ï̡߳£

    ΢¿Í»§/·þÎñÆ÷»úÖƵĺËÐÄʵÏÖÖ÷Òª¼¯ÖÐÔÚÏûÏ¢¶ÓÁÐÊý¾Ý½á¹¹ÉÏ¡£±ÈÈ磬MiniGUI ÖÐµÄ desktop ΢·þÎñÆ÷¹ÜÀí´°¿ÚµÄ´´½¨ºÍÏú»Ù¡£µ±Ò»¸öÏß³ÌÒªÇó desktop ΢·þÎñÆ÷½¨Á¢Ò»¸ö´°¿Úʱ£¬¸ÃÏß³ÌÊ×ÏÈÔÚ desktop µÄÏûÏ¢¶ÓÁÐÖзÅÖÃÒ»ÌõÏûÏ¢£¬È»ºó½øÈëÐÝÃß״̬¶øµÈ´ý desktop ´¦ÀíÕâÒ»ÇëÇ󣬵± desktop ´¦ÀíÍê³Éµ±Ç°ÈÎÎñÖ®ºó£¬»òÕý´¦ÓÚÐÝÃß״̬ʱ£¬Ëü¿ÉÒÔÁ¢¼´´¦ÀíÕâÒ»ÇëÇó£¬ÇëÇó´¦ÀíÍê³Éʱ£¬desktop ½«»½ÐѵȴýµÄỊ̈߳¬²¢·µ»ØÒ»¸ö´¦Àí½á¹û¡£

    µ± MiniGUI ÔÚ³õʼ»¯È«¾ÖÊý¾Ý½á¹¹ÒÔ¼°¸÷¸öÄ£¿éÖ®ºó£¬MiniGUI ÒªÆô¶¯¼¸¸öÖØÒªµÄ΢·þÎñÆ÷£¬ËüÃÇ·Ö±ðÍê³É²»Í¬µÄϵͳÈÎÎñ£º

    desktop ÓÃÓÚ¹ÜÀí MiniGUI ´°¿ÚÖеÄËùÓÐÖ÷´°¿Ú£¬°üÀ¨½¨Á¢¡¢Ïú»Ù¡¢ÏÔʾ¡¢Òþ²Ø¡¢ÐÞ¸Ä Z-order¡¢»ñµÃÊäÈë½¹µãµÈµÈ¡£
parsor Ïß³ÌÓÃÀ´´Ó IALÖÐÊÕ¼¯Êó±êºÍ¼üÅÌʼþ£¬²¢½«ÊÕ¼¯µ½µÄʼþת»»ÎªÏûÏ¢¶øÓʼĸø desktop ·þÎñÆ÷¡£
    timer Ïß³ÌÓÃÀ´´¥·¢¶¨Ê±Æ÷ʼþ¡£¸ÃÏß³ÌÆô¶¯Ê±Ê×ÏÈÉèÖà Linux ¶¨Ê±Æ÷£¬È»ºóµÈ´ý desktop Ï̵߳ĽáÊø£¬¼´´¦ÓÚÐÝÃß״̬¡£µ±½ÓÊÕµ½ SIGALRM ÐźÅʱ£¬¸ÃÏ̴߳¦Àí¸ÃÐźŲ¢Ïò desktop ·þÎñÆ÷·¢ËͶ¨Ê±Æ÷ÏûÏ¢¡£µ± desktop ½ÓÊÕµ½¶¨Ê±Æ÷ÏûϢʱ£¬desktop »á²é¿´µ±Ç°´°¿ÚµÄ¶¨Ê±Æ÷ÁÐ±í£¬Èç¹ûij¸ö¶¨Ê±Æ÷¹ýÆÚ£¬Ôò»áÏò¸Ã¶¨Ê±Æ÷ËùÊôµÄ´°¿Ú·¢ËͶ¨Ê±Æ÷ÏûÏ¢¡£

[Ŀ¼]


¶àÏß³ÌͨѶµÄ¹Ø¼üÊý¾Ý½á¹¹¡ª¡ªÏûÏ¢¶ÓÁÐ

4 ¶àÏß³ÌͨѶµÄ¹Ø¼üÊý¾Ý½á¹¹--ÏûÏ¢¶ÓÁÐ

4.1 ÏûÏ¢ºÍÏûϢѭ»·
    ÔÚÈκΠGUI ϵͳÖУ¬¾ùÓÐʼþ»òÏûÏ¢Çý¶¯µÄ¸ÅÄî¡£ÔÚMiniGUIÖУ¬ÎÒÃÇʹÓÃÏûÏ¢Çý¶¯×÷ΪӦÓóÌÐòµÄ´´½¨¹¹¼Ü¡£

    ÔÚÏûÏ¢Çý¶¯µÄÓ¦ÓóÌÐòÖУ¬¼ÆËã»úÍâÉè·¢ÉúµÄʼþ£¬ÀýÈç¼üÅ̼üµÄÇû÷¡¢Êó±ê¼üµÄ°´»÷µÈ£¬¶¼ÓÉÖ§³ÖϵͳÊÕ¼¯£¬½«ÆäÒÔÊÂÏȵÄÔ¼¶¨¸ñʽ·­ÒëΪÌض¨µÄÏûÏ¢¡£Ó¦ÓóÌÐòÒ»°ã°üº¬ÓÐ×Ô¼ºµÄÏûÏ¢¶ÓÁУ¬ÏµÍ³½«ÏûÏ¢·¢Ë͵½Ó¦ÓóÌÐòµÄÏûÏ¢¶ÓÁÐÖС£Ó¦ÓóÌÐò¿ÉÒÔ½¨Á¢Ò»¸öÑ­»·£¬ÔÚÕâ¸öÑ­»·ÖжÁÈ¡ÏûÏ¢²¢´¦ÀíÏûÏ¢£¬Ö±µ½Ìض¨µÄÏûÏ¢´«À´ÎªÖ¹¡£ÕâÑùµÄÑ­»·³ÆΪÏûϢѭ»·¡£Ò»°ãµØ£¬ÏûÏ¢ÓÉ´ú±íÏûÏ¢µÄÒ»¸öÕûÐÍÊýºÍÏûÏ¢µÄ¸½¼Ó²ÎÊý×é³É¡£

    Ó¦ÓóÌÐòÒ»°ãÒªÌṩһ¸ö´¦ÀíÏûÏ¢µÄ±ê×¼º¯Êý¡£ÔÚÏûϢѭ»·ÖУ¬ÏµÍ³¿ÉÒÔµ÷Óô˺¯Êý£¬Ó¦ÓóÌÐòÔڴ˺¯ÊýÖд¦ÀíÏàÓ¦µÄÏûÏ¢¡£

    MiniGUI Ö§³ÖÈçϼ¸ÖÖÏûÏ¢µÄ´«µÝ»úÖÆ¡£ÕâЩ»úÖÆΪ¶àÏ̻߳·¾³ÏµĴ°¿Ú¼äͨѶÌṩÁË»ù±¾Í¾¾¶£º

    ·Í¨¹ý PostMessage ·¢ËÍ¡£ÏûÏ¢·¢Ë͵½ÏûÏ¢¶ÓÁкóÁ¢¼´·µ»Ø¡£ÕâÖÖ·¢ËÍ·½Ê½³ÆΪ¡°Óʼġ±ÏûÏ¢¡£Èç¹ûÏûÏ¢¶ÓÁÐÖеÄÓʼÄÏûÏ¢»º³åÇøÒÑÂú£¬Ôò¸Ãº¯Êý·µ»Ø´íÎóÖµ¡£
    ·Í¨¹ý PostSyncMessage ·¢ËÍ¡£¸Ãº¯ÊýÓÃÀ´Ïò²»Í¬ÓÚµ÷Óøú¯ÊýµÄÏß³ÌÏûÏ¢¶ÓÁÐÓʼÄÏûÏ¢£¬²¢ÇÒÖ»ÓиÃÏûÏ¢±»´¦ÀíÖ®ºó£¬¸Ãº¯Êý²ÅÄÜ·µ»Ø£¬Òò´ËÕâÖÖÏûÏ¢³ÆΪ¡°Í¬²½ÏûÏ¢¡±¡£
    ·Í¨¹ý SendMessage ·¢ËÍ¡£¸Ãº¯Êý¿ÉÒÔÏòÈÎÒâÒ»¸ö´°¿Ú·¢ËÍÏûÏ¢£¬ÏûÏ¢´¦ÀíÍê³ÉÖ®ºó£¬¸Ãº¯Êý·µ»Ø¡£Èç¹ûÄ¿±ê´°¿ÚËùÔÚÏ̺߳͵÷ÓÃÏß³ÌÊÇͬһ¸öỊ̈߳¬¸Ãº¯ÊýÖ±½Óµ÷Óô°¿Ú¹ý³Ì£¬Èç¹û´¦ÓÚ²»Í¬µÄỊ̈߳¬ÔòÀûÓà PostSyncMessage º¯Êý·¢ËÍͬ²½ÏûÏ¢¡£
    ·Í¨¹ý SendNotifyMessage ·¢ËÍ¡£¸Ãº¯ÊýÏòÖ¸¶¨µÄ´°¿Ú·¢ËÍ֪ͨÏûÏ¢£¬½«ÏûÏ¢·ÅÈëÏûÏ¢¶ÓÁкóÁ¢¼´·µ»Ø¡£ÓÉÓÚÕâÖÖÏûÏ¢ºÍÓʼÄÏûÏ¢²»Í¬£¬ÊDz»ÔÊÐí¶ªÊ§µÄ£¬Òò´Ë£¬ÏµÍ³ÒÔÁ´±íµÄÐÎʽ´¦ÀíÕâÖÖÏûÏ¢¡£
ͨ¹ý SendAsyncMessage ·¢ËÍ¡£ÀûÓøú¯Êý·¢Ë͵ÄÏûÏ¢³ÆΪ¡°Òì²½ÏûÏ¢¡±£¬ÏµÍ³Ö±½Óµ÷ÓÃÄ¿±ê´°¿ÚµÄ´°¿Ú¹ý³Ì¡£

    ¶ÁÕß¿ÉÒÔÁªÏµÎÒÃÇÔÚµÚ1½ÚÖиø³öµÄ¡°Éú²úÕß/Ïû·ÑÕß¡±ÎÊÌâ¶øÏëµ½Ò»¸ö¼òµ¥µÄÏûÏ¢¶ÓÁеÄʵÏÖ£¬¸ÃÏûÏ¢¶ÓÁпÉÒÔ¼òµ¥µØÉè¼ÆΪһ¸öÀàËÆÇåµ¥ 2 µÄÑ­»·¶ÓÁС£µ«ÊÇ£¬GUI ϵͳÖеÄÏûÏ¢¶ÓÁв¢²»ÄÜÊÇÒ»¸ö¼òµ¥µÄÑ­»·¶ÓÁУ¬Ëü»¹Òª×¢Òâµ½ÈçÏÂһЩÎÊÌ⣺

    ÏûÏ¢Ò»°ã¸½´øÓÐÏà¹ØµÄÊý¾Ý£¬ÕâЩÊý¾Ý¶Ô¸÷ÖÖÏûÏ¢¾ßÓв»Í¬µÄº¬Ò壬Ôڶര¿Ú»·¾³£¬ÓÈÆäÊǶà½ø³Ì»·¾³Ï£¬ÏûÏ¢Êý¾ÝµÄÓÐЧ´«µÝ·Ç³£ÖØÒª¡£
    ÏûÏ¢×÷Ϊ´°¿Ú¼ä½øÐÐÊý¾Ý½»»»µÄÒ»ÖÖ·½Ê½£¬ÒªÌṩ¶àÖÖ´«µÝ»úÖÆ¡£Ä³Ð©Çé¿öÏ£¬·¢ËÍÏûÏ¢µÄ´°¿ÚÒªµÈµ½Õâ¸öÏûÏ¢´¦ÀíÍê³ÉÖ®ºó£¬ÖªµÀ´¦ÀíµÄ½á¹ûÖ®ºó²ÅÄܼÌÐøÖ´ÐУ»¶øÓÐЩÇé¿öÏ£¬·¢ËÍÏûÏ¢µÄ´°¿ÚÖ»ÊǼòµ¥µØÏò½ÓÊÕÏûÏ¢µÄ´°¿Ú֪ͨijЩʼþµÄ·¢Éú£¬Ò»°ã·¢ËͳöÏûÏ¢Ö®ºó¾Í·µ»Ø¡£ºóÒ»ÖÖÇé¿öÀàËÆÓÚÓʼÄÐżþ£¬ËùÒÔͨ³£³ÆΪÓʼÄÏûÏ¢¡£¸üÓÐÒ»ÖÖ½ÏΪ¸´ÔÓµÄÇé¿ö£¬¾ÍÊǵȴýÒ»¸ö¿ÉÄܳ¤Ê±¼äÎÞ·¨±»´¦ÀíµÄÏûϢʱ£¬·¢Ë͵ÄÏûÏ¢µÄ´°¿ÚÉèÖÃÒ»¸ö³¬Ê±Öµ£¬ÒÔ±ãÄܹ»ÔÚÏûÏ¢µÃ²»µ½¼°Ê±´¦ÀíµÄÇé¿öÏÂÄܹ»»Ö¸´Ö´ÐС£
    ijЩÌØÊâÏûÏ¢µÄ´¦ÀíÒ²ÐèҪעÒ⣬±ÈÈ綨ʱÆ÷¡£µ±Ä³¸ö¶¨Ê±Æ÷µÄƵÂʺܸߣ¬¶ø´¦ÀíÕâ¸ö¶¨Ê±Æ÷µÄ´°¿ÚµÄ·´Ó¦ËÙ¶ÈÓÖºÜÂý£¬ÕâʱÈç¹û²ÉÓÃÓʼÄÏûÏ¢»òÕß·¢ËÍÏûÏ¢µÄ·½Ê½£¬ÏßÐÔµÄÑ­»·¶ÓÁÐ×îÖվͻáÈûÂú¡£
×îºóÒ»¸öÎÊÌâÊÇÏûÏ¢ÓÅÏȼ¶µÄÎÊÌâ¡£Ò»°ãÇé¿öÏ£¬Òª¿¼ÂÇÓÅÏÈ´¦ÀíÊó±ê»ò¼üÅ̵ÄÊäÈëÏûÏ¢£¬Æä´Î²ÅÊÇÖØ»æºÍ¶¨Ê±Æ÷µÈÏûÏ¢¡£
    ÌØÊâÏûÏ¢µÄ´¦Àí¡£ÓÉÓÚ´°¿ÚÖØ»æÏûÏ¢µÄÌØÊâÐÔ£¨Í¨³£±È½Ï»¨·Ñʱ¼ä£©£¬Ö»Óе±³ÌÐò½«ÆäËûÏûÏ¢´¦ÀíÖ®ºó£¬²Å»á´¦ÀíÖØ»æÏûÏ¢¡£²¢ÇÒÖ»ÓдæÔÚ´°¿ÚµÄÎÞЧÇøÓòµÄʱºò£¬²Å»á֪ͨ³ÌÐò´¦Àí´°¿ÚµÄÖػ档
¼øÓÚÒÔÉÏÒªÌØÊ⿼ÂǵÄÎÊÌ⣬MiniGUI ÖеÄÏûÏ¢¶ÓÁÐÒª±ÈÇåµ¥ 2 ÖеÄÑ­»·¶ÓÁи´ÔÓ¡£²Î¼ûÇåµ¥ 3¡£

Çåµ¥ 3  MiniGUI µÄÏûÏ¢¶ÓÁж¨Òå

typedef struct _MSGQUEUE
{
    DWORD dwState;              // ÏûÏ¢¶ÓÁÐ״̬

    pthread_mutex_t lock;       // »¥³âËø
    sem_t wait;                 // µÈ´ýÐźÅÁ¿

    PQMSG  pFirstNotifyMsg;     // ֪ͨÏûÏ¢¶ÓÁеÄÍ·
    PQMSG  pLastNotifyMsg;      // ֪ͨÏûÏ¢¶ÓÁеÄβ

    PSYNCMSG pFirstSyncMsg;     // ͬ²½ÏûÏ¢¶ÓÁеÄÍ·
    PSYNCMSG pLastSyncMsg;      // ͬ²½ÏûÏ¢¶ÓÁеÄβ

    MSG* msg;                   // ÓʼÄÏûÏ¢»º³åÇø
    int len;                    // ÓʼÄÏûÏ¢»º³åÇø³¤¶È
    int readpos, writepos;      // ÓʼÄÏûÏ¢»º³åÇøµÄµ±Ç°¶ÁÈ¡ºÍдÈëλÖÃ

    /*
     * One thread can only support eight timers.
     * And number of all timers in a MiniGUI applicatoin is 16.
     */
    HWND TimerOwner[8];         // ¶¨Ê±Æ÷ËùÓÐÕß
    int  TimerID[8];            // ¶¨Ê±Æ÷±êʶ·û
    BYTE TimerMask;             // ÒÑʹÓõĶ¨Ê±Æ÷ÑÚÂë
} MSGQUEUE;
typedef MSGQUEUE* PMSGQUEUE;

    ¿ÉÒÔ¿´³ö£¬ÔÚ MiniGUI µÄÏûÏ¢¶ÓÁж¨ÒåÖУ¬Ö»ÓÐÓʼÄÏûÏ¢µÄ¶¨ÒåÀàËÆÇåµ¥ 2 ÖеÄÏßÐÔÑ­»·¶ÓÁС£ÉÏÃæÌáµ½£¬Í¨ÖªÏûÏ¢ÀàËÆÓʼÄÏûÏ¢£¬µ«¸ÃÏûÏ¢ÊDz»ÔÊÐí¶ªÊ§µÄ£¬Òò´Ë£¬¸ÃÏûϢͨ¹ýÁ´±íÐÎʽʵÏÖ¡£PMSG ½á¹¹µÄ¶¨ÒåÒ²ºÜ¼òµ¥£º

typedef struct _QMSG
{
    MSG                 Msg;
    struct _QMSG*       next;
    BOOL                fromheap;
}QMSG;
typedef QMSG* PQMSG;

    ÓÃÓÚͬ²½ÏûÏ¢´«µÝµÄÊý¾Ý½á¹¹Îª SYNCMSG£¬¸Ã½á¹¹ÔÚÏûÏ¢¶ÓÁÐÖÐÒ²ÐγÉÁËÒ»¸öÁ´±í£¬µ«¸Ã½á¹¹±¾ÉíÉÔ΢¸´ÔÓһЩ£º

typedef struct _SYNCMSG
{
    MSG              Msg;
    int              retval;
    sem_t            sem_handle;
    struct _SYNCMSG* pNext;
}SYNCMSG;
typedef SYNCMSG* PSYNCMSG;

    ¿ÉÒÔ¿´µ½£¬¸Ã½á¹¹ÖÐÓÐÒ»¸öÐźÅÁ¿£¬¸ÃÐźÅÁ¿¾ÍÊÇÓÃÀ´Í¨ÖªÍ¬²½ÏûÏ¢µÄ·¢ËÍÏ̵߳ġ£µ±½ÓÊÕ²¢´¦Àíͬ²½ÏûÏ¢µÄÏ̴߳¦Àí¸ÃÏûÏ¢Ö®ºó£¬½«ÔÚ retval ³ÉÔ±Öдæ·Å´¦Àí½á¹û£¬È»ºóͨ¹ý sem_handle ÐźÅÁ¿»½ÐÑͬ²½ÏûÏ¢µÄ·¢ËÍÏ̡߳£

    ÔÚÉÏÊöÏûÏ¢¶ÓÁнṹµÄ¶¨ÒåÖУ¬»¹ÓÐÁ½¸ö·Ö±ðÓÃÀ´ÊµÏÖ»¥³â·ÃÎʺÍͬ²½µÄ³ÉÔ±£¬¼´»¥³âËø lock ºÍÐźÅÁ¿ wait¡£»¥³âËø lock ÓÃÀ´ÊµÏÖ²»Í¬Ï̶߳ÔÏûÏ¢¶ÓÁеĻ¥³â·ÃÎÊ£¬±ÈÈçÔÚ»ñÈ¡ÓʼÄÏûϢʱµÄ²Ù×÷ÈçÏ£º

        pthread_mutex_lock (&pMsgQueue->lock);
        if (pMsgQueue->readpos != pMsgQueue->writepos) {

            pMsgQueue->readpos++;
            if (pMsgQueue->readpos >= pMsgQueue->len) pMsgQueue->readpos = 0;

            pthread_mutex_unlock (&pMsgQueue->lock);
            return 1;
        }
        else
            pMsgQueue->dwState &= ~QS_POSTMSG;

        pthread_mutex_unlock (&pMsgQueue->lock);


    ÐźÅÁ¿ wait ÓÃÀ´Í¬²½ÏûϢѭ»·¡£Ò»°ãÀ´Ëµ£¬Ò»¸öÏß³ÌÔÚ½¨Á¢´°¿ÚÖ®ºó£¬Òª½øÈëÏûϢѭ»·³ÖÐøµØ´ÓÏûÏ¢¶ÓÁÐÖлñÈ¡ÏûÏ¢£¨Í¨¹ý GetMessage() º¯Êý£©¡£µ±ÏûÏ¢¶ÓÁÐÖÐûÓÐÈκÎÏûϢʱ£¬¸ÃÏ߳̽«½øÈëÐÝÃß״̬£¬¶øµ±ÆäËûÏ߳̽«ÏûÏ¢ÓʼĻò·¢Ë͵½¸ÃÏûÏ¢¶ÓÁÐÖ®ºó£¬½«Í¨¹ýÐźÅÁ¿ wait »½ÐѸÃỊ̈߳º

    sem_getvalue (&pMsgQueue->wait, &sem_value);
    if (sem_value == 0)
        sem_post(&pMsgQueue->wait);

    ÔÚ MiniGUI µÄÏûÏ¢¶ÓÁнṹÖУ¬µÚÒ»¸ö³ÉÔ±ÊÇÏûÏ¢¶ÓÁеÄ״̬×Ö¡£¸Ã״̬×Öͨ¹ý±ê־λ±íʾÈçÏÂ״̬£º

    ·ÏûÏ¢¶ÓÁÐÖÐÊÇ·ñÓÐÓʼÄÏûÏ¢£»
    ·ÏûÏ¢¶ÓÁÐÖÐÊÇ·ñÓÐ֪ͨÏûÏ¢£»
    ·ÏûÏ¢¶ÓÁÐÖÐÊÇ·ñÓÐͬ²½ÏûÏ¢£»
    ·ÏûÏ¢¶ÓÁÐÖÐÊÇ·ñÓÐÍ˳öÏûÏ¢£»
    ·ÏûÏ¢¶ÓÁÐÖÐÊÇ·ñÓÐÖØ»æÏûÏ¢£»
    ·ÏûÏ¢¶ÓÁÐÖÐÊÇ·ñÓж¨Ê±Æ÷ÏûÏ¢¡£

    ͨ¹ýÕâЩ±êÖ¾£¬GetMessage() ¿ÉÅжÏÊÇ·ñÐèÒª¼ì²éÓʼÄÏûÏ¢¶ÓÁС¢Í¨ÖªÏûÏ¢Á´±íºÍͬ²½ÏûÏ¢Á´±íµÈµÈ¡£Í¬Ê±£¬ÀûÓÃÕâЩ±êÖ¾»¹¿ÉÒÔ´¦ÀíÉÏÃæÌáµ½µÄһЩÌØÊâÏûÏ¢¡£ÕâÀïÒÔ¶¨Ê±Æ÷ΪÀý½øÐÐ˵Ã÷¡£

    ÔÚ MiniGUI ÖУ¬Ò»¸ö´´½¨ÁË´°¿ÚµÄÏß³ÌÒ»°ãÓµÓÐÒ»¸öÏûÏ¢¶ÓÁУ¬Ê¹ÓøÃÏûÏ¢¶ÓÁÐËùÓд°¿Ú£¬°üÀ¨×Ó´°¿ÚÔÚÄÚ£¬Ò»¹²¿ÉÒÔ½¨Á¢ 8 ¸ö¶¨Ê±Æ÷¡£ÕâЩ¶¨Ê±Æ÷ÊÇ·ñµ½ÆÚ£¬ÌåÏÖÔÚÏûÏ¢¶ÓÁеÄ״̬×ÖÉϨD¨D״̬×ÖµÄ×îµÍ 8 λ·Ö±ðÓÃÀ´±íʾÕâ 8 ¸ö¶¨Ê±Æ÷ÊÇ·ñµ½ÆÚ¡£ÏûÏ¢¶ÓÁÐÖÐͬʱ»¹ÓÐÈý¸ö³ÉÔ±£º

    HWND TimerOwner[8];         // ¶¨Ê±Æ÷ËùÓÐÕß
    int  TimerID[8];            // ¶¨Ê±Æ÷±êʶ·û
    BYTE TimerMask;             // ÒÑʹÓõĶ¨Ê±Æ÷ÑÚÂë

    ÆäÖÐ TimerMask ±íʾµ±Ç°ÓÐЧµÄ¶¨Ê±Æ÷£¬Ã¿Î»±íʾһ¸ö¶¨Ê±Æ÷£»TimerID ±íʾÕâ 8 ¸ö¶¨Ê±Æ÷µÄ±êʶ·û£¨ÕûÊý£©£»¶ø TimerOwner Ôò±íʾ¶¨Ê±Æ÷µÄËùÓÐÕߣ¨´°¿Ú¾ä±ú£©¡£ÕâÖÖ¶¨Ê±Æ÷µÄʵÏÖ·½·¨ÀàËÆ Linux ÄÚºËÖеÄÐźÅʵÏÖ¡£¶¨Ê±Æ÷ÊÇ·ñÓÐЧÒÔ¼°ÊÇ·ñµ½ÆÚ¾ùÓɶþ½øÖÆ×Ö½ÚµÄÒ»¸öλÀ´±íʾ¡£µ± GetMessage ¼ì²éÕâЩ±ê־ʱ·¢ÏÖÓÐij¸ö¶¨Ê±Æ÷µ½ÆڲŻá»ñµÃÒ»¸ö¶¨Ê±Æ÷ÏûÏ¢¡£Ò²¾ÍÊÇ˵£¬¶¨Ê±Æ÷ÏûÏ¢ÊDz»ÅŶӵġ£ÕâÑù¾Í½â¾öÁËÅŶÓʱ¿ÉÄÜÈûÂúÏûÏ¢¶ÓÁеÄÎÊÌâ¡£

[Ŀ¼]


ÃæÏò¶ÔÏó¼¼ÊõÔÚ MiniGUI ÖеÄÓ¦ÓÃ

5 ÃæÏò¶ÔÏó¼¼ÊõÔÚ MiniGUI ÖеÄÓ¦ÓÃ

5.1 ¿Ø¼þÀàºÍ¿Ø¼þ
    MiniGUI ÖеÄÿ¸ö¿Ø¼þ¶¼ÊôÓÚijÖÖ×Ó´°¿ÚÀ࣬ÊǶÔÓ¦×Ó´°¿ÚÀàµÄʵÀý¡£ÕâÀàËÆÓÚÃæÏò¶ÔÏó¼¼ÊõÖÐÀàºÍ¶ÔÏóµÄ¹Øϵ¡£

    ÿ¸ö¿Ø¼þµÄÏûϢʵ¼Ê¶¼ÊÇÓиÿؼþËùÊô¿Ø¼þÀàµÄ»Øµ÷º¯Êý´¦ÀíµÄ£¬´Ó¶ø¿ÉÒÔÈÃÿ¸öÊôÓÚͳһ¿Ø¼þÀàµÄ¿Ø¼þ¾ù±£³ÖÓÐÏàͬµÄÓû§½çÃæºÍ´¦ÀíÐÐΪ¡£

    µ«ÊÇ£¬Èç¹ûÎÒÃÇÔÚµ÷ÓÃij¸ö¿Ø¼þÀàµÄ»Øµ÷º¯Êý֮ǰ£¬Ê×Ïȵ÷ÓÃ×Ô¼º¶¨ÒåµÄij¸ö»Øµ÷º¯ÊýµÄ»°£¬ÎÒÃǾͿÉÒÔÈøÿؼþÖØÔؿؼþÀàµÄijЩ´¦ÀíÐÐΪ£¬´Ó¶øÈøÿؼþÒ»·½Ãæ¼Ì³Ð¿Ø¼þÀàµÄ´ó²¿·Ö´¦ÀíÐÐΪ£¬ÁíÒ»·½ÃæÓÖ¾ßÓÐ×Ô¼ºµÄÌØÊâÐÐΪ¡£Õâʵ¼Ê¾ÍÊÇÃæÏò¶ÔÏóÖеļ̳кÍÅÉÉú¡£±ÈÈ磬һ°ãµÄ±à¼­¿ò»á½ÓÊÕËùÓеļüÅÌÊäÈ룬µ±ÎÒÃÇÏ£Íû×Ô¼ºµÄ±à¼­¿òÖ»½ÓÊÕÊý×Öʱ£¬¾Í¿ÉÒÔÓÃÕâÖÖ°ì·¨ÆÁ±Î·ÇÊý×ÖµÄ×Ö·ûÊäÈë¡£

5.2 GAL ºÍ IAL
    ÔÚ MiniGUI 0.3.xx µÄ¿ª·¢ÖУ¬ÎÒÃÇÒýÈëÁËͼÐκÍÊäÈë³éÏó²ã£¨Graphics and Input Abstract Layer£¬GAL ºÍ IAL£©µÄ¸ÅÄî¡£³éÏó²ãµÄ¸ÅÄîÀàËÆ Linux ÄÚºËÐéÄâÎļþϵͳµÄ¸ÅÄî¡£Ëü¶¨ÒåÁËÒ»×é²»ÒÀÀµÓÚÈκÎÌØÊâÓ²¼þµÄ³éÏó½Ó¿Ú£¬ËùÓж¥²ãµÄͼÐβÙ×÷ºÍÊäÈë´¦Àí¶¼½¨Á¢ÔÚ³éÏó½Ó¿ÚÖ®ÉÏ¡£¶øÓÃÓÚʵÏÖÕâÒ»³éÏó½Ó¿ÚµÄµ×²ã´úÂë³ÆΪ¡°Í¼ÐÎÒýÇ桱»ò¡°ÊäÈëÒýÇ桱£¬ÀàËƲÙ×÷ϵͳÖеÄÇý¶¯³ÌÐò¡£Õâʵ¼ÊÊÇÒ»ÖÖÃæÏò¶ÔÏóµÄ³ÌÐò½á¹¹¡£ÀûÓà GAL ºÍ IAL£¬MiniGUI ¿ÉÒÔÔÚÐí¶àͼÐÎÒýÇæÉÏÔËÐУ¬±ÈÈç SVGALib ºÍ LibGGI£¬²¢ÇÒ¿ÉÒԷdz£·½±ãµØ½« MiniGUI ÒÆÖ²µ½ÆäËû POSIX ϵͳÉÏ£¬Ö»ÐèÒª¸ù¾ÝÎÒÃǵijéÏó²ã½Ó¿ÚʵÏÖеÄͼÐÎÒýÇæ¼´¿É¡£Ä¿Ç°£¬ÎÒÃÇÒѾ­±àдÁË»ùÓÚ SVGALib ºÍ LibGGI µÄͼÐÎÒýÇæ¡£ÀûÓà LibGGI£¬ MiniGUI Ó¦ÓóÌÐò¿ÉÒÔÔËÐÐÔÚ X Window ÉÏ£¬½«´ó´ó·½±ãÓ¦ÓóÌÐòµÄµ÷ÊÔ¡£ÎÒÃÇÄ¿Ç°ÕýÔÚ½øÐÐ MiniGUI ˽ÓÐͼÐÎÒýÇæµÄÉè¼Æ¿ª·¢¡£Í¨¹ý MiniGUI µÄ˽ÓÐͼÐÎÒýÇ棬ÎÒÃÇ¿ÉÒÔ×î´ó³Ì¶ÈµØÕë¶Ô´°¿Úϵͳ¶ÔͼÐÎÒýÇæ½øÐÐÓÅ»¯£¬×îÖÕÌá¸ßϵͳµÄͼÐÎÐÔÄܺÍЧÂÊ¡£

    GAL ºÍ IAL µÄ½á¹¹ÊÇÒ»ÑùµÄ£¬ÎÒÃÇÕâÀïÖ»Äà GAL ×÷ΪʵÀý˵Ã÷ÃæÏò¶ÔÏó¼¼ÊõµÄÔËÓ㬲μûͼ 4¡£

    ϵͳά»¤Ò»¸öÒÑ×¢²áͼÐÎÒýÇæÊý×飬±£´æÿ¸öͼÐÎÒýÇæÊý¾Ý½á¹¹µÄÖ¸Õ롣ϵͳÀûÓÃÒ»¸öÖ¸Õë±£´æµ±Ç°Ê¹ÓõÄͼÐÎÒýÇæ¡£Ò»°ã¶øÑÔ£¬ÏµÍ³ÖÐÖÁÉÙÓÐÁ½¸öͼÐÎÒýÇ棬һ¸öÊÇ¡°ÑÆ¡±Í¼ÐÎÒýÇ棬²»½øÐÐÈκÎʵ¼ÊµÄͼÐÎÊä³ö£»Ò»¸öÊÇʵ¼ÊҪʹÓõÄͼÐÎÒýÇ棬±ÈÈç LibGGI »òÕß SVGALib¡£Ã¿¸öͼÐÎÒýÇæµÄÊý¾Ý½á¹¹¶¨ÒåÁ˸ÃͼÐÎÒýÇæµÄһЩÐÅÏ¢£¬±ÈÈç±êʶ·û¡¢ÊôÐԵȣ¬¸üÖØÒªµÄÊÇ£¬ËüʵÏÖÁË GAL Ëù¶¨ÒåµÄ¸÷¸ö½Ó¿Ú£¬°üÀ¨³õʼ»¯ºÍÖÕÖ¹¡¢Í¼ÐÎÉÏÏÂÎĹÜÀí¡¢»­µã´¦Àíº¯Êý¡¢»­Ïß´¦Àíº¯Êý¡¢¾ØÐοòÌî³äº¯Êý¡¢µ÷É«°åº¯ÊýµÈµÈ¡£

    Èç¹ûÔÚij¸öʵ¼ÊÏîÄ¿ÖÐËùʹÓõÄͼÐÎÓ²¼þ±È½ÏÌØÊ⣬ÏÖÓеÄͼÐÎÒýÇæ¾ù²»Ö§³Ö¡£Õâʱ£¬ÎÒÃǾͿÉÒÔ°²ÕÕ GAL Ëù¶¨ÒåµÄ½Ó¿ÚʵÏÖ×Ô¼ºµÄͼÐÎÒýÇ棬²¢Ö¸¶¨ MiniGUI ʹÓÃÕâÖÖ˽ÓеÄͼÐÎÒýÇæ¼´¿É¡£ÕâÖÖÈí¼þ¼¼Êõʵ¼Ê¾ÍÊÇÃæÏò¶ÔÏó¶à̬ÐԵľßÌåÌåÏÖ¡£

    ÀûÓà GAL ºÍ IAL£¬´ó´óÌá¸ßÁË MiniGUI µÄ¿ÉÒÆÖ²ÐÔ£¬²¢ÇÒʹµÃ³ÌÐòµÄ¿ª·¢ºÍµ÷ÊÔ±äµÃ¸ü¼ÓÈÝÒס£ÎÒÃÇ¿ÉÒÔÔÚ X Window ÉÏ¿ª·¢ºÍµ÷ÊÔ×Ô¼ºµÄ MiniGUI ³ÌÐò£¬Í¨¹ýÖØбàÒë¾Í¿ÉÒÔÈà MiniGUI Ó¦ÓóÌÐòÔËÐÐÔÚÌØÊâµÄǶÈëʽӲ¼þƽ̨ÉÏ¡£

5.3 ×Ö·û¼¯ºÍ×ÖÌåÖ§³Ö
    Ôڳɹ¦ÒýÈë GAL ºÍ IAL Ö®ºó£¬ÎÒÃÇÓÖÔÚ´¦Àí×ÖÌåºÍ×Ö·û¼¯µÄÄ£¿éµ±ÖÐÒýÈëÁËÂß¼­×ÖÌåµÄ¸ÅÄî¡£Âß¼­×ÖÌåÊÇ MiniGUI ÓÃÀ´´¦ÀíÎı¾£¨°üÀ¨Îı¾Êä³öºÍÎı¾·ÖÎö£©µÄ¶¥²ã½Ó¿Ú¡£Âß¼­×ÖÌå½Ó¿Ú½«¸÷ÖÖ²»Í¬µÄ×ÖÌ壨±ÈÈçËÎÌå¡¢ºÚÌåºÍ¿«Ì壩ºÍ×ÖÌå¸ñʽ£¨±ÈÈçµÈ¿í×ÖÌå¡¢±ä¿í×ÖÌåµÈ¹âÕ¤×ÖÌåºÍ TrueType µÈʸÁ¿×ÖÌ壩£¬ÒÔ¼°¸÷ÖÖ²»Í¬×Ö·û¼¯£¨ISO-8859¡¢GB2312¡¢Big5¡¢UNICODEµÈ£©×ÛºÏÁËÆðÀ´£¬´Ó¶ø¿ÉÒÔͨ¹ýͳһµÄ½Ó¿ÚÏÔʾ²»Í¬×Ö·û¼¯µÄ²»Í¬×ÖÌåµÄÎı¾£¬²¢ÇÒ»¹¿ÉÒÔ·ÖÎö¸÷ÖÖ×Ö·û¼¯Îı¾µÄ×é³É£¬±ÈÈç×Ö·û¡¢µ¥´ÊµÈ¡£ÔÚ¶à×ÖÌåºÍ¶à×Ö·û¼¯µÄÖ§³ÖÖУ¬ÎÒÃÇÒ²²ÉÓÃÁËÃæÏò¶ÔÏóµÄÈí¼þ¼¼Êõ£¬Ê¹µÃÌí¼ÓеÄ×ÖÌåÖ§³ÖºÍеÄ×Ö·û¼¯Ö§³Ö·Ç³£·½±ã¡£Ä¿Ç°£¬MiniGUI Äܹ»Ö§³Ö¸÷ÖÖ¹âÕ¤×ÖÌåºÍ TrueType¡¢Adobe Type 1 µÈʸÁ¿×ÖÌ壬²¢Äܹ»Ö§³Ö GB2312¡¢Big5 µÈ¶à×Ö½Ú×Ö·û¼¯£¬UNICODE µÄÖ§³ÖÕýÔÚ¿ª·¢µ±ÖС£

    Ïà¶Ô GAL ºÍ IAL ¶øÑÔ£¬MiniGUI ÖеÄ×Ö·û¼¯ºÍ×ÖÌåÖ§³Ö¸ü¼Ó¸´ÔÓ£¬Éæ¼°µ½µÄÄÚÈÝÒ²½Ï¶à¡£Ç°ÃæÌáµ½£¬ÎÒÃÇͨ¹ýÂß¼­×ÖÌåÕâÒ»½Ó¿Ú£¬ÊµÏÖÁËÎÄ×ÖÊä³öºÍÎı¾·ÖÎöÁ½¸ö¹¦ÄÜ¡£Êµ¼ÊÕâÁ½¸ö¹¦ÄÜÊÇÏ໥¹ØÁªµÄ¡£ÔÚ½øÐÐÎı¾Êä³öʱ£¬ÓÈÆäÔÚ´¦Àí¶à×Ö½Ú×Ö·û¼¯£¬±ÈÈç GB2312 »òÕß Big5 ʱ£¬Ê×ÏÈÒª¶ÔÎı¾½øÐзÖÎö£¬ÒÔ±ãÅжÏÊÇ·ñÊÇÒ»¸öÊôÓÚ¸Ã×Ö·û¼¯µÄË«×Ö½Ú×Ö·û¡£

[Ŀ¼]


δÀ´¿¼ÂÇ

6 ÔÚ MiniGUI 2.0 ÖеĿ¼ÂÇ

    ¾¡¹Ü MiniGUI ²ÉÓöàÏ̻߳úÖÆʵÏÖÁËÒ»¸öСÇÉ¡¢¸ßЧµÄ´°¿Úϵͳ£¬µ«ÓкܶàÀíÓÉÏ£Íû MiniGUI Äܹ»²ÉÓöà½ø³Ì»úÖÆʵÏÖ£¨¾¡¹Ü¶à½ø³Ì»úÖÆ¿ÉÄÜ´øÀ´Í¨Ñ¶ÉϵĶîÍ⿪֧£©£º

    ·Á¼ºÃµÄµØÖ·±£»¤¡£´°¿Ú±¾ÉíµÄ±ÀÀ£²»»áÓ°Ïì MiniGUI µÄÔËÐУ¬¶øÄ¿Ç°µÄ¶àÏ̻߳úÖÆÎÞ·¨ÌṩµØÖ·±£»¤¡£
    ·ÐźŴ¦ÀíÉϵÄÎÊÌâ¡£ÔÚ¶àÏ̳߳ÌÐòÖУ¬ËùÓеĶàÏ̹߳²Ïíͬһ¸öÐźŴ¦Àí·½Ê½£¬°üÀ¨ÊÇ·ñºöÂÔ¡¢ÊÇ·ñ²¶»ñµÈµÈ¡£Õâ¶ÔijЩ´óÐÍÈí¼þÊǺÜÄѽÓÊܵġ£
    ·¶àÏ̳߳ÌÐò¶Ô³ÌÐòÔ±ÒªÇó½Ï¸ß¡£ÔÚ±àд¶àÏ̳߳ÌÐòʱ£¬Í¨³£Òª¿¼Âǵ½º¯ÊýµÄ¡°Ḭ̈߳²È«¡±ÎÊÌ⣬¼´º¯ÊýÊÇ·ñÊÇ¿ÉÖØÈëµÄ£¬Òò´Ë£¬ÎÒÃÇͨ³£²»ÄÜʹÓÃÈ«¾Ö»òÕß¾²Ì¬±äÁ¿¡£

    ¼øÓÚÉÏÊöÐèÇó£¬ÎÒÃǽ«ÔÚ½ÓÏÂÀ´µÄ MiniGUI 2.0 ¿ª·¢ÖУ¬½øÐÐһЩÌåϵ½á¹¹Éϵĵ÷Õû£¬ÆäÖÐ×îΪÖØÒªµÄ¾ÍÊDzÉÓýø³Ì»úÖÆÌæ´úÏ̻߳úÖÆ¡£


[Ŀ¼]


¶à´°¿Ú¹ÜÀíºÍ¿Ø¼þ¼°¿Ø¼þÀà

    ±¾ÎÄÊÇ MiniGUI Ìåϵ½á¹¹ÏµÁÐÎÄÕµĵڶþƪ£¬Öصã½éÉÜ MiniGUI µÄ¶à´°¿Ú»úÖÆÒÔ¼°Ïà¹ØµÄ´°¿ÚÀ༼Êõ¡£ÆäÖÐÉæ¼°µ½´°¿Ú Z Ðò¡¢´°¿Ú¼ôÇС¢¿Ø¼þÀàºÍ¿Ø¼þÒÔ¼°ÊäÈ뷨ģ¿éÉè¼ÆµÈµÈ¡£


[Ŀ¼]


ÒýÑÔ

1 ÒýÑÔ

    ÔÚÈκÎÒ»¸ö×ã¹»¸´Ô GUI ϵͳÖУ¬´¦Àí´°¿ÚÖ®¼äµÄ»¥Ïà¼ôÇÐÊÇÆäÊ×Òª½â¾öµÄÎÊÌâ¡£ÒòΪ¶à´°¿ÚϵͳÊ×ÏÈҪȷ±£Ò»¸ö´°¿ÚÖеĻæÖÆÊä³ö²»»áÓ°Ïìµ½ÁíÍâÒ»¸ö´°¿Ú¡£Îª´Ë£¬GUI ϵͳһ°ãÒªÀûÓà Z ÐòÀ´¹ÜÀí´°¿ÚÖ®¼äµÄ»¥Ïà¼ôÇйØϵ¡£¸ù¾Ý´°¿ÚÔÚ Z ÐòÖÐËù´¦µÄλÖã¬GUI ϵͳҪ¼ÆËãÿ¸ö´°¿ÚÊܼôÇеÄÇøÓò£¬¼´¼ôÇÐÓò¡£Í¨³££¬´°¿ÚµÄ¼ôÇÐÓò¶¨ÒåΪ»¥²»ÏཻµÄ¾ØÐμ¯ºÏ¡£GUI ϵͳµÄµ×²ãͼÐÎÒýÇæÔÚ½øÐÐÊä³öʱ£¬Òª¸ù¾Ýµ±Ç°Êä³öµÄ¼ôÇÐÓò½øÐÐÊä³öµÄ¼ôÇвÙ×÷¡£´Ó¶ø±£Ö¤´°¿ÚµÄ»æÖÆÊä³ö²»»á»¥ÏàÓ°Ïì¡£ÒòΪÈκÎÒ»¸ö´°¿ÚµÄ´´½¨¡¢Ïú»Ù¡¢Òþ²Ø¡¢ÏÔʾ¾ùÓпÉÄÜÓ°ÏìÆäËû´°¿ÚµÄ¼ôÇÐÓò£¬ËùÒÔÊ×ÏÈÒªÓÐÒ»¸ö¸ßЧµÄ¼ôÇÐÓòά»¤Ëã·¨¡£±¾ÎĽ«ÏêϸÃèÊö MiniGUI ÖеļôÇÐÓòÉú³ÉËã·¨¡£

    Ðí¶àÈ˶Կؼþ£¨»òÕß²¿¼þ£©µÄ¸ÅÄîÒѾ­Ï൱ÊìϤÁË¡£¿Ø¼þ¿ÉÒÔÀí½âΪÖ÷´°¿ÚÖеÄ×Ó´°¿Ú¡£ÕâЩ×Ó´°¿ÚµÄÐÐΪºÍÖ÷´°¿ÚÒ»Ñù£¬¼´Äܹ»½ÓÊÕ¼üÅ̺ÍÊó±êµÈÍⲿÊäÈ룬Ҳ¿ÉÒÔÔÚ×Ô¼ºµÄÇøÓòÄÚ½øÐÐÊä³ö¨D¨DÖ»ÊÇËüÃǵÄËùÓл±»ÏÞÖÆÔÚÖ÷´°¿ÚÖС£MiniGUI Ò²Ö§³Ö×Ó´°¿Ú£¬²¢ÇÒ¿ÉÒÔÔÚ×Ó´°¿ÚÖÐǶÌ×½¨Á¢×Ó´°¿Ú¡£ÎÒÃǽ« MiniGUI ÖеÄËùÓÐ×Ó´°¿Ú¾ù³ÆΪ¿Ø¼þ¡£

    ÔÚ Windows »ò X Window ÖУ¬ÏµÍ³»áÔ¤Ïȶ¨ÒåһЩ¿Ø¼þÀ࣬µ±ÀûÓÃij¸ö¿Ø¼þÀà´´½¨¿Ø¼þÖ®ºó£¬ËùÓÐÊôÓÚÕâ¸ö¿Ø¼þÀàµÄ¿Ø¼þ¾ù»á¾ßÓÐÏàͬµÄÐÐΪºÍÏÔʾ¡£ÀûÓÃÕâЩ¼¼Êõ£¬¿ÉÒÔÈ·±£Ò»ÖµÄÈË»ú²Ù×÷½çÃ棬¶ø¶Ô³ÌÐòÔ±À´½²£¬¿ÉÒÔÏñ´î»ýľһÑùµØ×齨ͼÐÎÓû§½çÃæ¡£MiniGUI ʹÓÃÁ˿ؼþÀàºÍ¿Ø¼þµÄ¸ÅÄ²¢ÇÒ¿ÉÒÔ·½±ãµØ¶ÔÒÑÓпؼþ½øÐÐÖØÔØ£¬Ê¹µÃÆäÓÐһЩÌØÊâЧ¹û¡£±ÈÈ磬ÐèÒª½¨Á¢Ò»¸öÖ»ÔÊÐíÊäÈëÊý×ֵı༭¿òʱ£¬¾Í¿ÉÒÔͨ¹ýÖØÔØÒÑÓб༭¿ò¶øʵÏÖ£¬¶ø²»ÐèÒªÖØбàдһ¸öеĿؼþÀà¡£

    ÔÚ¶àÓïÖÖ»·¾³ÖУ¬ÊäÈë·¨ÊÇÒ»¸ö±Ø²»¿ÉÉÙµÄÄ£¿é¡£ÊäÈë·¨ÌṩÁ˽«±ê×¼¼üÅÌÊäÈë·­ÒëΪÊʵ±ÓïÖÖµÄÎÄ×ÖµÄÄÜÁ¦¡£MiniGUI ÖÐÒ²°üº¬Óбê×¼µÄÖÐÎļòÌåÊäÈë·¨£¬°üÀ¨È«Æ´¡¢Îå±ÊºÍÖÇÄÜÆ´ÒôµÈµÈ¡£±¾ÎÄ×îºó½«½éÉÜ MiniGUI ÖеÄÊäÈ뷨ģ¿éʵÏÖ¡£

[Ŀ¼]


´°¿ÚZÐò

2 ´°¿Ú Z Ðò

    Z Ðòʵ¼Ê¶¨ÒåÁË´°¿ÚÖ®¼äµÄ²ãµþ˳Ðò¡£ËµÆð¡°Z Ðò¡±Õâ¸öÃû³Æ£¬Êµ¼ÊÊÇÏà¶ÔÆÁÄ»×ø±ê¶øÑԵġ£Ò»°ã¶øÑÔ£¬ÆÁÄ»ÉϵÄËùÓд°¿Ú¾ùÓÐÒ»¸ö×ø±êϵ£¬¼´Ô­µãÔÚ×óÉϽǣ¬X ÖáˮƽÏòÓÒ£¬Y Öá´¹Ö±ÏòϵÄ×ø±êϵ¡£Z Ðò¾ÍÊÇÏà¶ÔÓÚÒ»¸ö¼ÙÏëµÄ Z Öá¶øÑԵģ¬Õâ¸ö Z Öá´ÓÆÁÄ»ÍâÖ¸ÏòÆÁÄ»ÄÚ¡£´°¿ÚÔÚÕâ¸ö Z ÖáÉϵÄÖµ£¬¾ÍÈ·¶¨ÁËÆä Z Ðò¡£Z ÐòÖµ´óµÄ´°¿Ú£¬¸²¸ÇÁË Z ÐòֵСµÄ´°¿Ú¡£

    µ±È»£¬ÔÚ³ÌÐòµ±ÖУ¬Z ÐòÒ»°ã±íʾΪһ¸öÁ´±í¡£Ô½½Ó½üÓÚÁ´±íÍ·µÄ½Úµã£¬Æä Z ÐòÖµ¾ÍÔ½´ó¡£ÔÚ MiniGUI ÖУ¬ÎÒÃÇά»¤ÁËÁ½¸ö Z Ðò¡£ÆäÖÐÒ»¸ö Z ÐòÓÀԶλÓÚÁíÒ»¸ö Z ÐòÖ®ÉÏ¡£ÕâÑù£¬¾Í¿ÉÒÔ´´½¨Ê¼ÖÕλÓÚÆäËû´°¿ÚÖ®ÉϵĴ°¿Ú£¬±ÈÈçÊäÈë·¨´°¿Ú¡£Èç¹ûÔÚ½¨Á¢´°¿Úʱ£¬Ö¸¶¨ÁË WS_EX_TOPMOST À©Õ¹ÊôÐÔ£¬¾Í¿ÉÒÔ´´½¨ÕâÑùµÄÖ÷´°¿Ú¡£ÒòΪ Z ÐòµÄ²Ù×÷ʵ¼Ê¾ÍÊÇÁ´±íµÄ²Ù×÷£¬ÕâÀï¾Í²»ÔÙ׸Êö¡£


[Ŀ¼]


´°¿Ú¼ôÇÐËã·¨

3 ´°¿Ú¼ôÇÐËã·¨

    ÓÐÁË´°¿Ú Z Ðò£¬ÎÒÃǾͿÉÒÔ¼ÆËãÿ¸ö´°¿ÚµÄ¼ôÇÐÓò¡£ÎÒÃÇ°ÑÒòΪ´°¿Ú Z Ðò¶ø²úÉúµÄ¼ôÇÐÓò³ÆΪ¡°È«¾Ö¼ôÇÐÓò¡±£¬ÕâÊÇÏà¶ÔÓÚ´°¿Ú×ÔÉí¶¨ÒåµÄ¼ôÇÐÓò¶øÑԵģ¬ÎÒÃǰѺóÕß³ÆΪ¡°¾Ö²¿¼ôÇÐÓò¡±¡£´°¿ÚÖеÄËùÓÐÊä³ö£¬Ê×ÏÈÒªÊܵ½È«¾Ö¼ôÇÐÓòµÄÓ°Ï죬Æä´ÎÊܵ½¾Ö²¿¼ôÇÐÓòµÄÓ°Ïì¡£ÎÒÃÇÔÚÕâÀïÖص㽲½â´°¿ÚµÄÈ«¾Ö¼ôÇÐÓòµÄÉú³ÉºÍά»¤¡£

3.1 È«¾Ö¼ôÇÐÓòµÄÉú³ÉºÍά»¤
    ÔÚ MiniGUI ÖУ¬¼ôÇÐÓò±íʾΪÈô¸É»¥²»ÏཻµÄ¾ØÐÎÖ®²¢¼¯£¬ÕâЩ¾ØÐγÆΪ¼ôÇоØÐΡ£×î³õ£¬ÆÁÄ»ÉÏûÓÐÈκδ°¿Úʱ£¬×ÀÃæµÄ¼ôÇÐÓòÓÉÒ»¸ö¾ØÐÎ×é³É£¬¼´ÆÁÄ»¾ØÐΣ»µ±ÆÁÄ»ÉÏÖ»ÓÐÒ»¸ö´°¿Úʱ£¬¸Ã´°¿ÚµÄ¼ôÇÐÓòÓÉÒ»¸ö¾ØÐÎ×é³É£¬¸Ã¾ØÐμ´Îª´°¿ÚÔÚÆÁÄ»ÉϵľØÐΣ¬¶ø×ÀÃæµÄ¼ôÇÐÓòÈ´¿ÉÄÜÊÇÓɶà¸ö¾ØÐÎ×é³ÉµÄ¡£

    ¶ÁÕߺÜÈÝÒ׿´³ö£¬ÔÚÖ»ÓÐÒ»¸ö´°¿ÚµÄÇé¿öÏ£¬ÐγÉ×ÀÃæ¼ôÇÐÓòµÄ¾ØÐÎ×î¶àÖ»ÄÜÓÐËĸö¡£

    ´Ëʱ£¬Èç¹ûÓÐÒ»¸öеĴ°¿Ú³öÏÖ£¬ÔòеĴ°¿Ú½«Í¬Ê±¼ôÇоɵĴ°¿ÚºÍ×ÀÃ棨ͼ 3¡£´°¿ÚµÄ¼ôÇоØÐÎÓÿÕÐľØÐαíʾ£¬¶ø×ÀÃæµÄ¼ôÇоØÐÎÓÃʵÐľØÐαíʾ£©¡£¶øÕâʱ£¬×ÀÃæºÍ¾É´°¿ÚµÄ¼ôÇÐÓò½«¶à³öһЩ¾ØÐΣ¬ÕâЩ¾ØÐÎÓ¦¸ÃÊÇÔ­ÓмôÇÐÓòÖеÄÿ¸ö¾ØÐÎÊܵ½Ð´°¿Ú¾ØÐÎÓ°ÏìÖ®ºóÉú³ÉµÄ¼ôÇоØÐΡ£Í¬Ñù£¬Ô­ÓмôÇÐÓòÖеÄÿ¸ö¾ØÐÎÖ»ÄÜ×î¶àÖ»ÄÜÅÉÉú³ö4¸öмôÇÐÓò£¬¶øijЩ¾ØÐθù±¾²»»áÊܵ½Ð´°¿Ú¾ØÐεÄÓ°Ïì¡£

    ÕâÑù£¬ÎÒÃÇ¿ÉÒÔ½«Ä³¸ö´°¿ÚÈ«¾Ö¼ôÇÐÓò¹éÄÉΪԭÓмôÇÐÓòÖÐÅųý£¨Exclude£©Ä³¸ö¾ØÐζøÉú³ÉµÄ£º

    ´°¿ÚµÄÈ«¾Ö¼ôÇÐÓò³õʼ»¯Îª´°¿Ú¾ØÐΡ£
    µ±´°¿ÚÖ®ÉÏÓÐÆäËû´°¿Ú¸²¸Çʱ£¬Ôò¸Ã´°¿ÚµÄÈ«¾Ö¼ôÇÐÓòΪÅųýд°¿Ú¾ØÐÎÖ®ºóµÄ¼ôÇÐÓò¡£
ÑØ Z Ðòµü´úµÚ 2 ²½£¬Ö±µ½×²ã´°¿Ú¡£
    Çåµ¥ 1 ÖеĴúÂëÊÇÔÚÏÔʾһ¸öд°¿Úʱ£¬MiniGUI ´¦Àí±»¸Ã´°¿ÚËù¸²¸ÇµÄÆäËûËùÓд°¿ÚµÄ´úÂë¡£Õâ¶Î´úÂëµ÷ÓÃÁ˼ôÇÐÓòά»¤½Ó¿ÚÖÐµÄ SubtractClipRect º¯Êý¼ÆËãеļôÇÐÓò¡£

Çåµ¥ 1  ÏÔʾд°¿Úʱ¼ÆË㱻д°¿Ú¸²¸ÇµÄ´°¿ÚµÄÈ«¾Ö¼ôÇÐÓò
// clip all windows under this window.
static void clip_windows_under_this (ZORDERINFO* zorder, PMAINWIN pWin, RECT* rcWin)
{
    PZORDERNODE pNode;
    PGCRINFO pGCRInfo;

    pNode = zorder->pTopMost;
    while (pNode->hWnd != (HWND)pWin)
        pNode = pNode->pNext;
    pNode = pNode->pNext;

    while (pNode)
    {
        if (((PMAINWIN)(pNode->hWnd))->dwStyle & WS_VISIBLE) {
            pGCRInfo = ((PMAINWIN)(pNode->hWnd))->pGCRInfo;

            pthread_mutex_lock (&pGCRInfo->lock);
            SubtractClipRect (&pGCRInfo->crgn, rcWin);
            pGCRInfo->age ++;
            pthread_mutex_unlock (&pGCRInfo->lock);
        }

        pNode = pNode->pNext;
    }
}

    ÓëÅųý¾ØÐÎÏà·´µÄ²Ù×÷ÊÇ°üº¬£¨Include£©Ä³¸ö¾ØÐε½¼ôÇÐÓòÖС£Õâ¸ö²Ù×÷ÓÃÓÚÒþ²Ø»òÕßÏú»Ùij¸ö´°¿Úʱ¡£µ±Ò»¸ö´°¿Ú±»Òþ²Ø»òÏú»Ùʱ£¬¸Ã´°¿Ú֮ϵÄËùÓд°¿Ú½«Êܵ½Ó°Ï죬´Ëʱ£¬Òª½«±»Òþ²Ø»òÏú»Ù´°¿ÚµÄ¾ØÐΰüº¬µ½ÕâЩÊÜÓ°Ïì´°¿ÚµÄÈ«¾Ö¼ôÇÐÓòÖС£Îª´Ë£¬MiniGUI µÄ¼ôÇÐÓòά»¤½Ó¿ÚÖÐÓÐÒ»¸öº¯ÊýרÓÃÓÚ¸ÃÀà²Ù×÷£¨IncludeClipRect£©¡£ÎªÈ·±£¼ôÇÐÓòÖоØÐλ¥²»Ïཻ£¬¸Ãº¯ÊýÊ×ÏȼÆËãÓëÿ¸ö¼ôÇоØÐεÄÏཻ¾ØÐΣ¬È»ºó½«×Ô¼ºÌí¼Óµ½¸Ã¼ôÇÐÓòÖС£

    µ«ÊÇ£¬ÔÚijЩÇé¿öÏ£¬ÎÒÃDZØÐëÖØмÆËãËùÓд°¿ÚµÄÈ«¾Ö¼ôÇÐÓò£¬±ÈÈçÔÚÒƶ¯Ä³¸ö´°¿Úʱ¡£

3.2 ¼ôÇоØÐεÄ˽ÓжÑ
    ÏÔÈ»£¬ÔÚ¼ôÇÐÓò·Ç³£¸´ÔÓ£¬»òÕß´°¿Ú·Ç³£¶àʱ£¬ÐèÒª´óÁ¿µÄ¾ØÐÎÀ´±íʾÿ¸ö´°¿ÚµÄÈ«¾Ö¼ôÇÐÓò¡£¶øÔÚ C ³ÌÐòÖУ¬Èç¹ûƵ·±Ê¹Óà malloc ºÍ free ÉêÇëºÍÊÍ·Åÿ¸ö¼ôÇоØÐΣ¬½«´øÀ´Ðí¶àÎÊÌâ¡£µÚÒ»£¬malloc ºÍ free ÊǷdz£ºÄʱµÄ²Ù×÷£»µÚ¶þ£¬Æµ·±µÄ malloc ºÍ free ½«µ¼Ö C ³ÌÐò¶ÑµÄËéƬ»¯£¬´Ó¶ø¿ÉÄܵ¼Ö½«À´µÄÄÚ´æ·ÖÅäʧ°Ü¡£ÎªÁ˱ÜÃâƵ·±Ê¹Óà malloc ºÍ free£¬MiniGUI ÔÚ³õʼ»¯Ê±£¬½¨Á¢ÁËÒ»¸ö˽ÓеĶѡ£ÎÒÃÇ¿ÉÒÔÖ±½Ó´ÓÕâ¸ö¶ÑÖзÖÅä¼ôÇоØÐΣ¬¶ø²»ÐèÒª´Ó½ø³ÌµÄÈ«¾Ö¶ÑÖзÖÅä¼ôÇоØÐΡ£Õâ¸ö˽ÓжÑʵ¼ÊÊÇÓÉһЩ¿ÕÏдýÓõļôÇоØÐÎ×é³ÉµÄ¡£Ã¿´Î·ÖÅäʱ·µ»Ø¸ÃÁ´±íµÄÍ·½Úµã£¬¶øÔÚÊÍ·Åʱ·Å½ø¸ÃÁ´±íµÄβ½Úµã¡£Èç¹û¸ÃÁ´±íΪ¿Õ£¬ÔòÀûÓà malloc ´Ó½ø³ÌµÄÈ«¾Ö¶ÑÖзÖÅä¼ôÇоØÐΡ£Çåµ¥ 2 ˵Ã÷ÁËÕâ¸ö˽Óжѵijõʼ»¯ºÍ²Ù×÷¡£

Çåµ¥ 2  ´Ó¼ôÇоØÐÎ˽ÓжÑÖзÖÅäºÍÊͷżôÇоØÐÎ
PCLIPRECT GUIAPI ClipRectAlloc(PFREECLIPRECTLIST pList)
{
    PCLIPRECT pRect;

#ifndef _LITE_VERSION
    pthread_mutex_lock (&pList->lock);
#endif

    if (pList->head) {
        pRect = pList->head;
        pList->head = pRect->next;
    }
    else {

        if (pList->free < pList->size) {
            pRect = pList->heap + pList->free;
            pRect->fromheap = TRUE;
            pList->free ++;
        }
        else {
            pRect = malloc (sizeof(CLIPRECT));
            if (pRect == NULL)
                fprintf (stderr, "GDI error: alloc clip rect failure!\n");
            else
                pRect->fromheap = FALSE;
        }
    }

#ifndef _LITE_VERSION
    pthread_mutex_unlock (&pList->lock);
#endif

    return pRect;
}

void GUIAPI FreeClipRect(PFREECLIPRECTLIST pList, CLIPRECT* pRect)
{
#ifndef _LITE_VERSION
    pthread_mutex_lock (&pList->lock);
#endif

    pRect->next = NULL;
    if (pList->head) {
        pList->tail->next = (PCLIPRECT)pRect;
        pList->tail = (PCLIPRECT)pRect;
    }
    else {
        pList->head = pList->tail = (PCLIPRECT)pRect;
    }

#ifndef _LITE_VERSION
    pthread_mutex_unlock (&pList->lock);
#endif
}


[Ŀ¼]


Ö÷´°¿ÚºÍ¿Ø¼þ¡¢¿Ø¼þÀà

4 Ö÷´°¿ÚºÍ¿Ø¼þ¡¢¿Ø¼þÀà

4.1 ¿Ø¼þÀàºÍ¿Ø¼þ
    Èç¹û¶ÁÕßÔø¾­±àд¹ý Windows Ó¦ÓóÌÐòµÄ»°£¬¾ÍÓ¦¸ÃÁ˽ⴰ¿ÚÀàµÄ¸ÅÄî¡£ÔÚ Windows ÖУ¬³ÌÐòËù½¨Á¢µÄÿ¸ö´°¿Ú£¬¶¼¶ÔÓ¦×ÅijÖÖ´°¿ÚÀà¡£ÕâÒ»¸ÅÄîºÍÃæÏò¶ÔÏó±à³ÌÖеÄÀà¡¢¶ÔÏóµÄ¹ØϵÀàËÆ¡£½èÓÃÃæÏò¶ÔÏóµÄÊõÓWindows ÖеÄÿ¸ö´°¿Úʵ¼Ê¶¼ÊÇij¸ö´°¿ÚÀàµÄÒ»¸öʵÀý¡£ÔÚ X Window ±à³ÌÖУ¬Ò²ÓÐÀàËƵĸÅÄ±ÈÈçÎÒÃǽ¨Á¢µÄÿһ¸ö Widget£¬Êµ¼Ê¶¼ÊÇij¸ö Widget ÀàµÄʵÀý¡£

    ÕâÑù£¬Èç¹û³ÌÐòÐèÒª½¨Á¢Ò»¸ö´°¿Ú£¬¾ÍÊ×ÏÈҪȷ±£Ñ¡ÔñÕýÈ·µÄ´°¿ÚÀ࣬ÒòΪÿ¸ö´°¿ÚÀà¾ö¶¨Á˶ÔÓ¦´°¿ÚʵÀýµÄ±íÏóºÍÐÐΪ¡£ÕâÀïµÄ±íÏóÖ¸´°¿ÚµÄÍâ¹Û£¬±ÈÈç´°¿Ú±ß¿ò¿í¶È£¬ÊÇ·ñÓбêÌâÀ¸µÈµÈ£¬ÐÐΪָ´°¿Ú¶ÔÓû§ÊäÈëµÄÏìÓ¦¡£Ã¿Ò»¸ö GUI ϵͳ¶¼»áÔ¤¶¨ÒåһЩ´°¿ÚÀ࣬³£¼ûµÄÓа´Å¥¡¢Áбí¿ò¡¢¹ö¶¯Ìõ¡¢±à¼­¿òµÈµÈ¡£Èç¹û³ÌÐòÒª½¨Á¢µÄ´°¿ÚºÜÌØÊ⣬¾ÍÐèÒªÊ×ÏÈ×¢²áÒ»¸ö´°¿ÚÀ࣬Ȼºó½¨Á¢Õâ¸ö´°¿ÚÀàÒ»¸öʵÀý¡£ÕâÑù¾Í´ó´óÌá¸ßÁË´úÂëµÄ¿ÉÖØÓÃÐÔ¡£

    ÔÚ MiniGUI ÖУ¬ÎÒÃÇÈÏΪÖ÷´°¿Úͨ³£ÊÇÒ»ÖֱȽÏÌØÊâµÄ´°¿Ú¡£ÒòΪÖ÷´°¿Ú´úÂëµÄ¿ÉÖØÓÃÐÔÒ»°ãºÜµÍ£¬Èç¹û°´ÕÕͨ³£µÄ·½Ê½ÎªÃ¿¸öÖ÷´°¿Ú×¢²áÒ»¸ö´°¿ÚÀàµÄ»°£¬Ôò»áµ¼Ö¶îÍâ²»±ØÒªµÄ´æ´¢¿Õ¼ä£¬ËùÒÔÎÒÃDz¢Ã»ÓÐÔÚÖ÷´°¿ÚÌṩ´°¿ÚÀàÖ§³Ö¡£µ«Ö÷´°¿ÚÖеÄËùÓÐ×Ó´°¿Ú£¬¼´¿Ø¼þ£¬¾ùÖ§³Ö´°¿ÚÀࣨ¿Ø¼þÀࣩµÄ¸ÅÄî¡£MiniGUI ÌṩÁ˳£ÓõÄÔ¤¶¨Òå¿Ø¼þÀ࣬°üÀ¨°´Å¥£¨°üÀ¨µ¥Ñ¡Å¥¡¢¸´Ñ¡Å¥£©¡¢¾²Ì¬¿ò¡¢Áбí¿ò¡¢½ø¶ÈÌõ¡¢»¬¿é¡¢±à¼­¿òµÈµÈ¡£³ÌÐòÒ²¿ÉÒÔ¶¨ÖÆ×Ô¼ºµÄ¿Ø¼þÀ࣬ע²áºóÔÙ´´½¨¶ÔÓ¦µÄʵÀý¡£Çåµ¥ 3 ÖеĴúÂë¾Í´´½¨ÁËÒ»¸ö±à¼­¿ò£¬Ò»¸ö°´Å¥¡£

    ²ÉÓÿؼþÀàºÍ¿Ø¼þʵÀýµÄ½á¹¹£¬²»½ö¿ÉÒÔÌá¸ß´úÂëµÄ¿ÉÖØÓÃÐÔ£¬¶øÇÒ»¹¿ÉÒÔ·½±ãµØ¶ÔÒÑÓпؼþÀà½øÐÐÀ©Õ¹¡£±ÈÈ磬ÔÚÐèÒª½¨Á¢Ò»¸öÖ»ÔÊÐíÊäÈëÊý×ֵı༭¿òʱ£¬¾Í¿ÉÒÔͨ¹ýÖØÔØÒÑÓб༭¿ò¿Ø¼þÀà¶øʵÏÖ£¬¶ø²»ÐèÒªÖØбàдһ¸öеĿؼþÀà¡£ÔÚ MiniGUI ÖУ¬ÕâÖÖ¼¼Êõ³ÆΪ×ÓÀ໯»òÕß´°¿ÚÅÉÉú¡£×ÓÀ໯µÄ·½·¨ÓÐÈýÖÖ£º

    ·Ò»ÖÖÊǶÔÒѾ­½¨Á¢µÄ¿Ø¼þʵÀý½øÐÐ×ÓÀ໯£¬×ÓÀ໯µÄ½á¹ûÊÇÖ»Ó°ÏìÕâÒ»¸ö¿Ø¼þʵÀý£»
    ·Ò»ÖÖÊǶÔij¸ö¿Ø¼þÀà½øÐÐ×ÓÀ໯£¬½«Ó°ÏìÆäºó´´½¨µÄËùÓиÿؼþÀàµÄ¿Ø¼þʵÀý£»
    ·×îºóÒ»ÖÖÊÇÔÚij¸ö¿Ø¼þÀàµÄ»ù´¡ÉÏÐÂ×¢²áÒ»¸ö×ÓÀ໯µÄ¿Ø¼þÀ࣬²»»áÓ°ÏìÔ­ÓпؼþÀà¡£ÔÚ Windows ÖУ¬ÕâÖÖ¼¼ÊõÓÖ³ÆΪ³¬À໯¡£

    ÔÚ MiniGUI ÖУ¬¿Ø¼þµÄ×ÓÀ໯ʵ¼ÊÊÇͨ¹ýÌæ»»ÒÑÓеĴ°¿Ú¹ý³ÌʵÏֵġ£Çåµ¥ 4 ÖеĴúÂë¾Íͨ¹ý¿Ø¼þÀà´´½¨ÁËÁ½¸ö×ÓÀ໯µÄ±à¼­¿ò£¬Ò»¸öÖ»ÄÜÊäÈëÊý×Ö£¬¶øÁíÒ»¸öÖ»ÄÜÊäÈë×Öĸ£º

Çåµ¥ 4  ¿Ø¼þµÄ×ÓÀ໯

#define IDC_CTRL1     100
#define IDC_CTRL2     110
#define IDC_CTRL3     120
#define IDC_CTRL4     130

#define MY_ES_DIGIT_ONLY    0x0001
#define MY_ES_ALPHA_ONLY    0x0002
static WNDPROC old_edit_proc;
static int RestrictedEditBox (HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
    if (message == MSG_CHAR) {
        DWORD my_style = GetWindowAdditionalData (hwnd);

        /* È·¶¨±»ÆÁ±ÎµÄ°´¼üÀàÐÍ */
        if ((my_style & MY_ES_DIGIT_ONLY) && (wParam < '0' || wParam > '9'))
            return 0;
        else if (my_style & MY_ES_ALPHA_ONLY)
            if (!((wParam >= 'A' && wParam <= 'Z') || (wParam >= 'a' && wParam <= 'z')))
                /* ÊÕµ½±»ÆÁ±ÎµÄ°´¼üÏûÏ¢£¬Ö±½Ó·µ»Ø */
                return 0;
    }

    /* ÓÉÀϵĴ°¿Ú¹ý³Ì´¦ÀíÆäÓàÏûÏ¢ */
    return (*old_edit_proc) (hwnd, message, wParam, lParam);
}

static int ControlTestWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
    case MSG_CREATE:
    {
        HWND hWnd1, hWnd2, hWnd3;

        CreateWindow (CTRL_STATIC, "Digit-only box:", WS_CHILD | WS_VISIBLE | SS_RIGHT, 0,
                    10, 10, 180, 24, hWnd, 0);
        hWnd1 = CreateWindow (CTRL_EDIT, "", WS_CHILD | WS_VISIBLE | WS_BORDER, IDC_CTRL1,
                    200, 10, 180, 24, hWnd, MY_ES_DIGIT_ONLY);
        CreateWindow (CTRL_STATIC, "Alpha-only box:", WS_CHILD | WS_VISIBLE | SS_RIGHT, 0,
                    10, 40, 180, 24, hWnd, 0);
        hWnd2 = CreateWindow (CTRL_EDIT, "", WS_CHILD | WS_BORDER | WS_VISIBLE, IDC_CTRL2,
                    200, 40, 180, 24, hWnd, MY_ES_ALPHA_ONLY);
        CreateWindow (CTRL_STATIC, "Normal edit box:", WS_CHILD | WS_VISIBLE | SS_RIGHT, 0,
                    10, 70, 180, 24, hWnd, 0);
        hWnd3 = CreateWindow (CTRL_EDIT, "", WS_CHILD | WS_BORDER | WS_VISIBLE, IDC_CTRL2,
                    200, 70, 180, 24, hWnd, MY_ES_ALPHA_ONLY);

        CreateWindow ("button", "Close", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, IDC_CTRL4,
                    100, 100, 60, 24, hWnd, 0);

        /* ÓÃ×Ô¶¨ÒåµÄ´°¿Ú¹ý³ÌÌæ»»±à¼­¿òµÄ´°¿Ú¹ý³Ì£¬²¢±£´æÀϵĴ°¿Ú¹ý³Ì¡£*/
        old_edit_proc = SetWindowCallbackProc (hWnd1, RestrictedEditBox);
        SetWindowCallbackProc (hWnd2, RestrictedEditBox);
        break;
    }

    ...
    }

    return DefaultMainWinProc (hWnd, message, wParam, lParam);
}

    ÔÚÇåµ¥ 4 ÖУ¬³ÌÐòÊ×Ïȶ¨ÒåÁËÒ»¸ö´°¿Ú´¦Àí¹ý³Ì£¬¼´ RestrictedEditBox º¯Êý¡£È»ºó£¬ÔÚÀûÓà CreateWindow º¯Êý½¨Á¢¿Ø¼þʱ£¬½«ÆäÖÐÁ½¸ö±à¼­¿òµÄ´°¿Ú´¦Àí¹ý³Ìͨ¹ý SetWindowCallbackProc Ìæ»»³ÉÁË×Ô¼º¶¨ÒåµÄ RestrictedEditBox º¯Êý£¬²¢ÇÒ½«¸Ãº¯Êý·µ»ØµÄÖµ£¨¼´ÀϵĿؼþ´°¿Ú´¦Àí¹ý³ÌµØÖ·£©±£´æÔÚÁË old_edit_box ±äÁ¿ÖС£ÔÚ½¨Á¢ÕâЩ±à¼­¿òÖ®ºó£¬ËüÃǵÄÏûÏ¢½«Ê×ÏÈÓÉ RestrictedEditBox º¯Êý´¦Àí£¬È»ºóÔÚijЩÇé¿öϲÅÓÉÀϵĴ°¿Ú´¦Àí¹ý³Ì´¦Àí¡£

    ÏÞÓÚƪ·ù£¬ÁíÍâÁ½Öֿؼþ×ÓÀ໯µÄ·½·¨¾Í²»ÔÚÕâÀï½²Êö¡£

4.2 MiniGUI ÖпؼþÀàµÄʵÏÖ
    MiniGUI º¯Êý¿âʵ¼Êά»¤ÁËÒ»¸öµ±Ç°ËùÓпؼþÀàµÄÊý¾Ý½á¹¹£¬ÆäÖаüº¬Á˿ؼþÀàÃû³ÆÒÔ¼°¶ÔÓ¦µÄ¿Ø¼þÀàÐÅÏ¢¡£¸ÃÊý¾Ý½á¹¹Êµ¼ÊÊÇÒ»¸ö¹þÏ£±í£¬¹þÏ£±íµÄÿ¸öÈë¿Ú°üº¬ÓÉÒ»¸öÖ¸Õ룬¸ÃÖ¸ÕëÖ¸ÏòËùÓÐÃû³ÌÒÔij¸ö×Öĸ¿ªÍ·£¨²»·Ö´óСд£©µÄ¿Ø¼þÀàÐÅÏ¢Á´±í¡£¿Ø¼þÀàÐÅÏ¢½á¹¹¶¨ÒåÈçÏ£º

#define MAXLEN_CLASSNAME    15
typedef struct _CTRLCLASSINFO
{
    char      name [MAXLEN_CLASSNAME + 1];
                                // ¿Ø¼þÀàÃû³Ì
    /*
     * common properties of this class
     */
    DWORD     dwStyle;          // ¿Ø¼þÀà·ç¸ñ

    HCURSOR   hCursor;          // ¿Ø¼þ¹â±ê
    int       iBkColor;         // ¿Ø¼þµÄ±³¾°ÑÕÉ«

    int (*ControlProc)(HWND, int, WPARAM, LPARAM);
                                // ¿Ø¼þ´¦Àí¹ý³Ì

    DWORD dwAddData;            // ¸½¼ÓÊý¾Ý

    int nUseCount;              // ʹÓüÆÊý£¬¼´ÏµÍ³ÖÐÊôÓڸÿؼþÀàµÄ¿Ø¼þ¸öÊý
    struct _CTRLCLASSINFO*  next;
                                // ÏÂÒ»¸ö¿Ø¼þÀàÐÅÏ¢½á¹¹
} CTRLCLASSINFO;
typedef CTRLCLASSINFO* PCTRLCLASSINFO;

    ÔڿؼþÀàµÄÊý¾Ý½á¹¹Öаüº¬ÁËÊó±ê¡¢¹â±ê¡¢¿Ø¼þÀàµÄ»Øµ÷º¯ÊýµØÖ·µÈµÈÐÅÏ¢¡£ÔÚ´´½¨ÊôÓڸÿؼþÀàµÄ¿Ø¼þʱ£¬ÕâЩÐÅÏ¢»á¸´ÖƵ½¿Ø¼þÊý¾Ý½á¹¹ÖС£ÕâÑù£¬ÐµĿؼþʵÀý¾Í¼Ì³ÐÁËÕâÖֿؼþÀàµÄ±íÏóºÍÐÐΪ¡£

    ¸Ã¹þÏ£±íµÄ¹þÏ£º¯Êýʵ¼Ê·Ç³£¼òµ¥£¬ËüµÄ·µ»ØÖµ¾ÍÊǿؼþÀàÃû³ÆÊ××ÖĸµÄÓ¢ÎÄ×Öĸ±í˳ÐòÖµ£º

static int HashFunc (char* szClassname)
{
    /* ÅжÏÊ××Ö·ûÊÇ·ñΪ×Öĸ */
    if (!isalpha (szClassName[0])) return ERR_CTRLCLASS_INVNAME;

    /* ½²ËùÓÐ×Ö·ûת»»Îª´óд */
    while (szClassName[i]) {
        szClassName[i] = toupper(szClassName[i]);

        i++;
        if (i > MAXLEN_CLASSNAME)
            return ERR_CTRLCLASS_INVLEN;
    }

    /* »ñµÃ¹þÏ£Öµ */
    return szClassName[0] - 'A';
}

    ¿Ø¼þÀàµÄ×¢²áºÍ×¢Ïúº¯Êý·Ç³£¼òµ¥£¬ÕâÀï²»ÔÙ׸Êö¡£

4.3 MiniGUI ÖпؼþµÄʵÏÖ
    ¿Ø¼þ½á¹¹Ïà¶Ô¸´ÔÓһЩ¡£ÆäÖаüº¬Á˿ؼþÔÚ¸¸´°¿ÚÖеÄλÖÃÐÅÏ¢¡¢¿Ø¼þ·ç¸ñ¡¢À©Õ¹·ç¸ñ¡¢¿Ø¼þÊó±ê¡¢Í¼±ê¡¢¿Ø¼þ»Øµ÷º¯ÊýµØÖ·µÈµÈ£º

typedef struct _CONTROL
{
    /*
     * ÕâЩ³ÉÔ±ºÍ MAINWIN ½á¹¹Ò»ÖÂ.
     */
    short DataType;         // ÄÚ²¿Ê¹ÓõÄÊý¾ÝÀàÐÍ
    short WinType;          // ÄÚ²¿Ê¹ÓõĴ°¿ÚÀàÐÍ

    int left, top;          // ¿Ø¼þÔÚ¸¸´°¿ÚÖеÄλÖÃ
    int right, bottom;

    int cl, ct;             // ¿Ø¼þ¿Í»§ÇøÔÚ¸¸´°¿ÚÖеÄλÖÃ
    int cr, cb;

    DWORD dwStyle;          // ¿Ø¼þ·ç¸ñ
    DWORD dwExStyle;        // ¿Ø¼þÀ©Õ¹·ç¸ñ

    int iBkColor;           // ±³¾°ÑÕÉ«
    HMENU hMenu;            // ²Ëµ¥¾ä±ú
    HACCEL hAccel;          // ¼ÓËÙ¼ü±í¾ä±ú
    HCURSOR hCursor;        // Êó±ê¹â±ê¾ä±ú
    HICON hIcon;            // ͼ±ê¾ä±ú
    HMENU hSysMenu;         // ϵͳ²Ëµ¥¾ä±ú

    HDC   privCDC;          // ˽ÓÐ DC ¾ä±ú
    INVRGN InvRgn;          // ¿Ø¼þµÄÎÞЧÇøÓò
    PGCRINFO pGCRInfo;      // ¿Ø¼þµÄÈ«¾Ö¼ôÇÐÇøÓò
    PZORDERNODE pZOrderNode;
                            // Z Ðò½Úµã
                            // ½ö¶Ô¾ßÓÐ WS_EX_CTRLASMAINWIN À©Õ¹·ç¸ñµÄ¿Ø¼þÓÐЧ

    PCARETINFO pCaretInfo;  // ²åÈë·ûÏûÏ¢

    DWORD dwAddData;        // ¿Ø¼þ¸½¼ÓÊý¾Ý
    DWORD dwAddData2;       // ¿Ø¼þ¸½¼ÓÊý¾Ý

    int (*ControlProc) (HWND, int, WPARAM, LPARAM); // ¿Ø¼þÏûÏ¢´¦Àí¹ý³Ì

    char* spCaption;         // ¿Ø¼þ±êÌâ
    int   id;                // ¿Ø¼þ±êʶ·û£¬ÕûÊý

    SCROLLBARINFO vscroll;   // ´¹Ö±¹ö¶¯ÌõÐÅÏ¢
    SCROLLBARINFO hscroll;   // ˮƽ¹ö¶¯ÌõÐÅÏ¢

    PMAINWIN pMainWin;       // °üº¬¸Ã¿Ø¼þµÄÖ÷´°¿Ú

    struct _CONTROL* pParent;// ¿Ø¼þµÄ¸¸´°¿Ú

    /*
     * Child windows.
     */
    struct _CONTROL* children;
                             // ¿Ø¼þµÄµÚÒ»¸ö×ӿؼþ
    struct _CONTROL* active;
                             // µ±Ç°»î¶¯×ӿؼþ
    struct _CONTROL* old_under_pointer;
                             // ÀϵÄÊó±êÊó±êËùÔÚ×ӿؼþ
    /*
     * ÏÂÃæÕâЩ³ÉÔ±Ö»¶Ô¿Ø¼þÓÐЧ
     */
    struct _CONTROL* next;   // ÏÂÒ»¸öÐֵܿؼþ
    struct _CONTROL* prev;   // Ç°Ò»¸öÐֵܿؼþ

    PCTRLCLASSINFO pcci;     // Ö¸Ïò¿Ø¼þËùÊô¿Ø¼þÀà½á¹¹µÄÖ¸Õë

} CONTROL;
typedef CONTROL* PCONTROL;

    ºÜÏÔÈ»£¬Ö»Òª½«¿Ø¼þµÄ»Øµ÷º¯ÊýµØÖ·½øÐÐÌæ»»£¬¾Í¿ÉÒԷdz£·½±ãµØ¶Ô¿Ø¼þ½øÐÐ×ÓÀ໯²Ù×÷¡£ÖµµÃÒ»ÌáµÄÊÇ£¬Ö÷´°¿ÚµÄ½á¹¹¶¨ÒåºÍ¿Ø¼þÊý¾Ý½á¹¹¶¨Òå»ù±¾ÉÏÊÇÏàͬµÄ£¬Ö»ÊÇÔÚijЩ³ÉÔ±ÉÏÓÐһЩССµÄ²î±ð¡£


[Ŀ¼]


ÊäÈ뷨ģ¿éµÄÉè¼Æ

5 ÊäÈ뷨ģ¿éµÄÉè¼Æ

    ÊäÈë·¨ÌṩÁ˽«±ê×¼¼üÅÌÊäÈë·­ÒëΪÊʵ±ÓïÖÖµÄÎÄ×ÖµÄÄÜÁ¦¡£MiniGUI ÖÐÒ²°üº¬Óбê×¼µÄÖÐÎļòÌåÊäÈë·¨£¬°üÀ¨È«Æ´¡¢Îå±ÊºÍÖÇÄÜÆ´ÒôµÈµÈ¡£MiniGUI µÄÊäÈë·¨ÊÇÒ»¸öÏà¶Ô¶ÀÁ¢µÄÄ£¿é£¨³ÆΪ IME£©£¬Ëüʵ¼ÊÊÇÒ»¸öÌØÊâµÄÖ÷´°¿Ú¡£¸ÃÖ÷´°¿Ú½«ÔÚÆô¶¯Ö®ºó£¬Ê×ÏȽ«×Ô¼º×¢²áΪÊäÈë·¨´°¿Ú¡£ÕâÑù£¬MiniGUI µÄ desktop ¾ÍÖªµÀÊ×ÏÈÒª½«°´¼üÐÅÏ¢·¢Ë͵½Õâ¸öÖ÷´°¿ÚÖ®ÖУ¬¶ø²»Êǵ±Ç°µÄ»î¶¯Ö÷´°¿Ú¡£µ±»î¶¯Ö÷´°¿Ú·¢Éú±ä»¯Ê±£¬desktop »á֪ͨÊäÈë·¨´°¿Úµ±Ç°µÄ»î¶¯´°¿Ú¡£ÕâÑù£¬µ±ÊäÈë·¨´°¿Ú½ÓÊÕµ½°´¼üÏûÏ¢²¢ÇÒ·­ÒëΪÊʵ±µÄ×Ö·ûÖ®ºó£¬¾Í¿ÉÒÔ½«Æä·¢Ë͵½µ±Ç°µÄ»î¶¯´°¿Ú¡£

    ΪÁËʵÏÖ desktop ºÍ IME ´°¿ÚÖ®¼äµÄ½»»¥£¬MiniGUI ΪÊäÈë·¨´°¿Ú¶¨ÒåÁËÈçÏÂÏûÏ¢£¬µ±»î¶¯´°¿Ú·¢Éú±ä»¯Ê±£¬MiniGUI »áÏò IME ´°¿Ú·¢ËÍÕâЩÏûÏ¢£º

    ·MSG_IME_SETTARGET£º·¢Ë͸ÃÏûÏ¢ÉèÖÃÊäÈë·¨µÄÄ¿±ê»î¶¯´°¿Ú£»
    ·MSG_IME_OPEN£º·¢Ë͸ÃÏûÏ¢¸æËßÊäÈë·¨´°¿Ú£¬µ±Ç°»î¶¯´°¿ÚÊǾßÓÐ WS_EX_IMECOMPOSE À©Õ¹·ç¸ñµÄ´°¿Ú£¬ËùÒÔÓ¦¸ÃÏÔʾÊäÈë·¨´°¿Ú¡£
    ·MSG_IME_CLOSE£º·¢Ë͸ÃÏûÏ¢¸æËßÊäÈë·¨´°¿Ú£¬µ±Ç°»î¶¯´°¿Ú²»¾ßÓÐ WS_EX_IMECOMPOSE À©Õ¹·ç¸ñ£¬ËùÒÔÓ¦¸ÃÒþ²ØÊäÈë·¨´°¿Ú¡£

    Èç¹ûÒ»¸ö´°¿ÚÒª³ÉΪÊäÈë·¨´°¿Ú£¬Ôò±ØÐëÍê³ÉÈçϹ¤×÷£º

    ·×¢²á³ÉΪµ±Ç°ÊäÈë·¨£»
    ·´¦Àí MSG_IME_SETTARGE ÏûÏ¢£¬²¢¼Ç¼µ±Ç°»î¶¯Ä¿±ê´°¿Ú£»
    ··­Òë°´¼ü²¢½«·­ÒëºóµÄ½á¹¹Í¨¹ý MSG_CHAR ÏûÏ¢·¢Ë͵½µ±Ç°»î¶¯µÄÄ¿±ê´°¿Ú£»
    ·´¦Àí MSG_IME_OPEN ºÍ MSG_IME_CLOSE ÏûÏ¢£¬ÔÚÇл»µ½ÐèÒªÊäÈë·¨µÄ»î¶¯´°¿Úʱ×Ô¶¯ÏÔʾÊäÈë·¨´°¿Ú¡£

[Ŀ¼]


С½á

6 С½á

    ±¾ÎÄÖص㽲ÊöÁË MiniGUI ÖеĴ°¿Ú¼ôÇд¦ÀíËã·¨¡£ÕâÊÇÈκÎÒ»¸ö¶à´°¿ÚϵͳÊ×ÏÈÒª½â¾öµÄÎÊÌ⡣Ȼºó£¬±¾ÎĽéÉÜÁË MiniGUI ÖпؼþÀàºÍ¿Ø¼þµÄʵÏÖ¡£×îºó½éÉÜÁË MiniGUI ÖÐÊäÈë·¨´°¿ÚµÄÉè¼Æ˼·¡£

¸½£ºMiniGUI µÄ×îнøÕ¹

    2001 ÄêÔªÔ 03 ÈÕ£¬MiniGUI µÄ 0.9.98 °æ±¾·¢²¼¡£¸Ã°æ±¾°üÀ¨Ò»¸öÎÒÃÇרÃÅÕë¶Ô PDA µÈǶÈëʽϵͳÉè¼ÆµÄ MiniGUI °æ±¾£¬¸Ã°æ±¾³ÆΪ MiniGUI-Lite¡£ÏÂÃæÊÇ¶Ô MiniGUI-Lite ¼òµ¥½éÉÜ£¬½«À´ÎÒÃÇ»¹Òª×«ÎÄÏêϸ½éÉÜ MiniGUI-Lite¡£

    ´ó¼Ò¶¼ÖªµÀ£¬MiniGUI ²ÉÓÃÁË»ùÓÚÏ̵߳ÄÌåϵ½á¹¹£¬²¢ÇÒ½¨Á¢ÁË»ùÓÚÏ̵߳ÄÏûÏ¢´«µÝºÍ´°¿Ú¹ÜÀí¹¦ÄÜ¡£µ«ÊÇ£¬ÔÚÐí¶àϵͳÖУ¬ÕâÖÖ»ùÓÚÏ̵߳Ľṹ²¢²»ÊǺܺá£ÕâÊÇÒòΪһЩÖÚËùÖÜÖªµÄÔ­ÒòÔì³ÉµÄ£­£­Linux Ị̈߳¬¾¡¹Ü¿ÉÒÔÌṩ×î´ó³Ì¶ÈÉϵÄÊý¾Ý¹²Ïí£¬µ«È´Ôì³ÉÁËϵͳÌåϵ½á¹¹µÄ´àÈõ¡£Èç¹ûij¸öÏß³ÌÒòΪ·Ç·¨µÄÊý¾Ý·ÃÎʶøÖÕÖ¹ÔËÐУ¬ÔòÕû¸ö½ø³Ì¶¼½«Êܵ½Ó°Ïì¡£ÓëÏ߳̽ṹÏà·´µÄÊDzÉÓô«Í³µÄ UNIX IPC »úÖƽ¨Á¢´°¿Úϵͳ£¬¼´ÀàËÆ X Window µÄ¿Í»§/·þÎñÆ÷Ìåϵ¡£ÕâÖÖÌåϵ½á¹¹ÓÐËüµÄÏÈÌì²»×㣬Ö÷ÒªÊÇͨ³£µÄ IPC »úÖÆÎÞ·¨Ìṩ¸ßЧµÄÊý¾Ý¸´ÖÆ£¬´óÁ¿µÄ CPU ×ÊÔ´ÓÃÓÚÔÚ¸÷½ø³ÌÖ®¼ä¸´ÖÆÊý¾Ý¡£ÔÚ PDA µÈÉ豸ÖУ¬ÕâÖÖ CPU ×ÊÔ´µÄÀ˷ѽ«×îÖÕµ¼ÖÂϵͳÐÔÄܵĽµµÍÒÔ¼°É豸ºÄµçÁ¿µÄÔö¼Ó¡£

    ΪÁ˽â¾ö MiniGUI °æ±¾ÒòΪÏ̶߳øÒýÈëµÄһЩÎÊÌ⣬ͬʱҲΪÁËÈà MiniGUI¸ü¼ÓÊʺÏÓÚǶÈëʽϵͳ£¬ÎÒÃǾö¶¨¿ª·¢Ò»¸ö MiniGUI Lite °æ±¾¡£Õâ¸ö°æ±¾µÄ¿ª·¢Ä¿µÄÊÇ£º

    1. ±£³ÖÓëÔ­ÏÈ MiniGUI °æ±¾ÔÚÔ´´úÂ뼶 98% ÒÔÉϵļæÈÝ¡£ 2. ²»ÔÙʹÓà LinuxThreads¡£ 3. ¿ÉÒÔͬʱÔËÐжà¸ö»ùÓÚ MiniGUI Lite µÄÓ¦ÓóÌÐò£¬¼´¶à¸ö½ø³Ì£¬²¢ÇÒÌṩǰºǫ́½ø³ÌµÄÇл»¡£
ÏÔÈ»£¬ÒªÍ¬Ê±Âú×ãÉÏÊöÈý¸öÄ¿µÄ£¬Èç¹û²ÉÓô«Í³µÄ C/S ½á¹¹¶ÔÏÖÓÐ MiniGUI ½øÐиÄÔ죬Ӧ¸Ã²»ÄÑʵÏÖ¡£µ«Ç°ÃæÌáµ½µÄ´«Í³ C/S ½á¹¹µÄȱÏÝÈ´ÎÞ·¨±ÜÃâ¡£¾­¹ý¶Ô PDA µÈǶÈëʽϵͳµÄ·ÖÎö£¬ÎÒÃÇ·¢ÏÖ£¬Ä³Ð© PDA ²úÆ·¾ßÓÐÔËÐжà¸öÈÎÎñµÄÄÜÁ¦£¬µ«Í¬Ò»Ê±¿ÌÔÚÆÁÄ»ÉϽøÐлæÖƵijÌÐò£¬Ò»°ã²»»á³¬¹ýÁ½¸ö¡£Òò´Ë£¬Ö»ÒªÈ·±£½«ÕâÁ½¸ö½ø³ÌµÄ»æÖÆÏ໥¸ôÀ룬¾Í²»ÐèÒª²ÉÓø´Ô C/S ½á¹¹´¦Àí¶à¸ö½ø³Ì´°¿ÚÖ®¼äµÄ»¥Ïà¼ôÇС£Ò²¾ÍÊÇ˵£¬ÔÚÕâÖÖ²úÆ·ÖУ¬Èç¹û²ÉÓûùÓÚ´«Í³ C/S ½á¹¹µÄ¶à´°¿Úϵͳ£¬Êµ¼ÊÊÇÒ»ÖÖÀË·Ñ¡£

    ÓÐÁËÉÏÊöÈÏʶ£¬ÎÒÃÇ¶Ô MiniGUI-Lite °æ±¾½øÐÐÁËÈçϼò»¯Éè¼Æ£º

    1. ÿ¸ö½ø³Ìά»¤×Ô¼ºµÄÖ÷´°¿Ú Z Ðò£¬Í¬Ò»½ø³Ì´´½¨µÄÖ÷´°¿ÚÖ®¼ä»¥Ïà¼ôÇС£Ò²¾ÍÊÇ˵£¬³ýÕâ¸ö½ø³ÌÖ»ÓÐÒ»¸öỊ̈߳¬Ö»ÓÐÒ»¸öÏûϢѭ»·Ö®Í⣬ËüÓëÔ­ÓÐµÄ MiniGUI °æ±¾Ö®¼äûÓÐÈκÎÇø±ð¡£Ã¿¸ö½ø³ÌÔÚ½øÐÐÆÁÄ»»æÖÆʱ£¬²»ÐèÒª¿¼ÂÇÆäËû½ø³Ì¡£ 2. ½¨Á¢Ò»¸ö¼òµ¥µÄ¿Í»§/·þÎñÆ÷Ìåϵ£¬µ«È·±£×îС»¯½ø³Ì¼äµÄÊý¾Ý¸´Öƹ¦ÄÜ¡£Òò´Ë£¬ÔÚ·þÎñÆ÷ºÍ¿Í»§Ö®¼ä´«µÝµÄÊý¾Ý½öÏÞÓÚÊäÈëÉ豸µÄÊäÈëÊý¾Ý£¬ÒÔ¼°¿Í»§ºÍ·þÎñÆ÷Ö®¼äµÄijЩÇëÇóºÍÏìÓ¦Êý¾Ý¡£ 3. ÓÐÒ»¸ö·þÎñÆ÷½ø³Ì£¨mginit£©£¬Ëü¸ºÔð³õʼ»¯Ò»Ð©ÊäÈëÉ豸£¬²¢ÇÒͨ¹ý UNIX Domain Ì×½Ó×Ö½«ÊäÈëÉ豸µÄÏûÏ¢·¢Ë͵½Ç°Ì¨µÄ MiniGUI Lite ¿Í»§½ø³Ì¡£ 4. ·þÎñÆ÷ºÍ¿Í»§±»·Ö±ðÏÞ¶¨ÔÚÆÁÄ»µÄijÁ½¸ö²»Ïཻ¾ØÐÎÄÚ½øÐлæÖÆ£¬Í¬Ò»Ê±¿Ì£¬Ö»ÄÜÓÐÒ»¸ö¿Í»§¼°·þÎñÆ÷½øÐÐÆÁÄ»»æÖÆ¡£ÆäËû¿Í»§¿É¼ÌÐøÔËÐУ¬µ«ÆÁÄ»ÊäÈë±»ÆÁ±Î¡£·þÎñÆ÷¿ÉÒÔÀûÓà API ½Ó¿Ú½«Ä³¸ö¿Í»§Çл»µ½Ç°Ì¨¡£Í¬Ê±£¬·þÎñÆ÷ºÍ¿Í»§Ö®¼ä²ÉÓÃÐÅºÅºÍ System V ÐźÅÁ¿½øÐÐͬ²½¡£ 5. ·þÎñÆ÷»¹²ÉÓà System V IPC »úÖÆÌṩһЩ×ÊÔ´µÄ¹²Ïí£¬°üÀ¨Î»Í¼¡¢Í¼±ê¡¢Êó±ê¡¢×ÖÌåµÈµÈ£¬ÒÔ±ã¼õÉÙʵ¼ÊÄÚ´æµÄÏûºÄ¡£
ÏÖÔÚÄã¿ÉÒÔʹÓà MiniGUI-Lite Ò»´ÎÔËÐв»Ö¹Ò»¸ö MiniGUI Ó¦ÓóÌÐò¡£ÎÒÃÇ¿ÉÒÔ´ÓÒ»¸ö³ÆΪ ¡°mginit¡± µÄ³ÌÐòÖÐÆô¶¯ÆäËû MiniGUI ³ÌÐò¡£Èç¹ûÒòΪijÖÖÔ­Òò¿Í»§ÖÕÖ¹£¬·þÎñÆ÷¿ÉÒÔ¼ÌÐøÔËÐС£ÔÚÎÒÃǵķ¢²¼°æ±¾ÖУ¬ÓÐÒ»¸ö³ÆΪ mglite-exec µÄÈí¼þ°ü, Õâ¸öÈí¼þ°üÀïÓÐÒ»¸ö mginit ³ÌÐò, ¸Ã³ÌÐò½¨Á¢ÁËÒ»¸öÐéÄâ¿ØÖÆ̨´°¿Ú¡£ÎÒÃÇ¿ÉÒÔ´ÓÕâ¸öÐéÄâ¿ØÖÆ̨µÄÃüÁîÐÐÆô¶¯¸ÃÈí¼þ°üÖÐÆäËûµÄ³ÌÐò£¬ÉõÖÁ¿ÉÒÔͨ¹ý gdb µ÷ÊÔÕâЩ³ÌÐò¡£

    ÎÒÃÇ¿ÉÒÔÔÚ MiniGUI-Lite ³ÌÐòÖд´½¨¶à¸ö´°¿Ú£¬µ«²»ÄÜÆô¶¯ÐµÄÏ߳̽¨Á¢´°¿Ú¡£ÕâÊÇ MiniGUI-Lite Çø±ðÓÚ MiniGUI Ô­Óа汾µÄ×î´ó²»Í¬¡£³ý´ËÖ®Í⣬ÆäËû¼¸ºõËùÓÐµÄ API ¶¼ºÍ MiniGUI Ô­Óа汾ÊǼæÈݵġ£Òò´Ë¡£´Ó MiniGUI Ô­Óа汾Ïò MiniGUI-Lite °æ±¾µÄÒÆÖ²ÊǷdz£¼òµ¥µÄ¡£²»ÐÅ£¬Çë¿´ mglite-exec °üÖеijÌÐò£¬ÆäÖÐËùÓеijÌÐò¾ùÀ´×Ô miniguiexec °ü£¬¶øÿ¸öÔ´ÎļþµÄ¸Ä¶¯²»³¬¹ý 5 ÐС£

[Ŀ¼]


Âß¼­×ÖÌåÒÔ¼°¶à×ÖÌåºÍ¶à×Ö·û¼¯ÊµÏÖ

    ±¾ÎÄÊÇ MiniGUI Ìåϵ½á¹¹ÏµÁÐÎÄÕµĵÚÈýƪ£¬Öصã½éÉÜ MiniGUI µÄÂß¼­×ÖÌåÖ§³Ö£¬Ö÷ÒªÄÚÈÝÉæ¼° MiniGUI ÖÐÒÔÃæÏò¶ÔÏó¼¼ÊõΪ»ù´¡¹¹½¨µÄ¶à×ÖÌåºÍ¶à×Ö·û¼¯Ö§³Ö£¬²¢¾ÙÀý˵Ã÷ÁËÈçºÎÔÚ MiniGUI ÖÐʵÏÖ¶ÔÐÂ×Ö·û¼¯ºÍÐÂ×ÖÌåµÄÖ§³Ö¡£
[Ŀ¼]


ÒýÑÔ

1 ÒýÑÔ

    ÎÒÃÇÔÚ½éÉÜ MiniGUI Ìåϵ½á¹¹µÄµÚһƪÎÄÕÂÖÐÌáµ½£¬MiniGUI ²ÉÓÃÁËÃæÏò¶ÔÏóµÄ¼¼ÊõʵÏÖÁË GAL¡¢IAL ÒÔ¼°¶à×ÖÌåºÍ¶à×Ö·û¼¯µÄÖ§³Ö¡£×ÖÌåºÍ×Ö·û¼¯µÄÖ§³Ö£¬¶ÔÈκÎÒ»¸ö GUI ϵͳÀ´½²¶¼ÊDz»¿ÉȱÉٵġ£²»¹ý£¬¸÷ÖÖ GUI ÔÚʵÏÖ¶à×ÖÌåºÍ¶à×Ö·û¼¯µÄÖ§³Öʱ£¬²ÉÓò»Í¬µÄ²ßÂÔ¡£±ÈÈ磬¶Ô¶à×Ö·û¼¯µÄÖ§³Ö£¬QT/Embedded²ÉÓà UNICODE Ϊ»ù´¡ÊµÏÖ£¬ÕâÖÖ·½·¨ÊÇÄ¿Ç°±È½Ï³£Óõķ½·¨£¬ÊÇÒ»ÖÖÊʺÏÓÚͨÓÃϵͳµÄ½â¾ö·½°¸¡£È»¶ø£¬ÕâÖÖ·½·¨´øÀ´Ðí¶àÎÊÌ⣬ÆäÖÐ×îÖ÷Òª¾ÍÊÇ UNICODE ºÍÆäËû×Ö·û¼¯Ö®¼äµÄת»»Âë±í»á´ó´óÔö¼Ó GUI ϵͳµÄ³ß´ç¡£Õâ¶ÔijЩǶÈëʽϵͳÀ´½²ÊDz»ÄܽÓÊܵġ£

    MiniGUI ÔÚÄÚ²¿²¢Ã»ÓвÉÓà UNICODE Ϊ»ù´¡ÊµÏÖ¶à×Ö·û¼¯µÄÖ§³Ö¡£MiniGUIµÄ²ßÂÔÊÇ£¬¶Ôij¸öÌض¨µÄ×Ö·û¼¯£¬ÔÚÄÚ²¿Ê¹Óú͸Ã×Ö·û¼¯ÍêÈ«Ò»ÖµÄÄÚÂë±íʾ¡£È»ºó£¬Í¨¹ýһϵÁгéÏóµÄ½Ó¿Ú£¬Ìṩ¶Ôij¸öÌض¨×Ö·û¼¯Îı¾µÄÒ»Ö·ÖÎö½Ó¿Ú¡£¸Ã½Ó¿Ú¼È¿ÉÒÔÓÃÓÚ¶Ô×ÖÌåÄ£¿é£¬Ò²¿ÉÒÔÓÃÀ´ÊµÏÖ¶à×Ö½Ú×Ö·û´®µÄ·ÖÎö¹¦ÄÜ¡£Èç¹ûÒªÔö¼Ó¶Ôij¸ö×Ö·û¼¯µÄÖ§³Ö£¬Ö»ÐèҪʵÏÖ¸Ã×Ö·û¼¯µÄ½Ó¿Ú¼´¿É¡£µ½Ä¿Ç°ÎªÖ¹£¬MiniGUI ÒѾ­ÊµÏÖÁË ISO8859-x µÄµ¥×Ö½Ú×Ö·û¼¯Ö§³Ö£¬ÒÔ¼° GB2312¡¢BIG5¡¢EUCKR¡¢UJIS µÈ¶à×Ö½Ú×Ö·û¼¯µÄÖ§³Ö¡£

    ºÍ×Ö·û¼¯ÀàËÆ£¬MiniGUI Ò²Õë¶Ô×ÖÌ嶨ÒåÁËһϵÁгéÏó½Ó¿Ú£¬Èç¹ûÒªÔö¼Ó¶ÔijÖÖ×ÖÌåµÄÖ§³Ö£¬Ö»ÐèʵÏÖ¸Ã×ÖÌåÀàÐ͵Ľӿڼ´¿É¡£µ½Ä¿Ç°ÎªÖ¹£¬MiniGUI ÒѾ­ÊµÏÖÁË¶Ô RBF ºÍ VBF ×ÖÌ壨ÕâÊÇ MiniGUI ¶¨ÒåµÄÁ½ÖÖ¹âÕ¤×ÖÌå¸ñʽ£©¡¢TrueType ºÍ Adobe Type1 ×ÖÌåµÈµÄÖ§³Ö¡£

    ÔÚ¶à×ÖÌåºÍ¶à×Ö·û¼¯µÄ³éÏó½Ó¿ÚÖ®ÉÏ£¬MiniGUI ͨ¹ýÂß¼­×ÖÌåΪӦÓóÌÐòÌṩÁËÒ»ÖµĽӿڡ£

    ±¾ÎÄÖصã½éÉÜ MiniGUI µÄÂß¼­×ÖÌå¡¢¶à×ÖÌåºÍ¶à×Ö·û¼¯µÄʵÏÖ£¬²¢ÒÔ EUCKR£¨º«ÎÄ£©×Ö·û¼¯ºÍ Adobe Type1 ×ÖÌåΪÀý£¬ËµÃ÷ÈçºÎÔÚ MiniGUI ÖÐʵÏÖÒ»ÖÖеÄ×Ö·û¼¯Ö§³ÖºÍеÄ×ÖÌåÀàÐÍÖ§³Ö¡£


[Ŀ¼]


Âß¼­×ÖÌå¡¢É豸×ÖÌåÒÔ¼°×Ö·û¼¯Ö®¼äµÄ¹Øϵ

2 Âß¼­×ÖÌå¡¢É豸×ÖÌåÒÔ¼°×Ö·û¼¯Ö®¼äµÄ¹Øϵ

    ÔÚ MiniGUI ÖУ¬Ã¿¸öÂß¼­×ÖÌåÖÁÉÙÓÉÒ»¸öµ¥×Ö½ÚµÄÉ豸×ÖÌå×é³É¡£É豸×ÖÌåÊÇÖ±½ÓÓëµ×²ã×ÖÌåÏà¹ØÁªµÄÊý¾Ý½á¹¹¡£Ã¿¸öÉ豸×ÖÌåÓÐÒ»¸ö²Ù×÷¼¯£¨¼´ font_ops£©£¬ÆäÖаüº¬ÁË get_char_width¡¢get_char_bitmap µÈ³éÏó½Ó¿Ú¡£Ã¿¸ö MiniGUI ËùÖ§³ÖµÄ×ÖÌåÀàÐÍ£¬±ÈÈçµÈ¿í¹âÕ¤×ÖÌ壨RBF£©¡¢±ä¿í¹âÕ¤×ÖÌ壨VBF£©¡¢TrueType ×ÖÌå¡¢Adobe Type1 ×ÖÌåµÈ¾ù¶ÔÓ¦Ò»×é×ÖÌå²Ù×÷¼¯¡£Í¨¹ýÕâ¸ö×ÖÌå²Ù×÷¼¯£¬ÎÒÃǾͿÉÒÔ´ÓÏàÓ¦µÄ×ÖÌåÎļþÖлñµÃij¸ö×Ö·ûµÄµãÕ󣨶ԹâÕ¤×ÖÌå¶øÑÔ£©»òÕßÂÖÀª£¨¶ÔʸÁ¿×ÖÌå¶øÑÔ£©¡£Ö®ºó£¬MiniGUI ÉϲãµÄ»æͼº¯Êý¾Í¿ÉÒÔ½«ÕâЩµãÕóÊä³öµ½ÆÁÄ»ÉÏ£¬×îÖվͿÉÒÔ¿´µ½ÏÔʾÔÚÆÁÄ»ÉϵÄÎÄ×Ö¡£


    ÔÚÉ豸×ÖÌå½á¹¹ÖУ¬»¹ÓÐÒ»¸ö×Ö·û¼¯²Ù×÷¼¯£¨¼´ charset_ops£©£¬ÆäÖаüº¬ÁË len_first_char¡¢char_offset¡¢len_first_substr µÈ³éÏó½Ó¿Ú¡£Ã¿¸ö MiniGUI ËùÖ§³ÖµÄ×Ö·û¼¯£¬±ÈÈç ISO8859-x¡¢GB2312¡¢BIG5 µÈ×Ö·û¼¯¾ù¶ÔÓ¦Ò»×é×Ö·û¼¯²Ù×÷¼¯¡£Í¨¹ýÕâ¸ö×Ö·û¼¯²Ù×÷¼¯£¬ÎÒÃǾͿÉÒÔ¶Ôij¸ö¶àÖÖ×Ö·û¼¯»ìºÏµÄ×Ö·û´®½øÐÐÎı¾·ÖÎö¡£±ÈÈçÔÚ¡°ABCÖÐÎÄ¡±Õâ¸ö×Ö·û´®ÖУ¬Í·Èý¸ö×Ö·ûÊÇÊôÓÚ ISO8859 µÄ×Ö·û£¬¶ø¡°ÖÐÎÄ¡±ÊÇÊôÓÚ GB2312 µÄ×Ö·û¡£Í¨¹ýµ÷ÓÃÕâÁ½¸ö×Ö·û¼¯²Ù×÷¼¯Öеĺ¯Êý£¬ÎÒÃǾͿÉÒÔÁ˽â¸Ã×Ö·û´®ÖÐÄÄЩ×Ö·ûÊÇÊôÓÚ ISO8859 µÄ×Ö·û£¬ÄÄЩ×Ö·ûÊÇÊôÓÚ GB2312 µÄ×Ö·û£¬ÉõÖÁ¿ÉÒÔ½øÐиü¼Ó¸´ÔӵķÖÎö¡£±ÈÈ磬MiniGUI ÖÐµÄ GetFirstWord º¯Êý¿ÉÒÔ´ÓÕâÖÖ×Ö·û´®ÖлñµÃµÚÒ»¸öµ¥´Ê¡£±ÈÈç¡°ABC DEF ÖÐÎÄ¡±×Ö·û´®ÖеĵÚÒ»¸öµ¥´ÊÊÇ¡°ABC¡±£¬¶øµÚ¶þ¸öµ¥´ÊÊÇ¡°DEF¡±£¬µÚÈý¸öµ¥´ÊºÍµÚËĸöµ¥´Ê·Ö±ðÊÇ¡°ÖС±ºÍ¡°ÎÄ¡±¡£¸Ãº¯ÊýµÄʵÏÖÈçÏ£º

int GUIAPI GetFirstWord (PLOGFONT log_font, const char* mstr, int len,
                    WORDINFO* word_info)
{
    DEVFONT* sbc_devfont = log_font->sbc_devfont;
    DEVFONT* mbc_devfont = log_font->mbc_devfont;

    if (mbc_devfont) {
        int mbc_pos;

        mbc_pos = (*mbc_devfont->charset_ops->pos_first_char) (mstr, len);
        if (mbc_pos == 0) {
            len = (*mbc_devfont->charset_ops->len_first_substr) (mstr, len);

            (*mbc_devfont->charset_ops->get_next_word) (mstr, len, word_info);
            return word_info->len + word_info->nr_delimiters;
        }
        else if (mbc_pos > 0)
            len = mbc_pos;
    }

    (*sbc_devfont->charset_ops->get_next_word) (mstr, len, word_info);
    return word_info->len + word_info->nr_delimiters;
}

    ¸Ãº¯ÊýÊ×ÏÈÅжϸÃÂß¼­×ÖÌåÊÇ·ñ°üº¬¶à×Ö½ÚÉ豸×ÖÌ壨mbc_devfontÊÇ·ñΪ¿Õ£©£¬Èç¹ûÊÇ£¬Ôòµ÷Óöà×Ö½Ú×Ö·û¼¯¶ÔÓ¦µÄ²Ù×÷º¯Êý pos_first_char¡¢len_first_substr¡¢get_next_word µÈº¯Êý»ñµÃµÚÒ»¸öµ¥´ÊÐÅÏ¢£¬²¢Ìî³ä word_info ½á¹¹¡£Èç¹û¸ÃÂß¼­×ÖÌåÖ»°üº¬µ¥×Ö½ÚÉ豸×ÖÌ壬ÔòÖ±½Óµ÷Óõ¥×Ö½Ú×Ö·û¼¯¶ÔÓ¦µÄ²Ù×÷º¯Êý get_next_word¡£Ò»°ã¶øÑÔ£¬ÔÚ GetFirstWord µÈº¯ÊýÖУ¬ÎÒÃÇÊ×ÏÈÒª½øÐжà×Ö½Ú×Ö·û¼¯µÄijЩÅжϣ¬±ÈÈç pos_first_char ·µ»ØµÄÊÇ×Ö·û´®ÖÐÊôÓÚ¸Ã×Ö·û¼¯µÄµÚÒ»¸ö×Ö·ûµÄλÖá£Èç¹û·µ»ØÖµ²»ÎªÁ㣬±íÃ÷µÚÒ»¸ö×Ö·ûÊǵ¥×Ö½Ú×Ö·û£»Èç¹ûΪÁ㣬²Å»áµ÷ÓÃÆäËûº¯Êý½øÐвÙ×÷¡£

    ÓÐÁËÕâÑùµÄÂß¼­×ÖÌå¡¢É豸×ÖÌåºÍ×Ö·û¼¯½á¹¹¶¨Ò壬µ±ÎÒÃÇÐèÒªÐÂÌí¼ÓÒ»ÖÖ×Ö·û¼¯»òÕß×ÖÌåÖ§³Öʱ£¬Ö»Ðè°´ÕÕÎÒÃǵÄ×ÖÌå²Ù×÷¼¯ºÍ×Ö·û¼¯²Ù×÷¼¯¶¨Òå¶ÔÓ¦µÄвÙ×÷¼¯½á¹¹¼´¿É£¬¶ø¶ÔÉϲã³ÌÐòûÓÐÈκÎÓ°Ïì¡£


[Ŀ¼]


MiniGUIÖеÄ×Ö·û¼¯Ö§³Ö3.1×Ö·û¼¯²Ù×÷¼¯

3 MiniGUI ÖеÄ×Ö·û¼¯Ö§³Ö 3.1 ×Ö·û¼¯²Ù×÷¼¯

    ÔÚ MiniGUI ÖУ¬Ã¿¸öÌض¨µÄ×Ö·û¼¯ÓɶÔÓ¦µÄ×Ö·û¼¯²Ù×÷¼¯À´±íʾ¡£×Ö·û¼¯²Ù×÷¼¯µÄ¶¨ÒåÈçÏ£¨include/gdi.h¡£Ç°ÃæµÄÊý×Ö±íʾÔÚ¸ÃÎļþÖеÄÐÐÊý£¬ÏÂͬ£©£º

250 typedef struct _CHARSETOPS
251 {
252     int nr_chars;              // ¸Ã×Ö·û¼¯ÖÐ×Ö·ûµÄ¸öÊý
253     int bytes_per_char;            // ÿ¸ö×Ö·ûµÄƽ¾ù×Ö½ÚÊý
254     int bytes_maxlen_char;     // ×Ö·ûµÄ×î´ó×Ö½ÚÊý
255     const char* name;          // ×Ö·û¼¯Ãû³Æ
256     char def_char [MAX_LEN_MCHAR]; // ĬÈÏ×Ö·û
257
258     int (*len_first_char) (const unsigned char* mstr, int mstrlen);
259     int (*char_offset) (const unsigned char* mchar);
260
261     int (*nr_chars_in_str) (const unsigned char* mstr, int mstrlen);
262
263     int (*is_this_charset) (const unsigned char* charset);
264
265     int (*len_first_substr) (const unsigned char* mstr, int mstrlen);
266     const unsigned char* (*get_next_word) (const unsigned char* mstr,
267                 int strlen, WORDINFO* word_info);
268
269     int (*pos_first_char) (const unsigned char* mstr, int mstrlen);
270
271 #ifndef _LITE_VERSION
272     unsigned short (*conv_to_uc16) (const unsigned char* mchar, int len);
273 #endif /* !LITE_VERSION */
274 } CHARSETOPS;

    ÆäÖУ¬Ç°¼¸¸ö×ֶΣ¨nr_chars¡¢bytes_per_char¡¢bytes_maxlen_char¡¢name¡¢def_char µÈ£©±íʾÁ˸Ã×Ö·û¼¯µÄһЩ»ù±¾ÐÅÏ¢£¬¾ßÌ庬Òå²Î¼û×¢ÊÍ¡£ÕâÀïÐèÒª¶Ô bytes_maxlen_char ºÍ def_chat ×÷½øÒ»²½½âÊÍ£º

    bytes_maxlen_char ÓÃÀ´±íʾ¸Ã×Ö·û¼¯ÖÐ×Ö·ûµÄ××Ö½ÚÊý¡£Í¨³£Çé¿öÏ£¬Ò»¸ö×Ö·û¼¯ÖеÄÿ¸ö×Ö·ûµÄ³¤¶ÈÒ»°ãÊǶ¨³¤µÄ£¬µ«ÊÇÒ²ÓÐÐí¶àÀýÍ⣬±ÈÈçÔÚ GB18303¡¢UNICODE µÈ×Ö·û¼¯ÖУ¬×Ö·ûµÄ××Ö½ÚÊý¿ÉÄܳ¬¹ý 4 ×Ö½Ú¡£
    def_char ÓÃÀ´±íʾ¸Ã×Ö·û¼¯ÖеÄĬÈÏ×Ö·û¡£¸Ã×Ö¶ÎÖ÷ÒªºÍ×ÖÌåÅäºÏʹÓᣵ±Ä³¸öÕë¶Ô¸Ã×Ö·û¼¯µÄ×ÖÌåÖÐȱÉÙһЩ×Ö·ûµÄ¶¨Òåʱ£¬¾ÍÐèÒªÓÃĬÈÏ×ÖÌåÌæ´úÕâЩȱÉÙµÄ×Ö·û¡£
ÔÚÉÏÊö×Ö·û¼¯µÄ²Ù×÷¼¯¶¨ÒåÖУ¬ºó¼¸¸ö×ֶζ¨ÒåΪº¯ÊýÖ¸Õ룬ËüÃǾùÓÉÂß¼­×ÖÌå½Ó¿ÚÓÃÀ´½øÐÐÎı¾·ÖÎö£º

    ·len_first_char ·µ»Ø¶à×Ö½Ú×Ö·û´®ÖеÚÒ»¸öÊôÓÚ¸Ã×Ö·û¼¯µÄ×Ö·ûµÄ³¤¶È¡£Èô²»ÊôÓÚ¸Ã×Ö·û¼¯£¬Ôò·µ»Ø 0¡£
    ·char_offset ·µ»Øij¸ö×Ö·ûÔÚ¸Ã×Ö·û¼¯ÖеÄλÖ᣸ÃÐÅÏ¢¿ÉÒÔÓÉÉ豸×ÖÌåʹÓã¬ÓÃÀ´´ÓÒ»¸ö×ÖÌåÎļþÖлñÈ¡¸Ã×Ö·û¶ÔÓ¦µÄ¿í¶È»òµãÕó¡£
    ·nr_chars_in_str ¼ÆËã×Ö·û´®ÖÐÊôÓÚ¸Ã×Ö·û¼¯µÄ×Ö·û¸öÊý²¢·µ»Ø¡£×¢Ò⣬´«ÈëµÄ×Ö·û´®±ØÐë¾ùΪ¸Ã×Ö·û¼¯×Ö·û¡£
    ·is_this_charset Åжϸø¶¨µÄÓÃÀ´±íʾ×Ö·û¼¯µÄÃû³ÆÊÇ·ñÖ¸¸Ã×Ö·û¼¯¡£ÒòΪ¶ÔijÖÖÌض¨µÄ×Ö·û¼¯£¬ÆäÃû³Æ²»Ò»¶¨ºÍ name ×Ö¶ÎËù¶¨ÒåµÄÃû³ÆÆ¥Åä¡£±ÈÈ磬¶Ô GB2312 ×Ö·û¼¯£¬¾Í¿ÉÄÜÓÐ gb2312-1980.0¡¢GB2312_80 µÈ¸÷ÖÖ²»Í¬µÄÃû³Æ¡£¸Ãº¯Êý¿ÉÒÔ°ïÖúÕýÈ·ÅжÏÒ»¸öÃû³ÆÊÇ·ñÖ¸¸Ã×Ö·û¼¯¡£
    ·len_first_substr ·µ»Øij¸ö¶à×Ö½Ú×Ö·û´®ÖÐÊôÓÚ¸Ã×Ö·û¼¯µÄ×Ó×Ö·û´®³¤¶È¡£Èç¹ûµÚÒ»¸ö×Ö·û²»ÊôÓÚ¸Ã×Ö·û¼¯£¬Ôò·µ»ØΪ 0¡£
    ·get_next_word ·µ»Ø¶à×Ö½Ú×Ö·û´®ÖÐÊôÓÚ¸Ã×Ö·û¼¯µÄ×Ö·û´®ÖÐÏÂÒ»¸öµ¥´ÊµÄÐÅÏ¢¡£¶ÔÅ·ÃÀÓïÑÔÀ´Ëµ£¬µ¥´ÊÖ®¼äÓÉ¿Õ¸ñ¡¢±êµã·ûºÅ¡¢ÖƱí·ûµÈÏà¸ô£»¶ÔÑÇÖÞÓïÑÔÀ´Ëµ£¬µ¥´Êͨ³£¶¨ÒåΪ×Ö·û¡£
pos_first_char ¸Ãº¯Êý·µ»Ø¶à×Ö½Ú×Ö·û´®ÖÐÊôÓÚ¸Ã×Ö·û¼¯µÄµÚÒ»¸ö×Ö·ûµÄλÖá£
    ·conv_to_uc16 ¸Ãº¯Êý½«Ä³¸öÊôÓÚ¸Ã×Ö·û¼¯µÄ×Ö·û£¬×ª»»Îª UNICODE µÄ 16 λÄÚÂë¡£¸Ãº¯ÊýÖ÷ÒªÓÃÀ´´Ó TrueType ×ÖÌåÖлñµÃ×Ö·ûµÄÂÖÀªÐÅÏ¢¡£ÒòΪ TrueType ×ÖÌåʹÓà UNICODE ¶¨Î»×Ö·û£¬ËùÒÔÐèÒªÕâ¸öº¯ÊýÍê³ÉÌض¨×Ö·û¼¯ÄÚÂëµ½ UNICODE ÄÚÂëµÄת»»¡£ÓÉÓÚ MiniGUI-Lite °æ±¾Éв»Ö§³Ö TrueType ×ÖÌ壬ËùÒԸú¯ÊýÔÚ MiniGUI-Lite °æ±¾ÖÐÎÞÐ趨Òå¡£

    ÔÚ src/font/charset.c ÖУ¬¶¨ÒåÁËϵͳ֧³ÖµÄËùÓÐ×Ö·û¼¯²Ù×÷¼¯£¬²¢Óɺ¯Êý GetCharsetOps ·µ»Øij¸ö×Ö·û¼¯Ãû³Æ¶ÔÓ¦µÄ×Ö·û¼¯²Ù×÷¼¯£¨src/font/charset.c£©£º

716 static CHARSETOPS* Charsets [] =
717 {
718     &CharsetOps_iso8859_1,
719     &CharsetOps_iso8859_5,
720 #ifdef _GB_SUPPORT
721     &CharsetOps_gb2312,
722 #endif
723 #ifdef _BIG5_SUPPORT
724     &CharsetOps_big5,
725 #endif
726 #ifdef _EUCKR_SUPPORT
727     &CharsetOps_euckr,
728 #endif
729 #ifdef _UJIS_SUPPORT
730     &CharsetOps_ujis
731 #endif
732 };
733
734 #define NR_CHARSETS     (sizeof(Charsets)/sizeof(CHARSETOPS*))
735
736 CHARSETOPS* GetCharsetOps (const char* charset_name)
737 {
738     int i;
739
740     for (i = 0; i &lt; NR_CHARSETS; i++) {
741         if ((*Charsets [i]-&gt;is_this_charset) (charset_name) == 0)
742             return Charsets [i];
743     }
744
745     return NULL;
746 }
747

3.2 ÐÂ×Ö·û¼¯µÄʵÏÖ¾ÙÀý
    Èç¹ûÎÒÃÇÐèÒª¶¨ÒåÒ»ÖÖеÄ×Ö·û¼¯Ö§³Öʱ£¬Ö»ÐèÔÚ¸ÃÎļþÖÐÌí¼ÓÏàÓ¦µÄ²Ù×÷¼¯º¯ÊýÒÔ¼°¶ÔÓ¦µÄ²Ù×÷¼¯½á¹¹¶¨Òå¼´¿É£¬±ÈÈ磬¶Ô EUCKR ×Ö·û¼¯µÄÖ§³Ö¶¨ÒåÈçÏ£¨src/font/charset.c£©£º

468 #ifdef _EUCKR_SUPPORT
469 /************************* EUCKR Specific Operations ************************/
470 static int euckr_len_first_char (const unsigned char* mstr, int len)
471 {
472     unsigned char ch1;
473     unsigned char ch2;
474
475     if (len < 2) return 0;
476
477     ch1 = mstr [0];
478     if (ch1 == '\0')
479         return 0;
480
481     ch2 = mstr [1];
482     if (ch1 >= 0xA1 && ch1 <= 0xFE && ch2 >= 0xA1 && ch2 <= 0xFE)
483         return 2;
484
485     return 0;
486 }
487
488 static int euckr_char_offset (const unsigned char* mchar)
489 {
490     if(mchar [0] > 0xAD)
491         return ((mchar [0] - 0xA4) * 94 + mchar [1] - 0xA1 - 0x8E);
492     else
493         return ((mchar [0] - 0xA1) * 94 + mchar [1] - 0xA1 - 0x8E);
494 }
495
496 static int euckr_is_this_charset (const unsigned char* charset)
497 {
498     int i;
499     char name [LEN_FONT_NAME + 1];
500
501     for (i = 0; i < LEN_FONT_NAME + 1; i++) {
502         if (charset [i] == '\0')
503             break;
504         name [i] = toupper (charset [i]);
505     }
506     name [i] = '\0';
507
508     if (strstr (name, "EUCKR") )
509         return 0;
510
511     return 1;
512 }
513
514 static int euckr_len_first_substr (const unsigned char* mstr, int mstrlen)
515 {
516     unsigned char ch1;
517     unsigned char ch2;
518     int i, left;
519     int sub_len = 0;
520
521     left = mstrlen;
522     for (i = 0; i < mstrlen; i += 2) {
523         if (left < 2) return sub_len;
524
525         ch1 = mstr [i];
526         if (ch1 == '\0') return sub_len;
527
528         ch2 = mstr [i + 1];
529         if (ch1 >= 0xA1 && ch1 <= 0xFE && ch2 >= 0xA1 && ch2 <= 0xFE)
530             sub_len += 2;
531         else
532             return sub_len;
533
534         left -= 2;
535     }
536
537     return sub_len;
538 }
539
540 static int euckr_pos_first_char (const unsigned char* mstr, int mstrlen)
541 {
542     unsigned char ch1;
543     unsigned char ch2;
544     int i, left;
545
546     i = 0;
547     left = mstrlen;
548     while (left) {
549         if (left < 2) return -1;
550
551         ch1 = mstr [i];
552         if (ch1 == '\0') return -1;
553
554         ch2 = mstr [i + 1];
555         if (ch1 >= 0xA1 && ch1 <= 0xFE && ch2 >= 0xA1 && ch2 <= 0xFE)
556             return i;
557
558         i += 1;
559         left -= 1;
560     }
561
562     return -1;
563 }
564
565 #ifndef _LITE_VERSION
566 static unsigned short euckr_conv_to_uc16 (const unsigned char* mchar, int len)
567 {
568     return '?';
569 }
570 #endif
571
572 static CHARSETOPS CharsetOps_euckr = {
573     8836,
574     2,
575     2,
576     FONT_CHARSET_EUCKR,
577     {'\xA1', '\xA1'},
578     euckr_len_first_char,
579     euckr_char_offset,
580     db_nr_chars_in_str,
581     euckr_is_this_charset,
582     euckr_len_first_substr,
583     db_get_next_word,
584     euckr_pos_first_char,
585 #ifndef _LITE_VERSION
586     euckr_conv_to_uc16
587 #endif
588 };
589 /************************* End of EUCKR *************************************/
590 #endif  /* _EUCKR_SUPPORT */


[Ŀ¼]


MiniGUIÖеÄ×ÖÌåÖ§³Ö

4 MiniGUI ÖеÄ×ÖÌåÖ§³Ö

4.1 É豸×ÖÌå
    ÔÚ MiniGUI ÖУ¬É豸×ÖÌ嶨ÒåÈçÏ£¨include/gdi.h£©£º

319 struct _DEVFONT
320 {
321     char             name [LEN_DEVFONT_NAME + 1];
322     DWORD            style;
323     FONTOPS*         font_ops;
324     CHARSETOPS*      charset_ops;
325     struct _DEVFONT* sbc_next;
326     struct _DEVFONT* mbc_next;
327     void*            data;
328 };

ÆäÖи÷×Ö¶Î˵Ã÷ÈçÏ£º

    name£º¸ÃÉ豸×ÖÌåµÄÃû³Æ¡£MiniGUI ÖÐÉ豸×ÖÌåµÄÃû³Æ¸ñʽÈçÏ£º

<type>-<name>-<style>-<width>-<height>-<charset1[,charset2]>

ÆäÖÐÿ¸öÓòµÄº¬ÒåÈçÏ£º

type£º×ÖÌåÀàÐÍ£¬±ÈÈçRBF£¨MiniGUI ¶¨ÒåµÄµÈ¿í×ÖÌå¸ñʽ£©¡¢VBF£¨MiniGUI ¶¨ÒåµÄ±ä¿í×ÖÌå¸ñʽ£©¡¢TTF£¨TrueType ×ÖÌ壩µÈµÈ¡£
name£ºÃû³Æ£¬±ÈÈç Song¡¢Hei¡¢Times µÈµÈ¡£
style£º¸Ã×ÖÌåµÄÑùʽ£¬±ÈÈçºÚÌ塢бÌåµÈµÈ¡£
width£º¸Ã×ÖÌåµÄ¿í¶È£¬¶ÔʸÁ¿×ÖÌåÀ´Ëµ£¬¿ÉÈ¡ 0¡£
height£º¸Ã×ÖÌåµÄ¸ß¶È£¬¶ÔʸÁ¿×ÖÌåÀ´Ëµ£¬¿ÉÈ¡ 0¡£
charset1, charset2£º¸Ã×ÖÌåÊÊÓõÄ×Ö·û¼¯Ãû³Æ¡£
style£º×ÖÌåÑùʽ¡£
font_ops£ºÉ豸×ÖÌå¶ÔÓ¦µÄ×ÖÌå²Ù×÷¼¯¡£
charset_ops£ºÉ豸×ÖÌå¶ÔÓ¦µÄ×Ö·û¼¯²Ù×÷¼¯¡£
sbc_next¡¢mbc_next£ºÄÚ²¿Ê¹ÓõÄÁ´±íά»¤×ֶΡ£
data£º¸ÃÉ豸×ÖÌåÏà¹ØµÄÄÚ²¿Êý¾Ý¡£
ÔÚ MiniGUI Æô¶¯Ê±£¬½«¸ù¾Ý MiniGUI.cfg ÎļþÖеĶ¨Ò彨Á¢Á½¸öÉ豸×ÖÌåÁ´±í£¬·Ö±ðΪµ¥×Ö½ÚÉ豸×ÖÌåÁ´ºÍ¶à×Ö½ÚÉ豸×ÖÌåÁ´¡£ÕâÁ½¸öÁ´±í½«ÓÉ CreateLogFont ʹÓã¬Í¨¹ý²éÕÒºÍÆ¥Å䣬½¨Á¢¶ÔÓ¦µÄÂß¼­×ÖÌå¡£

4.2 Âß¼­×ÖÌå
    Âß¼­×ÖÌåµÄ¶¨ÒåÈçÏ£¨include/gdi.h£©£º

228 typedef struct _LOGFONT {
229     char type [LEN_FONT_NAME + 1];
230     char family [LEN_FONT_NAME + 1];
231     char charset [LEN_FONT_NAME + 1];
232     DWORD style;
233     int size;
234     int rotation;
235     DEVFONT* sbc_devfont;
236     DEVFONT* mbc_devfont;
237 } LOGFONT;
238 typedef LOGFONT*    PLOGFONT;

    ÏÔÈ»£¬Ã¿¸öÂß¼­×ÖÌåÓÉ×îÆ¥Åä¸Ã×ÖÌåÒªÇ󣨴óС¡¢×Ö·û¼¯¡¢ÑùʽµÈ£©µÄÁ½¸öÉ豸×ÖÌ壨sbc_devfontºÍ mbc_devfong£©×é³É£¬·Ö±ðÓÃÀ´´¦Àí¶à×Ö½Ú×Ö·û´®Öеĵ¥×Ö½Ú×Ö·ûºÍ¶à×Ö½Ú×Ö·û¡£ÆäÖе¥×Ö½ÚÉ豸×ÖÌåÊDZز»¿ÉÉٵġ£

    Âß¼­×ÖÌåµÄÆ¥ÅäËã·¨¿É²Î¼û src/gdi/logfont.c ºÍsrc/font/devfont.c Îļþ¡£ÏÞÓÚƪ·ù£¬²»ÔÙ׸Êö¡£

4.3 É豸×ÖÌå²Ù×÷¼¯
    ºÍ×Ö·û¼¯²Ù×÷¼¯Ò»Ñù£¬MiniGUI ÖеÄÉ豸×ÖÌå²Ù×÷¼¯Õë¶ÔÿÖÖÉ豸×ÖÌåÀàÐͶø¶¨Ò壬°üÀ¨¶ÔÕâÖÖÉ豸×ÖÌåµÄ¸÷ÖÖ²Ù×÷º¯Êý£¨include/gdi.h£©£º

276 typedef struct _FONTOPS
277 {
278     int (*get_char_width) (LOGFONT* logfont, DEVFONT* devfont,
279             const unsigned char* mchar, int len);
280     int (*get_str_width) (LOGFONT* logfont, DEVFONT* devfont,
281             const unsigned char* mstr, int n, int cExtra);
282     int (*get_ave_width) (LOGFONT* logfont, DEVFONT* devfont);
283     int (*get_max_width) (LOGFONT* logfont, DEVFONT* devfont);
284     int (*get_font_height) (LOGFONT* logfont, DEVFONT* devfont);
285     int (*get_font_size) (LOGFONT* logfont, DEVFONT* devfont, int expect);
286     int (*get_font_ascent) (LOGFONT* logfont, DEVFONT* devfont);
287     int (*get_font_descent) (LOGFONT* logfont, DEVFONT* devfont);
288
289 /* TODO */
290 //    int (*get_font_ABC) (LOGFONT* logfont);
291
292     size_t (*char_bitmap_size) (LOGFONT* logfont, DEVFONT* devfont,
293             const unsigned char* mchar, int len);
294     size_t (*max_bitmap_size) (LOGFONT* logfont, DEVFONT* devfont);
295     const void* (*get_char_bitmap) (LOGFONT* logfont, DEVFONT* devfont,
296             const unsigned char* mchar, int len);
297
298     const void* (*get_char_pixmap) (LOGFONT* logfont, DEVFONT* devfont,
299             const unsigned char* mchar, int len, int* pitch);
300          /* Can be NULL */
301
302     void (*start_str_output) (LOGFONT* logfont, DEVFONT* devfont);
303          /* Can be NULL */
304     int (*get_char_bbox) (LOGFONT* logfont, DEVFONT* devfont,
305             const unsigned char* mchar, int len,
306             int* px, int* py, int* pwidth, int* pheight);
307          /* Can be NULL */
308     void (*get_char_advance) (LOGFONT* logfont, DEVFONT* devfont,
309             int* px, int* py);
310          /* Can be NULL */
311
312     DEVFONT* (*new_instance) (LOGFONT* logfont, DEVFONT* devfont,
313             BOOL need_sbc_font);
314          /* Can be NULL */
315     void (*delete_instance) (DEVFONT* devfont);
316          /* Can be NULL */
317 } FONTOPS;

    ±ÈÈ磬get_char_width ÓÃÀ´»ñµÃij¸ö×Ö·ûµÄ¿í¶È£¬¶ø get_char_bitmap ÓÃÀ´»ñµÃij¸ö×Ö·ûµÄλͼÐÅÏ¢µÈµÈ¡£

    ÔÚ src/font/rawbitmap.c ºÍ src/font/varbitmap.c ÎļþÖзֱð¶¨ÒåÁË¶Ô RBF ºÍ VBF Á½ÖÖ×ÖÌåµÄ²Ù×÷º¯Êý£¬±ÈÈç¶Ô±ä¿í¹âÕ¤×ÖÌåÀ´½²£¨VBF£©£¬Æä get_char_bitmap ¶¨ÒåÈçÏ£¨src/font/rawbitmap.c£©£º

155 static const void* get_char_bitmap (LOGFONT* logfont, DEVFONT* devfont,
156             const unsigned char* mchar, int len)
157 {
158     int offset;
159     unsigned char eff_char = *mchar;
160     VBFINFO* vbf_info = VARFONT_INFO_P (devfont);
161
162     if (*mchar < vbf_info->first_char || *mchar > vbf_info->last_char)
163         eff_char = vbf_info->def_char;
164
165     if (vbf_info->offset == NULL)
166         offset = (((size_t)vbf_info->max_width + 7) >> 3) * vbf_info->height
167                     * (eff_char - vbf_info->first_char);
168     else
169         offset = vbf_info->offset [eff_char - vbf_info->first_char];
170
171     return vbf_info->bits + offset;
172 }

    ÆäÖУ¬VARFONT_INFO_P ÊÇÒ»¸öºê£¬ÓÃÀ´´ÓÉ豸×ÖÌåµÄ data ×Ö¶ÎÖлñµÃ VBFINFO ½á¹¹µÄÖ¸Õë¡£ÓÐÁËÕâ¸öÖ¸ÕëÖ®ºó£¬¸Ãº¯Êý¼ÆËã×Ö·ûλͼµÄÆ«ÒÆÁ¿×îºó·µ»Ø×Ö·ûµÄλͼ¡£

4.4 ÐÂÉ豸×ÖÌåµÄʵÏÖ¾ÙÀý
    ÕâÀïÒÔ Adobe Type1 ×ÖÌåµÄʵÏÖΪÀý£¬ËµÃ÷ÈçºÎÔÚ MiniGUI ÖÐʵÏÖÒ»ÖÖеÄÉ豸×ÖÌå¡£MiniGUI ½èÓÃÁË T1Lib º¯Êý¿âʵÏÖÁË¶Ô Type1 ×ÖÌåµÄÖ§³Ö¡£

4.4.1 Type1 ×ÖÌå¼ò½é

    Type1 ʸÁ¿×ÖÌå1¸ñʽÓÉ Adobe ¹«Ë¾Éè¼Æ£¬²¢±»¸Ã¹«Ë¾µÄps±ê×¼Ö§³Ö¡£Òò´Ë£¬ËüÔÚLinuxÏÂÒ²±»Ö§³ÖµÃºÜºÃ¡£Ëü±» XºÍ ghostscriptÖ§³Ö¡£Ò»¸öµäÐ͵ÄType1×ÖÌå°üÀ¨Ò»¸öafm(adobe font metric) ¶ÈÁ¿Îļþ£¬Ò»¸öÍâÐÎÎļþ£¬Í¨³£ÊÇÒ»¸öpfb ( printer font binary) »òÕß pfa (printer font ascii) Îļþ£¬ÍâÐÎÎļþ°üÀ¨ËùÓеÄÂÖÀª£¬¶ø¶ÈÁ¿Îļþ°üº¬ÁËËùÓеĶÈÁ¿¡£±ÈÈç½ôÅÅ£¬Á¬×ÖµÈÐÅÏ¢¡£

4.4.2 T1Lib ¼ò½é

    T1Lib ÊÇÓà C ÓïÑÔʵÏÖµÄÒ»¸ö¿â£¬Ëü¿ÉÒÔ´Ó Adobe Type 1 ×ÖÌåÉú³Éλͼ¡£Ëü¿ÉÒÔʹÓÃX11R5 »òÕ߸üа汾ÌṩµÄ¹âÕ¤»¯¹¤¾ßµÄºÜ¶à¹¦ÄÜ£¬µ«±ÜÃâÁËÆäÒÑÖªµÄȱµã¡£µ±È»£¬T1LibÍêÈ«¿ÉÒÔÔÚûÓÐ X11 µÄ»·¾³Ï¹¤×÷¡£T1Lib ¿ÉÒÔ±»±àÒë³É¾²Ì¬»òÕ߶¯Ì¬¿â£¬´Ó¶ø¿ÉÒÔ·½±ãµØÁ¬½Ó¡£

    ÕâÀïÊÇT1Lib µÄһЩÌØÐÔ£º

    ·×ÖÌåͨ¹ýÔËÐÐʱ¶ÁÈ¡×Ö¿â¶ø±»T1libµÃÖª¡£¼´ËüÊÇÁé»î¿ÉÅäÖõġ£µ±È»£¬ËüÖ»Ö§³ÖType 1×ÖÌå¡£
×Ö·û»ò×Ö·û´®Ö»ÔÚÐèҪʱ²Å±»¹âÕ¤»¯¡£
    ·¶Ô×Ö·û´®¹âÕ¤»¯Ê±Ö§³Ö×Ö·û¼ä½ôÅÅ£¬²¢ÇÒ¿ÉÒÔÀûÓÃÒ»¸öAFMÎļþÌṩ½ôÅÅÐÅÏ¢£¬Èç¹ûûÓÐÕâ¸öÎļþ£¬T1Lib¿ÉÒÔÖ±½ÓÉú³ÉÕâЩÐÅÏ¢£¬Ò²¿ÉÒÔ½«ÆäÊä³öµ½Ò»¸öÎļþÒÔ±¸ºóÓá£
    ·Ö§³ÖÁ¬×Ö£¬Á¬×ÖÊÇÒ»¸öºÃµÄ×ÖÌåÄ£ÐÍ»áÌṩµÄ¹¦ÄÜ£¬Ä¿Ç°£¬Ö»ÓÐTEXºÍÓëÆäÏà¹ØµÄÈí¼þ°ü¶ÔÁ¬×ÖÖ§³ÖµÃ±È½ÏºÃ¡£Á¬×ÖÐÅÏ¢Ò²°üº¬ÔÚAFMÎļþÀï¡£
    ·Ö§³ÖÐýתºÍ¸÷ÖÖ·ÂÉä±ä»»¡£Ö§³Ö×ÖÌåÀ©Õ¹£¬Çãб¡£
    ·¿ÉÒÔ¶¯Ì¬ÔØÈëеĽâÂëʸÁ¿¡£ÓÃеĽâÂëʸÁ¿½âÎö×ÖÌå¡£
    ·Ö§³Ö5»Ò¶ÈµÄµÍ·Ö±æÂʺÍ17»Ò¶ÈµÄ¸ß·Ö±æÂʵķ´×ßÑù¡£
    ·×Ö·û´®¿ÉÒÔ±»Ìí¼ÓÏ»®Ïߣ¬ÉÏ»®Ïß»òÕߺáÏß¡£

4.4.3 Adobe Type1 ×ÖÌåÖ§³ÖµÄʵÏÖ

    ÔÚ MiniGUI É豸×ÖÌ嶨ÒåÖУ¬ÓÐÒ»¸ö data ×ֶοÉÓÃÀ´±£´æÉ豸×ÖÌåÏà¹ØµÄÊý¾Ý½á¹¹¡£¶Ô Type1 ×ÖÌåÀ´½²£¬ÎÒÃÇʹÓà TYPE1INFOºÍTYPE1INSTANCEINFOÁ½¸öÊý¾Ý½á¹¹À´´æ´¢ÕâÖÖÉ豸×ÖÌåµÄÀàÐÅÏ¢ºÍʵÀýÐÅÏ¢¡£

1) TYPE1INFOºÍTYPE1INSTANCEINFO ½á¹¹

ÕâÁ½¸ö½á¹¹µÄ¶¨ÒåÈçÏ£¨src/font/type1.h£©£º

  22 typedef struct tagTYPE1GLYPHINFO {
  23     int font_id;
  24     //BBox      font_bbox;
  25     //int       ave_width;
  26     BOOL valid;
  27 } TYPE1INFO, *PTYPE1INFO;
  28
  29 typedef struct tagTYPE1INSTANCEINFO {
  30     PTYPE1INFO  type1_info;
  31     int         rotation;/*in tenthdegrees*/
  32     T1_TMATRIX  * pmatrix;
  33     int         size;
  34     int         font_height;
  35     int         font_ascent;
  36     int         font_descent;
  37
  38     int         max_width;
  39     int         ave_width;
  40
  41     double      csUnit2Pixel;
  42     /*
  43      * last char or string's info
  44      * T1_SetChar, T1_SetString, T1_AASetSting, T1_AASetString all return a static
  45      * glyph pointer, we save the related infomation here for later use.
  46      * */
  47     char        last_bitmap_char;
  48     char        last_pixmap_char;
  49     char        * last_bitmap_str;
  50     char        * last_pixmap_str;
  51     int         last_ascent;
  52     int         last_descent;
  53     int         last_leftSideBearing;
  54     int         last_rightSideBearing;
  55     int         last_advanceX;
  56     int         last_advanceY;
  57     unsigned long       last_bpp;
  58     char  *     last_bits;
  59
  60 } TYPE1INSTANCEINFO, *PTYPE1INSTANCEINFO;
  61

    ÈçÇ°ÃæËù˵£¬TYPE1INFOºÍTYPE1INSTANCEINFOÊý¾Ý½á¹¹À´´æ´¢É豸×Ö·ûµÄÀàÐÅÏ¢ºÍʵÀýÐÅÏ¢¡£³õʼ»ªÊ±£¬ÆäʵֻÊÇ×¢²áÒ»¸öÄ£°å£¬´ËʱÀûÓÃTYPE1INFO¼ÇסÆäÔÚ T1libÖеÄFont ID£¬ÕâÀïvalidÓÃÀ´ËµÃ÷¸ÃÉ豸×ÖÌåÊÇ·ñ³õʼ»¯Íê±Ï¡£

    µ±Óû§´´½¨Ò»Âß¼­×ÖÌåʱ£¬Èç¹ûÓû§Ñ¡ÔñµÄÊÇType1×ÖÌåµÄijһÖÖ£¬¾Í»áµ÷Óà font_ops µÄº¯Êýnew_instance£¬¸Ãº¯Êý¸ù¾Ý´æÔÚÓÚ DevFont µÄdataµÄ TYPE1INFO ½á¹¹ÖÐµÄ id£¬ÒÔ¼°Óû§ÌṩµÄÏà¹Ø²ÎÊý£¬¹¹ÔìÒ»¸öTYPE1INSTANCEINFOÀàÐ͵ıäÁ¿£¬²¢·ÅÈëеÄÉ豸×ÖÌåµÄ˽ÓÐÊý¾ÝdataÖС£´Ó¶øÿ¸ö×ÖÌåʵÀý¿ÉÒÔÓÐ×Ô¼ºµÄ¸÷ÖÖÊôÐÔ¡£ÈçÐýת¶È¡£

    Ç°Ãæ¸÷¸ö×ֶεÄÒâÒå¿ÉÒÔ¸ù¾ÝÃû×ÖÍƲâ³öÀ´£¬´ÓcsUnix2Pixel ¿ªÊ¼ÔòÊÇΪÁËʵÏֵķ½±ãºÍ¸ßЧ¶ø×Ô¼º¶¨ÒåµÄһЩ±äÁ¿£¬ºóÃæ½âÊͺ¯ÊýʵÏÖʱ½«»á˵Ã÷¡£last*ϵÁк¯ÊýÖ÷ÒªÆ𻺳åµÄ×÷Óá£

2) InitType1Fonts ºÍ TermType1Fonts º¯Êý

    ÕâÁ½¸öº¯Êý¸ºÔðÕû¸ö Type 1 ×ÖÌåµÄ³õʼ»¯ºÍÖսᡣ

    InitType1Fonts µÄÖ÷ÒªÈÎÎñÊÇ£º³õʼ»¯T1lib£¬¸ù¾ÝÅäÖÃÎļþÌṩµÄÐÅÏ¢£¬½«¸÷ÖÖ×ÖÌå×¢²áµ½T1lib£¬²¢ÎªÃ¿Ò»¸ö×ÖÌåÉú³ÉÒ»¸ö DevFont ½á¹¹£¬×¢²áµ½ÏµÍ³ÖÐÈ¥¡£¸Ã½á¹¹ÖаüÀ¨µÄ font_ops£¬ÊÇÉϲã¶ÔType 1×ÖÌå¸÷ÖÖ²Ù×÷µÄ´°¿Ú¡£

    ÆäʵÖ÷ÒªµÄ´¦Àí¹¦ÄÜÔÚ T1lib ÖУ¬Ã¿´Î³ÌÐòÏò T1lib ×¢²áÒ»¸ö×ÖÌ壬T1lib»á·µ»ØÒ»¸ö Font ID£¬ÒÔºóÀûÓøÃID ÏòT1libÇëÇó¹ØÓÚ¶ÔÓ¦×ÖÌåµÄijЩ·þÎñ¡£

    ·TermType1Fonts ÔòÊÇ×¢Ïú Type1 ×ÖÌ壬¹Ø±ÕT1lib¡£

    ·InitType1Fonts ×¢²áÏòϵͳע²áÁËÓÃÀ´´¦Àí Abode Type1 ×ÖÌåµÄ×ÖÌå²Ù×÷¼¯£¬¶¨ÒåÈçÏ£¨src/font/type1.c£©£º

780 static FONTOPS type1_font_ops = {
781         get_char_width,
782         get_str_width,
783         get_ave_width,
784         get_max_width,
785         get_font_height,
786         get_font_size,
787         get_font_ascent,
788         get_font_descent,
789         char_bitmap_size,
790         max_bitmap_size,
791         get_char_bitmap,
792         get_char_pixmap,
793         start_str_output,
794         get_char_bbox,
795         get_char_advance,
796         new_instance,
797         delete_instance
798};

    ÏÈ˵Ã÷һЩ»ù±¾¸ÅÄî¡£

    ·ascent£ºÃèÊöij¸ö×Ö·ûÔÚ»ù×¼ÏßÉÏÓжàÉÙɨÃèÏß¡£ÕâÀïÒÔÏñËØΪµ¥Î»£¨ÏÂͬ£©¡£
descent£ºÃèÊöij¸ö×Ö·ûÔÚ»ù×¼ÏßÏÂÓжàÉÙɨÃèÏß¡£µ±×Ö·ûµÄµ×ÏßÔÚ»ù×¼ÏßÖ®ÏÂʱ£¬ÓøºÖµÀ´±íʾ£¬ËùÒÔÕû¸ö×Ö·ûµÄ¸ß¶È¾ÍÊÇ ascent - descent¡£
    ·leftSideBearing£ºÄ³¸ö×Ö·û´ÓÆäÔ­µãµ½×î×ó±ßÏñËصãµÄˮƽ¾àÀ룬Ҳ¿ÉÒÔ³ÆΪ¸Ã×Ö·ûµÄleft margin¡£
    ·rightSideBearing£ºÄ³¸ö×Ö·û´ÓÆäÔ­µãµ½×îÓÒ±ßÏñËصãµÄˮƽ¾àÀ룬Ҳ¿ÉÒÔ³ÆΪ¸Ã×Ö·ûµÄright margin¡£
    ·advanceX£ºÔÚij×Ö·ûµÄͼÏó±»·ÅÖú󣬵±Ç°Ô­µãÐèҪǰ½øµÄˮƽ¾àÀë¡£Ëüͨ³£±È×Ö·ûͼÏñµÄ¿í¶ÈÒª´ó£¬ÒòΪÁ½¸ö×Ö·ûÖ®¼ä´æÔÚÒ»¶¨µÄ¿Õ°×¡£ÓÉÓÚ¸ÃÖµ¶ÔÆëÖÁÏñËØ£¬ËùÒÔһЩҪÇó¾«È·µÄÄÚ²¿¼ÆËã²»ÄÜÓÃËü£¬»áÀÛ»ýÎó²î¡£
    ·advanceY£ºÔÚij×Ö·ûµÄͼÏó±»·ÅÖú󣬵±Ç°Ô­µãÐèҪǰ½øµÄÊúÖ±¾àÀë¡£

    ÕâÑù£¬get_char_width¡¢get_str_width¡¢get_ave_width¡¢get_max_width¡¢get_font_height¡¢get_font_size¡¢get_font_ascent¡¢get_font_descent¡¢char_bitmap_size¡¢max_bitmap_size¡¢get_char_advance µÈº¯ÊýµÄ¹¦ÄܾͺÜÃ÷ÏÔÁË£¬ËüÃÇÆäʵ¾ÍÊÇÈ¡³ö×ÖÌåµÄһЩ¶ÈÁ¿£¨Metrics£©¡£Æäʵ£¬ÕâЩÐÅÏ¢¶¼ÊÇ´ÓT1libÄÚ²¿È¡µÃ£¬ÐèҪעÒâµÄÊÇT1lib ÄÚ²¿Ê¹Óà PS µ¥Î»£¬¶øMiniGUIʹÓõĵ¥Î»ÊÇpixel£¬ ÐèҪת»»¡£ÒÔÏÂÒÔ get_char_bitmap ºÍ get_char_pixmap µÈº¯ÊýΪÀý˵Ã÷¡£

3) get_char_bitmap ºÍ get_char_pixmap

    ÕâÁ½¸öº¯ÊýÊÇÖ÷ÒªµÄ¹âÕ¤»¯º¯Êý¡£ËüÃÇÊ×ÏÈÅжÏÒ»ÏÂÐèÒª¹âÕ¤»¯µÄ×Ö·ûÊÇ·ñ¸Õ¸Õ±»¹âÕ¤»¯¹ý£¬Èç¹ûÊÇ£¬Ö±½Ó·µ»Ø»º³åÀïµÄÖµ¡£

    Ç°Ãæ½²¹ý£¬T1Lib Ö§³Ö5»Ò¶ÈµÄµÍ·Ö±æÂʺÍ17»Ò¶ÈµÄ¸ß·Ö±æÂʵķ´×ßÑù¡£ÕâÀïµÄget_char_bitmap·µ»ØÆÕͨµÄ¹âÕ¤»¯Î»Í¼£¬¶øget_char_pixmap·µ»Ø¾­¹ý·´×ßÑùºóµÄÏñËØλͼ¡£Èç¹û×ÖÌåÔÚ³õʼ»¯Ê±µ÷ÓÃ

T1_AASetLevel (T1_AA_LOW)
ÔòÕâÀïʹÓÃ5»Ò¶ÈÏñËØ£¬Èç¹û³õʼ»¯Ê±Êǵ÷Óãº

T1_AASetLevel (T1_AA_HIGH)
ÔòÕâÀïʹÓÃ17»Ò¶ÈÏñËØ¡£

    ÕâÀïʹÓõķ´×ßÑùÆäʵºÜ¼òµ¥£¬¾ÍÊÇÏȽ«×ÖÌå·Å´ó£¬È»ºóÔÙÈ¡ÑùËõС¡£µÍ¾«¶ÈÊÇ·Å´óËı¶(2*2)£¬¸ß¾«¶ÈÔòÊÇ·Å´ó16±¶£¨4*4£©£¬»Ò¶ÈÖµÔòÓÐn+1ÖÖ¡£

    µ±È»£¬ÎªÁËÌá¸ßÐÔÄÜ£¬Ã¿´Î¹âÕ¤»¯µÄ½á¹û¶¼Òª±»·Åµ½»º³åÀÏ´ÎÈç¹ûÒª¹âÕ¤»¯ÏàͬµÄ×Ö·û£¬²¢ÇÒ·½Ê½Ïàͬ£¬Ôò¿ÉÒÔ´ó´óµØÌá¸ßЧÂÊ¡£

4) start_str_output

    ¿ªÊ¼×Ö·û´®Êä³öʱµ÷Óøú¯Êý¡£Íê³ÉһЩ³õʼ»¯¹¤×÷¡£

5) get_char_bbox

    ¸ø³öµ±Ç°Ô­µãÖµ£¨*px£¬*py£©£¬µ÷Óøú¯ÊýÒªÇóµÃµ½ÔÚ×Ö·û±»»­³öºóµÄÔ­µãÖµ£¨ÐµÄ*px£¬*py£©£¬ÒÔ¼°µ±Ç°×Ö·ûµÄ¿í¶ÈºÍ¸ß¶È¡£

6) new_instance ºÍ delete_instance

    µ±Óû§´´½¨Ò»¸öеÄÂß¼­×ÖÌåʱµ÷ÓÃnew_instance £¬µ±Óû§É¾³ýÒ»¸öÂß¼­×ÖÌåʱ»áµ÷ÓÃdelete_instance¡£

    new_instance ¸ù¾Ý´«¸øËüµÄһЩ²ÎÊý£¨size£¬rotation£¬font_idµÈ£©³õʼ»¯Ò»¸öTYPE1INSTANCEINFOÀàÐ͵ıäÁ¿£¬²¢½«ÆäÓëеÄÉ豸×ÖÌå¹ØÁª£¬½«¸ÃÉ豸×ÖÌå·µ»Ø¡£ÒÔºóÉϲã¾Íͨ¹ý¸ÃÉ豸×ÖÌåµÃµ½×ÖÌåʵÀýÏà¹ØµÄÐÅÏ¢¡£

    delete_instance ÔòÓÃÀ´É¾³ýÏà¹ØµÄÊý¾Ý½á¹¹¡£


[Ŀ¼]


С½á

5 С½á

    ÃæÏò¶ÔÏó¼¼ÊõÔÚÈí¼þÉè¼Æµ±ÖÐÕ¼Óзdz£ÖØÒªµÄµØ룬µ«ÃæÏò¶ÔÏó²¢²»ÊÇ C++ µÈÓïÑÔµÄרÀû¡£Êµ¼ÊÉÏ£¬ÔÚÖîÈç²Ù×÷ϵͳµÈϵͳÈí¼þµ±ÖУ¬ÃæÏò¶ÔÏó¼¼ÊõµÄʹÓÃÊǷdz£¹ã·ºµÄ¡£ÀûÓà C ÓïÑÔʵÏÖÃæÏò¶ÔÏó¼¼Êõ£¬²»½ö½á¹¹ÇåÎú£¬¶øÇÒÔÚÖ´ÐÐЧÂʵȷ½ÃæÒ²ÓÐ C++ µÈÓïÑÔÎÞ·¨Ïà±ÈµÄÓÅÊÆ¡£´Ó±¾ÎÄÃèÊöµÄ×ÖÌåºÍ×Ö·û¼¯µÄʵÏÖµ±ÖÐÎÒÃÇ¿ÉÒÔ¿´µ½£¬²ÉÓÃÃæÏò¶ÔÏó¼¼Êõ£¬½«´ó´óÌá¸ßϵͳµÄÁé»îÐԺͿÉÀ©Õ¹ÐÔ¡£

    MiniGUI ×÷Ϊһ¸öÃæÏòʵʱǶÈëʽϵͳµÄͼÐÎÓû§½çÃæÖ§³Öϵͳ£¬¶ÔÆäÖ´ÐÐЧÂÊ¡¢¿É¶¨ÖÆ¡¢¿ÉÀ©Õ¹µÈ·½ÃæÓзdz£¸ßµÄÒªÇó¡£ÎªÁËÌá¸ßϵͳµÄÁé»îÐԺͿÉÀ©Õ¹ÐÔ£¬ÎÒÃÇÔÚһЩ¹Ø¼üÄ£¿éµ±ÖÐʹÓÃÁËÃæÏò¶ÔÏóµÄ¼¼Êõ¡£Êµ¼ù±íÃ÷£¬ÃæÏò¶ÔÏóµÄ¼¼ÊõÔÚ MiniGUI ÖеÄÔËÓÃÊdzɹ¦µÄ¡£


[Ŀ¼]


ͼÐγéÏó²ãºÍÊäÈë³éÏó²ã¼°NativeµÄʵÏÖ

    ±¾ÎÄÊÇ MiniGUI Ìåϵ½á¹¹ÏµÁÐÎÄÕµĵÚËÄƪ¡£Í¼ÐγéÏó²ã£¨GAL£©ºÍÊäÈë³éÏó²ã£¨IAL£©´ó´óÌá¸ßÁË MiniGUI µÄ¿ÉÒÆÖ²ÐÔ£¬²¢½«µ×²ãͼÐÎÉ豸ºÍÉϲã½Ó¿Ú·ÖÀ뿪À´¡£ÕâÀォÖصã½éÉÜ MiniGUI µÄ GAL ºÍ IAL ½Ó¿Ú£¬²¢ÒÔ×îÐ嵀 MiniGUI-Lite °æ±¾ÎªÀý£¬½éÉÜ»ùÓÚ Linux FrameBuffer µÄ Native ͼÐÎÒýÇæµÄʵÏÖ£¬ÒÔ¼°Ìض¨Ç¶ÈëʽϵͳÉÏÊäÈëÒýÇæµÄʵÏÖ¡£
[Ŀ¼]


ÒýÑÔ

1 ÒýÑÔ

ÔÚ MiniGUI 0.3.xx µÄ¿ª·¢ÖУ¬ÎÒÃÇÒýÈëÁËͼÐκÍÊäÈë³éÏó²ã£¨Graphics and Input Abstract Layer£¬GAL ºÍ IAL£©µÄ¸ÅÄî¡£³éÏó²ãµÄ¸ÅÄîÀàËÆ Linux ÄÚºËÐéÄâÎļþϵͳµÄ¸ÅÄî¡£Ëü¶¨ÒåÁËÒ»×é²»ÒÀÀµÓÚÈκÎÌØÊâÓ²¼þµÄ³éÏó½Ó¿Ú£¬ËùÓж¥²ãµÄͼÐβÙ×÷ºÍÊäÈë´¦Àí¶¼½¨Á¢ÔÚ³éÏó½Ó¿ÚÖ®ÉÏ¡£¶øÓÃÓÚʵÏÖÕâÒ»³éÏó½Ó¿ÚµÄµ×²ã´úÂë³ÆΪ¡°Í¼ÐÎÒýÇ桱»ò¡°ÊäÈëÒýÇ桱£¬ÀàËƲÙ×÷ϵͳÖеÄÇý¶¯³ÌÐò¡£Õâʵ¼ÊÊÇÒ»ÖÖÃæÏò¶ÔÏóµÄ³ÌÐò½á¹¹¡£ÀûÓà GAL ºÍ IAL£¬MiniGUI ¿ÉÒÔÔÚÐí¶àÒÑÓеÄͼÐκ¯Êý¿âÉÏÔËÐУ¬±ÈÈç SVGALib ºÍ LibGGI¡£²¢ÇÒ¿ÉÒԷdz£·½±ãµØ½« MiniGUI ÒÆÖ²µ½ÆäËû POSIX ϵͳÉÏ£¬Ö»ÐèÒª¸ù¾ÝÎÒÃǵijéÏó²ã½Ó¿ÚʵÏÖеÄͼÐÎÒýÇæ¼´¿É¡£±ÈÈ磬ÔÚ»ùÓÚ Linux µÄϵͳÉÏ£¬ÎÒÃÇ¿ÉÒÔÔÚ Linux FrameBuffer Çý¶¯³ÌÐòµÄ»ù´¡ÉϽ¨Á¢Í¨ÓÃµÄ MiniGUI ͼÐÎÒýÇ档ʵ¼ÊÉÏ£¬°üº¬ÔÚ MiniGUI 1.0.00 °æ±¾ÖеÄ˽ÓÐͼÐÎÒýÇ棨Native Engine£©¾ÍÊǽ¨Á¢ÔÚ FrameBuffer Ö®ÉϵÄͼÐÎÒýÇæ¡£Ò»°ã¶øÑÔ£¬»ùÓÚ Linux µÄǶÈëʽϵͳ¾ù»áÌṩ FrameBuffer Ö§³Ö£¬ÕâÑù˽ÓÐͼÐÎÒýÇæ¿ÉÒÔÔËÐÐÔÚÒ»°ãµÄ PC ÉÏ£¬Ò²¿ÉÒÔÔËÐÐÔÚÌض¨µÄǶÈëʽϵͳÉÏ¡£

Ïà±ÈͼÐÎÀ´½²£¬½« MiniGUI µÄµ×²ãÊäÈëÓëÉϲãÏà¸ôÏԵøüΪÖØÒª¡£ÔÚ»ùÓÚ Linux µÄǶÈëʽϵͳÖУ¬Í¼ÐÎÒýÇæ¿ÉÒÔͨ¹ý FrameBuffer ¶ø»ñµÃ£¬¶øÊäÈëÉ豸µÄ´¦ÀíȴûÓÐͳһµÄ½Ó¿Ú¡£ÔÚ PC ÉÏ£¬ÎÒÃÇͨ³£Ê¹ÓüüÅ̺ÍÊó±ê£¬¶øÔÚǶÈëʽϵͳÉÏ£¬¿ÉÄÜÖ»Óд¥ÃþÆÁºÍΪÊý²»¶àµÄ¼¸¸ö¼ü¡£ÔÚÕâÖÖÇé¿öÏ£¬Ìṩһ¸ö³éÏóµÄÊäÈë²ã£¬¾ÍÏԵøñÍâÖØÒª¡£

±¾ÎĽ«½éÉÜ MiniGUI µÄ GAL ºÍ IAL ½Ó¿Ú£¬²¢½éÉÜ˽ÓÐͼÐÎÒýÇæºÍÌض¨Ç¶ÈëʽϵͳϵÄÊäÈëÒýÇæʵÏÖ¡£


[Ŀ¼]


MiniGUIµÄGALºÍIAL¶¨Òå

2 MiniGUI µÄ GAL ºÍ IAL ¶¨Òå

GAL ºÍ IAL µÄ½á¹¹ÊÇÀàËƵģ¬ÎÒÃÇÒÔ GAL ΪÀý˵Ã÷ MiniGUI GAL ºÍ IAL ³éÏó²ãµÄ½á¹¹¡£

2.1 GAL ºÍͼÐÎÒýÇæ
²Î¼ûͼ 1¡£ÏµÍ³Î¬»¤Ò»¸öÒÑ×¢²áͼÐÎÒýÇæÊý×飬±£´æÿ¸öͼÐÎÒýÇæÊý¾Ý½á¹¹µÄÖ¸Õ롣ϵͳÀûÓÃÒ»¸öÖ¸Õë±£´æµ±Ç°Ê¹ÓõÄͼÐÎÒýÇæ¡£Ò»°ã¶øÑÔ£¬ÏµÍ³ÖÐÖÁÉÙÓÐÁ½¸öͼÐÎÒýÇ棬һ¸öÊÇ¡°ÑÆ¡±Í¼ÐÎÒýÇ棬²»½øÐÐÈκÎʵ¼ÊµÄͼÐÎÊä³ö£»Ò»¸öÊÇʵ¼ÊҪʹÓõÄͼÐÎÒýÇ棬±ÈÈç LibGGI »òÕß SVGALib£¬»òÕß Native Engine¡£Ã¿¸öͼÐÎÒýÇæµÄÊý¾Ý½á¹¹¶¨ÒåÁ˸ÃͼÐÎÒýÇæµÄһЩÐÅÏ¢£¬±ÈÈç±êʶ·û¡¢ÊôÐԵȣ¬¸üÖØÒªµÄÊÇ£¬ËüʵÏÖÁË GAL Ëù¶¨ÒåµÄ¸÷¸ö½Ó¿Ú£¬°üÀ¨³õʼ»¯ºÍÖÕÖ¹¡¢Í¼ÐÎÉÏÏÂÎĹÜÀí¡¢»­µã´¦Àíº¯Êý¡¢»­Ïß´¦Àíº¯Êý¡¢¾ØÐοòÌî³äº¯Êý¡¢µ÷É«°åº¯ÊýµÈµÈ¡£

Èç¹ûÔÚij¸öʵ¼ÊÏîÄ¿ÖÐËùʹÓõÄͼÐÎÓ²¼þ±È½ÏÌØÊ⣬ÏÖÓеÄͼÐÎÒýÇæ¾ù²»Ö§³Ö¡£Õâʱ£¬ÎÒÃǾͿÉÒÔ°²ÕÕ GAL Ëù¶¨ÒåµÄ½Ó¿ÚʵÏÖ×Ô¼ºµÄͼÐÎÒýÇ棬²¢Ö¸¶¨ MiniGUI ʹÓÃÕâÖÖ˽ÓеÄͼÐÎÒýÇæ¼´¿É¡£ÕâÖÖÈí¼þ¼¼Êõʵ¼Ê¾ÍÊÇÃæÏò¶ÔÏó¶à̬ÐԵľßÌåÌåÏÖ¡£

ÀûÓà GAL ºÍ IAL£¬´ó´óÌá¸ßÁË MiniGUI µÄ¿ÉÒÆÖ²ÐÔ£¬²¢ÇÒʹµÃ³ÌÐòµÄ¿ª·¢ºÍµ÷ÊÔ±äµÃ¸ü¼ÓÈÝÒס£ÎÒÃÇ¿ÉÒÔÔÚ X Window ÉÏ¿ª·¢ºÍµ÷ÊÔ×Ô¼ºµÄ MiniGUI ³ÌÐò£¬Í¨¹ýÖØбàÒë¾Í¿ÉÒÔÈà MiniGUI Ó¦ÓóÌÐòÔËÐÐÔÚÌØÊâµÄǶÈëʽӲ¼þƽ̨ÉÏ¡£

ÔÚ´úÂëʵÏÖÉÏ£¬MiniGUI ͨ¹ý GFX Êý¾Ý½á¹¹À´±íʾͼÐÎÒýÇ棬¼ûÇåµ¥ 1¡£

                         Çåµ¥ 1   MiniGUI ÖеÄͼÐÎÒýÇæ½á¹¹£¨src/include/gal.h£©

  55 typedef struct tagGFX
  56 {
  57     char*   id;
  58
  59     // Initialization and termination
  60     BOOL    (*initgfx) (struct tagGFX* gfx);
  61     void    (*termgfx) (struct tagGFX* gfx);
  62
  63     // Phisical graphics context
  64     GAL_GC  phygc;
  65     int     bytes_per_phypixel;
  66     int     bits_per_phypixel;
  67     int     width_phygc;
  68     int     height_phygc;
  69     int     colors_phygc;
  70     BOOL    grayscale_screen;
  71
  72     // GC properties
  73     int     (*bytesperpixel) (GAL_GC gc);
  74     int     (*bitsperpixel) (GAL_GC gc);
  75     int     (*width) (GAL_GC gc);
  76     int     (*height) (GAL_GC gc);
  77     int     (*colors) (GAL_GC gc);
  78
  79     // Allocation and release of graphics context
  80     int     (*allocategc) (GAL_GC gc, int width, int height, int depth,
  81                 GAL_GC* newgc);
  82     void    (*freegc) (GAL_GC gc);
  83     void    (*setgc) (GAL_GC gc);
  84
  85     // Clipping of graphics context
  86     void    (*enableclipping) (GAL_GC gc);
  87     void    (*disableclipping) (GAL_GC gc);
  88     int     (*setclipping) (GAL_GC gc, int x1, int y1, int x2, int y2);
  89     int     (*getclipping) (GAL_GC gc, int* x1, int* y1, int* x2, int* y2);
  90
  91     // Background and foreground colors
  92     int     (*getbgcolor) (GAL_GC gc, gal_pixel* color);
  93     int     (*setbgcolor) (GAL_GC gc, gal_pixel color);
  94     int     (*getfgcolor) (GAL_GC gc, gal_pixel* color);
  95     int     (*setfgcolor) (GAL_GC gc, gal_pixel color);
  96
  97     // Convertion between gal_color and gal_pixel
  98     gal_pixel (*mapcolor) (GAL_GC gc, gal_color *color);
  99     int     (*unmappixel) (GAL_GC gc, gal_pixel pixel, gal_color* color);
100     int     (*packcolors) (GAL_GC gc, void* buf, gal_color* colors, int len);
101     int     (*unpackpixels) (GAL_GC gc, void* buf, gal_color* colors, int len);
102
103     // Palette operations
104     int     (*getpalette) (GAL_GC gc, int s, int len, gal_color* cmap);
105     int     (*setpalette) (GAL_GC gc, int s, int len, gal_color* cmap);
106     int     (*setcolorfulpalette) (GAL_GC gc);
107
108     // Box operations
109     size_t  (*boxsize) (GAL_GC gc, int w, int h);
110     int     (*fillbox) (GAL_GC gc, int x, int y, int w, int h,
111                 gal_pixel pixel);
112     int     (*putbox) (GAL_GC gc, int x, int y, int w, int h, void* buf);
113     int     (*getbox) (GAL_GC gc, int x, int y, int w, int h, void* buf);
114     int     (*putboxmask) (GAL_GC gc, int x, int y, int w, int h, void* buf, gal_pixel cxx);
115     int     (*putboxpart) (GAL_GC gc, int x, int y, int w, int h, int bw,
116                 int bh, void* buf, int xo, int yo);
117     int     (*putboxwithop) (GAL_GC gc, int x, int y, int w, int h,
118                 void* buf, int raster_op);
119     int     (*scalebox) (GAL_GC gc, int sw, int sh, void* srcbuf,
120                 int dw, int dh, void* dstbuf);
121
122     int     (*copybox) (GAL_GC gc, int x, int y, int w, int h, int nx, int ny);
123     int     (*crossblit) (GAL_GC src, int sx, int sy, int sw, int sh,
124                 GAL_GC dst, int dx, int dy);
125
126     // Horizontal line operaions
127     int     (*drawhline) (GAL_GC gc, int x, int y, int w, gal_pixel pixel);
128     int     (*puthline)  (GAL_GC gc, int x, int y, int w, void* buf);
129     int     (*gethline)  (GAL_GC gc, int x, int y, int w, void* buf);
130
131     // Vertical line operations
132     int     (*drawvline) (GAL_GC gc, int x, int y, int h, gal_pixel pixel);
133     int     (*putvline)  (GAL_GC gc, int x, int y, int h, void* buf);
134     int     (*getvline)  (GAL_GC gc, int x, int y, int h, void* buf);
135
136     // Pixel operations
137     int     (*drawpixel) (GAL_GC gc, int x, int y, gal_pixel pixel);
138     int     (*putpixel) (GAL_GC gc, int x, int y, gal_pixel color);
139     int     (*getpixel) (GAL_GC gc, int x, int y, gal_pixel* color);
140
141     // Other drawing
142     int     (*circle) (GAL_GC gc, int x, int y, int r, gal_pixel pixel);
143     int     (*line) (GAL_GC gc, int x1, int y1, int x2, int y2,
144                 gal_pixel pixel);
145     int     (*rectangle) (GAL_GC gc, int l, int t, int r, int b,
146                 gal_pixel pixel);
147
148     // Simple Character output
149     int     (*putchar) (GAL_GC gc, int x, int y, char c);
150     int     (*putstr) (GAL_GC gc, int x, int y, const char* str);
151     int     (*getcharsize) (GAL_GC gc, int* width, int* height);
152     int     (*setputcharmode) (GAL_GC gc, int bkmode);
153     int     (*setfontcolors) (GAL_GC gc,
154                 gal_pixel fg, gal_pixel bg);
155
156     // Asynchronous mode support
157     void (*flush) (GAL_GC gc);
158     void (*flushregion) (GAL_GC gc, int x, int y, int w, int h);
159
160     // Panic
161     void (*panic) (int exitcode);
162
163 } GFX;
164
165 extern GFX* cur_gfx;

ϵͳÆô¶¯Ö®ºó£¬½«¸ù¾ÝÅäÖÃÑ°ÕÒÌض¨µÄͼÐÎÒýÇæ×÷Ϊµ±Ç°µÄͼÐÎÒýÇ棬²¢ÇÒ¶ÔÈ«¾Ö±äÁ¿ cur_gfx ¸³Öµ¡£Ö®ºó£¬µ± MiniGUI ÐèÒªÔÚÆÁÄ»ÉϽøÐлæÖÆÖ®ºó£¬µ÷Óõ±Ç°Í¼ÐÎÒýÇæµÄÏàÓ¦¹¦Äܺ¯Êý¡£±ÈÈ磬ÔÚ»­Ë®Æ½ÏßʱÈçϵ÷Óãº

(*cur_gfx->drawhline) (gc, x, y, w, pixel);

Ϊ·½±ã³ÌÐòÊéд£¬ÎÒÃÇ»¹¶¨ÒåÁËÈçÏ C ÓïÑԺ꣺

167 #define PHYSICALGC              (cur_gfx->phygc)
168 #define BYTESPERPHYPIXEL        (cur_gfx->bytes_per_phypixel)
169 #define BITSPERPHYPIXEL         (cur_gfx->bits_per_phypixel)
170 #define WIDTHOFPHYGC            (cur_gfx->width_phygc)
171 #define HEIGHTOFPHYGC           (cur_gfx->height_phygc)
172 #define COLORSOFPHYGC           (cur_gfx->colors_phygc)
173 #define GRAYSCALESCREEN         (cur_gfx->grayscale_screen)
174
175 #define GAL_BytesPerPixel       (*cur_gfx->bytesperpixel)
176 #define GAL_BitsPerPixel        (*cur_gfx->bitsperpixel)
177 #define GAL_Width               (*cur_gfx->width)
178 #define GAL_Height              (*cur_gfx->height)
179 #define GAL_Colors              (*cur_gfx->colors)
180
181 #define GAL_InitGfx             (*cur_gfx->initgfx)
182 #define GAL_TermGfx             (*cur_gfx->termgfx)
183
184 #define GAL_AllocateGC          (*cur_gfx->allocategc)
185 #define GAL_FreeGC              (*cur_gfx->freegc)
186
...
198
199 #define GAL_MapColor            (*cur_gfx->mapcolor)
200 #define GAL_UnmapPixel          (*cur_gfx->unmappixel)
201 #define GAL_PackColors          (*cur_gfx->packcolors)
202 #define GAL_UnpackPixels        (*cur_gfx->unpackpixels)
203
...
208 #define GAL_BoxSize             (*cur_gfx->boxsize)
209 #define GAL_FillBox             (*cur_gfx->fillbox)
210 #define GAL_PutBox              (*cur_gfx->putbox)
211 #define GAL_GetBox              (*cur_gfx->getbox)
212 #define GAL_PutBoxMask          (*cur_gfx->putboxmask)
213 #define GAL_PutBoxPart          (*cur_gfx->putboxpart)
214 #define GAL_PubBoxWithOp        (*cur_gfx->putboxwithop)
215 #define GAL_ScaleBox            (*cur_gfx->scalebox)
...
224 #define GAL_DrawVLine           (*cur_gfx->drawvline)
225 #define GAL_PutVLine            (*cur_gfx->putvline)
226 #define GAL_GetVLine            (*cur_gfx->getvline)

ÕâÑù£¬ÉÏÊö»­Ïߺ¯Êý¿ÉÒÔÈçÏÂÊéд£º

GAL_DrawVLine (gc, x, y, w, pixel);

ÏÔÈ»£¬Ö»ÒªÔÚϵͳ³õʼ»¯Ê±Äܹ»¸ù¾ÝÉ趨¶Ô cur_gfx ½øÐÐÊʵ±µÄ¸³Öµ£¬MiniGUI ¾ÍÄܹ»ÔÚÏàÓ¦µÄͼÐÎÒýÇæÖ®ÉϽøÐлæÖÆ¡£

¶Ôµ×²ãͼÐÎÒýÇæµÄµ÷Óã¬Ö÷Òª¼¯ÖÐÔÚ MiniGUI µÄ GDI º¯ÊýÖС£±ÈÈ磬Ҫ»æÖÆÒ»ÌõÖ±Ïߣ¬MiniGUI µÄ LineTo º¯Êý¶¨ÒåÈçÇåµ¥ 2 Ëùʾ£º

                           Çåµ¥ 2   LineTo º¯Êý£¨src/gdi/draw-lite.c£©

255 void GUIAPI LineTo (HDC hdc, int x, int y)
256 {
257     PCLIPRECT pClipRect;
258     PDC pdc;
259     RECT rcOutput;
260     int startx, starty;
261
262     pdc = dc_HDC2PDC(hdc);
263
264     if (dc_IsGeneralHDC(hdc)) {
265         if (!dc_GenerateECRgn (pdc, FALSE)) {
266             return;
267         }
268     }
269
270     // Transfer logical to device to screen here.
271     startx = pdc->CurPenPos.x;
272     starty = pdc->CurPenPos.y;
273
274     // Move the current pen pos.
275     pdc->CurPenPos.x = x;
276     pdc->CurPenPos.y = y;
277
278     coor_LP2SP(pdc, &x, &y);
279     coor_LP2SP(pdc, &startx, &starty);
280     rcOutput.left = startx - 1;
281     rcOutput.top  = starty - 1;
282     rcOutput.right = x + 1;
283     rcOutput.bottom = y + 1;
284     NormalizeRect(&rcOutput);
285
286     IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound);
287     if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput);
288
289     // set graphics context.
290     GAL_SetGC (pdc->gc);
291     GAL_SetFgColor (pdc->gc, pdc->pencolor);
292
293     pClipRect = pdc->ecrgn.head;
294     while(pClipRect)
295     {
296         if (DoesIntersect (&rcOutput, &pClipRect->rc)) {
297             GAL_SetClipping (pdc->gc, pClipRect->rc.left, pClipRect->rc.top,
298                     pClipRect->rc.right - 1, pClipRect->rc.bottom - 1);
299
300             if(starty == y) {
301                 if (startx > x)
302                     GAL_DrawHLine (pdc->gc, x, y, startx - x, pdc->pencolor);
303                 else
304                     GAL_DrawHLine (pdc->gc, startx, y, x - startx, pdc->pencolor);
305             }
306             else
307                 GAL_Line (pdc->gc, startx, starty, x, y, pdc->pencolor);
308         }
309
310         pClipRect = pClipRect->next;
311     }
312
313     if (!dc_IsMemHDC (hdc)) ShowCursorForGDI (TRUE, &rcOutput);
314 }

ÔÚ MiniGUI µÄËùÓлæͼº¯ÊýÖУ¬ÒªÒÀ´Î×öÈçϼ¸¼þÊ£º

½øÐÐÂß¼­×ø±êµ½É豸×ø±êµÄת»»£»
¼ì²éÊÇ·ñÓ¦¸ÃÖØÐÂÉú³ÉÓÐЧ¼ôÇÐÓò£»
¼ÆËãÊä³ö¾ØÐΣ¬²¢ÅжÏÊÇ·ñÒþ²ØÊó±ê£»
ÓÉÓڵײãÒýÇæÉв»Ö§³Ö¼ôÇÐÓò£¬Òò´Ë£¬¶Ô¼ôÇÐÓòÖеÄÿ¸ö¼ôÇоØÐΣ¬µ÷Óõײã»æͼº¯ÊýÊä³öÒ»´Î¡£
ÔÚÉÏÃæµÄËĸö²½Öèµ±ÖУ¬µÚ 3 ²½ºÍµÚ 4 ²½Êµ¼Ê¿ÉÒԷŵ½µ×²ãÒýÇæµ±ÖУ¬´Ó¶øÄܹ»´ó´óÌá¸ß MiniGUI µÄ»æͼЧÂÊ¡£²»¹ý£¬ÕâÖÖÐÔÄÜÉϵÄÌá¸ß£¬¶Ô¿éÊä³ö£¬±ÈÈçÌî³ä¾ØÐΡ¢Êä³öλͼÀ´½²£¬²¢²»ÊǷdz£Ã÷ÏÔ¡£ÔÚ½«À´µÄµ×²ãͼÐÎÒýÇæµ±ÖУ¬ÎÒÃǽ«Õë¶ÔÉÏÊöÁ½µã£¬½øÐнϴóµÄÓÅ»¯ÒÔÌá¸ßͼÐÎÊä³öЧÂÊ¡£

2.2 IAL ºÍÊäÈëÒýÇæ
ÈçÇ°ËùÊô£¬MiniGUI IAL ½á¹¹ºÍ GAL ½á¹¹ÀàËÆ¡£ÔÚ´úÂëʵÏÖÉÏ£¬MiniGUI ͨ¹ý INPUTÊý¾Ý½á¹¹À´±íʾÊäÈëÒýÇ棬¼ûÇåµ¥ 3¡£

                         Çåµ¥ 3   MiniGUI ÖеÄÊäÈëÒýÇæ½á¹¹£¨src/include/ial.h£©

  34 typedef struct tagINPUT
  35 {
  36     char*   id;
  37
  38     // Initialization and termination
  39     BOOL (*init_input) (struct tagINPUT *input, const char* mdev, const char* mtype);
  40     void (*term_input) (void);
  41
  42     // Mouse operations
  43     int  (*update_mouse) (void);
  44     int  (*get_mouse_x) (void);
  45     int  (*get_mouse_y) (void);
  46     void (*set_mouse_xy) (int x, int y);
  47     int  (*get_mouse_button) (void);
  48     void (*set_mouse_range) (int minx, int miny,int maxx,int maxy);
  49
  50     // Keyboard operations
  51     int  (*update_keyboard) (void);
  52     char* (*get_keyboard_state) (void);
  53         void (*suspend_keyboard) (void);
  54         void (*resume_keyboard) (void);
  55     void (*set_leds) (unsigned int leds);
  56
  57     // Event
  58 #ifdef _LITE_VERSION
  59     int (*wait_event) (int which, int maxfd, fd_set *in, fd_set *out, fd_set *except,
  60             struct timeval *timeout);
  61 #else
  62     int (*wait_event) (int which, fd_set *in, fd_set *out, fd_set *except,
  63             struct timeval *timeout);
  64 #endif
  65 }INPUT;
  66
  67 extern INPUT* cur_input;

ϵͳÆô¶¯Ö®ºó£¬½«¸ù¾ÝÅäÖÃÑ°ÕÒÌض¨µÄÊäÈëÒýÇæ×÷Ϊµ±Ç°µÄÊäÈëÒýÇ棬²¢ÇÒ¶ÔÈ«¾Ö±äÁ¿ cur_input ¸³Öµ¡£

(*cur_gfx->drawhline) (gc, x, y, w, pixel);

Ϊ·½±ã³ÌÐòÊéд£¬ÎÒÃÇ»¹¶¨ÒåÁËÈçÏ C ÓïÑԺ꣺

  69 #define IAL_InitInput           (*cur_input->init_input)
  70 #define IAL_TermInput           (*cur_input->term_input)
  71 #define IAL_UpdateMouse         (*cur_input->update_mouse)
  72 #define IAL_GetMouseX           (*cur_input->get_mouse_x)
  73 #define IAL_GetMouseY           (*cur_input->get_mouse_y)
  74 #define IAL_SetMouseXY          (*cur_input->set_mouse_xy)
  75 #define IAL_GetMouseButton      (*cur_input->get_mouse_button)
  76 #define IAL_SetMouseRange      (*cur_input->set_mouse_range)
  77
  78 #define IAL_UpdateKeyboard      (*cur_input->update_keyboard)
  79 #define IAL_GetKeyboardState    (*cur_input->get_keyboard_state)
  80 #define IAL_SuspendKeyboard             (*cur_input->suspend_keyboard)
  81 #define IAL_ResumeKeyboard              (*cur_input->resume_keyboard)
  82 #define IAL_SetLeds(leds)       if (cur_input->set_leds) (*cur_input->set_leds) (leds)
  83
  84 #define IAL_WaitEvent           (*cur_input->wait_event)

ÔÚ src/kernel/event.c ÖУ¬ÎÒÃÇÈçϵ÷ÓõײãµÄÊäÈëÒýÇ棬´Ó¶ø½«ÊäÈëÒýÇæµÄÊý¾Ýת»»Îª MiniGUI ÉϲãÄܹ»Àí½âµÄÏûÏ¢£¨ÒÔ MiniGUI-Lite ΪÀý£©£¬¼ûÇåµ¥ 4£º

                   Çåµ¥ 4   MiniGUI ¶Ôµ×²ãÊäÈëʼþµÄ´¦Àí

172 #ifdef _LITE_VERSION
173 BOOL GetLWEvent (int event, PLWEVENT lwe)
174 {
175     static LWEVENT old_lwe = {0, 0};
176     unsigned int interval;
177     int button;
178     PMOUSEEVENT me = &(lwe->data.me);
179     PKEYEVENT ke = &(lwe->data.ke);
180     unsigned char* keystate;
181     int i;
182     int make;       /* 0 = release, 1 = presse */
183
184     if (event == 0) {
185         if (timer_counter >= timeout_count) {
186
187             timeout_count = timer_counter + repeat_threshold;
188
189             // repeat last event
190             if (old_lwe.type == LWETYPE_KEY
191                     && old_lwe.data.ke.event == KE_KEYDOWN) {
192                 memcpy (lwe, &old_lwe, sizeof (LWEVENT));
193                 lwe->data.ke.status |= KE_REPEATED;
194                 return 1;
195             }
196
197             if (!(old_lwe.type == LWETYPE_MOUSE
198                     && (old_lwe.data.me.event == ME_LEFTDOWN ||
199                         old_lwe.data.me.event == ME_RIGHTDOWN ||
200                         old_lwe.data.me.event == ME_MIDDLEDOWN))) {
201                 // reset delay time
202                 timeout_count = timer_counter + timeout_threshold;
203             }
204
205             // reset delay time
206             lwe->type = LWETYPE_TIMEOUT;
207             lwe->count = timer_counter;
208             return 1;
209         }
210         return 0;
211     }
212
213     timeout_count = timer_counter + timeout_threshold;
214     // There was a event occurred.
215     if (event & IAL_MOUSEEVENT) {
216         lwe->type = LWETYPE_MOUSE;
217         if (RefreshCursor(&me->x, &me->y, &button)) {
218             me->event = ME_MOVED;
219             time1 = 0;
220             time2 = 0;
221
222             if (oldbutton == button)
223                 return 1;
224         }
225
226         if ( !(oldbutton & IAL_MOUSE_LEFTBUTTON) &&
227               (button & IAL_MOUSE_LEFTBUTTON) )
228         {
229             if (time1) {
230                 interval = timer_counter - time1;
231                 if (interval <= dblclicktime)
232                     me->event = ME_LEFTDBLCLICK;
233                 else
234                     me->event = ME_LEFTDOWN;
235                 time1 = 0;
236             }
237             else {
238                 time1 = timer_counter;
239                 me->event = ME_LEFTDOWN;
240             }
241             goto mouseret;
242         }
243
244         if ( (oldbutton & IAL_MOUSE_LEFTBUTTON) &&
245              !(button & IAL_MOUSE_LEFTBUTTON) )
246         {
247             me->event = ME_LEFTUP;
248             goto mouseret;
249         }
250
251         if ( !(oldbutton & IAL_MOUSE_RIGHTBUTTON) &&
252               (button & IAL_MOUSE_RIGHTBUTTON) )
253         {
254             if (time2) {
255                 interval = timer_counter - time2;
256                 if (interval <= dblclicktime)
257                     me->event = ME_RIGHTDBLCLICK;
258                 else
259                     me->event = ME_RIGHTDOWN;
260                 time2 = 0;
261             }
262             else {
263                 time2 = timer_counter;
264                 me->event = ME_RIGHTDOWN;
265             }
266             goto mouseret;
267         }
268
269         if ( (oldbutton & IAL_MOUSE_RIGHTBUTTON) &&
270             !(button & IAL_MOUSE_RIGHTBUTTON) )
271         {
272             me->event = ME_RIGHTUP;
273             goto mouseret;
274         }
275     }
276
277     if(event & IAL_KEYEVENT) {
278         lwe->type = LWETYPE_KEY;
279         keystate = IAL_GetKeyboardState ();
280         for(i = 0; i < NR_KEYS; i++) {
281             if(!oldkeystate[i] && keystate[i]) {
282                  ke->event = KE_KEYDOWN;
283                  ke->scancode = i;
284                  olddownkey = i;
285                  break;
286             }
287             if(oldkeystate[i] && !keystate[i]) {
288                  ke->event = KE_KEYUP;
289                  ke->scancode = i;
290                  break;
291             }
292         }
293         if (i == NR_KEYS) {
294             ke->event = KE_KEYDOWN;
295             ke->scancode = olddownkey;
296         }
297
298         make = (ke->event == KE_KEYDOWN)?1:0;
299
300         if (i != NR_KEYS) {
301             unsigned leds;
302
303             switch (ke->scancode) {
304                 case SCANCODE_CAPSLOCK:
305                     if (make && caps_off) {
306                         capslock = 1 - capslock;
307                         leds = slock | (numlock << 1) | (capslock << 2);
308                         IAL_SetLeds (leds);
309                         status = (DWORD)leds << 16;
310                     }
311                     caps_off = 1 - make;
312                 break;
313
314                 case SCANCODE_NUMLOCK:
315                     if (make && num_off) {
316                         numlock = 1 - numlock;
317                         leds = slock | (numlock << 1) | (capslock << 2);
318                         IAL_SetLeds (leds);
319                         status = (DWORD)leds << 16;
320                     }
321                     num_off = 1 - make;
322                 break;
323
324                 case SCANCODE_SCROLLLOCK:
325                     if (make & slock_off) {
326                         slock = 1 - slock;
327                         leds = slock | (numlock << 1) | (capslock << 2);
328                         IAL_SetLeds (leds);
329                         status = (DWORD)leds << 16;
330                     }
331                     slock_off = 1 - make;
332                     break;
333
334                 case SCANCODE_LEFTCONTROL:
335                     control1 = make;
336                     break;
337
338                 case SCANCODE_RIGHTCONTROL:
339                     control2 = make;
340                     break;
341
342                 case SCANCODE_LEFTSHIFT:
343                     shift1 = make;
344                     break;
345
346                 case SCANCODE_RIGHTSHIFT:
347                     shift2 = make;
348                     break;
349
350                 case SCANCODE_LEFTALT:
351                     alt1 = make;
352                     break;
353
354                 case SCANCODE_RIGHTALT:
355                     alt2 = make;
356                     break;
357
358             }
359
360             status &= 0xFFFFF0C0;
361
362             status |= (DWORD)((capslock << 8) |
363                              (numlock << 7)   |
364                              (slock << 6)     |
365                              (control1 << 5)  |
366                              (control2 << 4)  |
367                              (alt1 << 3)      |
368                              (alt2 << 2)      |
369                              (shift1 << 1)    |
370                              (shift2));
371
372             // Mouse button status
373             if (oldbutton & IAL_MOUSE_LEFTBUTTON)
374                 status |= 0x00000100;
375             else if (oldbutton & IAL_MOUSE_RIGHTBUTTON)
376                 status |= 0x00000200;
377         }
378         ke->status = status;
379         SHAREDRES_SHIFTSTATUS = status;
380         memcpy (oldkeystate, keystate, NR_KEYS);
381         memcpy (&old_lwe, lwe, sizeof (LWEVENT));
382         return 1;
383     }
384
385     old_lwe.type = 0;
386     return 0;
387
388 mouseret:
389     status &= 0xFFFFF0FF;
390     oldbutton = button;
391     if (oldbutton & IAL_MOUSE_LEFTBUTTON)
392         status |= 0x00000100;
393     if (oldbutton & IAL_MOUSE_RIGHTBUTTON)
394         status |= 0x00000200;
395     me->status = status;
396     SHAREDRES_SHIFTSTATUS = status;
397     memcpy (&old_lwe, lwe, sizeof (LWEVENT));
398     return 1;
399 }
#endif

´ÓÕâ¶Î´úÂëÖпÉÒÔ¿´³ö£¬¶Ô¶¨µãÉ豸À´½²£¬±ÈÈçÊó±ê»òÕß´¥ÃþÆÁ£¬MiniGUI Äܹ»×Ô¶¯Ê¶±ðÒƶ¯ÐÅÏ¢£¬Ò²Äܹ»×Ô¶¯Ê¶±ðÓû§µÄµ¥»÷ºÍË«»÷ʼþ¡£ÕâÑù£¬µ×²ãÒýÇæÖ»ÐèÌṩλÖÃÐÅÏ¢ºÍµ±Ç°µÄ°´¼ü״̬ÐÅÏ¢¾Í¿ÉÒÔÁË¡£¶ÔÀàËƼüÅ̵Ķ«Î÷£¬MiniGUI Ò²Äܹ»×Ô¶¯½øÐÐÖظ´´¦Àí¡£µ±Ò»¸ö°´¼ü°´ÏÂÒ»¶Îʱ¼äÖ®ºó£¬MiniGUI ½«Á¬Ðø·¢Ë͸ð´¼üµÄÏûÏ¢¸øÉϲ㴦Àí¡£¶ÔÌض¨µÄǶÈëʽϵͳÀ´½²£¬¿ÉÒÔ½«Ä³Ð©°´¼üÓ³ÉäΪ PC µÄijЩ¼üÅ̼ü£¬ÉϲãÖ»Ðè´¦ÀíÕâЩ¼üÅ̼üÏûÏ¢µÄ°´ÏºÍÊͷż´¿É¡£ÕâÑù£¬Ç¶ÈëʽϵͳÉϵÄijЩ¼üµÄ¹¦ÄܾͿÉÒÔÔÚ PC ÉϽøÐÐÄ£ÄâÁË¡£

[Ŀ¼]


NativeͼÐÎÒýÇæµÄʵÏÖ

3 Native ͼÐÎÒýÇæµÄʵÏÖ

Native ͼÐÎÒýÇæµÄͼÐÎÇý¶¯³ÌÐòÒѾ­ÌṩÁË»ùÓÚLinuxÄÚºËÌṩFrameBufferÖ®ÉϵÄÇý¶¯£¬Ä¿Ç°°üÀ¨¶ÔÏßÐÔ 2 bpp¡¢4bpp¡¢8bppºÍ 16bpp ÏÔʾģʽµÄÖ§³Ö¡£Ç°ÃæÒѾ­¿´µ½£¬GALÌṩµÄ½Ó¿Úº¯Êý´ó¶àÊýÓëͼÐÎÏà¹Ø£¬ËüÃÇÖ÷Òª¾ÍÊÇͨ¹ýµ÷ÓÃͼÐÎÇý¶¯³ÌÐòÀ´Íê³ÉÈÎÎñµÄ¡£Í¼ÐÎÇý¶¯³ÌÐòÆÁ±ÎÁ˵ײãÇý¶¯µÄϸ½Ú£¬Íê³Éµ×²ãÇý¶¯Ïà¹ØµÄ¹¦ÄÜ£¬¶ø²»ÊÇÄÇôӲ¼þÏà¹ØµÄһЩ¹¦ÄÜ£¬ÈçһЩ»­Ô²£¬»­ÏßµÄGDI º¯Êý¡£

ÏÂÃæ»ùÓÚÒѾ­ÊµÏֵĻùÓÚFrameBuffer µÄÇý¶¯³ÌÐò£¬½²Ò»Ð©ÊµÏÖÉϵÄϸ½Ú¡£Ê×ÏÈÁгöµÄºËÐÄÊý¾Ý½á¹¹ SCREENDEVICE¡£ÕâÀïÖ÷ÒªÊÇΪÁ˽²½â·½±ã£¬ËùÒÔɾ³ýÁËһЩ´ÎÒªµÄ±äÁ¿»òÕߺ¯Êý¡£

                              Çåµ¥ 5  Native ͼÐÎÒýÇæµÄºËÐÄÊý¾Ý½á¹¹

typedef struct _screendevice {
    int xres;       /* X screen res (real) */
    int yres;       /* Y screen res (real) */
    int planes;     /* # planes*/
    int bpp;        /* # bits per pixel*/
    int linelen;    /* line length in bytes for bpp 1,2,4,8, line length in pixels for bpp 16, 24, 32*/
    int size;       /* size of memory allocated*/
    gfx_pixel gr_foreground;      /* current foreground color */
    gfx_pixel gr_background;      /* current background color */
    int     gr_mode;
    int flags;      /* device flags*/
    void *  addr;       /* address of memory allocated (memdc or fb)*/

    PSD (*Open)(PSD psd);
    void    (*Close)(PSD psd);
    void    (*SetPalette)(PSD psd,int first,int count,gfx_color *cmap);
    void    (*GetPalette)(PSD psd,int first,int count,gfx_color *cmap);
    PSD (*AllocateMemGC)(PSD psd);
    BOOL    (*MapMemGC)(PSD mempsd,int w,int h,int planes,int bpp, int linelen,int size,void *addr);
    void    (*FreeMemGC)(PSD mempsd);
    void    (*FillRect)(PSD psd,int x,int y,int w,int h,gfx_pixel c);
    void     (*DrawPixel)(PSD psd, int x, int y, gfx_pixel c);
    gfx_pixel (*ReadPixel)(PSD psd, int x, int y);
    void    (*DrawHLine)(PSD psd, int x, int y, int w, gfx_pixel c);
    void    (*PutHLine) (GAL gal, int x, int y, int w, void* buf);
    void    (*GetHLine) (GAL gal, int x, int y, int w, void* buf);
    void    (*DrawVLine)(PSD psd, int x, int y, int w, gfx_pixel c);
    void    (*PutVLine) (GAL gal, int x, int y, int w, void* buf);
    void    (*GetVLine) (GAL gal, int x, int y, int w, void* buf);
    void (*Blit)(PSD dstpsd, int dstx, int dsty, int w, int h, PSD srcpsd, int srcx, int srcy);
    void    (*PutBox)( GAL gal, int x, int y, int w, int h, void* buf );
    void    (*GetBox)( GAL gal, int x, int y, int w, int h, void* buf );
    void    (*PutBoxMask)( GAL gal, int x, int y, int w, int h, void *buf);
    void    (*CopyBox)(PSD psd,int x1, int y1, int w, int h, int x2, int y2);
} SCREENDEVICE;

ÉÏÃæPSD ÊÇ SCREENDEVICE µÄÖ¸Õ룬GAL ÊÇGAL ½Ó¿ÚµÄÊý¾Ý½á¹¹¡£

ÎÒÃÇÖªµÀ£¬Í¼ÐÎÏÔʾÓиöÏÔʾģʽµÄ¸ÅÄһ¸öÏñËØ¿ÉÒÔÓÃһλ±ÈÌرíʾ£¬Ò²¿ÉÒÔÓÃ2£¬4£¬8£¬15£¬16£¬24£¬32¸ö±ÈÌرíʾ£¬ÁíÍ⣬VGA16±ê׼ģʽʹÓÃƽÃæͼÐÎģʽ£¬¶øVESA2.0ʹÓõÄÊÇÏßÐÔͼÐÎģʽ¡£ËùÒÔ¼´Ê¹ÊÇͬÑù»ùÓÚFramebuffer µÄÇý¶¯£¬²»Í¬µÄģʽҲҪʹÓò»Í¬µÄÇý¶¯º¯Êý£º»­Ò»¸ö1±ÈÌصĵ¥É«µãºÍ»­Ò»¸ö24λµÄÕæ²ÊµãÏÔÈ»ÊDz»Ò»ÑùµÄ¡£

ËùÒÔͼÐÎÇý¶¯³ÌÐòʹÓÃÁË×ÓÇý¶¯³ÌÐòµÄ¸ÅÄîÀ´Ö§³Ö¸÷ÖÖ²»Í¬µÄÏÔʾģʽ£¬ÊÂʵÉÏ£¬ËüÃDzÅÊÇ×îÖյŦÄܺ¯Êý¡£ÎªÁ˱£³ÖÊý¾Ý½á¹¹ÔÚ²ã´ÎÉϲ»ÖÁÓںܸ´ÔÓ£¬ÎÒÃÇͨ¹ýͼÐÎÇý¶¯³ÌÐòµÄ³õʼº¯ÊýOpenÖ±½Ó½«×ÓÇý¶¯³ÌÐòµÄ¸÷¹¦Äܺ¯Êý¸³µ½Í¼ÐÎÇý¶¯³ÌÐòµÄ½Ó¿Úº¯ÊýÖ¸Õ룬´Ó¶ø³õʼ»¯½áÊø¾ÍʹÓÃÒ»¸ö¼òµ¥µÄͼÐÎÇý¶¯½Ó¿Ú¡£ÏÂÃæÊÇ×ÓͼÐÎÇý¶¯³ÌÐò½Ó¿Ú£¨Çåµ¥ 6£©¡£

                     Çåµ¥ 6  Native ͼÐÎÒýÇæµÄ×ÓÇý¶¯³ÌÐò½Ó¿Ú

typedef struct {
    int  (*Init)(PSD psd);
    void     (*DrawPixel)(PSD psd, int x, int y, gfx_pixel c);
    gfx_pixel (*ReadPixel)(PSD psd, int x, int y);
    void    (*DrawHLine)(PSD psd, int x, int y, int w, gfx_pixel c);
    void    (*PutHLine) (GAL gal, int x, int y, int w, void* buf);
    void    (*GetHLine) (GAL gal, int x, int y, int w, void* buf);
    void    (*DrawVLine)(PSD psd, int x, int y, int w, gfx_pixel c);
    void    (*PutVLine) (GAL gal, int x, int y, int w, void* buf);
    void    (*GetVLine) (GAL gal, int x, int y, int w, void* buf);
    void (*Blit)(PSD dstpsd, int dstx, int dsty, int w, int h, PSD srcpsd, int srcx, int srcy);
    void    (*PutBox)( GAL gal, int x, int y, int w, int h, void* buf );
    void    (*GetBox)( GAL gal, int x, int y, int w, int h, void* buf );
    void    (*PutBoxMask)( GAL gal, int x, int y, int w, int h, void *buf);
    void    (*CopyBox)(PSD psd,int x1, int y1, int w, int h, int x2, int y2);
} SUBDRIVER, *PSUBDRIVER;

¿ÉÒÔ¿´µ½£¬¸Ã½Ó¿ÚÖгýÁË Init º¯ÊýÖ¸ÕëÍ⣬ÆäËûµÄº¯ÊýÖ¸Õ붼ÓëͼÐÎÇý¶¯³ÌÐò½Ó¿ÚÖеĺ¯ÊýÖ¸ÕëÒ»Ñù¡£ÕâÀïµÄInit º¯ÊýÖ÷ÒªÓÃÀ´Íê³ÉͼÐÎÇý¶¯²¿·ÖÓëÏÔʾģʽÏà¹ØµÄ³õʼ»¯ÈÎÎñ¡£

ÏÂÃæ½éÉÜSCREENDEVICEÊý¾Ý½á¹¹£¬ÕâÑù»ù±¾ÉϾͿÉÒÔÇå³þͼÐÎÒýÇæÁË¡£

Ò»¸öSCREENDEVICE´ú±íÒ»¸öÆÁÄ»É豸£¬Ëü¼´¿ÉÒÔ¶ÔÓ¦ÎïÀíÆÁÄ»É豸£¬Ò²¿ÉÒÔ¶ÔÓ¦Ò»¸öÄÚ´æÆÁÄ»É豸£¬ÄÚ´æÆÁÄ»É豸µÄ´æÔÚÖ÷ÒªÊÇΪÁËÌá¸ßGDI ÖÊÁ¿£¬±ÈÈçÎÒÃÇÏÈÔÚÄÚ´æÉú³ÉÒ»·ùλͼ£¬ÔÙ»­µ½ÆÁÄ»ÉÏ£¬ÕâÑù¸øÓû§µÄÊÓ¾õЧ¹û¾Í±È½ÏºÃ¡£

Ê×ÏȽéÉܼ¸¸ö±äÁ¿¡£

xres ±íʾÆÁÄ»µÄ¿í (ÒÔÏñËØΪµ¥Î»)£»
yres ±íʾÆÁÄ»µÄ¸ß (ÒÔÏñËØΪµ¥Î»)£»
planes £ºµ±´¦ÓÚƽÃæÏÔʾģʽʱ£¬planes ÓÃÓڼǼËùʹÓõÄƽÃæÊý£¬ÈçƽÃæģʽÏà¶ÔµÄʱÏßÐÔģʽ£¬´Ëʱ¸Ã±äÁ¿Ã»ÓÐÒâÒ塣ͨ³£½«ÆäÖÃΪ0¡£
bpp £º±íʾÿ¸öÏñËØËùʹÓõıÈÌØÊý£¬¿ÉÒÔΪ1£¬2£¬4£¬8£¬15£¬16£¬24£¬32¡£
linelen £º¶ÔÓë1£¬2£¬4£¬8±ÈÌØÿÏñËØģʽ£¬Ëü±íʾһÐÐÏñËØʹÓõÄ×Ö½ÚÊý£¬¶ÔÓÚ´óÓÚ8±ÈÌØÿÏñËØģʽ£¬Ëü±íʾһÐеÄÏñËØ×ÜÊý¡£
size £º±íʾ¸ÃÏÔʾģʽϸÃÉ豸ʹÓõÄÄÚ´æÊý¡£linelen ºÍ size µÄ´æÔÚÖ÷ÒªÊÇΪÁË·½±ãΪÄÚ´æÆÁÄ»É豸·ÖÅäÄÚ´æ¡£
gr_foreground ºÍ gr_background £º±íʾ¸ÃÄÚ´æÆÁÄ»µÄÇ°¾°ÑÕÉ«ºÍ±³¾°ÑÕÉ«£¬Ö÷Òª±»Ò»Ð©GDI º¯ÊýʹÓá£
gr_mode £ºËµÃ÷ÈçºÎ½«ÏñËØ»­µ½ÆÁÄ»ÉÏ£¬¿ÉѡֵΪ£ºMODE_SET MODE_XOR MODE_OR MODE_AND MODE_MAX,±È½Ï³£ÓõÄÊÇMODE_SETºÍMODE_XOR
flags £º¸ÃÆÁÄ»É豸µÄһЩѡÏ±È½ÏÖØÒªµÄÊÇ PSF_MEMORY ±êÖ¾£¬±íʾ¸ÃÆÁÄ»É豸´ú±íÎïÀíÆÁÄ»É豸»¹ÊÇÒ»¸öÄÚ´æÆÁÄ»É豸¡£
addr £ºÃ¿¸öÆÁÄ»É豸¶¼ÓÐÒ»¿éÄÚ´æ¿Õ¼äÓÃÀ´×÷Ϊ´æ´¢ÏñËØ¡£addr ±äÁ¿¼Ç¼ÁËÕâ¸ö¿Õ¼äµÄÆðʼµØÖ·¡£
ÏÂÃæ½éÉܸ÷½Ó¿Úº¯Êý£º

Open£¬Close
»ù±¾µÄ³õʼ»¯ºÍÖսắÊý¡£Ç°ÃæÒѾ­Ìáµ½£¬ÔÚ Open º¯ÊýÀïҪѡÔñ×ÓͼÐÎÇý¶¯³ÌÐò£¬½«ÆäʵÏֵĺ¯Êý¸³¸ø±¾ PSD ½á¹¹µÄº¯ÊýÖ¸Õë¡£ÕâÀïÎÒ½²½²»ùÓÚFrambebuffer µÄͼÐÎÒýÇæµÄ³õʼ»¯¡£

fb_open Ê×ÏÈ´ò¿ªFramebufferµÄÉ豸Îļþ /dev/fb0£¬È»ºóÀûÓà ioctl ¶Á³öµ±Ç°FramebufferµÄ¸÷ÖÖÐÅÏ¢¡£Ìî³äµ½PSD ½á¹¹ÖС£²¢ÇÒ¸ù¾ÝÕâЩÐÅϢѡ³ö×ÓÇý¶¯³ÌÐò¡£³ÌÐòµ±Ç°Ö§³Öfbvga16£¬fblin16£¬fblin8£¬¼´VGA16 ±ê׼ģʽ£¬VESAÏßÐÔ16λģʽ£¬VESAÏßÐÔ8λģʽ¡£È»ºó½«µ±Ç°ÖÕ¶ËģʽÖÃÓÚͼÐÎģʽ¡£²¢±£´æµ±Ç°µÄһЩϵͳÐÅÏ¢Èçµ÷É«°åÐÅÏ¢¡£×îºó£¬ÏµÍ³ÀûÓÃmmap ½« /dev/fb0 Ó³Éäµ½ÄÚ´æµØÖ·¡£ÒÔºó³ÌÐò·ÃÎÊ /dev/fb0 ¾ÍÏñ·ÃÎÊÒ»¸öÊý×éÒ»Ñù¼òµ¥¡£µ±È»£¬ÕâÊǶÔÏßÐÔģʽ¶øÑԵģ¬Èç¹ûÊÇƽÃæģʽ£¬ÎÊÌâÒª¸´ÔӵĶࡣ¹â´Ó´úÂëÀ´¿´£¬Æ½ÃæģʽµÄ´úÂëÊÇÏßÐÔģʽµÄʵÏֵĽ«½üÒ»±¶¡£ºóÃæµÄÄѵã·ÖÎöÀォ½²½âÕâ¸öÎÊÌâ¡£

SetPalette£¬GetPalette
µ±Ê¹ÓÃ8λ»òÒÔϵÄͼÐÎģʽʱ£¬ÒªÊ¹ÓÃϵͳµ÷É«°å¡£ÕâÀïÊǵ÷É«°å´¦Àíº¯Êý£¬ËüÃǺÍWindows API ÖеĸÅÄîÀàËÆ£¬linux ϵͳÀûÓà ioctl ÌṩÁË´¦Àíµ÷É«°åµÄ½Ó¿Ú¡£

AllocateMemGC£¬MapMemGC£¬FreeMemGC
Ç°ÃæÂÅ´ÎÌáµ½ÄÚ´æÆÁÄ»µÄ¸ÅÄÄÚ´æÆÁÄ»ÊÇÒ»¸öαÆÁÄ»£¬ÔÚ¶ÔÆÁĻͼÐβÙ×÷¹ý³ÌÖУ¬±ÈÈçÒƶ¯´°¿Ú£¬ÎÒÃÇÏÈÉú³ÉÒ»¸öÄÚ´æÆÁÄ»£¬½«ÎïÀíÆÁÄ»µÄÒ»¸öÇøÓò¿½±´µ½ÄÚ´æÆÁÄ»£¬ÔÙ¿½±´µ½ÎïÀíÆÁÄ»µÄÐÂλÖã¬ÕâÑù¾Í¼õÉÙÁËÆÁĻֱ½Ó¿½±´µÄÑÓʱ¡£AllocateMemGC ÓÃÓÚ¸øÄÚ´æÆÁÄ»·ÖÅä¿Õ¼ä£¬MapMemGC ×öһЩ³õʼ»¯¹¤×÷£¬¶øFreeMemGC ÔòÊÍ·ÅÄÚ´æÆÁÄ»¡£

DrawPixel£¬ReadPixel£¬DrawHLine£¬DrawVLine£¬FillRect
ÕâЩÊǵײãͼÐκ¯Êý¡£·Ö±ðÊÇ»­µã£¬¶Áµã£¬»­Ë®Æ½Ïߣ¬»­ÊúÖ±Ïߣ¬»­Ò»¸öʵÐľØÐΡ£Ö®ËùÒÔÔڵײãʵÏÖÕâô¶àº¯Êý£¬ÊÇΪÁËÌá¸ßЧÂÊ¡£Í¼Ðκ¯ÊýÖ§³Ö¶àÖÖ»­Í¼Ä£Ê½£¬³£ÓõÄÓÐÖ±½ÓÉèÖã¬Òà»ò£¬Alpha»ìºÏģʽ£¬´Ó¶ø¿ÉÒÔÖ§³Ö¸÷ÖÖͼÐÎЧ¹û¡£

PutHLine£¬GetHLine£¬PutVLine£¬GetVLine£¬PutBox£¬GetBox£¬PutBoxMask
Get* º¯ÊýÓÃÓÚ´ÓÆÁÄ»¿½±´ÏñËص½Ò»¿éÄÚ´æÇø£¬¶øPut*º¯ÊýÓÃÓÚ½«´æ·ÅÓÚÄÚ´æÇøµÄÏñËØ»­µ½ÆÁÄ»ÉÏ¡£PutBoxMask ÓëPutBoxµÄΨһÇø±ðÊÇÒª»­µÄÏñËØÈç¹ûÊÇ°×É«£¬¾Í²»»á±»»­µ½ÆÁÄ»ÉÏ£¬´Ó¶ø´ïµ½Ò»ÖÖ͸Ã÷µÄЧ¹û¡£

´ÓÉÏÃæ¿ÉÒÔ¿´µ½£¬ÕâЩº¯ÊýµÄµÚÒ»¸ö²ÎÊýÊÇGALÀàÐͶø²»ÊÇPSDÀàÐÍ£¬ÕâÊÇÒòΪËüÃÇÐèÒªGAL²ãµÄÐÅÏ¢ÒÔ±ãÔÚº¯ÊýÄÚ²¿ÊµÏÖ¼ôÇй¦ÄÜ¡£Ö®ËùÒÔ²»ºÍÆäËûº¯ÊýÒ»ÑùÔÚÉϲãʵÏÖ¼ôÇУ¬ÊÇÒòΪÕâÀïµÄ¼ôÇбȽÏÌØÊâ¡£±ÈÈçPutBox,

ÔÚ¼ôÇÐÊä³öÓòʱ£¬ÒªÍ¬Ê±¼ôÇÐÔÚ»º³åÖдýÊä³öµÄÏñËØ£º³¬³ö¼ôÇÐÓòµÄÏñËز»Ó¦¸Ã±»Êä³ö¡£ËùÒÔ£¬¼ôÇÐÒѾ­²»µ¥´¿ÊǶÔÏߣ¬¾ØÐεÈGDI¶ÔÏóµÄ¼ôÇС£¶ÔÏñËصļôÇе±È»ÐèÒªÖªµÀÏñËصĸñʽ£¬ÕâЩֻÊÇΪµ×²ãËùÓУ¬ËùÒÔΪÁËʵÏÖ¸ßЧµÄ¼ôÇУ¬ÎÒÃÇÑ¡ÔñÔڵײãʵÏÖËüÃÇ¡£ÕâÀïËùÓеĺ¯Êý¶¼ÓÐÁ½¸ö²¿·Ö£ºÏÈÊǼôÇУ¬ÔÙÊǶÁ»òÕßдÏñËØ¡£

Blit£¬CopyBox
Blit ÓÃÓÚÔÚ²»Í¬µÄÆÁÄ»É豸(ÎïÀíµÄ»òÕßÄÚ´æµÄ)Ö®¼ä¿½±´Ò»¿éÏñËص㣬CopyBoxÔòÓÃÓÚÔÚͬһÆÁÄ»ÉÏʵÏÖÇøÓòÏñËصĿ½±´¡£Èç¹ûʹÓõÄÊÇÏßÐÔģʽ£¬BlitµÄʵÏַdz£¼òµ¥£¬Ö±½Ómemcpy ¾Í¿ÉÒÔÁË£¬¶øCopyBox ΪÁË·ÀÖ¹¸²¸ÇÎÊÌ⣬±ØÐë¸ù¾Ý²»Í¬µÄÇé¿ö£¬²ÉÓò»Í¬µÄ¿½±´·½Ê½£¬±ÈÈç´Óµ×µ½¶¥µ×¿½±´£¬µ±ÐÂÀÏλÖÃÔÚͬһˮƽλÖò¢ÇÒÖظ´Ê±£¬ÔòÐèÒªÀûÓûº³å¼ä½Ó¿½±´¡£Èç¹ûʹÓÃƽÃæÏÔʾģʽ£¬ÕâÀï¾Í±È½Ï¸´ÔÓÁË¡£ÒòΪÄÚ´æÉ豸×ÜÊDzÉÓÃÏßÐÔģʽµÄ£¬ËùÒÔ¾ÍÒªÅжÏÊÇÎïÀíÉ豸»¹ÊÇÄÚ´æÉ豸£¬ÔÙ·Ö±ð´¦Àí¡£ÕâÒ²´ó´óµØÔö¼ÓÁËfbvga16ʵÏֵĴúÂë¡£

[Ŀ¼]


NativeÊäÈëÒýÇæµÄʵÏÖ

4 Native ÊäÈëÒýÇæµÄʵÏÖ

4.1 Êó±êÇý¶¯³ÌÐò
Êó±êÇý¶¯³ÌÐò·Ç³£¼òµ¥£¬³éÏóÒâÒåÉϽ²£¬³õʼ»¯Êó±êºó£¬Ã¿´ÎÓû§Òƶ¯Êó±ê£¬¾Í¿ÉÒԵõ½Ò»¸öX ºÍ Y ·½ÏòÉϵÄλÒÆÖµ£¬Çý¶¯³ÌÐòÄÚ²¿Î¬»¤Êó±êµÄµ±Ç°Î»Öã¬Óû§Òƶ¯ÁËÊó±êºó£¬µ±Ç°Î»Öñ»¼ÓÉÏλÒÆÖµ£¬²¢Í¨¹ýÉϲãCursorÖ§³Ö£¬·´Ó³µ½ÆÁÄ»ÉÏ£¬Óû§¾Í»áÈÏΪÊó±ê±»ËûÕýÈ·µØ¡°Òƶ¯¡±ÁË¡£

ÊÂʵÉÏ£¬Êó±êÇý¶¯³ÌÐòµÄʵÏÖÊÇÀûÓÃÄں˻òÕßÆäËûÇý¶¯³ÌÐòÌṩµÄ½Ó¿ÚÀ´Íê³ÉÈÎÎñµÄ¡£Linux ÄÚºËÇý¶¯³ÌÐòʹÓÃÉ豸Îļþ¶Ô´ó¶àÊýÓ²¼þ½øÐÐÁ˳éÏ󣬱ÈÈ磬ÎÒÃÇÑÛÖÐµÄ ps/2 Êó±ê¾ÍÊÇ /dev/psaux£¬ Êó±êÇý¶¯³ÌÐò½Ó¿ÚÈçÇåµ¥ 7 Ëùʾ¡£

                       Çåµ¥ 7  Native ÊäÈëÒýÇæµÄÊó±êÇý¶¯³ÌÐò½Ó¿Ú

typedef struct _mousedevice {
    int (*Open)(void);
    void    (*Close)(void);
    int (*GetButtonInfo)(void);
    void    (*GetDefaultAccel)(int *pscale,int *pthresh);
    int (*Read)(int *dx,int *dy,int *dz,int *bp);
    void (*Suspend)(void);
    void (*Resume)(void);
} MOUSEDEVICE;

ÏÖÔÚÓи÷ÖÖ¸÷ÑùµÄÊó±ê£¬ÀýÈçms Êó±ê£¬ ps/2 Êó±ê£¬×ÜÏßÊó±ê£¬gpm Êó±ê£¬ËüÃǵÄÖ÷Òª²î±ðÔÚÓÚ³õʼ»¯ºÍÊý¾Ý°ü¸ñʽÉÏ¡£

ÀýÈ磬´ò¿ªÒ»¸öGPM Êó±ê·Ç³£¼òµ¥£¬Ö»Òª½«É豸Îļþ´ò¿ª¾Í¿ÉÒÔÁË£¬µ±Ç°Öն˱»Çл»µ½Í¼ÐÎģʽʱ£¬GPM ·þÎñ³ÌÐò¾Í»á°ÑÊó±êËùÓеÄλÒÆÐÅÏ¢·Åµ½É豸ÎļþÖÐÈ¥¡£

static int GPM_Open(void)
{
    mouse_fd = open(GPM_DEV_FILE, O_NONBLOCK);
    if (mouse_fd < 0)
        return -1;
    return mouse_fd;
}

¶ÔÓÚPS/2 Êó±ê£¬²»µ«Òª´ò¿ªËüµÄÉ豸Îļþ£¬»¹ÒªÍù¸ÃÉ豸ÎļþдÈë¿ØÖÆ×Ö·ûÒÔʹµÃÊó±êÄܹ»¿ªÊ¼¹¤×÷¡£

static int PS2_Open(void)
{
uint8 initdata_ps2[] = { PS2_DEFAULT, PS2_SCALE11, PS2_ENABLE };
    mouse_fd = open(PS2_DEV_FILE, O_RDWR | O_NOCTTY | O_NONBLOCK);
    if (mouse_fd < 0)
            return -1;
    write(mouse_fd, initdata_ps2, sizeof(initdata_ps2));
    return mouse_fd;
}

¸÷Êó±êµÄÊý¾Ý°ü¸ñʽÊDz»Ò»ÑùµÄ¡£¶øÇÒÔÚ¶ÁÕâЩÊý¾Ýʱ£¬Ê×ÏÈÒª¸ù¾ÝÄÚºËÇý¶¯³ÌÐòÌṩµÄ¸ñʽ¶ÁÊý¾Ý£¬»¹Òª×¢Òâͬ²½£ºÃ¿´ÎɨÃèµ½Ò»¸öÍ·£¬²ÅÄܶÁºóÃæÏàÓ¦µÄÊý¾Ý£¬ÏóMicrowindowsÓÉÓÚûÓÐͬ²½£¬ÔÚijЩÇé¿öÏ£¬Êó±ê¾Í»á²»Ìý¡°Ö¸»Ó¡±¡£

Êó±êÇý¶¯³ÌÐòÖУ¬»¹ÓÐÒ»¸ö¡°¼ÓËÙ¡±µÄ¸ÅÄî¡£³ÌÐòÄÚ²¿ÓÃÁ½¸ö±äÁ¿£ºscale ºÍthresh À´±íʾ¡£µ±Êó±êµÄλÒƳ¬¹ý thresh ʱ£¬¾Í»á±»·Å´ó scale ±¶¡£ÕâÑù£¬×îºóµÄλÒƾÍÊÇ£º

        dx = thresh + (dx - thresh) * scale;
        dy = thresh + (dy - thresh) * scale;

ÖÁ´Ë£¬mouse driver »ù±¾ÉϺÜÇå³þÁË£¬ÉÏÃæµÄ½Ó¿Úº¯ÊýÖÐGetButtonInfoÓÃÀ´¸æËßµ÷ÓÃÕ߸ÃÊó±êÖ§³ÖÄÇЩbutton£¬ suspend ºÍresume º¯ÊýÊÇÓÃÀ´Ö§³ÖÐéÆÁÇл»µÄ£¬ÏÂÃæµÄ¼üÅÌÇý¶¯³ÌÐòÒ²Ò»Ñù¡£

4.2 ¼üÅÌÇý¶¯³ÌÐò
ÔÚʵÏÖ¼üÅÌÇý¶¯³ÌÐòÖÐÓöµ½µÄµÚÒ»¸öÎÊÌâ¾ÍÊÇʹÓÃÉ豸Îļþ /dev/tty»¹ÊÇ /dev/tty0¡£

# echo 1 > /dev/tty0
# echo 1 > /dev/tty

½á¹û¶¼½«°Ñ1 ÊäÈëµ½µ±Ç°ÖÕ¶ËÉÏ¡£ÁíÍ⣬Èç¹û´ÓαÖÕ¶ËÉÏÔËÐÐËüÃÇ£¬ÔòµÚÒ»ÌõÖ¸Áî»á½« 1 Êä³öµ½¿ØÖÆ̨µÄµ±Ç°Öնˣ¬¶øµÚ¶þÌõÖ¸Áî»á°Ñ 1 Êä³öµ½µ±Ç°Î±ÖÕ¶ËÉÏ¡£´Ó¶ø tty0 ±íʾµ±Ç°¿ØÖÆ̨Öնˣ¬tty ±íʾµ±Ç°Öնˣ¨Êµ¼ÊÊǵ±Ç°½ø³Ì¿ØÖÆÖն˵ıðÃû¶øÒÑ£©¡£

tty0 µÄÉ豸ºÅÊÇ 4£¬0

tty1 µÄÉ豸ºÅÊÇ 5£¬ 0

/dev/tty ÊǺͽø³ÌµÄÿһ¸öÖÕ¶ËÁªÏµÆðÀ´µÄ£¬/dev/tty µÄÇý¶¯³ÌÐòËù×öµÄÖ»ÊÇ°ÑËùÓеÄÇëÇóË͵½ºÏÊʵÄÖնˡ£

ȱʡÇé¿öÏ£¬/dev/tty ÊÇÆÕͨÓû§¿É¶ÁдµÄ£¬¶ø/dev/tty0 ÔòÖ»Óг¬¼¶Óû§Äܹ»¶Áд£¬Ö÷ÒªÊÇ»ùÓÚÕâ¸öÔ­Òò£¬ÎÒÃÇĿǰʹÓà /dev/tty ×÷ΪÉ豸Îļþ¡£ºóÃæËùÓÐÓйØÖն˴¦ÀíµÄ³ÌÐòµÄ¶¼²ÉÓÃËü×÷Ϊµ±Ç°ÖÕ¶ËÎļþ£¬ÕâÑùÒ²¿ÉÒԺʹ«Í³µÄ Unix Ïà¼æÈÝ¡£

¼üÅÌÇý¶¯³ÌÐò½Ó¿ÚÈçÇåµ¥ 8 Ëùʾ¡£

                     Çåµ¥ 8  Native ÊäÈëÒýÇæµÄ¼üÅÌÇý¶¯³ÌÐò½Ó¿Ú

typedef struct _kbddevice {
    int  (*Open)(void);
    void (*Close)(void);
    void (*GetModifierInfo)(int *modifiers);
    int  (*Read)(unsigned char *buf,int *modifiers);
    void (*Suspend)(void);
    void (*Resume)(void);
} KBDDEVICE;

»ù±¾Ô­Àí·Ç³£¼òµ¥£¬³õʼ»¯Ê±´ò¿ª /dev/tty£¬ÒÔºó¾Í´Ó¸ÃÎļþ¶Á³öËùÓеÄÊý¾Ý¡£ÓÉÓÚMiniGUI ÐèÒª²¶»ñ KEY_DOWN ºÍ KEY_UP ÏûÏ¢£¬¼üÅ̱»ÖÃÓÚԭʼ(raw)ģʽ¡£ÕâÑù£¬³ÌÐò´Ó /dev/tty ÖÐÖ±½Ó¶Á³ö¼üÅ̵ÄɨÃèÂ룬±ÈÈçÓû§°´ÏÂA ¼ü£¬¾Í¿ÉÒÔ¶Áµ½158£¬·ÅÏ£¬ÓÖ¶Áµ½30¡£Ô­Ê¼Ä£Ê½Ï£¬³ÌÐò±ØÐë×Ô¼º¼Çϸ÷¼üµÄ״̬£¬ÌرðÊÇshift£¬ctrl£¬alt£¬caps lock µÈ£¬ËùÒÔ³ÌÐòά»¤Ò»¸öÊý×飬¼Ç¼ÁËËùÓмüÅ̵Ä״̬¡£

ÕâÀï˵Ã÷Ò»ÏÂÊó±êÒƶ¯£¬°´¼üµÈʼþÊÇÈçºÎ±»´«Ë͵½ÉϲãÏûÏ¢¶ÓÁеġ£MiniGUI¹¤×÷ÔÚÓû§Ì¬£¬ËùÒÔËü²»¿ÉÄÜÀûÓÃÖжÏÕâÖÖ¸ßЧµÄ»úÖÆ¡£Ã»ÓÐÄÚºËÇý¶¯³ÌÐòµÄÖ§³Ö£¬ËüÒ²ºÜÄÑÀûÓÃÐźŵÈUnixϵͳµÄIPC»úÖÆ¡£MiniGUI¿ÉÒÔ×öµ½µÄ¾ÍÊÇ¿´ /dev/tty£¬ /dev/mouse µÈÎļþÊÇ·ñÓÐÊý¾Ý¿ÉÒÔ¶Á¡£Éϲãͨ¹ý²»¶Ïµ÷Óà GAL_WaitEvent ³¢ÊÔ¶ÁÈ¡ÕâЩÎļþ¡£ÕâÒ²ÊÇÏß³ÌParserµÄÖ÷ÒªÈÎÎñ¡£GAL_WaitEvent Ö÷ÒªÀûÓÃÁËϵͳµ÷ÓÃselect ÕâÒ»ÀàUnixϵͳÖеØλ½ö´ÎÓÚioctlµÄϵͳµ÷ÓÃÍê³É¸Ã¹¦ÄÜ¡£²¢½«µÈ´ýµ½µÄʼþ×÷Ϊ·µ»ØÖµ·µ»Ø¡£

ÖÁ´Ë½éÉÜÁ˼üÅ̺ÍÊó±êµÄÇý¶¯³ÌÐò£¬×÷Ϊ¼òµ¥µÄÊäÈëÉ豸£¬ËüÃǵÄÇý¶¯ÊǷdz£¼òµ¥µÄ¡£ÊÂʵÉÏ£¬ËüÃǵÄʵÏÖ´úÂëÒ²±È½ÏÉÙ£¬¾ÍÊÇÔÚǶÈëʽϵͳÖÐҪʹÓõĴ¥ÃþÆÁ£¬Èç¹û²Ù×÷ϵͳÄÚºËÖ§³Ö£¬ÆäÇý¶¯³ÌÐòÒ²ÊǷdz£¼òµ¥µÄ£ºËüÖ»²»¹ýÊÇÒ»ÖÖÌØÊâµÄÊó±ê¡£

[Ŀ¼]


Ìض¨Ç¶ÈëʽϵͳÉÏͼÐÎÒýÇæºÍÊäÈëÒýÇæʵÏÖ

5 Ìض¨Ç¶ÈëʽϵͳÉÏͼÐÎÒýÇæºÍÊäÈëÒýÇæʵÏÖ

ÈçÇ°ËùÊö£¬»ùÓÚ Linux µÄǶÈëʽϵͳ£¬ÆäÄÚºËÒ»°ã¾ß±¸¶Ô FrameBuffer µÄÖ§³Ö£¬´Ó¶ø¿ÉÒÔÀûÓÃÒÑÓÐµÄ Native ͼÐÎÒýÇæ¡£ÔÚ MiniGUI ´úÂëÖУ¬¿Éͨ¹ýµ÷Õû src/gal/native/native.h Öеĺ궨Òå¶ø¶¨Ò庯Êý¿âÖÐÊÇ·ñ°üº¬Ìض¨µÄͼÐÎÒýÇæÇý¶¯³ÌÐò£¨Çåµ¥ 9£©£º

                          Çåµ¥ 9  ¶¨Òå Native ÒýÇæµÄ×ÓÇý¶¯³ÌÐò


  16 /* define or undefine these macros
  17    to include or exclude specific fb driver.
  18  */
  19 #undef _FBLIN1_SUPPORT
  20 // #define _FBLIN1_SUPPORT        1
  21
  22 #undef _FBLIN2_SUPPORT
  23 // #define _FBLIN2_SUPPORT        1
  24
  22 #undef _FBLIN_2_SUPPORT
  23 // #define _FBLIN_2_SUPPORT        1
  24
  25 //#undef _FBLIN4_SUPPORT
  26 #define _FBLIN4_SUPPORT        1
  27
  28 // #undef _FBLIN8_SUPPORT
  29 #define _FBLIN8_SUPPORT        1
  30
  31 // #undef _FBLIN16_SUPPORT
  32 #define _FBLIN16_SUPPORT       1
  33
  34 #undef _FBLIN24_SUPPORT
  35 // #define _FBLIN24_SUPPORT       1
  36
  37 #undef _FBLIN32_SUPPORT
  38 // #define _FBLIN32_SUPPORT       1
  39
  40 #define HAVETEXTMODE    1       /* =0 for graphics only systems*/

ÆäÖУ¬HAVETEXTMODE ¶¨ÒåϵͳÊÇ·ñÓÐÎı¾Ä£Ê½£¬¿É½« MiniGUI ÖÐÓÃÀ´¹Ø±ÕÎı¾Ä£Ê½µÄ´úÂëÆÁ±Îµô¡£_FBLIN_2_SUPPORT ºÍ_FBLIN2_SUPPORT ·Ö±ðÓÃÀ´¶¨Òå big endian ºÍ little endian µÄ 2bpp Çý¶¯³ÌÐò¡£

¶ÔÓÚÊäÈëÒýÇæÀ´Ëµ£¬Çé¿ö¾ÍÓÐЩ²»Í¬ÁË¡£ÒòΪĿǰ»¹Ã»ÓÐͳһµÄ´¦ÀíÊä³öÉ豸µÄ½Ó¿Ú£¬¶øÇÒÿ¸öǶÈëʽϵͳµÄÊäÈëÉ豸Ҳ¸÷²»Ïàͬ£¬ËùÒÔ£¬ÎÒÃÇͨ³£ÒªÕë¶ÔÌض¨Ç¶ÈëʽϵͳÖØÐÂÊäÈëÒýÇæ¡£ÏÂÃæµÄ´úÂë¾ÍÊÇÕë¶Ô ADS »ùÓÚ StrongARM µÄǶÈëʽ¿ª·¢ÏµÍ³±àдµÄÊäÈëÒýÇ棨Çåµ¥ 10£©£º

           Çåµ¥ 10  Ϊ ADS ¹«Ë¾»ùÓÚ StrongARM µÄǶÈëʽ¿ª·¢ÏµÍ³±àдµÄÊäÈëÒýÇæ

  30
  31 #include <stdio.h>
  32 #include <stdlib.h>
  33 #include <string.h>
  34 #include <unistd.h>
  35 #include <sys/io.h>
  36 #include <sys/ioctl.h>
  37 #include <sys/poll.h>
  38 #include <linux/kd.h>
  39 #include <sys/types.h>
  40 #include <sys/stat.h>
  41 #include <fcntl.h>
  42
  43 #include "common.h"
  44 #include "misc.h"
  45 #include "ads_internal.h"
  46 #include "ial.h"
  47 #include "ads.h"
  48
  49 #ifndef NR_KEYS
  50 #define NR_KEYS         128
  51 #endif
  52
  53 static int ts;
  54 static int mousex = 0;
  55 static int mousey = 0;
  56 static POS pos;
  57
  58 static unsigned char state[NR_KEYS];
  59
  60 /************************  Low Level Input Operations **********************/
  61 /*
  62  * Mouse operations -- Event
  63  */
  64 static int mouse_update(void)
  65 {
  66         return 0;
  67 }
  68
  69 static int mouse_getx(void)
  70 {
  71         return mousex;
  72 }
  73
  74 static int mouse_gety(void)
  75 {
  76         return mousey;
  77 }
  78
  79 static void mouse_setposition(int x, int y)
  80 {
  81 }
  82
  83 static int mouse_getbutton(void)
  84 {
  85         return pos.b;
  86 }
  87
  88 static void mouse_setrange(int minx,int miny,int maxx,int maxy)
  89 {
  90 }
  91
  92 static int keyboard_update(void)
  93 {
  94         return 0;
  95 }
  96
  97 static char * keyboard_getstate(void)
  98 {
  99         return (char *)state;
100 }
101
102 #ifdef _LITE_VERSION
103 static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set  *except,
104                 struct timeval *timeout)
105 {
106         fd_set rfds;
107         int     e;
108
109     if (!in) {
110         in = &rfds;
111         FD_ZERO (in);
112     }
113
114         if (which & IAL_MOUSEEVENT) {
115                 FD_SET (ts, in);
116         if (ts > maxfd) maxfd = ts;
117         }
118
119         e = select (maxfd + 1, in, out, except, timeout) ;
120
121         if (e > 0) {
122                 if (ts >= 0 && FD_ISSET (ts, in))
123                 {
124             FD_CLR (ts, in);
125                         read (ts, &pos, sizeof (POS));
126                         if ( pos.x !=-1 && pos.y !=-1) {
127                                 mousex = pos.x;
128                                 mousey = pos.y;
129                         }
130                         pos.b = ( pos.b > 0 ? 4:0);
131                         return IAL_MOUSEEVENT;
132                 }
133
134         } else if (e < 0) {
135                 return -1;
136         }
137         return 0;
138 }
139 #else
140 static int wait_event (int which, fd_set *in, fd_set *out, fd_set *except,
141                 struct timeval *timeout)
142 {
143         struct pollfd ufd;
144         if ( (which & IAL_MOUSEEVENT) == IAL_MOUSEEVENT)
145         {
146                 ufd.fd     = ts;
147                 ufd.events = POLLIN;
148                 if ( poll (&ufd, 1, timeout) > 0)
149                 {
150                         read (ts, &pos, sizeof(POS));
151                         return IAL_MOUSEEVENT;
152                 }
153         }
154         return 0;
155 }
156 #endif
157
158 static void set_leds (unsigned int leds)
159 {
160 }
161
162 BOOL InitADSInput (INPUT* input, const char* mdev, const char* mtype)
163 {
164         int i;
165
166         ts = open ("/dev/ts", O_RDONLY);
167     if ( ts < 0 ) {
168         fprintf (stderr, "IAL: Can not open touch screen!\n");
169         return FALSE;
170     }
171
172         for(i = 0; i < NR_KEYS; i++)
173                 state[i] = 0;
174
175     input->update_mouse = mouse_update;
176     input->get_mouse_x = mouse_getx;
177     input->get_mouse_y = mouse_gety;
178     input->set_mouse_xy = mouse_setposition;
179     input->get_mouse_button = mouse_getbutton;
180     input->set_mouse_range = mouse_setrange;
181
182     input->update_keyboard = keyboard_update;
183     input->get_keyboard_state = keyboard_getstate;
184     input->set_leds = set_leds;
185
186     input->wait_event = wait_event;
187         mousex = 0;
188         mousey = 0;
189     return TRUE;
190 }
191
192 void TermADSInput (void)
193 {
194         if ( ts >= 0 )
195                 close(ts);
196 }
197

ÔÚÉÏÊöÊäÈëÒýÇæÖУ¬ÍêÈ«ºöÂÔÁ˼üÅÌÏà¹ØµÄº¯ÊýʵÏÖ£¬´úÂ뼯ÖÐÔÚ¶Ô´¥ÃþÆÁµÄ´¦ÀíÉÏ¡£ÏÔÈ»£¬ÊäÈëÒýÇæµÄ±àд²¢²»ÊǷdz£À§Äѵġ£

[Ŀ¼]


С½á

6 С½á

±¾ÎÄÏêϸ½éÉÜÁË MiniGUI µÄ GAL ºÍ IAL ½Ó¿Ú£¬²¢ÒÔ Native ͼÐÎÒýÇæºÍÊäÈëÒýÇæΪÀý£¬½éÉÜÁ˾ßÌåͼÐÎÒýÇæºÍÊäÈëÒýÇæµÄʵÏÖ¡£µ±È»£¬MiniGUI Ä¿Ç°µÄ GAL ºÍ IAL ½Ó¿Ú»¹ÓÐÐí¶à²»×ãÖ®´¦£¬±ÈÈçºÍÉϲãµÄ GDI ñîºÏ³Ì¶È²»¸ß£¬´Ó¶ø¶ÔЧÂÊÓÐЩËðʧ¡£ÔÚ MiniGUI ½«À´µÄ¿ª·¢ÖУ¬ÎÒÃǽ«ÖØÐÂÉè¼Æ GDI ÒÔ¼°µ×²ãµÄͼÐÎÒýÇæ½Ó¿Ú£¬ÒÔ±ãÕë¶Ô´°¿Úϵͳ½øÐÐÓÅ»¯¡£

[Ŀ¼]


¿ª·¢Ö¸ÄÏ

    ×Ô MiniGUI ´Ó 1998 Äêµ×ÍƳöÒÔÀ´£¬Ô½À´Ô½¶àµÄÈË¿ªÊ¼Ñ¡Ôñ MiniGUI ÔÚ Linux ÉÏ¿ª·¢ÊµÊ±Ç¶Èëʽϵͳ¡£ÎªÁË°ïÖúǶÈëʽÈí¼þ¿ª·¢ÈËԱʹÓà MiniGUI±àд³ö¸üºÃµÄÓ¦ÓóÌÐò£¬ÎÒÃǽ«×«Ð´Ò»ÏµÁÐÎÄÕ½²½â»ùÓÚ Linux ºÍ MiniGUI µÄǶÈëʽϵͳÈí¼þ¿ª·¢£¬²¢¹ÚÃû"»ùÓÚ Linux ºÍ MiniGUI µÄǶÈëʽϵͳÈí¼þ¿ª·¢Ö¸ÄÏ"¡£
[Ŀ¼]


Ñ¡ÔñMiniGUI-Threads»òÕßMiniGUI-Lite

1£ºÒýÑÔ
    ×Ô MiniGUI ´Ó 1998 Äêµ×ÍƳöÒÔÀ´£¬Ô½À´Ô½¶àµÄÈË¿ªÊ¼Ñ¡Ôñ MiniGUI ÔÚ Linux ÉÏ¿ª·¢ÊµÊ±Ç¶Èëʽϵͳ¡£MiniGUI ϵͳҲÖð½¥³ÉÊ죬²¢ÔÚ¸÷ÖÖǶÈëʽϵͳÖаçÑÝÁËÖØÒªµÄ½ÇÉ«¡£ÎªÁË°ïÖúǶÈëʽÈí¼þ¿ª·¢ÈËԱʹÓà MiniGUI±àд³ö¸üºÃµÄÓ¦ÓóÌÐò£¬ÎÒÃǽ«×«Ð´Ò»ÏµÁÐÎÄÕ½²½â»ùÓÚ Linux ºÍ MiniGUI µÄǶÈëʽϵͳÈí¼þ¿ª·¢£¬²¢¹ÚÃû"»ùÓÚ Linux ºÍ MiniGUI µÄǶÈëʽϵͳÈí¼þ¿ª·¢Ö¸ÄÏ"¡£¸ÃϵÁÐÎÄÕ½«½²ÊöÈçºÎÔÚ»ùÓÚ Linux µÄϵͳÉÏÀûÓà MiniGUI ¿ª·¢¾ßÓÐͼÐÎÓû§½çÃæÖ§³ÖµÄǶÈëʽϵͳÈí¼þ£¬ÆäÄÚÈݲ»½ö½öÏÞÓÚ MiniGUI µÄ±à³Ì£¬»¹»áÉæ¼°µ½Ò»Ð© Linux ÏÂǶÈëʽϵͳÈí¼þ¿ª·¢µÄ¼¼ÇÉ¡£ÏµÁÐÎÄÕµijõ²½¹æ»®ÈçÏ£º

    ·ÈçºÎÕë¶ÔÌض¨ÏîÄ¿Ñ¡Ôñ MiniGUI-Threads ºÍ MiniGUI-Lite
    ·Àí½âÏûϢѭ»·ºÍ´°¿Ú¹ý³Ì
    ·¶Ô»°¿òºÍ¿Ø¼þ±à³Ì
    ·Ê¹Óà GDI º¯Êý
    ·MiniGUI ºÍ Linux ϵͳµ÷ÓÃ
    ·MiniGUI-Lite Óë½ø³Ì¼äͨѶ
    ·½« MiniGUI ¼°Ó¦ÓóÌÐòÒÆÖ²µ½Ìض¨Æ½Ì¨
    ·ÀûÓà autoconf ½Ó¿Ú±àд¿çƽ̨´úÂë
    ·ÈçºÎµ÷ÊÔ MiniGUI Ó¦ÓóÌÐò

    ±¾ÎÄÊǸÃϵÁÐÎÄÕµĵÚһƪ£¬½«½²ÊöÈçºÎÕë¶Ô¾ßÌåÏîÄ¿Ñ¡ÔñʹÓà MiniGUI-Threads »òÕß MiniGUI-Lite °æ±¾£¬²¢±È½Ï²»Í¬°æ±¾¶ÔϵͳÈí¼þ½á¹¹µÄÓ°Ïì¡£


2£ºMiniGUI-Threads ºÍ MiniGUI-Lite µÄÇø±ð
    ´ó¼Ò¶¼ÖªµÀ£¬ÎÒÃÇ¿ÉÒÔ½« MiniGUI ±àÒë³ÉÁ½¸ö½ØÈ»²»Í¬µÄ°æ±¾£¬Ò»¸öÊÇ MiniGUI-Threads£¬Ò»¸öÊÇ MiniGUI-Lite¡£ÕâÁ½¸ö°æ±¾ÊÊÓÃÓÚ²»Í¬µÄÓ¦ÓÃÐèÇó¡£ÔÚÑ¡Ôñµ½µ×ʹÓà MiniGUI-Threads »¹ÊÇ MiniGUI-Lite ֮ǰ£¬ÎÒÃÇÊ×ÏÈÐèÒªÁ˽âÕâÁ½¸ö°æ±¾Ö®¼äµÄÇø±ð¡£

    MiniGUI-Threads ÊÇ MiniGUI µÄ×î³õ°æ±¾¡£MiniGUI ×î³õΪһ¸ö¹¤Òµ¿ØÖÆϵͳ¿ª·¢µÄ£¬¸Ãϵͳ¹¦Äܵ¥Ò»£¬µ«È´ÐèÒª·Ç³£¸ßµÄʵʱÐÔ£¬Òò´Ë¿¼Âǽ« MiniGUI ¿ª·¢³ÉÒ»¸ö»ùÓÚ¶àÏ̵߳ÄͼÐÎÓû§½çÃæÖ§³Öϵͳ¡£ÒòΪÔÚ´«Í³µÄ UNIX/Linux ϵͳÉÏ£¬µäÐ굀 GUI ϵͳ£¨±ÈÈç X£©²ÉÓô«Í³µÄ»ùÓÚ UNIX Ì×½Ó×ֵĿͻ§/·þÎñÆ÷ϵͳ½á¹¹¡£ÔÚÕâÖÖÌåϵ½á¹¹Ï£¬¿Í»§½¨Á¢´°¿Ú¡¢»æÖƵȵȶ¼ÒªÍ¨¹ýÌ×½Ó×Ö´«µÝµ½·þÎñÆ÷£¬ÓÉ·þÎñÆ÷Íê³ÉʵÖʹ¤×÷¡£ÕâÑù£¬ÏµÍ³·Ç³£ÒÀÀµÓÚ UNIX Ì×½Ó×ÖͨѶ¡£¶ø´ó¼Ò¶¼ÖªµÀ£¬UNIX Ì×½Ó×ÖµÄÊý¾Ý´«µÝ£¬Òª¾­¹ýÄںˣ¬È»ºóÔÙ´«µÝµ½ÁíÍâÒ»¸ö³ÌÐò¡£ÕâÑù£¬´óÁ¿µÄÊý¾ÝÔÚ¿Í»§/ÄÚºË/·þÎñÆ÷Ö®¼ä´«µÝ£¬´Ó¶øÔö¼ÓÁËϵͳ¸ººÉ£¬Ò²Õ¼ÓÃÁËÐí¶àϵͳ×ÊÔ´¡£Õâ¶ÔÐí¶àǶÈëʽϵͳ£¬ÓÈÆäÊÇʵʱÐÔÒªÇó·Ç³£¸ßµÄϵͳÀ´Ëµ£¬ÊDz»¿É½ÓÊܵġ£

    ΪÁ˽â¾öÕâ¸öÎÊÌ⣬MiniGUI Ê×ÏȲÉÓÃÁËÏ̻߳úÖÆ£¨ÀàËÆWindows CE£©£¬ËùÓеÄÓ¦ÓóÌÐò¶¼ÔËÐÐÔÚͬһ¸öµØÖ·¿Õ¼ä£¬ÕâÑù£¬´ó´óÌá¸ßÁ˳ÌÐòÖ®¼äµÄͨѶЧÂÊ£¬²¢ÇÒÌرðÊʺÏÓÚʵʱÐÔÒªÇó·Ç³£¸ßµÄϵͳ¡£Õâ¾ÍÊÇ MiniGUI-Threads¡£»ùÓÚ MiniGUI-Threads µÄ³ÌÐò£¬¿ÉÒÔ¾ßÓжà¸öỊ̈߳¬Ã¿¸öÏß³ÌÓв»Í¬µÄ¹¦ÄܺÍÈÎÎñ£¬²¢ÇÒ¿ÉÒÔ½¨Á¢¸÷×ԵĴ°¿Ú£¬²»Í¬µÄÏß³ÌÖ®¼ä£¬¿ÉÒÔͨ¹ý MiniGUI ÌṩµÄÏûÏ¢´«µÝ»úÖƽøÐÐʼþ´«ËͺÍͬ²½¡£

    µ«ÏÔÈ»£¬ÕâÖÖ»ùÓÚÏ̵߳ĽṹҲµ¼ÖÂÁËϵͳÕûÌåµÄ´àÈõ¨D¨DÈç¹ûij¸öÏß³ÌÒòΪ·Ç·¨µÄÊý¾Ý·ÃÎʶøÖÕÖ¹ÔËÐУ¬ÔòÕû¸ö½ø³Ì¶¼½«Êܵ½Ó°Ïì¡£²»¹ý£¬ÕâÖÖÌåϵ½á¹¹¶Ôʵʱ¿ØÖÆϵͳµÈʱ¼ä¹Ø¼üµÄϵͳÀ´½²£¬»¹ÊǷdz£Êʺϵġ£

    ΪÁ˽â¾ö MiniGUI-Threads °æ±¾ÒòΪÏ̶߳øÒýÈëµÄһЩÎÊÌ⣬ͬʱҲΪÁËÈà MiniGUI¸ü¼ÓÊʺÏÓÚǶÈëʽϵͳ£¬ÎÒÃǾö¶¨¿ª·¢Ò»¸ö MiniGUI-Lite °æ±¾¡£Õâ¸ö°æ±¾µÄ¿ª·¢Ä¿µÄÊÇ£º

    ·±£³ÖÓëÔ­ÏÈ MiniGUI °æ±¾ÔÚÔ´´úÂ뼶 99% ÒÔÉϵļæÈÝ¡£
    ·²»ÔÙʹÓÃÏ߳̿⡣
    ·¿ÉÒÔͬʱÔËÐжà¸ö»ùÓÚ MiniGUI-Lite µÄÓ¦ÓóÌÐò£¬¼´¶à¸ö½ø³Ì£¬²¢ÇÒÌṩǰºǫ́½ø³ÌµÄÇл»¡£

    ÏÔÈ»£¬ÒªÍ¬Ê±Âú×ãÉÏÊöÈý¸öÄ¿µÄ£¬Èç¹û²ÉÓô«Í³µÄ C/S ½á¹¹¶ÔMiniGUI-Threads ½øÐиÄÔ죬Ӧ¸Ã²»ÄÑʵÏÖ¡£µ«Ç°ÃæÌáµ½µÄ´«Í³ C/S ½á¹¹µÄȱÏÝÈ´ÎÞ·¨±ÜÃâ¡£¾­¹ý¶Ô PDA µÈǶÈëʽϵͳµÄ·ÖÎö£¬ÎÒÃÇ·¢ÏÖ£¬Ä³Ð© PDA ²úÆ·¾ßÓÐÔËÐжà¸öÈÎÎñµÄÄÜÁ¦£¬µ«Í¬Ò»Ê±¿ÌÔÚÆÁÄ»ÉϽøÐлæÖƵijÌÐò£¬Ò»°ã²»»á³¬¹ýÁ½¸ö¡£Òò´Ë£¬Ö»ÒªÈ·±£½«ÕâÁ½¸ö½ø³ÌµÄ»æÖÆÏ໥¸ôÀ룬¾Í²»ÐèÒª²ÉÓø´Ô C/S ½á¹¹´¦Àí¶à¸ö½ø³Ì´°¿ÚÖ®¼äµÄ»¥Ïà¼ôÇС£Ò²¾ÍÊÇ˵£¬ÔÚÕâÖÖ²úÆ·ÖУ¬Èç¹û²ÉÓûùÓÚ´«Í³ C/S ½á¹¹µÄ¶à´°¿Úϵͳ£¬Êµ¼ÊÊÇÒ»ÖÖÀË·Ñ¡£

    ÓÐÁËÉÏÊöÈÏʶ£¬ÎÒÃÇ¶Ô MiniGUI-Threads ½øÐÐÁËÈçϼò»¯Éè¼Æ£º

    ÿ¸ö½ø³Ìά»¤×Ô¼ºµÄÖ÷´°¿Ú Z Ðò£¬Í¬Ò»½ø³Ì´´½¨µÄÖ÷´°¿ÚÖ®¼ä»¥Ïà¼ôÇС£Ò²¾ÍÊÇ˵£¬³ýÕâ¸ö½ø³ÌÖ»ÓÐÒ»¸öỊ̈߳¬Ö»ÓÐÒ»¸öÏûϢѭ»·Ö®Í⣬ËüÓëÔ­ÓÐµÄ MiniGUI °æ±¾Ö®¼äûÓÐÈκÎÇø±ð¡£Ã¿¸ö½ø³ÌÔÚ½øÐÐÆÁÄ»»æÖÆʱ£¬²»ÐèÒª¿¼ÂÇÆäËû½ø³Ì¡£
    ½¨Á¢Ò»¸ö¼òµ¥µÄ¿Í»§/·þÎñÆ÷Ìåϵ£¬µ«È·±£×îС»¯½ø³Ì¼äµÄÊý¾Ý¸´Öƹ¦ÄÜ¡£Òò´Ë£¬ÔÚ·þÎñÆ÷ºÍ¿Í»§Ö®¼ä´«µÝµÄÊý¾Ý½öÏÞÓÚÊäÈëÉ豸µÄÊäÈëÊý¾Ý£¬ÒÔ¼°¿Í»§ºÍ·þÎñÆ÷Ö®¼äµÄijЩÇëÇóºÍÏìÓ¦Êý¾Ý¡£
ÓÐÒ»¸ö·þÎñÆ÷½ø³Ì£¨mginit£©£¬Ëü¸ºÔð³õʼ»¯Ò»Ð©ÊäÈëÉ豸£¬²¢ÇÒͨ¹ý UNIX Domain Ì×½Ó×Ö½«ÊäÈëÉ豸µÄÏûÏ¢·¢Ë͵½Ç°Ì¨µÄ MiniGUI-Lite ¿Í»§½ø³Ì¡£
    ·þÎñÆ÷ºÍ¿Í»§±»·Ö±ðÏÞ¶¨ÔÚÆÁÄ»µÄijÁ½¸ö²»Ïཻ¾ØÐÎÄÚ½øÐлæÖÆ£¬Í¬Ò»Ê±¿Ì£¬Ö»ÄÜÓÐÒ»¸ö¿Í»§¼°·þÎñÆ÷½øÐÐÆÁÄ»»æÖÆ¡£ÆäËû¿Í»§¿É¼ÌÐøÔËÐУ¬µ«ÆÁÄ»ÊäÈë±»ÆÁ±Î¡£·þÎñÆ÷¿ÉÒÔÀûÓà API ½Ó¿Ú½«Ä³¸ö¿Í»§Çл»µ½Ç°Ì¨¡£Í¬Ê±£¬·þÎñÆ÷ºÍ¿Í»§Ö®¼ä²ÉÓÃÐÅºÅºÍ System V ÐźÅÁ¿½øÐÐͬ²½¡£
    ·þÎñÆ÷»¹²ÉÓà System V IPC »úÖÆÌṩһЩ×ÊÔ´µÄ¹²Ïí£¬°üÀ¨Î»Í¼¡¢Í¼±ê¡¢Êó±ê¡¢×ÖÌåµÈµÈ£¬ÒÔ±ã¼õÉÙʵ¼ÊÄÚ´æµÄÏûºÄ¡£

    ´Ó´«Í³ C/S ´°¿ÚϵͳµÄ½Ç¶È¿´£¬MiniGUI-Lite µÄÕâÖÖÉè¼Æ£¬ÎÞ·¨´¦Àí´ïµ½ÍêÕûµÄ¶à´°¿ÚÖ§³Ö£¬ÕâµÄÈ·ÊÇÒ»¸ö½á¹¹Éè¼ÆÉϵIJ»×ãºÍȱÏÝ¡£²»¹ý£¬Õâʵ¼ÊÊÇ MiniGUI-Lite ²»Í¬ÓÚÆäËû´°¿ÚϵͳµÄÒ»¸öÌØÕ÷¡£ÒòΪ´¦Àíÿ¸ö½ø³ÌÖ®¼äµÄ»¥Ïà¼ôÇÐÎÊÌ⣬½«µ¼Ö¿ͻ§ºÍ·þÎñÆ÷Ö®¼äµÄͨѶÁ¿´ó´óÔö¼Ó£¬µ«Êµ¼ÊÉÏÔÚÐí¶àǶÈëʽϵͳµ±ÖÐÕâÖÖ´¦ÀíÊÇûÓбØÒªµÄ¡£ÔÚÀàËÆ PDA µÄǶÈëʽϵͳÖУ¬ÍùÍù¸÷¸ö³ÌÐòÆô¶¯ºó£¬¾Í¶ÀÕ¼ÆÁÄ»½øÐлæÖÆÊä³ö£¬ÆäËû³ÌÐò¸ù±¾¾ÍûÓбØÒªÖªµÀËüÏÖÔڵĴ°¿Ú±»±ðµÄ½ø³Ì¼ôÇÐÁË£¬ÒòΪËü¸ù±¾¾ÍûÓлú»áÊä³öµ½ÆÁÄ»ÉÏ¡£ËùÒÔ£¬ÔÚ MiniGUI-Lite µ±ÖУ¬µ±Ò»¸ö½ø³Ì³ÉΪ×²ã³ÌÐòʱ£¬·þÎñÆ÷»á±£Ö¤ÆäÊä³öÕý³££¬¶øµ±ÓÐеijÌÐò³ÉΪ×²ã³ÌÐòʱ£¬·þÎñÆ÷Ò²»á±£Ö¤ÆäËû³ÌÐò²»ÄÜÊä³öµ½ÆÁÄ»ÉÏ¡£µ«ÕâЩ½ø³ÌÒÀÈ»ÔÚÕý³£Ö´ÐÐ×Å£¬²»¹ý£¬·þÎñÆ÷Ö»Ïò×²ãµÄ³ÌÐò·¢ËÍÍⲿʼþÏûÏ¢¡£

    ±í 1 ¸ø³öÁË MiniGUI-Threads ºÍ MiniGUI-Lite µÄÇø±ð¡£´Ó±íÖÐ×ܽáµÄÇø±ð¿´À´£¬MiniGUI-Threads ÊʺÏÓÚ¹¦Äܵ¥Ò»¡¢ÊµÊ±ÐÔÒªÇóºÜ¸ßµÄϵͳ£¬±ÈÈ繤ҵ¿ØÖÆϵͳ£»¶ø MiniGUI-Lite ÊʺÏÓÚ¹¦Äܷḻ¡¢½á¹¹¸´ÔÓ¡¢ÏÔʾÆÁÄ»½ÏСµÄϵͳ£¬±ÈÈç PDA µÈÐÅÏ¢²úÆ·¡£

±í 1 MiniGUI-Threads ºÍ MiniGUI-Lite µÄÇø±ð

# MiniGUI-Threads
* MiniGUI-Lite

¶à´°¿ÚÖ§³Ö
    # ÍêÈ«
    * ²»ÄÜ´¦Àí½ø³Ì¼ä´°¿ÚµÄ¼ôÇУ¬µ«Ìṩ½ø³ÌÄڶര¿ÚµÄÍêÈ«Ö§³Ö

×ÖÌåÖ§³Ö
    # Ö§³ÖµãÕó×ÖÌ壨VBF¡¢RBF£©ºÍʸÁ¿×ÖÌ壨Adobe Type1 ºÍ TrueType£©
    * Ä¿Ç°Éв»Ö§³Ö¶Ô Adobe Type1 ºÍ TrueType µÈʸÁ¿×ÖÌåµÄÖ§³Ö

Ï̼߳äÏûÏ¢´«µÝ
    # ͨ¹ý MiniGUI µÄÏûÏ¢º¯Êý£¬¿ÉÔÚ²»Í¬µÄÏß³ÌÖ®¼ä´«µÝÏûÏ¢
    * δ¿¼ÂǶàÏß³ÌÓ¦Ó㬲»ÄÜÖ±½Óͨ¹ý MiniGUI ÏûÏ¢º¯ÊýÔÚ²»Í¬Ïß³ÌÖ®¼ä´«µÝÏûÏ¢

¶àÏ̴߳°¿Ú
    # MiniGUI Äܹ»´¦Àí²»Í¬Ïß³ÌÖ®¼äµÄ´°¿Ú²ãµþ
    * ²»ÄÜ´¦Àí¶àÏß³ÌÖ®¼äµÄ´°¿Ú²ãµþ

ÆäËû
    # »ùÓÚÏß³ÌµÄ C/S ½á¹¹£¬ÏµÍ³½¡×³ÐԽϲÒò´ËÒªÇóϵͳ¾­¹ýÑϸñ²âÊÔ
    * ²ÉÓà UNIX Domain Socket µÄ»ùÓÚ½ø³ÌµÄ C/S ½á¹¹£¬¿É½¨Á¢½¡×³µÄÈí¼þ¼Ü¹¹¡£²¢ÌṩÁË·½±ãµÄ¸ß²ã IPC »úÖÆ

    ³ýÉϱíÖÐÁгöµÄ²»Í¬Ö®Í⣬MiniGUI-Threads ºÍ MiniGUI-Lite µÄ API ÊÇÒ»Öµġ£

3£ºMiniGUI-Threads µÄµäÐÍÓ¦ÓúÍÈí¼þ¼Ü¹¹
    ±¾ÎĽéÉܵĻùÓÚ MiniGUI-Threads µäÐÍÓ¦ÓÃÊÇÒ»¸ö¼ÆËã»úÊý×Ö¿ØÖÆ£¨CNC£©ÏµÍ³¡£Õâ¸öϵͳÊÇÓÉÇ廪´óѧ»ùÓÚ RT-Linux ½¨Á¢µÄ»ú´²¿ØÖÆϵͳ¡£¸ÃϵͳʹÓà MiniGUI-Threads ×÷ΪͼÐÎÓû§½çÃæÖ§³Öϵͳ¡£Í¼ 1 ÊǸà CNC ϵͳµÄÓû§½çÃæ¡£

ͼ 1 Ç廪´óѧ»ùÓÚ RT-Linux ºÍ MiniGUI µÄÊý¿ØϵͳÖ÷½çÃæ

    ͼ 2 ÊǸÃϵͳµÄ¼Ü¹¹¡£ÔÚÓû§²ã£¬¸ÃϵͳÓÐÈý¸öỊ̈߳¬Ò»¸ö×÷Ϊ GUI Ö÷Ï̴߳æÔÚ£¬ÁíÒ»¸ö×÷Ϊ¼àÊÓÏ̼߳àÊÓϵͳµÄ¹¤×÷״̬£¬²¢ÔÚ¸ÃÏ߳̽¨Á¢µÄ´°¿ÚÉÏÊä³ö״̬ÐÅÏ¢£¬µÚÈý¸öÏß³ÌÊǹ¤×÷Ị̈߳¬¸ÃÏß³ÌÖ´Ðмӹ¤Ö¸Á²¢Í¨¹ý RT-Linux µÄʵʱ FIFO ºÍϵͳµÄʵʱģ¿é½øÐÐͨѶ¡£

ͼ 2 Ç廪´óѧ»ùÓÚ RT-Linux ºÍ MiniGUI µÄÊý¿Øϵͳ¼Ü¹¹

4£ºMiniGUI-Lite µÄµäÐÍÓ¦ÓúÍÈí¼þ¼Ü¹¹
    ÕâÀï½éÉܵĵäÐÍÓ¦ÓÃÊÇÒ»¸ö»ùÓÚ MiniGUI-Lite µÄ PDA¡£¸Ã PDA ÓɹúÄÚij¹«Ë¾»ùÓÚ Linux ¿ª·¢£¬ÆäÉÏ¿ÉÒÔÔËÐи÷ÖÖ PIM ³ÌÐò¡¢ä¯ÀÀÆ÷ÒÔ¼°¸÷ÖÖÓÎÏ·³ÌÐò¡£Í¼ 3 ÊǸà PDA µÄÓû§½çÃæ¡£

ͼ 3 ij¹«Ë¾¿ª·¢µÄ»ùÓÚ MiniGUI µÄ PDA Èí¼þ½çÃæ

    ¸ÃϵͳÖеÄËùÓÐÓ¦ÓóÌÐò¶¼ÒÔ Linux ½ø³ÌµÄÐÎʽִÐУ¬mginit£¨¼´ MiniGUI-Lite£©ÌṩÁËÊäÈë·¨Ö§³ÖºÍÓ¦ÓóÌÐò¹ÜÀí¹¦ÄÜ¡£µ±Ó¦ÓóÌÐòÖ®¼äÐèҪͨѶʱ£¬¿ÉÒÔͨ¹ý MiniGUI-Lite ËùÌṩµÄ request/response ½Ó¿ÚʵÏÖ¡£Í¼ 4 ÊǸÃϵͳµÄ¼Ü¹¹¡£

ͼ 4 ij¹«Ë¾¿ª·¢µÄ»ùÓÚ MiniGUI µÄ PDA Èí¼þ¼Ü¹¹

5£ºÐ¡½á
    ±¾ÎĽ²½âÁË MiniGUI-Threads ºÍ MiniGUI-Lite Ö®¼äµÄÇø±ð£¬²¢¾ÙÀý˵Ã÷ÁË»ùÓÚÕâÁ½¸ö²»Í¬°æ±¾µÄ²»Í¬Èí¼þ¼Ü¹¹¡£Ç¶Èëʽ³ÌÐò¿ª·¢ÈËÔ±±ØÐëÃ÷°×ÕâÁ½¸ö°æ±¾Ö®¼äµÄÇø±ð£¬²¢Õë¶Ô¾ßÌåÓ¦ÓÃÇ¡µ±Ñ¡ÔñʹÓÃÄĸö°æ±¾¡£

[Ŀ¼]


ÏûϢѭ»·ºÍ´°¿Ú¹ý³Ì

ÒýÑÔ
    ÎÒÃÇÖªµÀ£¬Á÷ÐÐµÄ GUI ±à³Ì¶¼ÓÐÒ»¸öÖØÒªµÄ¸ÅÄîÓëÖ®Ïà¹Ø£¬¼´"ʼþÇý¶¯±à³Ì"¡£Ê¼þÇý¶¯µÄº¬Òå¾ÍÊÇ£¬³ÌÐòµÄÁ÷³Ì²»ÔÙÊÇÖ»ÓÐÒ»¸öÈë¿ÚºÍÈô¸É¸ö³ö¿ÚµÄ´®ÐÐÖ´ÐÐÏß·£»Ïà·´£¬³ÌÐò»áÒ»Ö±´¦ÓÚÒ»¸öÑ­»·×´Ì¬£¬ÔÚÕâ¸öÑ­»·µ±ÖУ¬³ÌÐò´ÓÍⲿÊäÈëÉ豸»ñȡijЩʼþ£¬±ÈÈçÓû§µÄ°´¼ü»òÕßÊó±êµÄÒƶ¯£¬È»ºó¸ù¾ÝÕâЩʼþ×÷³öijÖÖµÄÏìÓ¦£¬²¢Íê³ÉÒ»¶¨µÄ¹¦ÄÜ£¬Õâ¸öÑ­»·Ö±µ½³ÌÐò½ÓÊܵ½Ä³¸öÏûϢΪֹ¡£"ʼþÇý¶¯"µÄµ×²ãÉèÊ©£¬¾ÍÊdz£ËµµÄ"ÏûÏ¢¶ÓÁÐ"ºÍ"ÏûϢѭ»·"¡£±¾ÎĽ«¾ßÌåÃèÊö MiniGUI ÖÐÓÃÀ´´¦ÀíÏûÏ¢µÄ¼¸¸öÖØÒªº¯Êý£¬²¢ÃèÊö MiniGUI-Threads ºÍ MiniGUI-Lite ÔÚÏûϢѭ»·ÊµÏÖÉϵÄһЩ²»Í¬¡£

    ´°¿ÚÊÇ MiniGUI µ±ÖÐ×î»ù±¾µÄ GUI ÔªËØ£¬Ò»µ©´°¿Ú½¨Á¢Ö®ºó£¬´°¿Ú¾Í»á´ÓÏûÏ¢¶ÓÁе±ÖлñÈ¡ÊôÓÚ×Ô¼ºµÄÏûÏ¢£¬È»ºó½»ÓÉËüµÄ´°¿Ú¹ý³Ì½øÐд¦Àí¡£ÕâЩÏûÏ¢µ±ÖУ¬ÓÐһЩÊÇ»ù±¾µÄÊäÈëÉ豸ʼþ£¬¶øÓÐһЩÔòÊÇÓë´°¿Ú¹ÜÀíÏà¹ØµÄÂß¼­ÏûÏ¢¡£±¾ÎĽ«½²Êö MiniGUI ÖеĴ°¿Ú½¨Á¢ºÍÏú»Ù¹ý³Ì£¬²¢½âÊÍÁË´°¿Ú¹ý³ÌµÄ¸ÅÄîÒÔ¼°¶ÔһЩÖØÒªÏûÏ¢µÄ´¦Àí¡£

2 ÏûÏ¢ºÍÏûϢѭ»·
    ÔÚ MiniGUI ÖУ¬ÏûÏ¢±»Èç϶¨Ò壨include/window.h£©£º

352 typedef struct _MSG
353 {
354     HWND             hwnd;
355     int              message;
356     WPARAM           wParam;
357     LPARAM           lParam;
358 #ifdef _LITE_VERSION
359     unsigned int     time;
360 #else
361     struct timeval   time;
362 #endif
363     POINT            pt;
364 #ifndef _LITE_VERSION
365     void*            pAdd;
366 #endif
367 }MSG;
368 typedef MSG* PMSG;

    Ò»¸öÏûÏ¢ÓɸÃÏûÏ¢ËùÊôµÄ´°¿Ú£¨hwnd£©¡¢ÏûÏ¢±àºÅ£¨message£©¡¢ÏûÏ¢µÄ WPARAM ÐͲÎÊý£¨wParam£©ÒÔ¼°ÏûÏ¢µÄ LPARAM ÐͲÎÊý£¨lParam£©×é³É¡£ÏûÏ¢µÄÁ½¸ö²ÎÊýÖаüº¬ÁËÖØÒªµÄÄÚÈÝ¡£±ÈÈ磬¶ÔÊó±êÏûÏ¢¶øÑÔ£¬lParam ÖÐÒ»°ã°üº¬Êó±êµÄλÖÃÐÅÏ¢£¬¶ø wParam ²ÎÊýÖÐÔò°üº¬·¢Éú¸ÃÏûϢʱ£¬¶ÔÓ¦µÄ SHIFT ¼üµÄ״̬ÐÅÏ¢µÈ¡£¶ÔÆäËû²»Í¬µÄÏûÏ¢ÀàÐÍÀ´½²£¬wParam ºÍ lParam Ò²¾ßÓÐÃ÷È·µÄ¶¨Òå¡£µ±È»£¬Óû§Ò²¿ÉÒÔ×Ô¶¨ÒåÏûÏ¢£¬²¢¶¨ÒåÏûÏ¢µÄ wParam ºÍ lParam ÒâÒ塣ΪÁËÓû§Äܹ»×Ô¶¨ÒåÏûÏ¢£¬MiniGUI ¶¨ÒåÁË MSG_USER ºê£¬¿ÉÈç϶¨Òå×Ô¼ºµÄÏûÏ¢£º

#define MSG_MYMESSAGE1  (MSG_USER + 1)
#define MSG_MYMESSAGE2  (MSG_USER + 2)

    Óû§¿ÉÒÔÔÚ×Ô¼ºµÄ³ÌÐòÖÐʹÓÃ×Ô¶¨ÒåÏûÏ¢£¬²¢ÀûÓÃ×Ô¶¨ÒåÏûÏ¢´«µÝÊý¾Ý¡£

    ÔÚÀí½âÏûÏ¢Ö®ºó£¬ÎÒÃÇ¿´ÏûϢѭ»·¡£¼ò¶øÑÔÖ®£¬ÏûϢѭ»·¾ÍÊÇÒ»¸öÑ­»·Ì壬ÔÚÕâ¸öÑ­»·ÌåÖУ¬³ÌÐòÀûÓà GetMessage º¯Êý²»Í£µØ´ÓÏûÏ¢¶ÓÁÐÖлñµÃÏûÏ¢£¬È»ºóÀûÓà DispatchMessage º¯Êý½«ÏûÏ¢·¢Ë͵½Ö¸¶¨µÄ´°¿Ú£¬Ò²¾ÍÊǵ÷ÓÃÖ¸¶¨´°¿ÚµÄ´°¿Ú¹ý³Ì£¬²¢´«µÝÏûÏ¢¼°Æä²ÎÊý¡£µäÐ͵ÄÏûϢѭ»·ÈçÏÂËùʾ£º

while (GetMessage (&Msg, hMainWnd)) {
       TranslateMessage (&Msg);
       DispatchMessage (&Msg);
}

    ÈçÉÏËùʾ£¬GetMessage º¯Êý´Ó hMainWnd ´°¿ÚËùÊôµÄÏûÏ¢¶ÓÁе±ÖлñµÃÏûÏ¢£¬È»ºóµ÷Óà TranslateMessage º¯Êý½« MSG_KEYDOWN ºÍ MSG_KEYUP ÏûÏ¢·­Òë³É MSG_CHAR ÏûÏ¢£¬×îºóµ÷Óà DispatchMessage º¯Êý½«ÏûÏ¢·¢Ë͵½Ö¸¶¨µÄ´°¿Ú¡£

    ÔÚ MiniGUI-Threads °æ±¾ÖУ¬Ã¿¸ö½¨Á¢Óд°¿ÚµÄ GUI Ïß³ÌÓÐ×Ô¼ºµÄÏûÏ¢¶ÓÁУ¬¶øÇÒ£¬ËùÓÐÊôÓÚͬһÏ̵߳Ĵ°¿Ú¹²Ïíͬһ¸öÏûÏ¢¶ÓÁС£Òò´Ë£¬GetMessage º¯Êý½«»ñµÃËùÓÐÓë hMainWnd ´°¿ÚÔÚͬһÏß³ÌÖеĴ°¿ÚµÄÏûÏ¢¡£

    ¶øÔÚ MiniGUI-Lite °æ±¾ÖУ¬Ö»ÓÐÒ»¸öÏûÏ¢¶ÓÁУ¬GetMessage ½«´Ó¸ÃÏûÏ¢¶ÓÁе±ÖлñµÃËùÓеÄÏûÏ¢£¬¶øºöÂÔ hMainWnd ²ÎÊý¡£

3 ¼¸¸öÖØÒªµÄÏûÏ¢´¦Àíº¯Êý
    ³ýÁËÉÏÃæÌáµ½µÄ GetMessage ºÍ TranslateMessage¡¢DispatchMessage º¯ÊýÒÔÍ⣬MiniGUI Ö§³ÖÈçϼ¸¸öÏûÏ¢´¦Àíº¯Êý¡£

    PostMessage£º¸Ãº¯Êý½«ÏûÏ¢·Åµ½Ö¸¶¨´°¿ÚµÄÏûÏ¢¶ÓÁкóÁ¢¼´·µ»Ø¡£ÕâÖÖ·¢ËÍ·½Ê½³ÆΪ"ÓʼÄ"ÏûÏ¢¡£Èç¹ûÏûÏ¢¶ÓÁÐÖеÄÓʼÄÏûÏ¢»º³åÇøÒÑÂú£¬Ôò¸Ãº¯Êý·µ»Ø´íÎóÖµ¡£ÔÚÏÂÒ»¸öÏûϢѭ»·ÖУ¬ÓÉ GetMessage º¯Êý»ñµÃÕâ¸öÏûÏ¢Ö®ºó£¬´°¿Ú²Å»á´¦Àí¸ÃÏûÏ¢¡£PostMessage Ò»°ãÓÃÓÚ·¢ËÍһЩ·Ç¹Ø¼üÐÔµÄÏûÏ¢¡£±ÈÈçÔÚ MiniGUI ÖУ¬Êó±êºÍ¼üÅÌÏûÏ¢¾ÍÊÇͨ¹ý PostMessage º¯Êý·¢Ë͵ġ£

    SendMessage£º¸Ãº¯ÊýºÍ PostMessage º¯Êý²»Í¬£¬ËüÔÚ·¢ËÍÒ»ÌõÏûÏ¢¸øÖ¸¶¨´°¿Úʱ£¬½«µÈ´ý¸ÃÏûÏ¢±»´¦ÀíÖ®ºó²Å»á·µ»Ø¡£µ±ÐèÒªÖªµÀij¸öÏûÏ¢µÄ´¦Àí½á¹ûʱ£¬Ê¹Óøú¯Êý·¢ËÍÏûÏ¢£¬È»ºó¸ù¾ÝÆä·µ»ØÖµ½øÐд¦Àí¡£ÔÚ MiniGUI-Threads µ±ÖУ¬Èç¹û·¢ËÍÏûÏ¢µÄÏ̺߳ͽÓÊÕÏûÏ¢µÄÏ̲߳»ÊÇͬһ¸öỊ̈߳¬·¢ËÍÏûÏ¢µÄÏ߳̽«×èÈû²¢µÈ´ýÁíÒ»¸öÏ̵߳Ĵ¦Àí½á¹û£¬È»ºó¼ÌÐøÔËÐУ»·ñÔò£¬SendMessage º¯Êý½«Ö±½Óµ÷ÓýÓÊÕÏûÏ¢´°¿ÚµÄ´°¿Ú¹ý³Ìº¯Êý¡£MiniGUI-Lite ÔòºÍÉÏÃæµÄµÚ¶þÖÖÇé¿öÒ»Ñù£¬Ö±½Óµ÷ÓýÓÊÕÏûÏ¢´°¿ÚµÄ´°¿Ú¹ý³Ìº¯Êý¡£

    SendNotifyMessage£º¸Ãº¯ÊýºÍ PostMessage ÏûÏ¢ÀàËÆ£¬Ò²ÊDz»µÈ´ýÏûÏ¢±»´¦Àí¼´·µ»Ø¡£µ«ºÍ PostMessage ÏûÏ¢²»Í¬£¬Í¨¹ý¸Ãº¯Êý·¢Ë͵ÄÏûÏ¢²»»áÒòΪ»º³åÇøÂú¶ø¶ªÊ§£¬ÒòΪϵͳ²ÉÓÃÁ´±íµÄÐÎʽ´¦ÀíÕâÖÖÏûÏ¢¡£Í¨¹ý¸Ãº¯Êý·¢Ë͵ÄÏûÏ¢Ò»°ã³ÆΪ"֪ͨÏûÏ¢"£¬Ò»°ãÓÃÀ´´Ó¿Ø¼þÏòÆ丸´°¿Ú·¢ËÍ֪ͨÏûÏ¢¡£

    PostQuitMessage£º¸ÃÏûÏ¢ÔÚÏûÏ¢¶ÓÁÐÖÐÉèÖÃÒ»¸ö QS_QUIT ±êÖ¾¡£GetMessage ÔÚ´ÓÖ¸¶¨ÏûÏ¢¶ÓÁÐÖлñÈ¡ÏûϢʱ£¬»á¼ì²é¸Ã±êÖ¾£¬Èç¹ûÓÐ QS_QUIT ±êÖ¾£¬GetMessage ÏûÏ¢½«·µ»Ø FALSE£¬´Ó¶ø¿ÉÒÔÀûÓø÷µ»ØÖµÖÕÖ¹ÏûϢѭ»·¡£

4 MiniGUI-Threads ºÍ MiniGUI-Lite ÔÚÏûÏ¢´¦ÀíÉϵIJ»Í¬
±í 1 ×ܽáÁË MiniGUI-Threads ºÍ MiniGUI-Lite ÔÚÏûÏ¢´¦ÀíÉϵIJ»Í¬

±í 1 MiniGUI-Threads ºÍ MiniGUI-Lite ÔÚÏûÏ¢´¦ÀíÉϵIJ»Í¬

# MiniGUI-Threads
* MiniGUI-Lite

¶àÏûÏ¢¶ÓÁÐ
    # ÿ¸ö´´½¨´°¿ÚµÄÏß³ÌÓµÓжÀÁ¢µÄÏûÏ¢¶ÓÁÐ
    * Ö»ÓÐÒ»¸öÏûÏ¢¶ÓÁС£ËùÓд°¿Ú¹²ÏíÒ»¸öÏûÏ¢¶ÓÁС£³ý·ÇǶÌ×ÏûϢѭ»·£¬·ñÔòÒ»¸ö³ÌÐòÖÐÖ»ÓÐÒ»¸öÏûϢѭ»·¡£

ÄÚ½¨¶àÏ̴߳¦Àí
    # ÊÇ¡£¿ÉÒÔ×Ô¶¯´¦Àí¿çÏ̵߳ÄÏûÏ¢´«µÝ
    * ²»ÄÜ¡£´ÓÒ»¸öÏß³ÌÏòÁíÍâÒ»¸öÏ̷߳¢ËÍ»òÕßÓʼÄÏûϢʱ£¬±ØÐëͨ¹ý»¥³â´¦Àí±£»¤ÏûÏ¢¶ÓÁС£

ÆäËû
    # ¿ÉÒÔÀûÓà PostSyncMessage º¯Êý¿çÏ̷߳¢ËÍÏûÏ¢£¬²¢µÈ´ýÏûÏ¢µÄ´¦Àí½á¹û
    * ²»ÄÜʹÓà PostSyncMessage¡¢SendAsynMessage µÈÏûÏ¢¡£

5 ´°¿ÚµÄ½¨Á¢ºÍÏú»Ù

5.1 ´°¿ÚµÄ½¨Á¢
    ÎÒÃÇÖªµÀ£¬MiniGUI µÄ API ÀàËÆ Win32 µÄ API¡£Òò´Ë£¬´°¿ÚµÄ½¨Á¢¹ý³ÌºÍ Windows ³ÌÐò»ù±¾ÀàËÆ¡£²»¹ýÒ²ÓÐһЩ²î±ð¡£Ê×ÏÈÎÒÃǻعËһϠWindows Ó¦ÓóÌÐòµÄ¿ò¼Ü£º

    ·ÔÚ WinMain () Öд´½¨´°¿Ú£¬Ê¹ÓÃÒÔϲ½Ö裺´´½¨´°¿ÚÀà¡¢µÇ¼Ç´°¿ÚÀà¡¢´´½¨²¢ÏÔʾ´°¿Ú¡¢Æô¶¯ÏûϢѭ»·¡£
    ·ÔÚ WndProc () ÖУ¬¸ºÔð¶Ô·¢µ½´°¿ÚÖеĸ÷ÖÖÏûÏ¢½øÐÐÏìÓ¦¡£
    ·ÔÚ MiniGUI ÖÐҲͬÑùÒªÓÐÕâÁ½¸öº¯Êý¡£²»¹ýÉÔ΢Óе㲻ͬ¡£³ÌÐòµÄÈë¿Úº¯ÊýÃû×Ö½ÐMiniGUIMain ()£¬Ëü¸ºÔð´´½¨³ÌÐòµÄÖ÷´°¿Ú¡£ÔÚ½¨Á¢Ö÷´°¿ÚÖ®ºó£¬³ÌÐò½øÈëÏûϢѭ»·¡£

    ÔÚ Win32 ³ÌÐòÖУ¬ÔÚ½¨Á¢Ò»¸öÖ÷´°¿Ú֮ǰ£¬³ÌÐòÊ×ÏÈҪע²áÒ»¸ö´°¿ÚÀ࣬Ȼºó´´½¨Ò»¸öÊôÓڸô°¿ÚÀàµÄÖ÷´°¿Ú¡£MiniGUI ȴûÓÐÔÚÖ÷´°¿ÚÖÐʹÓô°¿ÚÀàµÄ¸ÅÄî¡£ÔÚ MiniGUI ³ÌÐòÖУ¬Ê×Ïȳõʼ»¯Ò»¸ö MAINWINCREATE ½á¹¹£¬¸Ã½á¹¹ÖÐÔªËصĺ¬ÒåÊÇ£º

CreateInfo.dwStyle£º ´°¿Ú·ç¸ñ
CreateInfo.spCaption£º ´°¿ÚµÄ±êÌâ
CreateInfo.dwExStyle £º ´°¿ÚµÄ¸½¼Ó·ç¸ñ
CreateInfo.hMenu£º ¸½¼ÓÔÚ´°¿ÚÉϵIJ˵¥¾ä±ú
CreateInfo.hCursor£º ÔÚ´°¿ÚÖÐËùʹÓõÄÊó±ê¹â±ê¾ä±ú
CreateInfo.hIcon£º ³ÌÐòµÄͼ±ê
CreateInfo.MainWindowProc£º ¸Ã´°¿ÚµÄÏûÏ¢´¦Àíº¯ÊýÖ¸Õë
CreateInfo.lx£º ´°¿Ú×óÉϽÇÏà¶ÔÆÁÄ»µÄ¾ø¶Ôºá×ø±ê£¬ÒÔÏóËصã±íʾ
CreateInfo.ty£º ´°¿Ú×óÉϽÇÏà¶ÔÆÁÄ»µÄ¾ø¶Ô×Ý×ø±ê£¬ÒÔÏóËصã±íʾ
CreateInfo.rx£º ´°¿ÚµÄ³¤£¬ÒÔÏóËصã±íʾ
CreateInfo.by£º ´°¿ÚµÄ¸ß£¬ÒÔÏóËصã±íʾ
CreateInfo.iBkColor£º ´°¿Ú±³¾°ÑÕÉ«
CreateInfo.dwAddData£º ¸½´ø¸ø´°¿ÚµÄÒ»¸ö 32 λֵ
CreateInfo.hHosting£º ´°¿ÚÏûÏ¢¶ÓÁÐËùÊô

ÆäÖÐÓÐÈçϼ¸µãÒªÌرð˵Ã÷£º

    CreateInfo.dwAddData£ºÔÚ³ÌÐò±àÖƹý³ÌÖУ¬Ó¦¸Ã¾¡Á¿¼õÉÙ¾²Ì¬±äÁ¿£¬µ«ÊÇÈçºÎ²»Ê¹Óþ²Ì¬±äÁ¿¶ø¸ø´°¿Ú´«µÝ²ÎÊýÄØ£¿Õâʱ¿ÉÒÔʹÓÃÕâ¸öÓò¡£¸ÃÓòÊÇÒ»¸ö 32 λµÄÖµ£¬Òò´Ë¿ÉÒÔ°ÑËùÓÐÐèÒª´«µÝ¸ø´°¿ÚµÄ²ÎÊý±àÖƳÉÒ»¸ö½á¹¹£¬¶ø½«½á¹¹µÄÖ¸Õ븳Óè¸ÃÓò¡£ÔÚ´°¿Ú¹ý³ÌÖУ¬¿ÉÒÔʹÓà GetWindowAdditionalData º¯Êý»ñÈ¡¸ÃÖ¸Õ룬´Ó¶ø»ñµÃËùÐèÒª´«µÝµÄ²ÎÊý¡£
    CreateInfo.hHosting£º¸ÃÓò±íʾµÄÊǽ«Òª½¨Á¢µÄÖ÷´°¿ÚʹÓÃÄĸöÖ÷´°¿ÚµÄÏûÏ¢¶ÓÁС£Ê¹ÓÃÆäËûÖ÷´°¿ÚÏûÏ¢¶ÓÁеÄÖ÷´°¿Ú£¬ÎÒÃdzÆΪ"±»ÍйÜ"µÄÖ÷´°¿Ú¡£µ±È»£¬ÕâÖ»ÔÚ MiniGUI-Threads °æ±¾ÖÐÓÐЧ¡£
MainWinProc º¯Êý¸ºÔð´¦Àí´°¿ÚÏûÏ¢¡£Õâ¸öº¯Êý¾ÍÊÇÖ÷´°¿ÚµÄ"´°¿Ú¹ý³Ì"¡£´°¿Ú¹ý³ÌÒ»°ãÓÐËĸöÈë¿Ú²ÎÊý£¬µÚÒ»¸öÊÇ´°¿Ú¾ä±ú£¬µÚ¶þ¸öÊÇÏûÏ¢ÀàÐÍ£¬µÚÈý¸öºÍµÚËĸöÊÇÏûÏ¢µÄÁ½¸ö²ÎÊý¡£

    ÔÚ×¼±¸ºÃMAINWINCREATE ½á¹¹Ö®ºó£¬¾Í¿ÉÒÔµ÷Óà CreateMainWindow º¯Êý½¨Á¢Ö÷´°¿ÚÁË¡£ÔÚ½¨Á¢Ö÷´°¿ÚÖ®ºó£¬µäÐ͵ijÌÐò½«½øÈëÏûϢѭ»·¡£ÈçÏÂËùʾ£º

int MiniGUIMain (int args, const char* arg[])
{
    MSG Msg;
    MAINWINCREATE CreateInfo;
    HWND hWnd;

    // ³õʼ»¯ MAINWINCREATE ½á¹¹
    CreateInfo.dwStyle = WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | WS_CAPTION;
    CreateInfo.spCaption= "MiniGUI step three";
    CreateInfo.dwExStyle = WS_EX_NONE;
    CreateInfo.hMenu = createmenu();
    CreateInfo.hCursor = GetSystemCursor(0);
    CreateInfo.hIcon = 0;
    CreateInfo.MainWindowProc = MainWinProc;
    CreateInfo.lx = 0;
    CreateInfo.ty = 0;
    CreateInfo.rx = 640;
    CreateInfo.by = 480;
    CreateInfo.iBkColor = COLOR_lightwhite;
    CreateInfo.dwAddData = 0;
    CreateInfo.hHosting = HWND_DESKTOP;

    // ½¨Á¢Ö÷´°¿Ú
    hWnd = CreateMainWindow(&CreateInfo);
    if (hWnd == HWND_INVALID)
        return 0;

    // ÏÔʾÖ÷´°¿Ú
    ShowWindow (hWnd, SW_SHOWNORMAL);

    //  ½øÈëÏûϢѭ»·
    while (GetMessage(&Msg, hWnd)) {
        TranslateMessage (&Msg);
        DispatchMessage(&Msg);
    }

    MainWindowThreadCleanup (hWnd);
    return 0;
}

    ×¢Ò⣬ºÍ Windows ³ÌÐò²»Í¬µÄÊÇ£¬ÔÚÍ˳öÏûϢѭ»·Ö®ºó£¬»¹Òªµ÷ÓÃÒ»¸öº¯Êý£¬¼´ MainWindowThreadCleaup º¯Êý¡£¸Ãº¯ÊýµÄ¹¤×÷ÊÇÏú»ÙÖ÷´°¿ÚµÄÏûÏ¢¶ÓÁУ¬Ò»°ãÔÚÏ̻߳òÕß½ø³ÌµÄ×îºóµ÷Óá£

5.2 ´°¿ÚµÄÏú»Ù
    ÒªÏú»ÙÒ»¸öÖ÷´°¿Ú£¬¿ÉÒÔÀûÓà DestroyMainWindow (hWnd) º¯Êý¡£¸Ãº¯Êý½«Ïú»ÙÖ÷´°¿Ú£¬µ«²»»áÏú»ÙÖ÷´°¿ÚËùʹÓõÄÏûÏ¢¶ÓÁУ¬¶øҪʹÓÃMainWindowThreadCleaup ×îÖÕÇå³ýÖ÷´°¿ÚËùʹÓõÄÏûÏ¢¶ÓÁС£

    Ò»°ã¶øÑÔ£¬Ò»¸öÖ÷´°¿Ú¹ý³ÌÔÚ½ÓÊÕµ½ MSG_CLOSE ÏûÏ¢Ö®ºó»áÏú»ÙÖ÷´°¿Ú£¬²¢µ÷Óà PostQuitMessage ÏûÏ¢ÖÕÖ¹ÏûϢѭ»·¡£ÈçÏÂËùʾ£º

case MSG_CLOSE:
    // Ïú»Ù´°¿ÚʹÓõÄ×ÊÔ´
    DestroyLogFont (logfont1);
    DestroyLogFont (logfont2);
    DestroyLogFont (logfont3);

    // Ïú»Ù×Ó´°¿Ú
    DestroyWindow(hWndButton);
    DestroyWindow(hWndEdit);
    // Ïú»ÙÖ÷´°¿Ú
    DestroyMainWindow (hWnd);
    // ·¢ËÍ MSG_QUIT ÏûÏ¢
    PostQuitMessage(hWnd);
    return 0;


6 ¼¸¸öÖØÒªÏûÏ¢
    ÔÚ´°¿Ú£¨°üÀ¨Ö÷´°¿ÚºÍ×Ó´°¿ÚÔÚÄÚ£©µÄÉú´æÖÜÆÚµ±ÖУ¬Óм¸¸öÖØÒªµÄÏûÏ¢ÐèÒª×Ðϸ´¦Àí¡£ÏÂÃæÃèÊöÕâЩÏûÏ¢µÄ¸ÅÄîºÍµäÐÍ´¦Àí¡£

6.1 MSG_NCCREATE
    ¸ÃÏûÏ¢ÔÚ MiniGUI ½¨Á¢Ö÷´°¿ÚµÄ¹ý³ÌÖз¢Ë͵½´°¿Ú¹ý³Ì¡£lParam Öаüº¬ÁËÓÉ CreateMainWindow ´«µÝ½øÈëµÄ pCreateInfo ½á¹¹Ö¸Õë¡£Äú¿ÉÒÔÔÚ¸ÃÏûÏ¢µÄ´¦Àí¹ý³ÌÖÐÐÞ¸Ä pCreateInfo ½á¹¹ÖеÄijЩֵ¡£

6.2 MSG_SIZECHANGING
    ¸ÃÏûÏ¢´°¿Ú³ß´ç·¢Éú±ä»¯Ê±£¬»òÕß½¨Á¢´°¿Úʱ·¢Ë͵½´°¿Ú¹ý³Ì£¬ÓÃÀ´È·¶¨´°¿Ú´óС¡£wParam °üº¬Ô¤ÆڵĴ°¿Ú³ß´çÖµ£¬¶ø lParam ÓÃÀ´±£´æ½á¹ûÖµ¡£MiniGUI µÄĬÈÏ´¦ÀíÊÇ£¬

case MSG_SIZECHANGING:
    memcpy ((PRECT)lParam, (PRECT)wParam, sizeof (RECT));
    return 0;

    Äã¿ÉÒԽػñ¸ÃÏûÏ¢µÄ´¦Àí£¬´Ó¶øÈü´½«´´½¨µÄ´°¿ÚλÓÚÖ¸¶¨µÄλÖ㬻òÕß¾ßÓй̶¨µÄ´óС£¬±ÈÈçÔÚ SPINBOX ¿Ø¼þÖУ¬¾Í´¦ÀíÁ˸ÃÏûÏ¢£¬Ê¹Ö®¾ßÓй̶¨µÄ´óС£º

case MSG_SIZECHANGING:
{
    const RECT* rcExpect = (const RECT*) wParam;
    RECT* rcResult = (RECT*) lPraram;

    rcResult->left = rcExpect->left;
    rcResult->top = rcExpect->top;
    rcResult->right = rcExpect->left +  _WIDTH;
    rcResult->bottom = rcExpect->left +  _HEIGHT;
    return 0;
}

6.3 MSG_CHANGESIZE
    ÔÚÈ·Á¢´°¿Ú´óС֮ºó£¬¸ÃÏûÏ¢±»·¢Ë͵½´°¿Ú¹ý³Ì£¬ÓÃÀ´Í¨ÖªÈ·¶¨Ö®ºóµÄ´°¿Ú´óС¡£wParam °üº¬ÁË´°¿Ú´óС RECT µÄÖ¸Õë¡£×¢ÒâÓ¦ÓóÌÐòÓ¦¸Ã½«¸ÃÏûÏ¢´«µÝ¸ø MiniGUI ½øÐÐĬÈÏ´¦Àí¡£

6.4 MSG_SIZECHANGED
    ¸ÃÏûÏ¢ÓÃÀ´È·¶¨´°¿Ú¿Í»§ÇøµÄ´óС£¬ºÍ MSG_SIZECHANGING ÏûÏ¢ÀàËÆ¡£wParam ²ÎÊý°üº¬´°¿Ú´óСÐÅÏ¢£¬lParam ²ÎÊýÊÇÓÃÀ´±£´æ´°¿Ú¿Í»§Çø´óСµÄ RECT Ö¸Õ룬²¢ÇÒ¾ßÓÐĬÈÏÖµ¡£Èç¹û¸ÃÏûÏ¢µÄ´¦Àí·µ»Ø·ÇÁãÖµ£¬Ôò½«²ÉÓà lParam µ±Öаüº¬µÄ´óСֵ×÷Ϊ¿Í»§ÇøµÄ´óС£»·ñÔò£¬½«ºöÂÔ¸ÃÏûÏ¢µÄ´¦Àí¡£±ÈÈçÔÚ SPINBOX ¿Ø¼þÖУ¬¾Í´¦ÀíÁ˸ÃÏûÏ¢£¬²¢Ê¹¿Í»§ÇøÕ¼¾ßËùÓеĴ°¿Ú·¶Î§£º

case MSG_SIZECHANGED
{
    RECT* rcClient = (RECT*) lPraram;

    rcClient->right = rcClient->left  +  _WIDTH;
    rcClient->bottom = rcClient->top +  _HEIGHT;
    return 0;
}

6.5 MSG_CREATE
    ¸ÃÏûÏ¢ÔÚ½¨Á¢ºÃµÄ´°¿Ú³É¹¦Ìí¼Óµ½ MiniGUI µÄ´°¿Ú¹ÜÀíÆ÷Ö®ºó·¢Ë͵½´°¿Ú¹ý³Ì¡£Õâʱ£¬Ó¦ÓóÌÐò¿ÉÒÔÔÚÆäÖд´½¨×Ó´°¿Ú¡£Èç¹û¸ÃÏûÏ¢·µ»Ø·ÇÁãÖµ£¬Ôò½«Ïú»Ùн¨µÄ´°¿Ú¡£×¢Ò⣬ÔÚ MSG_NCCREATE ÏûÏ¢±»·¢ËÍʱ£¬´°¿ÚÉÐδÕý³£½¨Á¢£¬ËùÒÔ²»ÄÜÔÚ MSG_NCCREATE ÏûÏ¢Öн¨Á¢×Ó´°¿Ú¡£

6.6 MSG_PAINT
    ¸ÃÏûÏ¢ÔÚÐèÒª½øÐд°¿ÚÖØ»æʱ·¢Ë͵½´°¿Ú¹ý³Ì¡£MiniGUI ͨ¹ýÅжϴ°¿ÚÊÇ·ñº¬ÓÐÎÞЧÇøÓòÀ´È·¶¨ÊÇ·ñÐèÒªÖػ档µ±´°¿ÚÔÚ³õʼÏÔʾ¡¢´ÓÒþ²Ø״̬±ä»¯ÎªÏÔʾ״̬¡¢´Ó²¿·Ö²»¿É¼ûµ½¿É¼û״̬£¬»òÕßÓ¦ÓóÌÐòµ÷Óà InvalidateRect º¯Êýʹij¸ö¾ØÐÎÇøÓò±ä³ÉÎÞЧʱ£¬´°¿Ú½«¾ßÓÐÌض¨µÄÎÞЧÇøÓò¡£Õâʱ£¬MiniGUI ½«ÔÚ´¦ÀíÍêËùÓеÄÓʼÄÏûÏ¢¡¢Í¨ÖªÏûÏ¢Ö®ºó´¦ÀíÎÞЧÇøÓò£¬²¢Ïò´°¿Ú¹ý³Ì·¢ËÍ MSG_PAINT ÏûÏ¢¡£¸ÃÏûÏ¢µÄµäÐÍ´¦ÀíÈçÏ£º

case MSG_PAINT:
{
    HDC hdc;

    hdc = BeginPaint (hWnd);

    // ʹÓà hdc »æÖÆ´°¿Ú
    ...

    EndPaint (hWnd, hdc);
    break;
}

6.7 MSG_DESTROY
    ¸ÃÏûÏ¢ÔÚÓ¦ÓóÌÐòµ÷Óà DestroyMainWindow »òÕß DestroyWindow ʱ·¢Ë͵½´°¿Ú¹ý³Ìµ±ÖУ¬ÓÃÀ´Í¨ÖªÏµÍ³¼´½«Ïú»ÙÒ»¸ö´°¿Ú¡£Èç¹û¸ÃÏûÏ¢µÄ´¦Àí·µ»Ø·ÇÁãÖµ£¬Ôò½«È¡ÏûÏú»Ù¹ý³Ì¡£

7 Hello, World
    ÔÚÕâ¸öС½Úµ±ÖУ¬ÎÒÃǸø³öÒ»¸ö¼òµ¥µÄʾÀý³ÌÐò£¬¸Ã³ÌÐòÔÚ´°¿ÚÖдòÓ¡"Hello, world!"£º

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>

static int HelloWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;

    switch (message) {
        case MSG_PAINT:
            hdc = BeginPaint (hWnd);
            TexOut (hdc, 0, 0, "Hello, world!");
            EndPaint (hWnd, hdc);
        break;

        case MSG_CLOSE:
            DestroyMainWindow (hWnd);
            PostQuitMessage (hWnd);
        return 0;
    }

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}

static void InitCreateInfo (PMAINWINCREATE pCreateInfo)
{
    pCreateInfo->dwStyle = WS_CAPTION | WS_VISIBLE;
    pCreateInfo->dwExStyle = 0;
    pCreateInfo->spCaption = "Hello, world!" ;
    pCreateInfo->hMenu = 0;
    pCreateInfo->hCursor = GetSystemCursor (0);
    pCreateInfo->hIcon = 0;
    pCreateInfo->MainWindowProc = HelloWinProc;
    pCreateInfo->lx = 0;
    pCreateInfo->ty = 0;
    pCreateInfo->rx = 320;
    pCreateInfo->by = 240;
    pCreateInfo->iBkColor = PIXEL_lightwhite;
    pCreateInfo->dwAddData = 0;
    pCreateInfo->hHosting = HWND_DESKTOP;
}

int MiniGUIMain (int args, const char* arg[])
{
    MSG Msg;
    MAINWINCREATE CreateInfo;
    HWND hMainWnd;

#ifdef _LITE_VERSION
    SetDesktopRect (0, 0, 800, 600);
#endif

    InitCreateInfo (&CreateInfo);

    hMainWnd = CreateMainWindow (&CreateInfo);
    if (hMainWnd == HWND_INVALID)
        return -1;

    while (GetMessage (&Msg, hMainWnd)) {
        DispatchMessage (&Msg);
    }

    MainWindowThreadCleanup (hMainWnd);
    return 0;
}

    ºÜÏÔÈ»£¬ÕâÊÇÒ»¸ö·Ç³£¼òµ¥µÄ³ÌÐò¡£¸Ã³ÌÐòʹÓÃÁË MiniGUI µÄĬÈϹý³ÌÀ´´¦ÀíÎÒÃÇÇ°ÃæÌáµ½µÄÐí¶àÏûÏ¢£¬¶ø½ö½ö´¦ÀíÁË MSG_PAINT ºÍ MSG_CLOSE Á½ÌõÏûÏ¢¡£µ±Óû§µ¥»÷±êÌâÀ¸ÉϵĹرհ´Å¥Ê±£¬MiniGUI ½«·¢ËÍ MSG_CLOSE µ½´°¿Ú¹ý³Ì¡£Õâʱ£¬Ó¦ÓóÌÐò¾Í¿ÉÒÔÏú»Ù´°¿Ú£¬²¢ÖÕÖ¹ÏûϢѭ»·£¬×îÖÕÍ˳ö³ÌÐò¡£

8 С½á
    ±¾ÎÄÃèÊöÁË MiniGUI ÖÐÓëÏûÏ¢Ïà¹ØµÄ¼¸¸öÖØÒªº¯Êý£¬²¢½²ÊöÁË MiniGUI-Threads ºÍ MiniGUI-Lite ÔÚÏûÏ¢»úÖÆʵÏÖÉϵļ¸¸ö²»Í¬¡£±¾ÎÄ»¹½²ÊöÁËÔÚ MiniGUI ÖеĴ°¿Ú½¨Á¢ºÍÏú»Ù¹ý³Ì£¬²¢½âÊÍÁË´°¿Ú¹ý³ÌµÄ¸ÅÄîÒÔ¼°Ò»Ð©ÖØÒªÏûÏ¢µÄ´¦Àí¡£×îºó£¬±¾Îĸø³öÁËÒ»¸ö¼òµ¥µÄ MiniGUI µÄʾÀý³ÌÐò£¬¸Ã³ÌÐò½¨Á¢´°¿Ú£¬²¢ÔÚÆäÖдòÓ¡"Hello, world!"¡£


[Ŀ¼]


¶Ô»°¿òºÍ¿Ø¼þ±à³Ì

1 ÒýÑÔ
    ¶Ô»°¿ò±à³ÌÊÇÒ»¸ö¿ìËÙ¹¹½¨Óû§½çÃæµÄ¼¼Êõ¡£Í¨³££¬ÎÒÃDZàд¼òµ¥µÄͼÐÎÓû§½çÃæʱ£¬¿ÉÒÔͨ¹ýµ÷Óà CreateWindow º¯ÊýÖ±½Ó´´½¨ËùÓÐÐèÒªµÄ×Ó´°¿Ú£¬¼´¿Ø¼þ¡£µ«ÔÚͼÐÎÓû§½çÃæ±È½Ï¸´ÔÓµÄÇé¿öÏ£¬Ã¿½¨Á¢Ò»¸ö¿Ø¼þ¾Íµ÷ÓÃÒ»´Î CreateWindow º¯Êý£¬²¢´«µÝÐí¶à¸´ÔÓ²ÎÊýµÄ·½·¨ºÜ²»¿ÉÈ¡¡£Ö÷ÒªÔ­ÒòÖ®Ò»£¬¾ÍÊdzÌÐò´úÂëºÍÓÃÀ´½¨Á¢¿Ø¼þµÄÊý¾Ý»ìÔÚÒ»Æ𣬲»ÀûÓÚά»¤¡£Îª´Ë£¬Ò»°ãµÄ GUI ϵͳ¶¼»áÌṩһÖÖ»úÖÆ£¬ÀûÓÃÕâÖÖ»úÖÆ£¬Í¨¹ýÖ¸¶¨Ò»¸öÄ£°å£¬GUI ϵͳ¾Í¿ÉÒÔ¸ù¾Ý´ËÄ£°å½¨Á¢ÏàÓ¦µÄÖ÷´°¿ÚºÍ¿Ø¼þ¡£MiniGUI Ò²ÌṩÕâÖÖ·½·¨£¬Í¨¹ý½¨Á¢¶Ô»°¿òÄ£°å£¬¾Í¿ÉÒÔ½¨Á¢Ä£Ì¬»òÕß·Çģ̬µÄ¶Ô»°¿ò¡£

    ±¾ÎÄÊ×ÏȽ²½â×é³É¶Ô»°¿òµÄ»ù´¡£¬¼´¿Ø¼þµÄ»ù±¾¸ÅÄȻºó½²½â¶Ô»°Ä£°åµÄ¶¨Ò壬²¢ËµÃ÷ģ̬ºÍ·Çģ̬¶Ô»°¿òÖ®¼äµÄÇø±ðÒÔ¼°±à³Ì¼¼Êõ¡£

2 ¿Ø¼þºÍ¿Ø¼þÀà
    Ðí¶àÈ˶Կؼþ£¨»òÕß²¿¼þ£¬widget£©µÄ¸ÅÄîÒѾ­Ï൱ÊìϤÁË¡£¿Ø¼þ¿ÉÒÔÀí½âΪÖ÷´°¿ÚÖеÄ×Ó´°¿Ú¡£ÕâЩ×Ó´°¿ÚµÄÐÐΪºÍÖ÷´°¿ÚÒ»Ñù£¬¼´Äܹ»½ÓÊÕ¼üÅ̺ÍÊó±êµÈÍⲿÊäÈ룬Ҳ¿ÉÒÔÔÚ×Ô¼ºµÄÇøÓòÄÚ½øÐÐÊä³ö¨D¨DÖ»ÊÇËüÃǵÄËùÓл±»ÏÞÖÆÔÚÖ÷´°¿ÚÖС£MiniGUI Ò²Ö§³Ö×Ó´°¿Ú£¬²¢ÇÒ¿ÉÒÔÔÚ×Ó´°¿ÚÖÐǶÌ×½¨Á¢×Ó´°¿Ú¡£ÎÒÃǽ« MiniGUI ÖеÄËùÓÐ×Ó´°¿Ú¾ù³ÆΪ¿Ø¼þ¡£

    ÔÚ Windows »ò X Window ÖУ¬ÏµÍ³»áÔ¤Ïȶ¨ÒåһЩ¿Ø¼þÀ࣬µ±ÀûÓÃij¸ö¿Ø¼þÀà´´½¨¿Ø¼þÖ®ºó£¬ËùÓÐÊôÓÚÕâ¸ö¿Ø¼þÀàµÄ¿Ø¼þ¾ù»á¾ßÓÐÏàͬµÄÐÐΪºÍÏÔʾ¡£ÀûÓÃÕâЩ¼¼Êõ£¬¿ÉÒÔÈ·±£Ò»ÖµÄÈË»ú²Ù×÷½çÃ棬¶ø¶Ô³ÌÐòÔ±À´½²£¬¿ÉÒÔÏñ´î»ýľһÑùµØ×齨ͼÐÎÓû§½çÃæ¡£MiniGUI ʹÓÃÁ˿ؼþÀàºÍ¿Ø¼þµÄ¸ÅÄ²¢ÇÒ¿ÉÒÔ·½±ãµØ¶ÔÒÑÓпؼþ½øÐÐÖØÔØ£¬Ê¹µÃÆäÓÐһЩÌØÊâЧ¹û¡£±ÈÈ磬ÐèÒª½¨Á¢Ò»¸öÖ»ÔÊÐíÊäÈëÊý×ֵı༭¿òʱ£¬¾Í¿ÉÒÔͨ¹ýÖØÔØÒÑÓб༭¿ò¶øʵÏÖ£¬¶ø²»ÐèÒªÖØбàдһ¸öеĿؼþÀà¡£

    Èç¹û¶ÁÕßÔø¾­±àд¹ý Windows Ó¦ÓóÌÐòµÄ»°£¬Ó¦¸Ã¼ÇµÃÔÚ½¨Á¢Ò»¸ö´°¿Ú֮ǰ£¬±ØÐëÈ·±£ÏµÍ³ÖдæÔÚд°¿ÚËù¶ÔÓ¦µÄ´°¿ÚÀà¡£ÔÚ Windows ÖУ¬³ÌÐòËù½¨Á¢µÄÿ¸ö´°¿Ú£¬¶¼¶ÔÓ¦×ÅijÖÖ´°¿ÚÀà¡£ÕâÒ»¸ÅÄîºÍÃæÏò¶ÔÏó±à³ÌÖеÄÀà¡¢¶ÔÏóµÄ¹ØϵÀàËÆ¡£½èÓÃÃæÏò¶ÔÏóµÄÊõÓWindows ÖеÄÿ¸ö´°¿Úʵ¼Ê¶¼ÊÇij¸ö´°¿ÚÀàµÄÒ»¸öʵÀý¡£ÔÚ X Window ±à³ÌÖУ¬Ò²ÓÐÀàËƵĸÅÄ±ÈÈçÎÒÃǽ¨Á¢µÄÿһ¸ö Widget£¬Êµ¼Ê¶¼ÊÇij¸ö Widget ÀàµÄʵÀý¡£

    ÕâÑù£¬Èç¹û³ÌÐòÐèÒª½¨Á¢Ò»¸ö´°¿Ú£¬¾ÍÊ×ÏÈҪȷ±£Ñ¡ÔñÕýÈ·µÄ´°¿ÚÀ࣬ÒòΪÿ¸ö´°¿ÚÀà¾ö¶¨Á˶ÔÓ¦´°¿ÚʵÀýµÄ±íÏóºÍÐÐΪ¡£ÕâÀïµÄ±íÏóÖ¸´°¿ÚµÄÍâ¹Û£¬±ÈÈç´°¿Ú±ß¿ò¿í¶È£¬ÊÇ·ñÓбêÌâÀ¸µÈµÈ£¬ÐÐΪָ´°¿Ú¶ÔÓû§ÊäÈëµÄÏìÓ¦¡£Ã¿Ò»¸ö GUI ϵͳ¶¼»áÔ¤¶¨ÒåһЩ´°¿ÚÀ࣬³£¼ûµÄÓа´Å¥¡¢Áбí¿ò¡¢¹ö¶¯Ìõ¡¢±à¼­¿òµÈµÈ¡£Èç¹û³ÌÐòÒª½¨Á¢µÄ´°¿ÚºÜÌØÊ⣬¾ÍÐèÒªÊ×ÏÈ×¢²áÒ»¸ö´°¿ÚÀ࣬Ȼºó½¨Á¢Õâ¸ö´°¿ÚÀàÒ»¸öʵÀý¡£ÕâÑù¾Í´ó´óÌá¸ßÁË´úÂëµÄ¿ÉÖØÓÃÐÔ¡£

    ÔÚ MiniGUI ÖУ¬ÎÒÃÇÈÏΪÖ÷´°¿Úͨ³£ÊÇÒ»ÖֱȽÏÌØÊâµÄ´°¿Ú¡£ÒòΪÖ÷´°¿Ú´úÂëµÄ¿ÉÖØÓÃÐÔÒ»°ãºÜµÍ£¬Èç¹û°´ÕÕͨ³£µÄ·½Ê½ÎªÃ¿¸öÖ÷´°¿Ú×¢²áÒ»¸ö´°¿ÚÀàµÄ»°£¬Ôò»áµ¼Ö¶îÍâ²»±ØÒªµÄ´æ´¢¿Õ¼ä£¬ËùÒÔÎÒÃDz¢Ã»ÓÐÔÚÖ÷´°¿ÚÌṩ´°¿ÚÀàÖ§³Ö¡£µ«Ö÷´°¿ÚÖеÄËùÓÐ×Ó´°¿Ú£¬¼´¿Ø¼þ£¬¾ùÖ§³Ö´°¿ÚÀࣨ¿Ø¼þÀࣩµÄ¸ÅÄî¡£MiniGUI ÌṩÁ˳£ÓõÄÔ¤¶¨Òå¿Ø¼þÀ࣬°üÀ¨°´Å¥£¨°üÀ¨µ¥Ñ¡Å¥¡¢¸´Ñ¡Å¥£©¡¢¾²Ì¬¿ò¡¢Áбí¿ò¡¢½ø¶ÈÌõ¡¢»¬¿é¡¢±à¼­¿òµÈµÈ¡£³ÌÐòÒ²¿ÉÒÔ¶¨ÖÆ×Ô¼ºµÄ¿Ø¼þÀ࣬ע²áºóÔÙ´´½¨¶ÔÓ¦µÄʵÀý¡£±í 1 ¸ø³öÁË MiniGUI Ô¤Ïȶ¨ÒåµÄ¿Ø¼þÀàºÍÏàÓ¦ÀàÃû³Æ¶¨Òå¡£

±í 1 MiniGUI Ô¤¶¨ÒåµÄ¿Ø¼þÀàºÍ¶ÔÓ¦ÀàÃû³Æ

¿Ø¼þÀà ÀàÃû³Æ ºê¶¨Òå ±¸×¢
¾²Ì¬¿ò "static" CTRL_STATIC
°´Å¥ "button" CTRL_BUTTON
Áбí¿ò "listbox" CTRL_LISTBOX
½ø¶ÈÌõ "progressbar" CTRL_PRORESSBAR
»¬¿é "trackbar" CTRL_TRACKBAR
µ¥Ðб༭¿ò "edit"¡¢"sledit" CTRL_EDIT¡¢CTRL_SLEDIT
¶àÐб༭¿ò "medit"¡¢"mledit" CTRL_MEDIT¡¢CTRL_MLEDIT
¹¤¾ßÌõ "toolbar" CTRL_TOOLBAR
²Ëµ¥°´Å¥ "menubutton" CTRL_MENUBUTTON
Ê÷ÐͿؼþ "treeview" CTRL_TREEVIEW °üº¬ÔÚ mgext ¿â£¬¼´MiniGUI À©Õ¹¿âÖС£
ÔÂÀú¿Ø¼þ "monthcalendar" CTRL_MONTHCALENDAR ͬÉÏ
ÐýÅ¥¿Ø¼þ "spinbox" CTRL_SPINBOX ͬÉÏ

    ÔÚ MiniGUI ÖУ¬Í¨¹ýµ÷Óà CreateWindow º¯Êý£¬¿ÉÒÔ½¨Á¢Ä³¸ö¿Ø¼þÀàµÄÒ»¸öʵÀý¡£¿Ø¼þÀà¼È¿ÉÒÔÊDZí 1 ÖÐÔ¤¶¨Òå MiniGUI ¿Ø¼þÀ࣬Ҳ¿ÉÒÔÊÇÓû§×Ô¶¨ÒåµÄ¿Ø¼þÀà¡£Óë CreateWindow º¯ÊýÏà¹ØµÄ¼¸¸öº¯ÊýµÄÔ­ÐÍÈçÏ£¨include/window.h£©£º

904 HWND GUIAPI CreateWindowEx (const char* spClassName, const char* spCaption,
905                   DWORD dwStyle, DWORD dwExStyle, int id,
906                   int x, int y, int w, int h, HWND hParentWnd, DWORD dwAddData);
907 BOOL GUIAPI DestroyWindow (HWND hWnd);
908
909 #define CreateWindow(class_name, caption, style, id, x, y, w, h, parent, add_data) \
910         CreateWindowEx(class_name, caption, style, 0, id, x, y, w, h, parent, add_data)

    CreateWindow º¯Êý½¨Á¢Ò»¸ö×Ó´°¿Ú£¬¼´¿Ø¼þ¡£ËüÖ¸¶¨Á˿ؼþÀà¡¢¿Ø¼þ±êÌâ¡¢¿Ø¼þ·ç¸ñ£¬ÒÔ¼°´°¿ÚµÄ³õʼλÖúʹóС¡£¸Ãº¯Êýͬʱָ¶¨×Ó´°¿ÚµÄ¸¸´°¿Ú¡£CreateWindowEx º¯ÊýµÄ¹¦ÄÜºÍ CreateWindow º¯ÊýÒ»Ö£¬²»¹ý£¬¿ÉÒÔͨ¹ý CreateWindowEx º¯ÊýÖ¸¶¨¿Ø¼þµÄÀ©Õ¹·ç¸ñ¡£DestroyWindow º¯ÊýÓÃÀ´Ïú»ÙÓÃÉÏÊöÁ½¸öº¯Êý½¨Á¢µÄ¿Ø¼þ»òÕß×Ó´°¿Ú¡£

    Çåµ¥ 1 ÖеijÌÐò£¬ÀûÓÃÔ¤¶¨Òå¿Ø¼þÀà´´½¨¿Ø¼þ¡£ÆäÖÐhStaticWnd1 Êǽ¨Á¢ÔÚÖ÷´°¿Ú hWnd Öеľ²Ì¬¿ò£»hButton1¡¢hButton2¡¢hEdit1¡¢hStaticWnd2ÔòÊǽ¨Á¢ÔÚ hStaicWnd1 ÄÚ²¿µÄ¼¸¸ö¿Ø¼þ£¬²¢×÷Ϊ hStaticWnd1 µÄ×ӿؼþ¶ø´æÔÚ£¬½¨Á¢ÁËÁ½¸ö°´Å¥¡¢Ò»¸ö±à¼­¿òºÍÒ»¸ö¾²Ì¬°´Å¥£»¶ø hEdit2 ÊÇ hStaicWnd2 µÄ×ӿؼþ£¬ÊÇ hStaticWnd1 µÄ×Ó×ӿؼþ¡£

Çåµ¥1 ÀûÓÃÔ¤¶¨Òå¿Ø¼þÀà´´½¨¿Ø¼þ

#define IDC_STATIC1     100
#define IDC_STATIC2     150
#define IDC_BUTTON1     110
#define IDC_BUTTON2     120
#define IDC_EDIT1       130
#define IDC_EDIT2       140
int ControlTestWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
        static HWND hStaticWnd1, hStaticWnd2, hButton1, hButton2, hEdit1, hEdit2;
        switch (message) {
        case MSG_CREATE:
        {
            hStaticWnd1 = CreateWindow (CTRL_STATIC,
                                        "This is a static control",
                                        WS_CHILD | SS_NOTIFY | SS_SIMPLE | WS_VISIBLE | WS_BORDER,
                                        IDC_STATIC1,
                                        10, 10, 180, 300, hWnd, 0);
            hButton1    = CreateWindow (CTRL_BUTTON,
                                        "Button1",
                                        WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
                                        IDC_BUTTON1,
                                        20, 20, 80, 20, hStaticWnd1, 0);
            hButton2    = CreateWindow (CTRL_BUTTON,
                                        "Button2",
                                        WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
                                        IDC_BUTTON2,
                                        20, 50, 80, 20, hStaticWnd1, 0);
            hEdit1      = CreateWindow (CTRL_EDIT,
                                        "Edit Box 1",
                                        WS_CHILD | WS_VISIBLE | WS_BORDER,
                                        IDC_EDIT1,
                                        20, 80, 100, 24, hStaticWnd1, 0);
            hStaticWnd2 = CreateWindow (CTRL_STATIC,
                                        "This is child static control",
                                        WS_CHILD | SS_NOTIFY | SS_SIMPLE | WS_VISIBLE | WS_BORDER,
                                        IDC_STATIC1,
                                        20, 110, 100, 50, hStaticWnd1, 0);
            hEdit2      = CreateWindow (CTRL_EDIT,
                                        "Edit Box 2",
                                        WS_CHILD | WS_VISIBLE | WS_BORDER,
                                        IDC_EDIT2,
                                        0, 20, 100, 24, hStaticWnd2, 0);
           break;
          }
.......
    }
    return DefaultMainWinProc (hWnd, message, wParam, lParam);
}


    Óû§Ò²¿ÉÒÔͨ¹ý RegisterWindowClass º¯Êý×¢²á×Ô¼ºµÄ¿Ø¼þÀ࣬²¢½¨Á¢¸Ã¿Ø¼þÀàµÄ¿Ø¼þʵÀý¡£Èç¹û³ÌÐò²»ÔÙʹÓÃij¸ö×Ô¶¨ÒåµÄ¿Ø¼þÀ࣬ÔòÓ¦¸ÃʹÓà UnregisterWindowClass º¯Êý×¢Ïú×Ô¶¨ÒåµÄ¿Ø¼þÀà¡£ÉÏÊöÁ½¸öº¯ÊýÒÔ¼°ºÍ´°¿ÚÀàÏà¹Øº¯ÊýµÄÔ­ÐÍÈçÏ£¨include/window.h£©£º

897 BOOL GUIAPI RegisterWindowClass (PWNDCLASS pWndClass);
898 BOOL GUIAPI UnregisterWindowClass (const char* szClassName);
899 char* GUIAPI GetClassName (HWND hWnd);
900 BOOL GUIAPI GetWindowClassInfo (PWNDCLASS pWndClass);
901 BOOL GUIAPI SetWindowClassInfo (const WNDCLASS* pWndClass);

    RegisterWindowClass ͨ¹ý pWndClass ½á¹¹×¢²áÒ»¸ö¿Ø¼þÀࣻUnregisterWindowClass º¯ÊýÔò×¢ÏúÖ¸¶¨µÄ¿Ø¼þÀࣻGetClassName »îµÃ´°¿ÚµÄ¶ÔÓ¦´°¿ÚÀàÃû³Æ£¬¶ÔÖ÷´°¿Ú¶øÑÔ£¬´°¿ÚÀàÃû³ÆΪ"MAINWINDOW"£»GetWindowClassInfo ·Ö±ðÓÃÀ´»ñÈ¡ºÍÖ¸¶¨Ìض¨´°¿ÚÀàµÄÊôÐÔ¡£

    Çåµ¥ 2 ÖеijÌÐò£¬¶¨Òå²¢×¢²áÁËÒ»¸ö×Ô¼ºµÄ¿Ø¼þÀà¡£¸Ã¿Ø¼þÓÃÀ´ÏÔʾ°²×°³ÌÐòµÄ²½ÖèÐÅÏ¢£¬MSG_SET_STEP_INFO ÏûÏ¢ÓÃÀ´¶¨Òå¸Ã¿Ø¼þÖÐÏÔʾµÄËùÓв½ÖèÐÅÏ¢£¬°üÀ¨ËùÓв½ÖèÃû³Æ¼°Æä¼òµ¥ÃèÊö¡£MSG_SET_CURR_STEP ÏûÏ¢ÓÃÀ´Ö¸¶¨µ±Ç°²½Ö裬¿Ø¼þ½«¸ßÁÁÏÔʾµ±Ç°²½Öè¡£

Çåµ¥2 ¶¨Òå²¢×¢²á×Ô¶¨Òå¿Ø¼þÀà

#define STEP_CTRL_NAME "mystep"
#define MSG_SET_STEP_INFO   (MSG_USER + 1)
#define MSG_SET_CURR_STEP   (MSG_USER + 2)
static int StepControlProc (HWND hwnd,
                int message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    HELPWININFO* info;

    switch (message) {
    case MSG_PAINT:
        hdc = BeginPaint (hwnd);
        /* »ñÈ¡²½Öè¿Ø¼þÐÅÏ¢ */
        info = (HELPWININFO*)GetWindowAdditionalData (hwnd);
        /* »æÖƲ½ÖèÄÚÈÝ */
        ......
        EndPaint (hwnd, hdc);
        break;
    /* ¿Ø¼þ×Ô¶¨ÒåµÄÏûÏ¢£ºÓÃÀ´ÉèÖò½ÖèÐÅÏ¢ */
    case MSG_SET_STEP_INFO:
        SetWindowAdditionalData (hwnd, (DWORD)lParam);
        InvalidateRect (hwnd, NULL, TRUE);
        break;
    /* ¿Ø¼þ×Ô¶¨ÒåµÄÏûÏ¢£ºÓÃÀ´ÉèÖõ±Ç°²½ÖèÐÅÏ¢ */
    case MSG_SET_CURR_STEP:
        InvalidateRect (hwnd, NULL, FALSE);
        break;
    case MSG_DESTROY:
        break;
    }
    return DefaultControlProc (hwnd, message, wParam, lParam);
}
static BOOL RegisterStepControl ()
{
    int result;
    WNDCLASS StepClass;
    StepClass.spClassName = STEP_CTRL_NAME;
    StepClass.dwStyle     = 0;
    StepClass.hCursor     = GetSystemCursor (IDC_ARROW);
    StepClass.iBkColor    = COLOR_lightwhite;
    StepClass.WinProc     = StepControlProc;
    return RegisterWindowClass (&StepClass);
}
static void UnregisterStepControl ()
{
    UnregisterWindowClass (STEP_CTRL_NAME);
}

3 ¿Ø¼þ×ÓÀ໯
    ²ÉÓÿؼþÀàºÍ¿Ø¼þʵÀýµÄ½á¹¹£¬²»½ö¿ÉÒÔÌá¸ß´úÂëµÄ¿ÉÖØÓÃÐÔ£¬¶øÇÒ»¹¿ÉÒÔ·½±ãµØ¶ÔÒÑÓпؼþÀà½øÐÐÀ©Õ¹¡£±ÈÈ磬ÔÚÐèÒª½¨Á¢Ò»¸öÖ»ÔÊÐíÊäÈëÊý×ֵı༭¿òʱ£¬¾Í¿ÉÒÔͨ¹ýÖØÔØÒÑÓб༭¿ò¿Ø¼þÀà¶øʵÏÖ£¬¶ø²»ÐèÒªÖØбàдһ¸öеĿؼþÀà¡£ÔÚ MiniGUI ÖУ¬ÕâÖÖ¼¼Êõ³ÆΪ×ÓÀ໯»òÕß´°¿ÚÅÉÉú¡£×ÓÀ໯µÄ·½·¨ÓÐÈýÖÖ£º

    ·Ò»ÖÖÊǶÔÒѾ­½¨Á¢µÄ¿Ø¼þʵÀý½øÐÐ×ÓÀ໯£¬×ÓÀ໯µÄ½á¹ûÊÇÖ»Ó°ÏìÕâÒ»¸ö¿Ø¼þʵÀý£»
    ·Ò»ÖÖÊǶÔij¸ö¿Ø¼þÀà½øÐÐ×ÓÀ໯£¬½«Ó°ÏìÆäºó´´½¨µÄËùÓиÿؼþÀàµÄ¿Ø¼þʵÀý£»
    ·×îºóÒ»ÖÖÊÇÔÚij¸ö¿Ø¼þÀàµÄ»ù´¡ÉÏÐÂ×¢²áÒ»¸ö×ÓÀ໯µÄ¿Ø¼þÀ࣬²»»áÓ°ÏìÔ­ÓпؼþÀà¡£ÔÚ Windows ÖУ¬ÕâÖÖ¼¼ÊõÓÖ³ÆΪ³¬À໯¡£

    ÔÚ MiniGUI ÖУ¬¿Ø¼þµÄ×ÓÀ໯ʵ¼ÊÊÇͨ¹ýÌæ»»ÒÑÓеĴ°¿Ú¹ý³ÌʵÏֵġ£Çåµ¥ 3 ÖеĴúÂë¾Íͨ¹ý¿Ø¼þÀà´´½¨ÁËÁ½¸ö×ÓÀ໯µÄ±à¼­¿ò£¬Ò»¸öÖ»ÄÜÊäÈëÊý×Ö£¬¶øÁíÒ»¸öÖ»ÄÜÊäÈë×Öĸ£º

Çåµ¥ 3 ¿Ø¼þµÄ×ÓÀ໯

#define IDC_CTRL1     100
#define IDC_CTRL2     110
#define IDC_CTRL3     120
#define IDC_CTRL4     130
#define MY_ES_DIGIT_ONLY    0x0001
#define MY_ES_ALPHA_ONLY    0x0002
static WNDPROC old_edit_proc;
static int RestrictedEditBox (HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
    if (message == MSG_CHAR) {
        DWORD my_style = GetWindowAdditionalData (hwnd);
        /* È·¶¨±»ÆÁ±ÎµÄ°´¼üÀàÐÍ */
        if ((my_style & MY_ES_DIGIT_ONLY) && (wParam < '0' || wParam > '9'))
            return 0;
        else if (my_style & MY_ES_ALPHA_ONLY)
            if (!((wParam >= 'A' && wParam <= 'Z') || (wParam >= 'a' && wParam <= 'z')))
                /* ÊÕµ½±»ÆÁ±ÎµÄ°´¼üÏûÏ¢£¬Ö±½Ó·µ»Ø */
                return 0;
    }
    /* ÓÉÀϵĴ°¿Ú¹ý³Ì´¦ÀíÆäÓàÏûÏ¢ */
    return (*old_edit_proc) (hwnd, message, wParam, lParam);
}
static int ControlTestWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
    case MSG_CREATE:
    {
        HWND hWnd1, hWnd2, hWnd3;
        CreateWindow (CTRL_STATIC, "Digit-only box:", WS_CHILD | WS_VISIBLE | SS_RIGHT, 0,
                    10, 10, 180, 24, hWnd, 0);
        hWnd1 = CreateWindow (CTRL_EDIT, "", WS_CHILD | WS_VISIBLE | WS_BORDER, IDC_CTRL1,
                    200, 10, 180, 24, hWnd, MY_ES_DIGIT_ONLY);
        CreateWindow (CTRL_STATIC, "Alpha-only box:", WS_CHILD | WS_VISIBLE | SS_RIGHT, 0,
                    10, 40, 180, 24, hWnd, 0);
        hWnd2 = CreateWindow (CTRL_EDIT, "", WS_CHILD | WS_BORDER | WS_VISIBLE, IDC_CTRL2,
                    200, 40, 180, 24, hWnd, MY_ES_ALPHA_ONLY);
        CreateWindow (CTRL_STATIC, "Normal edit box:", WS_CHILD | WS_VISIBLE | SS_RIGHT, 0,
                    10, 70, 180, 24, hWnd, 0);
        hWnd3 = CreateWindow (CTRL_EDIT, "", WS_CHILD | WS_BORDER | WS_VISIBLE, IDC_CTRL2,
                    200, 70, 180, 24, hWnd, MY_ES_ALPHA_ONLY);
        CreateWindow ("button", "Close", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, IDC_CTRL4,
                    100, 100, 60, 24, hWnd, 0);
        /* ÓÃ×Ô¶¨ÒåµÄ´°¿Ú¹ý³ÌÌæ»»±à¼­¿òµÄ´°¿Ú¹ý³Ì£¬²¢±£´æÀϵĴ°¿Ú¹ý³Ì¡£*/
        old_edit_proc = SetWindowCallbackProc (hWnd1, RestrictedEditBox);
        SetWindowCallbackProc (hWnd2, RestrictedEditBox);
        break;
    }
    ......
    }
    return DefaultMainWinProc (hWnd, message, wParam, lParam);
}

4 ¶Ô»°¿òºÍ¶Ô»°¿òÄ£°å
    ÔÚ MiniGUI ÖУ¬¶Ô»°¿òÊÇÒ»ÀàÌØÊâµÄÖ÷´°¿Ú£¬ÕâÖÖÖ÷´°¿ÚÖ»¹Ø×¢ÓëÓû§µÄ½»»¥¨D¨DÏòÓû§ÌṩÊä³öÐÅÏ¢£¬µ«¸ü¶àµÄÊÇÓÃÓÚÓû§ÊäÈë¡£¶Ô»°¿ò¿ÉÒÔÀí½âΪ×ÓÀ໯֮ºóµÄÖ÷´°¿ÚÀà¡£ËüÕë¶Ô¶Ô»°¿òµÄÌØÊâÐÔ£¨¼´Óû§½»»¥£©½øÐÐÁËÌØÊâÉè¼Æ¡£±ÈÈçÓû§¿ÉÒÔʹÓà TAB ¼ü±éÀú¿Ø¼þ¡¢¿ÉÒÔÀûÓà ENTER ¼ü±íʾĬÈÏÊäÈëµÈµÈ¡£ÔÚ MiniGUI µ±ÖУ¬ÔÚ½¨Á¢¶Ô»°¿ò֮ǰ£¬Ê×ÏÈÐèÒª¶¨ÒåÒ»¸ö¶Ô»°¿òÄ£°å£¬¸ÃÄ£°åÖж¨ÒåÁ˶Ի°¿ò±¾ÉíµÄһЩÊôÐÔ£¬±ÈÈçλÖúʹóСµÈµÈ£¬Í¬Ê±¶¨ÒåÁ˶Ի°¿òÖÐËùÓпؼþµÄ³õʼÐÅÏ¢£¬°üÀ¨Î»ÖᢴóС¡¢·ç¸ñµÈµÈ¡£ÔÚ MiniGUI ÖУ¬ÓÃÁ½¸ö½á¹¹À´±íʾ¶Ô»°¿òÄ£°å£¨src/window.h£©£º

1172 typedef struct
1173 {
1174     char*       class_name;             // control class
1175     DWORD       dwStyle;                // control style
1176     int         x, y, w, h;             // control position in dialog
1177     int         id;                     // control identifier
1178     const char* caption;                // control caption
1179     DWORD       dwAddData;              // additional data
1180
1181     DWORD       dwExStyle;              // control extended style
1182 } CTRLDATA;
1183 typedef CTRLDATA* PCTRLDATA;
1184
1185 typedef struct
1186 {
1187     DWORD       dwStyle;                // dialog box style
1188     DWORD       dwExStyle;              // dialog box extended style
1189     int         x, y, w, h;             // dialog box position
1190     const char* caption;                // dialog box caption
1191     HICON       hIcon;                  // dialog box icon
1192     HMENU       hMenu;                  // dialog box menu
1193     int         controlnr;              // number of controls
1194     PCTRLDATA   controls;               // poiter to control array
1195     DWORD       dwAddData;              // addtional data, must be zero
1196 } DLGTEMPLATE;
1197 typedef DLGTEMPLATE* PDLGTEMPLATE;
1198

    ½á¹¹ CTRLDATA ÓÃÀ´¶¨Òå¿Ø¼þ£¬DLGTEMPLATE ÓÃÀ´¶¨Òå¶Ô»°¿ò±¾Éí¡£ÔÚ³ÌÐòÖУ¬Ó¦¸ÃÊ×ÏÈÀûÓà CTRLDATA ¶¨Òå¶Ô»°¿òÖÐËùÓеĿؼþ£¬²¢ÓÃÊý×é±íʾ¡£¿Ø¼þÔÚ¸ÃÊý×éÖеÄ˳Ðò£¬Ò²¾ÍÊǶԻ°¿òÖÐÓû§°´ TAB ¼üʱµÄ¿Ø¼þÇл»Ë³Ðò¡£È»ºó¶¨Òå¶Ô»°¿ò£¬Ö¸¶¨¶Ô»°¿òÖеĿؼþÊýÄ¿£¬²¢Ö¸¶¨ DLGTEMPLATE ½á¹¹ÖÐµÄ controls Ö¸ÕëÖ¸Ïò¶¨Òå¿Ø¼þµÄÊý×é¡£ÈçÇåµ¥ 4 Ëùʾ¡£

Çåµ¥ 4 ¶Ô»°¿òÄ£°åµÄ¶¨Òå

DLGTEMPLATE DlgInitProgress =
{
    WS_BORDER | WS_CAPTION,
    WS_EX_NONE,
    120, 150, 400, 130,
    "VAM-CNC ÕýÔÚ½øÐгõʼ»¯,
    0, 0,
    3, NULL,
    0
};

CTRLDATA CtrlInitProgress [] =
{
    {
        "static",
        WS_VISIBLE | SS_SIMPLE,
        10, 10, 380, 16,
        IDC_PROMPTINFO,
        "ÕýÔÚ...",
        0
    },
    {
        "progressbar",
        WS_VISIBLE,
        10, 40, 380, 20,
        IDC_PROGRESS,
        NULL,
        0
    },
    {
        "button",
        WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON,
        170, 70, 60, 25,
        IDOK,
        "È·¶¨",
        0
    }
};

    ÔÚ¶¨ÒåÁ˶Ի°¿òÄ£°åÊý¾ÝÖ®ºó£¬ÐèÒª¶¨Òå¶Ô»°¿òµÄ»Øµ÷º¯Êý£¬²¢µ÷ÓÃDialogBoxIndirectParam º¯Êý½¨Á¢¶Ô»°¿ò£¬ÈçÇåµ¥ 5 Ëùʾ£¬Ëù½¨Á¢µÄ¶Ô»°¿òÈçͼ 1 Ëùʾ¡£

Çåµ¥ 5 ¶¨Òå¶Ô»°¿ò»Øµ÷º¯Êý£¬²¢½¨Á¢¶Ô»°¿ò

/* ¶¨Òå¶Ô»°¿ò»Øµ÷º¯Êý */
static int InitDialogBoxProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
    case MSG_INITDIALOG:
        return 1;

    case MSG_COMMAND:
        switch (wParam) {
        case IDOK:
        case IDCANCEL:
            EndDialog (hDlg, wParam);
            break;
        }
        break;

    }

    return DefaultDialogProc (hDlg, message, wParam, lParam);
}
static void InitDialogBox (HWND hWnd)
{
    /* ½«¶Ô»°¿òºÍ¿Ø¼þÊý×é¹ØÁªÆðÀ´ */
    DlgInitProgress.controls = CtrlInitProgress;

    DialogBoxIndirectParam (&DlgInitProgress, hWnd, InitDialogBoxProc, 0L);
}

ͼ 1 Çåµ¥ 5 ³ÌÐò½¨Á¢µÄ¶Ô»°¿ò

DialogBoxIndirectParam ÒÔ¼°Ïà¹Øº¯ÊýµÄÔ­ÐÍÈçÏ£º

1203 int  GUIAPI DialogBoxIndirectParam (PDLGTEMPLATE pDlgTemplate,
1204                     HWND hOwner, WNDPROC DlgProc, LPARAM lParam);
1205 BOOL GUIAPI EndDialog (HWND hDlg, int endCode);
1206 void GUIAPI DestroyAllControls (HWND hDlg);

    ÔÚ DialogBoxIndirectParam ÖУ¬ÐèÒªÖ¸¶¨¶Ô»°¿òÄ£°å£¨pDlgTemplate£©¡¢¶Ô»°¿òµÄÍйÜÖ÷´°¿Ú¾ä±ú(hOwner)¡¢¶Ô»°¿ò»Øµ÷º¯ÊýµØÖ·£¨DlgProc£©£¬ÒÔ¼° udãÞ?a]dd?dd /)¯Ôc dd dd? ÇïÿÿÚ¬·¢Ë͵½¶Ô»°¿ò»Øµ÷º¯ÊýµÄ¡£¸ÃÏûÏ¢µÄ lParam ²ÎÊý°üº¬ÁËÓÉ DialogBoxIndirectParam º¯ÊýµÄµÚËĸö²ÎÊý´«µÝµ½¶Ô»°¿ò»Øµ÷º¯ÊýµÄÖµ¡£Óû§¿ÉÒÔÀûÓøÃÖµ½øÐжԻ°¿òµÄ³õʼ»¯£¬»òÕß±£´æÆðÀ´ÒÔ±¸ºóÓá£ÀýÈ磬Çåµ¥ 7 ÖеijÌÐò½« MSG_INITDIALOG ÏûÏ¢µÄ lParam ²ÎÊý±£´æµ½Á˶Ի°¿ò´°¿Ú¾ä±úµÄ¸½¼ÓÊý¾ÝÖУ¬ÕâÑù¿ÉÒÔÈ·±£ÔÚÈκÎÐèÒªµÄʱºò£¬·½±ãµØ´Ó¶Ô»°¿ò´°¿ÚµÄ¸½¼ÓÊý¾ÝÖлñÈ¡ÕâÒ»Êý¾Ý¡£

static int DepInfoBoxProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
    struct _DepInfo *info;

    switch(message) {
    case MSG_INITDIALOG:
    {
        /* ½«¶Ô»°¿ò²ÎÊý lParam ±£´æΪ´°¿ÚµÄ¸½¼ÓÊý¾Ý£¬ÒÔ±¸ºóÓÃ*/
        info = (struct _DepInfo*)lParam;
        SetWindowAdditionalData2 (hDlg, (DWORD)lParam);
        break;
    }

    case MSG_COMMAND:
    {
        /*  ´Ó´°¿ÚµÄ¸½¼ÓÊý¾ÝÖÐÈ¡³ö±£´æµÄ¶Ô»°¿ò²ÎÊý */
        info = (struct _DepInfo*) GetWindowAdditionalData2 (hDlg);

        switch(wParam) {
        case IDOK:
            /* ʹÓà info ½á¹¹ÖеÄÊý¾Ý */
            ......

        case IDCANCEL:
            EndDialog(hDlg,wParam);
            break;
        }
    }
    }

    return DefaultDialogProc (hDlg, message, wParam, lParam);
}

    ͨ³£¶øÑÔ£¬´«µÝµ½¶Ô»°¿ò»Øµ÷º¯ÊýÖеIJÎÊýÊÇÒ»¸ö½á¹¹µÄÖ¸Õ룬¸Ã½á¹¹°üº¬Ò»Ð©³õʼ»¯¶Ô»°¿òµÄÊý¾Ý£¬Í¬Ê±Ò²¿ÉÒÔ½«¶Ô»°¿òµÄÊäÈëÊý¾Ý±£´æÏÂÀ´²¢´«µÝµ½¶Ô»°¿òÖ®ÍâʹÓá£

6 ģ̬ºÍ·Çģ̬¶Ô»°¿ò
    ¼òµ¥¶øÑÔ£¬Ä£Ì¬¶Ô»°¿ò¾ÍÊÇÏÔʾ֮ºó£¬Óû§²»ÄÜÔÙÇл»µ½ÆäËûÖ÷´°¿Ú½øÐй¤×÷µÄ¶Ô»°¿ò£¬¶øÖ»ÄÜÔڹرÕÖ®ºó£¬²ÅÄÜʹÓÃÆäËûµÄÖ÷´°¿Ú¡£MiniGUI ÖУ¬Ê¹Óà DialogBoxIndirectParam º¯Êý½¨Á¢µÄ¶Ô»°¿ò¾ÍÊÇģ̬¶Ô»°¿ò¡£Êµ¼ÊÉÏ£¬¸Ã¶Ô»°¿òÊ×Ïȸù¾ÝÄ£°å½¨Á¢¶Ô»°¿ò£¬È»ºó½ûÖ¹ÆäÍйÜÖ÷´°¿Ú£¬²¢ÔÚÖ÷´°¿ÚµÄ MSG_CREATE ÏûÏ¢Öд´½¨¿Ø¼þ£¬²¢·¢ËÍ MSG_INITDIALOG ÏûÏ¢¸ø»Øµ÷º¯Êý£¬×îÖÕ½¨Á¢Ò»¸öеÄÏûϢѭ»·£¬²¢½øÈë¸ÃÏûϢѭ»·£¬Ö±µ½³ÌÐòµ÷Óà EndDialog º¯ÊýΪֹ¡£

    ʵ¼ÊÉÏ£¬ÎÒÃÇÒ²¿ÉÒÔÔÚ MiniGUI ÖÐÀûÓöԻ°¿òÄ£°å½¨Á¢ÆÕͨµÄÖ÷´°¿Ú£¬¼´·Çģ̬¶Ô»°¿ò¡£Õâʱ£¬ÎÒÃÇʹÓà CreateMainWindowIndirect º¯Êý¡£¸Ãº¯ÊýÒÔ¼°Ïà¹Øº¯ÊýµÄÔ­ÐÍÈçÏ£¨src/window.h£©£º

1199 HWND GUIAPI CreateMainWindowIndirect (PDLGTEMPLATE pDlgTemplate,
1200                     HWND hOwner, WNDPROC WndProc);
1201 BOOL GUIAPI DestroyMainWindowIndirect (HWND hMainWin);

    ʹÓà CreateMainWindowIndirect ¸ù¾Ý¶Ô»°¿òÄ£°å½¨Á¢µÄÖ÷´°¿ÚºÍÆäËûÀàÐ͵ÄÆÕͨÖ÷´°¿ÚûÓÐÈκÎÇø±ð¡£

7 С½á
    ¶Ô»°¿ò±à³ÌÊÇ MiniGUI Ó¦Óÿª·¢ÖÐʹÓÃ×îΪ³£¼ûµÄÒ»ÖÖ¼¼Êõ¡£Í¨¹ý¶¨ÒåÒ»¸ö¶Ô»°¿òÄ£°å£¬¾Í¿ÉÒÔ×Ô¶¯´´½¨Ò»¸ö¾ßÓи´ÔÓÊäÈëÊä³ö½çÃæµÄ¶Ô»°¿ò¡£±¾ÎĽ²ÊöÁË MiniGUI ÖеĿؼþÀàºÍ¿Ø¼þʵÀýµÄ¹Øϵ£¬²¢¾ÙÀý˵Ã÷¿Ø¼þ×ÓÀ໯µÄ¸ÅÄî¼°Ó¦Óã»È»ºó½²½âÁË MiniGUI ¶Ô»°¿òµÄ±à³Ì¼¼Êõ£¬°üÀ¨¶Ô»°¿òÄ£°åµÄ¶¨ÒåºÍ¶Ô»°¿ò»Øµ÷º¯ÊýµÄ±à³Ì£»×îºó˵Ã÷ÁËģ̬¶Ô»°¿òºÍ·Çģ̬¶Ô»°¿òÖ®¼äµÄÇø±ð¡£

[Ŀ¼]


ʹÓÃGDIº¯Êý

1 ÒýÑÔ
    GUI ϵͳµÄÒ»¸öÖØÒª×é³É²¿·Ö¾ÍÊÇ GDI£¬¼´Í¼ÐÎÉ豸½Ó¿Ú£¨Graphics Device Interface£©¡£Í¨¹ý GDI£¬GUI ³ÌÐò¾Í¿ÉÒÔÔÚ¼ÆËã»úÆÁÄ»ÉÏ£¬»òÕßÆäËûµÄÏÔʾÉ豸ÉϽøÐÐͼÐÎÊä³ö£¬°üÀ¨»ù±¾»æͼºÍÎı¾Êä³ö¡£±¾ÎĽ«ÏêϸÃèÊö MiniGUI ÖÐµÄ GDI º¯Êý£¬²¢¾ÙÀý˵Ã÷ÖØÒªº¯ÊýµÄÓ÷¨¡£ÆäÖаüÀ¨£ºDC µÄ¸ÅÄî¡¢»ñÈ¡ºÍÊÍ·Å£»¾ØÐβÙ×÷ºÍ¼ôÇÐÓò²Ù×÷£»»ù±¾»æͼº¯Êý£»Î»Í¼²Ù×÷º¯Êý£»Âß¼­×ÖÌå²Ù×÷º¯ÊýµÈ¡£

2 ͼÐÎÉ豸ÉÏÏÂÎÄ
    ÔÚ MiniGUI ÖУ¬²ÉÓÃÁËÔÚ Windows ºÍ X Window ÖÐÆÕ±é²ÉÓõÄͼÐÎÉ豸¸ÅÄÿ¸öͼÐÎÉ豸¶¨ÒåÁ˼ÆËã»úÏÔʾÆÁÄ»ÉϵÄÒ»¸ö¾ØÐÎÊä³öÇøÓò¡£ÔÚµ÷ÓÃͼÐÎÊä³öº¯Êýʱ£¬¾ùÒªÇóÖ¸¶¨¾­³õʼ»¯µÄͼÐÎÉ豸ÉÏÏÂÎÄ£¨Device Context£¬DC£©£¬Ò²³Æ×÷"É豸»·¾³"¡£´Ó³ÌÐòÔ±µÄ½Ç¶È¿´£¬Ò»¸ö¾­¹ý³õʼ»¯µÄͼÐÎÉ豸ÉÏÏÂÎÄÈ·¶¨ÁËÆäºó½øÐÐͼÐÎÊä³öµÄһЩ»ù±¾ÊôÐÔ£¬²¢Ò»Ö±±£³ÖÕâЩÊôÐÔ£¬Ö±µ½±»¸Ä±äΪֹ¡£ÕâЩÊôÐÔ°üÀ¨£ºÊä³öµÄÏßÌõÑÕÉ«¡¢Ìî³äÑÕÉ«¡¢×ÖÌåÑÕÉ«¡¢×ÖÌåÐÎ×´µÈµÈ¡£¶ø´Ó GUI ϵͳ½Ç¶ÈÀ´½²£¬Ò»¸öͼÐÎÉ豸ÉÏÏÂÎÄËù´ú±íµÄº¬Òå¾ÍÒª¸´Ôӵö࣬ËüÆðÂëÓ¦¸Ã°üº¬ÈçÏÂÄÚÈÝ£º

    ·¸ÃÉ豸ÉÏÏÂÎı¾ËùÔÚÉ豸ÐÅÏ¢£¨ÏÔʾģʽ¡¢É«²ÊÉî¶È¡¢ÏÔ´æ²¼¾ÖµÈµÈ£©£»
    ·¸ÃÉ豸ÉÏÏÂÎÄËù´ú±íµÄ´°¿ÚÒÔ¼°¸Ã´°¿Ú±»ÆäËû´°¿Ú¼ôÇеÄÐÅÏ¢£¨ÔÚ MiniGUI ÖУ¬³Æ×÷"È«¾Ö¼ôÇÐÓò"£©£»
    ·¸ÃÉ豸ÉÏÏÂÎĵĻù±¾²Ù×÷º¯Êý£¨µã¡¢Ö±Ïß¡¢¶à±ßÐΡ¢Ìî³ä¡¢¿é²Ù×÷µÈ£©£¬¼°ÆäÉÏÏÂÎÄÐÅÏ¢£»
    ·ÓɳÌÐòÉ趨µÄ¾Ö²¿ÐÅÏ¢£¨»æͼÊôÐÔ¡¢Ó³Éä¹ØϵºÍ¾Ö²¿¼ôÇÐÓòµÈ£©¡£

ËùÒÔ£¬´Ó³ÌÐòÔ±µÄ½Ç¶È¿´À´£¬ËûËù¹ØÐĵĽö½öÊÇÉ豸ÉÏÏÂÎı¾ÉíµÄһС²¿·Ö¶«Î÷¡£

2.1 É豸ÉÏÏÂÎĵĻñÈ¡ºÍÊÍ·Å
    ÔÚ MiniGUI ÖУ¬ËùÓлæͼÏà¹ØµÄº¯Êý¾ùÐèÒªÓÐÒ»¸öÉ豸ÉÏÏÂÎÄ¡£É豸ÉÏÏÂÎÄ¿Éͨ¹ý GetClientDC ºÍ ReleaseDC »ñÈ¡ºÍÊÍ·Å¡£ÓÉ GetDC Ëù»ñÈ¡µÄÉ豸ÉÏÏÂÎÄÊÇÕë¶ÔÕû¸ö´°¿ÚµÄ£¬¶ø GetClientDC Ëù»ñÈ¡µÄÉ豸ÉÏÏÂÎÄÊÇÕë¶Ô´°¿Ú¿Í»§Çø£¬Ò²¾ÍÊÇ˵£¬Ç°Ò»¸öº¯Êý»ñµÃµÄÉ豸ÉÏÏÂÎÄ£¬Æä×ø±êÔ­µãλÓÚ´°¿Ú×óÉϽǣ¬Êä³ö±»ÏÞ¶¨ÔÚ´°¿Ú·¶Î§Ö®ÄÚ£»ºóÒ»¸öº¯Êý»ñµÃµÄÉ豸ÉÏÏÂÎÄ£¬Æä×ø±êÔ­µãλÓÚ´°¿Ú¿Í»§Çø×óÉϽǣ¬Êä³ö±»ÏÞ¶¨ÔÚ´°¿Ú¿Í»§Çø·¶Î§Ö®ÄÚ¡£ÏÂÃæÊÇÕâÈý¸öº¯ÊýµÄÔ­ÐÍ˵Ã÷£¨include/gdi.h£©£º

398 HDC GUIAPI GetDC (HWND hwnd);
399 HDC GUIAPI GetClientDC (HWND hwnd);
400 void GUIAPI ReleaseDC (HDC hdc);

    GetDC ºÍ GetClientDC ÊÇ´ÓϵͳԤÁôµÄÈô¸É¸ö DC µ±ÖлñµÃÒ»¸öÄ¿Ç°ÉÐδʹÓõÄÉ豸ÉÏÏÂÎÄ¡£ËùÒÔ£¬Ó¦¸Ã×¢ÒâÈçÏÂÁ½µã£º

    ÔÚʹÓÃÍê³ÉÒ»¸öÓÉ GetDC ·µ»ØµÄÉ豸ÉÏÏÂÎÄÖ®ºó£¬Ó¦¸Ã¾¡¿ìµ÷Óà ReleaseDC ÊÍ·Å¡£
±ÜÃâͬʱʹÓöà¸öÉ豸ÉÏÏÂÎÄ£¬²¢±ÜÃâÔڵݹ麯ÊýÖе÷Óà GetDC ºÍ GetClientDC¡£

    ΪÁË·½±ã³ÌÐò±àд£¬Ìá¸ß»æͼЧÂÊ£¬MiniGUI »¹ÌṩÁ˽¨Á¢Ë½ÓÐÉ豸ÉÏÏÂÎĵĺ¯Êý£¬Ëù½¨Á¢µÄÉ豸ÉÏÏÂÎÄÔÚÕû¸ö´°¿ÚÉú´æÆÚÄÚÓÐЧ£¬´Ó¶øÃâ³ýÁË»ñÈ¡ºÍÊͷŵĹý³Ì¡£ÕâЩº¯ÊýµÄÔ­ÐÍÈçÏ£º

403 HDC GUIAPI CreatePrivateDC (HWND hwnd);
404 HDC GUIAPI CreatePrivateClientDC (HWND hwnd);
405 HDC GUIAPI GetPrivateClientDC (HWND hwnd);
406 void GUIAPI DeletePrivateDC (HDC hdc);

    ÔÚ½¨Á¢Ö÷´°¿Úʱ£¬Èç¹ûÖ÷´°¿ÚµÄÀ©Õ¹·ç¸ñÖÐÖ¸¶¨ÁË WS_EX_USEPRIVATEDC ·ç¸ñ£¬Ôò CreateMainWindow º¯Êý»á×Ô¶¯Îª¸Ã´°¿ÚµÄ¿Í»§Çø½¨Á¢Ë½ÓÐÉ豸ÉÏÏÂÎÄ¡£Í¨¹ý GetPrivateClientDC º¯Êý£¬¿ÉÒÔ»ñµÃ¸ÃÉ豸ÉÏÏÂÎÄ¡£¶Ô¿Ø¼þ¶øÑÔ£¬Èç¹û¿Ø¼þÀà¾ßÓÐ CS_OWNDC ÊôÐÔ£¬ÔòËùÓÐÊôÓڸÿؼþÀàµÄ¿Ø¼þ½«×Ô¶¯½¨Á¢Ë½ÓÐÉ豸ÉÏÏÂÎÄ¡£DeletePrivateDC º¯ÊýÓÃÀ´É¾³ý˽ÓÐÉ豸ÉÏÏÂÎÄ¡£¶ÔÉÏÊöÁ½ÖÖÇé¿ö£¬ÏµÍ³½«ÔÚÏú»Ù´°¿Úʱ×Ô¶¯µ÷Óà DeletePrivateDC º¯Êý¡£

    ÁíÍâÒ»¸ö»ñÈ¡ºÍÊÍ·ÅÉ豸ÉÏÏÂÎĵķ½·¨ÊÇͨ¹ý BeginPaint ºÍ EndPaint º¯Êý¡£ÕâÁ½¸öº¯ÊýÖ»ÄÜÔÚ´¦Àí MSG_PAINT µÄÏûÏ¢Öе÷Óá£MiniGUI ÔÚ BeginPaint º¯ÊýÖÐͨ¹ý GetClientDC »ñÈ¡¿Í»§ÇøÉ豸ÉÏÏÂÎÄ£¬È»ºó½«´°¿Úµ±Ç°µÄÎÞЧÇøÓòÑ¡Ôñµ½´°¿ÚµÄ¼ôÇÐÇøÓòÖУ»¶ø EndPaint º¯ÊýÔòÇå¿Õ´°¿ÚµÄÎÞЧÇøÓò£¬²¢ÊÍ·ÅÉ豸ÉÏÏÂÎÄ¡£ÕâÁ½¸öº¯ÊýµÄÔ­ÐÍÈçÏ£¨include/window.h£©£º

623 HDC GUIAPI BeginPaint(HWND hWnd);
624 void GUIAPI EndPaint(HWND hWnd, HDC hdc);

    ÒòΪ BeginPaint º¯Êý½«´°¿ÚµÄÎÞЧÇøÓòÑ¡Ôñµ½ÁËÉ豸ÉÏÏÂÎÄÖУ¬ËùÒÔ£¬¿ÉÒÔͨ¹ýһЩ±ØÒªµÄÓÅ»¯À´Ìá¸ß MSG_PAINT ÏûÏ¢µÄ´¦ÀíЧÂÊ¡£±ÈÈ磬ij¸ö³ÌÐòÒªÔÚ´°¿Ú¿Í»§ÇøÖÐÌî³äÈô¸É¾ØÐΣ¬¾Í¿ÉÒÔÔÚ MSG_PAINT º¯ÊýÖÐÈçÏ´¦Àí£º

MSG_PAINT:
{
    HDC hdc = BeginPaint (hWnd);

    for (j = 0; j < 10; j ++) {
        if (RectVisible  (hdc, rcs + j)) {
            FillBox (hdc, rcs[j].left, rcs[j].top, rcs [j].right, rcs [j].bottom);
        }
    }

    EndPaint (hWnd, hdc);
    return 0;
}

    ÕâÑù¿ÉÒÔ±ÜÃâ²»±ØÒªµÄÖØ»æ²Ù×÷£¬´Ó¶øÌá¸ß»æͼЧÂÊ¡£


2.2 ϵͳÄÚ´æÖеÄÉ豸ÉÏÏÂÎÄ
    MiniGUI Ò²ÌṩÁËÄÚ´æÉ豸ÉÏÏÂÎĵĴ´½¨ºÍÏú»Ùº¯Êý¡£ÀûÓÃÄÚ´æÉ豸ÉÏÏÂÎÄ£¬¿ÉÒÔÔÚϵͳÄÚ´æÖн¨Á¢Ò»¸öÀàËÆÏÔʾÄÚ´æµÄÇøÓò£¬È»ºóÔÚ¸ÃÇøÓòÖнøÐлæͼ²Ù×÷£¬½áÊøºóÔÙ¸´ÖƵ½ÏÔʾÄÚ´æÖС£ÕâÖÖ»æͼ·½·¨ÓÐÐí¶àºÃ´¦£¬±ÈÈçËٶȺܿ죬¼õÉÙÖ±½Ó²Ù×÷ÏÔ´æÔì³ÉµÄÉÁ˸ÏÖÏóµÈµÈ¡£²»¹ý£¬Ä¿Ç° MiniGUI ÖÐÖ»Äܽ¨Á¢ºÍÏÔʾÄڴ棬Ҳ¾ÍÊÇÎïÀíÉ豸ÉÏÏÂÎÄÒ»ÑùµÄÄÚ´æÉ豸ÉÏÏÂÎÄ¡£ÓÃÀ´½¨Á¢ºÍÏú»ÙÄÚ´æÉ豸ÉÏÏÂÎĵĺ¯ÊýÔ­ÐÍÈçÏÂ(include/gdi.h)£º

401 HDC GUIAPI CreateCompatibleDC (HDC hdc);
402 void GUIAPI DeleteCompatibleDC (HDC hdc);

2.3 ÆÁÄ»É豸ÉÏÏÂÎÄ
    MiniGUI ÔÚÆô¶¯Ö®ºó£¬¾Í½¨Á¢ÁËÒ»¸öÈ«¾ÖµÄÆÁÄ»É豸ÉÏÏÂÎÄ¡£¸Ã DC ÊÇÕë¶ÔÕû¸öÆÁÄ»µÄ£¬²¢ÇÒûÓÐÈκÎÔ¤Ïȶ¨ÒåµÄ¼ôÇÐÓò¡£ÔÚijЩӦÓóÌÐòÖУ¬¿ÉÒÔÖ±½ÓʹÓøÃÉ豸ÉÏÏÂÎĽøÐлæͼ£¬½«´ó´óÌá¸ß»æͼЧÂÊ¡£ÔÚ MiniGUI ÖУ¬ÆÁÄ»É豸ÉÏÏÂÎÄÓà HDC_SCREEN ±êʶ£¬²»ÐèÒª½øÐÐÈκλñÈ¡ºÍÊͷŲÙ×÷¡£

2.4 Ó³Éäģʽ
    Ò»¸öÉ豸ÉÏÏÂÎı»³õʼ»¯Ö®ºó£¬Æä×ø±êϵԭµãͨ³£ÊÇÊä³ö¾ØÐεÄ×óÉϽǣ¬¶ø x ÖáˮƽÏò×ó£¬y Öá´¹Ö±ÏòÏ£¬²¢ÒÔÏóËØΪµ¥Î»¡£ÕâÖÖ×ø±êµÄÓ³Éäģʽ±êʶΪ MM_TEXT¡£MiniGUI ÌṩÁËÒ»Ì׺¯Êý£¬¿ÉÒԸıäÕâÖÖÓ³É䷽ʽ£¬°üÀ¨¶ÔĬÈÏ×ø±êϵ½øÐÐÆ«ÒÆ¡¢Ëõ·ÅµÈ²Ù×÷¡£ÕâЩº¯ÊýµÄÔ­ÐÍÈçÏ£¨include/gdi.h£©£º

453 int GUIAPI GetMapMode (HDC hdc);
454 void GUIAPI GetViewportExt (HDC hdc, POINT* pPt);
455 void GUIAPI GetViewportOrg (HDC hdc, POINT* pPt);
456 void GUIAPI GetWindowExt (HDC hdc, POINT* pPt);
457 void GUIAPI GetWindowOrg (HDC hdc, POINT* pPt);
458 void GUIAPI SetMapMode (HDC hdc, int mapmode);
459 void GUIAPI SetViewportExt (HDC hdc, POINT* pPt);
460 void GUIAPI SetViewportOrg (HDC hdc, POINT* pPt);
461 void GUIAPI SetWindowExt (HDC hdc, POINT* pPt);
462 void GUIAPI SetWindowOrg (HDC hdc, POINT* pPt);

    GetMapMode º¯Êý·µ»Øµ±Ç°µÄÓ³Éäģʽ£¬Èô²»ÊÇ MM_TEXT ģʽ£¬Ôò·µ»ØMM_ANISOTROPIC¡£SetMapMode º¯ÊýÉèÖÃÓ³Éäģʽ£¬MiniGUI Ä¿Ç°Ö»Ö§³ÖÁ½ÖÖÓ³Éäģʽ£¬¼´MM_ANISOTROPIC ºÍ MM_TEXT¡£Get º¯Êý×éÓÃÀ´·µ»ØÓ³ÉäģʽÐÅÏ¢£¬°üÀ¨Æ«ÒÆÁ¿¡¢Ëõ·Å±ÈÀýµÈµÈ£¬¶ø Set º¯Êý×éÓÃÀ´ÉèÖÃÏàÓ¦µÄÓ³ÉäÐÅÏ¢¡£

    ͨ³£Çé¿öÏ£¬MiniGUI µÄ GDI º¯ÊýËùÖ¸¶¨µÄ×ø±ê²ÎÊý³ÆΪ"Âß¼­×ø±ê"£¬ÔÚ»æÖÆ֮ǰ£¬Ê×ÏÈҪת»¯³É"É豸×ø±ê"¡£µ±Ê¹Óà MM_TEXT Ó³Éäģʽʱ£¬Âß¼­×ø±êºÍÉ豸×ø±êÊǵȼ۵ġ£LPtoDP º¯ÊýÓÃÀ´Íê³ÉÂß¼­×ø±êµ½É豸×ø±êµÄת»»£¬DPtoLP º¯ÊýÓÃÀ´Íê³É´ÓÉ豸×ø±êµ½Âß¼­×ø±êµÄת»»¡£Âß¼­×ø±êºÍÉ豸×ø±êµÄ¹Øϵ¿É´Ó LPtoDP º¯ÊýÖп´µ½£¨src/gdi/coor.c£©£º

  61 void GUIAPI LPtoDP(HDC hdc, POINT* pPt)
  62 {
  63     PDC pdc;
  64
  65     pdc = dc_HDC2PDC(hdc);
  66
  67     if (pdc->mapmode != MM_TEXT) {
  68         pPt->x = (pPt->x - pdc->WindowOrig.x)
  69              * pdc->ViewExtent.x / pdc->WindowExtent.x
  70              + pdc->ViewOrig.x;
  71
  72         pPt->y = (pPt->y - pdc->WindowOrig.y)
  73              * pdc->ViewExtent.y / pdc->WindowExtent.y
  74              + pdc->ViewOrig.y;
  75     }
  76 }
  77

ÁíÍ⣬LPtoSP º¯ÊýºÍ SPtoLP º¯ÊýÍê³ÉÂß¼­×ø±êºÍÆÁÄ»×ø±êÖ®¼äµÄת»»¡£

3 ¾ØÐβÙ×÷ºÍÇøÓò²Ù×÷

3.1 ¾ØÐβÙ×÷

    ÔÚ MiniGUI ÖУ¬¾ØÐÎÊÇÈç϶¨ÒåµÄ£¨include/common.h£©£º

120 typedef struct tagRECT
121 {
122     int left;
123     int top;
124     int right;
125     int bottom;
126 } RECT;
127 typedef RECT* PRECT;
128 typedef RECT* LPRECT;

    ¼ò¶øÑÔÖ®£¬¾ØÐξÍÊÇÓÃÀ´±íʾÆÁÄ»ÉÏÒ»¸ö¾ØÐÎÇøÓòµÄÊý¾Ý½á¹¹£¬¶¨ÒåÁ˾ØÐÎ×óÉÏ½ÇµÄ x, y ×ø±ê£¨left ºÍ top£©ÒÔ¼°ÓÒÏÂ½ÇµÄ x, y ×ø±ê£¨right ºÍ bottom£©¡£ÐèҪעÒâµÄÊÇ£¬MiniGUI ÖеľØÐΣ¬ÆäÓÒ²àµÄ±ßºÍÏÂÃæµÄ±ßÊDz»ÊôÓڸþØÐεġ£ÀýÈ磬Ҫ±íʾÆÁÄ»ÉϵÄÒ»ÌõɨÃèÏߣ¬Ó¦¸ÃÓÃ
RECT rc = {x, y, x + w + 1, y + 1};
±íʾ¡£ÆäÖÐ x ÊÇɨÃèÏßµÄÆðµã£¬y ÊÇɨÃèÏߵĴ¹Ö±Î»Öã¬w ÊÇɨÃèÏß¿í¶È¡£

    MiniGUI ÌṩÁËÒ»×麯Êý£¬¿É¶Ô RECT ¶ÔÏó½øÐвÙ×÷£º

SetRect ¶Ô RECT ¶ÔÏóµÄ¸÷¸ö·ÖÁ¿½øÐи³Öµ£»
SetRectEmpty ½« RECT ¶ÔÏóÉèÖÃΪ¿Õ¡£MiniGUI ÖеĿվØÐζ¨ÒåΪ¸ß¶È»ò¿í¶ÈΪÁãµÄ¾ØÐΣ»
IsRectEmpty Åжϸø¶¨ RECT ¶ÔÏóÊÇ·ñΪ¿Õ¡£
NormalizeRect ¶Ô¸ø¶¨¾ØÐνøÐÐÕý¹æ»¯´¦Àí¡£MiniGUI ÖеľØÐΣ¬Ó¦¸ÃÂú×㣨right > left ²¢ÇÒ bottom > top£©µÄÌõ¼þ¡£Âú×ãÕâÒ»Ìõ¼þµÄ¾ØÐÎÓÖ³Æ"Õý¹æ»¯¾ØÐÎ"£¬¸Ãº¯Êý¿ÉÒÔ¶ÔÈÎÒâ¾ØÐνøÐÐÕý¹æ»¯´¦Àí¡£
CopyRect ¸´ÖƾØÐΣ»
EqualRect ÅжÏÁ½¸ö RECT ¶ÔÏóÊÇ·ñÏàµÈ£¬¼´Á½¸ö RECT ¶ÔÏóµÄ¸÷¸ö·ÖÁ¿ÏàµÈ£»
IntersectRect ¸Ãº¯ÊýÇóÁ½¸ö RECT ¶ÔÏóÖ®½»¼¯¡£ÈôÁ½¸ö¾ØÐθù±¾²»Ïཻ£¬Ôòº¯Êý·µ»Ø FALSE£¬ÇÒ½á¹û¾ØÐÎ䶨Ò壻·ñÔò·µ»Ø½»¾ØÐΡ£
DoesIntersec ¸Ãº¯Êý½ö½öÅжÏÁ½¸ö¾ØÐÎÊÇ·ñÏཻ¡£
IsCovered ¸Ãº¯ÊýÅÐ¶Ï RECT ¶ÔÏó A ÊÇ·ñÈ«²¿¸²¸Ç RECT ¶ÔÏó B£¬¼´ RECT B ÊÇ RECT A µÄÕæ×Ó¼¯¡£
UnionRect ¸Ãº¯ÊýÇóÁ½¸ö¾ØÐÎÖ®²¢¡£Èç¹ûÁ½¸ö¾ØÐθù±¾ÎÞ·¨Ïಢ£¬Ôò·µ»Ø FALSE¡£Á½¸öÏಢ֮ºóµÄ¾ØÐΣ¬ÆäÖÐËù°üº¬µÄÈÎÒâµã£¬Ó¦¸ÃÊôÓÚÁ½¸öÏಢ¾ØÐÎÖ®Ò»¡£
GetBoundRect ¸Ãº¯ÊýÇóÁ½¸ö¾ØÐεÄÍâ°ü×îС¾ØÐΡ£
SubstractRect ¸Ãº¯Êý´ÓÒ»¸ö¾ØÐÎÖмõÈ¥ÁíÍâÒ»¸ö¾ØÐΡ£×¢Ò⣬Á½¸ö¾ØÐÎÏà¼õµÄ½á¹û¿ÉÄÜÉú³É 4 ¸ö²»ÏཻµÄ¾ØÐΡ£¸Ãº¯Êý½«·µ»Ø½á¹û¾ØÐεĸöÊýÒÔ¼°²î¾ØÐΡ£ÏêϸÐÅÏ¢¿É²Î¼û"MiniGUI Ìåϵ½á¹¹Ö®¶þ¨D¨D¶à´°¿Ú¹ÜÀíºÍ¿Ø¼þ¼°¿Ø¼þÀà"Ò»ÎÄ¡£
OffsetRect ¸Ãº¯Êý¶Ô¸ø¶¨µÄ RECT ¶ÔÏó½øÐÐƽÒÆ´¦Àí¡£
InflateRect ¸Ãº¯Êý¶Ô¸ø¶¨µÄ RECT ¶ÔÏó½øÐÐÅòÕÍ´¦Àí¡£×¢ÒâÅòÕÍÖ®ºóµÄ¾ØÐοí¶ÈºÍ¸ß¶ÈÊǸø¶¨ÅòÕÍÖµµÄÁ½±¶¡£
InflateRectToPt ¸Ãº¯Êý½«¸ø¶¨µÄ RECT ¶ÔÏóÅòÕ͵½Ö¸¶¨µÄµã¡£
PtInRect ¸Ãº¯ÊýÅжϸø¶¨µÄµãÊÇ·ñλÓÚÖ¸¶¨µÄ RECT ¶ÔÏóÖС£

3.2 ÇøÓò²Ù×÷
    ÔÚ MiniGUI ÖУ¬ÇøÓò¶¨ÒåΪ»¥²»Ïཻ¾ØÐεļ¯ºÏ£¬ÔÚÄÚ²¿ÓÃÁ´±íÐÎʽ±íʾ¡£MiniGUI µÄÇøÓò¿ÉÒÔÓÃÀ´±íʾ´°¿ÚµÄ¼ôÇÐÓò¡¢ÎÞЧÇøÓò¡¢¿É¼ûÇøÓòµÈµÈ¡£ÔÚ MiniGUI ÖУ¬ÇøÓòºÍ¼ôÇÐÓòµÄ¶¨ÒåÊÇÒ»ÑùµÄ£¬¼ôÇÐÓò¶¨ÒåÈçÏ£¨include/gdi.h£©£º

  76 // Clip Rect
  77 typedef struct tagCLIPRECT
  78 {
  79     RECT rc;
  80     struct tagCLIPRECT* next;
  81 }CLIPRECT;
  82 typedef CLIPRECT* PCLIPRECT;
  83
  84 // Clip Region
  85 typedef struct tagCLIPRGN
  86 {
  87    RECT            rcBound;     // bound rect of clip region
  88    PCLIPRECT       head;        // clip rect list head
  89    PCLIPRECT       tail;        // clip rect list tail
  90    PBLOCKHEAP      heap;        // heap of clip rect
  91 } CLIPRGN;
  92 typedef CLIPRGN* PCLIPRGN;

    ÿ¸ö¼ôÇÐÓò¶ÔÏóÓÐÒ»¸ö BLOCKHEAP ³ÉÔ±¡£¸Ã³ÉÔ±ÊǼôÇÐÓò·ÖÅä RECT ¶ÔÏóµÄ˽Óжѡ£ÔÚʹÓÃÒ»¸ö¼ôÇÐÓò¶ÔÏó֮ǰ£¬Ê×ÏÈÓ¦¸Ã½¨Á¢Ò»¸ö BLOCKHEAP ¶ÔÏ󣬲¢¶Ô¼ôÇÐÓò¶ÔÏó½øÐгõʼ»¯¡£ÈçÏÂËùʾ£º

static BLOCKHEAP sg_MyFreeClipRectList;

...

    CLIPRGN my_region

    InitFreeClipRectList (&sg_MyFreeClipRectList, 20);
    InitClipRgn (&my_regioni, &sg_MyFreeClipRectList);

    ÔÚʵ¼ÊʹÓõ±ÖУ¬¶à¸ö¼ôÇÐÓò¿ÉÒÔ¹²Ïíͬһ¸ö BLOCKHEAP ¶ÔÏó¡£

    ÔÚ³õʼ»¯¼ôÇÐÓò¶ÔÏóÖ®ºó£¬¿ÉÒÔ¶Ô¼ôÇÐÓò½øÐÐÈçϲÙ×÷£º

SetClipRgn ¸Ãº¯Êý½«¼ôÇÐÓòÉèÖÃΪ½ö°üº¬Ò»¸ö¾ØÐεļôÇÐÓò£»
ClipRgnCopy ¸Ãº¯Êý¸´ÖƼôÇÐÓò£»
ClipRgnIntersect ¸Ãº¯ÊýÇóÁ½¸ö¼ôÇÐÓòµÄ½»¼¯£»
GetClipRgnBoundRect ¸Ãº¯ÊýÇó¼ôÇÐÓòµÄÍâ°ü×îС¾ØÐΣ»
IsEmptyClipRgn ¸Ãº¯ÊýÅжϼôÇÐÓòÊÇ·ñΪ¿Õ£¬¼´ÊÇ·ñ°üº¬¼ôÇоØÐΣ»
EmptyClipRgn ¸Ãº¯ÊýÊͷżôÇÐÓòÖеļôÇоØÐΣ¬²¢Çå¿Õ¼ôÇÐÓò£»
AddClipRect ¸Ãº¯Êý½«Ò»¸ö¼ôÇоØÐÎ×·¼Óµ½¼ôÇÐÓòÖС£×¢Òâ¸Ã²Ù×÷²¢²»ÅжϸüôÇÐÓòÊÇ·ñºÍ¼ôÇоØÐÎÏཻ¡£
IntersectClipRect ¸Ãº¯ÊýÇó¼ôÇÐÇøÓòºÍ¸ø¶¨¾ØÐÎÏཻµÄ¼ôÇÐÇøÓò¡£
SubtractClipRect ¸Ãº¯Êý´Ó¼ôÇÐÇøÓòÖмõÈ¥Ö¸¶¨µÄ¾ØÐΡ£
¾ØÐκÍÇøÓòµÄÔËËã¹¹³ÉÁË´°¿Ú¹ÜÀíµÄÖ÷ÒªËã·¨£¬Ò²ÊǸ߼¶ GDI º¯ÊýµÄ»ù±¾Ëã·¨Ö®Ò»£¬ÔÚ GUI ±à³ÌÖÐÕ¼Óзdz£ÖØÒªµÄµØλ¡£

4 »ù±¾Í¼ÐβÙ×÷
4.1 »ù±¾»æͼÊôÐÔ
    ÔÚÁ˽â»ù±¾»æͼº¯Êý֮ǰ£¬ÎÒÃÇÊ×ÏÈÁ˽âһϻù±¾»æͼÊôÐÔ¡£ÔÚ MiniGUI µÄÄ¿Ç°°æ±¾ÖУ¬»æͼÊôÐԱȽÏÉÙ£¬´óÌå°üÀ¨ÏßÌõÑÕÉ«¡¢Ìî³äÑÕÉ«¡¢Îı¾±³¾°Ä£Ê½¡¢Îı¾ÑÕÉ«¡¢TAB ¼ü¿í¶ÈµÈµÈ¡£±í 1 ¸ø³öÁËÕâЩÊôÐԵIJÙ×÷º¯Êý¡£

±í 1 »ù±¾»æͼÊôÐÔ¼°Æä²Ù×÷º¯Êý

»æͼÊôÐÔ ²Ù×÷º¯Êý ÊÜÓ°ÏìµÄ GDI º¯Êý
ÏßÌõÑÕÉ« GetPenColor/SetPenColor LineTo¡¢Circle¡¢Rectangle
Ìî³äÑÕÉ« GetBrushColor/SetBrushColor FillBox
Îı¾±³¾°Ä£Ê½ GetBkMode/SetBkMode TextOut¡¢DrawText
Îı¾ÑÕÉ« GetTextColor/SetTextColor ͬÉÏ
TAB ¼ü¿í¶È GetTabStop/SetTabStop ͬÉÏ

    MiniGUI Ä¿Ç°°æ±¾Öл¹¶¨ÒåÁËË¢×ӺͱʵÄÈô¸Éº¯Êý£¬ÕâЩº¯ÊýÊÇΪ½«À´¼æÈÝÐÔ¶ø¶¨ÒåµÄ£¬Ä¿Ç°ÎÞÓá£

4.2 »ù±¾»æͼº¯Êý
    MiniGUI ÖеĻù±¾»æͼº¯ÊýΪµã¡¢Ïß¡¢Ô²¡¢¾ØÐΡ¢µ÷É«°å²Ù×÷µÈ»ù±¾º¯Êý£¬Ô­ÐͶ¨ÒåÈçÏ£¨include/gdi.h£¬°æ±¾ 1.0.06£©£º

433 // Palette support
434 int GUIAPI GetPalette (HDC hdc, int start, int len, gal_color* cmap);
435 int GUIAPI SetPalette (HDC hdc, int start, int len, gal_color* cmap);
436 int GUIAPI SetColorfulPalette (HDC hdc);
437
438 // General drawing support
439 void GUIAPI SetPixel (HDC hdc, int x, int y, gal_pixel c);
440 void GUIAPI SetPixelRGB (HDC hdc, int x, int y, int r, int g, int b);
441 gal_pixel GUIAPI GetPixel (HDC hdc, int x, int y);
442 void GUIAPI GetPixelRGB (HDC hdc, int x, int y, int* r, int* g, int* b);
443 gal_pixel GUIAPI RGB2Pixel (HDC hdc, int r, int g, int b);
444
445 void GUIAPI LineTo (HDC hdc, int x, int y);
446 void GUIAPI MoveTo (HDC hdc, int x, int y);
447
448 void GUIAPI Circle (HDC hdc, int x, int y, int r);
449 void GUIAPI Rectangle (HDC hdc, int x0, int y0, int x1, int y1);

    ÕâÀïÓÐÁ½¸ö»ù±¾µÄ¸ÅÄîÐèÒªÃ÷È·Çø·Ö£¬¼´ÏóËØÖµºÍ RGB Öµ¡£RGB ÊǼÆËã»úÖÐͨ¹ýÈýÔ­É«µÄ²»Í¬±ÈÀý±íʾijÖÖÑÕÉ«µÄ·½·¨¡£Í¨³££¬RGB Öеĺ졢ÂÌ¡¢À¶¿ÉÈ¡ 0 ~ 255 µ±ÖеÄÈÎÒâÖµ£¬´Ó¶ø¿ÉÒÔ±íʾ 255x255x255 ÖÖ²»Í¬µÄÑÕÉ«¡£¶øÔÚÏÔʾÄÚ´æµ±ÖУ¬ÒªÏÔʾÔÚÆÁÄ»ÉϵÄÑÕÉ«²¢²»ÊÇÓà RGB ÕâÖÖ·½Ê½±íʾµÄ£¬ÏÔ´æµ±Öб£´æµÄÆäʵÊÇËùÓÐÏóËصÄÏóËØÖµ¡£ÏóËØÖµµÄ·¶Î§¸ù¾ÝÏÔʾģʽµÄ²»Í¬¶ø±ä»¯¡£ÔÚ 16 É«ÏÔʾģʽÏ£¬ÏóËØÖµ·¶Î§Îª [0, 15]£»¶øÔÚ 256 ɫģʽÏ£¬ÏóËØÖµ·¶Î§Îª [0, 255]£»ÔÚ 16 λɫģʽÏ£¬ÏóËØÖµ·¶Î§Îª [0, 2^16 - 1]¡£Í¨³£ÎÒÃÇËù˵ÏÔʾģʽÊǶàÉÙλɫ£¬¾ÍÊÇÖ¸ÏóËصÄλÊý¡£

    ÔÚ MiniGUI ÖУ¬ÉèÖÃij¸öÏóËصãµÄÑÕÉ«£¬¼È¿ÉÒÔÖ±½ÓʹÓÃÏóËØÖµ£¨SetPixel£©£¬Ò²¿ÉÒÔ¼ä½Óͨ¹ý RGB ÖµÀ´ÉèÖã¨SetPixelRGB£©£¬²¢ÇÒͨ¹ý RGB2Pixel º¯Êý£¬¿ÉÒÔ½« RGB ֵת»»ÎªÏóËØÖµ¡£

    µ÷É«°åÊǵÍÑÕɫλÊýµÄģʽÏ£¨±ÈÈç 256 É«»òÕ߸üÉÙµÄÑÕɫģʽ£©£¬ÓÃÀ´½¨Á¢ÓÐÏÞµÄÏóËØÖµºÍ RGB ¶ÔÓ¦¹ØϵµÄÒ»¸öÏßÐÔ±í¡£ÔÚ MiniGUI µ±ÖУ¬¿ÉÒÔͨ¹ý SetPaletteºÍ GetPalette ½øÐе÷É«°åµÄ²Ù×÷£¬¶øSetColorfulePalette ½«µ÷É«°åÉèÖÃΪĬÈϵĵ÷É«°å¡£Ò»°ã¶øÑÔ£¬ÔÚ¸ü¸ßµÄÑÕɫλÊý£¬±ÈÈç 15 λɫÒÔÉÏ£¬ÒòΪÏóËØÖµ·¶Î§Äܹ»±í´ïµÄÑÕÉ«ÒѾ­·Ç³£·á¸»ÁË£¬¼ÓÉÏ´æ´¢µÄ¹Øϵ£¬¾Í²»ÔÙʹÓõ÷É«°å½¨Á¢ÏóËØÖµºÍ RGB µÄ¶ÔÓ¦¹Øϵ£¬¶øʹÓøü¼òµ¥µÄ·½·¨½¨Á¢ RGB ºÍʵ¼ÊÏóËØÖ®¼äµÄ¹Øϵ£¬ÈçÏÂËùʾ£¨src/gal/native/native.h£©£º

174 /* Truecolor color conversion and extraction macros */
175 /*
176  * Conversion from RGB to gal_pixel
177  */
178 /* create 24 bit 8/8/8 format pixel (0x00RRGGBB) from RGB triplet*/
179 #define RGB2PIXEL888(r,g,b)     \
180         (((r) << 16) | ((g) << 8) | (b))
181
182 /* create 16 bit 5/6/5 format pixel from RGB triplet */
183 #define RGB2PIXEL565(r,g,b)     \
184         ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
185
186 /* create 15 bit 5/5/5 format pixel from RGB triplet */
187 #define RGB2PIXEL555(r,g,b)     \
188         ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3))
189
190 /* create 8 bit 3/3/2 format pixel from RGB triplet*/
191 #define RGB2PIXEL332(r,g,b)     \
192         (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))

    RGB2PIXEL888 ½« [0, 255] µÄ RGB ֵת»»Îª 24 λɫµÄÏóËØÖµ£»¶ø RGB2PIXEL565 ת»»Îª 16 λɫµÄÏóËØÖµ£»RGB2PIXEL555 ºÍRGB2PIXEL332 ·Ö±ðת»»Îª 15 λɫºÍ 8 λɫ¡£


4.3 ¼ôÇÐÓò²Ù×÷º¯Êý
    ÔÚÀûÓÃÉ豸ÉÏÏÂÎĽøÐлæͼʱ£¬»¹¿ÉÒÔ½øÐмôÇд¦Àí¡£MiniGUI ÌṩÁËÈçϺ¯ÊýÍê³É¶ÔÖ¸¶¨É豸ÉÏÏÂÎĵļôÇд¦Àí£¨include/gdi.h£©£º

468 // Clipping support
469 void GUIAPI ExcludeClipRect (HDC hdc, int left, int top,
470                             int right, int bottom);
471 void GUIAPI IncludeClipRect (HDC hdc, int left, int top,
472                               int right, int bottom);
473 void GUIAPI ClipRectIntersect (HDC hdc, const RECT* prc);
474 void GUIAPI SelectClipRect (HDC hdc, const RECT* prc);
475 void GUIAPI SelectClipRegion (HDC hdc, const CLIPRGN* pRgn);
476 void GUIAPI GetBoundsRect (HDC hdc, RECT* pRect);
477 BOOL GUIAPI PtVisible (HDC hdc, const POINT* pPt);
478 BOOL GUIAPI RectVisible (HDC hdc, const RECT* pRect);

    ExcludeClipRect ´ÓÉ豸ÉÏÏÂÎĵĵ±Ç°¿É¼ûÇøÓòÖÐÅųý¸ø¶¨µÄ¾ØÐÎÇøÓò,É豸ÉÏÏÂÎĵĿɼûÇøÓò½«ËõС£»IncludeClipRect Ïòµ±Ç°É豸ÉÏÏÂÎĵĿɼûÇøÓòÖÐÌí¼ÓÒ»¸ö¾ØÐÎÇøÓò£¬É豸ÉÏÏÂÎĵĿɼûÇøÓò½«À©´ó£»ClipRectIntersect ½«É豸ÉÏÏÂÎĵĿɼûÇøÓòÉèÖÃΪÒÑÓÐÇøÓòºÍ¸ø¶¨¾ØÐÎÇøÓòµÄ½»¼¯£»SelectClipRect ½«É豸ÉÏÏÂÎĵĿɼûÇøÓòÖØÖÃΪһ¸ö¾ØÐÎÇøÓò£»SelectClipRegion ½«É豸ÉÏÏÂÎĵĿɼûÇøÓòÉèÖÃΪһ¸öÖ¸¶¨µÄÇøÓò£»GetBoundsRect »ñÈ¡µ±Ç°¿É¼ûÇøÓòµÄÍâ°ü×îС¾ØÐΣ»PtVisible ºÍ RectVisible ÓÃÀ´Åжϸø¶¨µÄµã»òÕß¾ØÐÎÊÇ·ñ¿É¼û£¬¼´ÊÇ·ñÈ«²¿»ò²¿·ÖÂäÔڿɼûÇøÓòµ±ÖС£


5 λͼ²Ù×÷º¯Êý
    ÔÚ MiniGUI µÄ GDI º¯ÊýÖУ¬Î»Í¼²Ù×÷º¯ÊýÕ¼Óзdz£ÖØÒªµÄµØλ¡£Êµ¼ÊÉÏ£¬Ðí¶à¸ß¼¶»æͼ²Ù×÷º¯Êý¾ù½¨Á¢ÔÚλͼ²Ù×÷º¯ÊýÖ®ÉÏ£¬±ÈÈçÎı¾Êä³öº¯Êý¡£MiniGUI µÄÖ÷Ҫλͼ²Ù×÷º¯ÊýÈçÏÂËùʾ£¨include/gdi.h£©£º

495 void GUIAPI FillBox (HDC hdc, int x, int y, int w, int h);
496 void GUIAPI FillBoxWithBitmap (HDC hdc, int x, int y, int w, int h,
497                               PBITMAP pBitmap);
498 void GUIAPI FillBoxWithBitmapPart (HDC hdc, int x, int y, int w, int h,
499                               int bw, int bh, PBITMAP pBitmap, int xo, int yo);
500
501 void GUIAPI BitBlt (HDC hsdc, int sx, int sy, int sw, int sh,
502                    HDC hddc, int dx, int dy, DWORD dwRop);
503 void GUIAPI StretchBlt (HDC hsdc, int sx, int sy, int sw, int sh,
504                        HDC hddc, int dx, int dy, int dw, int dh, DWORD dwRop);

    FillBox Óõ±Ç°Ìî³äÉ«Ìî³ä¾ØÐοò£»FillBoxWithBitmap ÓÃÉ豸Ïà¹Øλͼ¶ÔÏóÌî³ä¾ØÐοò£¬¿ÉÒÔÓÃÀ´À©´ó»òÕßËõСλͼ£»FillBoxWithBitmapPart ÓÃÉ豸Ïà¹Øλͼ¶ÔÏóµÄ²¿·ÖÌî³ä¾ØÐοò£¬Ò²¿ÉÒÔÀ©´ó»òËõСλͼ¡£BitBlt º¯ÊýÓÃÀ´ÊµÏÖÁ½¸ö²»Í¬É豸ÉÏÏÂÎÄÖ®¼äµÄÏÔʾÄڴ渴ÖÆ¡£StretchBlt ÔòÔÚ BitBlt µÄ»ù´¡ÉϽøÐÐËõ·Å²Ù×÷¡£

    ͨ¹ý MiniGUI µÄ LoadBitmap º¯Êý£¬¿ÉÒÔ½«Ä³ÖÖλͼÎļþ×°ÔØΪ MiniGUI É豸Ïà¹ØµÄλͼ¶ÔÏ󣬼´ BITMAP ¶ÔÏó¡£É豸Ïà¹ØµÄλͼָµÄÊÇ£¬Î»Í¼µ±Öаüº¬µÄÊÇÓëÖ¸¶¨É豸ÉÏÏÂÎĵÄÏÔʾģʽÏàÆ¥ÅäµÄÏóËØÖµ£¬¶ø²»ÊÇÉ豸Î޹صÄλͼÐÅÏ¢¡£MiniGUI Ä¿Ç°¿ÉÒÔÓÃÀ´×°ÔØBMP Îļþ¡¢JPG Îļþ¡¢GIF ÎļþÒÔ¼° PCX¡¢TGA µÈ¸ñʽµÄλͼÎļþ£¬¶ø LoadMyBitmap º¯ÊýÔòÓÃÀ´½«Î»Í¼Îļþ×°ÔسÉÉ豸Î޹صÄλͼ¶ÔÏó¡£ÔÚ MiniGUI ÖУ¬É豸Ïà¹ØµÄλͼ¶ÔÏóºÍÉ豸Î޹صÄλͼ¶ÔÏó·Ö±ðÓà BITMAP ºÍ MYBITMAP Á½ÖÖÊý¾Ý½á¹¹±íʾ¡£Ïà¹Øº¯ÊýµÄÔ­ÐÍÈçÏ£¨include/gdi.h£©£º

666 int GUIAPI LoadMyBitmap (HDC hdc, PMYBITMAP pMyBitmap, RGB* pal, const char* spFileName);
667 int GUIAPI LoadBitmap (HDC hdc, PBITMAP pBitmap, const char* spFileName);
668 #ifdef _SAVE_BITMAP
669 int GUIAPI SaveBitmap (HDC hdc, PBITMAP pBitmap, const char* spFileName);
670 #endif
671 void GUIAPI UnloadBitmap (PBITMAP pBitmap);
672
673 int GUIAPI ExpandMyBitmap (HDC hdc, const MYBITMAP* pMyBitmap, const RGB* pal, PBITMAP pBitmap);
674
675 void GUIAPI ExpandMonoBitmap (HDC hdc, int w, int h, const BYTE* bits, int bits_flow, int pitch,
676                              BYTE* bitmap, int bg, int fg);
677 void GUIAPI Expand16CBitmap (HDC hdc, int w, int h, const BYTE* bits, int bits_flow, int pitch,
678                             BYTE* bitmap, const RGB* pal);
679 void GUIAPI Expand256CBitmap (HDC hdc, int w, int h, const BYTE* bits, int bits_flow, int pitch,
680                              BYTE* bitmap, const RGB* pal);
681 void GUIAPI CompileRGBBitmap (HDC hdc, int w, int h, const BYTE* bits, int bits_flow, int pitch,
682                              BYTE* bitmap, int rgb_order);
683
684 void GUIAPI ReplaceBitmapColor (HDC hdc, PBITMAP pBitmap, int iOColor, int iNColor);

    ÉÏÃæµÄ Expand º¯Êý×飬ÓÃÀ´½«É豸Î޹صÄλͼת»¯ÎªÓëÖ¸¶¨É豸ÉÏÏÂÎÄÏà¹ØµÄλͼ¶ÔÏó¡£

    ÓйØλͼ²Ù×÷µÄÏêϸʹÓ÷½·¨£¬¿É¼û mglite-exec °üÖÐµÄ bitmaptest ʾÀý³ÌÐò¡£

6 Âß¼­×ÖÌåºÍÎı¾Êä³öº¯Êý
    MiniGUI µÄÂß¼­×ÖÌ幦ÄÜÇ¿´ó£¬Ëü°üÀ¨ÁË×Ö·û¼¯¡¢×ÖÌåÀàÐÍ¡¢·ç¸ñ¡¢ÑùʽµÈµÈ·á¸»µÄÐÅÏ¢£¬²»½ö½ö¿ÉÒÔÓÃÀ´Êä³öÎı¾£¬¶øÇÒ¿ÉÒÔÓÃÀ´·ÖÎö¶àÓïÖÖÎı¾µÄ½á¹¹¡£ÕâÔÚÐí¶àÎı¾ÅÅ°æÓ¦ÓÃÖзdz£ÓÐÓá£ÔÚʹÓà MiniGUI µÄÂß¼­×ÖÌå֮ǰ£¬Ê×ÏÈÒª´´½¨Âß¼­×ÖÌ壬²¢ÇÒ½«ÆäÑ¡Ôñµ½ÒªÊ¹ÓÃÕâÖÖÂß¼­×ÖÌå½øÐÐÎı¾Êä³öµÄÉ豸ÉÏÏÂÎĵ±ÖС£Ã¿¸öÉ豸ÉÏÏÂÎĵÄĬÈÏÂß¼­×ÖÌåÊÇϵͳ×ÖÌ壬¼´ÓÃÀ´ÏÔʾ²Ëµ¥¡¢±êÌâµÄÂß¼­×ÖÌå¡£Äã¿ÉÒÔµ÷Óà CreateLogFont ºÍ CreateLogFontIndirect Á½¸öº¯ÊýÀ´½¨Á¢Âß¼­×ÖÌ壬²¢ÀûÓà SelectFont º¯Êý½«Âß¼­×ÖÌåÑ¡Ôñµ½Ö¸¶¨µÄÉ豸ÉÏÏÂÎÄÖУ¬ÔÚʹÓýáÊøÖ®ºó£¬Óà DestroyLogFont º¯ÊýÏú»ÙÂß¼­×ÖÌå¡£×¢ÒâÄã²»ÄÜÏú»ÙÕý±»Ñ¡ÖеÄÂß¼­×ÖÌå¡£Õ⼸¸öº¯ÊýµÄÔ­ÐÍÈçÏ£¨include/gdi.h£©£º

555 PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family,
556         const char* charset, char weight, char slant, char set_width,
557         char spacing, char underline, char struckout,
558         int size, int rotation);
559 PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT* logfont);
560 void GUIAPI DestroyLogFont (PLOGFONT log_font);
561
562 void GUIAPI GetLogFontInfo (HDC hdc, LOGFONT* log_font);
563
564 #define SYSLOGFONT_DEFAULT          0
565 PLOGFONT GUIAPI GetSystemFont (int font_id);
566
567 PLOGFONT GUIAPI GetCurFont (HDC hdc);
568 PLOGFONT GUIAPI SelectFont (HDC hdc, PLOGFONT log_font);

    GetSystemFont º¯Êý·µ»ØĬÈϵÄϵͳÂß¼­×ÖÌ壬GetCurFont º¯Êý·µ»Øµ±Ç°Ñ¡ÖеÄÂß¼­×ÖÌå¡£×¢ÒⲻҪɾ³ýϵͳÂß¼­×ÖÌå¡£ÏÂÃæµÄ³ÌÐò¶Î½¨Á¢Á˶à¸öÂß¼­×ÖÌ壺

   static LOGFONT  *logfont, *logfontgb12, *logfontbig24;

            logfont = CreateLogFont (NULL, "SansSerif", "ISO8859-1",
                        FONT_WEIGHT_REGULAR, FONT_SLANT_ITALIC, FONT_SETWIDTH_NORMAL,
                        FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_LINE,
                        16, 0);
            logfontgb12 = CreateLogFont (NULL, "song", "GB2312",
                        FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL,
                        FONT_SPACING_CHARCELL, FONT_UNDERLINE_LINE, FONT_STRUCKOUT_LINE,
                        12, 0);
            logfontbig24 = CreateLogFont (NULL, "ming", "BIG5",
                        FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL,
                        FONT_SPACING_CHARCELL, FONT_UNDERLINE_LINE, FONT_STRUCKOUT_NONE,
                        24, 0);

    ÆäÖУ¬µÚÒ»¸ö×ÖÌ壬¼´ logfont ÊÇÊôÓÚ×Ö·û¼¯ ISO8859-1 µÄ×ÖÌ壬²¢ÇÒÑ¡Óà SansSerif Ì壬´óСΪ 16 ÏóËظߣ»logfontgb12 ÊÇÊôÓÚ×Ö·û¼¯ GB2312 µÄ×ÖÌ壬²¢Ñ¡Óà song Ì壨ËÎÌ壩£¬´óСΪ 12 ÏóËظߣ»logfontbig24 ÊÇÊôÓÚ×Ö·û¼¯ BIG5 µÄ×ÖÌ壬²¢Ñ¡Óà ming Ì壨¼´Ã÷Ì壩¡£

    ÔÚ½¨Á¢ÁËÂß¼­×ÖÌåÖ®ºó£¬Ó¦ÓóÌÐò¿ÉÒÔÀûÓÃÂß¼­×ÖÌå½øÐжàÓïÖÖ»ìºÍÎı¾µÄ·ÖÎö¡£ÕâÀïµÄ¶àÓïÖÖ»ìºÍÎı¾ÊÇÖ¸£¬Á½¸ö²»Ïཻ×Ö·û¼¯µÄÎı¾×é³ÉµÄ×Ö·û´®£¬±ÈÈç GB2312 ºÍ ISO8859-1£¬»òÕß BIG5 ºÍ ISO8859-2£¬Í¨³£ÊǶà×Ö·û¼¯ºÍµ¥×Ö·û¼¯Ö®¼äµÄ»ìºÍ¡£ÀûÓÃÏÂÃæµÄº¯Êý£¬¿ÉÒÔʵÏÖ¶àÓïÖÖ»ìºÍÎı¾µÄÎı¾×é³É·ÖÎö£¨include/gdi.h£©£º

570 // Text parse support
571 int GUIAPI GetTextMCharInfo (PLOGFONT log_font, const char* mstr, int len,
572                 int* pos_chars);
573 int GUIAPI GetTextWordInfo (PLOGFONT log_font, const char* mstr, int len,
574                 int* pos_words, WORDINFO* info_words);
575 int GUIAPI GetFirstMCharLen (PLOGFONT log_font, const char* mstr, int len);
576 int GUIAPI GetFirstWord (PLOGFONT log_font, const char* mstr, int len,
577                             WORDINFO* word_info);

    GetTextMCharInfo º¯Êý·µ»Ø¶àÓïÖÖ»ìºÍÎı¾ÖÐÿ¸ö×Ö·ûµÄ×Ö½ÚλÖᣱÈÈç¶Ô"ABCººÓï"×Ö·û´®£¬¸Ãº¯Êý½«ÔÚ pos_chars Öзµ»Ø{0, 1, 2, 3, 5} 5 ¸öÖµ¡£GetTextWordInfo º¯ÊýÔò½«·ÖÎö¶àÓïÖÖ»ìºÍÎı¾ÖÐÿ¸öµ¥´ÊµÄλÖ᣶Ե¥×Ö½Ú×Ö·û¼¯Îı¾£¬µ¥´ÊÒÔ¿Õ¸ñ¡¢TAB ¼üΪ·Ö½ç£¬¶Ô¶à×Ö½Ú×Ö·û¼¯Îı¾£¬µ¥´ÊÒÔµ¥¸ö×Ö·ûΪ½ç¡£GetFirstMCharLen º¯Êý·µ»ØµÚÒ»¸ö»ìºÍÎı¾×Ö·ûµÄ×Ö½Ú³¤¶È¡£GetFirstWord º¯Êý·µ»ØµÚÒ»¸ö»ìºÍÎı¾µ¥´ÊµÄµ¥´ÊÐÅÏ¢¡£

    ÒÔϺ¯Êý¿ÉÒÔÓÃÀ´¼ÆËãÂß¼­×ÖÌåµÄÊä³ö³¤¶ÈºÍ¸ß¶ÈÐÅÏ¢£¨include/gdi.h£©£º

580 int GUIAPI GetTextExtentPoint (HDC hdc, const char* text, int len, int max_extent,
581                 int* fit_chars, int* pos_chars, int* dx_chars, SIZE* size);
582
583 // Text output support
584 int GUIAPI GetFontHeight (HDC hdc);
585 int GUIAPI GetMaxFontWidth (HDC hdc);
586 void GUIAPI GetTextExtent (HDC hdc, const char* spText, int len, SIZE* pSize);
587 void GUIAPI GetTabbedTextExtent (HDC hdc, const char* spText, int len, SIZE* pSize);

    GetTextExtentPoint º¯Êý¼ÆËãÔÚ¸ø¶¨µÄÊä³ö¿í¶ÈÄÚÊä³ö¶à×Ö½ÚÎı¾Ê±£¨¼´Êä³öµÄ×Ö·ûÏÞÖÆÔÚÒ»¶¨µÄ¿í¶Èµ±ÖУ©£¬¿ÉÊä³öµÄ×î´ó×Ö·û¸öÊý¡¢Ã¿¸ö×Ö·ûËùÔÚµÄ×Ö½ÚλÖá¢Ã¿¸ö×Ö·ûµÄÊä³öλÖã¬ÒÔ¼°Êµ¼ÊµÄÊä³ö¸ß¶ÈºÍ¿í¶È¡£GetFontHeight ºÍ GetMaxFontWidth Ôò·µ»ØÂß¼­×ÖÌåµÄ¸ß¶ÈºÍ×î´ó×Ö·û¿í¶È¡£GetTextExtent ¼ÆËãÎı¾µÄÊä³ö¸ß¶ÈºÍ¿í¶È¡£GetTabbedTextExtent º¯Êý·µ»Ø¸ñʽ»¯×Ö·û´®µÄÊä³ö¸ß¶ÈºÍ¿í¶È¡£

    ÒÔϺ¯ÊýÓÃÀ´Êä³öÎı¾£¨include/gdi.h£©£º

596 int GUIAPI TextOutLen (HDC hdc, int x, int y, const char* spText, int len);
597 int GUIAPI TabbedTextOutLen (HDC hdc, int x, int y, const char* spText, int len);
598 int GUIAPI TabbedTextOutEx (HDC hdc, int x, int y, const char* spText, int nCount,
599             int nTabPositions, int *pTabPositions, int nTabOrigin);
600 void GUIAPI GetLastTextOutPos (HDC hdc, POINT* pt);
601
602 // Compatiblity definitions
603 #define TextOut(hdc, x, y, text)    TextOutLen (hdc, x, y, text, -1)
604 #define TabbedTextOut(hdc, x, y, text)  TabbedTextOutLen (hdc, x, y, text, -1)

...

621 int GUIAPI DrawTextEx (HDC hdc, const char* pText, int nCount,
622                 RECT* pRect, int nIndent, UINT nFormat);

    TextOutLen º¯ÊýÓÃÀ´ÔÚ¸ø¶¨Î»ÖÃÊä³öÖ¸¶¨³¤¶ÈµÄ×Ö·û´®£¬Èô³¤¶ÈΪ -1£¬Ôò×Ö·û´®±ØÐëÊÇÒÔ '\0' ½áβµÄ¡£TabbedTextOutLen º¯ÊýÓÃÀ´Êä³ö¸ñʽ»¯×Ö·û´®¡£TabbedTextOutEx º¯ÊýÓÃÀ´Êä³ö¸ñʽ»¯×Ö·û´®£¬µ«¿ÉÒÔÖ¸¶¨×Ö·û´®ÖÐÿ¸ö TAB ¼üµÄλÖá£DrawText Êǹ¦ÄÜ×ÔÓµÄÊä³öº¯Êý£¬¿ÉÒÔÒÔ²»Í¬µÄ¶ÔÆ뷽ʽÔÚÖ¸¶¨¾ØÐÎÄÚ²¿Êä³öÎı¾¡£ÏÂÃæµÄ³ÌÐò¶Î£¬¾Í¸ù¾Ý×Ö·û´®ËùÃèÊöµÄÄÇÑù£¬µ÷Óà DrawText º¯Êý½øÐжÔÆëÎı¾Êä³ö£º

void OnModeDrawText (HDC hdc)
{
    RECT rc1, rc2, rc3, rc4;
    const char* szBuff1 = "This is a good day. \n"
            "ÕâÊÇÀûÓà DrawText »æÖƵÄÎı¾, ʹÓÃ×ÖÌå GB2312 Song 12. "
            "Îı¾´¹Ö±¿¿ÉÏ, ˮƽ¾ÓÖÐ";
    const char* szBuff2 = "This is a good day. \n"
            "ÕâÊÇÀûÓà DrawText »æÖƵÄÎı¾, ʹÓÃ×ÖÌå GB2312 Song 16. "
            "Îı¾´¹Ö±¿¿ÉÏ, ˮƽ¿¿ÓÒ";
    const char* szBuff3 = "µ¥ÐÐÎı¾´¹Ö±¾ÓÖÐ, ˮƽ¾ÓÖÐ";
    const char* szBuff4 =
            "ÕâÊÇÀûÓà DrawTextEx »æÖƵÄÎı¾, ʹÓÃ×ÖÌå GB2312 Song 16. "
            "Ê×ÐÐËõ½øֵΪ 32. Îı¾´¹Ö±¿¿ÉÏ, ˮƽ¿¿×ó";

    rc1.left = 1; rc1.top  = 1; rc1.right = 401; rc1.bottom = 101;
    rc2.left = 0; rc2.top  = 110; rc2.right = 401; rc2.bottom = 351;
    rc3.left = 0; rc3.top  = 361; rc3.right = 401; rc3.bottom = 451;
    rc4.left = 0; rc4.top  = 461; rc4.right = 401; rc4.bottom = 551;

    SetBkColor (hdc, COLOR_lightwhite);

    Rectangle (hdc, rc1.left, rc1.top, rc1.right, rc1.bottom);
    Rectangle (hdc, rc2.left, rc2.top, rc2.right, rc2.bottom);
    Rectangle (hdc, rc3.left, rc3.top, rc3.right, rc3.bottom);
    Rectangle (hdc, rc4.left, rc4.top, rc4.right, rc4.bottom);

    InflateRect (&rc1, -1, -1);
    InflateRect (&rc2, -1, -1);
    InflateRect (&rc3, -1, -1);
    InflateRect (&rc4, -1, -1);

    SelectFont (hdc, logfontgb12);
    DrawText (hdc, szBuff1, -1, &rc1, DT_NOCLIP | DT_CENTER | DT_WORDBREAK);

    SelectFont (hdc, logfontgb16);
    DrawText (hdc, szBuff2, -1, &rc2, DT_NOCLIP | DT_RIGHT | DT_WORDBREAK);

    SelectFont (hdc, logfontgb24);
    DrawText (hdc, szBuff3, -1, &rc3, DT_NOCLIP | DT_SINGLELINE | DT_CENTER | DT_VCENTER);

    SelectFont (hdc, logfontgb16);
    DrawTextEx (hdc, szBuff4, -1, &rc4, 32, DT_NOCLIP | DT_LEFT | DT_WORDBREAK);
}

    ÓйØÂß¼­×ÖÌåºÍÎı¾Êä³öµÄº¯ÊýÏêϸʹÓ÷½·¨£¬¿É¼û mglite-exec °üÖÐµÄ fontest ʾÀý³ÌÐò¡£

7 С½á
    ±¾ÎĽ²ÊöÁË MiniGUI ÖнӿÚ×î¶àÒ²×Ô GDI º¯Êý¼°ÆäʹÓ÷½·¨¡£ÆäÖаüÀ¨£ºÉ豸ÉÏÏÂÎĵĸÅÄî¡¢»ñÈ¡ºÍÊÍ·Å£»¾ØÐβÙ×÷ºÍÇøÓò²Ù×÷£»»ù±¾»æͼº¯Êý£»Î»Í¼²Ù×÷º¯Êý£»Âß¼­×ÖÌå²Ù×÷º¯ÊýµÈµÈ¡£Ä¿Ç°°æ±¾µÄ GDI ½Ó¿Ú»¹ÓÐÐí¶à¹¦ÄÜÉϵÄȱÏÝ£¬ÎÒÃǽ«ÔÚÏÂÒ»¸ö°æ±¾¿ª·¢ÖÐ×ÅÖؽøÐиÄÉÆ¡£¹ØÓÚ MiniGUI ÏÂÒ»°æ±¾µÄ¿ª·¢¼Æ»®£¬Çë²Î¼û±¾Îĸ½Â¼¡£

¸½Â¼£ºMiniGUI µÄ×îпª·¢¼Æ»®
    MiniGUI ·¢Õ¹µ½½ñÌ죬µÃµ½ÁËÐí¶àÓû§µÄÈÏ¿É£¬Ê¹ÓÃËüµÄÈËÒ²Ô½À´Ô½¶àÁË¡£Ä¿Ç°£¬Óû§ÒѾ­´Ó¹úÄÚ·¢Õ¹µ½Á˹úÍâ¡£Õâ˵Ã÷ MiniGUI µ±ÖеÄÐí¶àÉè¼Æ˼ÏëµÃµ½ÁËÈÏ¿É£¬Ò²´ó´ó¼¤ÀøÁËÎÒÃǵĿª·¢ÈÈÇé¡£

    ×÷Ϊһ¸öÃæÏòʵʱǶÈëʽϵͳµÄ GUI£¬MiniGUI µÄ 1.0.xx °æ±¾»ù±¾Äܹ»Âú×ãÐí¶àǶÈëʽϵͳµÄÓ¦ÓÃÐèÇó¡£µ«Õ⻹ԶԶ²»¹»£¬ÎÒÃÇÈÔÈ»ÐèÒª½øÒ»²½µÄ¿ª·¢£¬ÒÔ±ãÈà MiniGUI ÔÚǶÈëʽ GUI ϵͳÖдﵽÁìÏȵØλ¡£

    MiniGUI ·¢Õ¹µ½½ñÌ죬µÃµ½ÁËÐí¶àÓû§µÄÈÏ¿É£¬Ê¹ÓÃËüµÄÈËÒ²Ô½À´Ô½¶àÁË¡£Ä¿Ç°£¬Óû§ÒѾ­´Ó¹úÄÚ·¢Õ¹µ½Á˹úÍâ¡£Õâ˵Ã÷ MiniGUI µ±ÖеÄÐí¶àÉè¼Æ˼ÏëµÃµ½ÁËÈÏ¿É£¬Ò²´ó´ó¼¤ÀøÁËÎÒÃǵĿª·¢ÈÈÇé¡£

    ×÷Ϊһ¸öÃæÏòʵʱǶÈëʽϵͳµÄ GUI£¬MiniGUI µÄ 1.0.xx °æ±¾»ù±¾Äܹ»Âú×ãÐí¶àǶÈëʽϵͳµÄÓ¦ÓÃÐèÇó¡£µ«Õ⻹ԶԶ²»¹»£¬ÎÒÃÇÈÔÈ»ÐèÒª½øÒ»²½µÄ¿ª·¢£¬ÒÔ±ãÈà MiniGUI ÔÚǶÈëʽ GUI ϵͳÖдﵽÁìÏȵØλ¡£

    ÎÒÃÇÒѾ­¿ªÊ¼ÁË MiniGUI а汾¿ª·¢£¨¼´ 1.1.xx£©£¬¶ÔÕâ¸ö°æ±¾£¬ÓÐÈçÏÂеÄÉèÏ룺

    MiniGUI-Lite µÄÈ«¾ÖÊó±êÖ§³Ö¡£Ä¿Ç°µÄ MiniGUI-Lite °æ±¾£¬Êó±êµÄλÖÃË¢ÐÂÊÇÓÉÊó±êËùÔÚ¿Í»§»òÕß·þÎñÆ÷¹ÜÀíµÄ¡£Ð°汾ÖУ¬½«¿¼ÂÇÓÉ·þÎñÆ÷ͳһ¹ÜÀí¡£Õâ¸ö¹¤×÷Ä¿Ç°ÒѾ­»ù±¾Íê³É¡£
    ÔÚ MiniGUI-Lite ÖÐÌí¼Ó²ã£¨Layer£©µÄ¸ÅÄîºÍ´¦Àí¡£ÔÚÒ»´Î MiniGUI-Lite »á»°ÖУ¬¿ÉÒÔ½¨Á¢¶à¸ö²ã¡£Ã¿¸ö²ãÖпÉÒÔ°üº¬Äܹ»Í¬Ê±ÏòÆÁÄ»Êä³öµÄ¶à¸ö¿Í»§£¬¶øÿһʱ¿Ì£¬Äܹ»ÔÚÆÁÄ»ÉÏÏÔʾµÄ²ãÖ»ÓÐÒ»¸ö¡£¶Ô²ã¶øÑÔ£¬ÎÒÃÇ¿ÉÒÔ½øÐвãµÄ¼¤»î´¦Àí¡£¼¤»îµÄ²ã£¬½«ÏÔʾÔÚÆÁÄ»ÉÏ£¬¶øÆäËû²ãµÄ»æͼ½«±»ÆÁ±Î¡£¶Ô²ãÖпͻ§µÄ»æͼÆÁ±ÎËã·¨£¬½«¿¼ÂÇʹÓò»Í¬ÓÚµ±Ç° MiniGUI-Lite ͨ¹ýÐźźÍÐźÅÁ¿½áºÏµÄ·½·¨£¬ÒòΪÕâÖÖ·½·¨ÔÚ¶àÏß³ÌÓ¦ÓÃÖУ¬¿ÉÄܳöÏÖÎÊÌâ¡£
    ²ãÖпͻ§¿ÉÒÔ»¥Ïà¼ôÇС£ºó½¨Á¢µÄ¿Í»§£¬½«¼ôÇÐÏȽ¨Á¢µÄ¿Í»§¾ØÐΡ£Îª´Ë£¬ÒªÎªÃ¿¸ö²ã½¨Á¢Ò»¸ö¹²ÏíÄÚ´æµÄ IPC ¶ÔÏ󣬿ͻ§Í¨¹ý¸Ã¶ÔÏó·ÃÎʵ±Ç°²ã¿Í»§Ö®¼äµÄÖصþºÍ¸²¸ÇÇé¿ö£¬¶øÇÒÒª½¨Á¢Ò»¸öÃæÏò²ãµÄÐźÅÁ¿ºÍ age Öµ£¬ÓÃÀ´Ð­µ÷¿Í»§¼ôÇоØÐεı仯¡£²ãµÄ¿Í»§¼ôÇоØÐεı仯£¬½«Ó°Ïì¸÷¸ö¿Í»§Ëù½¨Á¢´°¿ÚµÄÈ«¾Ö¼ôÇÐÇøÓò£¬´Ó¶øÓ°Ïì DC µÄ¿É¼ûÇøÓò¡£
    Ò»¸ö²ãÖпͻ§Ö®¼äÐÎ³ÉµÄ Z ÐòÊǹ̶¨µÄ¡£²»¹ý£¬Èç¹û°´ÕÕ 3 ËùÃèÊöµÄ·½·¨£¬Æäʵ Z ÐòÒ²ÊÇ¿ÉÒԱ仯µÄ¡£¿¼Âǵ½ÐÔÄÜÒòËØ£¬¿Í»§ÔÚ²ãÖÐËùÕ¼µÄÏÔʾ¾ØÐβ»Äܱ仯£¬Ò²¾ÍÊÇ˵£¬¼È²»Äܸıä´óС£¬Ò²²»ÄÜÒƶ¯¡£µ«Äܹ»¸Ä±ä Z Ðò£¬¼´¸Ä±ä¿Í»§Ö®¼äµÄ»¥Ïà²ãµþ¹Øϵ¡£
BTW£ºÎªÊ²Ã´ÒªÈç´Ë¿¼ÂÇ£¿
    ͨ¹ýÉÏÃæµÄ·½·¨£¬¿ÉÒÔ½«Ò»×é¾ßÓй²Í¬Ä¿±êµÄ¿Í»§·ÅÖÃÔÚͬһ¸ö²ãÉÏ¡£±ÈÈ磬²ãÖпÉÒÔÓÐÒ»¸ö vcongui ³ÌÐò£¬ÓÃËü¿ÉÒÔµ÷ÊÔÆäËûµÄ MiniGUI ³ÌÐò¡£ÔÙ±ÈÈ磬ÔÚ VOD µÈ³ÌÐòÖУ¬ÊµÊ±²¥·Å VCD µÄ¿Í»§¾Í¿ÉÒÔǶÈëµ½Ö÷¿Ø½çÃæµ±ÖС£¶ø·þÎñÆ÷½«¾ßÓнÏÉÙµÄ GUI ÄÜÁ¦£¬½ö½öÌṩһ¸öÈÎÎñÀ¸£¬ÓÃÀ´¼¤»îij¸ö²ã£¬»òÕ߸ıä¿Í»§ÔÚÒ»¸ö²ãÖÐµÄ Z Ðò¡£

    µ±È»£¬ÕâÑù°²ÅŶÔijЩСÆÁÄ»µÄǶÈëʽӦÓÃÀ´½²£¬±ÈÈç PDA£¬²¢²»ÊǷdz£Êʺϣ¬µ«¶Ô STB¡¢»òÕßÆäËû¾ßÓдóÆÁÄ»µÄʵʱǶÈëʽϵͳÀ´½²£¬½«¾ßÓзdz£¸ßµÄÓ¦ÓüÛÖµ¡£

    µ×²ãͼÐÎÒýÇ潫½øÐзdz£ÖØ´óµÄÐ޸ģ¬Õ⽫ӰÏìµ½ MiniGUI-Threads ºÍ MiniGUI-Lite Á½¸ö°æ±¾¡£Ä¿Ç°µÄ MiniGUI ͼÐÎÒýÇ棬ÒòΪÊܵ½ÀúÊ·Ô­ÒòµÄÓ°Ï죬ÓÐÐí¶à±×¶Ë¡£ÔÚеİ汾ÖУ¬ÎÒÃǽ«¿¼ÂÇÀàËÆ SDL ÄÇÑùµÄÉè¼Æ·½·¨£¬½«µ×²ãͼÐÎÉ豸³éÏóΪһ¸öÄÚ´æ¶ÔÏ󣬲¢¿¼ÂǼÓËÙ¹¦ÄܵÄʵÏÖ¡£Í¬Ê±£¬ÎÒÃÇ»¹ÒªÊµÏÖÐí¶àÉÐδʵÏÖµÄͼÐι¦ÄÜ£¬°üÀ¨¹âÕ¤²Ù×÷¡¢Alpha »ìºÍ¡¢¶à±ßÐÎÖ§³Ö¡¢ÍÖÔ²ºÍ»¡ÏßÖ§³ÖµÈµÈ¡£
BTW£ºµ±Ç° GAL µÄÉè¼Æ±×¶Ë
    µ±Ç° GAL µÄÉè¼Æ±×¶ËÖ÷ÒªÊdzéÏó²ã´ÎÌ«¸ß£¬¶øÇÒ²¢Ã»ÓÐÔڵײãʵÏÖ¼ôÇÐÓòµÄÖ±½ÓÖ§³Ö¡£ÕâÊÇÒªÔÚа汾ÖÐ×ÅÖØ¿¼ÂǸĽøµÄ¡£ÐµļôÇÐÓòËã·¨£¬½«¿¼ÂÇÉú³É x-y-banned µÄ¼ôÇÐÓò£¬ÒÔ±ãµ×²ã»æͼº¯ÊýÄܹ»Ö±½ÓÀûÓüôÇÐÓò½øÐÐÉè¼Æ»æͼËã·¨¡£

    ½«¿¼ÂÇÔÚ MiniGUI-Lite °æ±¾ÖÐʵÏÖ¶ÔʸÁ¿×ÖÌåµÄÖ§³Ö£¬Í¬Ê±Ôö¼Ó Cache ´¦ÀíÄÜÁ¦£¬ÒÔ±ãÌá¸ßʸÁ¿×ÖÌåµÄäÖȾЧÂÊ¡£
    ¶Ô´°¿Ú¹ÜÀí£¬ÔÚÕâ´Î¿ª·¢Öн«²»×÷´óµÄÐ޸ģ¬Ö÷Òª½«½øÐÐһЩ´úÂëµÄÇåÀí¹¤×÷¡£

    ÒÔÉÏÊÇÎÒÃǶÔа汾µÄһЩÏë·¨£¬Ï£Íû´ó¼ÒÄܹ»ÌÖÂÛ£¬²¢Çë¶àÌὨÒéºÍÒâ¼û¡£ÎÒÃǽ«¿¼ÂÇÊ×ÏÈʵÏֲ㣬ȻºóʵÏÖͼÐÎÒýÇæµÄ¸Ä½ø£¬×îºóʵÏÖʸÁ¿×ÖÌåÔÚ MiniGUI-Lite µ±ÖеÄÖ§³Ö¼°ÓÅ»¯¡£Èç¹ûÄú¶Ô MiniGUI а汾µÄ¿ª·¢ÓÐÐËȤ£¬¿ÉÒÔ¼ÓÈëÎÒÃǵÄÓʼþÁÐ±í£¬ÏêϸÐÅÏ¢Çë²Î¼ûhttp://www.minigui.org/ctalk.shtml¡£

[Ŀ¼]


MiniGUI 1.1.0ÒýÈëµÄÐÂGDI¹¦Äܺͺ¯Êý£¨1£©

1 ÒýÑÔ
    ÔÚ±¾ÏµÁпª·¢Ö¸ÄÏ£¨ËÄ£©ÖУ¬ÎÒÃÇÏêϸ½²½âÁË MiniGUI µÄ GDI º¯Êý¼°ÆäʹÓá£ÎÒÃÇÒ²ÔøÌáµ½£¬MiniGUI ÏÖÓÐµÄ GDI º¯ÊýºÍ¹¦ÄÜ£¬Éв»ÄܶԻú¶¥ºÐ¡¢ÊÝ¿Í»§»úµÈ¸ß¶ËǶÈëʽϵͳÌṩÁ¼ºÃÖ§³Ö¡£Òò´Ë£¬ÎÒÃÇÔÚ MiniGUI 1.1.0 °æ±¾µÄ¿ª·¢ÖУ¬Öصã¶Ô GAL ºÍ GDI ½øÐÐÁË´ó¹æÄ£µÄ¸ÄÁ¼£¬¼¸ºõÖØбàдÁËËùÓдúÂë¡£ÕâЩеĽӿں͹¦ÄÜ£¬Ê×ÏȳöÏÖÔÚ×î½ü·¢²¼µÄ MiniGUI 1.1.0Pre4 °æ±¾ÖУ¬ÎªÁË°ïÖú¿ª·¢ÈËÔ±ÕýÈ·Àí½âºÍʹÓÃÕâЩ¹¦ÄÜ£¬ÌØ׫ÎÄ˵Ã÷РGAL ºÍРGDI µÄ½Ó¿ÚºÍ¹¦ÄÜ¡£

2 РGAL ºÍРGDI ½Ó¿ÚµÄÉè¼ÆÄ¿±ê
    Ê×ÏÈ£¬MiniGUI ¾ÉµÄ GDI ½Ó¿Ú·Ç³£¼òµ¥£¬Æ书ÄÜÖ÷Òª¼¯ÖÐÔÚλͼºÍ¿é²Ù×÷ÉÏ£¬ÀýÈç FillBox º¯Êý¡¢FillBoxWithBitmap µÈµÈ£¬¶øȱÉÙ¶ÔÆäËû¸ß¼¶Í¼ÐβÙ×÷µÄÖ§³Ö£¬±ÈÈçÍÖÔ²¡¢Ô²»¡¡¢ÑùÌõÇúÏߵȵȡ£Æä´Î£¬¾ÉµÄ GDI ½Ó¿Ú»¹È±ÉÙ»ù±¾µÄ¹âÕ¤²Ù×÷¹¦ÄÜ¡£ÕâÀïµÄ¹âÕ¤²Ù×÷£¬Ö¸ÓûÉ趨ÏóËØÈçºÎÓëÆÁÄ»ÉÏÒÑÓеÄÏóËؽøÐÐÔËËã¡£×î»ù±¾µÄ¹âÕ¤²Ù×÷¹¦ÄÜÊǶþ½øÖƵÄλ²Ù×÷£¬°üÀ¨Óë¡¢»ò¡¢Òì»òÒÔ¼°Ö±½ÓÉèÖõȵȣ»¸ß¼¶µÄ¹âÕ¤²Ù×÷°üÀ¨Í¸Ã÷´¦ÀíºÍ Alpha »ìºÍ¡£ÕâЩ GDI ¹¦ÄܵÄȱ·¦£¬Ê¹µÃ MiniGUI ÔÚ»ú¶¥ºÐ¡¢ÊÝ¿Í»§µÈϵͳÖÐÓ¦ÓÃʱ£¬ÏÔµÃ"Á¦²»´ÓÐÄ"¡£ÔٴΣ¬¾ÉµÄ GDI ½Ó¿Ú»ù±¾ÉÏûÓп¼Âǵ½ÈκÎÓ²¼þ¼ÓËÙ¹¦ÄÜ¡£ÎÒÃÇ´ó¼Ò¶¼ÖªµÀ£¬ÏÔʾ¿¨×ÔÉíÌṩµÄÓ²¼þ¼ÓËÙ¹¦ÄÜ£¬Äܹ»´ó´óÌá¸ßͼÐγÌÐòµÄÔËÐÐËٶȣ¬Ê¹µÃ»­ÃæÁ÷³©¶ø×ÔÈ»£¬Èç¹û GUI ϵͳ²»Äܳä·ÖÀûÓÃÕâЩӲ¼þÌØÐԵĻ°£¬ÔòͼÐδ¦ÀíÄÜÁ¦½«´ó´òÕÛ¿Û¡£×îºó£¬¾ÉµÄ GAL Éè¼Æ´æÔÚ³éÏó²ã´ÎÌ«¸ßµÄÎÊÌ⣬µ¼ÖÂÁË GAL ÒýÇæÓ·Ö×£¬ÇÒÖظ´´úÂëºÜ¶à£¬Ò²²»±ãÓÚ½øÐдúÂëÉϵÄÓÅ»¯¡£

    ×ÛÉÏËùÊö£¬ÎÒÃDzÎÕÕÖøÃûµÄ¿çƽ̨ÓÎÏ·ºÍ¶àýÌ庯Êý¿â SDL£¨Simple DirectMedia Layer£©¶Ô GAL ÒýÇæ½á¹¹½øÐÐÁËÖØÐÂÉè¼Æ£¬²¢ÇÒÖØÐÂʵÏÖÁËËùÓÐµÄ GDI º¯Êý£¬Ê¹µÃÐ嵀 GDI ½Ó¿Ú¾ß±¸ÈçÏÂÌØÐÔ£º

    ·Äܹ»³ä·ÖÀûÓÃÓ²¼þÌØÐÔ£¬°üÀ¨ÏÔʾÄÚ´æºÍÓ²¼þ¼ÓËÙÄÜÁ¦¡£
    ·Ö§³Ö¸ß¼¶Í¼ÐβÙ×÷£¬°üÀ¨»ù±¾¹âÕ¤²Ù×÷¡¢Í¸Ã÷´¦ÀíºÍ Alpha »ìºÍ¡£
    ·ÔöÇ¿Á˼ôÇÐÇøÓò´¦ÀíÄÜÁ¦£¬ÓÐÖúÓÚÓÅ»¯Í¼ÐÎÊä³öº¯Êý¡£
    ·ÔöÇ¿ÁËÔ­ÓÐµÄ BITMAP ½Ó¿Ú£¬Ê¹Ö®Ö§³Ö͸Ã÷ºÍ Alpha ͨµÀ¡£
    ·³ä·ÖÀûÓÃǶÈëʽ»ã±à´úÂë½øÐдúÂëÓÅ»¯¡£

ÏÂÃ潫Öص㽲ÊöÐ嵀 GAL ¹¦ÄܺÍÐ嵀 GDI ½Ó¿Ú¡£

3 РGAL ¹¦ÄÜÌØÐÔ
    Ð嵀 GAL ½á¹¹À´×ÔÖøÃûµÄ¿çƽ̨ÓÎÏ·ºÍ¶àýÌå¿â SDL£¨Simple DirectMedia Layer£©¡£Ä¿Ç°ÌṩÁË¶Ô Linux FrameBuffer µÄÖ§³Ö£¬¼Æ»®ÔÚ½«À´Ìṩ¶Ô X¡¢SVGALib ºÍ VGL£¨FreeBSD£©µÈµÈͼÐοâµÄÖ§³Ö¡£

3.1 GAL ºÍ GDI µÄ¹Øϵ
    ´ó¼Ò¶¼ÖªµÀ£¬MiniGUI µÄ GAL ÊÇÒ»¸öͼÐγéÏó²ã£¬Ìṩ¸øÉϲã GDI º¯ÊýһЩ»ù´¡µÄ¹¦ÄܺÍÉèÊ©¡£ÔÚÏÈÇ°µÄÉè¼ÆÖУ¬GAL ¿ÉÒÔ¿´³ÉÊÇ GDI ͼÐÎÇý¶¯³ÌÐò£¬Ðí¶àͼÐβÙ×÷º¯Êý£¬±ÈÈçµã¡¢Ïß¡¢¾ØÐÎÌî³ä¡¢Î»Í¼²Ù×÷µÈµÈ£¬¾ùͨ¹ý GAL µÄÏàÓ¦º¯ÊýÍê³É¡£ÕâÖÖÉè¼ÆµÄ×î´óÎÊÌâÊÇÎÞ·¨¶Ô GDI ½øÐÐÀ©Õ¹¡£±ÈÈçÒªÔö¼ÓÍÖÔ²»æÖƺ¯Êý£¬¾ÍÐèÒªÔÚÿ¸öÒýÇæµ±ÖÐʵÏÖÍÖÔ²µÄ»æÖƺ¯Êý¡£²¢ÇÒ GDI ¹ÜÀíµÄÊǼôÇÐÓò£¬¶ø GAL ÒýÇæÈ´»ùÓÚ¼ôÇоØÐνøÐвÙ×÷¡£ÕâÖÖ·½·¨Ò²µ¼ÖÂÁË GDI º¯ÊýÎÞ·¨½øÐлæÖÆÓÅ»¯¡£Òò´Ë£¬ÔÚÐ嵀 GAL ºÍ GDI ½Ó¿ÚÉè¼ÆÖУ¬ÎÒÃǽ« GAL µÄ½Ó¿Ú½øÐÐÁËÏÞÖÆ£¬¶ø½«Ô­ÓÐÐí¶àÓÉ GAL ÒýÇæÍê³ÉµÄͼÐÎÊä³öº¯Êý£¬Ìá¸ßµ½Éϲã GDI º¯ÊýÖÐÍê³É¡£GAL ºÍ GDI µÄÐµĹ¦ÄÜ»®·ÖÈçÏ£º

    ·GAL ¸ºÔð¶ÔÏÔʾÉ豸½øÐгõʼ»¯£¬²¢¹ÜÀíÏÔʾÄÚ´æµÄʹÓã»
    ·GAL ¸ºÔðΪÉϲã GDI ÌṩӳÉäµ½½ø³ÌµØÖ·¿Õ¼äµÄÏßÐÔÏÔʾÄڴ棬ÒÔ¼°ÖîÈçµ÷É«°åµÈÆäËûÏà¹ØÐÅÏ¢£»
    ·GAL ¸ºÔðʵÏÖ¿ìËÙµÄλ¿é²Ù×÷£¬°üÀ¨¾ØÐÎÌî³äºÍ Blitting ²Ù×÷µÈ£¬²¢ÇÒÔÚ¿ÉÄܵÄÇé¿öÏ£¬³ä·ÖÀûÓÃÓ²¼þ¼ÓËÙ¹¦ÄÜ£»
    ·GDI º¯ÊýʵÏָ߼¶Í¼Ðι¦ÄÜ£¬°üÀ¨µã¡¢Ïß¡¢Ô²¡¢ÍÖÔ²¡¢Ô²»¡¡¢ÑùÌõÇúÏߣ¬ÒÔ¼°¸ü¼Ó¸ß¼¶µÄÂß¼­»­±ÊºÍÂß¼­»­Ë¢£¬±ØҪʱµ÷Óà GAL ½Ó¿ÚÍê³É¼ÓËÙ¹¦ÄÜ£»

    ¾¡¹ÜijЩÏÔʾ¿¨Ò²ÌṩÓжÔÉÏÊö¸ß¼¶»æͼ¹¦ÄܵÄÓ²¼þÖ§³Ö£¬µ«¿¼Âǵ½ÆäËûÒòËØ£¬ÕâЩӲ¼þ¼ÓËÙ¹¦Äܲ»ÓÉ GAL ½Ó¿ÚÌṩ£»¶øͳͳͨ¹ýÈí¼þʵÏÖ¡£

    ÕâÑù£¬GAL Ö÷ҪʵÏֵĻæͼ¹¦ÄÜÏÞÖÆÔÚλ¿é²Ù×÷ÉÏ£¬±ÈÈç¾ØÐÎÌî³äºÍ Blitting ²Ù×÷£»¶øÆäËûµÄ¸ß¼¶Í¼Ðι¦ÄÜ£¬ÔòÈ«²¿ÓÉ GDI º¯ÊýʵÏÖ¡£

3.2 ÏÔʾÄÚ´æµÄÓÐЧÀûÓÃ
    Ð嵀 GAL ½Ó¿ÚÄܹ»ÓÐЧÀûÓÃÏÔʾ¿¨ÉϵÄÏÔʾÄڴ棬²¢³ä·ÖÀûÓÃÓ²¼þ¼ÓËÙ¹¦ÄÜ¡£ÎÒÃÇÖªµÀ£¬ÏÖÔÚÏÔʾ¿¨Ò»°ã¾ßÓÐ 4M ÒÔÉϵÄÏÔʾÄڴ棬¶øÒ»°ãµÄÏÔʾģʽÏ£¬²»»áÕ¼ÓÃËùÓеÄÏÔʾÄÚ´æ¡£±ÈÈçÔÚÏÔʾģʽΪ 1204x768x32bpp ʱ£¬Ò»ÆÁÏóËØËùÕ¼ÓõÄÄÚ´æΪ 3M£¬»¹ÓÐ 1M µÄÄÚ´æ¿É¹©Ó¦ÓóÌÐòʹÓá£Òò´Ë£¬Ð嵀 GAL ÒýÇæÄܹ»¹ÜÀíÕⲿ·Öδ±»Ê¹ÓõÄÏÔʾÄڴ棬²¢·ÖÅä¸øÓ¦ÓóÌÐòʹÓá£ÕâÑù£¬Ò»·½Ãæ¿ÉÒÔ½ÚʡϵͳÄÚ´æµÄʹÓã¬ÁíÒ»·½Ã棬¿ÉÒÔ³ä·ÖÀûÓÃÏÔʾ¿¨ÌṩµÄ¼ÓËÙ¹¦ÄÜ£¬ÔÚÏÔʾÄÚ´æµÄÁ½¸ö²»Í¬ÄÚ´æÇøÓòÖ®¼ä½øÐпìËÙµÄλ¿é²Ù×÷£¬Ò²¾ÍÊdz£ËµµÄ Blitting¡£

3.3 Blitting ²Ù×÷
    ÔÚÉϲã GDI ½Ó¿ÚÔÚ½¨Á¢ÄÚ´æ DC É豸ʱ£¬½«Ê×ÏÈÔÚÏÔʾÄÚ´æÉÏ·ÖÅäÄڴ棬Èç¹ûʧ°Ü£¬²Å»á¿¼ÂÇʹÓÃϵͳÄÚ´æ¡£ÕâÑù£¬Èç¹û GAL ÒýÇæÌṩÁËÓ²¼þ¼ÓËÙ¹¦ÄÜ£¬Á½¸ö²»Í¬ DC É豸֮¼äµÄ Blitting ²Ù×÷£¨¼´ GDI º¯Êý BitBlt£©£¬½«ÒÔ×î¿ìµÄËÙ¶ÈÔËÐС£¸ü½øÒ»²½£¬Èç¹ûÓ²¼þÖ§³Ö͸Ã÷»ò Alpha »ìºÍ¹¦ÄÜ£¬Ôò͸Ã÷µÄ»òÕß Alpha »ìºÍµÄ Blitting ²Ù×÷Ò²½«ÒÔ×î¿ìµÄËÙ¶ÈÔËÐС£Ð嵀 GAL ½Ó¿ÚÄܹ»¸ù¾Ýµ×²ãÒýÇæµÄ¼ÓËÙÄÜÁ¦×Ô¶¯ÀûÓÃÕâЩӲ¼þ¼ÓËÙ¹¦ÄÜ¡£Ä¿Ç°Ö§³ÖµÄÓ²¼þ¼ÓËÙÄÜÁ¦Ö÷ÒªÓУº¾ØÐÎÌî³ä£¬ÆÕͨµÄ Blitting ²Ù×÷£¬Í¸Ã÷¡¢Alpha »ìºÍµÄ Blitting ²Ù×÷µÈ¡£µ±È»£¬Èç¹ûÓ²¼þ²»Ö§³ÖÕâЩ¼ÓËÙ¹¦ÄÜ£¬Ð嵀 GAL ½Ó¿ÚÒ²Äܹ»Í¨¹ýÈí¼þʵÏÖÕâЩ¹¦ÄÜ¡£Ä¿Ç°Í¨¹ý GAL µÄ FrameBuffer ÒýÇæÌṩÉÏÊöÓ²¼þ¼ÓËÙ¹¦ÄܵÄÏÔ¿¨ÓУºMatrox¡¢3dfx µÈ¡£

    ÔÚͨ¹ýÈí¼þʵÏÖ͸Ã÷»ò»ìºÍµÄ DC ¼ä Blitting ²Ù×÷ʱ£¬Ð嵀 GAL ½Ó¿ÚÀûÓÃÁËÁ½ÖÖÓÐЧµÄÓÅ»¯´ëÊ©£º

    ÔÚ i386 ƽ̨ÉÏ£¬³ä·ÖÀûÓÃǶÈëʽ»ã±à´úÂë½øÐÐÓÅ»¯´¦Àí£»±ÈÈçÔÚ´¦Àí 32 λɫģʽϵÄÆÕͨ Blitting ²Ù×÷ʱ£¬ÔÚÀûÓÃÆÕͨµÄ C ¿âº¯Êý£¬¼´ memcpy ½øÐÐλ¿é¸´ÖÆʱ£¬ÓÉÓÚ memcpy º¯ÊýÊÇÒÔ×Ö½ÚΪµ¥Î»½øÐи´ÖƵģ¬´Ó¶øÎÞ·¨ÀûÓà 32 λ CPU ¶Ô 32 λ×ֵĴ¦ÀíÄÜÁ¦£¬Îª´Ë£¬¿ÉÒÔʹÓÃǶÈëʽ»ã±à£¬²¢ÒÔ 32 λ×ÖΪµ¥Î»½øÐи´ÖÆ£¬Õ⽫´ó´óÌá¸ß Bliting ²Ù×÷µÄ´¦ÀíËٶȡ£
    ¶ÔÔ´ DC ½øÐÐ RLE£¨Run Length Encoding£©±àÂ룬´Ó¶ø¶ÔÏóËصĴ¦ÀíÊýÁ¿×îС»¯¡£RLE ¿ÉÒÔ¿´³ÉÊÇÒ»ÖÖͼÏóѹËõËã·¨£¬Windows BMP Îļþ¾ÍÀûÓÃÁËÕâÖÖËã·¨¡£RLE ÊÇ°´Ë®Æ½É¨ÃèÏß½øÐÐѹËõ±àÂë´¦ÀíµÄ¡£ÔÚÒ»ÌõɨÃèÏßÉÏ£¬Èç¹ûÓдóÁ¿ÏàͬµÄÏóËØ£¬Ôò²»»á±£´æÕâЩÏóËص㣬¶øÊÇÊ×Ïȱ£´æ¾ßÓÐÏàͬÏóËصãµÄÊýÄ¿£¬È»ºó±£´æÕâЩÏóËصãµÄÖµ¡£ÕâÑù£¬ÔÚ½øÐÐ͸Ã÷»òÕß»ìºÍµÄ Blitting ²Ù×÷ʱ£¬¿ÉÒÔ´ó´ó½µµÍÖðµãÔËËã´øÀ´µÄËÙ¶ÈËðʧ¡£µ«ÊÇ£¬Èç¹ûÔÚ×µÄÇé¿öÏ£¬±ÈÈçËùÓÐˮƽɨÃèÏßÉϵÄÏóËص㶼¾ßÓкÍÏàÁڵ㲻ͬµÄÏóËØÖµ£¬Ôò RLE ±àÂë·´¶ø»áÔö¼ÓÏóËصĴ洢¿Õ¼ä£¨×µÄÇé¿öÊÇÔ­ÓпռäµÄÁ½±¶£©£¬Í¬Ê±Ò²»á½µµÍ Blitting ²Ù×÷µÄËٶȡ£Òò´ËÊÇ·ñʹÓà RLE ±àÂ룬Ҫ¸ù¾ÝÇé¿ö¶ø¶¨¡£Ð嵀 GDI ½Ó¿ÚÔÚÖ¸¶¨Ô´ DC µÄ͸Ã÷ºÍ Alpha ͨµÀֵʱ£¬¿ÉÒÔÖ¸¶¨ÊÇ·ñʹÓà RLE ±àÂë¡£

3.4 ÓÐЧ·Ö±æÂÊ
    Ð嵀 GAL ÒýÇæ¿ÉÒÔÉ趨һ¸ö²»Í¬ÓÚʵ¼ÊÏÔʾ·Ö±æÂʵÄÓÐЧ·Ö±æÂÊ¡£±ÈÈçʵ¼ÊµÄÏÔʾ·Ö±æÂÊÊÇ 1024x768£¬Ôò¿ÉÒÔÔÚ /etc/MiniGUI.cfg ÎļþÖÐÖ¸¶¨±Èʵ¼Ê·Ö±æÂʵ͵ÄÓÐЧ·Ö±æÂÊ¡£ÕâÖÖÌØÐÔÓÐÀûÓÚÔÚ PC Éϵ÷ÊÔÐèÒªÔËÐÐÔÚ½ÏС·Ö±æÂÊϵͳÉϵÄÓ¦ÓóÌÐò¡£±ÈÈ磺

[system]
gal_engine=native
ial_engine=native

[native]
defaultmode=320x240x16

    ÆäÖÐÔÚ defaultmode µ±ÖÐÖ¸¶¨ÁËÓÐЧ·Ö±æÂÊΪ 320x240£¬16 Ôò±íʾÑÕÉ«Éî¶È£¬¼´ 16 λɫ£¬»òÕß³ÆΪÿÏóËصĶþ½øÖÆλÊý¡£ÐèҪעÒâµÄÊÇ£¬¶Ô VESA FramBuffer É豸£¬±ØÐëÖ¸¶¨ºÍµ±Ç°ÑÕÉ«Éî¶ÈÒ»ÖµÄÑÕÉ«Éî¶ÈÖµ¡£¶ÔÆäËûµÄ FrameBuffer É豸£¬Èç¹ûÄܹ»Ö§³Ö¶àÖÖÏÔʾģʽ£¬Ôò»á¸ù¾Ý defaultmode Ö¸¶¨µÄģʽÉèÖõ±Ç°·Ö±æÂÊ¡£

3.5 РGAL µÄÏÞÖÆ
    ÐèҪעÒâµÄÊÇ£¬Ð嵀 GAL ½á¹¹Ö»´òËãÖ§³ÖÏßÐÔÏÔʾÄڴ棬²¢ÇÒÖ»Ö§³Ö 8 λɫÒÔÉϵÄÏÔʾģʽ¡£Èç¹ûÒªÖ§³ÖµÍÓÚ 8 λɫµÄÏÔʾģʽ£¬Ôò¿ÉÒÔÑ¡ÔñʹÓÃÀ쵀 GAL ºÍ GDI ½Ó¿Ú¡£ÔÚÅäÖà MiniGUI µÄʱºò£¬Äã¿ÉÒÔÖ¸¶¨ÊÇ·ñʹÓÃÀ쵀 GAL ºÍ GDI ½Ó¿Ú¡£Ä¬ÈÏÇé¿öϵÄÅäÖÃÊÇʹÓÃÐ嵀 GAL ºÍ GDI ½Ó¿Ú£¬ÐèҪʹÓÃÀ쵀 GAL ºÍ GDI ½Ó¿Úʱ£¬Ó¦½øÐÐÈçϵÄÅäÖãº

./configure --disable-newgal

    ÁíÍ⣬Ð嵀 GAL ½Ó¿ÚÖ§³Ö Gamma УÕýºÍ YUV Overlay£¬µ«Ä¿Ç°ÉÐδÔÚ GDI ½Ó¿ÚÖÐÌåÏÖÕâЩ¹¦ÄÜ¡£ÔÚеİ汾ÖУ¬»áÖð²½Ìí¼ÓÏàÓ¦µÄ GDI ½Ó¿Ú¡£

4 Ð嵀 GDI ½Ó¿Ú

4.1 еÄÇøÓòËã·¨
    Ð嵀 GDI ²ÉÓÃÁËеÄÇøÓòËã·¨£¬¼´ÔÚ X Window ºÍÆäËû GUI ϵͳµ±Öй㷺ʹÓõÄÇøÓòËã·¨¡£ÕâÖÖÇøÓò³Æ×÷"x-y-banned"ÇøÓò£¬²¢ÇÒ¾ßÓÐÈçÏÂÌص㣺

ÇøÓòÓÉ»¥²»ÏཻµÄ·Ç¿Õ¾ØÐÎ×é³É£»
    ÇøÓòÓÖ¿ÉÒÔ»®·ÖΪÈô¸É»¥²»ÏཻµÄˮƽÌõ´ø£¬Ã¿¸öˮƽÌõ´øÖеľØÐÎÊǵȸߣ¬¶øÇÒÊÇÉ϶ÔÆëµÄ£»»òÕß˵£¬ÕâЩ¾ØÐξßÓÐÏàͬµÄ¸ß¶È£¬¶øÇÒËùÓоØÐεÄ×óÉÏ½Ç y ×ø±êÏàµÈ¡£
ÇøÓòÖоØÐεÄÅÅÁУ¬Ê×ÏÈÊÇÔÚ x ·½Ïò£¨ÔÚÒ»¸öÌõ´øÖУ©´Ó×óµ½ÓÒÅÅÁУ¬È»ºó°´ÕÕ y ×ø±ê´ÓÉϵ½ÏÂÅÅÁС£

    ÔÚ GDI º¯Êý½øÐлæͼÊä³öʱ£¬¿ÉÒÔÀûÓà x-y-banned ÇøÓòµÄÌØÊâÐÔÖʽøÐлæͼµÄÓÅ»¯¡£ÔÚ½«À´°æ±¾ÖÐÌí¼ÓµÄ»æͼº¯Êý£¬½«³ä·ÖÀûÓÃÕâÒ»ÌØÐÔ½øÐлæͼÊä³öÉϵÄÓÅ»¯¡£

    Ð嵀 GDI Ôö¼ÓÁËÈçϽӿڣ¬¿ÉÓÃÓÚ¼ôÇÐÇøÓòµÄÔËË㣨include/gdi.h£©£º

BOOL GUIAPI PtInRegion (PCLIPRGN region, int x, int y);
BOOL GUIAPI RectInRegion (PCLIPRGN region, const RECT* rect);

BOOL GUIAPI IntersectRegion (CLIPRGN *dst, const CLIPRGN *src1, const CLIPRGN *src2);
BOOL GUIAPI UnionRegion (PCLIPRGN dst, const CLIPRGN* src1, const CLIPRGN* src2);
BOOL GUIAPI SubtractRegion (CLIPRGN* rgnD, const CLIPRGN* rgnM, const CLIPRGN* rgnS);
BOOL GUIAPI XorRegion (CLIPRGN *dst, const CLIPRGN *src1, const CLIPRGN *src2);

PtInRegion º¯Êý¿ÉÓÃÀ´¼ì²é¸ø¶¨µãÊÇ·ñλÓÚ¸ø¶¨µÄÇøÓòÖС£
RectInRegion º¯Êý¿ÉÓÃÀ´¼ì²é¸ø¶¨¾ØÐÎÊÇ·ñºÍ¸ø¶¨ÇøÓòÏཻ¡£
IntersectRegion º¯Êý¶ÔÁ½¸ö¸ø¶¨ÇøÓò½øÐÐÇó½»ÔËËã¡£
UnionRegion º¯Êý¿ÉºÏ²¢Á½¸ö²»Í¬µÄÇøÓò£¬ºÏ²¢ºóµÄÇøÓòÈÔÈ»ÊÇ x-y-banned µÄÇøÓò¡£
SubstractRegion º¯Êý´ÓÒ»¸öÇøÓòÖмõÈ¥ÁíÍâÒ»¸öÇøÓò¡£
XorRegion º¯Êý¶ÔÁ½¸öÇøÓò½øÐÐÒì»òÔËË㣬Æä½á¹ûÏ൱ÓÚ src1 ¼õ src2 µÄ½á¹û A Óë src2 ¼õ src1 µÄ½á¹û B Ö®¼äµÄ½»¡£
ÔÚ MiniGUI 1.1.0 °æ±¾Õýʽ·¢²¼Ê±£¬ÎÒÃǽ«Ìí¼Ó´Ó¶à±ßÐΡ¢ÍÖÔ²»òÔ²»¡µÈ·â±ÕÇúÏßÖÐÉú³É¼ôÇÐÓòµÄ GDI º¯Êý¡£ÕâÑù£¬¾Í¿ÉÒÔʵÏÖ½« GDI Êä³öÏÞÖÆÔÚÌØÊâ·â±ÕÇúÏßµÄЧ¹û¡£

4.2 ¹âÕ¤²Ù×÷
    ¹âÕ¤²Ù×÷ÊÇÖ¸ÔÚ½øÐлæͼÊä³öʱ£¬ÈçºÎ½«ÒªÊä³öµÄÏóËصãºÍÆÁÄ»ÉÏÒÑÓеÄÏóËصã½øÐÐÔËËã¡£×îµäÐ͵ÄÔËËãÊÇÏÂÃæÒª½²µ½µÄ Alpha »ìºÍ¡£ÕâÀïµÄ¹âÕ¤²Ù×÷ÌØÖ¸¶þ½øÖƵÄλ²Ù×÷£¬°üÀ¨Óë¡¢»ò¡¢Òì»òºÍÖ±½ÓµÄÉèÖ㨸²¸Ç£©µÈµÈ¡£Ó¦ÓóÌÐò¿ÉÒÔÀûÓà SetRasterOperation/GetRasterOperation º¯ÊýÉèÖûòÕß»ñÈ¡µ±Ç°µÄ¹âÕ¤²Ù×÷¡£ÕâÁ½¸öº¯ÊýµÄÔ­ÐÍÈçÏ£¨include/gdi.h£©£º

#define ROP_SET         0
#define ROP_AND         1
#define ROP_OR          2
#define ROP_XOR         3

int GUIAPI GetRasterOperation (HDC hdc);
int GUIAPI SetRasterOperation (HDC hdc, int rop);

    ÔÚÉèÖÃÁËеĹâÕ¤²Ù×÷Ö®ºó£¬ÆäºóµÄÒ»°ãͼÐÎÊä³ö½«Êܵ½É趨µÄ¹âÕ¤²Ù×÷µÄÓ°Ï죬ÕâЩͼÐÎÊä³ö°üÀ¨£ºSetPixel¡¢LineTo¡¢Circle¡¢Rectangle¡¢FillRect ºÍ FillCircle µÈµÈ¡£ÐèҪעÒâµÄÊÇ£¬Ð嵀 GDI º¯ÊýÒýÈëÁËÒ»¸öеľØÐÎÌî³äº¯Êý¨D¨DFillRect¡£ÈçÉÏËùÊö£¬FillRect º¯ÊýÊÇÊܵ±Ç°¹âÕ¤²Ù×÷Ó°ÏìµÄ£¬¶øÔ­Ï鵀 FillBox º¯ÊýÔò²»Êܵ±Ç°µÄ¹âÕ¤²Ù×÷Ó°Ïì¡£ÕâÊÇÒòΪ FillBox º¯Êý»áÀûÓÃÓ²¼þ¼ÓËÙ¹¦ÄÜʵÏÖ¾ØÐÎÌî³ä£¬²¢ÇҸú¯ÊýµÄÌî³äËÙ¶ÈÒª±È FillRect º¯Êý¿ì¡£

4.3 ÄÚ´æ DC ºÍ BitBlt
    Ð嵀 GDI º¯ÊýÔöÇ¿ÁËÄÚ´æ DC ²Ù×÷º¯Êý¡£GDI º¯ÊýÔÚ½¨Á¢ÄÚ´æ DC ʱ£¬½«µ÷Óà GAL µÄÏàÓ¦½Ó¿Ú¡£ÈçÇ°ËùÊö£¬GAL ½«¾¡Á¿°ÑÄÚ´æ DC ½¨Á¢ÔÚÏÔʾ¿¨µÄÏÔʾÄÚ´æµ±ÖС£ÕâÑù£¬¿ÉÒÔ³ä·ÖÀûÓÃÏÔʾ¿¨µÄÓ²¼þ¼ÓËÙ¹¦ÄÜ£¬ÊµÏÖÏÔʾÄÚ´æÖÐÁ½¸ö²»Í¬ÇøÓòÖ®¼äλ¿éµÄ¿ìËÙÒƶ¯¡¢¸´ÖƵȵȣ¬°üÀ¨Í¸Ã÷´¦ÀíºÍ Alpha »ìºÍ¡£Ó¦ÓóÌÐò¿ÉÒÔ½¨Á¢Ò»¸ö¾ßÓÐÖðµã Alpha ÌØÐÔµÄÄÚ´æ DC£¨Ã¿¸öµã¾ßÓв»Í¬µÄ Alpha Öµ£©£¬Ò²¿ÉÒÔͨ¹ý SetMemDCAlpha ÉèÖÃÄÚ´æ DC ËùÓÐÏóËØµÄ Alpha Öµ£¨»òÕß³ÆΪ"Alpha ͨµÀ"£©£¬È»ºóÀûÓà BitBlt ºÍ StretchBlt º¯ÊýʵÏÖ DC Ö®¼äµÄλ¿é´«ËÍ¡£Ó¦ÓóÌÐò»¹¿ÉÒÔͨ¹ý SetMemDCColorKey º¯ÊýÉèÖÃÔ´ DC µÄ͸Ã÷É«£¬´Ó¶øÔÚ½øÐÐ BitBlt ʱÌø¹ýÕâЩ͸Ã÷É«¡£

ÓйØÄÚ´æ DC µÄ GDI º¯ÊýÓУ¨include/gdi.h£©£º

#define MEMDC_FLAG_NONE         0x00000000          /* None. */
#define MEMDC_FLAG_SWSURFACE    0x00000000          /* DC is in system memory */
#define MEMDC_FLAG_HWSURFACE    0x00000001          /* DC is in video memory */
#define MEMDC_FLAG_SRCCOLORKEY  0x00001000          /* Blit uses a source color key */
#define MEMDC_FLAG_SRCALPHA     0x00010000          /* Blit uses source alpha blending */
#define MEMDC_FLAG_RLEACCEL     0x00004000          /* Surface is RLE encoded */

HDC GUIAPI CreateCompatibleDC (HDC hdc);
HDC GUIAPI CreateMemDC (int width, int height, int depth, DWORD flags,
                Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
BOOL GUIAPI ConvertMemDC (HDC mem_dc, HDC ref_dc, DWORD flags);
BOOL GUIAPI SetMemDCAlpha (HDC mem_dc, DWORD flags, Uint8 alpha);
BOOL GUIAPI SetMemDCColorKey (HDC mem_dc, DWORD flags, Uint32 color_key);
void GUIAPI DeleteMemDC (HDC mem_dc);

    CreateCompatibleDC º¯Êý´´½¨Ò»¸öºÍ¸ø¶¨ DC ¼æÈݵÄÄÚ´æ DC¡£¼æÈݵĺ¬ÒåÊÇÖ¸£¬Ð´´½¨µÄÄÚ´æ DC µÄÏóËظñʽ¡¢¿í¶ÈºÍ¸ß¶ÈÓë¸ø¶¨ DC ÊÇÏàͬµÄ¡£ÀûÓÃÕâÖÖ·½Ê½½¨Á¢µÄÄÚ´æ DC ¿ÉÒÔ¿ìËÙ Blit µ½ÓëÖ®¼æÈÝµÄ DC ÉÏ¡£

    ÕâÀïÐèÒª¶ÔÏóËظñʽ×ö½øÒ»²½½âÊÍ¡£ÏóËظñʽ°üº¬ÁËÑÕÉ«Éî¶È£¨¼´Ã¿ÏóËصãµÄ¶þ½øÖÆλÊý£©¡¢µ÷É«°å»òÕßÏóËصãÖÐ RGBA£¨ºì¡¢ÂÌ¡¢À¶¡¢Alpha£©Ëĸö·ÖÁ¿µÄ×é³É·½Ê½¡£ÆäÖÐµÄ Alpha ·ÖÁ¿£¬¿ÉÒÔÀí½âΪһ¸öÏóËصãµÄ͸Ã÷¶È£¬0 ±íʾÍêȫ͸Ã÷£¬255 ±íʾÍêÈ«²»Í¸Ã÷¡£ÔÚ MiniGUI ÖУ¬Èç¹ûÑÕÉ«Éî¶ÈµÍÓÚ 8£¬Ôò GAL »áĬÈÏ´´½¨Ò»¸öµ÷É«°å£¬²¢ÇÒ¿ÉÒÔµ÷Óà SetPalette º¯ÊýÐ޸ĵ÷É«°å¡£Èç¹ûÑÕÉ«Éî¶È¸ßÓÚ 8£¬Ôòͨ¹ýËĸö±äÁ¿·Ö±ðÖ¸¶¨ÏóËصãÖÐ RGBA ·ÖÁ¿ËùÕ¼µÄλ¡£Èç¹ûÊǽ¨Á¢¼æÈÝ DC£¬Ôò¼æÈÝÄÚ´æ DC ºÍ¸ø¶¨ DC ¾ßÓÐÒ»ÑùµÄÑÕÉ«Éî¶È£¬Í¬Ê±¾ßÓÐÒ»ÑùµÄµ÷É«°å»òÕßÒ»ÑùµÄ RGBA ·ÖÁ¿×é³É·½Ê½¡£

    Èç¹ûµ÷Óà CreateMemDC º¯Êý£¬Ôò¿ÉÒÔÖ¸¶¨Ð½¨ÄÚ´æ DC µÄ¸ß¶È¡¢¿í¶È¡¢ÑÕÉ«Éî¶È£¬ÒÔ¼°±ØÒªµÄ RGBA ×é³É·½Ê½¡£ÔÚ MiniGUI ÖУ¬ÊÇͨ¹ý¸÷×ÔÔÚÏóËصãÖÐËùÕ¼ÓõÄλÑÚÂëÀ´±íʾ RGBA Ëĸö·ÖÁ¿µÄ×é³É·½Ê½µÄ¡£±ÈÈ磬Èç¹ûÒª´´½¨Ò»¸ö°üº¬Öðµã Alpha ÐÅÏ¢µÄ16 λÄÚ´æ DC£¬Ôò¿ÉÒÔÓÃÿ·ÖÁ¿Ëĸö¶þ½øÖÆλµÄ·½Ê½·ÖÅä 16 λµÄÏóËØÖµ£¬ÕâÑù£¬RGBA Ëĸö·ÖÁ¿µÄÑÚÂë·Ö±ðΪ£º0x0000F000, 0x00000F00, 0x000000F0, 0x0000000F¡£

    ConvertMemDC º¯ÊýÓÃÀ´½«Ò»¸öÈÎÒâµÄÄÚ´æ DC ¶ÔÏ󣬸ù¾Ý¸ø¶¨µÄ²Î¿¼ DC µÄÏóËظñʽ½øÐÐת»»£¬Ê¹µÃ½á¹û DC ¾ßÓкͲο¼ DC Ò»ÑùµÄÏóËظñʽ¡£ÕâÑù£¬×ª»»ºóµÄ DC ¾ÍÄܹ»¿ìËÙ Blit µ½ÓëÖ®¼æÈÝµÄ DC ÉÏ¡£

    SetMemDCAlpha º¯ÊýÓÃÀ´É趨»òÕßÈ¡ÏûÕû¸öÄÚ´æ DC ¶ÔÏóµÄ Alpha ͨµÀÖµ¡£ÎÒÃÇ»¹¿ÉÒÔͨ¹ý MEMDC_FLAG_RLEACCEL ±êÖ¾Ö¸¶¨ÄÚ´æ DC ²ÉÓûòÕßÈ¡Ïû RLE ±àÂ뷽ʽ¡£Alpha ͨµÀÖµ½«×÷ÓÃÔÚ DC µÄËùÓÐÏóËصãÉÏ¡£

    SetMemDCColorKey º¯ÊýÓÃÀ´É趨»òÕßÈ¡ÏûÕû¸öÄÚ´æ DC ¶ÔÏóµÄ ColorKey£¬¼´Í¸Ã÷ÏóËØÖµ¡£ÎÒÃÇ»¹¿ÉÒÔͨ¹ý MEMDC_FLAG_RLEACCEL ±êÖ¾Ö¸¶¨ÄÚ´æ DC ²ÉÓûòÕßÈ¡Ïû RLE ±àÂ뷽ʽ¡£

    ÄÚ´æ DC ºÍÆäËû DC Ò»Ñù£¬Ò²¿ÉÒÔµ÷Óà GDI µÄ»æͼº¯ÊýÏòÄÚ´æ DC ÖнøÐÐÈÎÒâµÄ»æͼÊä³ö£¬È»ºóÔÙ BitBlt µ½ÆäËû DC ÖС£ÏÂÃæµÄ³ÌÐò¶ÎÑÝʾÁËÈçºÎʹÓÃÄÚ´æ DC Ïò´°¿Ú DC ½øÐÐ͸Ã÷ºÍ Alpha »ìºÍµÄ Blitting ²Ù×÷£º

  /* Öðµã Alpha ²Ù×÷ */
    mem_dc = CreateMemDC (400, 100, 16, MEMDC_FLAG_HWSURFACE | MEMDC_FLAG_SRCALPHA,
                    0x0000F000, 0x00000F00, 0x000000F0, 0x0000000F);

    /* ÉèÖÃÒ»¸ö²»Í¸Ã÷µÄË¢×Ó²¢Ìî³ä¾ØÐÎ */
    SetBrushColor (mem_dc, RGBA2Pixel (mem_dc, 0xFF, 0xFF, 0x00, 0xFF));
    FillBox (mem_dc, 0, 0, 200, 50);

    /* ÉèÖÃÒ»¸ö 25%  ͸Ã÷µÄË¢×Ó²¢Ìî³ä¾ØÐÎ */
    SetBrushColor (mem_dc, RGBA2Pixel (mem_dc, 0xFF, 0xFF, 0x00, 0x40));
    FillBox (mem_dc, 200, 0, 200, 50);

    /* ÉèÖÃÒ»¸ö°ë͸Ã÷µÄË¢×Ó²¢Ìî³ä¾ØÐÎ */
    SetBrushColor (mem_dc, RGBA2Pixel (mem_dc, 0xFF, 0xFF, 0x00, 0x80));
    FillBox (mem_dc, 0, 50, 200, 50);

    /* ÉèÖÃÒ»¸ö 75% ͸Ã÷µÄË¢×Ó²¢Ìî³ä¾ØÐÎ */
    SetBrushColor (mem_dc, RGBA2Pixel (mem_dc, 0xFF, 0xFF, 0x00, 0xC0));
    FillBox (mem_dc, 200, 50, 200, 50);
    SetBkMode (mem_dc, BM_TRANSPARENT);

    /* ÒÔ°ë͸Ã÷µÄÏóËصãÊä³öÎÄ×Ö */
    SetTextColor (mem_dc, RGBA2Pixel (mem_dc, 0x00, 0x00, 0x00, 0x80));
    TabbedTextOut (mem_dc, 0, 0, "Memory DC with alpha.\n"
                                 "The source DC have alpha per-pixel.");

    /* Blit µ½´°¿Ú DC ÉÏ */
    start_tick = GetTickCount ();
    count = 100;
    while (count--) {
        BitBlt (mem_dc, 0, 0, 400, 100, hdc, rand () % 800, rand () % 800);
    }
    end_tick = GetTickCount ();
    TellSpeed (hwnd, start_tick, end_tick, "Alpha Blit", 100);

    /* ɾ³ýÄÚ´æ DC */
    DeleteMemDC (mem_dc);

    /* ¾ßÓÐ Alpha ͨµÀ µÄÄÚ´æ DC£º32 룬RGB ¸÷Õ¼ 8 룬ÎÞ Alpha ·ÖÁ¿ */
    mem_dc = CreateMemDC (400, 100, 32, MEMDC_FLAG_HWSURFACE | MEMDC_FLAG_SRCALPHA | MEMDC_FLAG_SRCCOLORKEY,
                    0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000);

    /* Êä³öÌî³ä¾ØÐκÍÎı¾µ½ÄÚ´æ DC ÉÏ */
    SetBrushColor (mem_dc, RGB2Pixel (mem_dc, 0xFF, 0xFF, 0x00));
    FillBox (mem_dc, 0, 0, 400, 100);
    SetBkMode (mem_dc, BM_TRANSPARENT);
    SetTextColor (mem_dc, RGB2Pixel (mem_dc, 0x00, 0x00, 0xFF));
    TabbedTextOut (mem_dc, 0, 0, "Memory DC with alpha.\n"
                                 "The source DC have alpha per-surface.");

    /* Blit µ½´°¿Ú DC ÉÏ */
    start_tick = GetTickCount ();
    count = 100;
    while (count--) {
        /* ÉèÖÃÄÚ´æ DC µÄ Alpha ͨµÀ */
        SetMemDCAlpha (mem_dc, MEMDC_FLAG_SRCALPHA | MEMDC_FLAG_RLEACCEL, rand () % 256);
        BitBlt (mem_dc, 0, 0, 400, 100, hdc, rand () % 800, rand () % 800);
    }
    end_tick = GetTickCount ();
    TellSpeed (hwnd, start_tick, end_tick, "Alpha Blit", 100);

    /* Ìî³ä¾ØÐÎÇøÓò£¬ ²¢Êä³öÎÄ×Ö */
    FillBox (mem_dc, 0, 0, 400, 100);
    SetBrushColor (mem_dc, RGB2Pixel (mem_dc, 0xFF, 0x00, 0xFF));
    TabbedTextOut (mem_dc, 0, 0, "Memory DC with alpha and colorkey.\n"
                                 "The source DC have alpha per-surface.\n"
                                 "And the source DC have a colorkey, \n"
                                 "and RLE accelerated.");

    /* ÉèÖÃÄÚ´æ DC µÄ͸Ã÷ÏóËØÖµ */
    SetMemDCColorKey (mem_dc, MEMDC_FLAG_SRCCOLORKEY | MEMDC_FLAG_RLEACCEL,
                    RGB2Pixel (mem_dc, 0xFF, 0xFF, 0x00));
    /* Blit µ½´°¿Ú DC ÉÏ */
    start_tick = GetTickCount ();
    count = 100;
    while (count--) {
        BitBlt (mem_dc, 0, 0, 400, 100, hdc, rand () % 800, rand () % 800);
        CHECK_MSG;
    }
    end_tick = GetTickCount ();
    TellSpeed (hwnd, start_tick, end_tick, "Alpha and colorkey Blit", 100);

    /* ɾ³ýÄÚ´æ DC ¶ÔÏó */
    DeleteMemDC (mem_dc);

4.4 ÔöÇ¿µÄ BITMAP ²Ù×÷
    Ð嵀 GDI º¯ÊýÔöÇ¿ÁË BITMAP ½á¹¹£¬Ìí¼ÓÁ˶Ô͸Ã÷ºÍ Alpha ͨµÀµÄÖ§³Ö¡£Í¨¹ýÉèÖà bmType¡¢bmAlpha¡¢bmColorkey µÈ³ÉÔ±£¬¾Í¿ÉÒÔʹµÃ BITMAP ¶ÔÏó¾ßÓÐijЩÊôÐÔ¡£È»ºó¿ÉÒÔÀûÓà FillBoxWithBitmap/Part º¯Êý½« BITMAP ¶ÔÏó»æÖƵ½Ä³¸ö DC ÉÏ¡£Äã¿ÉÒÔ½« BITMAP ¶ÔÏó¿´³ÉÊÇÔÚϵͳÄÚ´æÖн¨Á¢µÄÄÚ´æ DC ¶ÔÏó£¬Ö»ÊDz»ÄÜÏòÕâÖÖÄÚ´æ DC ¶ÔÏó½øÐлæͼÊä³ö¡£ÏÂÃæµÄʾÀý³ÌÐò´ÓͼÏóÎļþÖÐ×°ÔØÒ»¸öλͼ¶ÔÏó£¬È»ºóÉèÖÃ͸Ã÷ºÍ Alpha ͨµÀÖµ£¬×îºóʹÓà FillBoxWithBitmap º¯ÊýÊä³öµ½´°¿Ú DC ÉÏ£º

   int tox = 800, toy = 800;
    int count;
    BITMAP bitmap;
    unsigned int start_tick, end_tick;

    if (LoadBitmap (hdc, &bitmap, "res/icon.bmp"))
        return;

    bitmap.bmType = BMP_TYPE_ALPHACHANNEL;

    /* λͼµÄ Alpha »ìºÍ */
    start_tick = GetTickCount ();
    count = 1000;
    while (count--) {
        tox = rand() % 800;
        toy = rand() % 800;

        /* ÉèÖÃËæ»ú Alpha ͨµÀÖµ */
        bitmap.bmAlpha = rand() % 256;
        /* ÏÔʾµ½´°¿Ú DC ÉÏ */
        FillBoxWithBitmap (hdc, tox, toy, 0, 0, &bitmap);
    }
    end_tick = GetTickCount ();
    TellSpeed (hwnd, start_tick, end_tick, "Alpha Blended Bitmap", 1000);

    bitmap.bmType = BMP_TYPE_ALPHACHANNEL | BMP_TYPE_COLORKEY;
    /*  È¡µÚÒ»¸öÏóËصãÖµ£¬²¢ÉèÖÃΪ͸Ã÷ÏóËØÖµ */
    bitmap.bmColorKey = GetPixelInBitmap (&bitmap, 0, 0);

    /* ͸Ã÷¼° Alpha »ìºÍ */
    start_tick = GetTickCount ();
    count = 1000;
    while (count--) {
        tox = rand() % 800;
        toy = rand() % 800;

        /*  ÉèÖÃÒ»¸öËæ»ú Alpha ͨµÀÖµ */
        bitmap.bmAlpha = rand() % 256;
        /* ÏÔʾµ½´°¿Ú DC ÉÏ */
        FillBoxWithBitmap (hdc, tox, toy, 0, 0, &bitmap);
    }
    end_tick = GetTickCount ();
    TellSpeed (hwnd, start_tick, end_tick, "Alpha Blended Transparent Bitmap", 1000);

    UnloadBitmap (&bitmap);

    ÄãÒ²¿ÉÒÔͨ¹ý CreateMemDCFromBitmap º¯Êý½«Ä³¸ö BITMAP ¶ÔÏóת»»³ÉÄÚ´æ DC ¶ÔÏ󡣸ú¯ÊýµÄÔ­ÐÍÈçÏ£¨src/gdi.h£©£º

HDC GUIAPI CreateMemDCFromBitmap (HDC hdc, BITMAP* bmp);

    ÐèҪעÒâµÄÊÇ£¬´Ó BITMAP ¶ÔÏó´´½¨µÄÄÚ´æ DC Ö±½ÓʹÓà BITMAP ¶ÔÏóÖÐµÄ bmBits ËùÖ¸ÏòµÄÄڴ棬¸ÃÄÚ´æ´æÔÚÓÚϵͳÄڴ棬¶ø²»ÊÇÏÔʾÄÚ´æÖС£

    ºÍ BITMAP Ïà¹ØµÄ MYBITMAP ½á¹¹£¬Ð嵀 GDI Ò²×öÁËһЩÔöÇ¿¡£MYBITMAP ¿ÉÒÔ¿´³ÉÊÇÉ豸Î޹صÄλͼ½á¹¹£¬ÄãÒ²¿ÉÒÔÀûÓà CreateMemDCFromMyBitmap º¯Êý½«Ò»¸ö MYBITMAP ¶ÔÏóת»»³ÉÄÚ´æ DC¡£¸Ãº¯ÊýµÄÔ­ÐÍÈçÏ£¨src/gdi.h£©£º

    HDC GUIAPI CreateMemDCFromMyBitmap (HDC hdc, MYBITMAP* mybmp);

    ÐèҪעÒâµÄÊÇ£¬Ðí¶à GAL ÒýÇæ²»ÄܶÔϵͳÄÚ´æµ½ÏÔʾÄÚ´æµÄ BitBlt ²Ù×÷ÌṩӲ¼þ¼ÓËÙ£¬ËùÒÔ£¬FillBoxWithBitmap º¯Êý£¬ÒÔ¼°´Ó BITMAP ¶ÔÏó»òÕß MYBITMAP ¶ÔÏó´´½¨µÄÄÚ´æ DC ÎÞ·¨Í¨¹ýÓ²¼þ¼ÓËÙ¹¦ÄÜ¿ìËÙ BitBlt µ½ÆäËû DC ÉÏ¡£Èç¹ûÏ£Íû´ïµ½ÕâÑùµÄЧ¹û£¬¿ÉÒÔͨ¹ýÔ¤ÏÈ´´½¨µÄ½¨Á¢ÓÚÏÔʾÄÚ´æÖÐµÄ DC ½øÐпìËÙµÄ BitBlt ÔËËã¡£

4.5 Ð嵀 GDI »æͼº¯Êý
    ³ýÁ˹âÕ¤²Ù×÷ÒâÍ⣬»¹Ìí¼ÓÁËһЩÓÐÓÃµÄ GDI »æͼº¯Êý£¬°üÀ¨ FillRect¡¢FillCircle µÈµÈ£¬ÎÒÃǽ«ÔÚ½ÓÏÂÀ´µÄ¿ª·¢ÖУ¬½«¼ÌÐøÌí¼ÓÖîÈçÍÖÔ²¡¢Ô²»¡¡¢Èý´ÎÑùÌõÇúÏß¡¢¶à±ßÐÎÌî³äµÈ¸ß¼¶»æͼº¯Êý¡£Ä¿Ç°ÐÂÔöµÄ GDI º¯ÊýÓУº

void GUIAPI FillRect (HDC hdc, int x, int y, int w, int h);
void GUIAPI FillCircle (HDC hdc, int sx, int sy, int r);

BOOL GUIAPI ScaleBitmap (BITMAP* dst, const BITMAP* src);

BOOL GUIAPI GetBitmapFromDC (HDC hdc, int x, int y, int w, int h, BITMAP* bmp);

gal_pixel GUIAPI GetPixelInBitmap (const BITMAP* bmp, int x, int y);
BOOL GUIAPI SetPixelInBitmap (const BITMAP* bmp, int x, int y, gal_pixel pixel);

FillRect º¯ÊýÌî³äÖ¸¶¨¾ØÐΣ¬Êܵ±Ç°¹âÕ¤²Ù×÷Ó°Ïì¡£
FillCircle º¯ÊýÌî³äÖ¸¶¨µÄÔ²£¬Êܵ±Ç°¹âÕ¤²Ù×÷Ó°Ïì¡£
ScaleBitmap º¯Êý½«Ô´ BITMAP ¶ÔÏó½øÐÐÉìËõ´¦Àí¡£
GetBitmapFromDC º¯Êý½«Ö¸¶¨¾ØÐη¶Î§ÄÚµÄÏóËظ´ÖƵ½ BITMAP ¶ÔÏóÖС£
GetPixelInBitmap º¯Êý»ñµÃ BITMAP ¶ÔÏóÖÐÖ¸¶¨Î»ÖõÄÏóËØÖµ¡£
SetPixelInBitmap º¯ÊýÉèÖà BITMAP ¶ÔÏóÖÐÖ¸¶¨Î»ÖõÄÏóËØÖµ¡£
5 ÆäËû
    ¾¡¹ÜÔÚ 1.1.0Pre4 ÒÔ¼°Æäºó°æ±¾¶Ô MiniGUI µÄ GAL ºÍ GDI ½øÐÐÁË´ó¹æÄ£µÄ¸ÄÔ죬µ«ÔÚа汾ÖÐÈÔÈ»¿ÉÒÔÀûÓÃÀ쵀 GAL ºÍ GDI ½Ó¿Ú£¬´Ó¶øÌṩ¶ÔµÍ¶ËÏÔʾÉ豸µÄÖ§³Ö¡£ÐèҪעÒâµÄÊÇ£¬ËäȻРGDI API µ±ÖеÄÐí¶à½á¹¹ºÍº¯Êý¾ßÓÐÏàͬµÄÃû³Æ£¬µ«Ä³Ð©º¯ÊýÒѾ­±»ÖØж¨Òå¡£ËùÒÔ£¬ÔÚ±àдӦÓóÌÐòµÄʱºò£¬ÒªÌرð×¢ÒâÕâÒ»µã¡£±ÈÈ磺Ð嵀 mde ÑÝʾ³ÌÐòµ±ÖУ¬¾ÍÀûÓÃÁËÔÚ <minigui/config.h> Öж¨ÒåµÄ _USE_NEWGAL ºêÀ´ÅжÏÊÇ·ñʹÓÃÐ嵀 GAL ºÍ GDI º¯Êý£¬ÈçÏÂËùʾ£º

#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>

......
#ifdef _USE_NEWGAL
    SetRasterOperation (hdc, ROP_XOR);
    FillRect (hdc, 0, 0, 200, 200);
#else
    /* Not implemented */
#endif
......


6 С½á
    ±¾ÎÄÖصã½éÉÜÁËÔÚ MiniGUI 1.1.0 °æ±¾¿ª·¢¹ý³ÌÖÐÐÂÔöµÄ GAL¡¢GDI ¹¦Äܺͽӿڡ£Ð嵀 GAL ºÍ GDIÖصãÕë¶Ô¸ß¶ËͼÐÎÓ¦ÓýøÐÐÁËÓÅ»¯ºÍ¹¦ÄÜÔöÇ¿£¬ÆäÖаüÀ¨Í¸Ã÷´¦Àí¡¢Alpha »ìºÍµÈ¸ß¼¶ÌØÐÔ£¬²¢ÇÒÄܹ»¶ÔÓ²¼þ¼ÓËÙ¹¦ÄÜÌṩÁ¼ºÃÖ§³Ö¡£±¾ÎÄ·Ö±ð¾Í GAL ºÍ GDI µÄ¹Øϵ¡¢GAL µÄ¹¦ÄÜÌØÐÔ¡¢GDI µÄÔöÇ¿½Ó¿ÚµÈ·½Ãæ½ÏΪȫÃæµØ½éÉÜÁËÐ嵀 GAL ºÍ GDI ½Ó¿Ú¡£Ï£ÍûÄܹ»¶Ô³ÌÐò¿ª·¢ÓÐËù°ïÖú¡£

[Ŀ¼]


MiniGUI 1.1.0ÒýÈëµÄÐÂGDI¹¦Äܺͺ¯Êý£¨2£©

1 ÒýÑÔ
    ÎÒÃÇÔÚ±¾ÏµÁÐÖ÷ÌâÎåÖÐÔø¾­ÏêϸÃèÊöÁËÔÚ MiniGUI 1.1.0 °æ±¾¿ª·¢¹ý³ÌÖÐÌí¼ÓµÄРGDI ¹¦Äܺͺ¯Êý¡£ÕâЩ½Ó¿ÚÊ״γöÏÖÔÚ°æ±¾ 1.1.0Pre4 µ±ÖС£Ä¿Ç° MiniGUI 1.1.0Pre7 °æ±¾ÒѾ­·¢²¼£¬¸Ã°æ±¾ÖеÄРGDI ½Ó¿ÚÇ÷ÓÚÎȶ¨£¬Ïà¶Ô 1.1.0Pre4 °æ±¾¶øÑÔ£¬ÓÖÐÂÔöÁËÈô¸É¸ß¼¶Í¼Ðνӿڡ£ÕâЩ½Ó¿ÚÉæ¼°µ½Ö±ÏߺÍÇúÏßÉú³ÉÆ÷¡¢¸´ÔÓÇúÏߵĻæÖÆ¡¢·â±ÕÇúÏßÌî³ä¡¢¸´ÔÓÇøÓòµÄ´´½¨¡¢Ö±½ÓµÄÏÔʾ»º³åÇø·ÃÎÊ¡¢YUV ¸²¸ÇºÍ Gamma УÕýµÈµÈ¡£±¾ÎĽ«¾ÍÕâЩÖ÷ÌâÏêϸÃèÊö¸÷¸ö½Ó¿ÚµÄÓ÷¨¡£

2 ÇúÏߺÍÌî³äÉú³ÉÆ÷
    ÔÚÒ»°ãµÄͼÐÎϵͳÖУ¬Í¨³£¸øÓû§ÌṩÈô¸ÉÓÃÓÚ½øÐÐÖ±Ïß»òÕ߸´ÔÓÇúÏߣ¬±ÈÈçÔ²»¡¡¢ÍÖÔ²ºÍÑùÌõÇúÏߵĻæͼº¯Êý¡£Óû§¿ÉÒÔͨ¹ýÕâЩº¯Êý½øÐлæͼ£¬µ«²»ÄÜÀûÓÃÕâЩϵͳÖÐÒÑÓеÄÇúÏßÉú³ÉËã·¨Íê³ÉÆäËûµÄ¹¤×÷¡£ÔÚ MiniGUI Ð嵀 GDI ½Ó¿ÚÉè¼Æµ±ÖУ¬ÎÒÃDzÉÓÃÁËÒ»ÖÖÌØÊâµÄÉè¼Æ·½·¨À´ÊµÏÖÇúÏߺͷâ±ÕÇúÏßµÄÌî³ä£¬ÕâÖÖ·½·¨·Ç³£Áé»î£¬¶øÇÒ¸øÓû§ÌṩÁËÖ±½ÓʹÓÃϵͳÄÚ²¿Ëã·¨µÄ»ú»á£º

    1£©ÏµÍ³Öж¨ÒåÁËÈô¸ÉÓÃÀ´Éú³ÉÖ±ÏߺÍÇúÏߵĺ¯Êý£¬ÎÒÃdzÆ֮Ϊ"ÇúÏßÉú³ÉÆ÷"£»
    2£©Óû§ÔÚµ÷ÓÃÉú³ÉÆ÷֮ǰ£¬ÐèÒª¶¨ÒåÒ»¸ö»Øµ÷º¯Êý£¬²¢½«º¯ÊýµØÖ·´«µÝ¸øÇúÏßÉú³ÉÆ÷£¬ÇúÏßÉú³ÉÆ÷ÔÚÉú³ÉÁËÒ»¸öÇúÏßÉϵĵã»òÕß·â±ÕÇúÏßÖеÄÒ»ÌõˮƽÌî³äÏßʱ£¬½«µ÷ÓÃÕâ¸ö»Øµ÷º¯Êý¡£
    3£©Óû§¿ÉÒÔÔڻص÷º¯Êýµ±ÖÐÍê³ÉÕë¶Ôеĵã»òÕßеÄˮƽÌî³äÏߵIJÙ×÷¡£¶Ô MiniGUI »æͼº¯ÊýÀ´Ëµ£¬¾ÍÊÇÍê³É»æͼ¹¤×÷¡£
    4£©ÒòΪ»Øµ÷º¯ÊýÔÚÉú³ÉÆ÷µÄÔËÐйý³ÌÖв»¶Ïµ÷Óã¬ÎªÁ˱£³ÖÒ»ÖµÄÉÏÏÂÎÄ»·¾³£¬ÏµÍ³ÔÊÐíÓû§ÔÚµ÷ÓÃÇúÏßÉú³ÉÆ÷ʱ´«µÝÒ»¸ö±íʾÉÏÏÂÎĵÄÖ¸Õ룬Éú³ÉÆ÷½«°Ñ¸ÃÖ¸Õë´«µÝ¸ø»Øµ÷º¯Êý¡£

    ÏÂÃ潫·ÖС½Ú½²ÊöÄ¿Ç°µÄ MiniGUI °æ±¾ËùÌṩµÄÇúÏߺÍÌî³äÉú³ÉÆ÷¡£

2.1 Ö±Ïß¼ôÇÐÆ÷ºÍÖ±ÏßÉú³ÉÆ÷

Ö±Ïß¼ôÇÐÆ÷ºÍÉú³ÉÆ÷µÄÔ­ÐÍÈçÏ£º

/* Line clipper */
BOOL GUIAPI LineClipper (const RECT* cliprc, int *_x0, int *_y0, int *_x1, int *_y1);

/* Line generators */
typedef void (* CB_LINE) (void* context, int stepx, int stepy);
void GUIAPI LineGenerator (void* context, int x1, int y1, int x2, int y2, CB_LINE cb);


    Ö±Ïß¼ôÇÐÆ÷²¢²»ÊÇÉú³ÉÆ÷£¬ËüÓÃÓÚ¶Ô¸ø¶¨µÄÖ±Ïß½øÐмôÇвÙ×÷¡£cliprc ÊǸø¶¨µÄÖ±Ïߣ¬¶ø _x0¡¢_y0¡¢_x1 ºÍ _y1 ´«µÝÒª¼ôÇеÄÖ±ÏßÆðʼ¶Ëµã£¬²¢Í¨¹ýÕâЩָÕë·µ»Ø¼ôÇÐÖ®ºóµÄÖ±ÏßÆðʼ¶Ëµã¡£MiniGUI ÄÚ²¿Ê¹ÓÃÁË Cohen-Sutherland Ëã·¨¡£

LineGenerator ÊDzÉÓà Breshenham Ëã·¨µÄÉú³ÉÆ÷¡£¸ÃÉú³ÉÆ÷´Ó¸ø¶¨Ö±ÏßµÄÆðʼ¶Ëµã¿ªÊ¼£¬Ã¿Éú³ÉÒ»¸öµãµ÷ÓÃÒ»´Î cb »Øµ÷º¯Êý£¬²¢´«µÝÉÏÏÂÎÄ context¡¢ÒÔ¼°ÐµĵãÏà¶ÔÓÚÉÏÒ»¸öµãµÄ²½½øÖµ»òÕß²îÁ¿¡£±ÈÈ磬´«µÝ stepx =1£¬stepy = 0 ±íʾеĵã±ÈÉÏÒ»¸öµãÔÚ X ÖáÉÏÇ°½øÒ»²½£¬¶øÔÚ Y ÖáÉϱ£³Ö²»±ä¡£»Øµ÷º¯Êý¿ÉÒÔÔÚ²½½øÖµ»ù´¡ÉÏʵÏÖijÖ̶ֳÈÉϵÄÓÅ»¯¡£

2.2 Ô²Éú³ÉÆ÷

MiniGUI ¶¨ÒåµÄÔ²Éú³ÉÆ÷Ô­ÐÍÈçÏ£º

/* Circle generator */
typedef void (* CB_CIRCLE) (void* context, int x1, int x2, int y);
void GUIAPI CircleGenerator (void* context, int sx, int sy, int r, CB_CIRCLE cb);

    Ê×ÏÈÒªÖ¸¶¨Ô²ÐÄ×ø±êÒÔ¼°°ë¾¶£¬²¢´«µÝÉÏÏÂÎÄÐÅÏ¢ÒÔ¼°»Øµ÷º¯Êý£¬Ã¿Éú³ÉÒ»¸öµã£¬Éú³ÉÆ÷½«µ÷ÓÃÒ»´Î cb »Øµ÷º¯Êý£¬²¢´«µÝÈý¸öÖµ£ºx1¡¢x2 ºÍ y¡£ÕâÈý¸öֵʵ¼Ê±íʾÁËÔ²ÉϵÄÁ½¸öµã£º(x1, y) ºÍ (x2, y)¡£ÒòΪԲµÄ¶Ô³ÆÐÔ£¬Éú³ÉÆ÷Ö»Òª¼ÆËãÔ²ÉϵÄËÄ·ÖÖ®Ò»Ô²»¡µã¼´¿ÉµÃ³öÔ²ÉÏËùÓеĵ㡣

2.3 ÍÖÔ²Éú³ÉÆ÷

    ÍÖÔ²Éú³ÉÆ÷ºÍÔ²Éú³ÉÆ÷ÀàËÆ£¬Ô­ÐÍÈçÏ£º

/* Ellipse generator */
typedef void (* CB_ELLIPSE) (void* context, int x1, int x2, int y);
void GUIAPI EllipseGenerator (void* context, int sx, int sy, int rx, int ry, CB_ELLIPSE cb);

    Ê×ÏÈÒªÖ¸¶¨ÍÖÔ²ÐÄ×ø±êÒÔ¼° X ÖáºÍ Y Öá°ë¾¶£¬²¢´«µÝÉÏÏÂÎÄÐÅÏ¢ÒÔ¼°»Øµ÷º¯Êý£¬Ã¿Éú³ÉÒ»¸öµã£¬Éú³ÉÆ÷½«µ÷ÓÃÒ»´Î cb »Øµ÷º¯Êý£¬²¢´«µÝÈý¸öÖµ£ºx1¡¢x2 ºÍ y¡£ÕâÈý¸öֵʵ¼Ê±íʾÁËÍÖÔ²ÉϵÄÁ½¸öµã£º(x1, y) ºÍ (x2, y)¡£ÒòΪÍÖÔ²µÄ¶Ô³ÆÐÔ£¬Éú³ÉÆ÷Ö»Òª¼ÆËãÍÖÔ²ÉϵĶþ·ÖÖ®Ò»Ô²»¡µã¼´¿ÉµÃ³öÍÖÔ²ÉÏËùÓеĵ㡣

2.4 Ô²»¡Éú³ÉÆ÷

MiniGUI ¶¨ÒåµÄÔ²»¡Éú³ÉÆ÷ÈçÏÂËùʾ£º

/* Arc generator */
typedef void (* CB_ARC) (void* context, int x, int y);
void GUIAPI ArcGenerator (void* context, int sx, int sy, int r, fixed ang1, fixed ang2, CB_ARC cb);

    Ê×ÏÈÒªÖ¸¶¨Ô²»¡µÄÔ²ÐÄ¡¢°ë¾¶¡¢Æðʼ»¡¶ÈºÍÖÕÖ¹»¡¶È¡£ÐèҪעÒâµÄÊÇ£¬Æðʼ»¡¶ÈºÍÖÕÖ¹»¡¶ÈÊDzÉÓö¨µãÊý±íʾµÄ£¬¶ø²»ÊǸ¡µãÊý£¬²¢ÇÒÊÇ»¡¶È¶ø²»ÊǽǶȡ£È»ºó´«µÝ cb »Øµ÷º¯Êý¡£Ã¿Éú³ÉÒ»¸öÔ²»¡Éϵĵ㣬¸Ãº¯Êý½«µ÷Óûص÷º¯Êý£¬²¢´«µÝеãµÄ×ø±êÖµ (x, y)¡£

    Óйض¨µãÊýµÄÐÅÏ¢£¬Çë²ÎÔı¾ÏµÁÐ"Ö÷ÌâÁù£ºMiniGUI ÌṩµÄ·Ç GUI/GDI ½Ó¿Ú"Ò»ÎÄ¡£

2.5 ´¹Ö±µ¥µ÷¶à±ßÐÎÉú³ÉÆ÷

    ͨ³£¶øÑÔ£¬¶à±ßÐÎÓÐ͹¶à±ßÐκͰ¼¶à±ßÐÎÖ®·Ö¡£ÕâÀïµÄ´¹Ö±µ¥µ÷¶à±ßÐΣ¬ÊÇΪÁËÓÅ»¯¶à±ßÐÎÌî³äËã·¨¶øÕë¶Ô¼ÆËã»úͼÐÎÌصã¶øÌá³öµÄÒ»ÖÖÌØÊâ¶à±ßÐΣ¬ÕâÖÖ¶à±ßÐεĶ¨ÒåÈçÏ£º

´¹Ö±µ¥µ÷¶à±ßÐÎÊÇÖ¸£¬¶à±ßÐεıߺͼÆËã»úÆÁÄ»ÉϵÄËùÓÐˮƽɨÃèÏߣ¬Ö»ÄÜÓÐÒ»¸ö»òÕßÁ½¸ö½»µã£¬²»»áÓиü¶à½»µã¡£

ͼ 1 ¸ø³öÁË͹¶à±ßÐΡ¢°¼¶à±ßÐκʹ¹Ö±µ¥µ÷¶à±ßÐεļ¸¸öʾÀý¡£

    ÐèҪעÒâµÄÊÇ£¬Í¹¶à±ßÐÎÒ»¶¨ÊÇ´¹Ö±µ¥µ÷¶à±ßÐΣ¬µ«´¹Ö±µ¥µ÷¶à±ßÐοÉÒÔÊÇ°¼¶à±ßÐΡ£ÏÔÈ»£¬ÆÕͨµÄ¶à±ßÐÎÌî³äËã·¨ÐèÒªÅж϶à±ßÐαߺÍÿÌõÆÁĻɨÃèÏßÖ®¼äµÄ½»µã¸öÊý£¬¶ø´¹Ö±µ¥µ÷¶à±ßÐÎÔò¿ÉÒÔÃâÈ¥ÕâÒ»Åжϣ¬ËùÒÔ¿ÉÒÔ´ó´óÌá¸ß¶à±ßÐÎÌî³äµÄËٶȡ£

MiniGUI Ëù¶¨ÒåµÄ´¹Ö±µ¥µ÷¶à±ßÐÎÏà¹Øº¯ÊýÔ­ÐÍÈçÏ£º

/* To determine whether the specified Polygon is Monotone Vertical Polygon */
BOOL GUIAPI PolygonIsMonotoneVertical (const POINT* pts, int vertices);

/* Monotone vertical polygon generator */
typedef void (* CB_POLYGON) (void* context, int x1, int x2, int y);
BOOL GUIAPI MonotoneVerticalPolygonGenerator (void* context, const POINT* pts, int vertices, CB_POLYGON cb);

    PolygonIsMonotoneVertical ÓÃÀ´Åжϸø¶¨µÄ¶à±ßÐÎÊÇ·ñÊÇ´¹Ö±µ¥µ÷¶à±ßÐΣ¬¶ø MonotoneVerticalPolygonGenerator º¯ÊýÊÇ´¹Ö±¶à±ßÐÎÉú³ÉÆ÷¡£ÔÚ MiniGUI µ±ÖУ¬¶à±ßÐÎÊÇÓÉ×é³É¶à±ßÐεĶ¥µãÀ´±íʾµÄ¡£pts ±íʾ¶¥µãÊý×飬¶ø vertices ±íʾ¶¥µã¸öÊý¡£Éú³ÉÆ÷Éú³ÉµÄʵ¼ÊÊÇÌî³ä¶à±ßÐεÄÿһÌõˮƽÏߣ¬¶ËµãΪ (x1, y) ºÍ (x2, y)¡£

2.6 Ò»°ã¾ØÐÎÉú³ÉÆ÷

    MiniGUI »¹ÌṩÁËÒ»°ãµÄ¾ØÐÎÉú³ÉÆ÷£¬¸ÃÉú³ÉÆ÷¿ÉÒÔ´¦Àí͹¶à±ßÐΣ¬Ò²¿ÉÒÔ´¦Àí°¼¶à±ßÐΡ£Ô­ÐÍÈçÏ£º

/* General polygon generator */
typedef void (* CB_POLYGON) (void* context, int x1, int x2, int y);
BOOL GUIAPI PolygonGenerator (void* context, const POINT* pts, int vertices, CB_POLYGON cb);

    ºÍ´¹Ö±µ¥µ÷¶à±ßÐÎÉú³ÉÆ÷Ò»Ñù£¬¸Ãº¯ÊýÉú³ÉµÄÊÇÌî³ä¶à±ßÐεÄÿһÌõˮƽɨÃèÏߣºx1 ÊÇˮƽÏßµÄÆðʼX×ø±ê£»x2 ÊÇˮƽÏßµÄÖÕÖ¹ X ×ø±ê£»y ÊÇˮƽÏßµÄ Y ×ø±êÖµ¡£

2.7 Ìî×¢Éú³ÉÆ÷

    Ìî×¢£¨flood filling£©Éú³ÉÆ÷±È½Ï¸´ÔÓ¡£Õâ¸öº¯ÊýÔÚ MiniGUI ÄÚ²¿ÓÃÓÚ FloodFill º¯Êý¡£ÎÒÃÇÖªµÀ£¬FloodFill º¯Êý´Ó¸ø¶¨µÄÆðʼλÖÿªÊ¼£¬ÒÔ¸ø¶¨µÄÑÕÉ«ÏòËÄÃæ°Ë·½Ìî³äij¸öÇøÓò£¨ÏñˮһÑùÂûÑÓ£¬Òò´Ë½Ð Flood Filling£©£¬Ò»Ö±µ½Óöµ½Óë¸ø¶¨ÆðʼλÖõÄÏóËØÖµ²»Í¬µÄµãΪֹ¡£Òò´Ë£¬ÔÚÕâÒ»¹ý³ÌÖУ¬ÎÒÃÇÐèÒªÁ½¸ö»Øµ÷º¯Êý£¬Ò»¸ö»Øµ÷º¯ÊýÓÃÀ´ÅжÏÂûÑÓ¹ý³ÌÖÐÓöµ½µÄµãµÄÏóËØÖµÊÇ·ñºÍÆðʼµãÏàͬ£¬ÁíÍâÒ»¸ö»Øµ÷º¯ÊýÓÃÀ´Éú³ÉÌî³ä¸ÃÇøÓòµÄˮƽɨÃèÏß¡£ÔÚ½øÐлæͼʱ£¬¸Ãº¯Êý±È½ÏµÄÊÇÏóËØÖµ£¬µ«Êµ¼ÊÉÏ£¬¸Ãº¯ÊýÒ²¿ÉÒԱȽÏÈκÎÆäËûÖµ£¬´Ó¶øÍê³ÉÌØÓеÄÂûÑÓ¶¯×÷¡£Õâ¾ÍÊǽ«Ìî×¢Éú³ÉÆ÷µ¥¶À³öÀ´µÄ³õÖÔ¡£MiniGUI Èç϶¨ÒåÌî×¢Éú³ÉÆ÷£º

/* General Flood Filling generator */
typedef BOOL (* CB_EQUAL_PIXEL) (void* context, int x, int y);
typedef void (* CB_FLOOD_FILL) (void* context, int x1, int x2, int y);
BOOL GUIAPI FloodFillGenerator (void* context, const RECT* src_rc, int x, int y,
                CB_EQUAL_PIXEL cb_equal_pixel, CB_FLOOD_FILL cb_flood_fill);

    cb_equal_pixel ±»µ÷Óã¬ÒÔ±ãÅжÏÄ¿±êµãµÄÏóËØÖµÊÇ·ñºÍÆðʼµãÒ»Ñù£¬ÆðʼµãµÄÏóËØÖµ¿ÉÒÔͨ¹ý context À´´«µÝ¡£cb_flood_fill º¯ÊýÓÃÀ´Ìî³äÒ»ÌõɨÃèÏߣ¬´«µÝµÄÊÇˮƽɨÃèÏߵĶ˵㣬¼´(x1, y) ºÍ (x2, y)¡£

2.8 ÇúÏߺÍÌî³äÉú³ÉÆ÷µÄÓ÷¨

    ÇúÏߺÍÌî³äÉú³ÉÆ÷µÄÓ÷¨·Ç³£¼òµ¥¡£ÎªÁ˶ÔÇúÏߺÍÌî³äÉú³ÉÆ÷Óиö¸üºÃµÄÁ˽⣬ÎÒÃÇÊ×ÏÈ¿´ MiniGUI ÄÚ²¿ÊÇÈçºÎʹÓÃÇúÏߺÍÌî³äÉú³ÉÆ÷µÄ¡£

ÏÂÃæµÄ³ÌÐò¶ÎÀ´×Ô MiniGUI µÄ FloodFill º¯Êý£¨src/newgdi/flood.c£©£º

static void _flood_fill_draw_hline (void* context, int x1, int x2, int y)
{
    PDC pdc = (PDC)context;
    RECT rcOutput = {MIN (x1, x2), y, MAX (x1, x2) + 1, y + 1};

    ENTER_DRAWING (pdc, rcOutput);
    _dc_draw_hline_clip (context, x1, x2, y);
    LEAVE_DRAWING (pdc, rcOutput);
}

static BOOL equal_pixel (void* context, int x, int y)
{
    gal_pixel pixel = _dc_get_pixel_cursor ((PDC)context, x, y);

    return ((PDC)context)->skip_pixel == pixel;
}

/* FloodFill
* Fills an enclosed area (starting at point x, y).
*/
BOOL GUIAPI FloodFill (HDC hdc, int x, int y)
{
    PDC pdc;
    BOOL ret = TRUE;

    if (!(pdc = check_ecrgn (hdc)))
        return TRUE;

    /* hide cursor tempororily */
    ShowCursor (FALSE);

    coor_LP2SP (pdc, &x, &y);

    pdc->cur_pixel = pdc->brushcolor;
    pdc->cur_ban = NULL;

    pdc->skip_pixel = _dc_get_pixel_cursor (pdc, x, y);

    /* does the start point have a equal value? */
    if (pdc->skip_pixel == pdc->brushcolor)
        goto equal_pixel;

    ret = FloodFillGenerator (pdc, &pdc->DevRC, x, y, equal_pixel, _flood_fill_draw_hline);

equal_pixel:
    UNLOCK_GCRINFO (pdc);

    /* Show cursor */
    ShowCursor (TRUE);

    return ret;
}

    ¸Ãº¯ÊýÔÚ¾­¹ýһЩ±ØÒªµÄ³õʼ»¯¹¤×÷Ö®ºó£¬µ÷Óà FloodFillGenerator º¯Êý£¬²¢´«µÝÁËÉÏÏÂÎÄ pdc £¨pdc ÊÇ MiniGUI ÄÚ²¿±íʾ DC µÄÊý¾Ý½á¹¹£©ºÍÁ½¸ö»Øµ÷º¯ÊýµØÖ·£ºequal_pixel ºÍ _flood_fill_draw_hline º¯Êý¡£ÔÚÕâ֮ǰ£¬¸Ãº¯Êý»ñµÃÁËÆðʼµãµÄÏóËØÖµ£¬²¢±£´æÔÚÁËpdc->skip_pixel µ±ÖС£equal_pixel º¯Êý»ñµÃ¸ø¶¨µãµÄÏóËØÖµ£¬È»ºó·µ»ØÓë pdc->skip_pixel Ïà±È½ÏÖ®ºóµÄÖµ£»_flood_fill_draw_hline º¯Êýµ÷ÓÃÄÚ²¿º¯Êý½øÐÐˮƽÏߵĻæÖÆ¡£

    ¶ÁÕß¿ÉÒÔ¿´µ½£¬ÕâÖÖ¼òµ¥µÄÉú³ÉÆ÷ʵÏÖ·½Ê½£¬Äܹ»´ó´ó½µµÍ´úÂ븴ÔӶȣ¬Ìá¸ß´úÂëµÄÖØÓÃÄÜÁ¦¡£ÓÐÐËȤµÄ¶ÁÕß¿ÉÒÔ±È½Ï MiniGUI ÐÂÀÏ GDI ½Ó¿ÚµÄ LineTo º¯ÊýʵÏÖ£¬ÏàÐÅÄܹ»µÃ³öÒ»ÑùµÄ½áÂÛ¡£

    µ±È»Éè¼ÆÉú³ÉÆ÷µÄÄ¿µÄÖ÷Òª»¹ÊÇΪ·½±ãÓû§Ê¹ÓᣱÈÈ磬Äã¿ÉÒÔÀûÓà MiniGUI ÄÚ²¿µÄÇúÏßÉú³ÉÆ÷Íê³É×Ô¼ºµÄ¹¤×÷¡£ÏÂÃæµÄʾÀý¼Ù¶¨ÄãʹÓÃÔ²Éú³ÉÆ÷»æÖÆÒ»¸öÏß¿íΪ 4 ÏóËصÄÔ²£º

static void draw_circle_pixel (void* context, int x1, int x2, int y)
{
    HDC hdc = (HDC) context;

    /* ÒÔÔ²ÉϵÄÿ¸öµãΪԲÐÄ£¬Ìî³ä°ë¾¶Îª 2 µÄÔ²¡£*/
    FillCircle (hdc, x1, y, 2);
    FillCircle (hdc, x2, y, 2);
}

void DrawMyCircle (HDC hdc, int x, int y, int r, gal_pixel pixel)
{
    gal_pixel old_brush;

    old_bursh = SetBrushColor (hdc, pixle);

    /* µ÷ÓÃÔ²Éú³ÉÆ÷ */
    CircleGenerator ((void*)hdc, x, y, r, draw_circle_pixel);

    /* »Ö¸´¾ÉµÄ»­Ë¢ÑÕÉ« */
    SetBrushColor (hdc, old_brush);
}


    ´ÓÉÏÃæµÄÀý×Ó¿ÉÒÔ¿´³ö£¬ÇúÏߺÍÌî³äÉú³ÉÆ÷µÄÓ÷¨¼«Æä¼òµ¥£¬¶øÇҽṹÇåÎúÃ÷ÁË¡£¶ÁÕßÔÚ×Ô¼ºµÄ¿ª·¢¹ý³ÌÖУ¬Ò²¿ÉÒÔѧϰÕâÖÖ·½·¨¡£

3 »æÖƸ´ÔÓÇúÏß

»ùÓÚ 2 ÖÐÃèÊöµÄÇúÏßÉú³ÉÆ÷£¬MiniGUI ÌṩÁËÈçÏ»ù±¾µÄÇúÏß»æÖƺ¯Êý£º

void GUIAPI MoveTo (HDC hdc, int x, int y);
void GUIAPI LineTo (HDC hdc, int x, int y);
void GUIAPI Rectangle (HDC hdc, int x0, int y0, int x1, int y1);
void GUIAPI PollyLineTo (HDC hdc, const POINT* pts, int vertices);
void GUIAPI SplineTo (HDC hdc, const POINT* pts);
void GUIAPI Circle (HDC hdc, int sx, int sy, int r);
void GUIAPI Ellipse (HDC hdc, int sx, int sy, int rx, int ry);
void GUIAPI Arc (HDC hdc, int sx, int sy, int r, fixed ang1, fixed ang2);

MoveTo ½«µ±Ç°»­±ÊµÄÆðʼµãÒƶ¯µ½¸ø¶¨µã£¨x, y£©£¬ÒÔÂß¼­×ø±êÖ¸¶¨¡£
LineTo ´Óµ±Ç°»­±Êµã»­Ö±Ïßµ½¸ø¶¨µã£¨x, y£©£¬ÒÔÂß¼­×ø±êÖ¸¶¨¡£
Rectangle º¯Êý»­¶¥µãΪ£¨x0, y0£©ºÍ£¨x1, y0£©µÄ¾ØÐΡ£
PollyLineTo º¯ÊýÀûÓà LineTo º¯Êý»­ÕÛÏß¡£pts Ö¸¶¨ÁËÕÛÏߵĸ÷¸ö¶Ëµã£¬vertices Ö¸¶¨ÁËÕÛÏ߶˵ã¸öÊý¡£
SplineTo º¯ÊýÀûÓà LineTo º¯Êý»­Èý´ÎÑùÌõÇúÏß¡£ÐèҪעÒâµÄÊÇ£¬±ØÐë´«µÝËĸöµã²ÅÄÜΩһȷ¶¨Ò»ÌõÑùÌõÇúÏߣ¬Ò²¾ÍÊÇ˵£¬pts ÊÇÒ»¸öÖ¸Ïò°üº¬ 4 ¸ö POINT ½á¹¹Êý×éµÄÖ¸Õë¡£
Circle º¯Êý»æÖÆÔ²£¬Ô²ÐÄΪ (sx, sy)£¬°ë¾¶Îª r£¬ÒÔÂß¼­×ø±êÖ¸¶¨¡£
Ellipse º¯Êý»æÖÆÍÖÔ²£¬ÍÖÔ²ÐÄΪ£¨sx, sy£©£¬X Öá°ë¾¶Îª rx£¬Y Öá°ë¾¶Îª ry¡£
Arc º¯Êý»æÖÆÔ²»¡£¬£¨sx, sy£© Ö¸¶¨ÁËÔ²ÐÄ£¬r Ö¸¶¨°ë¾¶£¬ang1 ºÍ ang2 Ö¸¶¨Ô²»¡µÄÆðʼ»¡¶ÈºÍÖÕÖ¹»¡¶È¡£ÐèҪעÒâµÄÊÇ£¬ang1 ºÍ ang2 ÊÇÒÔ¶¨µãÊýÐÎʽָ¶¨µÄ¡£
×÷ΪʾÀý£¬ÎÒÃÇ¿´ Circle ºÍ Ellipse º¯ÊýµÄÓ÷¨¡£¼Ù¶¨¸ø¶¨ÁËÁ½¸öµã£¬pts[0] ºÍ pts[1]£¬ÆäÖÐ pts[0] ÊÇÔ²ÐÄ»òÕßÍÖÔ²ÐÄ£¬¶ø pts[1] ÊÇÔ²»òÕßÍÖÔ²ÍâÇоØÐεÄÒ»¸ö¶¥µã¡£ÏÂÃæµÄ³ÌÐò¶Î»æÖÆÓÉÕâÁ½¸öµã¸ø¶¨µÄÔ²»òÕßÍÖÔ²£º

           int rx = ABS (pts[1].x - pts[0].x);
            int ry = ABS (pts[1].y - pts[0].y);

            if (rx == ry)
                Circle (hdc, pts[0].x, pts[0].y, rx);
            else
                Ellipse (hdc, pts[0].x, pts[0].y, rx, ry);

4 ·â±ÕÇúÏßÌî³ä
    MiniGUI Ä¿Ç°ÌṩÁËÈçϵķâ±ÕÇúÏßÌî³äº¯Êý£º

void GUIAPI FillBox (HDC hdc, int x, int y, int w, int h);
void GUIAPI FillCircle (HDC hdc, int sx, int sy, int r);
void GUIAPI FillEllipse (HDC hdc, int sx, int sy, int rx, int ry);
void GUIAPI FillSector (HDC hdc, int sx, int sy, int r, int ang1, int ang2);
BOOL GUIAPI FillPolygon (HDC hdc, const POINT* pts, int vertices);
BOOL GUIAPI FloodFill (HDC hdc, int x, int y);

FillBox º¯ÊýÌî³äÖ¸¶¨µÄ¾ØÐΡ£¸Ã¾ØÐÎ×óÉϽǶ¥µãΪ£¨x, y£©£¬¿í¶ÈΪ w£¬¸ß¶ÈΪ h£¬ÒÔÂß¼­×ø±êÖ¸¶¨¡£
FillCircle º¯ÊýÌî³äÖ¸¶¨µÄÔ²¡£Ô²ÐÄΪ£¨sx, xy£©£¬°ë¾¶Îª r£¬ÒÔÂß¼­×ø±êÖ¸¶¨¡£
FillEllips º¯ÊýÌî³äÖ¸¶¨µÄÍÖÔ²¡£ÍÖÔ²ÐÄΪ£¨sx, sy£©£¬X Öá°ë¾¶Îª rx£¬Y Öá°ë¾¶Îª ry¡£
FillSector º¯ÊýÌî³äÓÉÔ²»¡ºÍÁ½Ìõ°ë¾¶ÐγɵÄÉÈÐΡ£Ô²ÐÄΪ£¨x, y£©£¬°ë¾¶Îª r£¬Æðʼ»¡¶ÈΪ ang1£¬ÖÕÖ¹»¡¶ÈΪ ang2¡£
FillPolygon º¯ÊýÌî³ä¶à±ßÐΡ£pts ±íʾ¶à±ßÐθ÷¸ö¶¥µã£¬vertices ±íʾ¶à±ßÐζ¥µã¸öÊý¡£
FloodFill ´ÓÖ¸¶¨µã£¨x, y£©¿ªÊ¼Ìî×¢¡£

    ÐèҪעÒâµÄÊÇ£¬ËùÓÐÌî³äº¯ÊýʹÓõ±Ç°»­Ë¢ÊôÐÔ£¨ÑÕÉ«£©£¬²¢ÇÒÊܵ±Ç°¹âÕ¤²Ù×÷µÄÓ°Ïì¡£

    ÏÂÃæµÄÀý×Ó˵Ã÷ÁËÈçºÎʹÓà FillCircle ºÍ FillEllipse º¯ÊýÌî³äÔ²»òÕßÍÖÔ²¡£¼Ù¶¨¸ø¶¨ÁËÁ½¸öµã£¬pts[0] ºÍ pts[1]£¬ÆäÖÐ pts[0] ÊÇÔ²ÐÄ»òÕßÍÖÔ²ÐÄ£¬¶ø pts[1] ÊÇÔ²»òÕßÍÖÔ²ÍâÇоØÐεÄÒ»¸ö¶¥µã¡£

           int rx = ABS (pts[1].x - pts[0].x);
            int ry = ABS (pts[1].y - pts[0].y);

            if (rx == ry)
                FillCircle (hdc, pts[0].x, pts[0].y, rx);
            else
                FillEllipse (hdc, pts[0].x, pts[0].y, rx, ry);


5 ½¨Á¢¸´ÔÓÇøÓò

    ³ýÁËÀûÓÃÌî³äÉú³ÉÆ÷½øÐÐÌî³ä»æÖÆÒÔÍ⣬ÎÒÃÇ»¹¿ÉÒÔʹÓÃÌî³äÉú³ÉÆ÷½¨Á¢ÓÉ·â±ÕÇúÏß°üΧµÄ¸´ÔÓÇøÓò¡£ÎÒÃÇÖªµÀ£¬MiniGUI µ±ÖеÄÇøÓòÊÇÓÉ»¥²»ÏཻµÄ¾ØÐÎ×é³ÉµÄ£¬²¢ÇÒÂú×ã x-y-banned µÄ·Ö²¼¹æÔò¡£ÀûÓÃÉÏÊöµÄ¶à±ßÐλòÕß·â±ÕÇúÏßÉú³ÉÆ÷£¬¿ÉÒÔ½«Ã¿ÌõɨÃèÏß¿´³ÉÊÇ×é³ÉÇøÓòµÄ¸ß¶ÈΪ 1 µÄÒ»¸ö¾ØÐΣ¬ÕâÑù£¬ÎÒÃÇ¿ÉÒÔÀûÓÃÕâЩÉú³ÉÆ÷½¨Á¢¸´ÔÓÇøÓò¡£MiniGUI ÀûÓÃÏÖÓеķâ±ÕÇúÏßÉú³ÉÆ÷£¬ÊµÏÖÁËÈçϵĸ´ÔÓÇøÓòÉú³Éº¯Êý£º

BOOL GUIAPI InitCircleRegion (PCLIPRGN dst, int x, int y, int r);
BOOL GUIAPI InitEllipseRegion (PCLIPRGN dst, int x, int y, int rx, int ry);
BOOL GUIAPI InitPolygonRegion (PCLIPRGN dst, const POINT* pts, int vertices);
BOOL GUIAPI InitSectorRegion (PCLIPRGN dst, const POINT* pts, int vertices);

    ÀûÓÃÕâЩº¯Êý£¬ÎÒÃÇ¿ÉÒÔ½«Ä³¸öÇøÓò·Ö±ð³õʼ»¯ÎªÔ²¡¢ÍÖÔ²¡¢¶à±ßÐκÍÉÈÐÎÇøÓò¡£È»ºó£¬¿ÉÒÔÀûÓÃÕâЩÇøÓò½øÐеã»÷²âÊÔ£¨PtInRegion ºÍ RectInRegion£©£¬»òÕßÑ¡Ôñµ½ DC µ±ÖÐ×÷Ϊ¼ôÇÐÓò£¬´Ó¶ø»ñµÃÌØÊâÏÔʾЧ¹û¡£

6 Ö±½Ó·ÃÎÊÏÔʾ»º³åÇø

    ÔÚÐ嵀 GDI ½Ó¿ÚÖУ¬ÎÒÃÇÌí¼ÓÁËÓÃÀ´Ö±½Ó·ÃÎÊÏÔʾ»º³åÇøµÄº¯Êý£¬Ô­ÐÍÈçÏ£º

Uint8* GUIAPI LockDC (HDC hdc, const RECT* rw_rc, int* width, int* height, int* pitch);
void GUIAPI UnlockDC (HDC hdc);

    LockDC º¯ÊýËø¶¨¸ø¶¨ HDC µÄÖ¸¶¨¾ØÐÎÇøÓò£¨ÓɾØÐÎ rw_rcÖ¸¶¨£¬É豸×ø±ê£©£¬È»ºó·µ»Ø»º³åÇøÍ·Ö¸Õë¡£µ± width¡¢height¡¢pitch Èý¸öÖ¸Õ벻Ϊ¿Õʱ£¬¸Ãº¯Êý½«·µ»ØËø¶¨Ö®ºóµÄ¾ØÐÎÓÐЧ¿í¶È¡¢ÓÐЧ¸ß¶ÈºÍÿɨÃèÏßËùÕ¼µÄ×Ö½ÚÊý¡£
    UnlockDC º¯Êý½â¿ªÒÑËø¶¨µÄ HDC¡£
    Ëø¶¨Ò»¸ö HDC Òâζ×Å MiniGUI ½øÈëÒÔ»¥³â·½Ê½·ÃÎÊÏÔʾ»º³åÇøµÄ״̬¡£Èç¹û±»Ëø¶¨µÄ HDC ÊÇÒ»¸öÆÁÄ» DC£¨¼´·ÇÄÚ´æ DC£©£¬Ôò¸Ãº¯Êý½«ÔÚ±ØҪʱÒþ²ØÊó±ê¹â±ê£¬²¢Ëø¶¨ HDC ¶ÔÓ¦µÄÈ«¾Ö¼ôÇÐÓò¡£ÔÚËø¶¨Ò»¸ö HDC Ö®ºó£¬³ÌÐò¿Éͨ¹ý¸Ãº¯Êý·µ»ØµÄÖ¸Õë¶ÔËø¶¨ÇøÓò½øÐзÃÎÊ¡£ÐèҪעÒâµÄÊÇ£¬²»Äܳ¤Ê±¼äËø¶¨Ò»¸ö HDC£¬Ò²²»Ó¦¸ÃÔÚËø¶¨Ò»¸ö HDC ʱ½øÐÐÆäËû¶îÍâµÄϵͳµ÷Óá£

    ¼Ù¶¨ÒÔËø¶¨¾ØÐÎ×óÉϽÇΪԭµã½¨Á¢×ø±êϵ£¬X ÖáˮƽÏòÓÒ£¬Y Öá´¹Ö±ÏòÏ£¬Ôò¿ÉÒÔͨ¹ýÈçÏµĹ«Ê½¼ÆËã¸Ã×ø±êϵÖУ¨x, y£©µã¶ÔÓ¦µÄ»º³åÇøµØÖ·£¨¼Ù¶¨¸Ãº¯Êý·µ»ØµÄÖ¸ÕëֵΪ frame_buffer£©£º

   Uint8* pixel_add = frame_buffer + y * (*pitch) + x * GetGDCapability (hdc, GDCAP_BPP);

¸ù¾Ý¸Ã HDC µÄÑÕÉ«Éî¶È£¬¾Í¿ÉÒÔ¶Ô¸ÃÏóËؽøÐжÁд²Ù×÷¡£×÷ΪʾÀý£¬ÏÂÃæµÄ³ÌÐò¶ÎËæ»úÌî³äËø¶¨ÇøÓò£º

   int i, width, height, pitch;
    RECT rc = {0, 0, 200, 200};
    int bpp = GetGDCapability (hdc, GDCAP_BPP);
    Uint8* frame_buffer = LockDC (hdc, &rc, &width, &height, &pitch);
    Uint8* row = frame_buffer;

    for (i = 0; i < *height; i++) {
        memset (row, rand ()%0x100, *width * bpp);
        row += *pitch;
    }

    UnlockDC (hdc);


7 YUV ¸²¸ÇºÍ Gamma УÕý

    ΪÁËÔöÇ¿ MiniGUI ¶Ô¶àýÌåµÄÖ§³Ö£¬ÎÒÃÇÔö¼ÓÁË¶Ô YUV ¸²¸Ç£¨Overlay£©ºÍ Gamma УÕýµÄÖ§³Ö¡£

7.1 YUV ¸²¸Ç£¨Overlay£©

    ¶àýÌåÁìÓòÖУ¬ÓÈÆäÔÚÉæ¼°µ½ MPEG ²¥·Åʱ£¬Í¨³£Ê¹Óà YUV ÑÕÉ«¿Õ¼äÀ´±íʾÑÕÉ«£¬Èç¹ûÒªÔÚÆÁÄ»ÉÏÏÔʾһ¸± MPEG ½âѹ֮ºóµÄͼƬ£¬ÔòÐèÒª½øÐÐ YUV ÑÕÉ«¿Õ¼äµ½ RGB ÑÕÉ«¿Õ¼äµÄת»»¡£YUV ¸²¸Ç×î³õÀ´×ÔһЩÏÔʾоƬµÄ¼ÓËÙ¹¦ÄÜ¡£ÕâÖÖÏÔʾоƬÄܹ»ÔÚÓ²¼þ»ù´¡ÉÏÍê³É YUV µ½ RGB µÄת»»£¬ÃâÈ¥Èí¼þת»»´øÀ´µÄÐÔÄÜËðʧ¡£ÔÚÕâÖÖÏÔʾоƬÉϽ¨Á¢ÁË YUV ¸²¸ÇÖ®ºó£¬¿ÉÒÔÖ±½Ó½« YUV ÐÅϢдÈ뻺³åÇø£¬Ó²¼þÄܹ»×Ô¶¯Íê³É YUV µ½ RGB µÄת»»£¬´Ó¶øÔÚ RGB ÏÔʾÆ÷ÉÏÏÔʾ³öÀ´¡£ÔÚ²»Ö§³Ö YUV ¸²¸ÇµÄÏÔʾоƬÉÏ£¬MiniGUI Ò²Äܹ»Í¨¹ýÈí¼þʵÏÖ YUV ¸²¸Ç£¬Õâʱ£¬ÐèÒªµ÷Óà DisplayYUVOverlay º¯Êý½« YUV ÐÅϢת»»²¢Ëõ·ÅÏÔʾÔÚ½¨Á¢ YUV ¸²¸ÇµÄ DC É豸ÉÏ¡£

MiniGUI ÌṩµÄ YUV ¸²¸Ç²Ù×÷º¯ÊýÔ­ÐÍÈçÏ£º

/***************************** YUV overlay support ***************************/
/* ×î³£¼ûµÄÊÓƵ¸²¸Ç¸ñʽ.
*/
#define GAL_YV12_OVERLAY  0x32315659    /* Planar mode: Y + V + U  (3 planes) */
#define GAL_IYUV_OVERLAY  0x56555949    /* Planar mode: Y + U + V  (3 planes) */
#define GAL_YUY2_OVERLAY  0x32595559    /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
#define GAL_UYVY_OVERLAY  0x59565955    /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
#define GAL_YVYU_OVERLAY  0x55595659    /* Packed mode: Y0+V0+Y1+U0 (1 plane) */

/* ¸Ãº¯Êý´´½¨Ò»¸öÊÓƵÊä³ö¸²¸Ç
*/
GAL_Overlay* GUIAPI CreateYUVOverlay (int width, int height,
                Uint32 format, HDC hdc);

/* Ëø¶¨¸²¸Ç½øÐÐÖ±½ÓµÄ»º³åÇø¶Áд£¬½áÊøºó½âËø */
int GAL_LockYUVOverlay (GAL_Overlay *overlay);
void GAL_UnlockYUVOverlay (GAL_Overlay *overlay);

#define LockYUVOverlay GAL_LockYUVOverlay
#define UnlockYUVOverlay GAL_UnlockYUVOverlay

/* ÊÍ·ÅÊÓƵ¸²¸Ç */
void GAL_FreeYUVOverlay (GAL_Overlay *overlay);
#define FreeYUVOverlay GAL_FreeYUVOverlay

/* ½«ÊÓƵ¸²¸Ç´«Ë͵½Ö¸¶¨ DC É豸ÉÏ¡£¸Ãº¯ÊýÄܹ»½øÐÐ 2 άËõ·Å
*/
void GUIAPI DisplayYUVOverlay (GAL_Overlay* overlay, const RECT* dstrect);

ÓйØÊÓƵ¸ñʽµÄÐÅÏ¢£¬¿É²Î¼û£º

http://www.webartz.com/fourcc/indexyuv.htm

ÓйØÑÕÉ«¿Õ¼äµÄÏ໥¹ØϵµÄÏ¢£¬¿É²Î¼û£º

http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html

7.2 Gamma УÕý

    Gamma УÕýͨ¹ýΪ RGB ÑÕÉ«¿Õ¼äµÄÿ¸öÑÕɫͨµÀÉèÖà Gamma Òò×Ó£¬À´¶¯Ì¬µ÷Õû RGB ÏÔʾÆ÷ÉϵÄʵ¼Ê RGB Ч¹û¡£ÐèҪעÒâµÄÊÇ£¬Gamma УÕýÐèÒªÏÔʾоƬµÄÓ²¼þÖ§³Ö¡£

    Ó¦ÓóÌÐò¿ÉÒÔͨ¹ý SetGamma º¯ÊýÉèÖà RGB Èý¸öÑÕɫͨµÀµÄ Gamma УÕýÖµ¡£¸Ãº¯ÊýÔ­ÐÍÈçÏ£º

int GAL_SetGamma (float red, float green, float blue);
#define SetGamma GAL_SetGamma

    ÏßÐÔ Gamma УÕýÖµµÄ·¶Î§ÔÚ 0.1 µ½ 10.0 Ö®¼ä¡£Èç¹ûÓ²¼þ²»Ö§³Ö Gamma УÕý£¬¸Ãº¯Êý½«·µ»Ø -1¡£

    Ó¦ÓóÌÐòÒ²¿ÉÒÔͨ¹ý SetGammaRamp º¯ÊýÉèÖà RGB Èý¸öÑÕɫͨµÀµÄ·ÇÏßÐÔ Gamma УÕýÖµ¡£¸Ãº¯ÊýÔ­ÐÍÈçÏ£º

int GAL_SetGammaRamp (Uint16 *red, Uint16 *green, Uint16 *blue);
#define SetGammaRamp GAL_SetGammaRamp

int GAL_GetGammaRamp (Uint16 *red, Uint16 *green, Uint16 *blue);
#define GetGammaRamp GAL_GetGammaRamp

    º¯Êý SetGammaRamp ʵ¼ÊÉèÖõÄÊÇÿ¸öÑÕɫͨµÀµÄ Gamma ת»»±í£¬Ã¿¸ö±íÓÉ 256 ¸öÖµ×é³É£¬±íʾÉèÖÃÖµºÍʵ¼ÊÖµÖ®¼äµÄ¶ÔÓ¦¹Øϵ¡£µ±ÉèÖÃÆÁÄ»ÉÏij¸öÏóËØµÄ RGB ·Ö±ðΪ R¡¢G¡¢B ʱ£¬Êµ¼ÊÔÚÏÔʾÆ÷ÉÏ»ñµÃµÄÏóËØ RGB Öµ·Ö±ðΪ£ºred[R]¡¢green[G]¡¢blue[B]¡£Èç¹ûÓ²¼þ²»Ö§³Ö Gamma УÕý£¬¸Ãº¯Êý½«·µ»Ø -1¡£

    º¯Êý GetGammaRamp »ñµÃµ±Ç°µÄ Gamma ת»»±í¡£

    Gamma УÕýµÄ×î³õÄ¿µÄ£¬ÊÇΪÁËÄܹ»ÔÚÏÔʾÆ÷ÉϾ«È·»¹Ô­Ò»¸±Í¼Æ¬¡£Gamma ÖµÔÚijÖ̶ֳÈÉϱíʾµÄÊÇij¸öÑÕɫͨµÀµÄ¶Ô±È¶È±ä»¯¡£µ« Gamma ÔÚ¶àýÌåºÍÓÎÏ·³ÌÐòÖÐÓÐһЩÌØÊâÓÃ;¨D¨Dͨ¹ý Gamma УÕý£¬¿ÉÒÔ·½±ãµØ»ñµÃ¶Ô±È¶È½¥½øЧ¹û¡£

8 С½á

    ±¾ÎÄÃèÊöÁË×Ô MiniGUI 1.1.0Pre4 °æ±¾·¢²¼ÒÔÀ´ÐÂÔöµÄ GDI ½Ó¿Ú¡£ÕâЩ½Ó¿ÚÉæ¼°µ½ÇúÏߺÍÌî³äÉú³ÉÆ÷¡¢¸´ÔÓÇúÏߵĻæÖÆ¡¢·â±ÕÇúÏßÌî³ä¡¢¸´ÔÓÇøÓòµÄ´´½¨¡¢Ö±½Ó·ÃÎÊ FrameBuffer¡¢YUV ¸²¸ÇºÍ Gamma УÕýµÈµÈ¡£Í¨¹ý±¾ÎĵĽéÉÜ£¬ÏàÐŶÁÕßÄܹ»¶Ô MiniGUI µÄРGDI ½Ó¿ÚÓÐÒ»¸ö¸ü¼ÓÈ«ÃæµÄÈÏʶ¡£

[Ŀ¼]


MiniGUI ÌṩµÄ·Ç GUI/GDI ½Ó¿Ú

1 ÒýÑÔ
    Ò»°ã¶øÑÔ£¬GUI ϵͳµÄÓ¦ÓóÌÐò±à³Ì½Ó¿ÚÖ÷Òª¼¯ÖÐÓÚ´°¿Ú¡¢ÏûÏ¢¶ÓÁС¢Í¼ÐÎÉ豸µÈÏà¹Ø·½Ãæ¡£µ«ÒòΪ GUI ϵͳÔÚ´¦Àíϵͳʼþʱͨ³£»áÌṩ×Ô¼ºµÄ»úÖÆ£¬¶øÕâЩ»úÖÆÍùÍù»áºÍ²Ù×÷ϵͳ±¾ÉíÌṩµÄ»úÖƲ»Ïà¼æÈÝ¡£±ÈÈ磬MiniGUI ÌṩÁËÏûϢѭ»·»úÖÆ£¬¶øÓ¦ÓóÌÐòµÄ½á¹¹Ò»°ãÊÇÏûÏ¢Çý¶¯µÄ£»Ò²¾ÍÊÇ˵£¬Ó¦ÓóÌÐòͨ¹ý±»¶¯½ÓÊÕÏûÏ¢À´¹¤×÷¡£µ«ºÜ¶àÇé¿öÏ£¬Ó¦ÓóÌÐòÐèÒªÖ÷¶¯¼àÊÓij¸öϵͳʼþ£¬±ÈÈçÔÚ UNIX ²Ù×÷ϵͳÖУ¬¿ÉÒÔͨ¹ý select ϵͳµ÷ÓüàÌýij¸öÎļþÃèÊö·ûÉÏÊÇ·ñÓпɶÁÊý¾Ý¡£ÕâÑù£¬ÈçºÎ½« MiniGUI µÄÏûÏ¢¶ÓÁлúÖƺÍÏÖÓвÙ×÷ϵͳµÄÆäËû»úÖÆÈÚºÏÔÚÒ»Æ𣬾ͳÉÁËÒ»¸ö½ÏΪÀ§ÄѵÄÎÊÌâ¡£±¾ÎĽ«½²Êö¼¸ÖÖ½â¾öÕâÒ»ÎÊÌâµÄ·½·¨¡£

    ÎÒÃÇÖªµÀ£¬MiniGUI-Lite ²ÉÓà UNIX Domain Socket ʵÏÖ¿Í»§³ÌÐòºÍ·þÎñÆ÷³ÌÐòÖ®¼äµÄ½»»¥¡£Ó¦ÓóÌÐòÒ²¿ÉÒÔÀûÓÃÕâÒ»»úÖÆ£¬Íê³É×Ô¼ºµÄͨѶÈÎÎñ¨D¨D¿Í»§Ïò·þÎñÆ÷Ìá½»ÇëÇ󣬶ø·þÎñÆ÷Íê³É¶Ô¿Í»§µÄÇëÇó´¦Àí²¢Ó¦´ð¡£Ò»·½Ã棬ÔÚ MiniGUI-Lite µÄ·þÎñÆ÷³ÌÐòÖУ¬Äã¿ÉÒÔÀ©Õ¹ÕâÒ»»úÖÆ£¬×¢²á×Ô¼ºµÄÇëÇó´¦Àíº¯Êý£¬Íê³É¶¨ÖƵÄÇëÇó/ÏìӦͨѶÈÎÎñ¡£ÁíÒ»·½Ã棬MiniGUI-Lite µ±ÖÐÒ²ÌṩÁËÈô¸ÉÓÃÀ´´´½¨ºÍ²Ù×÷ UNIX Domain Socket µÄº¯Êý£¬ÈκΠMiniGUI-Lite µÄÓ¦ÓóÌÐò¶¼¿ÉÒÔ½¨Á¢ UNIX Domain Socket£¬²¢Íê³ÉºÍÆäËû MiniGUI-Lite Ó¦ÓóÌÐòÖ®¼äµÄÊý¾Ý½»»»¡£±¾ÎĽ«¾ÙÀý½²ÊöÈçºÎÀûÓà MiniGUI-Lite ÌṩµÄº¯ÊýÍê³É´ËÀàͨѶÈÎÎñ¡£

    ǶÈëʽ Linux ϵͳÏÖÔÚÄܹ»ÔÚÐí¶à²»Í¬¼Ü¹¹µÄÓ²¼þƽ̨ÉÏÔËÐУ¬MiniGUI Ò²Äܹ»ÔÚÕâЩӲ¼þƽ̨ÉÏÔËÐС£µ«ÓÉÓÚÐí¶àÓ²¼þƽ̨¾ßÓкÍÆäËûÓ²¼þƽ̨²»Í¬µÄÌØÐÔ£¬±ÈÈç˵£¬³£¼ûµÄ CPU ÊÇ Little Endian µÄ£¬¶øijЩ CPU ÔòÊÇ Big Endian µÄ¡£ÕâÒªÇóÎÒÃÇÔÚ±àд´úÂ룬ÓÈÆäÊÇÎļþ I/O Ïà¹Ø´úÂëʱ£¬±ØÐë±àд¿ÉÒÆÖ²´úÂ룬ÒÔ±ãÊʺϾßÓв»Í¬¼Ü¹¹µÄƽ̨¡£±¾ÎĽ«ÃèÊö MiniGUI ΪӦÓóÌÐòÌṩµÄ¿ÉÒÆÖ²ÐÔº¯Êý¼°ÆäÓ÷¨¡£

    ³ýÁËÓëÉÏÊöÄÚÈÝÏà¹ØµÄº¯ÊýÖ®Í⣬MiniGUI »¹ÌṩÁËÆäËûһЩº¯Êý£¬±¾ÎÄ×îºó²¿·Ö½«ÃèÊöÕâЩº¯ÊýµÄÓÃ;ºÍÓ÷¨£¬°üÀ¨ÅäÖÃÎļþ¶ÁдÒÔ¼°¶¨µãÊýÔËËã¡£

2 MiniGUI-LiteºÍ select ϵͳµ÷ÓÃ
    ÎÒÃÇÖªµÀ£¬ÔÚ MiniGUI-Lite Ö®ÉÏÔËÐеÄÓ¦ÓóÌÐòÖ»ÓÐÒ»¸öÏûÏ¢¶ÓÁС£Ó¦ÓóÌÐòÔÚ³õʼ»¯Ö®ºó£¬»á½¨Á¢Ò»¸öÏûϢѭ»·£¬È»ºó²»Í£µØ´ÓÕâ¸öÏûÏ¢¶ÓÁе±ÖлñµÃÏûÏ¢²¢´¦Àí£¬Ö±µ½½ÓÊÕµ½ MSG_QUIT ÏûϢΪֹ¡£Ó¦ÓóÌÐòµÄ´°¿Ú¹ý³ÌÔÚ´¦ÀíÏûϢʱ£¬ÒªÔÚ´¦ÀíÍêÏûÏ¢Ö®ºóÁ¢¼´·µ»Ø£¬ÒÔ±ãÓлú»á»ñµÃÆäËûµÄÏûÏ¢²¢´¦Àí¡£ÏÖÔÚ£¬Èç¹ûÓ¦ÓóÌÐòÔÚ´¦Àíij¸öÏûϢʱ¼àÌýij¸öÎļþÃèÊö·û¶øµ÷Óà select ϵͳµ÷Ó㬾ÍÓпÉÄÜ»á³öÏÖÎÊÌâ¨D¨DÒòΪ select ϵͳµ÷ÓÿÉÄ᳤ܻʱ¼ä×èÈû£¬¶øÓÉ MiniGUI-Lite ·þÎñÆ÷·¢Ë͸ø¿Í»§µÄʼþµÃ²»µ½¼°Ê±´¦Àí¡£ÕâÑù£¬ÏûÏ¢Çý¶¯µÄ·½Ê½ºÍ select ϵͳµ÷ÓþÍÄÑÓںܺõØÈںϡ£ÔÚ MiniGUI-Threads ÖУ¬ÒòΪÿ¸öÏ̶߳¼ÓÐ×Ô¼ºÏàÓ¦µÄÏûÏ¢¶ÓÁУ¬¶øϵͳÏûÏ¢¶ÓÁÐÊÇÓɵ¥¶ÀÔËÐÐµÄ desktop Ï̹߳ÜÀíµÄ£¬ËùÒÔÈκÎÒ»¸öÓ¦ÓóÌÐò½¨Á¢µÄÏ̶߳¼¿ÉÒÔ³¤Ê±¼ä×èÈû£¬´Ó¶ø¿ÉÒÔµ÷ÓÃÀàËÆ select µÄϵͳµ÷Óᣵ«ÔÚ MiniGUI-Lite µ±ÖУ¬Èç¹ûÒª¼àÌýij¸öÓ¦ÓóÌÐò×Ô¼ºµÄÎļþÃèÊö·ûʼþ£¬±ØÐë½øÐÐÇ¡µ±µÄ´¦Àí£¬ÒÔ±ÜÃⳤʱ¼ä×èÈû¡£

    ÔÚ MiniGUI-Lite µ±ÖУ¬Óм¸ÖÖ½â¾öÕâÒ»ÎÊÌâµÄ°ì·¨£º

    ÔÚµ÷Óà select ϵͳµ÷ÓÃʱ£¬´«µÝ³¬Ê±Öµ£¬±£Ö¤ select ϵͳµ÷Óò»»á³¤Ê±¼ä×èÈû¡£
    ÉèÖö¨Ê±Æ÷£¬¶¨Ê±Æ÷µ½ÆÚʱ£¬ÀûÓà select ϵͳµ÷Óò鿴±»¼àÌýµÄÎļþÃèÊö·û¡£Èç¹ûûÓÐÏàÓ¦µÄʼþ·¢Éú£¬ÔòÁ¢¼´·µ»Ø£¬·ñÔò½øÐжÁд²Ù×÷¡£
    ÀûÓà MiniGUI-Lite ÌṩµÄ RegisterListenFD º¯ÊýÔÚϵͳÖÐ×¢²á¼àÌýÎļþÃèÊö·û£¬²¢ÔÚ±»¼àÌýµÄÎļþÃèÊö·ûÉÏ·¢ÉúÖ¸¶¨µÄʼþʱ£¬Ïòij¸ö´°¿Ú·¢ËÍ MSG_FDEVENT ÏûÏ¢¡£

    ÓÉÓÚÇ°Á½ÖÖ½â¾ö·½·¨±È½Ï¼òµ¥£¬ÕâÀïÎÒÃÇÖص㽲ÊöµÄµÚÈýÖÖ½â¾ö°ì·¨¡£MiniGUI-Lite ΪӦÓóÌÐòÌṩÁËÈçÏÂÁ½¸öº¯Êý¼°Ò»¸öºê£º
#define MAX_NR_LISTEN_FD   5

/* Return TRUE if all OK, and FALSE on error. */
BOOL GUIAPI RegisterListenFD (int fd, int type, HWND hwnd, void* context);

/* Return TRUE if all OK, and FALSE on error. */
BOOL GUIAPI UnregisterListenFD (int fd);

MAX_NR_LISTEN_FD ºê¶¨ÒåÁËϵͳÄܹ»¼àÌýµÄ×î¶àÎļþÃèÊö·ûÊý£¬Ä¬È϶¨ÒåΪ 5¡£
RegisterListenFD º¯ÊýÔÚϵͳµ±ÖÐ×¢²áÒ»¸öÐèÒª¼àÌýµÄÎļþÃèÊö·û£¬²¢Ö¸¶¨¼àÌýµÄʼþÀàÐÍ£¨type ²ÎÊý£¬¿ÉÈ¡ POLLIN¡¢POLLOUT »òÕß POLLERR£©£¬½ÓÊÕ MSG_FDEVENT ÏûÏ¢µÄ´°¿Ú¾ä±úÒÔ¼°Ò»¸öÉÏÏÂÎÄÐÅÏ¢¡£
UnregisterListenFD º¯Êý×¢ÏúÒ»¸ö±»×¢²áµÄ¼àÌýÎļþÃèÊö·û¡£

ÔÚÓ¦ÓóÌÐòʹÓÃRegisterListenFD º¯Êý×¢²áÁ˱»¼àÌýµÄÎļþÃèÊö·ûÖ®ºó£¬µ±Ö¸¶¨µÄʼþ·¢ÉúÔÚ¸ÃÎļþÃèÊö·ûÉÏʱ£¬ÏµÍ³»á½« MSG_FDEVENT ÏûÏ¢·¢Ë͵½Ö¸¶¨µÄ´°¿Ú£¬Ó¦ÓóÌÐò¿ÉÔÚ´°¿Ú¹ý³ÌÖнÓÊÕ¸ÃÏûÏ¢²¢´¦Àí¡£MiniGUI ÖÐµÄ libvcongui ¾ÍÀûÓÃÁËÉÏÊöº¯Êý¼àÌýÀ´×ÔÖ÷¿ØαÖÕ¶ËÉϵĿɶÁʼþ£¬ÈçÏÂÃæµÄ³ÌÐò¶ÎËùʾ£¨vcongui/vcongui.c£©£º
    ...

    /* ×¢²áÖ÷¿ØαÖÕ¶Ëα¼àÌýÎļþÃèÊö·û */
    RegisterListenFD (pConInfo->masterPty, POLLIN, hMainWnd, 0);

    /* ½øÈëÏûϢѭ»· */
    while (!pConInfo->terminate && GetMessage (&Msg, hMainWnd)) {
        DispatchMessage (&Msg);
    }
    /* ×¢Ïú¼àÌýÎļþÃèÊö·û */
    UnregisterListenFD (pConInfo->masterPty);

    ...

/* ÐéÄâ¿ØÖÆ̨µÄ´°¿Ú¹ý³Ì */
static int VCOnGUIMainWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    PCONINFO pConInfo;

    pConInfo = (PCONINFO)GetWindowAdditionalData (hWnd);
    switch (message) {

         ...

       /* ½ÓÊÕµ½ MSG_FDEVENT ÏûÏ¢£¬Ôò´¦ÀíÖ÷¿ØαÖÕ¶ËÉϵÄÊäÈëÊý¾Ý */
        case MSG_FDEVENT:
            ReadMasterPty (pConInfo);
        break;

        ...
    }

    /* µ÷ÓÃĬÈÏ´°¿Ú¹ý³Ì */
    if (pConInfo->DefWinProc)
        return (*pConInfo->DefWinProc)(hWnd, message, wParam, lParam);
    else
        return DefaultMainWinProc (hWnd, message, wParam, lParam);
}

    ÔÚ 3.2 ½Úµ±ÖУ¬ÎÒÃÇ»¹¿ÉÒÔ¿´µ½RegisterListenFD º¯ÊýµÄʹÓá£ÏÔÈ»£¬Í¨¹ýÕâÖÖ¼òµ¥µÄ×¢²á¼àÌýÎļþÃèÊö·ûµÄ½Ó¿Ú£¬MiniGUI-Lite ³ÌÐòÄܹ»·½±ãµØÀûÓõײãµÄÏûÏ¢»úÖÆÍê³É¶ÔÒ첽ʼþµÄ´¦Àí¡£

3 MiniGUI-Lite Óë½ø³Ì¼äͨѶ

3.1 ¼òµ¥ÇëÇó/Ó¦´ð´¦Àí
ÎÒÃÇÖªµÀ£¬MiniGUI-Lite ÀûÓÃÁË UNIX Domain Socket ʵÏÖ·þÎñÆ÷ºÍ¿Í»§³ÌÐòÖ®¼äµÄͨѶ¡£ÎªÁËʵÏÖ¿Í»§ºÍ·þÎñÆ÷Ö®¼äµÄ¼òµ¥·½±ãµÄͨѶ£¬MiniGUI-Lite Öж¨ÒåÁËÒ»ÖÖ¼òµ¥µÄÇëÇó/ÏìÓ¦½á¹¹¡£¿Í»§³ÌÐòͨ¹ýÖ¸¶¨µÄ½á¹¹½«ÇëÇó·¢Ë͵½·þÎñÆ÷£¬·þÎñÆ÷´¦ÀíÇëÇó²¢Ó¦´ð¡£ÔÚ¿Í»§¶Ë£¬Ò»¸öÇëÇó¶¨ÒåÈçÏ£¨include/gdi.h£©£º
typedef struct tagREQUEST {
    int id;
    const void* data;
    size_t len_data;
} REQUEST;
typedef REQUEST* PREQUEST;

ÆäÖУ¬id ÊÇÓÃÀ´±êʶÇëÇóÀàÐ͵ÄÕûÐÍÊý£¬data ÊÇ·¢Ë͸ø¸ÃÇëÇóµÄ¹ØÁªÊý¾Ý£¬len_data ÔòÊÇÊý¾ÝµÄ³¤¶È¡£¿Í»§ÔÚ³õʼ»¯ REQUEST ½á¹¹Ö®ºó£¬¾Í¿ÉÒÔµ÷Óà cli_request Ïò·þÎñÆ÷·¢ËÍÇëÇ󣬲¢µÈ´ý·þÎñÆ÷µÄÓ¦´ð¡£¸Ãº¯ÊýµÄÔ­ÐÍÈçÏ¡£
/* send a request to server and wait reply */
int cli_request (PREQUEST request, void* result, int len_rslt);

    ·þÎñÆ÷³ÌÐò£¨¼´ mginit£©»áÔÚ×Ô¼ºµÄÏûϢѭ»·µ±ÖлñµÃÀ´×Ô¿Í»§µÄÇëÇ󣬲¢½øÐд¦Àí£¬×îÖջὫ´¦Àí½á¹û·¢Ë͸ø¿Í»§¡£

    ÔÚÉÏÊöÕâÖÖ¼òµ¥µÄ¿Í»§/·þÎñÆ÷ͨѶÖУ¬¿Í»§ºÍ·þÎñÆ÷±ØÐë¾Íÿ¸öÇëÇóÀàÐÍ´ï³ÉÒ»Ö£¬Ò²¾ÍÊÇ˵£¬¿Í»§ºÍ·þÎñÆ÷±ØÐëÁ˽âÿÖÖÀàÐÍÇëÇóµÄÊý¾Ýº¬Òå²¢½øÐÐÇ¡µ±µÄ´¦Àí¡£

    MiniGUI-Lite ÀûÓÃÉÏÊöÕâÖÖ¼òµ¥µÄͨѶ·½·¨£¬ÊµÏÖÁËÈô¸Éϵͳ¼¶µÄͨѶÈÎÎñ£º

    Êó±ê¹â±êµÄ¹ÜÀí¡£Êó±ê¹â±êÊÇÒ»¸öÈ«¾Ö×ÊÔ´£¬µ±¿Í»§ÐèÒª´´½¨»òÕßÏú»ÙÊó±ê¹â±ê£¬¸Ä±äÊó±ê¹â±êµÄÐÎ×´¡¢Î»Öã¬ÏÔʾ»òÕßÒþ²ØÊó±êʱ£¬¾Í·¢ËÍÇëÇóµ½·þÎñÆ÷£¬·þÎñÆ÷³ÌÐòÍê³ÉÏàÓ¦ÈÎÎñ²¢½«½á¹û·¢Ë͸ø¿Í»§¡£
²ã¼°»î¶¯¿Í»§¹ÜÀí¡£µ±¿Í»§²éѯ²ãµÄÐÅÏ¢£¬Ð½¨²ã£¬¼ÓÈëij¸öÒÑÓв㣬»òÕßÉèÖòãÖеĻ¿Í»§Ê±£¬Í¨¹ý¸Ã½Ó¿Ú·¢ËÍÇëÇóµ½·þÎñÆ÷¡£
    ÆäËûһЩϵͳ¼¶µÄÈÎÎñ¡£±ÈÈçÔÚÐ嵀 GDI ½Ó¿ÚÖУ¬·þÎñÆ÷³ÌÐòͳһ¹ÜÀíÏÔʾ¿¨ÖпÉÄÜÓÃÀ´½¨Á¢ÄÚ´æ DC µÄÏÔʾÄڴ棬µ±¿Í»§ÒªÉêÇ뽨Á¢ÔÚÏÔʾÄÚ´æÖеÄÄÚ´æ DC ʱ£¬¾Í»á·¢ËÍÇëÇóµ½·þÎñÆ÷¡£

    ΪÁËÈÃÓ¦ÓóÌÐòÒ²Äܹ»Í¨¹ýÕâÖÖ¼òµ¥µÄ·½Ê½ÊµÏÖ¿Í»§ºÍ·þÎñÆ÷Ö®¼äµÄͨѶ£¬·þÎñÆ÷³ÌÐò¿ÉÒÔ×¢²áһЩ¶¨ÖƵÄÇëÇó´¦Àíº¯Êý£¬È»ºó¿Í»§¾Í¿ÉÒÔÏò·þÎñÆ÷·¢ËÍÕâЩÇëÇó¡£Îª´Ë£¬MiniGUI-Lite ÌṩÁËÈçϽӿڣº

#define MAX_SYS_REQID           0x0010
#define MAX_REQID               0x0018

/*
* Register user defined request handlers for server
* Note that user defined request id should larger than MAX_SYS_REQID
*/
typedef int (* REQ_HANDLER) (int cli, int clifd, void* buff, size_t len);
BOOL GUIAPI RegisterRequestHandler (int req_id, REQ_HANDLER your_handler);
REQ_HANDLER GUIAPI GetRequestHandler (int req_id);

    ·þÎñÆ÷¿ÉÒÔͨ¹ýµ÷ÓÃRegisterRequestHandler º¯Êý×¢²áһЩÇëÇó´¦Àíº¯Êý¡£×¢ÒâÇëÇó´¦Àíº¯ÊýµÄÔ­ÐÍÓÉREQ_HANDLER ¶¨Òå¡£»¹Òª×¢Òâϵͳ¶¨ÒåÁËMAX_SYS_REQID ºÍ MAX_REQID ÕâÁ½¸öºê¡£MAX_REQID ÊÇÄܹ»×¢²áµÄ×î´óÇëÇó ID ºÅ£¬¶ø MAX_SYS_REQID ÊÇϵͳÄÚ²¿Ê¹ÓõÄ×î´óµÄÇëÇó ID ºÅ£¬Ò²¾ÍÊÇ˵£¬Í¨¹ýRegisterRequestHandler ×¢²áµÄÇëÇó ID ºÅ£¬±ØÐë´óÓÚ MAX_SYS_REQID ¶øСÓÚ»òµÈÓÚ MAX_REQID¡£

    ×÷ΪʾÀý£¬ÎÒÃǼÙÉè·þÎñÆ÷Ìæ¿Í»§¼ÆËãÁ½¸öÕûÊýµÄºÍ¡£¿Í»§·¢ËÍÁ½¸öÕûÊý¸ø·þÎñÆ÷£¬¶ø·þÎñÆ÷½«Á½¸öÕûÊýµÄºÍ·¢Ë͸ø¿Í»§¡£ÏÂÃæµÄ³ÌÐò¶ÎÔÚ·þÎñÆ÷³ÌÐòÖÐÔËÐУ¬ÔÚϵͳÖÐ×¢²áÁËÒ»¸öÇëÇó´¦Àíº¯Êý£º
typedef struct TEST_REQ
{
   int a, b;
} TEST_REQ;

static int send_reply (int clifd, void* reply, int len)
{
    MSG reply_msg = {HWND_INVALID, 0};

    /* ·¢ËÍÒ»¸ö¿ÕÏûÏ¢½Ó¿Ú¸ø¿Í»§£¬ÒÔ±ã˵Ã÷ÕâÊÇÒ»¸öÇëÇóµÄÓ¦´ð */
    if (sock_write (clifd, &reply_msg, sizeof (MSG)) < 0)
        return SOCKERR_IO;

    /* ½«½á¹û·¢Ë͸ø¿Í»§ */
    if (sock_write (clifd, reply, len) < 0)
        return SOCKERR_IO;

    return SOCKERR_OK;
}

static int test_request (int cli, int clifd, void* buff, size_t len)
{
    int ret_value = 0;
    TEST_REQ* test_req = (TEST_REQ*)buff;

    ret_value = test_req.a + test_req.b;

    return send_reply (clifd, &ret_value, sizeof (int));
}

...
     RegisterRequestHandler (MAX_SYS_REQID + 1, test_request);
...

¶ø¿Í»§³ÌÐò¿ÉÒÔͨ¹ýÈçϵijÌÐò¶ÎÏò¿Í»§·¢ËÍÒ»¸öÇëÇó»ñµÃÁ½¸öÕûÊýµÄºÍ£º
        REQUEST req;
        TEST_REQ test_req = {5, 10};
        int ret_value;

        req.id = MAX_SYS_REQID + 1;
        req.data = &rest_req;
        req.len_data = sizeof (TEST_REQ);

        cli_request (&req, &ret_value, sizeof (int));
        printf ("the returned value: %d\n", ret_value);    /* ret_value µÄÖµÓ¦¸ÃÊÇ 15 */

    ¶ÁÕßÒѾ­¿´µ½£¬Í¨¹ýÕâÖÖ¼òµ¥µÄÇëÇó/Ó¦´ð¼¼Êõ£¬MiniGUI-Lite ¿Í»§³ÌÐòºÍ·þÎñÆ÷³ÌÐòÖ®¼ä¿ÉÒÔ½¨Á¢Ò»Öַdz£·½±ãµÄ½ø³Ì¼äͨѶ»úÖÆ¡£µ«ÕâÖÖ¼¼ÊõÒ²ÓÐһЩȱµã£¬±ÈÈçÊܵ½ MAX_REQID ´óСµÄÓ°Ï죬ͨѶ»úÖƲ¢²»ÊǷdz£Áé»î£¬¶øÇÒÇëÇóÖ»ÄÜ·¢Ë͸øMiniGUI-Lite µÄ·þÎñÆ÷³ÌÐò£¨¼´ mginit£©´¦ÀíµÈµÈ¡£

3.2 ¸´Ô UNIX Domain Socket ·â×°
    ΪÁ˽â¾öÉÏÊö¼òµ¥ÇëÇó/Ó¦´ð»úÖƵIJ»×㣬MiniGUI-Lite Ò²ÌṩÁ˾­¹ý·â×°µÄ UNIX Domain Socket ´¦Àíº¯Êý¡£ÕâЩº¯ÊýµÄ½Ó¿ÚÔ­ÐÍÈçÏ£¨include/minigui.h£©£º
/* Used by server to create a listen socket.
* Name is the name of listen socket.
* Please located the socket in /var/tmp directory. */

/* Returns fd if all OK, -1 on error. */
int serv_listen (const char* name);

/* Wait for a client connection to arrive, and accept it.
* We also obtain the client's pid and user ID from the pathname
* that it must bind before calling us. */

/* returns new fd if all OK, < 0 on error */
int serv_accept (int listenfd, pid_t *pidptr, uid_t *uidptr);

/* Used by clients to connect to a server.
* Name is the name of the listen socket.
* The created socket will located at the directory /var/tmp,
* and with name of '/var/tmp/xxxxx-c', where 'xxxxx' is the pid of client.
* and 'c' is a character to distinguish diferent projects.
* MiniGUI use 'a' as the project character.
*/

/* Returns fd if all OK, -1 on error. */
int cli_conn (const char* name, char project);

#define SOCKERR_IO          -1
#define SOCKERR_CLOSED      -2
#define SOCKERR_INVARG      -3
#define SOCKERR_OK          0

/* UNIX domain socket I/O functions. */

/* Returns SOCKERR_OK if all OK, < 0 on error.*/
int sock_write_t (int fd, const void* buff, int count, unsigned int timeout);
int sock_read_t (int fd, void* buff, int count, unsigned int timeout);

#define sock_write(fd, buff, count) sock_write_t(fd, buff, count, 0)
#define sock_read(fd, buff, count) sock_read_t(fd, buff, count, 0)

    ÉÏÊöº¯ÊýÊÇ MiniGUI-Lite ÓÃÀ´½¨Á¢ÏµÍ³ÄÚ²¿Ê¹ÓÃµÄ UNIX Domain Socket ²¢½øÐÐÊý¾Ý´«µÝµÄº¯Êý£¬ÊǶԻù±¾Ì×½Ó×Öϵͳµ÷Óõķâ×°¡£ÕâЩº¯ÊýµÄ¹¦ÄÜÃèÊöÈçÏ£º

serv_listen£º·þÎñÆ÷µ÷Óøú¯Êý½¨Á¢Ò»¸ö¼àÌýÌ×½Ó×Ö£¬²¢·µ»ØÌ×½Ó×ÖÎļþÃèÊö·û¡£½¨Ò齫·þÎñÆ÷¼àÌýÌ×½Ó×Ö½¨Á¢ÔÚ /var/tmp/ Ŀ¼Ï¡£
serv_accept£º·þÎñÆ÷µ÷Óøú¯Êý½ÓÊÜÀ´×Ô¿Í»§µÄÁ¬½ÓÇëÇó¡£
cli_conn£º¿Í»§µ÷Óøú¯ÊýÁ¬½Óµ½·þÎñÆ÷£¬ÆäÖÐ name ÊÇ¿Í»§µÄ¼àÌýÌ×½Ó×Ö¡£¸Ãº¯ÊýΪ¿Í»§½¨Á¢µÄÌ×½Ó×Ö½«±£´æÔÚ /var/tmp/ Ŀ¼ÖУ¬²¢ÇÒÒÔ -c µÄ·½Ê½ÃüÃû£¬ÆäÖÐ c ÊÇÓÃÀ´Çø±ð²»Í¬Ì×½Ó×ÖͨѶÓÃ;µÄ×Öĸ£¬ÓÉ project ²ÎÊýÖ¸¶¨¡£MiniGUI-Lite ÄÚ²¿Ê¹ÓÃÁË 'a'£¬ËùÒÔÓÉÓ¦ÓóÌÐò½¨Á¢µÄÌ×½Ó×Ö£¬Ó¦¸ÃʹÓóý 'a' Ö®ÍâµÄ×Öĸ¡£
sock_write_t£ºÔÚ½¨Á¢²¢Á¬½ÓÖ®ºó£¬¿Í»§ºÍ·þÎñÆ÷Ö®¼ä¾Í¿ÉÒÔʹÓà sock_write_t º¯ÊýºÍ sock_read_t º¯Êý½øÐÐÊý¾Ý½»»»¡£sock_write_t µÄ²ÎÊýºÍϵͳµ÷Óà write ÀàËÆ£¬µ«¿ÉÒÔ´«µÝ½øÈëÒ»¸ö³¬Ê±²ÎÊý£¬×¢Òâ¸Ã²ÎÊýÒÔ 10ms Ϊµ¥Î»£¬ÎªÁãʱ³¬Ê±ÉèÖÃʧЧ£¬ÇÒ³¬Ê±ÉèÖÃÖ»ÔÚ mginit ³ÌÐòÖÐÓÐЧ¡£
sock_read_t£ºsock_read_t µÄ²ÎÊýºÍϵͳµ÷Óà readÀàËÆ£¬µ«¿ÉÒÔ´«µÝ½øÈëÒ»¸ö³¬Ê±²ÎÊý£¬×¢Òâ¸Ã²ÎÊýÒÔ 10ms Ϊµ¥Î»£¬ÎªÁãʱ³¬Ê±ÉèÖÃʧЧ£¬ÇÒ³¬Ê±ÉèÖÃÖ»ÔÚ mginit ³ÌÐòÖÐÓÐЧ¡£

    ÏÂÃæµÄ´úÂëÑÝʾÁË×÷Ϊ·þÎñÆ÷µÄ³ÌÐòÈçºÎÀûÓÃÉÏÊöº¯Êý½¨Á¢Ò»¸ö¼àÌýÌ×½Ó×Ö£º
#define LISTEN_SOCKET    "/var/tmp/mysocket"

static int listen_fd;

BOOL listen_socket (HWND hwnd)
{
    if ((listen_fd = serv_listen (LISTEN_SOCKET)) < 0)
        return FALSE;
    return RegisterListenFD (fd, POLL_IN, hwnd, NULL);
}

    µ±·þÎñÆ÷½ÓÊÕµ½À´×Ô¿Í»§µÄÁ¬½ÓÇëÇóÊÇ£¬·þÎñÆ÷µÄ hwnd ´°¿Ú½«½ÓÊÕµ½ MSG_FDEVENT ÏûÏ¢£¬Õâʱ£¬·þÎñÆ÷¿É½ÓÊܸÃÁ¬½ÓÇëÇó£º
int MyWndProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {

        ...

        case MSG_FDEVENT:
             if (LOWORD (wParam) == listen_fd) { /* À´×Ô¼àÌýÌ×½Ó×Ö */
                  pid_t pid;
                  uid_t uid;
                  int conn_fd;
                  conn_fd = serv_accept (listen_fd, &pid, &uid);
                  if (conn_fd >= 0) {
                       RegisterListenFD (conn_fd, POLL_IN, hwnd, NULL);
                  }
             }
             else { /* À´×ÔÒÑÁ¬½ÓÌ×½Ó×Ö */
                   int fd = LOWORD(wParam);
                   /* ´¦ÀíÀ´×Ô¿Í»§µÄÊý¾Ý */
                   sock_read_t (fd, ...);
                   sock_write_t (fd, ....);
             }
        break;

        ...

    }
}

    ÉÏÃæµÄ´úÂëÖУ¬·þÎñÆ÷½«Á¬½ÓµÃµ½µÄÐÂÎļþÃèÊö·ûÒ²×¢²áΪ¼àÌýÃèÊö·û£¬Òò´Ë£¬ÔÚ MSG_FDEVENT ÏûÏ¢µÄ´¦ÀíÖУ¬Ó¦¸ÃÅжϵ¼Ö MSG_FDEVENT ÏûÏ¢µÄÎļþÃèÊö·ûÀàÐÍ£¬²¢×öÊʵ±µÄ´¦Àí¡£

ÔÚ¿Í»§¶Ë£¬µ±ÐèÒªÁ¬½Óµ½·þÎñÆ÷ʱ£¬¿Éͨ¹ýÈçÏ´úÂ룺
    int conn_fd;

    if ((conn_fd  = cli_conn (LISTEN_SOCKET, 'b')) >= 0) {
        /* Ïò·þÎñÆ÷·¢ËÍÇëÇó */
        sock_write_t (fd, ....);
        /* »ñÈ¡À´×Ô·þÎñÆ÷µÄ´¦Àí½á¹û */
        sock_read_t (fd, ....);
    }

4 ±àд¿ÉÒÆÖ²´úÂë
    ÎÒÃÇÖªµÀ£¬Ðí¶àǶÈëʽϵͳËùʹÓÃµÄ CPU ¾ßÓкÍÆǪ̃ͨʽ»ú CPU ÍêÈ«²»Í¬µÄ¹¹ÔìºÍÌص㡣µ«ÓÐÁ˲Ù×÷ϵͳºÍ¸ß¼¶ÓïÑÔ£¬¿ÉÒÔ×î´ó³Ì¶ÈÉϽ«ÕâЩ²»Í¬Òþ²ØÆðÀ´¡£Ö»ÒªÀûÓø߼¶ÓïÑÔ±à³Ì£¬±àÒëÆ÷ºÍ²Ù×÷ϵͳÄܹ»°ïÖú³ÌÐòÔ±½â¾öÐí¶àºÍ CPU ¹¹Ôì¼°ÌصãÏà¹ØµÄÎÊÌ⣬´Ó¶ø½ÚÊ¡³ÌÐò¿ª·¢Ê±¼ä£¬²¢Ìá¸ß³ÌÐò¿ª·¢Ð§ÂÊ¡£È»¶øijЩ CPU ÌصãÈ´ÊÇÓ¦ÓóÌÐò¿ª·¢ÈËÔ±Ëù±ØÐëÃæ¶ÔµÄ£¬ÕâÆäÖоÍÓÐÈçϼ¸¸öÐèÒªÌرð×¢ÒâµÄ·½Ã棺

    ×Ö½Ú˳Ðò¡£Ò»°ãÇé¿öÏ£¬ÎÒÃǽӴ¥µ½µÄ CPU ÔÚ´æ·Å¶à×Ö½ÚµÄÕûÊýÊý¾Ýʱ£¬½«µÍλ×Ö½Ú´æ·ÅÔڵ͵ØÖ·µ¥ÔªÖУ¬±ÈÈç³£¼ûµÄ Intel x86 ϵÁÐ CPU¡£¶øijЩ CPU ²ÉÓÃÏà·´µÄ×Ö½Ú˳Ðò¡£±ÈÈçÔÚǶÈëʽϵͳÖÐʹÓýÏΪ¹ã·ºµÄ PowerPC ¾Í½«µÍλ×Ö½Ú´æ·ÅÔڸߵØÖ·µ¥ÔªÖС£Ç°Õ߽РLittle Endian ϵͳ£»¶øºóÕ߽РBig Endian ϵͳ¡£
ÔÚijЩƽ̨É쵀 Linux Äںˣ¬¿ÉÄÜȱÉÙijЩ¸ß¼¶ÏµÍ³µ÷Óã¬×î³£¼ûµÄ¾ÍÊÇÓëÐéÄâÄÚ´æ»úÖÆÏà¹ØµÄϵͳµ÷Óá£ÔÚijЩ CPU ÉÏÔËÐÐµÄ Linux ²Ù×÷ϵͳ£¬ÒòΪ CPU ÄÜÁ¦µÄÏÞÖÆ£¬ÎÞ·¨ÌṩÐéÄâÄÚ´æ»úÖÆ£¬»ùÓÚÐéÄâÄÚ´æʵÏÖµÄijЩ IPC »úÖƾÍÎÞ·¨Õý³£¹¤×÷¡£±ÈÈçÔÚijЩȱÉÙ MMU µ¥ÔªµÄ CPU ÉÏ£¬¾ÍÎÞ·¨Ìṩ System V IPC »úÖÆÖеĹ²ÏíÄÚ´æ¡£

    ΪÁ˱àд¾ßÓÐ×î¹ã·ºÊÊÓ¦ÐԵĿÉÒÆÖ²´úÂ룬ӦÓóÌÐò¿ª·¢ÈËÔ±±ØÐë×¢Òâµ½ÕâЩ²»Í¬£¬²¢ÇÒ¸ù¾ÝÇé¿ö±àд¿ÉÒÆÖ²´úÂë¡£ÕâÀÎÒÃǽ«ÃèÊöÈçºÎÔÚ MiniGUI Ó¦ÓóÌÐòÖбàд¿ÉÒÆÖ²´úÂë¡£

4.1 Àí½â²¢Ê¹Óà MiniGUI µÄ Endian ¶Áдº¯Êý
    ΪÁ˽â¾öÉÏÊöµÄµÚÒ»¸öÎÊÌ⣬MiniGUI ÌṩÁËÈô¸É Endian Ïà¹ØµÄ¶Áдº¯Êý¡£ÕâЩº¯Êý¿ÉÒÔ»®·ÖΪÈçÏÂÁ½Àࣺ

    ÓÃÀ´½»»»×Ö½ÚÐòµÄº¯Êý¡£°üÀ¨ArchSwapLE16¡¢ArchSwapBE16 µÈ¡£
    ÓÃÀ´¶Áд±ê×¼I/O Á÷µÄº¯Êý¡£°üÀ¨MGUI_ReadLE16¡¢MGUI_ReadBE16 µÈ¡£

    Ç°Ò»ÀàÓÃÀ´½«Ä³¸ö 16λ¡¢32 λ»òÕß 64 λÕûÊý´Óij¸öÌض¨µÄ×Ö½ÚÐòת»»ÎªÏµÍ³Ë½ÓУ¨native£©×Ö½ÚÐò¡£¾ÙÀýÈçÏ£º
    int fd, len_header;

...

    if (read (fd, &len_header, sizeof (int)) == -1)
        goto error;
#if MGUI_BYTEORDER == MGUI_BIG_ENDIAN
    len_header = ArchSwap32 (len_header);        // Èç¹ûÊÇ Big Endian ϵͳ£¬Ôòת»»×Ö½ÚÐò
#endif
...

    ÔÚÉÏÃæµÄ³ÌÐò¶ÎÖУ¬Ê×ÏÈͨ¹ý read ϵͳµ÷ÓôÓÖ¸¶¨µÄÎļþÃèÊö·ûÖжÁÈ¡Ò»¸öÕûÊýÖµµ½ len_header ±äÁ¿ÖС£¸ÃÎļþÖб£´æµÄÕûÊýÖµÊÇ Little Endian µÄ£¬Òò´ËÈç¹ûÔÚ Big Endian ϵͳÉÏʹÓÃÕâ¸öÕûÊýÖµ£¬¾Í±ØÐë½øÐÐ×Ö½Ú˳Ðò½»»»¡£ÕâÀï¿ÉÒÔʹÓà ArchSwapLE32£¬½« Little Endian µÄ 32 λÕûÊýֵת»»ÎªÏµÍ³Ë½ÓеÄ×Ö½ÚÐò¡£Ò²¿ÉÒÔÈçÉÏÊö³ÌÐò¶ÎÄÇÑù£¬Ö»¶Ô Big Endian ϵͳ½øÐÐ×Ö½ÚÐòת»»£¬Õâʱ£¬Ö»ÒªÀûÓà ArchSwap32 º¯Êý¼´¿É¡£

    MiniGUI ÌṩµÄÓÃÀ´×ª»»×Ö½ÚÐòµÄº¯Êý£¨»òÕߺ꣩ÈçÏ£º

ArchSwapLE16(X) ½«Ö¸¶¨µÄÒÔ Little Endian ×Ö½ÚÐò´æ·ÅµÄ 16 λÕûÊýֵת»»ÎªÏµÍ³Ë½ÓÐÕûÊýÖµ¡£Èç¹ûϵͳ±¾ÉíÊÇ Little Endian ϵͳ£¬Ôò¸Ãº¯Êý²»×÷Èκι¤×÷£¬Ö±½Ó·µ»Ø X£»Èç¹ûϵͳ±¾ÉíÊÇ Big Endian ϵͳ£¬Ôòµ÷Óà ArchSwap16 º¯Êý½»»»×Ö½ÚÐò¡£
ArchSwapLE32(X) ½«Ö¸¶¨µÄÒÔ Little Endian ×Ö½ÚÐò´æ·ÅµÄ 32 λÕûÊýֵת»»ÎªÏµÍ³Ë½ÓÐÕûÊýÖµ¡£Èç¹ûϵͳ±¾ÉíÊÇ Little Endian ϵͳ£¬Ôò¸Ãº¯Êý²»×÷Èκι¤×÷£¬Ö±½Ó·µ»Ø X£»Èç¹ûϵͳ±¾ÉíÊÇ Big Endian ϵͳ£¬Ôòµ÷Óà ArchSwap32 º¯Êý½»»»×Ö½ÚÐò¡£
ArchSwapBE16(X) ½«Ö¸¶¨µÄÒÔ Big Endian ×Ö½ÚÐò´æ·ÅµÄ 16 λÕûÊýֵת»»ÎªÏµÍ³Ë½ÓÐÕûÊýÖµ¡£Èç¹ûϵͳ±¾ÉíÊÇ Big Endian ϵͳ£¬Ôò¸Ãº¯Êý²»×÷Èκι¤×÷£¬Ö±½Ó·µ»Ø X£»Èç¹ûϵͳ±¾ÉíÊÇ Little Endian ϵͳ£¬Ôòµ÷Óà ArchSwap16 º¯Êý½»»»×Ö½ÚÐò¡£
ArchSwapBE32(X) ½«Ö¸¶¨µÄÒÔ Big Endian ×Ö½ÚÐò´æ·ÅµÄ 32 λÕûÊýֵת»»ÎªÏµÍ³Ë½ÓÐÕûÊýÖµ¡£Èç¹ûϵͳ±¾ÉíÊÇ Big Endian ϵͳ£¬Ôò¸Ãº¯Êý²»×÷Èκι¤×÷£¬Ö±½Ó·µ»Ø X£»Èç¹ûϵͳ±¾ÉíÊÇ Little Endian ϵͳ£¬Ôòµ÷Óà ArchSwap32 º¯Êý½»»»×Ö½ÚÐò¡£

    MiniGUI ÌṩµÄµÚ¶þÀຯÊýÓÃÀ´´Ó±ê×¼ I/O µÄÎļþ¶ÔÏóÖжÁд Endian ÕûÊýÖµ¡£Èç¹ûÒª¶ÁÈ¡µÄÎļþÊÇÒÔ Little Endian ×Ö½ÚÐò´æ·ÅµÄ£¬Ôò¿ÉÒÔʹÓà MGUI_ReadLE16 ºÍMGUI_ReadLE32 µÈº¯Êý¶ÁÈ¡ÕûÊýÖµ£¬ÕâЩº¯Êý½«°Ñ¶ÁÈëµÄÕûÊýֵת»»ÎªÏµÍ³Ë½ÓÐ×Ö½ÚÐò£¬·´Ö®Ê¹ÓÃMGUI_ReadBE16 ºÍMGUI_ReadBE32 º¯Êý¡£Èç¹ûҪдÈëµÄÎļþÊÇÒÔ Little Endian ×Ö½ÚÐò´æ·ÅµÄ£¬Ôò¿ÉÒÔʹÓà MGUI_WriteLE16 ºÍMGUI_WriteLE32 µÈº¯Êý¶ÁÈ¡ÕûÊýÖµ£¬ÕâЩº¯Êý½«°ÑҪдÈëµÄÕûÊýÖµ´Óϵͳ˽ÓÐ×Ö½ÚÐòת»»Îª Little Endian ×Ö½ÚÐò£¬È»ºóдÈëÎļþ£¬·´Ö®Ê¹ÓÃMGUI_WriteBE16 ºÍMGUI_WriteBE32 º¯Êý¡£ÏÂÃæµÄ´úÂë¶Î˵Ã÷ÁËÉÏÊöº¯ÊýµÄÓ÷¨£º
    FILE* out;
    int ount;
...
    MGUI_WriteLE32 (out, count);  // ÒÔ Little Endian ×Ö½ÚÐò±£´æ count µ½ÎļþÖС£
...


4.2 ÀûÓÃÌõ¼þ±àÒë±àд¿ÉÒÆÖ²´úÂë
    ÔÚÉæ¼°µ½¿ÉÒÆÖ²ÐÔÎÊÌâµÄʱºò£¬ÓÐʱÎÒÃÇÄܹ»·½±ãµØͨ¹ý 4.1 ÖÐÃèÊöµÄ·½·¨½øÐк¯Êý·â×°£¬´Ó¶øÌṩ¾ßÓÐÁ¼ºÃÒÆÖ²ÐԵĴúÂ룬µ«ÓÐʱÎÒÃÇÎÞ·¨Í¨¹ýº¯Êý·â×°µÄ·½·¨Ìṩ¿ÉÒÆÖ²ÐÔ´úÂë¡£Õâʱ£¬¿ÖÅÂÖ»ÄÜʹÓÃÌõ¼þ±àÒëÁË¡£ÏÂÃæµÄ´úÂë˵Ã÷ÁËÈçºÎʹÓÃÌõ¼þ±àÒëµÄ·½·¨È·±£³ÌÐòÕý³£¹¤×÷£¨¸Ã´úÂëÀ´×Ô MiniGUI src/kernel/sharedres.c£©£º
/* Èç¹ûϵͳ²»Ö§³Ö¹²ÏíÄڴ棬Ôò¶¨Òå _USE_MMAP
#undef  _USE_MMAP
/* #define _USE_MMAP 1 */

void *LoadSharedResource (void)
{
#ifndef _USE_MMAP
    key_t shm_key;
    void *memptr;
    int shmid;
#endif

    /* ×°Ôع²Ïí×ÊÔ´ */
    ...

#ifndef _USE_MMAP /* »ñÈ¡¹²ÏíÄÚ´æ¶ÔÏó */
    if ((shm_key = get_shm_key ()) == -1) {
        goto error;
    }
    shmid = shmget (shm_key, mgSizeRes, SHM_PARAM | IPC_CREAT | IPC_EXCL);
    if (shmid == -1) {
        goto error;
    }

    // Attach to the share memory.
    memptr = shmat (shmid, 0, 0);
    if (memptr == (char*)-1)
        goto error;
    else {
        memcpy (memptr, mgSharedRes, mgSizeRes);
        free (mgSharedRes);
    }

    if (shmctl (shmid, IPC_RMID, NULL) < 0)
        goto error;
#endif

    /* ´ò¿ªÎļþ */
    if ((lockfd = open (LOCKFILE, O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1)
        goto error;

#ifdef _USE_MMAP
    /* Èç¹ûʹÓà mmap£¬¾Í½«¹²Ïí×ÊԴдÈëÎļþ */
    if (write (lockfd, mgSharedRes, mgSizeRes) < mgSizeRes)
        goto error;
    else
    {
        free(mgSharedRes);
        mgSharedRes = mmap( 0, mgSizeRes, PROT_READ|PROT_WRITE, MAP_SHARED, lockfd, 0);
    }
#else
    /* ·ñÔò½«¹²ÏíÄÚ´æ¶ÔÏó ID дÈëÎļþ */
    if (write (lockfd, &shmid, sizeof (shmid)) < sizeof (shmid))
        goto error;
#endif

    close (lockfd);

#ifndef _USE_MMAP
    mgSharedRes = memptr;
    SHAREDRES_SHMID = shmid;
#endif
    SHAREDRES_SEMID = semid;

    return mgSharedRes;

error:
    perror ("LoadSharedResource");
    return NULL;
}

    ÉÏÊö³ÌÐò¶ÎÊÇ MiniGUI-Lite ·þÎñÆ÷³ÌÐòÓÃÀ´×°Ôع²Ïí×ÊÔ´µÄ¡£Èç¹ûϵͳ֧³Ö¹²ÏíÄڴ棬Ôò³õʼ»¯¹²ÏíÄÚ´æ¶ÔÏ󣬲¢½«×°ÔصĹ²Ïí×ÊÔ´¹ØÁªµ½¹²ÏíÄÚ´æ¶ÔÏó£¬È»ºó½«¹²ÏíÄÚ´æ¶ÔÏó ID дÈëÎļþ£»Èç¹ûϵͳ²»Ö§³Ö¹²ÏíÄڴ棬Ôò½«³õʼ»¯ºóµÄ¹²Ïí×ÊÔ´È«²¿Ð´ÈëÎļþ¡£ÔÚ¿Í»§¶Ë£¬Èç¹ûÖ§³Ö¹²ÏíÄڴ棬Ôò¿ÉÒÔ´ÓÎļþÖлñµÃ¹²ÏíÄÚ´æ¶ÔÏó ID£¬²¢Ö±½Ó¹ØÁªµ½¹²ÏíÄڴ棻Èç¹û²»Ö§³Ö¹²ÏíÄڴ棬Ôò¿ÉÒÔʹÓà mmap ϵͳµ÷Ó㬽«ÎļþÓ³Éäµ½½ø³ÌµÄµØÖ·¿Õ¼ä¡£¿Í»§¶ËµÄ´úÂë¶ÎÈçÏ£º
void* AttachSharedResource (void)
{
#ifndef _USE_MMAP
    int shmid;
#endif
    int lockfd;
    void* memptr;

    if ((lockfd = open (LOCKFILE, O_RDONLY)) == -1)
        goto error;

#ifdef _USE_MMAP
    /* ʹÓà mmap ½«¹²Ïí×ÊÔ´Ó³Éäµ½½ø³ÌµØÖ·¿Õ¼ä */
    mgSizeRes = lseek (lockfd, 0, SEEK_END );
    memptr = mmap( 0, mgSizeRes, PROT_READ, MAP_SHARED, lockfd, 0);
#else
    /* ·ñÔò»ñÈ¡¹²ÏíÄÚ´æ¶ÔÏó ID£¬²¢¹ØÁª¸Ã¹²ÏíÄÚ´æ */
    if (read (lockfd, &shmid, sizeof (shmid)) < sizeof (shmid))
        goto error;
    close (lockfd);

    memptr = shmat (shmid, 0, SHM_RDONLY);
#endif
    if (memptr == (char*)-1)
        goto error;
    return memptr;

error:
    perror ("AttachSharedResource");
    return NULL;
}

5 ÆäËû

5.1 ¶ÁдÅäÖÃÎļþ
MiniGUI µÄÅäÖÃÎļþ£¬¼´ /etc/MiniGUI.cfg ÎļþµÄ¸ñʽ£¬²ÉÓÃÁËÀàËÆ Windows INI ÎļþµÄ¸ñʽ¡£ÕâÖÖÎļþ¸ñʽ·Ç³£¼òµ¥£¬ÈçÏÂËùʾ£º
[section-name1]
key-name1=key-value1
key-name2=key-value2

[section-name2]
key-name3=key-value3
key-name4=key-value4

    ÕâÖÖÅäÖÃÎļþÖеIJÎÊýÒÔ section ·Ö×飬ȻºóÓà key=value µÄÐÎʽָ¶¨²ÎÊý¼°ÆäÖµ¡£Ó¦ÓóÌÐòÒ²¿ÉÒÔÀûÓÃÕâÖÖÅäÖÃÎļþ¸ñʽ±£´æһЩÅäÖÃÐÅÏ¢£¬Îª´Ë£¬MiniGUI ÌṩÁËÈçÏÂÈý¸öº¯Êý£¨include/minigui.h£©£º
int GUIAPI GetValueFromEtcFile (const char* pEtcFile, const char* pSection,const char* pKey, char* pValue, int iLen);
int GUIAPI GetIntValueFromEtcFile (const char* pEtcFile, const char* pSection,const char* pKey, int* value);
int GUIAPI SetValueToEtcFile (const char* pEtcFile, const char* pSection, const char* pKey, char* pValue);

ÕâÈý¸öº¯ÊýµÄÓÃ;ÈçÏ£º

    ·GetValueFromEtcFile£º´ÓÖ¸¶¨µÄÅäÖÃÎļþµ±ÖлñÈ¡Ö¸¶¨µÄ¼üÖµ£¬¼üÖµÒÔ×Ö·û´®ÐÎʽ·µ»Ø¡£
    ·GetIntValueFromEtcFile£º´ÓÖ¸¶¨µÄÅäÖÃÎļþµ±ÖлñÈ¡Ö¸¶¨µÄÕûÊýÐͼüÖµ¡£¸Ãº¯Êý½«»ñµÃµÄ×Ö·û´®×ª»»ÎªÕûÊýÖµ·µ»Ø£¨²ÉÓÃstrtol º¯Êýת»»£©¡£
    ·SetValueToEtcFile£º¸Ãº¯Êý½«¸ø¶¨µÄ¼üÖµ±£´æµ½Ö¸¶¨µÄÅäÖÃÎļþµ±ÖУ¬Èç¹ûÅäÖÃÎļþ²»´æÔÚ£¬Ôò½«Ð½¨ÅäÖÃÎļþ¡£Èç¹û¸ø¶¨µÄ¼üÒÑ´æÔÚ£¬Ôò½«¸²¸Ç¾ÉÖµ¡£

¼Ù¶¨Ä³¸öÅäÖÃÎļþ¼Ç¼ÁËһЩӦÓóÌÐòÐÅÏ¢£¬²¢¾ßÓÐÈçϸñʽ£º
[mginit]
nr=8
autostart=0

[app0]
path=../tools/
name=vcongui
layer=
tip=Virtual&console&on&MiniGUI
icon=res/konsole.gif

[app1]
path=../bomb/
name=bomb
layer=
tip=Game&of&Minesweaper
icon=res/kmines.gif

[app2]
path=../controlpanel/
name=controlpanel
layer=
tip=Control&Panel
icon=res/kcmx.gif

    ÆäÖÐµÄ [mginit] ¶Î¼Ç¼ÁËÓ¦ÓóÌÐò¸öÊý£¨nr¼ü£©£¬ÒÔ¼°×Ô¶¯Æô¶¯µÄÓ¦ÓóÌÐòË÷Òý£¨autostart¼ü£©¡£¶ø [appX] ¶Î¼Ç¼ÁËÿ¸öÓ¦ÓóÌÐòµÄÐÅÏ¢£¬°üÀ¨¸ÃÓ¦ÓóÌÐòµÄ·¾¶¡¢Ãû³Æ¡¢Í¼±êµÈµÈ¡£ÏÂÃæµÄ´úÂëÑÝʾÁËÈçºÎʹÓà MiniGUµÄÅäÖÃÎļþº¯Êý»ñÈ¡ÕâЩÐÅÏ¢£¨¸Ã´úÂë¶ÎÀ´×Ô mde ÑÝʾ°üÖÐµÄ mginit ³ÌÐò£©£º
#define APP_INFO_FILE "mginit.rc"

static BOOL get_app_info (void)
{
    int i;
    APPITEM* item;

    /* »ñÈ¡Ó¦ÓóÌÐò¸öÊýÐÅÏ¢ */
    if (GetIntValueFromEtcFile (APP_INFO_FILE, "mginit", "nr", &app_info.nr_apps) != ETC_OK)
        return FALSE;

    if (app_info.nr_apps <= 0)
        return FALSE;

    /* »ñÈ¡×Ô¶¯Æô¶¯µÄÓ¦ÓóÌÐòË÷Òý */
    GetIntValueFromEtcFile (APP_INFO_FILE, "mginit", "autostart", &app_info.autostart);

    if (app_info.autostart >= app_info.nr_apps || app_info.autostart < 0)
        app_info.autostart = 0;

    /* ·ÖÅäÓ¦ÓóÌÐòÐÅÏ¢½á¹¹ */
    if ((app_info.app_items = (APPITEM*)calloc (app_info.nr_apps, sizeof (APPITEM))) == NULL) {
        return FALSE;
    }

    /* »ñȡÿ¸öÓ¦ÓóÌÐòµÄ·¾¶¡¢Ãû³Æ¡¢Í¼±êµÈÐÅÏ¢ */
    item = app_info.app_items;
    for (i = 0; i < app_info.nr_apps; i++, item++) {
        char section [10];

        sprintf (section, "app%d", i);
        if (GetValueFromEtcFile (APP_INFO_FILE, section, "path", item->path, PATH_MAX) != ETC_OK)
            goto error;

        if (GetValueFromEtcFile (APP_INFO_FILE, section, "name", item->name, NAME_MAX) != ETC_OK)
            goto error;

        if (GetValueFromEtcFile (APP_INFO_FILE, section, "layer", item->layer, LEN_LAYER_NAME) != ETC_OK)
            goto error;

        if (GetValueFromEtcFile (APP_INFO_FILE, section, "tip", item->tip, TIP_MAX) != ETC_OK)
            goto error;

        strsubchr (item->tip, '&', ' ');

        if (GetValueFromEtcFile (APP_INFO_FILE, section, "icon", item->bmp_path, PATH_MAX + NAME_MAX) != ETC_OK)
            goto error;

        if (LoadBitmap (HDC_SCREEN, &item->bmp, item->bmp_path) != ERR_BMP_OK)
            goto error;

        item->cdpath = TRUE;
    }
    return TRUE;

error:
    free_app_info ();
    return FALSE;
}

5.2 ¶¨µãÊýÔËËã
    ͨ³£ÔÚ½øÐÐÊýѧÔËËãʱ£¬ÎÒÃDzÉÓø¡µãÊý±íʾʵÊý£¬²¢ÀûÓà ͷÎļþÖÐËùÉùÃ÷µÄº¯Êý½øÐи¡µãÊýÔËËã¡£ÎÒÃÇÖªµÀ£¬¸¡µãÊýÔËËãÊÇÒ»Öַdz£ºÄʱµÄÔËËã¹ý³Ì¡£ÎªÁ˼õÉÙÒòΪ¸¡µãÊýÔËËã¶ø´øÀ´µÄ¶îÍâ CPU Ö¸ÁÔÚһЩÈýάͼÐο⵱ÖУ¬Í¨³£»á²ÉÓö¨µãÊýÀ´±íʾʵÊý£¬²¢ÀûÓö¨µãÊý½øÐÐÔËË㣬ÕâÑù£¬½«´ó´óÌá¸ßÈýάͼÐεÄÔËËãËٶȡ£MiniGUI Ò²ÌṩÁËһЩ¶¨µãÊýÔËË㺯Êý£¬·ÖΪÈçϼ¸Àࣺ

    ÕûÊý¡¢¸¡µãÊýºÍ¶¨µãÊýÖ®¼äµÄת»»¡£ÀûÓà itofix ºÍ fixtoi º¯Êý¿ÉʵÏÖÕûÊýºÍ¶¨µãÊýÖ®¼äµÄÏ໥ת»»£»ÀûÓà ftofix ºÍ fixtof º¯Êý¿ÉʵÏÖ¸¡µãÊýºÍ¶¨µãÊýÖ®¼äµÄת»»¡£
¶¨µãÊý¼Ó¡¢¼õ¡¢³Ë¡¢³ýµÈ»ù±¾ÔËËã¡£ÀûÓà fadd¡¢fsub¡¢fmul¡¢fdiv¡¢fsqrtµÈº¯Êý¿ÉʵÏÖ¶¨µãÊý¼Ó¡¢¼õ¡¢³Ë¡¢³ýÒÔ¼°Æ½·½¸ùÔËËã¡£
    ¶¨µãÊýµÄÈý½ÇÔËËã¡£ÀûÓà fcos¡¢fsin¡¢ftan¡¢facos¡¢fasin µÈº¯Êý¿ÉÇó¸ø¶¨¶¨µãÊýµÄÓàÏÒ¡¢ÕýÏÒ¡¢ÕýÇС¢·´ÓàÏÒ¡¢·´ÕýÏÒÖµ¡£
    ¾ØÕó¡¢ÏòÁ¿µÈÔËËã¡£¾ØÕó¡¢ÏòÁ¿Ïà¹ØÔËËãÔÚÈýάͼÐÎÖзdz£ÖØÒª£¬ÏÞÓÚƪ·ù£¬±¾ÎIJ»»áÏêϸ½²ÊöÕâЩÔËË㣬¶ÁÕ߿ɲÎÔÄMiniGUI µÄ include/fixedmath.h Í·Îļþ¡£

    ÏÂÃæµÄ´úÂë¶ÎÑÝʾÁ˶¨µãÊýµÄÓ÷¨£¬¸Ã³ÌÐò¶Î¸ù¾Ý¸ø¶¨µÄÈý¸öµã£¨pts[0]¡¢pts[1]¡¢pts[2]£©»­Ò»¸ö»¡Ïߣ¬ÆäÖÐ pts[0] ×÷ΪԲÐÄ£¬pts[1] ÊÇÔ²»¡µÄÆðµã£¬¶ø pts[2] ÊÇÔ²»¡ÖÕµãºÍÔ²ÐÄÁ¬ÏßÉϵÄÒ»¸öµã£º
void draw_arc (HDC hdc, POINT* pts)
{
            int sx = pts [0].x, sy = pts [0].y;
            int dx = pts [1].x - sx, dy = pts [1].y - sy;
            int r = sqrt (dx * dx * 1.0 + dy * dy * 1.0);
            double cos_d = dx * 1.0 / r;
            fixed cos_f = ftofix (cos_d);
            fixed ang1 = facos (cos_f);
            int r2;
            fixed ang2;

            if (dy > 0) {
                ang1 = fsub (0, ang1);
            }

            dx = pts [2].x - sx;
            dy = pts [2].y - sy;
            r2 = sqrt (dx * dx * 1.0 + dy * dy * 1.0);
            cos_d = dx * 1.0 / r2;
            cos_f = ftofix (cos_d);
            ang2 = facos (cos_f);
            if (dy > 0) {
                ang2 = fsub (0, ang2);
            }

            Arc (hdc, sx, sy, r, ang1, ang2);
}

    ÉÏÊö³ÌÐòµÄ¼ÆËã·Ç³£¼òµ¥£¬²½ÖèÈçÏ£¨¸Ã³ÌÐò¶ÎÀ´×Ô mde ÑÝʾ³ÌÐò°üÖÐµÄ painter/painter.c ³ÌÐò£©£º

    ¸ù¾Ý pts[0] ºÍ pts[1] ¼ÆËãÔ²»¡µÄ°ë¾¶£¬È»ºó¼ÆËãÔ²»¡µÄÆðʼƫ½Ç£¬¼´ ang1£¬Ê¹ÓÃÁËftofix º¯ÊýºÍ facos º¯Êý¡£
    ¼ÆËã pts[2] µãºÍÔ²ÐÄÁ¬Ïߵļнǣ¬¼´ ang2£¬Ê¹ÓÃÁË ftofix ºÍ facos º¯Êý¡£
µ÷Óà Arc º¯Êý»æÖÆÔ²»¡¡£

6 С½á
    ±¾ÎĽ²ÊöÁË MiniGUI ΪӦÓóÌÐòÌṩµÄһЩ·Ç GUI/GDI µÄ½Ó¿Ú¡£ÕâЩ½Ó¿ÚÖУ¬Ä³Ð©ÊÇΪÁ˽â¾öºÍ²Ù×÷ϵͳµÄ½»»¥¶øÉè¼ÆµÄ£¬ÒÔ±ã MiniGUI Ó¦ÓóÌÐòÄܹ»¸üºÃµØÓë²Ù×÷ϵͳÌṩµÄ»úÖÆÈÚºÏÔÚÒ»Æ𣻶øijЩÌṩÁË¶Ô UNIX Domain Socket Á¼ºÃ·â×°µÄ½Ó¿Ú£¬¿É°ïÖúÓ¦ÓóÌÐò·½±ã½øÐнø³Ì¼äͨѶ»òÕßÀ©Õ¹Æ书ÄÜ£»ÆäËû½Ó¿ÚÔòרעÓÚǶÈëʽϵͳµÄÌØÊâÐÔ£¬ÎªÓ¦ÓóÌÐòÌṩÁË¿ÉÒÆÖ²µÄÎļþ I/O ·â×°´úÂë¡£ÔÚÕâЩ½Ó¿ÚµÄ°ïÖúÏ£¬Ç¶Èëʽϵͳ¿ª·¢ÈËÔ±¿ÉÒÔ±àд¹¦ÄÜÇ¿´ó¶øÁé»îµÄÓ¦ÓóÌÐò¡£

[Ŀ¼]


MiniGUI ºÍÆäËûǶÈëʽ Linux ÉϵÄͼÐμ°Í¼ÐÎÓû§½çÃæϵͳ

1 Linux ͼÐÎÁìÓòµÄ»ù´¡ÉèÊ©
    ±¾Ð¡½ÚÊ×ÏÈÏò¶ÁÕßÃèÊö Linux ͼÐÎÁìÓòÖг£¼ûµÄ»ù´¡ÉèÊ©¡£Ö®ËùÒÔ³ÆΪ»ù´¡ÉèÊ©£¬ÊÇÒòΪÕâЩϵͳ£¨»òÕߺ¯Êý¿â£©£¬Ò»°ã×÷ΪÆäËû¸ß¼¶Í¼ÐλòÕßͼÐÎÓ¦ÓóÌÐòµÄ»ù±¾º¯Êý¿â¡£ÕâЩϵͳ£¨»òÕߺ¯Êý¿â£©°üÀ¨£ºX Window¡¢SVGALib¡¢FrameBuffer µÈµÈ¡£

1.1 X Window
    ÌáÆð Linux ÉϵÄͼÐΣ¬Ðí¶àÈËÊ×ÏÈÏëµ½µÄÊÇ X Window¡£ÕâһϵͳÊÇÄ¿Ç°Àà UNIX ϵͳÖд¦ÓÚ¿ØÖƵØλµÄ×ÀÃæͼÐÎϵͳ¡£ÎÞÒÉ£¬X Window ×÷Ϊһ¸öͼÐλ·¾³Êdzɹ¦µÄ£¬ËüÉÏÃæÔËÐÐ×Å°üÀ¨ CAD½¨Ä£¹¤¾ßºÍ°ì¹«Ì×¼þÔÚÄڵĴóÁ¿Ó¦ÓóÌÐò¡£µ«±ØÐë¿´µ½µÄÊÇ£¬ÓÉÓÚ X Window ÔÚÌåϵ½Ó¿ÚÉϵÄÔ­Òò£¬ÏÞÖÆÁËÆä¶ÔÓÎÏ·¡¢¶àýÌåµÄÖ§³ÖÄÜÁ¦¡£Óû§ÔÚ X Window ÉÏÔËÐÐ VCD ²¥·ÅÆ÷£¬»òÕßÔËÐÐһЩ´óÐ͵ÄÈýάÓÎϷʱ£¬¾­³£»á·¢ÏÖͬÑùµÄÓ²¼þÅäÖã¬È´²»ÄÜ»ñµÃºÍ Windows ²Ù×÷ϵͳһÑùµÄͼÐÎЧ¹û¨D¨D¼´Ê¹Ê¹ÓÃÁ˼ÓËÙµÄ X Server£¬ÆäЧ¹ûÒ²²»ÄÜÁîÈËÂúÒâ¡£ÁíÍ⣬´óÐ͵ÄÓ¦ÓóÌÐò£¨±ÈÈç Mozilla ä¯ÀÀÆ÷£©ÔÚ X Window ÉÏÔËÐÐʱµÄÏìÓ¦ÄÜÁ¦£¬Ò²Ï൱²»ÄÜÁîÈËÂúÒâ¡£µ±È»£¬ÕâÀïÓÐ Linux ÄÚºËÔÚ½ø³Ìµ÷¶ÈÉϵÄÎÊÌ⣬ҲÓÐ X Window µÄÔ­Òò¡£

    X Window ΪÁËÂú×ã¶ÔÓÎÏ·¡¢¶àýÌåµÈÓ¦ÓöÔͼÐμÓËÙÄÜÁ¦µÄÒªÇó£¬ÌṩÁË DGA£¨Ö±½ÓͼÐηÃÎÊ£©À©Õ¹£¬Í¨¹ý¸ÃÀ©Õ¹£¬Ó¦ÓóÌÐò¿ÉÒÔÔÚÈ«ÆÁģʽÏÂÖ±½Ó·ÃÎÊÏÔʾ¿¨µÄÖ¡»º³åÇø£¬²¢Äܹ»Ìṩ¶ÔijЩ¼ÓËÙ¹¦ÄܵÄÖ§³Ö¡£

    Tiny-XÊÇXServerÔÚǶÈëʽϵͳµÄСÇÉʵÏÖ£¬ËüÓÉXfree86 Core Team µÄKeith Packard¿ª·¢¡£ËüµÄÄ¿±êÊÇÔËÐÐÓÚСÄÚ´æϵͳ»·¾³¡£µäÐ͵ÄÔËÐÐÓÚX86 CPU ÉϵÄTiny-X Server ³ß´ç½Ó½ü£¨Ð¡ÓÚ£©1MB¡£

1.2 SVGALib
    SVGALib ÊÇ Linux ϵͳÖÐ×îÔç³öÏÖµÄ·Ç X ͼÐÎÖ§³Ö¿â¡£Õâ¸ö¿â´Ó×î³õ¶Ô±ê×¼ VGA ¼æÈÝоƬµÄÖ§³Ö¿ªÊ¼£¬Ò»Ö±·¢Õ¹µ½¶ÔÀÏʽ SVGA оƬµÄÖ§³ÖÒÔ¼°¶ÔÏÖ½ñÁ÷Ðеĸ߼¶ÊÓƵоƬµÄÖ§³Ö¡£ËüΪÓû§ÌṩÁËÔÚ¿ØÖÆ̨ÉϽøÐÐͼÐαà³ÌµÄ½Ó¿Ú£¬Ê¹Óû§¿ÉÒÔÔÚ PC ¼æÈÝϵͳÉÏ·½±ãµØ»ñµÃͼÐÎÖ§³Ö¡£µ«¸ÃϵͳÓÐÈçϲ»×㣺

    ½Ó¿ÚÔÓÂÒ¡£SVGALib ´Ó×î³õµÄ vgalib ·¢Õ¹¶øÀ´£¬±£ÁôÁËÀÏϵͳµÄÐí¶à½Ó¿Ú£¬¶øÕâЩ½Ó¿ÚÈ´²»ÄÜÁ¼ºÃµØÓ­ºÏÐÂÏÔʾоƬµÄͼÐÎÄÜÁ¦¡£
    δÄܽϺõØÒþ²ØÓ²¼þϸ½Ú¡£Ðí¶à²Ù×÷£¬²»ÄÜ×Ô¶¯Ê¹ÓÃÏÔʾоƬµÄ¼ÓËÙÄÜÁ¦Ö§³Ö¡£
¿ÉÒÆÖ²ÐԲSVGALib Ä¿Ç°Ö»ÄÜÔËÐÐÔÚ x86 ƽ̨ÉÏ£¬¶ÔÆäËûƽ̨µÄÖ§³ÖÄÜÁ¦½Ï²î£¨Alpha ƽ̨³ýÍ⣩¡£
    ·¢Õ¹»ºÂý£¬Óб»ÆäËûͼÐοâÈ¡´úµÄ¿ÉÄÜ¡£SVGALib ×÷Ϊһ¸öÀϵÄͼÐÎÖ§³Ö¿â£¬Ä¿Ç°µÄÓ¦Ó÷¶Î§Ô½À´Ô½Ð¡£¬ÓÈÆäÔÚ Linux ÄÚºËÔö¼ÓÁË FrameBuffer Çý¶¯Ö§³ÖÖ®ºó£¬ÓÐÖð½¥±»ÆäËûͼÐοâÌæ´úµÄ¼£Ïó¡£
    ¶ÔÓ¦ÓõÄÖ§³ÖÄÜÁ¦½Ï²î¡£SVAGLib ×÷Ϊһ¸öͼÐο⣬¶Ô¸ß¼¶Í¼Ðι¦ÄܵÄÖ§³Ö£¬±ÈÈçÖ±ÏߺÍÇúÏߵȵȣ¬È´²»ÄÜÁîÈËÂúÒâ¡£¾¡¹Ü SVGALib ÓÐÐí¶àȱµã£¬µ« SVGALib ¾­³£±»ÆäËûͼÐοâÓÃÀ´³õʼ»¯Ìض¨Ð¾Æ¬µÄÏÔʾģʽ£¬²¢»ñµÃÓ³Éäµ½½ø³ÌµØÖ·¿Õ¼äµÄÏßÐÔÏÔʾÄÚ´æÊ×µØÖ·£¨¼´Ö¡»º³åÇø£©£¬¶øÆäËûµÄ½Ó¿ÚÈ´ºÜÉÙÓõ½¡£ÁíÍ⣬SVGALib ÖÐËù°üº¬µÄÖîÈç¼üÅÌ¡¢Êó±êºÍÓÎÏ·¸ËµÄ½Ó¿Ú£¬Ò²ºÜÉÙ±»ÆäËûÓ¦ÓóÌÐòËùʹÓá£

    Òò´Ë£¬SVGALib µÄʹÓÃÔ½À´Ô½ÉÙ£¬±ÊÕßÒ²²»½¨ÒéÓû§Ê¹ÓÃÕâ¸öͼÐο⡣µ±È»£¬Èç¹ûÓû§µÄÏÔʾ¿¨Ö»Ö§³Ö±ê×¼ VGA ģʽ£¬Ôò SVGALib »¹ÊDZȽϺõÄÑ¡Ôñ¡£

1.3 FrameBuffer
    FrameBuffer ÊdzöÏÖÔÚ 2.2.xx Äں˵±ÖеÄÒ»ÖÖÇý¶¯³ÌÐò½Ó¿Ú¡£ÕâÖÖ½Ó¿Ú½«ÏÔʾÉ豸³éÏóΪ֡»º³åÇø¡£Óû§¿ÉÒÔ½«Ëü¿´³ÉÊÇÏÔʾÄÚ´æµÄÒ»¸öÓ³Ïñ£¬½«ÆäÓ³Éäµ½½ø³ÌµØÖ·¿Õ¼äÖ®ºó£¬¾Í¿ÉÒÔÖ±½Ó½øÐжÁд²Ù×÷£¬¶øд²Ù×÷¿ÉÒÔÁ¢¼´·´Ó¦ÔÚÆÁÄ»ÉÏ¡£¸ÃÇý¶¯³ÌÐòµÄÉ豸ÎļþÒ»°ãÊÇ /dev/fb0¡¢/dev/fb1 µÈµÈ¡£±ÈÈ磬¼ÙÉèÏÖÔÚµÄÏÔʾģʽÊÇ 1024x768-8 λɫ£¬Ôò¿ÉÒÔͨ¹ýÈçϵÄÃüÁîÇå¿ÕÆÁÄ»£º

$ dd if=/dev/zero of=/dev/fb0 bs=1024 count=768

    ÔÚÓ¦ÓóÌÐòÖУ¬Ò»°ãͨ¹ý½« FrameBuffer É豸ӳÉäµ½½ø³ÌµØÖ·¿Õ¼äµÄ·½Ê½Ê¹Ó㬱ÈÈçÏÂÃæµÄ³ÌÐò¾Í´ò¿ª /dev/fb0 É豸£¬²¢Í¨¹ý mmap ϵͳµ÷ÓýøÐеØÖ·Ó³É䣬ËæºóÓà memset ½«ÆÁÄ»Çå¿Õ£¨ÕâÀï¼ÙÉèÏÔʾģʽÊÇ 1024x768-8 λɫģʽ£¬ÏßÐÔÄÚ´æģʽ£©£º

int fb;
unsigned char* fb_mem;

fb = open ("/dev/fb0", O_RDWR);
fb_mem = mmap (NULL, 1024*768, PROT_READ|PROT_WRITE,MAP_SHARED,fb,0);

memset (fb_mem, 0, 1024*768);


    FrameBuffer É豸»¹ÌṩÁËÈô¸É ioctl ÃüÁͨ¹ýÕâЩÃüÁ¿ÉÒÔ»ñµÃÏÔʾÉ豸µÄһЩ¹Ì¶¨ÐÅÏ¢£¨±ÈÈçÏÔʾÄÚ´æ´óС£©¡¢ÓëÏÔʾģʽÏà¹ØµÄ¿É±äÐÅÏ¢£¨±ÈÈç·Ö±æÂÊ¡¢ÏóËؽṹ¡¢Ã¿É¨ÃèÏßµÄ×Ö½Ú¿í¶È£©£¬ÒÔ¼°Î±²Êɫģʽϵĵ÷É«°åÐÅÏ¢µÈµÈ¡£

    ͨ¹ý FrameBuffer É豸£¬»¹¿ÉÒÔ»ñµÃµ±Ç°ÄÚºËËùÖ§³ÖµÄ¼ÓËÙÏÔʾ¿¨µÄÀàÐÍ£¨Í¨¹ý¹Ì¶¨ÐÅÏ¢µÃµ½£©£¬ÕâÖÖÀàÐÍͨ³£ÊǺÍÌض¨ÏÔʾоƬÏà¹ØµÄ¡£±ÈÈçÄ¿Ç°×îеÄÄںˣ¨2.4.9£©ÖУ¬¾Í°üº¬ÓÐ¶Ô S3¡¢Matrox¡¢nVidia¡¢3Dfx µÈµÈÁ÷ÐÐÏÔʾоƬµÄ¼ÓËÙÖ§³Ö¡£ÔÚ»ñµÃÁ˼ÓËÙоƬÀàÐÍÖ®ºó£¬Ó¦ÓóÌÐò¾Í¿ÉÒÔ½« PCI É豸µÄÄÚ´æI/O£¨memio£©Ó³Éäµ½½ø³ÌµÄµØÖ·¿Õ¼ä¡£ÕâЩ memio Ò»°ãÊÇÓÃÀ´¿ØÖÆÏÔʾ¿¨µÄ¼Ä´æÆ÷£¬Í¨¹ý¶ÔÕâЩ¼Ä´æÆ÷µÄ²Ù×÷£¬Ó¦ÓóÌÐò¾Í¿ÉÒÔ¿ØÖÆÌض¨ÏÔ¿¨µÄ¼ÓËÙ¹¦ÄÜ¡£

    PCI É豸¿ÉÒÔ½«×Ô¼ºµÄ¿ØÖƼĴæÆ÷Ó³Éäµ½ÎïÀíÄÚ´æ¿Õ¼ä£¬¶øºó£¬¶ÔÕâЩ¿ØÖƼĴæÆ÷µÄ·ÃÎÊ£¬¸ø±ä³ÉÁ˶ÔÎïÀíÄÚ´æµÄ·ÃÎÊ¡£Òò´Ë£¬ÕâЩ¼Ä´æÆ÷ÓÖ±»³ÆΪ"memio"¡£Ò»µ©±»Ó³Éäµ½ÎïÀíÄڴ棬Linux µÄÆÕͨ½ø³Ì¾Í¿ÉÒÔͨ¹ý mmap ½«ÕâЩÄÚ´æ I/O Ó³Éäµ½½ø³ÌµØÖ·¿Õ¼ä£¬ÕâÑù¾Í¿ÉÒÔÖ±½Ó·ÃÎÊÕâЩ¼Ä´æÆ÷ÁË¡£

    µ±È»£¬ÒòΪ²»Í¬µÄÏÔʾоƬ¾ßÓв»Í¬µÄ¼ÓËÙÄÜÁ¦£¬¶Ômemio µÄʹÓúͶ¨ÒåÒ²¸÷×Ô²»Í¬£¬Õâʱ£¬¾ÍÐèÒªÕë¶Ô¼ÓËÙоƬµÄ²»Í¬ÀàÐÍÀ´±àдʵÏÖ²»Í¬µÄ¼ÓËÙ¹¦ÄÜ¡£±ÈÈç´ó¶àÊýоƬ¶¼ÌṩÁ˶ԾØÐÎÌî³äµÄÓ²¼þ¼ÓËÙÖ§³Ö£¬µ«²»Í¬µÄоƬʵÏÖ·½Ê½²»Í¬£¬Õâʱ£¬¾ÍÐèÒªÕë¶Ô²»Í¬µÄоƬÀàÐͱàд²»Í¬µÄÓÃÀ´Íê³ÉÌî³ä¾ØÐεĺ¯Êý¡£

    ˵µ½ÕâÀ¶ÁÕß¿ÉÄÜÒѾ­Òâʶµ½ FrameBuffer Ö»ÊÇÒ»¸öÌṩÏÔʾÄÚ´æºÍÏÔʾоƬ¼Ä´æÆ÷´ÓÎïÀíÄÚ´æÓ³Éäµ½½ø³ÌµØÖ·¿Õ¼äÖеÄÉ豸¡£ËùÒÔ£¬¶ÔÓÚÓ¦ÓóÌÐò¶øÑÔ£¬Èç¹ûÏ£ÍûÔÚ FrameBuffer Ö®ÉϽøÐÐͼÐαà³Ì£¬»¹ÐèÒªÍê³ÉÆäËûÐí¶à¹¤×÷¡£¾Ù¸öÀý×ÓÀ´½²£¬FrameBuffer ¾ÍÏñÒ»ÕÅ»­²¼£¬Ê¹ÓÃʲôÑù×ӵĻ­±Ê£¬ÈçºÎ»­»­£¬»¹ÐèÒªÄã×Ô¼º¶¯ÊÖÍê³É¡£

1.4 LibGGI
    LibGGI ÊÔͼ½¨Á¢Ò»¸öÒ»°ãÐÔµÄͼÐνӿڣ¬¶øÕâ¸ö³éÏó½Ó¿ÚÁ¬Í¬Ïà¹ØµÄÊäÈ루Êó±ê¡¢¼üÅÌ¡¢ÓÎÏ·¸ËµÈ£©³éÏó½Ó¿ÚÒ»Æ𣬿ÉÒÔ·½±ãµØÔËÐÐÔÚ X Window¡¢SVGALib¡¢FrameBuffer µÈµÈÖ®ÉÏ¡£½¨Á¢ÔÚ LibGGI Ö®ÉϵÄÓ¦ÓóÌÐò£¬²»¾­ÖØбàÒ룬¾Í¿ÉÒÔÔÚÉÏÊöÕâЩµ×²ãͼÐνӿÚÉÏÔËÐС£µ«²»ÖªºÎ¹Ê£¬LibGGI µÄ·¢Õ¹¼¸ºõÍ£ÖÍ¡£

2 Linux ͼÐÎÁìÓòµÄ¸ß¼¶º¯Êý¿â

2.1 Xlib ¼°ÆäËûÏà¹Øº¯Êý¿â
    ÔÚ X Window ϵͳÖнøÐÐͼÐαà³Ìʱ£¬¿ÉÒÔÑ¡ÔñÖ±½ÓʹÓà Xlib¡£Xlib ʵ¼ÊÊǶԵײã X ЭÒéµÄ·â×°£¬¿Éͨ¹ý¸Ãº¯Êý¿â½øÐÐÒ»°ãµÄͼÐÎÊä³ö¡£Èç¹ûÄãµÄ X Server Ö§³Ö DGA£¬Ôò¿ÉÒÔͨ¹ý DGA À©Õ¹Ö±½Ó·ÃÎÊÏÔʾÉ豸£¬´Ó¶ø»ñµÃ¼ÓËÙÖ§³Ö¡£¶ÔÒ»°ãÓû§¶øÑÔ£¬ÓÉÓÚ Xlib µÄ½Ó¿Ú̫ԭʼ¶øÇÒ¸´ÔÓ£¬Òò´ËÒ»°ãµÄͼÐγÌÐòÑ¡ÔñÆäËû¸ß¼¶Ò»Ð©µÄͼÐοâ×÷Ϊ»ù´¡¡£±ÈÈ磬GTK¡¢QT µÈµÈ¡£ÕâÁ½¸öº¯Êýͬʱ»¹ÊÇһЩ¸ß¼¶µÄͼÐÎÓû§½çÃæÖ§³Öº¯Êý¿â¡£ÓÉÓÚÖÖÖÖÔ­Òò£¬GTK¡¢QT µÈº¯Êý¿â´æÔÚÓÐÅÓ´ó¡¢Õ¼ÓÃϵͳ×ÊÔ´¶àµÄÎÊÌ⣬²»Ì«ÊʺÏÔÚǶÈëʽϵͳÖÐʹÓá£Õâʱ£¬Äã¿ÉÒÔÑ¡ÔñʹÓà FLTK£¬ÕâÊÇÒ»¸öÇáÁ¿¼¶µÄͼÐκ¯Êý¿â£¬µ«ËüµÄÖ÷Òª¹¦Äܼ¯ÖÐÔÚÓû§½çÃæÉÏ£¬ÌṩÁ˽ÏΪ·á¸»µÄ¿Ø¼þ¼¯¡£

2.2 SDL
    SDL£¨Simple DirectMedia Layer£©ÊÇÒ»¸ö¿çƽ̨µÄ¶àýÌåÓÎÏ·Ö§³Ö¿â¡£ÆäÖаüº¬Á˶ÔͼÐΡ¢ÉùÒô¡¢ÓÎÏ·¸Ë¡¢Ï̵߳ȵȵÄÖ§³Ö£¬Ä¿Ç°¿ÉÒÔÔËÐÐÔÚÐí¶àƽ̨ÉÏ£¬ÆäÖаüÀ¨ X Window¡¢X Window with DGA¡¢Linux FrameBuffer ¿ØÖÆ̨¡¢Linux SVGALib£¬ÒÔ¼°Windows DirectX¡¢BeOS µÈµÈ¡£

    ÒòΪ SDL רÃÅΪÓÎÏ·ºÍ¶àýÌåÓ¦ÓöøÉè¼Æ¿ª·¢£¬ËùÒÔËü¶ÔͼÐεÄÖ§³Ö·Ç³£ÓÅÐ㣬ÓÈÆäÊǸ߼¶Í¼ÐÎÄÜÁ¦£¬±ÈÈç Alpha »ìºÍ¡¢Í¸Ã÷´¦Àí¡¢YUV ¸²¸Ç¡¢Gamma УÕýµÈµÈ¡£¶øÇÒÔÚ SDL »·¾³ÖÐÄܹ»·Ç³£·½±ãµØ¼ÓÔØÖ§³Ö OpenGL µÄ Mesa ¿â£¬´Ó¶øÌṩ¶Ô¶þάºÍÈýάͼÐεÄÖ§³Ö¡£

    ¿ÉÒÔ˵£¬SDL ÊDZàд¿çƽ̨ÓÎÏ·ºÍ¶àýÌåÓ¦ÓõÄ×î¼Ñƽ̨£¬Ò²µÄÈ·µÃµ½Á˹㷺ӦÓá£Ïà¹ØÐÅÏ¢£¬¿É²ÎÔÄ http://www.libsdl.org¡£

2.3 Allegro
    Allegro ÊÇÒ»¸öרÃÅΪ x86 ƽ̨Éè¼ÆµÄÓÎϷͼÐο⡣×î³õµÄ Allegro ÔËÐÐÔÚ DOS »·¾³Ï£¬¶øÄ¿Ç°¿ÉÔËÐÐÔÚ Linux FrameBuffe ¿ØÖÆ̨¡¢Linux SVGALib¡¢X Window µÈϵͳÉÏ¡£Allegro ÌṩÁËһЩ·á¸»µÄͼÐι¦ÄÜ£¬°üÀ¨¾ØÐÎÌî³äºÍÑùÌõÇúÏßÉú³ÉµÈµÈ£¬¶øÇÒ¾ßÓнϺõÄÈýάͼÐÎÏÔʾÄÜÁ¦¡£ÓÉÓÚ Allegro µÄÐí¶à¹Ø¼ü´úÂëÊDzÉÓûã±à±àдµÄ£¬ËùÒԸú¯Êý¿â¾ßÓÐÔËÐÐËٶȿ졢×ÊÔ´Õ¼ÓÃÉÙµÄÌص㡣Ȼ¶ø£¬Allegro Ò²´æÔÚÈçÏÂȱµã£º

    ·¶ÔÏ̵߳ÄÖ§³Ö½Ï²î¡£Allegro µÄÐí¶àº¯ÊýÊÇ·ÇḬ̈߳²È«µÄ£¬²»ÄÜͬʱÔÚÁ½¸öÒÔÉϵÄÏß³ÌÖÐʹÓá£
    ·Ó²¼þ¼ÓËÙÄÜÁ¦µÄÖ§³Ö²»×㣬ÔÚÉè¼ÆÉÏûÓÐΪӲ¼þ¼ÓËÙÌṩ½Ó¿Ú¡£

    ÓÐ¹Ø Allegro µÄ½øÒ»²½ÐÅÏ¢£¬¿É²ÎÔÄhttp://www.allegro.cc/¡£

2.4 Mesa3D
    Mesa3D ÊÇÒ»¸ö¼æÈÝ OpenGL ¹æ·¶µÄ¿ª·ÅÔ´Â뺯Êý¿â£¬ÊÇÄ¿Ç° Linux ÉÏÌṩרҵÈýάͼÐÎÖ§³ÖµÄΩһѡÔñ¡£Mesa3D ͬʱҲÊÇÒ»¸ö¿çƽ̨µÄº¯Êý¿â£¬Äܹ»ÔËÐÐÔÚ X Window¡¢X Window with DGA¡¢BeOS¡¢Linux SVGALib µÈƽ̨ÉÏ¡£

    ÓÐ¹Ø Mesa3D µÄ½øÒ»²½ÐÅÏ¢£¬¿É²ÎÔÄ http://www.mesa3d.org/¡£

2.5 DirectFB
    DirectFB ÊÇרעÓÚ Linux FrameBuffer ¼ÓËÙµÄÒ»¸öͼÐο⣬²¢ÊÔͼ½¨Á¢Ò»¸ö¼æÈÝ GTK µÄǶÈëʽ GUI ϵͳ¡£ËüÒÔ¿É×°Ôغ¯Êý¿âµÄÐÎÊÆÌṩ¶Ô¼ÓËÙ FrameBuffer Çý¶¯³ÌÐòµÄÖ§³Ö¡£Ä¿Ç°£¬¸Ãº¯Êý¿âÕýÔÚ¿ª·¢Ö®ÖУ¨×îа汾 0.9.97£©£¬ÏêÇé¿É¼û http://www.directfb.org/¡£

3 ÃæÏòǶÈëʽLinux ϵͳµÄͼÐÎÓû§½çÃæ

3.1 MicoroWindows/NanoX
    MicroWindows£¨http://microwindows.censoft.com£©ÊÇÒ»¸ö¿ª·ÅÔ´ÂëµÄÏîÄ¿£¬Ä¿Ç°ÓÉÃÀ¹ú Century Software ¹«Ë¾Ö÷³Ö¿ª·¢¡£¸ÃÏîÄ¿µÄ¿ª·¢Ò»¶È·Ç³£»îÔ¾£¬¹úÄÚÒ²ÓÐÈ˲ÎÓëÁËÆäÖеĿª·¢£¬²¢±àдÁË GB2312 µÈ×Ö·û¼¯µÄÖ§³Ö¡£µ«ÔÚ Qt/Embedded ·¢²¼ÒÔÀ´£¬¸ÃÏîÄ¿±äµÃ²»Ì«»îÔ¾£¬²¢³¤Ê±¼äÍ£ÁôÔÚ 0.89Pre7 °æ±¾¡£¿ÉÒÔ˵£¬ÒÔ¿ª·ÅÔ´ÂëÐÎÊÆ·¢Õ¹µÄ MicroWindows ÏîÄ¿£¬»ù±¾Í£ÖÍ¡£

    MicroWindows ÊÇÒ»¸ö»ùÓÚµäÐÍ¿Í»§/·þÎñÆ÷Ìåϵ½á¹¹µÄ GUI ϵͳ£¬»ù±¾·ÖΪÈý²ã¡£×îµ×²ãÊÇÃæÏòͼÐÎÊä³öºÍ¼üÅÌ¡¢Êó±ê»ò´¥ÃþÆÁµÄÇý¶¯³ÌÐò£»Öмä²ãÌṩµ×²ãÓ²¼þµÄ³éÏó½Ó¿Ú£¬²¢½øÐд°¿Ú¹ÜÀí£»×î¸ß²ã·Ö±ðÌṩ¼æÈÝÓÚ X Window ºÍ Windows CE£¨Win32 ×Ó¼¯£©µÄ API¡£

    ¸ÃÏîÄ¿µÄÖ÷ÒªÌØÉ«ÔÚÓÚÌṩÁËÀàËÆ X µÄ¿Í»§/·þÎñÆ÷Ìåϵ½á¹¹£¬²¢ÌṩÁËÏà¶ÔÍêÉƵÄͼÐι¦ÄÜ£¬°üÀ¨Ò»Ð©¸ß¼¶µÄ¹¦ÄÜ£¬±ÈÈç Alpha »ìºÏ£¬Èýά֧³Ö£¬TrueType ×ÖÌåÖ§³ÖµÈ¡£µ«ÐèҪעÒâµÄÊÇ£¬MicroWindows µÄͼÐÎÒýÇæ´æÔÚÐí¶àÎÊÌ⣬¿ÉÒÔ¹éÄÉÈçÏ£º

ÎÞÈκÎÓ²¼þ¼ÓËÙÄÜÁ¦¡£
    ͼÐÎÒýÇæÖдæÔÚÐí¶àµÍЧËã·¨£¬Í¬Ê±Î´¾­ÈκÎÓÅ»¯¡£±ÈÈçÔÚÖ±Ïß»òÕßÔ²»¡»æͼº¯ÊýÖУ¬´æÔÚµÍЧµÄÖðµãÅжϼôÇеÄÎÊÌâ¡£
    ´úÂëÖÊÁ¿½Ï²î¡£ÓÉÓÚ¸ÃÏîĿȱÉÙÒ»¸öÇ¿ÓÐÁ¦µÄºËÐÄ´úÂëά»¤ÈËÔ±£¬Òò´Ë´úÂëÖÊÁ¿²Î²î²»Æ룬ӰÏìÕûÌåϵͳÎȶ¨ÐÔ¡£ÕâÒ²ÊÇ MicroWindows ³¤Ê±¼äÍ£ÁôÔÚ 0.89Pre7 °æ±¾ÉϵÄÔ­Òò¡£

MicroWindows ²ÉÓà MPL Ìõ¿î·¢²¼£¨¸ÃÌõ¿î»ù±¾ÀàËÆ LGPL Ìõ¿î£©¡£

3.2 OpenGUI
    OpenGUI£¨http://www.tutok.sk/fastgl/£©ÔÚ Linux ϵͳÉÏ´æÔÚÒѾ­ºÜ³¤Ê±¼äÁË¡£×î³õµÄÃû×ֽРFastGL£¬Ö»Ö§³Ö 256 É«µÄÏßÐÔÏÔ´æģʽ£¬µ«Ä¿Ç°Ò²Ö§³ÖÆäËûÏÔʾģʽ£¬²¢ÇÒÖ§³Ö¶àÖÖ²Ù×÷ϵͳƽ̨£¬±ÈÈç MS-DOS¡¢QNX ºÍ Linux µÈµÈ£¬²»¹ýÄ¿Ç°Ö»Ö§³Ö x86 Ó²¼þƽ̨¡£OpenGUI Ò²·ÖΪÈý²ã¡£×îµÍ²ãÊÇÓÉ»ã±à±àдµÄ¿ìËÙͼÐÎÒýÇ棻Öмä²ãÌṩÁËͼÐλæÖÆ API£¬°üÀ¨ÏßÌõ¡¢¾ØÐΡ¢Ô²»¡µÈ£¬²¢ÇÒ¼æÈÝÓÚ Borland µÄ BGI API¡£µÚÈý²ãÓà C++ ±àд£¬ÌṩÁËÍêÕûµÄ GUI ¶ÔÏ󼯡£

    OpenGUI ²ÉÓà LGPL Ìõ¿î·¢²¼¡£OpenGUI ±È½ÏÊʺÏÓÚ»ùÓÚ x86 ƽ̨µÄʵʱϵͳ£¬¿ÉÒÆÖ²ÐÔÉԲĿǰµÄ·¢Õ¹Ò²»ù±¾Í£ÖÍ¡£

3.3 Qt/Embedded
    Qt/EmbeddedÊÇÖøÃûµÄ Qt ¿â¿ª·¢ÉÌ TrollTech£¨http://www.trolltech.com/£©·¢²¼µÄÃæÏòǶÈëʽϵͳµÄ Qt °æ±¾¡£ÒòΪ Qt ÊÇ KDE µÈÏîĿʹÓÃµÄ GUI Ö§³Ö¿â£¬ËùÒÔÓÐÐí¶à»ùÓÚ Qt µÄ X Window ³ÌÐò¿ÉÒԷdz£·½±ãµØÒÆÖ²µ½ Qt/Embedded °æ±¾ÉÏ¡£Òò´Ë£¬×Ô´Ó Qt/Embedded ÒÔ GPL Ìõ¿îÐÎÊÆ·¢²¼ÒÔÀ´£¬¾ÍÓдóÁ¿µÄǶÈëʽ Linux ¿ª·¢ÉÌתµ½ÁË Qt/Embedded ϵͳÉÏ¡£±ÈÈ纫¹úµÄ Mizi ¹«Ë¾£¬Ì¨ÍåÊ¡µÄijЩǶÈëʽ Linux Ó¦Óÿª·¢É̵ȵȡ£

    ²»¹ý£¬ÔÚ±ÊÕß¿´À´£¬Qt/Embedded »¹ÓÐһЩÎÊÌâÖµµÃ¿ª·¢Õß×¢Ò⣺

    Ä¿Ç°£¬¸Ãϵͳ²ÉÓÃÁ½ÖÖÌõ¿î·¢²¼£¬ÆäÖаüÀ¨ GPL Ìõ¿î¡£¶Ôº¯Êý¿âʹÓà GPL Ìõ¿î£¬Òâζ×ÅÆäÉϵÄÓ¦ÓÃÐèÒª×ñÑ­ GPL Ìõ¿î¡£µ±È»ÁË£¬Èç¹ûÒª¿ª·¢ÉÌÒµ³ÌÐò£¬TrollTech Ò²ÔÊÐíÄã²ÉÓÃÁíÍâÒ»¸öÊÚȨÌõ¿î£¬Õâʱ£¬¾Í±ØÐëÏò TrollTech ½»ÄÉÊÚȨ·ÑÓÃÁË¡£
    Qt/Embedded ÊÇÒ»¸ö C++ º¯Êý¿â£¬¾¡¹Ü Qt/Embedded Éù³Æ¿ÉÒԲüôµ½×îÉÙ 630K£¬µ«ÕâʱµÄ Qt/Embedded ¿âÒѾ­»ù±¾ÉÏʧȥÁËʹÓüÛÖµ¡£µÍµÄ³ÌÐòЧÂÊ¡¢´óµÄ×ÊÔ´ÏûºÄÒ²¶ÔÔËÐÐ Qt/Embedded µÄÓ²¼þÌá³öÁ˸ü¸ßµÄÒªÇó¡£
Qt/Embedded ¿âÄ¿Ç°Ö÷ÒªÕë¶ÔÊÖ³ÖʽÐÅÏ¢Öնˣ¬ÒòΪ¶ÔÓ²¼þ¼ÓËÙÖ§³ÖµÄØÑ·¦£¬ºÜÄÑÓ¦Óõ½¶ÔͼÐÎËٶȡ¢¹¦ÄܺÍЧÂÊÒªÇó½Ï¸ßµÄǶÈëʽϵͳµ±ÖУ¬±ÈÈç»ú¶¥ºÐ¡¢ÓÎÏ·Öն˵ȵȡ£
    Qt/Embedded ÌṩµÄ¿Ø¼þ¼¯·ç¸ñÑØÓÃÁË PC ·ç¸ñ£¬²¢²»Ì«ÊʺÏÐí¶àÊÖ³ÖÉ豸µÄ²Ù×÷ÒªÇó¡£
    Qt/Embedded µÄ½á¹¹¹ýÓÚ¸´ÔÓ£¬ºÜÄѽøÐеײãµÄÀ©³ä¡¢¶¨ÖƺÍÒÆÖ²£¬ÓÈÆäÊÇÄǸöÓÃÀ´ÊµÏÖ signal/slot »úÖƵÄÖøÃûµÄ moc Îļþ¡£

    ÒòΪÉÏÊöÕâЩԭÒò£¬Ä¿Ç°Ëù¼ûµ½µÄ Qt/Embedded µÄÔËÐл·¾³£¬¼¸ºõÊÇÇåһɫ»ùÓÚ StrongARM µÄ iPAQ¡£

3.4 MiniGUI
    MiniGUI£¨http://www.minigui.org£©ÊÇÓɱÊÕßÖ÷³Ö£¬²¢ÓÉÐí¶à×ÔÓÉÈí¼þ¿ª·¢ÈËÔ±Ö§³ÖµÄÒ»¸ö×ÔÓÉÈí¼þÏîÄ¿£¨×ñÑ­ LGPL Ìõ¿î·¢²¼£©£¬ÆäÄ¿±êÊÇΪ»ùÓÚ Linux µÄʵʱǶÈëʽϵͳÌṩһ¸öÇáÁ¿¼¶µÄͼÐÎÓû§½çÃæÖ§³Öϵͳ¡£¸ÃÏîÄ¿×Ô 1998 Äêµ×¿ªÊ¼µ½ÏÖÔÚ£¬ÒÑÀú¾­ 3 Äê¶àµÄ¿ª·¢¹ý³Ì¡£µ½Ä¿Ç°ÎªÖ¹£¬ÒѾ­·Ç³£³ÉÊìºÍÎȶ¨¡£Ä¿Ç°£¬ÎÒÃÇÒѾ­Õýʽ·¢²¼ÁËÎȶ¨°æ±¾ 1.0.9£¬²¢ÇÒ¿ªÊ¼ÁËа汾ϵÁеĿª·¢£¬¼´ MiniGUI Version 1.1.x£¬¸ÃϵÁеÄÕýʽ°æÒ²¼´½«·¢²¼¡£

    ÔÚ MiniGUI ¼¸ÄêµÄ·¢Õ¹¹ý³ÌÖУ¬ÓÐÐí¶àÖµµÃÒ»ÌáµÄ¼¼Êõ´´Ðµ㣬ÕýÊÇÓÉÓÚÕâЩ¼¼ÊõÉϵĴ´Ð£¬²ÅʹµÃ MiniGUI ¸ü¼ÓÊʺÏʵʱǶÈëʽϵͳ£»¶øÇÒ MiniGUI µÄÁé»îÐԷdz£ºÃ£¬¿ÉÒÔÓ¦ÓÃÔÚ°üÀ¨ÊÖ³ÖÉ豸¡¢»ú¶¥ºÐ¡¢ÓÎÏ·Öն˵ȵÈÔÚÄڵĸ÷Öָ߶˻òÕߵͶ˵ÄǶÈëʽϵͳµ±ÖС£ÕâЩ¼¼Êõ´´Ð°üÀ¨£º

    ͼÐγéÏó²ã¡£Í¼ÐγéÏó²ã¶Ô¶¥²ã API »ù±¾Ã»ÓÐÓ°Ï죬µ«´ó´ó·½±ãÁË MiniGUI Ó¦ÓóÌÐòµÄÒÆÖ²¡¢µ÷ÊԵȹ¤×÷¡£Ä¿Ç°°üº¬Èý¸öͼÐÎÒýÇ棬SVGALib¡¢LibGGI ÒÔ¼°Ö±½Ó»ùÓÚ Linux FrameBuffer µÄ Native Engine£¬ÀûÓà LibGGI ʱ£¬¿ÉÔÚ X Window ÉÏÔËÐÐ MiniGUI Ó¦ÓóÌÐò£¬²¢¿É·Ç³£·½±ãµØ½øÐе÷ÊÔ¡£ÓëͼÐγéÏó²ãÏà¹ØµÄ»¹ÓÐÊäÈëʼþµÄ³éÏó²ã¡£MiniGUI ÏÖÔÚÒѾ­±»Ö¤Ã÷Äܹ»ÔÚ»ùÓÚ ARM¡¢MIPS¡¢StrongARM ÒÔ¼° PowerPC µÈµÄǶÈëʽϵͳÉÏÁ÷³©ÔËÐС£
¶à×ÖÌåºÍ¶à×Ö·û¼¯Ö§³Ö¡£Õⲿ·Öͨ¹ýÉ豸ÉÏÏÂÎÄ£¨DC£©µÄÂß¼­×ÖÌ壨LOGFONT£©ÊµÏÖ£¬²»¹ÜÊÇ×ÖÌåÀàÐÍ»¹ÊÇ×Ö·û¼¯£¬¶¼¿ÉÒԷdz£·½±ãµØ½øÐÐÀ©³ä¡£Ó¦ÓóÌÐòÔÚÆô¶¯Ê±£¬¿ÉÇл»ÏµÍ³×Ö·û¼¯£¬±ÈÈç GB¡¢BIG5¡¢EUCKR¡¢UJIS¡£ÀûÓà DrawText µÈº¯Êýʱ£¬¿Éͨ¹ýÖ¸¶¨×ÖÌå¶ø»ñµÃÆäËû×Ö·û¼¯Ö§³Ö¡£¶ÔÓÚÒ»¸ö´°¿ÚÀ´Ëµ£¬Í¬Ê±ÏÔʾ²»Í¬ÓïÖÖµÄÎÄ×ÖÊÇ¿ÉÄܵġ£MiniGUI µÄÕâÖÖ×Ö·û¼¯Ö§³Ö²»Í¬ÓÚ´«Í³Í¨¹ý UNICODE ʵÏֵĶà×Ö·û¼¯Ö§³Ö£¬ÕâÖÖʵÏÖ¸ü¼ÓÊʺÏÓÚǶÈëʽϵͳ¡£
Á½¸ö²»Í¬¼Ü¹¹µÄ°æ±¾¡£×î³õµÄ MiniGUI ÔËÐÐÔÚ PThread ¿âÖ®ÉÏ£¬Õâ¸ö°æ±¾ÊʺÏÓÚ¹¦Äܵ¥Ò»µÄǶÈëʽϵͳ£¬µ«´æÔÚϵͳ½¡×³ÐÔ²»¹»µÄȱµã¡£ÔÚ 0.9.98 °æ±¾ÖУ¬ÎÒÃÇÒýÈëÁË MiniGUI-Lite °æ±¾£¬Õâ¸ö°æ±¾ÔÚÌá¸ßϵͳ½¡×³ÐÔµÄͬʱ£¬Í¨¹ýһϵÁд´ÐÂ;¾¶£¬±ÜÃâÁË´«Í³ C/S ½á¹¹µÄÈõµã£¬Îª¹¦Äܸ´ÔÓµÄǶÈëʽϵͳÌṩÁËÒ»¸ö¸ßЧ¡¢Îȶ¨µÄ GUI ϵͳ¡£

    ÔÚ MiniGUI 1.1.0 °æ±¾µÄ¿ª·¢ÖУ¬ÎÒÃDzÎÕÕ SDL ºÍ Allegro µÄͼÐβ¿·Ö£¬ÖØÐÂÉè¼ÆÁËͼÐγéÏó²ã£¬²¢ÔöÇ¿ÁËͼÐι¦ÄÜ£¬Í¬Ê±ÔöÇ¿ÁË MiniGUI-Lite °æ±¾µÄijЩÌØÐÔ¡£ÕâЩÌØÐÔ°üÀ¨£º

    MiniGUI-Lite Ö§³Ö²ãµÄ¸ÅÄͬһ²ã¿ÉÈÝÄɶà¸öÄܹ»Í¬Ê±ÏÔʾµÄ¿Í»§³ÌÐò£¬²¢Æ½ÆÌÔÚÆÁÄ»ÉÏÏÔʾ¡£
Ð嵀 GAL Äܹ»Ö§³ÖÓ²¼þ¼ÓËÙÄÜÁ¦£¬²¢Äܹ»³ä·ÖʹÓÃÏÔʾÄڴ棻РGAL Ö®ÉϵÄРGDI ½Ó¿ÚµÃµ½½øÒ»²½ÔöÇ¿¡£Ð嵀 GDI ½Ó¿Ú¿ÉÒÔÖ§³Ö Alpha »ìºÍ¡¢Í¸Ã÷λ¿é´«Êä¡¢¹âÕ¤²Ù×÷¡¢YUV¸²¸Ç¡¢Gamma УÕý£¬ÒÔ¼°¸ß¼¶Í¼Ðι¦ÄÜ£¨ÍÖÔ²¡¢¶à±ßÐΡ¢ÑùÌõÇúÏߣ©µÈµÈ¡£

    MiniGUI а汾ÔÚͼÐη½ÃæµÄÔöÇ¿ºÍÌá¸ß£¬½«´ó´óÀ©Õ¹ËüµÄÓ¦ÓÃÁìÓò£¬Ï£ÍûÄܹ»¶ÔǶÈëʽ Linux ÉϵĶàýÌåÓ¦Óá¢ÓÎÏ·¿ª·¢Ìṩ֧³Ö¡£

    ×ݹÛǶÈëʽ Linux ϵͳÉϵĸ÷ÖÖͼÐÎϵͳ·½°¸£¬ÎÒÃÇ·¢ÏÖ£¬Ðí¶àͼÐÎϵͳ£¨Èç Qt/Embedded ºÍ MicoroWindows£©£¬Ö»×¢ÖØÊÖ³ÖÉ豸ÉϵÄÐèÇó£¬È´²»Ì«×¢ÖØÆäËûÓ¦ÓÃÁìÓòµÄÐèÇ󣬶øÆäËûÐí¶àÐèҪͼÐÎÖ§³ÖµÄǶÈëʽ Linux ϵͳȴÐèÒªÐí¶à¶ÀÌصġ¢¸ß¼¶µÄͼÐι¦ÄÜ£¬¶ø²»½ö½öÊÇͼÐÎÓû§½çÃ档Ϊ´Ë£¬ÔÚ½ÓÏÂÀ´µÄ¿ª·¢ÖУ¬ÎÒÃÇ»¹½«ÔÚÈçÏÂÁìÓò¼ÌÐø¿ª·¢ MiniGUI£º

    ·ÌṩÔËÐÐÔÚ MiniGUI É쵀 JAVA ÐéÄâ»ú AWT ×é¼þµÄʵÏÖ¡£
    ·Ìṩ MiniGUI É쵀 OpenGL ʵÏÖ¡£
    ·ÌṩÀà QT ¿Ø¼þ¼¯µÄ C++ ·â×°¡£
    ·Ìṩ´°¿Ú/¿Ø¼þ·ç¸ñÖ÷ÌâÖ§³Ö¡£
    ·ÔÚ MiniGUI-Lite µ±ÖÐÔö¼Ó¶ÔʸÁ¿×ÖÌåµÄÖ§³Ö¡£

4 С½á
    ×ÛÉÏËùÊö£¬±ÊÕßÈÏΪÔÚǶÈëʽ Linux ͼÐÎÁìÓò£¬»¹ÓÐÐí¶àÓдý¿ª·¢ÈËÔ±×ÐϸÑо¿ºÍ½â¾öµÄÎÊÌâ¡£MiniGUI µÄеķ¢Õ¹£¬Ò²ÕýÔ´ÓÚ¶ÔÕâЩÐèÇóµÄÈÏʶ֮ÉÏ¡£ÎÒÃÇÒ²ÖÔÐÄÏ£ÍûÄܹ»Óиü¶àµÄ×ÔÓÉÈí¼þ¿ª·¢ÈËÔ±¼ÓÃË MiniGUI µÄ¿ª·¢£¬Ò»Í¬¿ª·¢ÐµÄǶÈëʽ Linux µÄͼÐÎϵͳ¡£

[Ŀ¼]


LiteµÄиĽø

    MiniGUI´Ó0.98¿ªÊ¼ÍƳöLite°æ±¾¡£Lite°æ±¾ÊÇMiniGUIÂõÏòǶÈëʽӦÓÃÖØÒªµÄÒ»²½¡£ÔÚLite°æ±¾ÖУ¬ÎÒÃÇʹÓÃÁË×Ô¼ºÉè¼ÆµÄÒýÇ棬Å×ÆúÁËpthread¿â£¬´Ó¶øʹµÃMiniGUIÄܹ»Çá×°ÉÏÕ󣬸üÎȶ¨£¬¸ü¸ßЧÂÊ£¬Ò²¸ü·ûºÏǶÈëʽϵͳӦÓᣱ¾ÎĽéÉÜÁËMiniGUI Lite°æ±¾µÄ»ùÓÚUnix IPCʵÏֵĶà½ø³Ì»úÖÆ¡£²¢Ïêϸ½éÉÜÁËһЩʵÏÖϸ½Ú¡£

1 ÒýÑÔ£ºÎªÊ²Ã´Òª¿ª·¢Lite°æ±¾

    ÏÖÔÚ£¬´ó¶àÊýUNIXϵͳ²ÉÓÃX ´°¿Úϵͳ×÷ΪͼÐÎÓû§½çÃ棬MS Windows Ôò²ÉÓà Microsoft¹«Ë¾×Ô¼ºÉè¼ÆµÄGUIϵͳ¡£ÕâÁ½ÖÖGUIϵͳҲ´ú±í×ÅĿǰͨÓÃGUIϵͳµÄÁ½ÖÖʵÏÖ¡£±ÈÈ磬ÖøÃûµÄ×ÔÓÉÈí¼þMicroWindows¾ÍͬʱʵÏÖÁËÀàËÆÓÚMS WindowsµÄMicroWindows API ºÍÀàËÆÓÚX WindowµÄNanoX API¡£

    MiniGUI Ô­À´¾Í²ÉÓÃÁËÀàËÆÓÚMS WindowsµÄÌåϵ½á¹¹£¬²¢ÇÒ½¨Á¢ÁË»ùÓÚÏ̵߳ÄÏûÏ¢´«µÝºÍ´°¿Ú¹ÜÀí»úÖÆ¡£È»¶ø£¬ËüÊÇ»ùÓÚPOSIX Ï̵߳ģ¬ÕâÖÖʵÏÖÌṩ×î´ó³Ì¶ÈÉϵÄÊý¾Ý¹²Ïí£¬µ«Ò²Í¬Ê±Ôì³ÉMiniGUIÌåϵ½á¹¹ÉϵĴàÈõ¡£Èç¹ûij¸öÏß³ÌÒòΪ·Ç·¨µÄÊý¾Ý·ÃÎʶøÖÕÖ¹ÔËÐУ¬ÔòÕû¸öϵͳ¶¼½«Êܵ½Ó°Ïì¡£

    ÁíÒ»ÖÖ·½·¨ÊDzÉÓÃUNIX½ø³Ì¼äͨÐÅ»úÖƽ¨Á¢´°¿Úϵͳ£¬¼´ÀàËÆ X Window µÄ¿Í»§/·þÎñÆ÷Ìåϵ¡£µ«ÊÇÕâÖÖÌåϵ½á¹¹Ò²ÓÐËüµÄÏÈÌì²»×㣬Ö÷ÒªÊÇͨ³£µÄ IPC »úÖÆÎÞ·¨Ìṩ¸ßЧµÄÊý¾Ý¸´ÖÆ£¬´óÁ¿µÄ CPU ×ÊÔ´ÓÃÓÚ¸÷½ø³ÌÖ®¼ä¸´ÖÆÊý¾Ý¡£ÔÚ PDA µÈÉ豸ÖУ¬ÕâÖÖ CPU ×ÊÔ´µÄÀ˷ѽ«×îÖÕµ¼ÖÂϵͳÐÔÄܵĽµµÍÒÔ¼°É豸ºÄµçÁ¿µÄÔö¼Ó¡£

    ΪÁ˽â¾öÒÔÉϸ÷ÖÖÎÊÌ⣬ͬʱҲΪÁËÈà MiniGUI¸ü¼ÓÊʺÏÓÚǶÈëʽϵͳ£¬ÎÒÃÇ¿ª·¢ÁËMiniGUI Lite °æ±¾¡£

2 Lite°æ±¾¼ò½é

    ÔÚMiniGUI Lite °æ±¾ÖУ¬ÎÒÃÇ¿ÉÒÔͬʱÔËÐжà¸ö MiniGUI Ó¦ÓóÌÐò¡£Ê×ÏÈÎÒÃÇÆô¶¯Ò»¸ö·þÎñÆ÷³ÌÐò mginit£¬È»ºóÎÒÃÇ¿ÉÒÔ´ÓÖÐÆô¶¯ÆäËû×öΪ¿Í»§ÔËÐÐµÄ MiniGUI Ó¦ÓóÌÐò¡£Èç¹ûÒòΪijÖÖÔ­Òò¿Í»§ÖÕÖ¹£¬·þÎñÆ÷¿ÉÒÔ¼ÌÐøÔËÐС£mginit³ÌÐò½¨Á¢ÁËÒ»¸öÐéÄâ¿ØÖÆ̨´°¿Ú¡£ÎÒÃÇ¿ÉÒÔ´ÓÕâ¸öÐéÄâ¿ØÖÆ̨µÄÃüÁîÐÐÆô¶¯ÆäËûµÄ³ÌÐò£¬ÉõÖÁ¿ÉÒÔͨ¹ý gdb µ÷ÊÔÕâЩ³ÌÐò¡£ Õâ´ó´ó·½±ãÁËMiniGUIÓ¦ÓóÌÐòµÄµ÷ÊÔ¡£

    MiniGUI-Lite Çø±ðÓÚ MiniGUI Ô­Óа汾µÄ×î´ó²»Í¬ÔÚÓÚÎÒÃÇ¿ÉÒÔÔÚ MiniGUI-Lite ³ÌÐòÖд´½¨¶à¸ö´°¿Ú£¬µ«²»ÄÜÆô¶¯ÐµÄÏ߳̽¨Á¢´°¿Ú¡£³ý´ËÖ®Í⣬ÆäËû¼¸ºõËùÓÐµÄ API ¶¼ºÍ MiniGUI Ô­Óа汾ÊǼæÈݵġ£Òò´Ë£¬´Ó MiniGUI Ô­Óа汾Ïò MiniGUI-Lite °æ±¾µÄÒÆÖ²ÊǷdz£¼òµ¥µÄ¡£Ïómglite-exec °üÖеijÌÐò£¬ÆäÖÐËùÓеijÌÐò¾ùÀ´×Ô miniguiexec °ü£¬¶øÿ¸öÔ´ÎļþµÄ¸Ä¶¯²»³¬¹ý 5 ÐС£

3 Lite°æ±¾µÄÉè¼Æ

    Éè¼ÆÖ®³õ£¬ÎÒÃÇÈ·¶¨MiniGUI Lite °æ±¾µÄ¿ª·¢Ä¿µÄ£º

    ·±£³ÖÓëÔ­ÏÈ MiniGUI °æ±¾ÔÚÔ´´úÂ뼶 98% ÒÔÉϵļæÈÝ¡£
    ·²»ÔÙʹÓà LinuxThreads¡£
    ·¿ÉÒÔͬʱÔËÐжà¸ö»ùÓÚ MiniGUI Lite µÄÓ¦ÓóÌÐò£¬¼´¶à¸ö½ø³Ì£¬²¢ÇÒÌṩǰºǫ́½ø³ÌµÄÇл»¡£

    ÏÔÈ»£¬ÒªÂú×ãÕâÈý¸öÉè¼ÆÄ¿µÄ£¬Èç¹û²ÉÓô«Í³µÄ C/S ½á¹¹¶ÔÏÖÓÐ MiniGUI ½øÐиÄÔ죬Ӧ¸Ã²»ÄÑʵÏÖ¡£µ«´«Í³ C/S ½á¹¹µÄȱÏÝÈ´ÎÞ·¨±ÜÃâ¡£¾­¹ý¶Ô PDA µÈǶÈëʽϵͳµÄ·ÖÎö£¬ÎÒÃÇ·¢ÏÖ£¬Ä³Ð© PDA ²úÆ·¾ßÓÐÔËÐжà¸öÈÎÎñµÄÄÜÁ¦£¬µ«Í¬Ò»Ê±¿ÌÔÚÆÁÄ»ÉϽøÐлæÖƵijÌÐò£¬Ò»°ã²»»á³¬¹ýÁ½¸ö¡£Òò´Ë£¬Ö»ÒªÈ·±£½«ÕâÁ½¸ö½ø³ÌµÄ»æÖÆÏ໥¸ôÀ룬¾Í²»ÐèÒª²ÉÓø´Ô C/S ½á¹¹´¦Àí¶à¸ö½ø³Ì´°¿ÚÖ®¼äµÄ»¥Ïà¼ôÇС£ÔÚÕâÖÖ²úÆ·ÖУ¬Èç¹û²ÉÓûùÓÚ´«Í³ C/S ½á¹¹µÄ¶à´°¿Úϵͳ£¬Êµ¼ÊÊÇÒ»ÖÖÀË·Ñ¡£

Òò´Ë£¬ÎÒÃÇ¶Ô MiniGUI-Lite °æ±¾½øÐÐÁËÈçϼò»¯Éè¼Æ£º

    ÿ¸ö½ø³Ìά»¤×Ô¼ºµÄÖ÷´°¿Ú Z Ðò£¬Í¬Ò»½ø³Ì´´½¨µÄÖ÷´°¿ÚÖ®¼ä»¥Ïà¼ôÇС£Ò²¾ÍÊÇ˵£¬³ýÁËÖ»ÓÐÒ»¸öỊ̈߳¬Ö»ÓÐÒ»¸öÏûϢѭ»·Ö®Í⣬һ¸ö½ø³ÌÓëÔ­ÓÐµÄ MiniGUI °æ±¾Ö®¼äûÓÐÈκÎÇø±ð¡£Ã¿¸ö½ø³ÌÔÚ½øÐÐÆÁÄ»»æÖÆʱ£¬²»ÐèÒª¿¼ÂÇÆäËû½ø³Ì¡£
    ½¨Á¢Ò»¸ö¼òµ¥µÄ¿Í»§/·þÎñÆ÷Ìåϵ£¬µ«È·±£×îС»¯½ø³Ì¼äµÄÊý¾Ý¸´Öƹ¦ÄÜ¡£Òò´Ë£¬ÔÚ·þÎñÆ÷ºÍ¿Í»§Ö®¼ä´«µÝµÄÊý¾Ý½öÏÞÓÚÊäÈëÉ豸µÄÊäÈëÊý¾Ý£¬ÒÔ¼°¿Í»§ºÍ·þÎñÆ÷Ö®¼äµÄijЩÇëÇóºÍÏìÓ¦Êý¾Ý¡£
ÓÐÒ»¸ö·þÎñÆ÷½ø³Ì£¨mginit£©£¬Ëü¸ºÔð³õʼ»¯Ò»Ð©ÊäÈëÉ豸£¬²¢ÇÒͨ¹ý UNIX Domain Ì×½Ó×Ö½«ÊäÈëÉ豸µÄÏûÏ¢·¢Ë͵½Ç°Ì¨µÄ MiniGUI Lite ¿Í»§½ø³Ì¡£
    ·þÎñÆ÷ºÍ¿Í»§±»·Ö±ðÏÞ¶¨ÔÚÆÁÄ»µÄijÁ½¸ö²»Ïཻ¾ØÐÎÄÚ½øÐлæÖÆ£¬Í¬Ò»Ê±¿Ì£¬Ö»ÄÜÓÐÒ»¸ö¿Í»§¼°·þÎñÆ÷½øÐÐÆÁÄ»»æÖÆ¡£ÆäËû¿Í»§¿É¼ÌÐøÔËÐУ¬µ«ÆÁÄ»ÊäÈë±»ÆÁ±Î¡£·þÎñÆ÷¿ÉÒÔÀûÓà API ½Ó¿Ú½«Ä³¸ö¿Í»§Çл»µ½Ç°Ì¨¡£Í¬Ê±£¬·þÎñÆ÷ºÍ¿Í»§Ö®¼ä²ÉÓÃÐÅºÅºÍ System V ÐźÅÁ¿½øÐÐͬ²½¡£
    ·þÎñÆ÷»¹²ÉÓà System V IPC »úÖÆÌṩһЩ×ÊÔ´µÄ¹²Ïí£¬°üÀ¨Î»Í¼¡¢Í¼±ê¡¢Êó±ê¡¢×ÖÌåµÈµÈ£¬ÒÔ±ã¼õÉÙʵ¼ÊÄÚ´æµÄÏûºÄ¡£
4 Lite°æ±¾µÄһЩʵÏÖϸ½Ú

4.1 ϵͳ³õʼ»¯
    Ó¦ÓóÌÐòµÄÈë¿ÚµãΪmain()º¯Êý£¬¶øMiniGUIÓ¦ÓóÌÐòµÄÈë¿ÚµãΪMiniGUIMain£¬ÔÚÕâÁ½¸öÈë¿ÚµãÖ®¼ä£¬ÊÇMiniGUIµÄ³õʼ»¯²¿·ÖºÍ½áÊø²¿·Ö¡£

    ÔÚϵͳ³õʼ»¯Ê±£¬MiniGUIÇø·ÖÁ½ÖÖÇé¿ö£º·þÎñÆ÷£¨Server£©ºÍ¿Í»§(Client)¡£Õë¶ÔÕâÁ½ÖÖ²»Í¬µÄÇé¿ö£¬ËæºóµÄ¸÷Ïî²Ù×÷¾ùÓв»Í¬µÄ´¦Àí£¬ÕâÖ÷ÒªÒÀ¾ÝÈ«¾Ö±äÁ¿mgServer¡£ÓÉÓÚ½ö½ö¸ù¾ÝÃû³ÆÅжÏÊÇ·ñΪ·þÎñÆ÷£¬ËùÒÔ·þÎñÆ÷µÄÃû×ÖÖ»ÄÜÊÇ"mginit"¡£ InitGUI()ÊǶÔMiniGUI½øÐгõʼ»¯µÄº¯Êý£¬ËüÖ÷Òª¸ºÔð£º

»ñÈ¡ÓйØÖն˵ÄÐÅÏ¢¡£
³õʼ»¯Í¼ÐγéÏó²ã¡£
Èç¹ûÊÇ·þÎñÆ÷£¬Ôò×°Èë¹²Ïí×ÊÔ´£¬ÈôΪ¿Í»§ÔòÓë¹²Ïí×ÊÔ´½¨Á¢Á¬½Ó¡£
½¨Á¢Óë´°¿Ú»î¶¯ÓйصÄÔËÐл·¾³¡£
Èç¹ûΪ·þÎñÆ÷£¬Ôò³õʼ»¯Ê¼þÇý¶¯³éÏó²ã£¨IAL£©£¬Èç¹ûΪ¿Í»§£¬Ôò´ò¿ªÓë·þÎñÆ÷ʼþÇý¶¯Æ÷µÄͨµÀ¡£
Èç¹ûΪ·þÎñÆ÷£¬ÔòÉ趨¿ÕÏд¦ÀíΪIdleHandler4Server,Èç¹ûΪ¿Í»§£¬ÔòÉ趨¿ÕÏд¦ÀíΪIdleHandle4Client¡£
Á÷³ÌÈçͼ 2(Ϊͻ³öÖص㣬ÎÒÃǺöÂÔÁËһЩϸ½Ú)£º

4.2 ¹²Ïí×ÊÔ´³õʼ»¯
    ¹²Ïí×ÊÔ´ÊÇ¿Í»§·þÎñÆ÷Ä£ÐÍÖеÄÖØÒªÔªËØ£¬ËüÓÉ·þÎñÆ÷¸ºÔð´´½¨ºÍÊÍ·Å£¬¶øÌṩËùÓпͻ§³ÌÐò¹²ÏíµÄÊý¾Ý×ÊÔ´¡£ËüµÄ³õʼ»¯¹ý³ÌÓÉͼ 3ËùʾµÄµ÷ÓÃÁ÷Íê³É¡£

    Èç¹ûÊÇ·þÎñÆ÷£¬Ôò³õʼ»¯´Ë½á¹¹£¬src/kernel/sharedres.c/LoadSharedResource£¨£©¸ºÔðÍê³ÉÕâÒ»ÈÎÎñ

    ¶ÔÓÚ¿Í»§£¬ÔòÖ»ÐèÒªÓë´Ë½á¹¹½øÐÐÁ¬½Ó¼´¿É£¬ËüÔÚsrc/kernel/sharedres.c/AttachSharedResource()ʵÏÖ

4.3 ·þÎñÆ÷¿Í»§Í¨ÐÅÁ¬½Ó³õʼ»¯
    ÔÚ¿Í»§·þÎñÆ÷Ä£Ð͵ÄÌÖÂÛÖУ¬ÎÒÃÇ»¹½«ÏêϸµÄÌÖÂÛ·þÎñÆ÷¿Í»§µÄͨÐÅ»úÖÆ,ÕâÀïÖ»¸ø³ö³õʼ»¯µÄµ÷ÓùØϵ¡£

4.4 ¶à½ø³ÌÄ£ÐÍ
    Lite°æ±¾ÊÇÖ§³Ö¿Í»§·þÎñÆ÷£¨C/S£©·½Ê½µÄ¶à½ø³Ìϵͳ£¬ÔÚÔËÐйý³ÌÖÐÓÐÇÒ½öÓÐÒ»¸ö·þÎñÆ÷³ÌÐòÔÚÔËÐУ¬ËüµÄÈ«¾Ö±äÁ¿mgServer±»ÉèΪTRUE£¬ÆäÓàµÄMiniGUIÓ¦ÓóÌÐòΪ¿Í»§£¬mgServer±äÁ¿±»ÉèΪFALSE¡£¸÷¸öÓ¦ÓóÌÐò·Ö±ðÔËÐÐÓÚ¸÷×Ô²»Í¬µÄ½ø³Ì¿Õ¼ä

    Ä¿Ç°µÄ³ÌÐò½á¹¹Ê¹Ã¿¸ö¼ÓÔصĽø³ÌÓµÓÐÒ»¸ö×ÔÒѵÄ×ÀÃæÄ£Ðͼ°ÆäÏûÏ¢¶ÓÁÐ,½ø³Ì¼äµÄͨÐÅÒÀ¿¿ÒÔÏÂËùÌáµ½µÄ½ø³ÌͨÐÅÄ£ÐÍÀ´Íê³É¡£

4.5 ½ø³ÌͨÐÅÄ£ÐÍ
    ÕâÀïÎÒÃÇËùÖ¸µÄ½ø³ÌͨÐÅ°üÀ¨Í¨¹ý¹²ÏíÄÚ´æʵÏÖµÄÊý¾Ý½»»»ºÍͨ¹ýÌ×½Ó×ÖʵÏֵĿͻ§·þÎñÆ÷ͨÐÅÄ£ÐÍ¡£

    ·þÎñÆ÷¸ºÔð×°Èë¹²Ïí×ÊÔ´£¬ÆäÖаüÀ¨ÏµÍ³Í¼±ê¡¢Î»Í¼¡¢×ÖÌåµÈ£¬¿Í»§Ôòͨ¹ýAttachSharedResource()»ñÈ¡Ö¸Ïò¹²Ïí×ÊÔ´µÄÖ¸Õ룬³õʼ»¯Ò»¿é¹²ÏíÄÚ´æ¼°ÓëʹÓÃÒÑÓй²ÏíÄÚ´æµÄ·½·¨ÔÚÇ°ÃæµÄÃèÊöÖÐÒÑÌáµ½£¬Ôڴ˲»ÔÙ׸Êö¡£

4.6 ¸÷½ø³ÌÖ®¼äµÄͬ²½
    ÕâÀïËùÖ¸µÄ½ø³Ìͬ²½Ö÷ÒªÊÇÖ¸¸÷½ø³Ì»æÖƵÄͬ²½£¬ÏÔÈ»£¬Í¬Ê±²»¿ÉÄÜÓÐÁ½¸ö½ø³ÌÏòÆÁÄ»»æÖÆ¡£´«Í³µÄGUIʵÏÖ´ó¶àÊÇÖ»ÓÐÒ»¸ö½ø³Ì¸ºÔð»æÖÆ£¬¶øÔÚÎÒÃÇLite°æ±¾ÖУ¬¸÷½ø³Ì¸ºÔð×Ô¼ºµÄ»æÖÆ¡£Í¬Ê±£¬ÎÒÃǵÄLite °æ±¾»¹Ö§³ÖÐéÆÁÇл»£¬µ±ÎÒÃÇÇл»³öÈ¥µÄʱºò£¬Ë­Ò²²»Äܹ»ÏòÆÁÄ»»æÖÆ¡£

    Lite °æ±¾ÀûÓÃUnix ÐźŽâ¾öÁË»æÖÆͬ²½ÎÊÌ⡣ϵͳ¶¨ÒåÁËÁ½¸öÐźţºSIG_SETSCR ºÍ SIG_DNTDRAW£¬ËüÃÇÆäʵÊÇÖض¨ÒåÁ˵ÄÐźÅSIGUNUSEDºÍ SIGSTKFLT¡£Ã¿¸ö½ø³Ì¶¼¶¨ÒåÁËÁ½¸ö±äÁ¿dont_drawºÍcant_draw¡£

    ·þÎñÆ÷ÀûÓÃSIG_SETSCRºÍSIG_DNTDRAWÀ´¿ØÖƸ÷¿Í»§³ÌÐòË­ÓÐȨ¶ÔÆÁÄ»»æÖÆ£¬¶ø²»ÊÇ×Ô¼ºÈ«È¨´úÀí¡£ÕâҲʹµÃ½ø³Ì¼äͨÐÅÁ¿´ó´ó¼õÉÙ£ºµ±·þÎñÆ÷Ï£ÍûÒ»¸ö¿Í»§³ÌÐò²»ÒªÏòÆÁÄ»»æÖÆʱ£¬¾ÍÏòËü·¢ËÍSIG_DNTDRAWÐźţ¬µ±ÈÃÆä»æÖÆʱ£¬Ôò·¢ËÍSIG_SETSCR¡£´Ó¶øʵÏÖÁ˸÷½ø³Ì¼äµÄÆÁÄ»»æÖÆͬ²½¡£

    µ±Ò»¸ö¿Í»§ÊÕµ½SIG_DNTDRAWʱ£¬½«×Ô¼ºµÄ±äÁ¿dont_dawÉèÖÃΪture,ÊÕµ½SIG_SETSCRʱ£¬Ôò½«dont_draw±äÁ¿ÉèÖÃΪfalse¡£ÁíÒ»¸ö±äÁ¿cant_drawÔòÊǸø¿Í»§×Ô¼ºÓõģ¬±ÈÈ磬×ö¼ôÇÐʱ£¬µ±ËüµÄ¼ôÇÐÓòΪ¿Õ¼¯Ê±£¬ÓÖ±ÈÈ磬µ±½øÐÐÐéÆÁÇл»Ê±£¬µ±Ç°µÄ½ø³Ì½«×Ô¼ºµÄcant_draw±äÁ¿ÉèÖÃΪtrue¡£

    ÁíÍ⣬Èç¹ûÒ»¸ö¿Í»§ÕýÔÚ»æͼ£¬ÎÒÃÇÖ»ÓеÈËü»­Íêºó²ÅÄÜÈÃÆäËû½ø³ÌµÃµ½ÕâһȨÀû¡£ÎÒÃDz»ÐèÒªÖªµÀË­ÔÚ»æͼ£¬µ«ÎÒÃÇÒªµÈµ½ÕâÒ»¹ý³Ì½áÊø¡£Lite°æ±¾ÀûÓÃÐźÅÁ¿»úÖƽâ¾öÁËÕâÒ»ÎÊÌâ¡£ÔÚ¹²ÏíÄÚ´æÀï±£´æ×ÅÒ»¸ö±äÁ¿shmid£¬¸÷½ø³ÌÀûÓÃËüÀ´ÊµÏÖ¸÷×ÔµÄËø»úÖÆ¡£ÕâÖÖ»úÖÆÓеãÀàËÆÓÚÎļþËø£¬²»¹ýÒª¿ìÐí¶à¡£

    ´Ó¶ø£¬ÀûÓÃÐźÅÁ¿»úÖÆ£¬Lite°æ±¾ÊµÏÖÁ˶à½ø³ÌµÄ»æÖÆͬ²½¡£·þÎñÆ÷ÀûÓÃÐźſØÖƸ÷¿Í»§£¬¶ø¸÷¿Í»§Ò²³ä·ÖºÏ×÷¡£Ïà¹Ø´úÂ붼ÔÚMiniGUIµÄϵͳ¿âÀïʵÏÖ¡£±£Ö¤ÁËϵͳµÄÎȶ¨ÔËÐС£

5 ×ܽáÓï

    MiniGUI Lite°æ±¾ÊÔͼÔÚ´«Í³µÄ»ùÓÚÏ̵߳ĵ¥Ìå½á¹¹ºÍC/S½á¹¹Ö®¼äÑ°ÇóÒ»ÖÖЧÂʺÍÎȶ¨ÐÔµÄÕÛÖУ¬ÒÔ±ã¸ü¼ÓÊʺÏÔËÐÐÔÚPDAµÈСÐÍǶÈëʽϵͳÖС£Èç½ñ£¬MiniGUI Lite°æ±¾ÒѾ­Îȶ¨µØÔËÐÐÔÚһЩPDAϵͳÉÏ£¬ÊÂʵ֤Ã÷ÕâÖÖ³¢ÊÔÊdzɹ¦µÄ¡£


[Ŀ¼]


°²×°ÊÖ²á

MiniGUI ¼òÒ×°²×°ÊÖ²á
κÓÀÃ÷ (2001/08/09)

1. °²×°Ç°µÄ×¼±¸
1) Ñ¡ÔñͼÐÎÒýÇæ
    Èç¹ûÄúµÄ Linux ÄÚºËÖ§³Ö FrameBuffer, Ôò¿ÉÒÔʹÓÃÄÚ½¨ÓÚ MiniGUI µÄͼÐÎÒýÇæ -- ¼´ "˽ÓÐÒýÇæ". ÕâÑù, ¾ÍûÓбØÒª°²×°ÏÂÃæÌáµ½µÄÆäËüͼÐκ¯Êý¿â×÷Ϊ MiniGUI µÄͼÐÎÒýÇæÁË. ¶øÇÒ, Native ÒýÇæÊÇΨһ֧³Ö MiniGUI-Lite µÄÒýÇæ, Èç¹ûÄúÒª½« MiniGUI ÅäÖÃΪ MiniGUI-Lite, ҲûÓбØÒª°²×°ÆäËüµÄͼÐοâ×÷ΪÒýÇæ.

    Native ÒýÇæ¼È¿ÉÒÔÖ§³Ö MiniGUI-Threads, Ò²¿ÉÒÔÖ§³Ö MiniGUI-Lite. ÐèҪעÒâµÄÊÇ, Native ÒýÇæÄ¿Ç°»¹²»ÄÜÌṩ¶Ô "fbvga16" (±ê×¼ VGA 16 ɫģʽ) µÄÁ¼ºÃÖ§³Ö. ¶øÇÒÐèҪעÒâ Native ÒýÇæÄ¿Ç°Ö»ÄÜÔËÐÐÔÚ Linux FrameBuffer Ö®ÉÏ.

    Èç¹ûÄúµÄ Linux Äں˲»Ö§³Ö FrameBuffer, Ôò¿ÉÒÔʹÓà SVGALib ×÷ΪͼÐÎÒýÇæ. SVGALib ÊÇÒ»ÖÖÖ±½Ó·ÃÎÊͼÐÎоƬµÄÀϵÄͼÐκ¯Êý¿â. Òò´Ë, Èç¹ûʹÓà SVGALib, ÔòÐèÒª»ñµÃ root ȨÏÞ²ÅÄÜÈà MiniGUI ³ÌÐòÖ§³Ö½øÐÐͼÐÎоƬµÄ I/O ²Ù×÷.

    ÐèҪעÒâµÄÊÇ, ÒòΪ SVGALib ÊÇÒ»ÖÖÀϵÄͼÐοâ, ËùÒÔ²»ÄܶԴ󲿷ÖÁ÷ÐеÄÏÔʾ¿¨ÌṩÁ¼ºÃÖ§³Ö. È»¶ø, Èç¹ûÄúµÄÏÔʾоƬÊÇ VESA ¼æÈݵÄ, Ôò SVGALib ¿ÉÒÔͨ¹ý VESA BIOS 2.0 ÌṩµÄ½Ó¿ÚÁ¼ºÃÔËÐÐ. Ðí¶àÏÔʾоƬ¶¼ÊÇ VESA ¼æÈݵÄ, µ«Ä³Ð©²»ÊÇ, ±ÈÈç Intel µÄ i810 оƬ×é.

    ÄãÒ²¿ÉÒÔʹÓà LibGGI ×÷Ϊ MiniGUI µÄͼÐÎÒýÇæ. LibGGI ÊÇÒ»ÖÖеÄÃæÏò Linux µÄͼÐÎÒýÇæ, ËüÒ²¿ÉÒÔÎȶ¨µØÔËÐÐÔÚ Linux FrameBuffer Ö®ÉÏ. ×îÖ÷ÒªµÄÊÇ, ÔËÐÐÔÚ LibGGI Ö®ÉϵÄÓ¦ÓóÌÐò¿ÉÒÔ·½±ãµØÔËÐÐÔÚ X Window Ö®ÉÏ, ¶øÇÒ²»ÐèÒªÖØбàÒë.

    ×¢Òâ, SVGALib ºÍ LibGGI ²»ÄÜÓÃÀ´Ö§³Ö MiniGUI-Lite.

2) °²×°ÒýÇæ
    Èç¹ûÄú¾ö¶¨Ê¹Óà Native ÒýÇæ, ÔòûÓбØÒªÔ¤ÏÈ°²×°Ä³¸öÌض¨µÄͼÐοâ. Native ÒýÇæÒѾ­ÄÚ½¨ÓÚ MiniGUI µ±ÖÐ.

    Èç¹ûҪʹÓà SVGALib ×÷ΪͼÐÎÒýÇæ, ÔòÐèÒª°²×°¾­¹ýÐÞ¸ÄµÄ "svgalib-1.4.0-hz" Èí¼þ°üºÍ "vgagl4-0.1.0" °ü. Çë´ÓÈçÏ FTP Õ¾µãÏÂÔØ:

    ftp://ftp.minigui.net/pub/minigui/dep-libs

    »òÕß´Ó HTTP Õ¾µãÏÂÔØ£º

    http://www.minigui.org/cdownload.shtml

    ²¢½«ÉÏÊöÁ½¸öÈí¼þ°ü°²×°µ½ÄúµÄϵͳµ±ÖÐ. °²×°¹ý³Ì½«¸²¸ÇϵͳÖÐÀ쵀 SVGALib, µ«²¢²»»áÓ°ÏìÄúµÄϵͳ.

    Èç¹ûÄúʹÓà LibGGI ×÷ΪͼÐÎÒýÇæ, Çë´Ó http://www.ggi-projects.org ÏÂÔØ×îÐ嵀 GGI Ô´´úÂë, ²¢°²×°Ö®. »òÕß, Ò²¿ÉÒÔ´ÓÎÒÃÇµÄ FTP Õ¾µãÉÏÏÂÔØ:

    ftp://ftp.minigui.net/pub/minigui/dep-libs

    »òÕß´Ó HTTP Õ¾µãÏÂÔØ£º

    http://www.minigui.org/cdownload.shtml

3) ÏÂÔØ MiniGUI
    ÔÚÏÂÔز¢°²×°ºÃͼÐÎÒýÇæÖ®ºó, Çë´ÓÎÒÃǵÄÕ¾µãÉÏÏÂÔØÈçÏ tar.gz Èí¼þ°ü²¢½â¿ª:

libminigui-1.0.xx.tar.gz: MiniGUI º¯Êý¿âÔ´´úÂë, ÆäÖаüÀ¨ libminigui, libmywins, libmgext, ºÍ libvcongui.
minigui-res-1.0.xx.tar.gz: MiniGUI ËùʹÓõÄ×ÊÔ´, °üÀ¨Í¼±ê, λͼºÍÊó±ê¹â±ê.
minigui-fonts-1.0.xx.tar.gz: MiniGUI ËùʹÓõĻù±¾×ÖÌå. ÔÚÎÒÃǵÄÕ¾µãÉÏ, »¹¿ÉÒÔÕÒµ½ÆäËü×ÖÌå.
minigui-imetabs-1.0.xx.tar.gz: ÖÐÎÄ GB ÊäÈë·¨ËùʹÓõÄÂë±í.
minigui-exec-1.0.xx.tar.gz: MiniGUI-Threads µÄʾÀý³ÌÐò.
mglite-exec-1.0.xx.tar.gz: MiniGUI-Lite µÄʾÀý³ÌÐò.

    ×¢Òâ, Èç¹ûÄãÒÔÇ°°²×°¹ý "minigui-res", "minigui-fonts", »òÕß "minigui-imetabs" µÄÀÏ°æ±¾, ¶øÇÒÕ¾µãÉϲ¢Ã»ÓÐÌṩа汾µÄ»°, ˵Ã÷Äú¿ÉÒÔ¼ÌÐøÑØÓÃÀϵİ汾.

2 °²×° MiniGUI µÄ×ÊÔ´Îļþ
    ÎÒÃÇÊ×ÏÈÒª°²×° MiniGUI µÄ×ÊÔ´Îļþ. Çë°´ÕÕÈçϲ½Öè:

1) ʹÓà "tar" ÃüÁî½â¿ª "minigui-res-1.0.xx.tar.gz". ¿ÉʹÓÃÈçÏÂÃüÁî:

           $ tar zxf minigui-res-1.0.xx.tar.gz

2) ¸Ä±äµ½Ð½¨Ä¿Â¼ÖÐ, È»ºóÒÔ³¬¼¶Óû§Éí·ÝÔËÐÐ "make" ÃüÁî:

           $ su -c make install

3) ʹÓÃÏàͬµÄ²½Öè°²×° "minigui-fonts" ºÍ "minigui-imetabs" Èí¼þ°ü.

3 ÅäÖúͱàÒë MiniGUI
    MiniGUI ʹÓÃÁË "automake" ºÍ "autoconf" ½Ó¿Ú, Òò¶ø MiniGUI µÄÅäÖúͱàÒë·Ç³£ÈÝÒ×:

1) ʹÓà "tar" ½â¿ª "libminigui-1.0.xx.tar.gz" µ½ÐµÄĿ¼:

           $ tar zxf libminigui-1.0.xx.tar.gz

2) ¸Ä±äµ½ÐÂĿ¼, È»ºóÔËÐÐ "./configure":

           $ ./configure

3) ÔËÐÐÏÂÃæµÄÃüÁî±àÒë²¢°²×° MiniGUI:

           $ make; su -c 'make install';

4) ĬÈÏÇé¿öÏÂ, MiniGUI µÄº¯Êý¿â½«°²×°ÔÚ `/usr/local/lib' Ŀ¼ÖÐ. ÄúÓ¦¸ÃÈ·±£¸ÃĿ¼ÒѾ­ÁÐÔÚ "/etc/ld.so.conf" ÎļþÖÐ. ²¢ÇÒÔÚ°²×°Ö®ºó, ÒªÔËÐÐÏÂÃæµÄÃüÁî¸üй²Ïíº¯Êý¿âϵͳµÄ»º´æ:

            $ su -c ldconfig

5) Èç¹ûÒª¿ØÖÆÄúµÄ MiniGUI ÌṩÄÇЩ¹¦ÄÜ, Ôò¿ÉÒÔÔËÐÐ:

           $ ./configure --help

    ²é¿´ÍêÕûµÄÅäÖÃÑ¡ÏîÇåµ¥, È»ºóͨ¹ýÃüÁîÐпª¹Ø´ò¿ª»òÕ߹رÕijЩ¹¦ÄÜ. ÀýÈç, Èç¹ûÄú²»Ï£Íû MiniGUI ʹÓà LoadBitmap º¯Êý×°ÔØ JPEG ͼƬ, Ôò¿ÉÒÔʹÓÃ:

           $ ./configure --disable-jpgsupport

6) ×¢Òâ, ijЩ MiniGUI ÌØÉ«ÒÀÀµÓÚÆäËüº¯Êý¿â, ÇëÈ·±£ÒÑ°²×°ÁËÕâЩº¯Êý¿â.

4 ÔËÐÐ MiniGUI µÄÑÝʾ³ÌÐò
    "minigui-exec-1.0.xx.tar.gz" ºÍ "mglite-exec-1.0.xx.tar.gz" Öзֱð°üº¬ÁË MiniGUI-Threads ºÍ MiniGUI-Lite µÄÑÝʾ³ÌÐò. Èç¹û½« MiniGUI ÅäÖÃΪ MiniGUI-Threads, ÔòÇë±àÒë²¢ÔËÐÐ minigui-exec Èí¼þ°ü, ·ñÔò, Çë±àÒë²¢ÔËÐÐ mglite-exec Èí¼þ°ü.

ÔËÐÐ֮ǰ, Ó¦¸Ã½â¿ª²¢±àÒëÕâЩ tar.gz °ü:

1) ʹÓà "tar" ÃüÁÈí¼þ°ü½â¿ªµ½ÐµÄĿ¼.

2) ÒÀ´ÎÔËÐÐ "./configure" ºÍ "make" ±àÒëÑÝʾ³ÌÐò.

3) ÔËÐÐ "make install" ½«°²×°ÆäÖеÄһЩӦÓóÌÐòµ½ÏµÍ³ÖÐ. ×¢ÒâÕâЩ³ÌÐò½«±»°²×°µ½ "/usr/local/bin" Ŀ¼ÖÐ, ¶øijЩÑÝʾ³ÌÐò²¢²»»á°²×°µ½ÏµÍ³µ±ÖÐ.

4) ³¢ÊÔÔËÐÐÑÝʾ³ÌÐòºÍÓ¦ÓóÌÐò. ÀýÈç, Èç¹û½« MiniGUI ÅäÖÃΪ MiniGUI-Threads, Ôò¿ÉÒÔ½øÈë "minigui-exec-1.0.xx/amuze/" ÔËÐÐ "./amuze".

5) Èç¹ûÅäÖò¢°²×°ÁË MiniGUI-Lite, ÔòÓ¦¸ÃÊ×ÏÈÔËÐзþÎñÆ÷, È»ºó´Ó·þÎñÆ÷µ±ÖÐÔËÐÐÆäËüÑÝʾ³ÌÐò. ±àÒë "mglite-exec" ½«Éú³ÉÒ»¸ö "mginit" ³ÌÐò, ¸Ã³ÌÐò½«Ìṩһ¸öÔËÐÐÓÚ MiniGUI-Lite µÄÐéÄâ¿ØÖÆ̨.

5. °²×°¼°ÅäÖÃʾÀý
    ±¾Ê¾Àý¼Ù¶¨Óû§Ê¹ÓõÄϵͳÊÇ RedHat Linux 6.x ·¢Ðаæ, ʹÓà Linux ÄÚºË 2.2.xx »òÕß 2.4.xx, Óû§µÄÄ¿±êÊÇÔËÐÐ MiniGUI-Lite (ʹÓà MiniGUI Version 1.0.00). ²½ÖèÈçÏÂ:

1) È·±£ÄúµÄ PC »úÏÔʾ¿¨ÊÇ VESA ¼æÈݵÄ. ´ó¶àÊýÏÔʾ¿¨ÊÇ VESA ¼æÈݵÄ, È»¶øijЩÄÚǶÔÚÖ÷°åÉϵÄÏÔʾ¿¨¿ÉÄܲ»ÊÇ VESA ¼æÈݵÄ, ±ÈÈç Intel i810 ϵÁÐ. Èç¹ûÏÔʾ¿¨ÊÇ VESA ¼æÈݵÄ, ¾Í¿ÉÒÔʹÓà Linux ÄÚºËÖÐµÄ VESA FrameBuffer Çý¶¯³ÌÐòÁË.

2) È·±£ÄúµÄ Linux Äں˰üº¬ÁË FrameBuffer Ö§³Ö, ²¢°üº¬ÁË VESA FrameBuffer Çý¶¯³ÌÐò. RedHat Linux 6.x ·¢Ðаæ×Ô´øµÄÄÚºËÖÐÒѾ­°üº¬Á˸ÃÇý¶¯³ÌÐò. Èç¹ûʹÓÃ×Ô¼º±àÒëµÄÄÚºË, Çë¼ì²éÄúµÄÄÚºËÅäÖÃ.

3) ÐÞ¸Ä /etc/lilo.conf Îļþ, ÔÚÄúËùʹÓõÄÄÚºËÑ¡Ïî¶ÎÖÐ, Ìí¼ÓÈçÏÂÒ»ÐÐ:

                vga=0x0317

    ÕâÑù, Linux ÄÚºËÔÚÆô¶¯Ê±½«°ÑÏÔʾģʽÉèÖÃΪ 1024x768x16bpp ģʽ. Èç¹ûÄúµÄÏÔʾÆ÷ÎÞ·¨´ïµ½ÕâÖÖÏÔʾ·Ö±æÂÊ, ¿É¿¼ÂÇÉèÖà vga=0x0314, ¶ÔÓ¦ 800x600x16bpp ģʽ.

Ð޸ĺóµÄ /etc/lilo.conf ÎļþÀàËÆ:

                boot=/dev/hda
                map=/boot/map
                install=/boot/boot.b
                prompt
                timeout=50
                linear
                default=linux

                image=/boot/vmlinuz-2.4.2
                    vga=0x0317          ; ÕâÒ»ÐÐÉèÖÃÏÔʾģʽ.
                    label=linux
                    read-only
                    root=/dev/hda6

                other=/dev/hda1
                    label=dos

4) ÔËÐÐ lilo ÃüÁî, ʹËù×÷µÄÐÞ¸ÄÉúЧ, ²¢ÖØÐÂÆô¶¯ÏµÍ³.

5) Èç¹ûÒ»ÇÐÕý³£, ½«ÔÚ Linux Äں˵ÄÒýµ¼¹ý³ÌÖп´µ½ÆÁÄ»×óÉϽdzöÏÖ¿É°®µÄ Linux ¼ªÏéÎï -- Æó¶ì, ²¢·¢ÏÖϵͳµÄÏÔʾģʽ·¢Éú±ä»¯.

6) °´ÕÕµÚ 4 ½ÚËù½², ÏÂÔØ libminigui-1.0.00.tar.gz, mglite-exec-1.0.02.tar.gz, ÒÔ¼° minigui-res-1.0.02.tar.gz, minigui-fonts-1.0.00.tar.gz, minigui-imetabs-0.9.96.tar.gz µÈÈí¼þ°ü. ×¢ÒâÒª°²×°ÕýÈ·µÄ°æ±¾.

7) ÒÔ root Óû§Éí·Ý°²×° minigui-res-1.0.02.tar.gz, minigui-fonts-1.0.00.tar.gz, ºÍ minigui-imetabs-0.9.96.tar.gz Èí¼þ°ü. ÕâЩÈí¼þ°üµÄ°²×°Ò»°ã²»»á³öÏÖÎÊÌâ. ´Ë´¦²»ÔÙ׸Êö.

8) ÔÚij¸öĿ¼Ï½⿪ libminigui-1.0.00.tar.gz, ²¢½øÈëн¨µÄ libminigui-1.0.00 Ŀ¼.

       $ tar zxf libminigui-1.0.00.tar.gz
       $ cd libminigui-1.0.00

9) ÒÀ´ÎÔËÐÐÈçÏÂÃüÁî:

       $ ./autogen.sh ; Èç¹ûÄúµÄϵͳÖÐûÓа²×° autoconf/automake,
                      ; Ôò²»ÒªÖ´ÐÐÕâÒ»²½.
       $ ./configure
       $ make

10) ÒÔ root Éí·ÝÔËÐÐ make install ÃüÁî:

       $ su -
       # make install

11) ÐÞ¸Ä /etc/ld.so.conf Îļþ, ½« /usr/local/lib Ŀ¼Ìí¼Óµ½¸ÃÎļþ×îºóÒ»ÐÐ. Ð޸ĺóÀàËÆ:

                /usr/lib
                /usr/X11R6/lib
                /usr/i486-linux-libc5/lib
                /usr/local/lib

12) ÒÔ root Éí·ÝÖ´ÐÐ ldconfig ÃüÁî:

       # ldconfig

13) ÔÚÐÂĿ¼Öн⿪ mglite-exec-1.0.02.tar.gz, ²¢½øÈëн¨Ä¿Â¼:

       $ tar zxf mglite-exec-1.0.02.tar.gz
       $ cd mglite-exec-1.0.02

14) ÒÀ´ÎÔËÐÐÈçÏÂÃüÁî:

       $ ./autogen.sh ; Èç¹ûÄúµÄϵͳÖÐûÓа²×° autoconf/automake,
                      ; Ôò²»ÒªÖ´ÐÐÕâÒ»²½.
       $ ./configure
       $ make

15) ½øÈë mginit Ŀ¼, ²¢Ö´ÐÐ mginit ³ÌÐò:

       $ cd mginit
       $ ./mginit

16) Èç¹ûÒ»ÇÐÕý³£, Õâʱ¿ÉÒÔ¿´µ½Ò»¸öÐéÄâ¿ØÖÆ̨³öÏÖÔÚÆÁÄ»ÉÏ.

17) Çл»µ½ ../demos Ŀ¼, Ö´ÐÐÆäÖеijÌÐò:

      $ cd ../demos
      $ ./fminigui

18) Èç¹ûÄܹ»ÔÚÆÁÄ»ÉÏ¿´µ½Ò»¸ö²»¶Ï·É¶¯µÄ GUI ´°¿Ú, Ôò±íÃ÷Ò»ÇÐ OK.

19) ÈçºÎ¹Ø±ÕÕâ¸ö´°¿Ú, ²»ÐèÒªÔÚÕâÀï׸ÊöÁË°É. :)


[Ŀ¼]


[ ±¾ÎļþÓÉÁ¼ÓÑ¡¤ÊղؼÒ×Ô¶¯Éú³É ]