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

📄 tooldemo.c

📁 CVI教程,用于信号采集系统的多任务开发软件.学习简单,功能实用.
💻 C
📖 第 1 页 / 共 2 页
字号:
/*--------------------------------------------------------------------------*//* Demo of Toolbar Instrument driver                                        *//*--------------------------------------------------------------------------*//*--------------------------------------------------------------------------*//* Includes                                                                 *//*--------------------------------------------------------------------------*/#include <utility.h>#include <userint.h>#include "toolbar.h"#include "tooldemo.h"/*--------------------------------------------------------------------------*//* Defines                                                                  *//*--------------------------------------------------------------------------*/#define USE_ICO 1/*------------------------------------------------------------*//* It is suggested to use graphics files of all the same type.*//* CVI treats white pixels in a ICO file as transparent, and  *//* will convert the VAL_PANEL_GRAY pixels in a BMP or PCX to  */ /* the default panel background color when using the "Conform *//* bitmap colors" option in the Toolbar_New function.         *//*------------------------------------------------------------*/#if _NI_unix_    #define IMAGE_NEW     "buttons/new.pcx"    #define IMAGE_OPEN    "buttons/open.pcx"    #define IMAGE_SAVE    "buttons/save.pcx"    #define IMAGE_SAVEALL "buttons/saveall.pcx"    #define IMAGE_CUT     "buttons/cut.pcx"    #define IMAGE_COPY    "buttons/copy.pcx"    #define IMAGE_PASTE   "buttons/paste.pcx"    #define IMAGE_GO      "buttons/go.pcx"    #define IMAGE_STOP    "buttons/stop.pcx"    #define IMAGE_BYNAME  "buttons/byname.pcx"    #define IMAGE_BYDATE  "buttons/bydate.pcx"    #define IMAGE_BYSIZE  "buttons/bysize.pcx"    #define IMAGE_BYTYPE  "buttons/bytype.pcx"    #define IMAGE_HELP    "buttons/help.pcx"#else      #if USE_ICO    #define IMAGE_NEW     "buttons/new.ico"    #define IMAGE_OPEN    "buttons/open.ico"    #define IMAGE_SAVE    "buttons/save.ico"    #define IMAGE_SAVEALL "buttons/saveall.ico"    #define IMAGE_CUT     "buttons/cut.ico"    #define IMAGE_COPY    "buttons/copy.ico"    #define IMAGE_PASTE   "buttons/paste.ico"    #define IMAGE_GO      "buttons/go.ico"    #define IMAGE_STOP    "buttons/stop.ico"    #define IMAGE_BYNAME  "buttons/byname.ico"    #define IMAGE_BYDATE  "buttons/bydate.ico"    #define IMAGE_BYSIZE  "buttons/bysize.ico"    #define IMAGE_BYTYPE  "buttons/bytype.ico"    #define IMAGE_HELP    "buttons/help.ico"  #else        #define IMAGE_NEW     "buttons/new.bmp"    #define IMAGE_OPEN    "buttons/open.bmp"    #define IMAGE_SAVE    "buttons/save.bmp"    #define IMAGE_SAVEALL "buttons/saveall.bmp"    #define IMAGE_CUT     "buttons/cut.bmp"    #define IMAGE_COPY    "buttons/copy.bmp"    #define IMAGE_PASTE   "buttons/paste.bmp"    #define IMAGE_GO      "buttons/go.bmp"    #define IMAGE_STOP    "buttons/stop.bmp"    #define IMAGE_BYNAME  "buttons/byname.bmp"    #define IMAGE_BYDATE  "buttons/bydate.bmp"    #define IMAGE_BYSIZE  "buttons/bysize.bmp"    #define IMAGE_BYTYPE  "buttons/bytype.bmp"    #define IMAGE_HELP    "buttons/help.bmp"  #endif#endif/*--------------------------------------------------------------------------*//* Variables                                                                *//*--------------------------------------------------------------------------*/static int hMainPanel;static int hAboutPanel;static ToolbarType gToolbar;/*--------------------------------------------------------------------------*//* Prototypes                                                               *//*--------------------------------------------------------------------------*/static ToolbarType InstallToolBar(int panel);static void ShowAction (int parentPanel, char *action);int CVICALLBACK RingCallback (int panel, int control, int event,     void *callb4ackData, int eventData1, int eventData2);int CVICALLBACK StringCallback (int panel, int control, int event,     void *callb4ackData, int eventData1, int eventData2);int CVICALLBACK SortByCallback (int panel, int control, int event,    void *callbackData, int eventData1, int eventData2);int CVICALLBACK GoStopCallback (int panel, int control, int event,        void *callbackData, int eventData1, int eventData2);         /*--------------------------------------------------------------------------*//* Main                                                                     *//*--------------------------------------------------------------------------*/int main (int argc, char *argv[]) {    int value;        if (InitCVIRTE (0, argv, 0) == 0)          return -1;  /* out of memory */    if ((hMainPanel = LoadPanel (0, "tooldemo.uir", PANEL)) < 0)        return -1;    SetCtrlAttribute (hMainPanel, PANEL_QUIT, ATTR_VISIBLE, 0);        gToolbar = InstallToolBar(hMainPanel);        /* Update switch on UIR for style */    Toolbar_GetAttribute (gToolbar, TOOLBAR_ATTR_STYLE, &value);    SetCtrlVal(hMainPanel, PANEL_STYLE, (value==TOOLBAR_VAL_FLAT));    DisplayPanel (hMainPanel);    RunUserInterface ();        /* Cleanup */        Toolbar_Discard(gToolbar);    gToolbar = 0;    DiscardPanel(hMainPanel);    hMainPanel = 0;        return 0;}/*--------------------------------------------------------------------------*//* InstallToolBar                                                           *//*--------------------------------------------------------------------------*/static ToolbarType InstallToolBar(int panel){    int i, index;    char Target[][20]={   "Linux", "Win 95", "Win NT", "Win 3.11",          "Solaris 1.0", "Solaris 2.0", "HP UX", "DOS", "Mac OS"};    int control;    ToolbarType toolbar;            /*----------------------------------------------------------------------*/    /* Create toolbar                                                       */    /*----------------------------------------------------------------------*/    if (Toolbar_New (panel, GetPanelMenuBar(panel), "", 0, 0, 1, 1,                             &toolbar) < 0)        return 0;            /*----------------------------------------------------------------------*/    /* Create items in toolbar                                              */    /*----------------------------------------------------------------------*/    Toolbar_InsertItem (toolbar, END_OF_LIST, kCommandButton, 1, "New",                        kMenuCallback, MENU_FILE_NEW, NULL, NULL, IMAGE_NEW);                            Toolbar_InsertItem (toolbar, END_OF_LIST, kSeparator, 1, NULL,                        kNoCallback, 0, NULL, NULL, NULL);    Toolbar_InsertItem (toolbar, END_OF_LIST, kCommandButton, 1, "Open",                        kMenuCallback, MENU_FILE_OPEN, NULL, NULL, IMAGE_OPEN);    Toolbar_InsertItem (toolbar, END_OF_LIST, kCommandButton, 1, "Save",                        kMenuCallback, MENU_FILE_SAVE, NULL, NULL, IMAGE_SAVE);                            Toolbar_InsertItem (toolbar, END_OF_LIST, kCommandButton, 1, "Save All",                        kMenuCallback, MENU_FILE_SAVEALL, NULL, NULL, IMAGE_SAVEALL);                            Toolbar_InsertItem (toolbar, END_OF_LIST, kSeparator, 1, NULL,                        kNoCallback, 0, NULL, NULL, NULL);    Toolbar_InsertItem (toolbar, END_OF_LIST, kCommandButton, 1, "Cut",                        kMenuCallback, MENU_EDIT_CUT, NULL, NULL, IMAGE_CUT);                            Toolbar_InsertItem (toolbar, END_OF_LIST, kCommandButton, 1, "Copy",                        kMenuCallback, MENU_EDIT_COPY, NULL, NULL, IMAGE_COPY);                            Toolbar_InsertItem (toolbar, END_OF_LIST, kCommandButton, 1, "Paste",                         kMenuCallback, MENU_EDIT_PASTE, NULL, NULL, IMAGE_PASTE);                            Toolbar_InsertItem (toolbar, END_OF_LIST, kCommandButton, 1, "Go",                        kControlCallback, NULL, GoStopCallback, (void*)1, IMAGE_GO);    Toolbar_InsertItem (toolbar, END_OF_LIST, kCommandButton, 1, "Stop",                        kControlCallback, NULL, GoStopCallback, (void*)2, IMAGE_STOP);    Toolbar_GetIndexFromDescription (toolbar, "Stop", &index);    Toolbar_DimItem (toolbar, index, 1);    Toolbar_InsertItem (toolbar, END_OF_LIST, kExclusiveToggleButton, 1, "By Name",                        kControlCallback, NULL, SortByCallback, (void*)1, IMAGE_BYNAME);                            Toolbar_InsertItem (toolbar, END_OF_LIST, kExclusiveToggleButton, 1, "By Date",                        kControlCallback, NULL, SortByCallback, (void*)2, IMAGE_BYDATE);                            Toolbar_InsertItem (toolbar, END_OF_LIST, kExclusiveToggleButton, 1, "By Size",                        kControlCallback, NULL, SortByCallback, (void*)3, IMAGE_BYSIZE);                            Toolbar_InsertItem (toolbar, END_OF_LIST, kExclusiveToggleButton, 1, "By Type",                        kControlCallback, NULL, SortByCallback, (void*)4, IMAGE_BYTYPE);                            Toolbar_InsertItem (toolbar, END_OF_LIST, kRing, 1, "Target",                        kControlCallback, 0, RingCallback, NULL, "");    Toolbar_InsertItem (toolbar, END_OF_LIST, kSeparator, 1, NULL,                        kNoCallback, 0, NULL, NULL, NULL);    Toolbar_InsertItem (toolbar, END_OF_LIST, kString, 1, "Font",                        kControlCallback, 0, StringCallback, NULL, "");    Toolbar_InsertItem (toolbar, END_OF_LIST, kCommandButton, 1, "About",                        kMenuCallback, MENU_HELP_ABOUT, NULL, NULL, IMAGE_HELP);      /*----------------------------------------------------------------------*/    /* Fill ring with values                                                */      /*----------------------------------------------------------------------*/    Toolbar_GetCtrlFromDescription(toolbar, "Target", &panel, &control);      for (i=0; i<9; i++)          InsertListItem (panel, control, -1, Target[i], i);          Toolbar_GetIndexFromDescription (toolbar, "Target", &index);    Toolbar_GetItemAttribute(toolbar, index, TOOLBAR_ATTR_WIDTH, &i);    Toolbar_SetItemAttribute(toolbar, index, TOOLBAR_ATTR_WIDTH, 80);    Toolbar_Display (toolbar);        Toolbar_SetItemAttribute(toolbar, control, TOOLBAR_ATTR_WIDTH, 100);        /*----------------------------------------------------------------------*/    /* Fill sting with value                                                */      /*----------------------------------------------------------------------*/    Toolbar_GetCtrlFromDescription(toolbar, "Font", &panel, &control);      SetCtrlVal(panel, control, "Times New Roman");          Toolbar_GetIndexFromDescription (toolbar, "Target", &index);    Toolbar_GetItemAttribute(toolbar, index, TOOLBAR_ATTR_WIDTH, &i);    Toolbar_SetItemAttribute(toolbar, index, TOOLBAR_ATTR_WIDTH, 80);    Toolbar_Display (toolbar);        Toolbar_SetItemAttribute(toolbar, control, TOOLBAR_ATTR_WIDTH, 100);

⌨️ 快捷键说明

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