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

📄 test3.c

📁 安装DDD之前
💻 C
📖 第 1 页 / 共 2 页
字号:
    sprintf(number_string," %1d",MAX_SWITCH-i);    label_string = XmStringCreateLtoR(number_string,				     XmSTRING_DEFAULT_CHARSET);    switch_label[i] = XtVaCreateManagedWidget( "switch_label",				       xmLabelGadgetClass,switch_box,                                       XmNlabelString,label_string,				       XmNleftAttachment,XmATTACH_WIDGET,				       XmNleftWidget,on_off_box[i-1],				       NULL);    on_off_box[i] = XtVaCreateManagedWidget( "on_off_box",				       xmRowColumnWidgetClass,switch_box,				       XmNtopAttachment,XmATTACH_WIDGET,				       XmNtopWidget,switch_label[i],				       XmNleftAttachment,XmATTACH_WIDGET,				       XmNleftWidget,on_off_box[i-1],                                       XmNradioBehavior,TRUE,                                       XmNorientation,XmVERTICAL,				       XmNpacking,XmPACK_TIGHT,                                       NULL);    on_switches[i] = XtVaCreateManagedWidget( "on_switches",				       xmToggleButtonGadgetClass,on_off_box[i],                                       XmNlabelString,dummy_string,				       NULL);    XtAddCallback(on_switches[i],XmNvalueChangedCallback,toggled_proc,NULL);    off_switches[i] = XtVaCreateManagedWidget( "off_switches",				       xmToggleButtonGadgetClass,on_off_box[i],                                       XmNlabelString,dummy_string,				       XmNset,TRUE,     				       NULL);    XtAddCallback(off_switches[i],XmNvalueChangedCallback,toggled_proc,NULL);    XmStringFree(label_string);  }  XmStringFree(dummy_string);  label_string = XmStringCreateLtoR("on",				     XmSTRING_DEFAULT_CHARSET);  switch_on_label = XtVaCreateManagedWidget( "switch_on_label",				       xmLabelGadgetClass,switch_box,                                       XmNlabelString,label_string,				       XmNleftAttachment,XmATTACH_WIDGET,				       XmNleftWidget,on_off_box[MAX_SWITCH-1],				       XmNtopAttachment,XmATTACH_WIDGET,				       XmNtopWidget,switch_label[MAX_SWITCH-1],				       NULL);  XmStringFree(label_string);  label_string = XmStringCreateLtoR("off",				     XmSTRING_DEFAULT_CHARSET);  switch_off_label = XtVaCreateManagedWidget( "switch_off_label",			  	      xmLabelGadgetClass,switch_box,                          	      XmNlabelString,label_string,			  	      XmNleftAttachment,XmATTACH_WIDGET,			  	      XmNleftWidget,on_off_box[MAX_SWITCH-1],			  	      XmNtopAttachment,XmATTACH_WIDGET,			  	      XmNtopWidget,switch_on_label,				      XmNtopOffset,5,			  	      NULL);  XmStringFree(label_string);  /*    Treat the simulated ADC    */  label_string = XmStringCreateLtoR("ADC input level",				     XmSTRING_DEFAULT_CHARSET);    adc_label = XtVaCreateManagedWidget("adc_label", 				      xmLabelGadgetClass,                                      form,				      XmNtopAttachment,XmATTACH_WIDGET,				      XmNtopWidget,switch_box,				      XmNtopOffset,30,				      XmNleftAttachment,XmATTACH_FORM,				      XmNleftOffset,30,				      XmNlabelString,label_string,                                      NULL);  XmStringFree(label_string);  adc_slider = XtVaCreateManagedWidget( "slider",				       xmScaleWidgetClass,form,				       XmNtopAttachment,XmATTACH_WIDGET,                                       XmNtopWidget,adc_label,				       XmNtopOffset,10,				       XmNleftAttachment,XmATTACH_FORM,				       XmNleftOffset,30,				       XmNminimum,0,				       XmNmaximum,MAX_ADC,				       XmNscaleWidth,250,				       XmNorientation,XmHORIZONTAL,				       XmNshowValue,TRUE,				       NULL);  XtRealizeWidget(toplevel);/* Note: the following values are the result of * querying the current geometry. */{#if XmVERSION > 1static XtWidgetGeometry Expected[] = {   {CWWidth | CWHeight            ,  243,  311,  180,  306, 0,0,0, /* main_window */},   {CWWidth | CWHeight | CWX | CWY,    0,   31,  180,    2, 0,0,0, /* Separator1 */},   {CWWidth | CWHeight | CWX | CWY,    0,   33,  180,  273, 0,0,0, /* form */},   {CWWidth | CWHeight | CWX | CWY,   30,   30,   58,   17, 0,0,0, /* lcd_label */},   {CWWidth | CWHeight | CWX | CWY,   30,   47,   98,   21, 0,0,0, /* lcd_frame */},   {CWWidth | CWHeight | CWX | CWY,    2,    2,   94,   17, 0,0,0, /* lcd */},   {CWWidth | CWHeight | CWX | CWY,  158,   30,   58,   17, 0,0,0, /* led_label */},   {CWWidth | CWHeight | CWX | CWY,  158,   47,  217,   48, 0,0,0, /* led_frame */},   {CWWidth | CWHeight | CWX | CWY,    2,    2,  213,   44, 0,0,0, /* led_clumn */},   {CWWidth | CWHeight | CWX | CWY,    3,    3,   14,   34, 0,0,0, /* led */},   {CWWidth | CWHeight | CWX | CWY,   24,    3,   14,   34, 0,0,0, /* led */},   {CWWidth | CWHeight | CWX | CWY,   45,    3,   14,   34, 0,0,0, /* led */},   {CWWidth | CWHeight | CWX | CWY,   66,    3,   14,   34, 0,0,0, /* led */},   {CWWidth | CWHeight | CWX | CWY,   87,    3,   14,   34, 0,0,0, /* led */},   {CWWidth | CWHeight | CWX | CWY,  108,    3,   14,   34, 0,0,0, /* led */},   {CWWidth | CWHeight | CWX | CWY,  129,    3,   14,   34, 0,0,0, /* led */},   {CWWidth | CWHeight | CWX | CWY,  150,    3,   14,   34, 0,0,0, /* led */},   {CWWidth | CWHeight | CWX | CWY,  171,    3,   14,   34, 0,0,0, /* led */},   {CWWidth | CWHeight | CWX | CWY,  192,    3,   14,   34, 0,0,0, /* led */},   {CWWidth | CWHeight | CWX | CWY,   30,   98,   52,   17, 0,0,0, /* switches_label */},   {CWWidth | CWHeight | CWX | CWY,   30,  115,  238,   66, 0,0,0, /* switch_box */},   {CWWidth | CWHeight | CWX | CWY,    0,    0,   16,   17, 0,0,0, /* switch_label */},   {CWWidth | CWHeight | CWX | CWY,    0,   17,   27,   49, 0,0,0, /* on_off_box */},   {CWWidth | CWHeight | CWX | CWY,    3,    3,   21,   20, 0,0,0, /* on_switches */},   {CWWidth | CWHeight | CWX | CWY,    3,   26,   21,   20, 0,0,0, /* off_switches */},   {CWWidth | CWHeight | CWX | CWY,   27,    0,   16,   17, 0,0,0, /* switch_label */},   {CWWidth | CWHeight | CWX | CWY,   27,   17,   27,   49, 0,0,0, /* on_off_box */},   {CWWidth | CWHeight | CWX | CWY,    3,    3,   21,   20, 0,0,0, /* on_switches */},   {CWWidth | CWHeight | CWX | CWY,    3,   26,   21,   20, 0,0,0, /* off_switches */},   {CWWidth | CWHeight | CWX | CWY,   54,    0,   16,   17, 0,0,0, /* switch_label */},   {CWWidth | CWHeight | CWX | CWY,   54,   17,   27,   49, 0,0,0, /* on_off_box */},   {CWWidth | CWHeight | CWX | CWY,    3,    3,   21,   20, 0,0,0, /* on_switches */},   {CWWidth | CWHeight | CWX | CWY,    3,   26,   21,   20, 0,0,0, /* off_switches */},   {CWWidth | CWHeight | CWX | CWY,   81,    0,   16,   17, 0,0,0, /* switch_label */},   {CWWidth | CWHeight | CWX | CWY,   81,   17,   27,   49, 0,0,0, /* on_off_box */},   {CWWidth | CWHeight | CWX | CWY,    3,    3,   21,   20, 0,0,0, /* on_switches */},   {CWWidth | CWHeight | CWX | CWY,    3,   26,   21,   20, 0,0,0, /* off_switches */},   {CWWidth | CWHeight | CWX | CWY,  108,    0,   16,   17, 0,0,0, /* switch_label */},   {CWWidth | CWHeight | CWX | CWY,  108,   17,   27,   49, 0,0,0, /* on_off_box */},   {CWWidth | CWHeight | CWX | CWY,    3,    3,   21,   20, 0,0,0, /* on_switches */},   {CWWidth | CWHeight | CWX | CWY,    3,   26,   21,   20, 0,0,0, /* off_switches */},   {CWWidth | CWHeight | CWX | CWY,  135,    0,   16,   17, 0,0,0, /* switch_label */},   {CWWidth | CWHeight | CWX | CWY,  135,   17,   27,   49, 0,0,0, /* on_off_box */},   {CWWidth | CWHeight | CWX | CWY,    3,    3,   21,   20, 0,0,0, /* on_switches */},   {CWWidth | CWHeight | CWX | CWY,    3,   26,   21,   20, 0,0,0, /* off_switches */},   {CWWidth | CWHeight | CWX | CWY,  162,    0,   16,   17, 0,0,0, /* switch_label */},   {CWWidth | CWHeight | CWX | CWY,  162,   17,   27,   49, 0,0,0, /* on_off_box */},   {CWWidth | CWHeight | CWX | CWY,    3,    3,   21,   20, 0,0,0, /* on_switches */},   {CWWidth | CWHeight | CWX | CWY,    3,   26,   21,   20, 0,0,0, /* off_switches */},   {CWWidth | CWHeight | CWX | CWY,  189,    0,   16,   17, 0,0,0, /* switch_label */},   {CWWidth | CWHeight | CWX | CWY,  189,   17,   27,   49, 0,0,0, /* on_off_box */},   {CWWidth | CWHeight | CWX | CWY,    3,    3,   21,   20, 0,0,0, /* on_switches */},   {CWWidth | CWHeight | CWX | CWY,    3,   26,   21,   20, 0,0,0, /* off_switches */},   {CWWidth | CWHeight | CWX | CWY,  216,   17,   16,   17, 0,0,0, /* switch_on_label */},   {CWWidth | CWHeight | CWX | CWY,  216,   39,   22,   17, 0,0,0, /* switch_off_label */},   {CWWidth | CWHeight | CWX | CWY,   30,  211,   94,   17, 0,0,0, /* adc_label */},   {CWWidth | CWHeight | CWX | CWY,   30,  238,  250,   35, 0,0,0, /* slider */},   {CWWidth | CWHeight | CWX | CWY,    0,   16,  250,   19, 0,0,0, /* Scrollbar */},   {CWWidth | CWHeight | CWX | CWY,    0,    0,  180,   31, 0,0,0, /* menu_bar */},   {CWWidth | CWHeight | CWX | CWY,    5,    5,   40,   21, 0,0,0, /* file_button */},};#elsestatic XtWidgetGeometry Expected[] = {   CWWidth | CWHeight            ,  771,  192,  180,  314, 0,0,0, /* main_window */   CWWidth | CWHeight | CWX | CWY,    0,   31,  180,    2, 0,0,0, /* Separator1 */   CWWidth | CWHeight | CWX | CWY,    0,   33,  180,  281, 0,0,0, /* form */   CWWidth | CWHeight | CWX | CWY,   30,   30,   58,   17, 0,0,0, /* lcd_label */   CWWidth | CWHeight | CWX | CWY,   30,   47,   98,   21, 0,0,0, /* lcd_frame */   CWWidth | CWHeight | CWX | CWY,    2,    2,   94,   17, 0,0,0, /* lcd */   CWWidth | CWHeight | CWX | CWY,  158,   30,   58,   17, 0,0,0, /* led_label */   CWWidth | CWHeight | CWX | CWY,  158,   47,  217,   48, 0,0,0, /* led_frame */   CWWidth | CWHeight | CWX | CWY,    2,    2,  213,   44, 0,0,0, /* led_clumn */   CWWidth | CWHeight | CWX | CWY,    3,    3,   14,   34, 0,0,0, /* led */   CWWidth | CWHeight | CWX | CWY,   24,    3,   14,   34, 0,0,0, /* led */   CWWidth | CWHeight | CWX | CWY,   45,    3,   14,   34, 0,0,0, /* led */   CWWidth | CWHeight | CWX | CWY,   66,    3,   14,   34, 0,0,0, /* led */   CWWidth | CWHeight | CWX | CWY,   87,    3,   14,   34, 0,0,0, /* led */   CWWidth | CWHeight | CWX | CWY,  108,    3,   14,   34, 0,0,0, /* led */   CWWidth | CWHeight | CWX | CWY,  129,    3,   14,   34, 0,0,0, /* led */   CWWidth | CWHeight | CWX | CWY,  150,    3,   14,   34, 0,0,0, /* led */   CWWidth | CWHeight | CWX | CWY,  171,    3,   14,   34, 0,0,0, /* led */   CWWidth | CWHeight | CWX | CWY,  192,    3,   14,   34, 0,0,0, /* led */   CWWidth | CWHeight | CWX | CWY,   30,   98,   52,   17, 0,0,0, /* switches_label */   CWWidth | CWHeight | CWX | CWY,   30,  115,  270,   74, 0,0,0, /* switch_box */   CWWidth | CWHeight | CWX | CWY,    0,    0,   16,   17, 0,0,0, /* switch_label */   CWWidth | CWHeight | CWX | CWY,    0,   17,   31,   57, 0,0,0, /* on_off_box */   CWWidth | CWHeight | CWX | CWY,    3,    3,   25,   24, 0,0,0, /* on_switches */   CWWidth | CWHeight | CWX | CWY,    3,   30,   25,   24, 0,0,0, /* off_switches */   CWWidth | CWHeight | CWX | CWY,   31,    0,   16,   17, 0,0,0, /* switch_label */   CWWidth | CWHeight | CWX | CWY,   31,   17,   31,   57, 0,0,0, /* on_off_box */   CWWidth | CWHeight | CWX | CWY,    3,    3,   25,   24, 0,0,0, /* on_switches */   CWWidth | CWHeight | CWX | CWY,    3,   30,   25,   24, 0,0,0, /* off_switches */   CWWidth | CWHeight | CWX | CWY,   62,    0,   16,   17, 0,0,0, /* switch_label */   CWWidth | CWHeight | CWX | CWY,   62,   17,   31,   57, 0,0,0, /* on_off_box */   CWWidth | CWHeight | CWX | CWY,    3,    3,   25,   24, 0,0,0, /* on_switches */   CWWidth | CWHeight | CWX | CWY,    3,   30,   25,   24, 0,0,0, /* off_switches */   CWWidth | CWHeight | CWX | CWY,   93,    0,   16,   17, 0,0,0, /* switch_label */   CWWidth | CWHeight | CWX | CWY,   93,   17,   31,   57, 0,0,0, /* on_off_box */   CWWidth | CWHeight | CWX | CWY,    3,    3,   25,   24, 0,0,0, /* on_switches */   CWWidth | CWHeight | CWX | CWY,    3,   30,   25,   24, 0,0,0, /* off_switches */   CWWidth | CWHeight | CWX | CWY,  124,    0,   16,   17, 0,0,0, /* switch_label */   CWWidth | CWHeight | CWX | CWY,  124,   17,   31,   57, 0,0,0, /* on_off_box */   CWWidth | CWHeight | CWX | CWY,    3,    3,   25,   24, 0,0,0, /* on_switches */   CWWidth | CWHeight | CWX | CWY,    3,   30,   25,   24, 0,0,0, /* off_switches */   CWWidth | CWHeight | CWX | CWY,  155,    0,   16,   17, 0,0,0, /* switch_label */   CWWidth | CWHeight | CWX | CWY,  155,   17,   31,   57, 0,0,0, /* on_off_box */   CWWidth | CWHeight | CWX | CWY,    3,    3,   25,   24, 0,0,0, /* on_switches */   CWWidth | CWHeight | CWX | CWY,    3,   30,   25,   24, 0,0,0, /* off_switches */   CWWidth | CWHeight | CWX | CWY,  186,    0,   16,   17, 0,0,0, /* switch_label */   CWWidth | CWHeight | CWX | CWY,  186,   17,   31,   57, 0,0,0, /* on_off_box */   CWWidth | CWHeight | CWX | CWY,    3,    3,   25,   24, 0,0,0, /* on_switches */   CWWidth | CWHeight | CWX | CWY,    3,   30,   25,   24, 0,0,0, /* off_switches */   CWWidth | CWHeight | CWX | CWY,  217,    0,   16,   17, 0,0,0, /* switch_label */   CWWidth | CWHeight | CWX | CWY,  217,   17,   31,   57, 0,0,0, /* on_off_box */   CWWidth | CWHeight | CWX | CWY,    3,    3,   25,   24, 0,0,0, /* on_switches */   CWWidth | CWHeight | CWX | CWY,    3,   30,   25,   24, 0,0,0, /* off_switches */   CWWidth | CWHeight | CWX | CWY,  248,   17,   16,   17, 0,0,0, /* switch_on_label */   CWWidth | CWHeight | CWX | CWY,  248,   39,   22,   17, 0,0,0, /* switch_off_label */   CWWidth | CWHeight | CWX | CWY,   30,  219,   94,   17, 0,0,0, /* adc_label */   CWWidth | CWHeight | CWX | CWY,   30,  246,  250,   35, 0,0,0, /* slider */   CWWidth | CWHeight | CWX | CWY,    0,   16,  250,   19, 0,0,0, /* Scrollbar */   CWWidth | CWHeight | CWX | CWY,    0,    0,  180,   31, 0,0,0, /* menu_bar */   CWWidth | CWHeight | CWX | CWY,    5,    5,   40,   21, 0,0,0, /* file_button */};#endif/* toplevel should be replaced with to correct applicationShell */PrintDetails(toplevel, Expected);}LessTifTestMainLoop(toplevel);  exit(0);}/*==========================================================*/void exit_proc(Widget w,XtPointer client_data,XtPointer call_data)/*==========================================================*/{   exit(0);}/*==========================================================*/void test_proc(Widget w,XtPointer client_data,XtPointer call_data)/*==========================================================*/{  if (strcmp(XtName(w),"on_switches") == 0)     XtVaSetValues(leds[0],XmNlabelPixmap,led_on_pixmap,NULL);  else    XtVaSetValues(leds[0],XmNlabelPixmap,led_off_pixmap,NULL);}/*==========================================================*/void toggled_proc(Widget w,XtPointer client_data,XtPointer call_data)/*==========================================================*/{  int i;  XmToggleButtonCallbackStruct *state =      (XmToggleButtonCallbackStruct *) call_data;  for (i=0;i<MAX_SWITCH;i++)  {    if (XtParent(w) == on_off_box[i])     {      if (strcmp(XtName(w),"on_switches") == 0)       {	if (state -> set) 	{           ICTP_IO_switch_state |= 1<<(MAX_SWITCH-i-1);        }        else        {           ICTP_IO_switch_state &= ~(1<<(MAX_SWITCH-i-1));        }      }    }  }printf("%x\n",ICTP_IO_switch_state);}

⌨️ 快捷键说明

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