📄 selectwindow.cc
字号:
ruleselectwindow = new SelectWindow (display, gc, this, fontstruct, SELECTWINDOW_BORDERBESIDETEXT, ypos, windowwidth, 40, RuletypInfos, RULETYPNUMBER, CHANGESELECTED_ACTION, 0, SELECTWINDOWOPTION_EXCLUSIVESELECTION); ypos = ruleselectwindow->Gety () + ruleselectwindow->Getheight () + SELECTWINDOW_INSIDESPACE; } ParametertypInfos[0].options |= TEXTOPTION_SELECTED; for (counter = 1; counter < PARAMETERTYPNUMBER; counter++) ParametertypInfos[counter].options &= ~TEXTOPTION_SELECTED; parameterselectwindow = new SelectWindow (display, gc, this, fontstruct, SELECTWINDOW_BORDERBESIDETEXT, ypos, windowwidth, 60, ParametertypInfos, PARAMETERTYPNUMBER, CHANGESELECTED_ACTION, 0, SELECTWINDOWOPTION_EXCLUSIVESELECTION); ypos = parameterselectwindow->Gety () + parameterselectwindow->Getheight () + SELECTWINDOW_INSIDESPACE; char *newtext; newtext = (char *) malloc (sizeof (char) * DOUBLELENGTH + 2); sprintf (newtext, "%lf", threshold); char *thresholdtext = "threshold:"; short textwidthtextwidth = XTextWidth (fontstruct, thresholdtext, strlen (thresholdtext)); short textwidth = XTextWidth (fontstruct, newtext, strlen (newtext)) + SELECTWINDOW_INSIDESPACE; lowerbound = new TextBox (display, gc, this, fontstruct, textwidthtextwidth + 2 * SELECTWINDOW_BORDERBESIDETEXT, ypos, textwidth, textheight, 0, newtext, 0, TEXTOPTION_DOUBLEINPUT | TEXTOPTION_DARK, THRESHOLDCHANGE_ACTION, 0); ypos = lowerbound->Gety () + lowerbound->Getheight () + SELECTWINDOW_INSIDESPACE; char *hillvaluetext; hillvaluetext = (char *) malloc (sizeof (char) * DOUBLELENGTH + 2); sprintf (hillvaluetext, "%lf", hillheight); char *hilltext = "hillheight:"; textwidthtextwidth = XTextWidth (fontstruct, thresholdtext, strlen (hilltext)); textwidth = XTextWidth (fontstruct, newtext, strlen (newtext)) + SELECTWINDOW_INSIDESPACE; hillheightbox = new TextBox (display, gc, this, fontstruct, textwidthtextwidth + 2 * SELECTWINDOW_BORDERBESIDETEXT, ypos, textwidth, textheight, 0, hillvaluetext, 0, TEXTOPTION_DOUBLEINPUT | TEXTOPTION_DARK, HILLHEIGHTCHANGE_ACTION, 0); ypos = hillheightbox->Gety () + hillheightbox->Getheight () + SELECTWINDOW_INSIDESPACE; OK = new ActionIcon (display, gc, this, fontstruct, 35, ypos, 40, 30, "Ok", NULL, 0, 0, SELECTED_OK, ICON_SELECTABLE); Cancel = new ActionIcon (display, gc, this, fontstruct, 105, ypos, 40, 30, "Cancel", NULL, 0, 0, SELECTED_CANCEL, ICON_SELECTABLE);// now resize window to fit short depth; SizeMe (windowwidth + 2 * SELECTWINDOW_BORDERBESIDETEXT, OK->Gety () + OK->Getheight () + SELECTWINDOW_BORDERBESIDETEXT); depth = DefaultDepth (display, DefaultScreen (display)); pixmap = XCreatePixmap (display, window, width, height, depth); XSetForeground (display, gc, buttonpix); XFillRectangle (display, pixmap, gc, 0, 0, width, height); DrawBorder (pixmap, 0, 0, width, height, 0, 0, "", HIGH); DrawBorder (pixmap, lowerbound->Getx () - 2, lowerbound->Gety () - 2, lowerbound->Getwidth () + 2, lowerbound->Getheight () + 2, 0, 0, "", LOW); DrawBorder (pixmap, hillheightbox->Getx () - 2, hillheightbox->Gety () - 2, hillheightbox->Getwidth () + 2, hillheightbox->Getheight () + 2, 0, 0, "", LOW); XSetForeground (display, gc, blackpix); XDrawString (display, pixmap, gc, SELECTWINDOW_BORDERBESIDETEXT, lowerbound->Gety () + lowerbound->Getheight () - 3, thresholdtext, strlen (thresholdtext)); XDrawString (display, pixmap, gc, SELECTWINDOW_BORDERBESIDETEXT, hillheightbox->Gety () + hillheightbox->Getheight () - 3, hilltext, strlen (hilltext)); SetSelectedInput (ExposureMask | EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask); FixMySize (); MapMe ();}RuleOptionWindow::~RuleOptionWindow (){ XFreePixmap (display, pixmap); delete OK; delete Cancel; delete hillheightbox; delete lowerbound; delete dataselectwindow; if (ruleselectwindow != NULL) delete ruleselectwindow; delete parameterselectwindow;}void RuleOptionWindow::Action (int Actionnumber, int value){ switch (Actionnumber) { case THRESHOLDCHANGE_ACTION: threshold = *((double *) value); threshold = MAX (MIN (threshold, 1.0), 0.0); lowerbound->ChangeText (threshold); break; case HILLHEIGHTCHANGE_ACTION: hillheight = *((double *) value); hillheight = MAX (MIN (hillheight, 1.0), 0.0); hillheightbox->ChangeText (hillheight); break; case SELECTED_OK: if (ruleinfo->selecteddims->Anzahl_gesetzt () > 0) { XDefineCursor (display, window, waitcursor); XFlush (display); if (ruleselectwindow != NULL) // initoptions==RULEOPTION { switch (ruleselectwindow->GetAcuteInfo ()) { case RULETYP1: ruleinfo->rules = Ermittle_Regeln (*(ruleinfo->clustering), threshold, *(ruleinfo->dataset), ruleinfo->inputdim, *(dataselectwindow->Getbvector ()), (Parameter_Typ) parameterselectwindow->GetAcuteInfo (), *(ruleinfo->selectedcluster)); break; case RULETYP2A: ruleinfo->rules = Finde_Regeln (hillheight, Dim_insgesamt, *(ruleinfo->clustering), threshold, *(ruleinfo->dataset), ruleinfo->inputdim, *(dataselectwindow->Getbvector ()), (Parameter_Typ) parameterselectwindow->GetAcuteInfo (), *(ruleinfo->selectedcluster)); break; case RULETYP2B: ruleinfo->rules = Finde_Regeln (hillheight, Dim_einzeln, *(ruleinfo->clustering), threshold, *(ruleinfo->dataset), ruleinfo->inputdim, *(dataselectwindow->Getbvector ()), (Parameter_Typ) parameterselectwindow->GetAcuteInfo (), *(ruleinfo->selectedcluster)); break; } } else { ruleinfo->classify = Ermittle_Klassifizierung (*(ruleinfo->clustering), threshold, *(ruleinfo->dataset), ruleinfo->inputdim, *(dataselectwindow->Getbvector ()), (Parameter_Typ) parameterselectwindow->GetAcuteInfo (), *(ruleinfo->selectedcluster)); } XUngrabPointer (display, CurrentTime); short rulesfound = FALSE; if (ruleselectwindow != NULL) // initoptions==RULEOPTION { if (ruleinfo->rules.Lese_Regelanzahl () > 0) rulesfound = TRUE; } else { if (ruleinfo->classify.Lese_Klassenanzahl () > 0) rulesfound = TRUE; } if (rulesfound) Parent->Action (actionnumber, (int) ruleinfo); else { Mainwindow->printError ("No rules found!"); Parent->Action (actionnumber, (int) NULL); } } else Parent->Action (actionnumber, (int) NULL); UnmapMe ();#if 0 /* XXX: would you believe this ??? */ delete this;#endif break; case SELECTED_CANCEL: UnmapMe (); Parent->Action (actionnumber, (int) NULL);#if 0 /* XXX: would you believe this ??? */ delete this;#endif break; }}void RuleOptionWindow::HandleEvent (XEvent * Event){ switch (Event->type) { case Expose: XCopyArea (display, pixmap, window, gc, Event->xgraphicsexpose.x, Event->xgraphicsexpose.y, Event->xgraphicsexpose.width, Event->xgraphicsexpose.height, Event->xgraphicsexpose.x, Event->xgraphicsexpose.y); break; }}IntegerSelectWindow::IntegerSelectWindow (Display * initdisplay, GC initgc, BigWindow * Parent, XFontStruct * fontstruct, int initx, int inity, char *inittext, char *initdefaulttext, int Minvalue, int Maxvalue, int initvalue, unsigned short options):BigWindow (initdisplay, initgc, Parent->GetWindow (), fontstruct, initx, inity, 10, 10, inittext, 0){ minvalue = Minvalue; maxvalue = Maxvalue; value = initvalue; defaulttext = initdefaulttext; lighticon = NULL; short integerwidth = XTextWidth (fontstruct, defaulttext, strlen (defaulttext)) + 10; short integerboxxpos, integerboxypos; short textwidth = XTextWidth (fontstruct, text, strlen (text)); short textxpos, textypos; short depth, integerheight = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent; short arrowsize = 11, arrowupxpos = 10, arrowupypos = 0, arrowdownypos; short lightxpos = 0, lightypos; integerboxypos = arrowupypos + arrowsize + 2 * DEFAULT_BDWIDTH + 2; lightypos = integerboxypos + (int) (.5 * (integerheight - DEFAULTLIGHTSIZE)) + DEFAULT_BDWIDTH; textxpos = lightxpos + DEFAULTLIGHTSIZE + SELECTWINDOW_INSIDESPACE; textypos = integerboxypos + integerheight - fontstruct->max_bounds.descent + DEFAULT_BDWIDTH; integerboxxpos = textxpos + textwidth + SELECTWINDOW_INSIDESPACE; integerbox = new TextBox (display, gc, this, fontstruct, integerboxxpos, integerboxypos, integerwidth, integerheight, 0, defaulttext, 1, TEXTOPTION_DARK, INTEGERSELECTWINDOW_VALUECHANGE, INTEGERSELECTWINDOW_NOOP); arrowdownypos = integerboxypos + integerheight + 4; arrowupxpos = integerboxxpos + (int) (.5 * (integerwidth - arrowsize)); arrowup = new ActionIcon (display, gc, this, fontstruct, arrowupxpos, arrowupypos, arrowsize, arrowsize, "", littlearrowup_bits, littlearrowup_width, littlearrowup_height, INTEGERSELECTWINDOW_COUNTUP, ICON_SELECTABLE | ICON_REPEATEDCLICK); arrowdown = new ActionIcon (display, gc, this, fontstruct, arrowupxpos, arrowdownypos, arrowsize, arrowsize, "", littlearrowdown_bits, littlearrowdown_width, littlearrowdown_height, INTEGERSELECTWINDOW_COUNTDOWN, ICON_SELECTABLE | ICON_REPEATEDCLICK); lighticon = new OnOffIcon (display, gc, this, fontstruct, lightxpos, lightypos, DEFAULTLIGHTSIZE, DEFAULTLIGHTSIZE, NULL, NULL, 0, 0, INTEGERSELECTWINDOW_LIGHTCHANGE, ICON_SELECTABLE | ICON_LIGHTICON); if (options & DISPLAY_LIGHTICON) lighticon->MapMe (); width = integerboxxpos + integerwidth + 4; height = arrowdownypos + arrowsize + 2 * DEFAULT_BDWIDTH; XResizeWindow (display, window, width, height); depth = DefaultDepth (display, DefaultScreen (display)); pixmap = XCreatePixmap (display, window, width, height, depth); XSetForeground (display, gc, buttonpix); XFillRectangle (display, pixmap, gc, 0, 0, width, height); XSetForeground (display, gc, blackpix); XDrawString (display, pixmap, gc, textxpos, textypos, text, strlen (text)); clickarea_left = textxpos; clickarea_right = textxpos + XTextWidth (fontstruct, text, strlen (text)); clickarea_bottom = textypos; clickarea_top = textypos - integerheight; DrawBorder (pixmap, integerboxxpos - 2, integerboxypos - 2, integerbox->Getwidth () + 6, integerbox->Getheight () + 6, 0, 0, "", LOW); if (options & DISPLAY_LIGHTICON) SetSelectedInput (ExposureMask | ButtonPressMask); else SetSelectedInput (ExposureMask); MapMe ();}void IntegerSelectWindow::SetDefault (){ lighticon->DelStatus (ICON_SELECTED); integerbox->ChangeText (defaulttext);}void IntegerSelectWindow::SetValue (int newvalue){ value = newvalue; lighticon->AddStatus (ICON_SELECTED); integerbox->SetStatus (integerbox->GetStatus () | TEXTOPTION_INTINPUT); integerbox->ChangeText (value);}int IntegerSelectWindow::GetValue (){ if (lighticon->IsSelected ()) return (MAX (MIN (value, maxvalue), minvalue)); else return (MAXINT);}void IntegerSelectWindow::Action (int Actionnumber, int Value){ switch (Actionnumber) { case INTEGERSELECTWINDOW_COUNTUP: if (lighticon->IsSelected () && (value < maxvalue)) integerbox->ChangeText (++value); break; case INTEGERSELECTWINDOW_COUNTDOWN: if (lighticon->IsSelected () && (value > minvalue)) integerbox->ChangeText (--value); break; case INTEGERSELECTWINDOW_LIGHTCHANGE: if (Value == SWITCHON) { integerbox->SetStatus (integerbox->GetStatus () | TEXTOPTION_INTINPUT); integerbox->ChangeText (value); } else { integerbox->SetStatus (integerbox->GetStatus () & ~TEXTOPTION_INTINPUT); integerbox->ChangeText (defaulttext); } break; case INTEGERSELECTWINDOW_VALUECHANGE: value = *((int *) Value); break; }}void IntegerSelectWindow::HandleEvent (XEvent * Event){ switch (Event->type) { case Expose: XCopyArea (display, pixmap, window, gc, Event->xgraphicsexpose.x, Event->xgraphicsexpose.y, Event->xgraphicsexpose.width, Event->xgraphicsexpose.height, Event->xgraphicsexpose.x, Event->xgraphicsexpose.y); break; case ButtonPress: if (lighticon->IsMapped () && (clickarea_left <= Event->xbutton.x) && (clickarea_right >= Event->xbutton.x) && (clickarea_top <= Event->xbutton.y) && (clickarea_bottom >= Event->xbutton.y)) { if (lighticon->IsSelected ()) { lighticon->UnselectMe (); Action (INTEGERSELECTWINDOW_LIGHTCHANGE, SWITCHOFF); } else { lighticon->SelectMe (); Action (INTEGERSELECTWINDOW_LIGHTCHANGE, SWITCHON); } } break; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -