📄 help.c
字号:
/* File : help.c Author : Sergiy Uvarov - Copyright (C) 2001 Description : Creating help menu. Copyright notice: avr_simulator - A GNU/Linux simulator for the Atmel AVR series of microcontrollers. Copyright (C) 2001 Sergey Uvarov This program 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 program 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 program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Sergiy Uvarov E-mail : colonel@ff.dsu.dp.ua*/#include <stdio.h>#include <stdlib.h>#include <libintl.h>#include <Xm/XmAll.h>#include "help.h"#define _(x) gettext(x)Widget about_window;static void freeMem(Widget wg, XtPointer client, XtPointer call){ XtFree(client);}XtArgVal cvtResourceFromString(Widget wg, char *type, char *value){ XtArgVal v; XrmValue from, to; from.addr = value; from.size = strlen(value)+1; to.addr = (XPointer)&v; to.size = sizeof(v); if(XtConvertAndStore(wg, XtRString, &from, type, &to)) { return v; } else { from.addr = value; from.size = strlen(value)+1; to.addr = NULL; /* Converter will allocate the storage */ to.size = 0; if(XtConvertAndStore(wg, XtRString, &from, type, &to)) { void *mem; mem = XtMalloc(to.size); /* Copy private storage */ memcpy(mem, to.addr, to.size); XtAddCallback(wg, XmNdestroyCallback, freeMem, mem); return (XtArgVal)mem; } } printf("Can't convert %s to %s.\n", value, type); return 0;}void create_about(void){ Widget shell,frame,button,label,form; XmString strings[10]; Pixel pixel[10]; int n; Arg args[10]; XmRenderTable render_table; XmRendition renditions[10]; XmString string; shell=XtVaCreateWidget("Shell",xmDialogShellWidgetClass,toplevel, XmNtitle,_("About"),NULL); about_window=XtVaCreateWidget("form",xmFormWidgetClass,shell, XmNdialogStyle,XmDIALOG_MODELESS, XmNresizePolicy,XmRESIZE_NONE, NULL); frame=XtVaCreateManagedWidget("frame",xmFrameWidgetClass,about_window, XmNtopAttachment,XmATTACH_FORM, XmNtopOffset,10, XmNleftAttachment,XmATTACH_FORM, XmNleftOffset,10, XmNrightAttachment,XmATTACH_FORM, XmNrightOffset,10,NULL); pixel[0]=cvtResourceFromString(frame,"Pixel","#f0f0f0"); pixel[1]=cvtResourceFromString(frame,"Pixel","#3055f0"); n=0; XtSetArg(args[n],XmNrenditionForeground,pixel[1]);n++; /* XtSetArg(args[n],XmNfont,"misc");n++; */ XtSetArg(args[n],XmNfontName,"fixed");n++; XtSetArg(args[n],XmNfontType,XmFONT_IS_FONT);n++; renditions[0]=XmRenditionCreate(frame,(XmStringTag)"Big_rendition",args,n); render_table=XmRenderTableAddRenditions(NULL,renditions,1,XmMERGE_REPLACE); form=XtVaCreateManagedWidget("form",xmFormWidgetClass,frame, XmNbackground,pixel[0],NULL); strings[0]=XmStringGenerate( " AVR Simulator V1.3.1\n\n",NULL, XmCHARSET_TEXT,"Big_rendition"); strings[1]=XmStringGenerate(" AVR Simulator - A GNU/Linux simulator for the Atmel AVR series of microcontrollers. This program was developed as the graduated work. Copyright (C) 2001 Sergiy Uvarov This program 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 program 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 program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Sergiy Uvarov Web site: E-mail : colonel@ff.dsu.dp.ua\n", XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT,_MOTIF_DEFAULT_LOCALE); XmStringConcatAndFree(strings[0],strings[1]); label=XtVaCreateManagedWidget("label",xmLabelGadgetClass,form, XmNtopAttachment,XmATTACH_FORM, XmNleftAttachment,XmATTACH_FORM, XmNrightAttachment,XmATTACH_FORM, XmNbottomAttachment,XmATTACH_FORM, XmNrenderTable,render_table, XmNlabelString,strings[0], XmNalignment,XmALIGNMENT_BEGINNING,NULL); XmStringFree(strings[0]); string=XmStringGenerate(_(" Close "),XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT,_MOTIF_DEFAULT_LOCALE); button=XtVaCreateManagedWidget("Close",xmPushButtonGadgetClass,about_window, XmNbottomAttachment,XmATTACH_FORM, XmNbottomOffset,10, XmNleftAttachment,XmATTACH_POSITION, XmNleftPosition,40, XmNrightAttachment,XmATTACH_POSITION, XmNrightPosition,60, XmNhighlightThickness,1, XmNlabelString,string, XmNshadowThickness,1,NULL); XmStringFree(string); XtVaSetValues(frame,XmNbottomAttachment,XmATTACH_WIDGET, XmNbottomWidget,button,XmNbottomOffset,10,NULL);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -