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

📄 notebookdemo.c

📁 s3c44b0上用的MINIGUI源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*** $Id: main.c,v 1.14 2003/08/15 08:45:46 weiym Exp $**** NoteBook, the M$ Windows like notepad Editor on MiniGUI.** Copyright (c) 2000, Feng Da ke (minx@thtfchain.com).**** Some idea and source come from VConGUI (Virture Console GUI) **** Create date: 2000/07/05** BTW: today, my sweetheart lovly MinMin comes back from millitery training.*/ /***  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*//*** Modify records:****  Who             When        Where       For What                Status**-----------------------------------------------------------------------------** FrankXM         2000.07.05   CIMS104     Create                  processing** leon            2000.11.07   BJ.blpt     Fix bugs                Finished**** TODO:*/#include <stdio.h>#include <stdlib.h>#include <time.h>#include <string.h>#include <sys/time.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <popt.h>#include <unistd.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#include <minigui/mywindows.h>#include <minigui/filedlg.h>#include "notebookdemo.h"static void AboutNotebook (HWND hParent){    MessageBox (hParent,         "记事簿 -- Version 0.6\n\n"        "是一个参考 M$ Windows 的 notepad 制作的文本编辑器, "        "在 MiniGUI 下使用. \n\n"        "开发这个文本编辑器的最大困难就是要同时排除多行"        "编辑控件的故障. 如今还有很多的功能未实现, 请耐心等待后"        "续版本, 欢迎提交 BUG 报告: minx@thtfchain.com -- 冯大可.\n\n"        "本版本经陈雷 (chenlei@minigui.org), 魏永明 (ymwei@minigui.org) 进一步完善.",        "记事簿",        MB_OK | MB_ICONEXCLAMATION);};static void AboutLaodan (HWND hParent){    MessageBox (hParent,           "老聃 (laodan), 本名李耳, 道家创始人"            "著有道德二篇, 清净无为以治万物.\n\n"            "本系统设计目的是试图寻找 MiniGUI "            "系统的应用前景, 并在制作中寻找方便的开发方法与工具.\n\n"            "作者喜爱先秦哲学, 诸子百家之言, 每下工夫制作一新系统, "            "必以一子为名. "            "故作者在 MiniGUI 上的工作均以老聃 (Laodan) 为代名.",            "老聃",          MB_OK | MB_ICONEXCLAMATION);}static BOOL MergeFileFullName(PNOTEINFO pNoteInfo){    if ((strlen(pNoteInfo->filePath) < 1) || (strlen(pNoteInfo->fileName) < 1))        return FALSE;    if (pNoteInfo->filePath[strlen(pNoteInfo->filePath)-1] != '/')        strcat (pNoteInfo->filePath,"/");    strcpy (pNoteInfo->fileFullName,pNoteInfo->filePath);    strcat (pNoteInfo->fileFullName,pNoteInfo->fileName);    return TRUE;}BOOL DivideFileFullName(PNOTEINFO pNoteInfo){       char currentpath [PATH_MAX + 1];    char *str;    int temp ,i,j;    temp = strlen(pNoteInfo->fileFullName);        getcwd(currentpath,PATH_MAX);    if (temp <1) return FALSE;    if (pNoteInfo->fileFullName[temp-1]=='/') return FALSE;    if (strchr(pNoteInfo->fileFullName,'/')==NULL)    {        strcpy(pNoteInfo->filePath,currentpath);        strcpy(pNoteInfo->fileName,pNoteInfo->fileFullName);        MergeFileFullName(pNoteInfo);        return TRUE;    }    for (i= temp-1;i>=0;i--)    {        if (pNoteInfo->fileFullName[i]=='/')            break;    }    for (j=0;j<=i;j++)    {        pNoteInfo->filePath[j]=pNoteInfo->fileFullName[j];    }    pNoteInfo->filePath[i+1]=0;    str = (char*)(pNoteInfo->fileFullName + i + 1);    strcpy (pNoteInfo->fileName,str);    return TRUE;}static HMENU createpmenuabout (void){    HMENU hmnu;    MENUITEMINFO mii;    memset (&mii, 0, sizeof(MENUITEMINFO));    mii.type        = MFT_STRING;    mii.id          = 0;    mii.typedata    = (DWORD)"帮助";    hmnu = CreatePopupMenu (&mii);        memset (&mii, 0, sizeof(MENUITEMINFO));    mii.type        = MFT_STRING ;    mii.state       = 0;    mii.id          = IDM_ABOUT_THIS;    mii.typedata    = (DWORD)"关于记事簿...";    InsertMenuItem(hmnu, 0, TRUE, &mii);/*    memset (&mii, 0, sizeof(MENUITEMINFO));    mii.type        = MFT_STRING ;    mii.state       = 0;    mii.id          = IDM_ABOUT;    mii.typedata    = (DWORD)"关于老聃...";    InsertMenuItem(hmnu, 1, TRUE, &mii);*/    return hmnu;}static HMENU createpmenusearch (void){    HMENU hmnu;    MENUITEMINFO mii;    memset (&mii, 0, sizeof(MENUITEMINFO));    mii.type        = MFT_STRING;    mii.id          = 0;    mii.typedata    = (DWORD)"搜索";    hmnu = CreatePopupMenu (&mii);        memset (&mii, 0, sizeof(MENUITEMINFO));    mii.type        = MFT_STRING ;    mii.state       = 0;    mii.id          = IDM_SEARCH;    mii.typedata    = (DWORD)"查找";    InsertMenuItem(hmnu, 0, TRUE, &mii);    memset (&mii, 0, sizeof(MENUITEMINFO));    mii.type        = MFT_STRING ;    mii.state       = 0;    mii.id          = IDM_SECHNEXT;    mii.typedata    = (DWORD)"查找下一个 F3";    InsertMenuItem(hmnu, 1, 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)"文件";    hmnu = CreatePopupMenu (&mii);        memset (&mii, 0, sizeof(MENUITEMINFO));    mii.type        = MFT_STRING;    mii.state       = 0;    mii.id          = IDM_NEW;    mii.typedata    = (DWORD)"新建";    InsertMenuItem(hmnu, 0, TRUE, &mii);        mii.type        = MFT_STRING;    mii.state       = 0;    mii.id          = IDM_OPEN;    mii.typedata    = (DWORD)"打开...";    InsertMenuItem(hmnu, 1, TRUE, &mii);        mii.type        = MFT_STRING;    mii.state       = 0;    mii.id          = IDM_SAVE;    mii.typedata    = (DWORD)"保存";    InsertMenuItem(hmnu, 2, TRUE, &mii);        mii.type        = MFT_STRING;    mii.state       = 0;    mii.id          = IDM_SAVEAS;    mii.typedata    = (DWORD)"另存为...";    InsertMenuItem(hmnu, 3, TRUE, &mii);    mii.type        = MFT_SEPARATOR;    mii.state       = 0;    mii.id          = 0;    mii.typedata    = 0;    InsertMenuItem(hmnu, 4, TRUE, &mii);    mii.type        = MFT_STRING;    mii.state       = 0;    mii.id          = IDM_PRINT;    mii.typedata    = (DWORD)"打印";    InsertMenuItem(hmnu, 5, TRUE, &mii);        mii.type        = MFT_SEPARATOR;    mii.state       = 0;    mii.id          = 0;    mii.typedata    = 0;    InsertMenuItem(hmnu, 6, TRUE, &mii);    mii.type        = MFT_STRING;    mii.state       = 0;    mii.id          = IDM_EXIT;    mii.typedata    = (DWORD)"退出";    InsertMenuItem(hmnu, 7, 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)"文件";    mii.hsubmenu    = createpmenufile ();    InsertMenuItem(hmnu, 0, TRUE, &mii);    mii.type        = MFT_STRING;    mii.id          = 140;    mii.typedata    = (DWORD)"帮助";    mii.hsubmenu    = createpmenuabout ();    InsertMenuItem(hmnu, 4, TRUE, &mii);                           return hmnu;}//modified by leon to fix the saveas bugBOOL NBSaveAs (PNOTEINFO pNoteInfo, HWND hParent, HWND hMLEditWnd){    FILEDLGDATA myWinFileData;    FILE * file;    int choise=0;    int reallength=0;    char buffer[102400];    strcpy (myWinFileData.filepath, pNoteInfo->filePath);    myWinFileData.IsSave = TRUE;        choise = OpenFileDialog (hParent, TRUE, &myWinFileData);    if (choise == IDOK)    {        strcpy(pNoteInfo->fileFullName,myWinFileData.filefullname);        DivideFileFullName(pNoteInfo);        umask (S_IXGRP | S_IWOTH);        if ((file = fopen (pNoteInfo->fileFullName, "w+")) == NULL)        {             MessageBox (hParent,"文件打开失败","记事簿", MB_OK | MB_ICONSTOP);             return FALSE;        }        reallength = GetWindowTextLength(hMLEditWnd);        GetWindowText(hMLEditWnd,buffer,102400);        //fprintf(stderr,"\n in saveas:\nreallength:%d\ntext:\n%s",reallength,buffer);        if (fwrite(buffer, 1, reallength, file) < 0)              MessageBox (hParent,"文件写入错","记事簿", MB_OK | MB_ICONEXCLAMATION);        pNoteInfo->isChanged = FALSE;        fclose (file);        return TRUE;    }    return FALSE;}BOOL NBSave (PNOTEINFO pNoteInfo, HWND hParent, HWND hMLEditWnd)

⌨️ 快捷键说明

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