⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thaifont.c

📁 minigui desktop enviroment
💻 C
字号:
/*** $Id: Thaifont.c,v 1.1 2004/12/10 10:08:25 cxzhang Exp $**** The demo of font.**** Copyright (C) 2001 ~ 2002 Wei Yongming.** Copyright (C) 2003 Feynman Software.**** Create date: 2002/01/17*//***  This source is free software; you can redistribute it and/or**  modify it under the terms of the GNU General Public**  License as published by the Free Software Foundation; either**  version 2 of the License, or (at your option) any later version.****  This software is distributed in the hope that it will be useful,**  but WITHOUT ANY WARRANTY; without even the implied warranty of**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU**  General Public License for more details.****  You should have received a copy of the GNU General Public**  License along with this library; if not, write to the Free**  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,**  MA 02111-1307, USA*//*** TODO:*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#define IDM_EXIT            160#define IDM_TEXTOUT1        200#define IDM_ABOUT           310static HMENU createpmenuabout (void){    HMENU hmnu;    MENUITEMINFO mii;    memset (&mii, 0, sizeof(MENUITEMINFO));    mii.type        = MFT_STRING;    mii.id          = 0;    mii.typedata    = (DWORD)"About";    hmnu = CreatePopupMenu (&mii);        memset (&mii, 0, sizeof(MENUITEMINFO));    mii.type        = MFT_STRING ;    mii.state       = 0;    mii.id          = IDM_ABOUT;    mii.typedata    = (DWORD)"About MiniGUI...";    InsertMenuItem(hmnu, 3, TRUE, &mii);    return hmnu;}static HMENU createpmenufile (void){    HMENU hmnu;    MENUITEMINFO mii;    memset (&mii, 0, sizeof(MENUITEMINFO));    mii.type        = MFT_STRING;    mii.id          = 0;    mii.typedata    = (DWORD)"File";    hmnu = CreatePopupMenu (&mii);        mii.type        = MFT_STRING;    mii.state       = 0;    mii.id          = IDM_EXIT;    mii.typedata    = (DWORD)"Exit";    InsertMenuItem(hmnu, 0, TRUE, &mii);    return hmnu;}static HMENU createpmenudialogs (void){    HMENU hmnu;    MENUITEMINFO mii;    memset (&mii, 0, sizeof(MENUITEMINFO));    mii.type        = MFT_STRING;    mii.id          = 0;    mii.typedata    = (DWORD)"Text";    hmnu = CreatePopupMenu (&mii);        mii.type        = MFT_STRING ;    mii.state       = 0;    mii.id          = IDM_TEXTOUT1;    mii.typedata    = (DWORD)"TextOut1...";    InsertMenuItem(hmnu, 0, TRUE, &mii);        return hmnu;}static HMENU createmenu (void){    HMENU hmnu;    MENUITEMINFO mii;    hmnu = CreateMenu();    memset (&mii, 0, sizeof(MENUITEMINFO));    mii.type        = MFT_STRING;    mii.id          = 100;    mii.typedata    = (DWORD)"File";    mii.hsubmenu    = createpmenufile ();    InsertMenuItem(hmnu, 0, TRUE, &mii);    mii.type        = MFT_STRING;    mii.id          = 110;    mii.typedata    = (DWORD)"Fonts";    mii.hsubmenu    = createpmenudialogs ();    InsertMenuItem(hmnu, 1, TRUE, &mii);        mii.type        = MFT_STRING;    mii.id          = 120;    mii.typedata    = (DWORD)"About";    mii.hsubmenu    = createpmenuabout ();    InsertMenuItem(hmnu, 2, TRUE, &mii);                       return hmnu;}#define MODE_TEXTOUT1           11#define ROW 4 #define COL 5#define WIDTH 120#define HEIGHT 40static PLOGFONT logfont1;void OnModeTextOut1 (HDC hdc){    int i;    int offset_x = 10;    int offset_y = -30;    char    buffer[20];    FILE* thai = fopen("thai", "w+");    SetBkColor (hdc, COLOR_blue);    SetBkMode (hdc, BM_TRANSPARENT);    for(i = 0; i < ROW + 1; i++)    {        LineEx(hdc, 0, i*HEIGHT, COL*WIDTH, i*HEIGHT);    }    for(i = 0; i < COL + 1; i++)    {        LineEx(hdc, i*WIDTH, 0, i*WIDTH, ROW*HEIGHT);    }    SetPenColor(hdc, COLOR_red);    LineEx(hdc, 0, 1*HEIGHT, COL*WIDTH+100, 1*HEIGHT);    LineEx(hdc, 0, 2*HEIGHT, COL*WIDTH+100, 2*HEIGHT);    LineEx(hdc, 0, 3*HEIGHT, COL*WIDTH+100, 3*HEIGHT);    SelectFont (hdc, logfont1);    i = 161;    while (i <= 251)    {        if ((i-161)%25 == 0)        {            offset_x = 10;            offset_y += 40;        }        sprintf(buffer, "%c %c %c %c %c", i, i+1, i+2, i+3, i+4);        fprintf(thai, "%s", buffer);         TextOut (hdc, offset_x, offset_y, buffer);        offset_x += 120;        i += 5;    }    fclose(thai);    SetPenColor(hdc, COLOR_black);    TextOut(hdc, 610, 10, "I");    TextOut(hdc, 610, 50, "II");    TextOut(hdc, 610, 90, "III");    TextOut(hdc, 610, 130, "IV");} int FontTestMainWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam){    static int mode = MODE_TEXTOUT1;    switch (message) {        case MSG_CREATE:            logfont1 = CreateLogFont (NULL, "fixed", "ISO8859-11",                         FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL,                        FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE,                         29, 0);        break;        case MSG_PAINT:        {            HDC hdc;            hdc = BeginPaint (hWnd);            switch (mode) {            case MODE_TEXTOUT1:                OnModeTextOut1 (hdc);                break;            }            EndPaint (hWnd, hdc);            return 0;        }                case MSG_COMMAND:        switch (wParam)         {            case IDM_EXIT:                SendMessage (hWnd, MSG_CLOSE, 0, 0L);            break;            case IDM_TEXTOUT1:                mode = MODE_TEXTOUT1;                InvalidateRect (hWnd, NULL, TRUE);            break;            case IDM_ABOUT:            break;        }        break;        case MSG_CLOSE:            if (MessageBox (hWnd,                             "Are you sure to quit?",                             "FontTest",                             MB_YESNOCANCEL | MB_ICONQUESTION) != IDYES)                return 0;            DestroyLogFont (logfont1);            DestroyMainWindow (hWnd);            PostQuitMessage (hWnd);        return 0;    }    return DefaultMainWinProc (hWnd, message, wParam, lParam);}static void InitCreateInfo (PMAINWINCREATE pCreateInfo){    pCreateInfo->dwStyle = WS_CAPTION | WS_BORDER | WS_SYSMENU;    pCreateInfo->dwExStyle = WS_EX_NONE;    pCreateInfo->spCaption = "The font test main window";    pCreateInfo->hMenu = createmenu ();    pCreateInfo->hCursor = GetSystemCursor (IDC_ARROW);    pCreateInfo->hIcon = GetSmallSystemIcon (IDI_APPLICATION);    pCreateInfo->MainWindowProc = FontTestMainWinProc;    pCreateInfo->lx = 0;     pCreateInfo->ty = 0;    pCreateInfo->rx = 1024;    pCreateInfo->by = 700;    pCreateInfo->iBkColor = COLOR_lightwhite;     pCreateInfo->dwAddData = 0;    pCreateInfo->hHosting = HWND_DESKTOP;}int MiniGUIMain (int args, const char* arg[]){    MSG Msg;    MAINWINCREATE CreateInfo;    HWND hMainWnd;#if defined(_LITE_VERSION) && !(_STAND_ALONE)    int i;    const char* layer = NULL;    RECT max_rect = {0, 0, 0, 0};    for (i = 1; i < args; i++) {        if (strcmp (arg[i], "-layer") == 0) {            layer = arg[i + 1];            break;        }    }    GetLayerInfo (layer, &max_rect, NULL, NULL, NULL);    if (JoinLayer (layer, arg[0],                 max_rect.left, max_rect.top,                 max_rect.left + 1024,                 max_rect.top + 768) == INV_LAYER_HANDLE) {        printf ("JoinLayer: invalid layer handle.\n");        exit (1);    }    if (!InitVectorialFonts ()) {        printf ("InitVectorialFonts: error.\n");        exit (2);    }#endif    InitCreateInfo (&CreateInfo);    hMainWnd = CreateMainWindow (&CreateInfo);    if (hMainWnd == HWND_INVALID)        exit (3);    ShowWindow (hMainWnd, SW_SHOWNORMAL);    while (GetMessage (&Msg, hMainWnd)) {        TranslateMessage (&Msg);        DispatchMessage (&Msg);    }    MainWindowThreadCleanup (hMainWnd);#ifdef _LITE_VERSION    TermVectorialFonts ();#endif    return 0;}#ifndef _LITE_VERSION#include <minigui/dti.c>#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -