📄 userinfo.cxx
字号:
{ // Name input box NxInput *ip; // Input widget ip = new NxInput(grpx, grpy, input_width, 20, "Name: "); ip->when(FL_WHEN_CHANGED); ip->callback(input_cb, (void *) this); ip->maximum_size(_Inputs[0].dta_sz = 40); _Inputs[0].dta_flags = UI_DFLAGS_SL | UI_APW; _Inputs[0].fld_name = UI_FLD_NAME; _Inputs[0].input = ip; grpy += 20 + 5; } // end of Name field { NxInput *ip; // Input widget ip = new NxInput(grpx, grpy, input_width, 20, "Company: "); ip->when(FL_WHEN_CHANGED); ip->callback(input_cb, (void *) this); ip->maximum_size(_Inputs[1].dta_sz = 40); _Inputs[1].fld_name = UI_FLD_COMPANY; _Inputs[1].dta_flags = UI_DFLAGS_SL | UI_GENERIC; _Inputs[1].input = ip; grpy += 20 + 10; } // end of Company Field { Fl_Editor *mip; long ed_flags; mip = new Fl_Editor(grpx, grpy, input_width, 20 * 3 + 1, "Address: \n\n\n\n\n"); instance->def_font(mip); mip->box(FL_BORDER_BOX); mip->align(FL_ALIGN_LEFT); ed_flags = mip->Engine()->GetFlags(); ed_flags |= EF_BYTELIMITS; mip->Engine()->SetFlags(ed_flags); mip->when(FL_WHEN_CHANGED); mip->callback(input_cb, (void *) this); mip->Engine()->SetMaxChar((_Inputs[2].dta_sz = 132)); _Inputs[2].fld_name = UI_FLD_ADDRESS; _Inputs[2].dta_flags = UI_DFLAGS_ML | UI_GENERIC; _Inputs[2].input = mip; grpy += (3 * 20) + 5; } // end of Address field { NxInput *ip; ip = new NxInput(grpx, grpy, input_width, 20, "Phone: "); ip->when(FL_WHEN_CHANGED); ip->callback(input_cb, (void *) this); ip->maximum_size(_Inputs[3].dta_sz = 24); _Inputs[3].fld_name = UI_FLD_PHONE; _Inputs[3].dta_flags = UI_DFLAGS_SL | UI_GENERIC;// Changed the validation of the field to allow anything, as suggested by Jeff Clausen// _Inputs[3].dta_flags = UI_DFLAGS_SL | UI_DFLAGS_NUMERIC | UI_DFLAGS_WHITESP | UI_DFLAGS_ALPHA; _Inputs[3].input = ip; grpy += (20 + 5); } // end of Phone field { NxInput *ip; ip = new NxInput(grpx, grpy, input_width, 20, "Email: "); ip->when(FL_WHEN_CHANGED); ip->callback(input_cb, (void *) this); ip->maximum_size(_Inputs[4].dta_sz = 40); _Inputs[4].fld_name = UI_FLD_EMAIL; _Inputs[4].dta_flags = UI_DFLAGS_SL | UI_GENERIC; _Inputs[4].input = ip; } // end of input widget definitions... g1->end(); _userInfog = g1; } // end of ID tab group { Fl_Group *g2; // Notes Tab Group int grpx, grpy = cury + (3 * mar); g2 = new Fl_Group(curx, cury, o->w(), o->h() - 20); g2->box(FL_FLAT_BOX); g2->label("Notes"); instance->def_font(g2); g2->color(_mainw->color()); grpx = g2->x() + (int) max_lbl_wid; { Fl_Editor *mip; // Editor box long ed_flags; mip = new Fl_Editor(grpx, grpy, input_width, 7 * 20, "Notes: \n\n\n\n\n\n\n\n\n\n\n"); mip->align(FL_ALIGN_LEFT); ed_flags = mip->Engine()->GetFlags(); ed_flags |= EF_BYTELIMITS; mip->Engine()->SetFlags(ed_flags); mip->Engine()->SetMaxChar((_Inputs[5].dta_sz = 220)); _Inputs[5].fld_name = UI_FLD_NOTES; _Inputs[5].dta_flags = UI_DFLAGS_ML | UI_GENERIC; _Inputs[5].input = mip; } // end of input widget definitions g2->end(); _notesg = g2; } // end of Notes tab group o->end(); _mainTab = o; } // end of Tab widget _mainw->end(); _mainw->hide(); return;} // end of NxUserInfo::MakeWindow(void)voidNxUserInfo::ShowWindow(void){ _mainw->show();}voidNxUserInfo::HideWindow(void){ _mainw->hide();}/*******************************************************************************\**** Function: void SetAppPrefs()** Desc: Stores any changed values into the PAR database** Accepts: Nothing (void)** Returns: Nothing (void)** \*******************************************************************************/voidNxUserInfo::SetAppPrefs(void){ char *pardb, // Database name par_data[512]; // Par data int idx, // Quick index variable rc; // Result code db_handle *hdb; // Database handle if ((pardb = db_getDefaultDB()) == NULL) { printf("No Default database! Changes lost"); return; } // end of if if ((hdb = db_openDB(pardb, PAR_DB_MODE_RW)) == NULL) { printf("Unable to open %s, error=%d", pardb, pardb_errno); return; } // end of if // Write out any changes for (idx = 0; idx < UI_FLD_MAXFLDS; idx++) { memset(par_data, 0, sizeof(par_data)); if (_Inputs[idx].dta_flags & UI_DFLAGS_DIRTY) { if (_Inputs[idx].dta_flags & UI_DFLAGS_SL) { NxInput *nxip = (NxInput *) _Inputs[idx].input; strcpy(par_data, nxip->value()); } // end of if else { Fl_Editor *nxip = (Fl_Editor *) _Inputs[idx].input; nxip->SaveTo(par_data); } // end of else rc = par_setGlobalPref(hdb, "UserId", const_cast < char *>(ParIds[_Inputs[idx].fld_name]), PAR_TEXT, par_data, strlen(par_data)); _Inputs[idx].dta_flags &= ~UI_DFLAGS_DIRTY; } // end of if } // end of for char col_msg[CL_MAX_MSG_LEN] = { '\0' }; int col_len = sprintf(col_msg, "sc_userinfo^SYSCON_UI_CHANGE"); sysconf_ipc_write(CL_MSG_BROADCAST_ID, col_msg, col_len); return;} // end of NxUserInfo::SetAppPrefs(void)/*******************************************************************************\**** Function: void input_cp()** Desc: Callback for any input in an input widget** Accepts: Fl_Widget *w = Ptr to the widget responsible for the branch** void *d = Ptr to any ancillary data** Returns: Nothing (void)**\*******************************************************************************/voidNxUserInfo::input_cb(Fl_Widget * w, void *d){ char *cp; int i, pos, rc, sz; NxUserInfo *me = (NxUserInfo *) d; NxInput *nxip = NULL; // Find the correct widget, and automatically mark him as being dirty for (i = 0; i < UI_FLD_MAXFLDS; i++) { if (w == me->_Inputs[i].input) { if (me->_Inputs[i].dta_flags & UI_DFLAGS_SL) { nxip = (NxInput *) w; me->_Inputs[i].dta_flags |= UI_DFLAGS_DIRTY; break; } // end of else } // end of if } // end of for if (nxip == NULL) return; // Determine if a character was added... if ((rc = Fl::event_key()) >= FL_Button || !rc) return; sz = nxip->size() + 1; pos = nxip->position(); cp = (char *) calloc(sz + 1, sizeof(char)); if (cp == NULL) return; strcpy(cp, nxip->value()); // This is a generic field validator, specific fields will have to // be identified and handled separately... if (!VALIDATE_CHAR(cp[pos - 1], me->_Inputs[i].dta_flags)) { printf("Invalid character for this field!\n"); memmove(&cp[pos - 1], &cp[pos], sz - pos); nxip->value(cp); nxip->position(pos - 1); nxip->redraw(); } // end of if free(cp); return;} // end of NxUserInfo::input_cb(Fl_Widget *, void *)/*******************************************************************************\**** Function: void save_reset_cb()** Desc: Callback for saving/reseting data** Accepts: Fl_Widget *w = Ptr to widget responsible for the branch** void *d = Ptr to any ancillary data** Returns: Nothing (void)**\*******************************************************************************/voidNxUserInfo::save_reset_cb(Fl_Widget * w, void *d){ NxUserInfo *me = (NxUserInfo *) d; NxButton *btn = (NxButton *) w; if (me->_saveb == btn) { // Save things.... for (int i = 0; i < UI_FLD_MAXFLDS; i++) { if (me->_Inputs[i].dta_flags & UI_DFLAGS_ML) { Fl_Editor *nxip = (Fl_Editor *) me->_Inputs[i].input; if (nxip->changed() == true) me->_Inputs[i].dta_flags |= UI_DFLAGS_DIRTY; } // end of if } // end of for me->SetAppPrefs(); } // end of if else { // Reset the values me->GetAppPrefs(); } return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -