📄 selectwindow.cc
字号:
//**************************************************************//* filename: selectwindow.cc *//* *//**************************************************************//* programmed by: Thomas Wagner *//* last change: 24-05-95 *//* last change: 10-10-98 HT *//**************************************************************#include <stdio.h>#include <stdlib.h>#include <string.h>#include <X11/Xlib.h>#include "selectwindow.h"#include "mainwindow.h"#include "include_bmps/littlearrowup.bmp"#include "include_bmps/littlearrowdown.bmp"extern unsigned long buttonpix, blackpix, shadowpix, lightpix;extern Cursor maincursor, waitcursor;extern MainWindow *Mainwindow;static SelectWindowInfo Infos[CLUSTERTYPNUMBER] ={ {"FCM", TEXTOPTION_SELECTABLE, FCM}, {"GK", TEXTOPTION_SELECTABLE, GK}, {"GK parallel", TEXTOPTION_SELECTABLE, GK_parallel}, {"GG", TEXTOPTION_SELECTABLE, GG}, {"GG parallel", TEXTOPTION_SELECTABLE, GG_parallel}, {"not yet", 0, 10}, {"not yet", 0, 10}, {"not yet", 0, 10}, {"to be continued ..", 0, 10}};static SelectWindowInfo ValidityInfos[VALIDYTYPNUMBER] ={ {"S-Validity", TEXTOPTION_SELECTABLE, S}, {"PK-Validity", TEXTOPTION_SELECTABLE, PK}, {"CS-Validity", TEXTOPTION_SELECTABLE, CS}, {"D1-Validity", TEXTOPTION_SELECTABLE, D1}, {"FHV-Validity", TEXTOPTION_SELECTABLE, FHV}, {"DPA-Validity", TEXTOPTION_SELECTABLE, DPA}, {"PD-Validity", TEXTOPTION_SELECTABLE, PD}, {"Classify-Validity", TEXTOPTION_SELECTABLE, CLASSIFY}};static SelectWindowInfo RuletypInfos[RULETYPNUMBER] ={ {"Rule type 1", TEXTOPTION_SELECTABLE, RULETYP1}, {"Rule type 2 a", TEXTOPTION_SELECTABLE, RULETYP2A}, {"Rule type 2 b", TEXTOPTION_SELECTABLE, RULETYP2B}};static SelectWindowInfo ParametertypInfos[PARAMETERTYPNUMBER] ={ {"trapezium parameter", TEXTOPTION_SELECTABLE, Trapez}, {"convex parameter", TEXTOPTION_SELECTABLE, Konvex}, {"not yet", 0, 0}, {"not yet", 0, 0}, {"not yet", 0, 0}};RuleInfo::RuleInfo ( //DVektorArray *Cluster, //DMatrix *Membership, Clustering * initclustering, int Inputdim, BVektor * Selecteddims, BVektor * Selectedcluster, Datensatz * Dataset){ clustering = initclustering; inputdim = Inputdim; selecteddims = Selecteddims; selectedcluster = Selectedcluster; dataset = Dataset;}RuleInfo::~RuleInfo (){}void RuleInfo::operator= (RuleInfo & source){ clustering = source.clustering; inputdim = source.inputdim; selecteddims = source.selecteddims; selectedcluster = source.selectedcluster; dataset = source.dataset;}ClusterInfo::ClusterInfo (Datensatz * Dataset, char Ispossib, int Clustertyp, int Clusternumber, int Repeatnumber, double initM, double initK, int initexactness, double initdelta_u, Guete_Typ Validitytyp, BVektor * Bvector){ dataset = Dataset; ispossib = Ispossib; clustertyp = Clustertyp; clusternumber = Clusternumber; repeatnumber = Repeatnumber; M = initM; K = initK; exactness = initexactness; delta_u = initdelta_u; bvector = Bvector; validitytyp = Validitytyp;}void ClusterInfo::operator= (ClusterInfo & source){ dataset = source.dataset; ispossib = source.ispossib; clustertyp = source.clustertyp; clusternumber = source.clusternumber; repeatnumber = source.repeatnumber; M = source.M; K = source.K; delta_u = source.delta_u; bvector = source.bvector;}SelectWindow::SelectWindow (Display * initdisplay, GC initgc, BigWindow * initParent, XFontStruct * fontstruct, int initx, int inity, int initwidth, int initheight, SelectWindowInfo * Infos, unsigned short Infonumber, int Changeactionnumber, int Doubleclickactionnumber, unsigned short initoptions):BigWindow (initdisplay, initgc, initParent->GetWindow (), fontstruct, initx, inity, initwidth, initheight, NULL, 0){ Parent = initParent; options = initoptions; infos = Infos; infonumber = Infonumber; offset = 0; doubleclickactionnumber = Doubleclickactionnumber; changeactionnumber = Changeactionnumber; unsigned short counter; scrollwindow = NULL; short textwidth = 0, maxheight; short depth, textheight = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent;// first add options, to place text left in textboxes for (counter = 0; counter < infonumber; counter++) infos[counter].options |= TEXTOPTION_GIVENXPOS; textnumber = (int) (height / textheight); if (textnumber > infonumber) textnumber = infonumber; textwidth = width - 4; if (textnumber < infonumber) // scrollwindow is needed { textwidth -= (SCROLL_MINWIDTH + SELECTWINDOW_INSIDESPACE); scrollwindow = new ScrollWindow (display, gc, this, fontstruct, textwidth + SELECTWINDOW_INSIDESPACE, 2, SCROLL_MINWIDTH, textnumber * textheight + 1, 0, infonumber - textnumber, 0, SELECTWINDOW_SCROLLED_ACTION); scrollwindow->MapMe (); scrollwindow->SetValue (infonumber - textnumber); } textboxes = (TextBox **) malloc (sizeof (TextBox *) * (textnumber)); for (counter = 0; counter < textnumber; counter++) { if (counter < infonumber) textboxes[counter] = new TextBox (display, gc, this, fontstruct, 2, 2 + textheight * counter, textwidth, textheight, (int) SELECTWINDOW_BORDERBESIDETEXT / 2, infos[counter].Selecttext, 0, infos[counter].options, CHANGETEXTSELECTION_ACTION, TEXT_DOUBLECLICKED); else textboxes[counter] = new TextBox (display, gc, this, fontstruct, 2, 2 + textheight * counter, textwidth, textheight, (int) SELECTWINDOW_BORDERBESIDETEXT / 2, "", 0, TEXTOPTION_DEFAULT, CHANGETEXTSELECTION_ACTION, TEXT_DOUBLECLICKED); } if (scrollwindow != NULL) maxheight = MAX (textnumber * textheight + 4, scrollwindow->Getheight ()); else maxheight = textnumber * textheight + 4; SizeMe (width, maxheight); 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, textwidth + 4, textnumber * textheight + 4, 0, 0, "", LOW); SetSelectedInput (ExposureMask); FixMySize (); MapMe ();}SelectWindow::~SelectWindow (){}void SelectWindow::ChangeInfo (SelectWindowInfo * Infos, unsigned short Infonumber){ free (infos); infos = Infos; infonumber = Infonumber; unsigned short counter; for (counter = 0; counter < textnumber; counter++) { if (counter < infonumber) { textboxes[counter]->SetStatus (infos[counter].options); textboxes[counter]->ChangeText (infos[counter].Selecttext); } else { textboxes[counter]->SetStatus (TEXTOPTION_GIVENXPOS); textboxes[counter]->ChangeText (""); } } if (scrollwindow != NULL) { if (infonumber > textnumber) { scrollwindow->SetMinMax (0, (infonumber - textnumber)); scrollwindow->SetValue (infonumber - textnumber); } else { scrollwindow->SetMinMax (0, 0); scrollwindow->SetValue (0); } } else { if (infonumber > textnumber) { short textheight = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent; scrollwindow = new ScrollWindow (display, gc, this, fontstruct, 0, 2, SCROLL_MINWIDTH, textnumber * textheight + 1, 0, infonumber - textnumber, 0, SELECTWINDOW_SCROLLED_ACTION); for (counter = 0; counter < textnumber; counter++) textboxes[counter]->ResizeMe (-scrollwindow->Getwidth (), 0); short textwidth = textboxes[0]->Getwidth (); scrollwindow->MoveMe (textwidth + SELECTWINDOW_INSIDESPACE, 0); scrollwindow->SetValue (infonumber - textnumber); scrollwindow->MapMe (); XSetForeground (display, gc, buttonpix); XFillRectangle (display, pixmap, gc, 0, 0, width, height); DrawBorder (pixmap, 0, 0, textwidth + 4, height, 0, 0, "", LOW); XCopyArea (display, pixmap, window, gc, 0, 0, width, height, 0, 0); } }}void SelectWindow::Action (int Actionnumber, int value){ unsigned short counter; switch (Actionnumber) { case CHANGETEXTSELECTION_ACTION: if (options & SELECTWINDOWOPTION_EXCLUSIVESELECTION) { for (counter = 0; counter < infonumber; counter++) infos[counter].options &= ~TEXTOPTION_SELECTED; for (counter = 0; counter < textnumber; counter++) { if (value != (int) (textboxes[counter])) textboxes[counter]->UnselectMe (); else { textboxes[counter]->SelectMe (); infos[counter + offset].options |= TEXTOPTION_SELECTED; } } } else { for (counter = 0; counter < textnumber; counter++) { if (value == (int) (textboxes[counter])) { if (textboxes[counter]->IsSelected ()) { textboxes[counter]->UnselectMe (); infos[counter + offset].options &= ~TEXTOPTION_SELECTED; } else { textboxes[counter]->SelectMe (); infos[counter + offset].options |= TEXTOPTION_SELECTED; } } } } Parent->Action (changeactionnumber, value); break; case TEXT_DOUBLECLICKED: Parent->Action (doubleclickactionnumber, value); break; case SELECTWINDOW_SCROLLED_ACTION: if (infonumber > textnumber) { offset = (infonumber - textnumber) - value; for (counter = 0; counter < textnumber; counter++) { textboxes[counter]->SetStatus (infos[counter + offset].options); textboxes[counter]->ChangeText (infos[counter + offset].Selecttext); } } else { offset = 0; for (counter = 0; counter < infonumber; counter++) { textboxes[counter]->SetStatus (infos[counter].options); textboxes[counter]->ChangeText (infos[counter].Selecttext); } for (counter = infonumber; counter < textnumber; counter++) { textboxes[counter]->SetStatus (0); textboxes[counter]->ChangeText (""); } } break; }}int SelectWindow::GetAcuteInfo (){ unsigned short counter, foundindex = 0; for (counter = 0; counter < infonumber; counter++) { if (infos[counter].options & TEXTOPTION_SELECTED) foundindex = counter; } return infos[foundindex].info;}BVektor *SelectWindow::Getbvector (){ unsigned short counter; BVektor *bvector = new BVektor (infonumber, NULL); for (counter = 0; counter < infonumber; counter++) { if (infos[counter].options & TEXTOPTION_SELECTED) bvector->Setze_i (counter, TRUE); } return /***/ bvector;}void SelectWindow::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; }}ClusterOptionWindow::ClusterOptionWindow (Display * initdisplay, GC initgc, BigWindow * initParent, XFontStruct * fontstruct, int initx, int inity, char *text, int initactionnumber, ClusterInfo * clusterinfo):BigWindow (initdisplay, initgc, DefaultRootWindow (initdisplay), fontstruct, initx, inity, 350, 200, text, DEFAULT_BDWIDTH){ char *possitext = "possibilistic"; actionnumber = initactionnumber; SelectWindowInfo *datainfo; exactnessselect = NULL; dataselectwindow = NULL; myclusterinfo = *(clusterinfo); Parent = initParent; unsigned short counter; short leftheight = 0, rightheight = 0; short intselectypos; // pos. of numberoutput short clusterselectwidth, clusterselectheight; // of cluster-select-window // first the right elements clusternumberselect = new IntegerSelectWindow (display, gc, this, fontstruct, 0, 0, "Clusterno.", "auto", 2, 100, 2, DISPLAY_LIGHTICON); if (clusterinfo->clusternumber < MAXINT) clusternumberselect->SetValue (clusterinfo->clusternumber); repeatnumberselect = new IntegerSelectWindow (display, gc, this, fontstruct, 0, 0, "repeats", "opt.", 1, 1000, 1, DISPLAY_LIGHTICON); if (clusterinfo->repeatnumber < MAXINT) repeatnumberselect->SetValue (clusterinfo->repeatnumber);/* //+ Mselect = new IntegerSelectWindow (display, gc, this, fontstruct, 0, 0, "M", "100", 2.0, 100, clusterinfo->M, 0); Kselect = new IntegerSelectWindow (display, gc, this, fontstruct, 0, 0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -