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

📄 nxfindapp.cxx

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CXX
📖 第 1 页 / 共 2 页
字号:
    }}c_statusWindow::~c_statusWindow(){}voidc_statusWindow::setStatus(char *status){    status_msg->value(status);}voidc_statusWindow::statusCancel_callback(Fl_Widget * fl, void *l){    expectingResults = false;    cancelSearch = true;    NxApp::Instance()->show_window(((NxFind *) (NxApp::Instance()))->				   getFindWindow()->GetWindowPtr());}voidc_statusWindow::hide(){    DPRINT("in hide window\n");    if (0 == ((NxFind *) (NxApp::Instance()))->getTotalFound()) {	((NxFind *) (NxApp::Instance()))->getResultsMessage()->show();	((NxFind *) (NxApp::Instance()))->getResultsTable()->hide();    } else {	((NxFind *) (NxApp::Instance()))->getResultsMessage()->hide();	((NxFind *) (NxApp::Instance()))->getResultsTable()->show();    }    ((NxFind *) (NxApp::Instance()))->getResultsTable()->	rows(((NxFind *) (NxApp::Instance()))->getTotalFound());    NxApp::Instance()->show_window(((NxFind *) (NxApp::Instance()))->				   getResultWindow()->GetWindowPtr());}voidc_statusWindow::show(){    //((NxFind*)(NxApp::Instance()))->getFindWindow()->GetWindowPtr()->deactivate();    ((NxFind *) (NxApp::Instance()))->getStatusWindow()->GetWindowPtr()->	show();}voidc_statusWindow::setCurNode(Fl_Toggle_Node * node){    curNode = node;}char *c_statusWindow::getNextService(){    if (NULL == curNode)	curNode =	    ((NxFind *) (NxApp::Instance()))->getAppTree()->traverse_start();    else	curNode =	    ((NxFind *) (NxApp::Instance()))->getAppTree()->	    traverse_forward();    while (curNode) {	if (true == ((NxAppData *) curNode->user_data())->appSearch)	    return ((NxAppData *) curNode->user_data())->nxAppName;	else	    curNode =		((NxFind *) (NxApp::Instance()))->getAppTree()->		traverse_forward();    }    DPRINT("return NULL\n");    return NULL;}char *c_statusWindow::getApp(){    if (curNode) {	return ((NxAppData *) curNode->user_data())->appName;    }    return NULL;}voidc_statusWindow::search(){    int ipc_id = -1;    char *msg = new char[CL_MAX_MSG_LEN];    //sleep(1);    // FIXME start app if needed something like this FIXME    // if (0 > oinf_fd) {    //      flags = some_flags    //      oin_fd = colosseum_start(appName, flags);           //      }    bool stringCheck =	((NxFind *) (NxApp::Instance()))->getStringCheckValue();    bool dateCheck = ((NxFind *) (NxApp::Instance()))->getDateCheckValue();    if (stringCheck == true && dateCheck == false) {	// FIXME	//  when the PAR database is done need to determine if 	//  service can search on strings. Currently all service	//  can search on string values	// send the search request	ipc_id = NxApp::Instance()->StartApp(getService(), 0, 2, 10);	DPRINT("service [%s] for ipc_id[%d]\n", getService(), ipc_id);	if (ipc_id <= 0)	    return;	initiateSearch(ipc_id);	sprintf(msg, "nxfind^EXECUTE^search^%s^%d^",		((NxFind *) (NxApp::Instance()))->getLookupInput()->value(),		((NxFind *) (NxApp::Instance()))->getResultsTable()->		text_width());	executeSearch(ipc_id, msg);    }    if (stringCheck == false && dateCheck == true) {	// FIXME	// when the PAR database is done need to determine if	// service can search on dates.  Currently only schedule	// searches on dates.	if (0 == strcmp("nxschedule", getService()) ||	    0 == strcmp("nxtodo", getService())) {	    // send the search request	    ipc_id = NxApp::Instance()->StartApp(getService(), 0, 2, 10);	    DPRINT("service [%s] for ipc_id[%d]\n", getService(), ipc_id);	    if (ipc_id <= 0)		return;	    initiateSearch(ipc_id);	    sprintf(msg, "nxfind^EXECUTE^datesearch^%d^%ld^%ld^",		    ((NxFind *) (NxApp::Instance()))->getResultsTable()->		    text_width(),		    ((NxFind *) (NxApp::Instance()))->getStartTime(),		    ((NxFind *) (NxApp::Instance()))->getEndTime());	    executeSearch(ipc_id, msg);	}    }    if (stringCheck == true && dateCheck == true) {	// FIXME	// when the PAR database is done need to determine if 	// the sevice can search on dates and string. Currently only schedule	// searches on dates and strings.	if (0 == strcmp("nxschedule", getService()) ||	    0 == strcmp("nxtodo", getService())) {	    ipc_id = NxApp::Instance()->StartApp(getService(), 0, 2, 10);	    DPRINT("service [%s] for ipc_id[%d]\n", getService(), ipc_id);	    if (ipc_id <= 0)		return;	    initiateSearch(ipc_id);	    sprintf(msg, "nxfind^EXECUTE^search^%s^%d^%ld^%ld^",		    ((NxFind *) (NxApp::Instance()))->getLookupInput()->		    value(),		    ((NxFind *) (NxApp::Instance()))->getResultsTable()->		    text_width(),		    ((NxFind *) (NxApp::Instance()))->getStartTime(),		    ((NxFind *) (NxApp::Instance()))->getEndTime());	    executeSearch(ipc_id, msg);	}    }    delete[]msg;    msg = 0;}voidc_statusWindow::initiateSearch(int ipc_id){    char *msg = new char[CL_MAX_MSG_LEN];    sprintf(msg, "nxfind^INITIATE^0^");    int x = NxApp::Instance()->Write_Fd(ipc_id, msg, CL_MAX_MSG_LEN);    delete[]msg;    msg = 0;}voidc_statusWindow::executeSearch(int ipc_id, char *msg){    char format_string[512];    NxSearchData *data = new NxSearchData;;    DPRINT("Writing message [%s] for ipc_id[%d]\n", msg, ipc_id);    int x = NxApp::Instance()->Write_Fd(ipc_id, msg, CL_MAX_MSG_LEN);    data->recno = APP_DESC;    strcpy(data->appName, getService());    strcpy(data->data, getAppNameString(format_string));    ((NxFind *) (NxApp::Instance()))->addData(data);}char *c_statusWindow::getAppNameString(char *format_string){    Fl_Toggle_Tree *pTree = ((NxFind *) (NxApp::Instance()))->getAppTree();    Flv_Table_Child *pTable =	((NxFind *) (NxApp::Instance()))->getResultsTable();    int width = pTable->text_width();    int sep_width = (int) fl_width("-");    int string_width = 0;    int diff_width = 0;    int sep_count = 0;    Fl_Toggle_Node *node = 0;    NxAppData *data = 0;    char sep_string[128];    fl_font(DEFAULT_TEXT_FONT, DEFAULT_TEXT_SIZE);    node = pTree->traverse_start();    while (node) {	data = ((NxAppData *) node->user_data());	if (0 == strcmp(data->nxAppName, getService())) {	    string_width = (int) fl_width(data->appName);	    diff_width = (width - string_width) / 2;	    if (0 >= diff_width)		return data->appName;	    else {		sep_count = diff_width / sep_width;		if (0 < sep_count) {		    if (sep_count > 128)			sep_count = 128;		    memset(sep_string, 0, sizeof(sep_string));		    for (int idx = 0; idx <= sep_count; idx++)			sep_string[idx] = '-';		    sprintf(format_string, "%s%s%s", sep_string,			    data->appName, sep_string);		    return format_string;		} else {		    return data->appName;		}	    }	}	node = pTree->traverse_forward();    }    return NULL;}voidNxFind::viewRecord(NxSearchData * data){    int ipc_id = -1;    char *msg = new char[CL_MAX_MSG_LEN];#ifdef NOTUSED    ipc_id = NxApp::Instance()->Find_Fd(data->appName);    if (0 > ipc_id)	return;    // start app if needed something like this          // if (0 > oinf_fd) {    //      flags = some_flags    //      oin_fd = colosseum_start(appName, flags);           //      }#endif    ipc_id = NxApp::Instance()->StartApp(data->appName, 0, 0);    if (ipc_id <= 0)	return;    sprintf(msg, "nxfind^INITIATE^0^");    NxApp::Instance()->Write_Fd(ipc_id, msg, CL_MAX_MSG_LEN);    if (APP_FILE == data->recno)	sprintf(msg, "nxfind^EXECUTE^showrecord^%s^", data->fileName);    else	sprintf(msg, "nxfind^EXECUTE^showrecord^%d^", data->recno);    NxApp::Instance()->Write_Fd(ipc_id, msg, CL_MAX_MSG_LEN);    delete[]msg;    msg = 0;#ifdef CONFIG_NANOX    /* Now, contact the screentop and force the app to raise */    /* Only available in Nano-X (for now)                    */    scrtopShowApp(data->appName);#endif}voidNxFind::checkIt_callback(Fl_Widget * fl, void *l){    Fl_Toggle_Node *node = appTree->selected();    if (node) {	if ((Fl::event_x() >= 17) && (Fl::event_x() <= 29)) {	    appTree->unselect();	    if (node->pixmap() == echeck_pixmap) {		((NxAppData *) node->user_data())->appSearch = true;		node->pixmap(check_pixmap);	    } else if (node->pixmap() == check_pixmap) {		node->pixmap(echeck_pixmap);		((NxAppData *) node->user_data())->appSearch = false;	    }	}    }    if (appTree->selection_count() > 0)	appTree->unselect();}voidNxFind::addData(NxSearchData * data){    results_table->Add(total_found, data);    results_table->set_value(total_found, 0, data->data);    total_found++;}voidNxFind::searchLookup_callback(Fl_Widget * fl, void *l){    if ((stringCheck->value() == 0) && (dateCheck->value() == 0)) {	error_msg->value("Error: No Search Constraint.");	NxApp::Instance()->show_window(errorWindow->GetWindowPtr(),				       DEACTIVATE,				       findWindow->GetWindowPtr());	return;    }    if (0 == strcmp(lookup_input->value(), "") && (0 != stringCheck->value())) {	error_msg->value("Error: No search value!");	NxApp::Instance()->show_window(errorWindow->GetWindowPtr(),				       DEACTIVATE,				       findWindow->GetWindowPtr());	return;    }    Fl_Toggle_Node *node =	((NxFind *) (NxApp::Instance()))->getAppTree()->traverse_start();    int have_search = 0;    while (node) {	if (true == ((NxAppData *) node->user_data())->appSearch) {	    have_search = 1;	    break;	} else	    node =		((NxFind *) (NxApp::Instance()))->getAppTree()->		traverse_forward();    }    if (!have_search) {	error_msg->value("Error: No Application selected!");	NxApp::Instance()->show_window(errorWindow->GetWindowPtr(),				       DEACTIVATE,				       findWindow->GetWindowPtr());	return;    }    results_table->Init(255);    total_found = 0;    results_table->row(0);    status = startSearchStatus();    //statusWindow->setStatus("Searching...");    statusWindow->setExpectingFlag(true);    // have a thread to monitor status    //findWindow->GetWindowPtr()->hide();    //NxApp::Instance()->show_window(resultWindow->GetWindowPtr());}voidNxFind::fromCalendar_callback(Fl_Widget * fl, void *l){    NxFind *pThis = (NxFind *) l;    pThis->SetPickedDate(pThis->fromTime);    NxApp::Instance()->show_window(dateWindow->GetWindowPtr(),				   DEACTIVATE, findWindow->GetWindowPtr());    pThis->date_callback(fromDate_callback);}voidNxFind::toCalendar_callback(Fl_Widget * fl, void *l){    NxFind *pThis = (NxFind *) l;    pThis->SetPickedDate(pThis->toTime);    NxApp::Instance()->show_window(dateWindow->GetWindowPtr(),				   DEACTIVATE, findWindow->GetWindowPtr());    pThis->date_callback(toDate_callback);}voidNxFind::fromDate_callback(Fl_Widget * fl, void *l){    NxFind *pThis = (NxFind *) l;    pThis->dateWindow->GetWindowPtr()->hide();    pThis->show_window(findWindow->GetWindowPtr());    if (pThis->GetPickedDate()) {	pThis->fromTime = pThis->GetPickedDate();	pThis->UpdateFromButton();    }}voidNxFind::toDate_callback(Fl_Widget * fl, void *l){    NxFind *pThis = (NxFind *) l;    pThis->dateWindow->GetWindowPtr()->hide();    pThis->show_window(findWindow->GetWindowPtr());    if (pThis->GetPickedDate()) {	pThis->toTime = pThis->GetPickedDate();	pThis->UpdateToButton();    }}voidNxFind::doneLookup_callback(Fl_Widget * fl, void *l){    NxFind *pThis = (NxFind *) l;    static char fromBuf[30];    static char toBuf[30];    NxApp::Instance()->show_window(findWindow->GetWindowPtr(), ACTIVATE);    lookup_input->value("");    stringCheck->value(false);    dateCheck->value(false);    toTime = fromTime = time(0);    tm *tt = localtime(&fromTime);    //strftime(fromBuf, 29, "%b %d, %y", tt);    //strftime(toBuf, 29, "%b %d, %y", tt);    pThis->GetDateString(fromBuf, tt, sizeof(fromBuf), SHORT_YEAR);    pThis->GetDateString(toBuf, tt, sizeof(toBuf), SHORT_YEAR);    pThis->UpdateFromButton();    pThis->UpdateToButton();}voidNxFind::resultsView_callback(Fl_Widget * fl, void *l){    NxFind *pThis = (NxFind *) l;    NxSearchData *data = 0;    data = (NxSearchData *) results_table->selected();    if (Fl::event_clicks()) {	if (data) {	    if (APP_DESC == data->recno)		return;	    else {		pThis->viewRecord(data);	    }	}    }    Fl::event_clicks(0);}voidNxFind::errorOk_callback(Fl_Widget * fl, void *l){    NxApp::Instance()->show_window(findWindow->GetWindowPtr(),				   DEACTIVATE, errorWindow->GetWindowPtr());}voidNxFind::exit_callback(Fl_Widget * fl, void *l){    mainWindow->hide();    exit(0);}voidNxFind::add_apps(Fl_Toggle_Tree * _appTree){    int size = 0;    int count, i;    db_handle *db;    char *searchList, *l;    /* Dum, dah, dum, dum, dummmmmm! */    /* PAR to the rescue */    /* Fire up the PAR database, and load all the applications */    /* That are interested in global search */    db = db_openDB(db_getDefaultDB(), PAR_DB_MODE_RDONLY);    if (!db) {	printf("Error - Couldn't open the par database %s\n",	       db_getDefaultDB());	return;    }    size = par_getCapability(db, "nxgblsearch", (void **) &searchList);    if (size <= 0) {	return;    }    count = par_getStringListCount(searchList, ' ');    l = searchList;    for (i = 0; i < count; i++) {	Fl_Toggle_Node *appNode;	char title[50];	char *application = par_parseStringList(&l, ' ');	if (par_getAppTitle(db, application, title, sizeof(title)) <= 0)	    continue;	appNode = _appTree->add_next(title, 0, echeck_pixmap);	if (appNode) {	    NxAppData *data = new NxAppData;	    strcpy(data->appName, title);	    strcpy(data->nxAppName, application);	    data->appSearch = false;	    appNode->user_data(data);	    _appTree->traverse_up();	}    }    db_closeDB(db);}Fl_Window *NxFind::get_main_window(){    if (mainWindow)	return mainWindow;    else	return 0;}

⌨️ 快捷键说明

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