00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include <stdarg.h>
00029 #include <ctype.h>
00030 #include <cstring>
00031 #include <iostream>
00032
00033 #include "typen.h"
00034 #include "basegfx.h"
00035 #include "newfont.h"
00036 #include "spfst.h"
00037 #include "loaders.h"
00038 #include "misc.h"
00039 #include "events.h"
00040 #include "stack.h"
00041 #include "dlg_box.h"
00042 #include "paradialog.h"
00043 #include "widgets/textrenderer.h"
00044
00045 #include "spfst-legacy.h"
00046
00047
00048 #ifdef _WIN32_
00049 #include <windows.h>
00050 #include <winuser.h>
00051 #endif
00052
00053
00054
00055 char strrstring[200];
00056
00057 void strrd8d(int l, char* s)
00058 {
00059 itoa ( l / minmalq, s, 10);
00060 }
00061
00062 void strrd8u(int l, char* s)
00063 {
00064 itoa ( (l + minmalq - 1) / minmalq, s, 10);
00065 }
00066
00067 void strrd8n(int l, char* s)
00068 {
00069 itoa ( (l + minmalq/2) / minmalq, s, 10);
00070 }
00071
00072
00073 char* strrrd8d(int l)
00074 {
00075 itoa ( l / minmalq, strrstring, 10);
00076
00077 return strrstring;
00078 }
00079
00080 char* strrrd8u(int l)
00081 {
00082 itoa ( (l + minmalq - 1) / minmalq, strrstring, 10);
00083
00084 return strrstring;
00085 }
00086
00087 char* strrrd8n(int l)
00088 {
00089 itoa ( (l + minmalq/2) / minmalq, strrstring, 10);
00090
00091 return strrstring;
00092 }
00093
00094
00095 void *dialogtexture = NULL;
00096
00097 int actdisplayedmessage = 0;
00098 long int lastdisplayedmessageticker = 0xffffff;
00099
00100
00101 tvirtualscreenbuf virtualscreenbuf;
00102
00103
00104 tvirtualscreenbuf :: tvirtualscreenbuf ( void )
00105 {
00106 buf = NULL;
00107 size = 0;
00108 }
00109
00110 void tvirtualscreenbuf:: init ( void )
00111 {
00112 size = hgmp->bytesperscanline * hgmp->resolutiony;
00113 buf = malloc( size );
00114 }
00115
00116 tvirtualscreenbuf:: ~tvirtualscreenbuf ()
00117 {
00118 free( buf );
00119 buf = NULL;
00120 }
00121
00122
00123 char getletter( const char * s)
00124 {
00125 const char* c = s;
00126
00127 while ( *c && (*c != 126 ))
00128 c++;
00129
00130 if (*c == '~' ) {
00131 c++;
00132 return *c;
00133 } else {
00134 return 0;
00135 }
00136 }
00137
00138
00139 collategraphicoperations* tdialogbox::pcgo = NULL;
00140
00141 tdialogbox::tdialogbox()
00142 {
00143 eventQueue = setEventRouting ( false, true );
00144
00145 npush ( activefontsettings );
00146 activefontsettings.font = schriften.smallarial;
00147 activefontsettings.color = black;
00148 activefontsettings.background = 255;
00149 activefontsettings.markcolor = red;
00150
00151
00152 virtualbufoffset = 0;
00153 boxstatus = 0;
00154
00155 dlg_mode = 0;
00156 int rdw = 0;
00157
00158 if ( first ) {
00159 pdialogbox rn = first;
00160 rdw &= rn->getcapabilities() & 1;
00161 while ( rn->next ) {
00162 rn = rn->next;
00163 rdw &= rn->getcapabilities() & 1;
00164 }
00165
00166
00167 prev = rn;
00168 rn->next = this;
00169 } else {
00170 first = this;
00171 prev = NULL;
00172 }
00173 next = NULL;
00174
00175 if ( rdw )
00176 dlg_mode |= 2;
00177 }
00178
00179
00180 int tdialogbox::getcapabilities ( void )
00181 {
00182 return 0;
00183 }
00184
00185 extern void repaintdisplay ( void );
00186
00187
00188 void tdialogbox::repaintdisplay( void )
00189 {
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 }
00223
00224 void tdialogbox::redrawall ( void )
00225 {
00226 paint();
00227 if ( prev )
00228 prev->redrawall();
00229 else
00230 repaintDisplay();
00231 }
00232
00233 void tdialogbox::redrawall2 ( int xx1, int yy1, int xx2, int yy2 )
00234 {
00235 paint ();
00236 if ( x1 > xx1 || y1 > yy1 || x1+xsize < xx2 || y1+ysize < yy2 ) {
00237 if ( prev )
00238 prev->redrawall2 ( xx1, yy1, xx2, yy2 );
00239 else
00240 repaintDisplay();
00241 }
00242 }
00243
00244
00245 pdialogbox tdialogbox::first = NULL;
00246
00247 void tdialogbox::setvirtualframebuf ( void )
00248 {
00249 agmp->linearaddress = (PointerSizedInt) virtualscreenbuf.buf;
00250 agmp->windowstatus = 100;
00251 agmp->scanlinelength = hgmp->scanlinelength;
00252 }
00253
00254 void tdialogbox::setclipping ( void )
00255 {
00256 bar ( x1, y1, x1 + xsize, y1 + ysize, 255 );
00257 if ( next )
00258 next->setclipping ( );
00259 }
00260
00261 void tdialogbox::copyvirtualframebuf ( void )
00262 {
00263 ms = getmousestatus();
00264 if (ms == 2)
00265 mousevisible(false);
00266
00267 npush ( *agmp );
00268 void* buf = (void*) agmp->linearaddress;
00269 *agmp = *hgmp;
00270
00271 putspritetexture ( x1, y1, x1 + xsize, y1 + ysize, buf );
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285 npop ( *agmp );
00286
00287 if (ms == 2)
00288 mousevisible(true);
00289
00290 }
00291
00292 void tdialogbox::paint ( void )
00293 {
00294 setvirtualframebuf();
00295 redraw();
00296 if ( next )
00297 next->setclipping();
00298 copyvirtualframebuf();
00299 *agmp = *hgmp;
00300 }
00301
00302
00303 int getplayercolor ( int i )
00304 {
00305 if ( actmap ) {
00306 int textcolor = i * 8 + 21;
00307 if ( i == 7 || i == 2 )
00308 textcolor += 1;
00309 return textcolor;
00310 } else
00311 return 20;
00312 }
00313
00314 void tdialogbox::init(void)
00315 {
00316 imagesaved = false;
00317 if ( actmap && actmap->actplayer != -1 ) {
00318 textcolor = getplayercolor ( actmap->actplayer );
00319 }
00320 else
00321 textcolor = 20;
00322
00323 firstbutton = NULL;
00324 windowstyle = dlg_in3d | dlg_3dtitle;
00325 x1 = 50;
00326 xsize = 540;
00327 y1 = 50;
00328 ysize = 380;
00329 starty = 40;
00330 title = "dialogbox";
00331 npush( activefontsettings );
00332 activefontsettings.height = 0;
00333 activefontsettings.length = 0;
00334 memset(taborder, 0, sizeof(taborder));
00335 tabcount = 0;
00336 markedtab = 0;
00337 disablecolor = darkgray;
00338 boxstatus = 1;
00339 dlg_mode = 0;
00340 }
00341
00342
00343
00344
00345
00346 #include "dlgraph.cpp"
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356 void tdialogbox::changecoordinates(void)
00357 {
00358
00359 }
00360
00361 tdlgengine::pbutton tdlgengine :: getbutton ( int id )
00362 {
00363 pbutton pb = firstbutton;
00364 while ( pb && (pb->id != id))
00365 pb = pb->next;
00366 return pb;
00367 }
00368
00369 void tdlgengine::buttonpressed(int id)
00370 {
00371 pbutton pb;
00372 int w;
00373 Uint16 *pw, *pw2;
00374
00375 pb = firstbutton;
00376 while ( pb ) {
00377 if ((pb->art == 5)) {
00378 pw = (Uint16*) pb->data;
00379 pw2 = (Uint16*) pb->data2;
00380 w = *pw;
00381 if ((pb->id + 1 == id)) {
00382 if (taste == ct_pup) {
00383 if (*pw >= pb->max)
00384 *pw -= pb->max - 1;
00385 else
00386 *pw = 0;
00387 }
00388 else
00389 if (taste == ct_pos1) {
00390 *pw = 0;
00391 }
00392 else
00393 if (*pw > 0) {
00394 if ( pb->newpressed == 0 )
00395 (*pw) --;
00396 else
00397 if ( pb->newpressed == 1) {
00398 (*pw) --;
00399 pb->lasttick = ticker;
00400 } else
00401 if ( pb->newpressed == 2) {
00402 int dst = ticker - pb->lasttick;
00403 if ( *pw < dst )
00404 (*pw) = 0;
00405 else
00406 (*pw) -= dst;
00407 pb->lasttick = ticker;
00408 }
00409 }
00410 }
00411 if ((pb->id + 2 == id)) {
00412 if (taste == ct_pdown) {
00413 if (*pw + (pb->max * 2) - 1 <= *pw2)
00414 *pw += pb->max - 1;
00415 else
00416 *pw = *pw2 - pb->max;
00417 }
00418 else
00419 if (taste == ct_ende) {
00420 *pw = *pw2 - pb->max;
00421 }
00422 else
00423 if ( *pw + pb->max < *pw2 ) {
00424
00425 if ( pb->newpressed == 0 )
00426 (*pw)++;
00427 else
00428 if ( pb->newpressed == 1) {
00429 (*pw) ++;
00430 pb->lasttick = ticker;
00431 } else
00432 if ( pb->newpressed == 2) {
00433 int dst = ticker - pb->lasttick;
00434 if ( *pw + dst + pb->max >= *pw2 )
00435 *pw = *pw2 - pb->max;
00436
00437 else
00438 (*pw) += dst;
00439 pb->lasttick = ticker;
00440 }
00441 }
00442 }
00443 if (w != *pw) {
00444 char mss = getmousestatus();
00445 if (mss == 2 )
00446 mousevisible(false);
00447 showbutton(pb->id);
00448 buttonpressed(pb->id);
00449 if (mss == 2 )
00450 mousevisible(true);
00451 }
00452
00453 }
00454 pb = pb->next;
00455 }
00456 }
00457
00458
00459 void tdlgengine::addbutton( const char * ltxt,
00460 tmouserect rect1,
00461 int lart,
00462 int lstyle,
00463 int lid,
00464 char enabled)
00465 {
00466 addbutton ( ltxt, rect1.x1, rect1.y1, rect1.x2, rect1.y2, lart, lstyle, lid, enabled );
00467 }
00468
00469 const char* emptystring = "";
00470
00471 void tdlgengine::addbutton( const char * ltxt,
00472 int lx1,
00473 int ly1,
00474 int lx2,
00475 int ly2,
00476 int lart,
00477 int lstyle,
00478 int lid,
00479 char enabled)
00480 {
00481 pbutton pb;
00482 char ch;
00483
00484 pb = firstbutton;
00485 if (lid <= 0)
00486 displaymessage("tdialogbox: \n id equal or less then 0\n:%d\n",2, lid);
00487 while ( pb ) {
00488 if (pb->id == lid)
00489 displaymessage("tdialogbox: duplicate button id: %d\n",2, lid);
00490
00491 pb = pb->next;
00492 }
00493 pb = new tbutton;
00494 pb->x1 = lx1;
00495 pb->x2 = lx2;
00496 pb->y1 = ly1;
00497 pb->y2 = ly2;
00498 pb->style = lstyle;
00499 pb->id = lid;
00500 pb->next = firstbutton;
00501 if ( ltxt )
00502 pb->text = ltxt;
00503 else
00504 pb->text = emptystring;
00505 pb->art = lart;
00506 pb->active = enabled;
00507 pb->status = 1;
00508 pb->scrollspeed = 30;
00509 pb->pressed = 0;
00510 pb->newpressed = 0;
00511
00512 firstbutton = pb;
00513
00514 ch = getletter(pb->text);
00515 if (ch != 0) {
00516 pb->key[0] = char2key( tolower(ch) );
00517 pb->keynum = 1;
00518 }
00519 else
00520 pb->keynum = 0;
00521 pb->markedkeynum = 1;
00522 pb->markedkey[0] = ct_enter;
00523
00524 }
00525
00526
00527 void tdlgengine::addscrollbar(tmouserect rec,
00528 int* numberofitems,
00529 int itemsvisible,
00530 int* actitem,
00531 int lid,
00532 int keys)
00533 {
00534 addscrollbar ( rec.x1, rec.y1, rec.x2, rec.y2, numberofitems, itemsvisible, actitem, lid, keys );
00535 }
00536
00537 void tdialogbox :: bar ( tmouserect rect, int color )
00538 {
00539 ::bar ( rect.x1, rect.y1, rect.x2, rect.y2, color );
00540 }
00541
00542 void tdialogbox :: bar ( int x1, int y1, int x2, int y2, int color )
00543 {
00544 ::bar ( x1, y1, x2, y2, color );
00545 }
00546
00547
00548 void tdlgengine::addDropDown( int x1, int y1, int x2, int y2, int ID, const char** entries, int entrynum, int* pos )
00549 {
00550 pbutton pb = firstbutton;
00551 if ( ID <= 0)
00552 displaymessage("tdialogbox: id equal or less then 0", 2);
00553 while (pb != NULL) {
00554 if (pb->id == ID)
00555 displaymessage("tdialogbox: duplicate button id: %d\n",2, ID);
00556 pb = pb->next;
00557 }
00558 pb = new tbutton;
00559 pb->x1 = x1;
00560 pb->x2 = x2;
00561 pb->y1 = y1;
00562 pb->y2 = y2;
00563 pb->style = 0;
00564 pb->id = ID;
00565 pb->next = firstbutton;
00566 pb->text = NULL;
00567 pb->art = 6;
00568 pb->active = true;
00569 pb->status = 1;
00570 pb->keynum = 0;
00571 pb->markedkeynum = 0;
00572 pb->scrollspeed = 30;
00573 pb->pressed = 0;
00574 pb->newpressed = 0;
00575 pb->entries = entries;
00576 pb->entrynum = entrynum;
00577 pb->data = pos;
00578 firstbutton = pb;
00579 }
00580
00581
00582 void tdlgengine::addscrollbar(int lx1,
00583 int ly1,
00584 int lx2,
00585 int ly2,
00586 int* numberofitems,
00587 int itemsvisible,
00588 int* actitem,
00589 int lid,
00590 int keys)
00591 {
00592 pbutton pb;
00593
00594 pb = firstbutton;
00595 if (lid <= 0)
00596 displaymessage("tdialogbox: id equal or less then 0", 2);
00597 while (pb != NULL) {
00598 if (pb->id == lid)
00599 displaymessage("tdialogbox: duplicate button id: %d\n",2, lid);
00600 pb = pb->next;
00601 }
00602 pb = new tbutton;
00603 pb->x1 = lx1;
00604 pb->x2 = lx2;
00605 pb->y1 = ly1 + 13;
00606 pb->y2 = ly2 - 13;
00607 pb->style = 0;
00608 pb->id = lid;
00609 pb->next = firstbutton;
00610 pb->text = NULL;
00611 pb->art = 5;
00612 pb->active = true;
00613 pb->status = 1;
00614 pb->keynum = 0;
00615 pb->markedkeynum = 0;
00616 pb->scrollspeed = 30;
00617 pb->pressed = 0;
00618 pb->newpressed = 0;
00619 firstbutton = pb;
00620
00621 addbutton("",lx1+1, ly1 + 1 , lx2 - 1, ly1 + 10, 0, 2, lid + 1, true);
00622 addbutton("",lx1+1, ly2 - 10 , lx2 - 1, ly2 - 1, 0, 2, lid + 2, true);
00623
00624 if (keys == 2) {
00625 addmarkedkey(lid + 1,ct_up);
00626 addmarkedkey(lid + 1,ct_pup);
00627 addmarkedkey(lid + 1,ct_pos1);
00628
00629 addmarkedkey(lid + 2,ct_down);
00630 addmarkedkey(lid + 2,ct_pdown);
00631 addmarkedkey(lid + 2,ct_ende);
00632 }
00633 if (keys == 1) {
00634 addkey(lid + 1,ct_up);
00635 addkey(lid + 1,ct_pup);
00636 addkey(lid + 1,ct_pos1);
00637
00638 addkey(lid + 2,ct_down);
00639 addkey(lid + 2,ct_pdown);
00640 addkey(lid + 2,ct_ende);
00641 }
00642
00643
00644 pb->data = actitem;
00645 pb->data2 = numberofitems;
00646 pb->max = itemsvisible;
00647
00648 }
00649
00650
00651 void tdialogbox::rebuildtaborder(void)
00652 {
00653 pbutton pb = firstbutton;
00654 int i = 0;
00655 ttaborder b;
00656
00657 tabcount = 0;
00658 while (pb != NULL) {
00659 if ((pb->art >= 0) && (pb->art <= 3))
00660 if ((pb->status == 1) && pb->active) {
00661 tabcount++;
00662 taborder[tabcount].id = pb->id;
00663 taborder[tabcount].x1 = pb->x1;
00664 taborder[tabcount].y1 = pb->y1;
00665 taborder[tabcount].x2 = pb->x2;
00666 taborder[tabcount].y2 = pb->y2;
00667 taborder[tabcount].button = pb;
00668
00669 }
00670 pb = pb->next;
00671 }
00672
00673 if (tabcount > 1)
00674 for (i = 1; i <= tabcount - 1; i++) {
00675 if ((taborder[i].y1 > taborder[i + 1].y1) || ((taborder[i].y1 == taborder[i + 1].y1) && (taborder[i].x1 > taborder[i + 1].x1)))
00676 {
00677 b = taborder[i];
00678 taborder[i] = taborder[i + 1];
00679 taborder[i + 1] = b;
00680 if (i > 1)
00681 i -= 2;
00682 }
00683 }
00684
00685
00686 pbutton pb2 = NULL;
00687 if (i > 0) {
00688 if (markedtab > 0)
00689 pb2 = taborder[i].button;
00690 }
00691
00692 showtabmark(markedtab);
00693
00694 if ( markedtab ) {
00695 markedtab = 0;
00696 if (tabcount > 0) {
00697 for (i = 1; i <= tabcount; i++)
00698 if (taborder[i].button == pb2)
00699 markedtab = i;
00700 }
00701 }
00702
00703 showtabmark(markedtab);
00704 }
00705
00706
00707 void tdialogbox::showbutton(int id)
00708 {
00709 pbutton pb;
00710 int c;
00711 char mss = getmousestatus();
00712
00713 if (mss == 2)
00714 mousevisible(false);
00715 pb = firstbutton;
00716 while (pb != NULL) {
00717 if (pb->id == id)
00718 if ( pb->pressed == 0) {
00719 c = pb->status;
00720 pb->status = 1;
00721 if (pb->active)
00722 enablebutton(id);
00723 else
00724 disablebutton(id);
00725
00726 if (pb->art == 5) {
00727 showbutton ( id + 1);
00728 showbutton ( id + 2);
00729 }
00730
00731 if (c != 1)
00732 rebuildtaborder();
00733 }
00734
00735 pb = pb->next;
00736 }
00737 if (mss == 2)
00738 mousevisible(true);
00739 }
00740
00741
00742 void tdialogbox::hidebutton(int id)
00743 {
00744 pbutton pb;
00745
00746 pb = firstbutton;
00747 while (pb != NULL) {
00748 if (pb->id == id) {
00749 pb->status = 0;
00750 if (pb->art == 5) {
00751 hidebutton ( id + 1);
00752 hidebutton ( id + 2);
00753 }
00754 }
00755 pb = pb->next;
00756 }
00757 rebuildtaborder();
00758 }
00759
00760
00761
00762 void tdlgengine::clearkey ( char id )
00763 {
00764 pbutton pb = firstbutton;
00765 while ( pb ) {
00766 if ( pb->id == id ) {
00767 pb->keynum = 0;
00768 pb->markedkeynum = 0;
00769 }
00770 pb = pb->next;
00771 }
00772 }
00773
00774 void tdlgengine::addkey( int id, tkey key )
00775 {
00776 pbutton pb = firstbutton;
00777 while ( pb ) {
00778 if (pb->id == id) {
00779 int exist = 0;
00780 for ( int i = 0; i < pb->keynum; i++ )
00781 if ( pb->key[i] == key )
00782 exist++;
00783 if ( !exist ) {
00784 pb->key [ pb->keynum ] = key;
00785 pb->keynum++;
00786 }
00787 }
00788 pb = pb->next;
00789 }
00790 }
00791
00792
00793 void tdlgengine::addmarkedkey(int id, tkey key)
00794 {
00795 pbutton pb;
00796
00797 pb = firstbutton;
00798 while ( pb ) {
00799 if (pb->id == id) {
00800 int exist = 0;
00801 for ( int i = 0; i < pb->markedkeynum; i++ )
00802 if ( pb->markedkey[i]== key )
00803 exist++;
00804 if ( !exist ) {
00805 pb->markedkey [ pb->markedkeynum ] = key;
00806 pb->markedkeynum++;
00807 }
00808 }
00809 pb = pb->next;
00810 }
00811 }
00812
00813
00814 void tdialogbox::setscrollspeed(char id , int speed)
00815 {
00816 pbutton pb;
00817
00818 pb = firstbutton;
00819 while (pb != NULL) {
00820 if (pb->id == id) {
00821 if (pb->art == 5) {
00822 setscrollspeed( id + 1, speed );
00823 setscrollspeed( id + 2, speed );
00824 } else
00825 pb->scrollspeed = speed;
00826 }
00827
00828 pb = pb->next;
00829 }
00830 }
00831
00832
00833 void tdlgengine::addeingabe(int lid,
00834 void* data,
00835 int min,
00836 int max)
00837 {
00838 pbutton pb;
00839
00840 pb = firstbutton;
00841 while (pb != NULL) {
00842 if (pb->id == lid) {
00843 pb->data = data;
00844 if ( min > max ) {
00845 pb->min = max;
00846 pb->max = min;
00847 } else {
00848 pb->min = min;
00849 pb->max = max;
00850 }
00851 addmarkedkey(pb->id,ct_enter);
00852 addmarkedkey(pb->id,ct_space);
00853 }
00854 pb = pb->next;
00855 }
00856 }
00857
00858
00859
00860 void tdialogbox::enablebutton(int id)
00861 {
00862
00863 pbutton pb = firstbutton;
00864 if ( !pb )
00865 return;
00866
00867
00868 while ( pb && pb->id != id )
00869 pb = pb->next;
00870
00871 if ( !pb )
00872 return;
00873
00874 npush( activefontsettings );
00875
00876 collategraphicoperations cgo ( x1 + pb->x1, max ( y1 + pb->y1 - 20, 0 ), x1 + pb->x2, y1 + pb->y2 );
00877
00878 char strng[200];
00879 activefontsettings.font = schriften.smallarial;
00880 activefontsettings.justify = lefttext;
00881 activefontsettings.length = pb->x2 - pb->x1 - 10;
00882 activefontsettings.markcolor = textcolor - 2;
00883 activefontsettings.color = textcolor;
00884 activefontsettings.background = 255;
00885
00886
00887 if (pb->art == 0) {
00888 if ((pb->style == 1) || (pb->style == 2))
00889 newknopf(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
00890
00891 if ( pb->text )
00892 if (pb->text[0] ) {
00893 activefontsettings.justify = centertext;
00894 showtext3( pb->text,x1 + pb->x1,y1 + (pb->y1 + pb->y2) / 2 - activefontsettings.font->height / 2);
00895 }
00896 }
00897
00898 if ((pb->art == 1) || ( pb->art == 2 )) {
00899 rahmen(true,x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
00900 paintsurface( pb->x1 + 1, pb->y1 + 1, pb->x2 - 1, pb->y2 - 1 );
00901 if ( pb->text )
00902 if (pb->text[0] ) {
00903 if ( pb->style != 3 ) {
00904 showtext3(pb->text,x1 + pb->x1,y1 + pb->y1 - activefontsettings.font->height);
00905 } else {
00906 npush ( activefontsettings.length );
00907 activefontsettings.length = 300;
00908 cgo.off();
00909 showtext3(pb->text,x1 + pb->x2 + 10,y1 + pb->y1 );
00910 cgo.on();
00911 npop ( activefontsettings.length );
00912 }
00913 }
00914
00915 if (pb->art == 1)
00916 showtext2((char*) pb->data , x1 + pb->x1 + 5,y1 + pb->y1 + 2);
00917
00918 if (pb->art == 2) {
00919 if (pb->max <= 255 && pb->min >= 0) {
00920 char* pbt = (char*) pb->data;
00921 itoa ( *pbt, strng, 10 );
00922 showtext2( strng, x1 + pb->x1 + 5,y1 + pb->y1 + 2);
00923 }
00924 else
00925 if (pb->max <= 65535 && pb->min >= 0) {
00926 Uint16* pw = (Uint16*) pb->data;
00927 itoa ( *pw, strng, 10 );
00928 showtext2(strng, x1 + pb->x1 + 5,y1 + pb->y1 + 2);
00929 }
00930 else {
00931 int* pl = (int*) pb->data;
00932 itoa ( *pl, strng, 10 );
00933 showtext2(strng, x1 + pb->x1 + 5,y1 + pb->y1 + 2);
00934 }
00935 }
00936 }
00937 if (pb->art == 3) {
00938 rahmen(true,x1 + pb->x1,y1 + pb->y1,x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y2);
00939
00940 showtext3(pb->text,x1 + pb->x1 + (pb->y2 - pb->y1) + 5,y1 + (pb->y1 + pb->y2 - activefontsettings.font->height) / 2);
00941
00942 char* pbl = (char*) pb->data;
00943
00944 int cl;
00945 if (*pbl)
00946 cl = pb->min;
00947 else
00948 cl = pb->max;
00949
00950 line(x1 + pb->x1,y1 + pb->y1,x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y2, cl);
00951 line(x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y1,x1 + pb->x1,y1 + pb->y2, cl);
00952 }
00953
00954 if (pb->art == 5) {
00955 Uint16* pw = (Uint16*) pb->data;
00956 Uint16* pw2 =(Uint16*) pb->data2;
00957 rahmen(true,x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
00958
00959 paintsurface2(x1 + pb->x1 + 1,y1 + pb->y1 + 1,x1 + pb->x2 - 1,y1 + pb->y2 - 1 );
00960
00961
00962 int l = pb->y2 - pb->y1 - 2;
00963 rahmen(false, x1 + pb->x1 + 1, y1 + pb->y1 + 1 + l * *pw / *pw2,
00964 x1 + pb->x2 - 1, y1 + pb->y1 + 1 + l * (*pw + pb->max) / *pw2);
00965
00966
00967
00968
00969 }
00970
00971 if ( pb->art == 6 ) {
00972 bar ( x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2, lightgray );
00973 rahmen(true,x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
00974 int pos = *( (int*) pb->data );
00975 if ( pos < 0 || pos >= pb->entrynum )
00976 fatalError("invalid pos in dropdown",2);
00977
00978 showtext3(pb->entries[pos], x1 + pb->x1 + (pb->y2 - pb->y1) + 5, y1 + (pb->y1 + pb->y2 - activefontsettings.font->height) / 2);
00979
00980 line ( x1 + pb->x2 - 20, y1 + pb->y1 + 4, x1 + pb->x2 - 10, y1 + pb->y1 + 4, textcolor );
00981 line ( x1 + pb->x2 - 20, y1 + pb->y1 + 4, x1 + pb->x2 - 15, y1 + pb->y1 + 14, textcolor );
00982 line ( x1 + pb->x2 - 10, y1 + pb->y1 + 4, x1 + pb->x2 - 15, y1 + pb->y1 + 14, textcolor );
00983 }
00984
00985 pb->active = true;
00986 npop( activefontsettings );
00987 rebuildtaborder();
00988 }
00989
00990
00991
00992
00993 void tdialogbox::disablebutton(int id)
00994 {
00995 pbutton pb;
00996 int *pl;
00997 Uint16 *pw, *pw2;
00998 char *pbt;
00999 char *pbl;
01000 char* s;
01001 char* t;
01002 int l;
01003 char cl;
01004
01005 pb = firstbutton;
01006 if ( !pb )
01007 return;
01008 while ((pb != NULL) && (pb->id != id))
01009 pb = pb->next;
01010 if (pb == NULL)
01011 return;
01012
01013 npush(activefontsettings);
01014 activefontsettings.font = schriften.smallarial;
01015 activefontsettings.justify = lefttext;
01016 activefontsettings.length = pb->x2 - pb->x1 - 10;
01017 activefontsettings.color = disablecolor;
01018
01019 s = new char[200];
01020 strcpy(s, pb->text);
01021
01022 t = strchr( s, 126 );
01023 while ( t != NULL ) {
01024 do {
01025 t[0] = t[1];
01026 t++;
01027 } while ( t[0] !=0 ) ;
01028 t = strchr( s, 126 );
01029 }
01030
01031 if (pb->art == 0) {
01032 if (pb->text != NULL)
01033 if (pb->text[0] != 0) {
01034 activefontsettings.justify = centertext;
01035 showtext2(s, x1 + pb->x1, y1 + (pb->y1 + pb->y2) / 2 - activefontsettings.font->height / 2);
01036 }
01037 if ((pb->style == 1) || (pb->style == 2)) {
01038 rectangle(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2,disablecolor);
01039 rectangle(x1 + pb->x1 - 1,y1 + pb->y1 - 1,x1 + pb->x2 + 1,y1 + pb->y2 + 1,disablecolor);
01040 }
01041 }
01042 if ((pb->art == 1) || (pb->art == 2)) {
01043 rectangle(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2,disablecolor);
01044 if (pb->text != NULL)
01045 if (pb->text[0] != 0) {
01046 if ( pb->style != 3 )
01047
01048 showtext2(pb->text,x1 + pb->x1,y1 + pb->y1 - activefontsettings.font->height);
01049 else {
01050 npush ( activefontsettings );
01051 activefontsettings.length = 0;
01052 showtext2(pb->text,x1 + pb->x2 + 10,y1 + pb->y1 );
01053 npop ( activefontsettings );
01054 }
01055 }
01056
01057 if (pb->art == 1) {
01058 showtext2( (char*)pb->data,x1 + pb->x1 + 5,y1 + pb->y1 + 2);
01059 }
01060 if (pb->art == 2) {
01061 if (pb->max <= 255 && pb->min >= 0) {
01062 pbt = (char*) pb->data;
01063 itoa ( *pbt, s, 10 );
01064 showtext2(s,x1 + pb->x1 + 5,y1 + pb->y1 + 2);
01065 }
01066 else
01067 if (pb->max <= 65535 && pb->min >= 0) {
01068 pw = (Uint16*) pb->data;
01069 itoa ( *pw, s , 10);
01070 showtext2(s, x1 + pb->x1 + 5,y1 + pb->y1 + 2);
01071 }
01072 else {
01073 pl = (int*) pb->data;
01074 itoa ( *pl, s, 10);
01075 showtext2(s, x1 + pb->x1 + 5,y1 + pb->y1 + 2);
01076 }
01077 }
01078 }
01079 if (pb->art == 3) {
01080 rectangle(x1 + pb->x1,y1 + pb->y1,x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y2,disablecolor);
01081 showtext2(s,x1 + pb->x1 + (pb->y2 - pb->y1) + 5,y1 + (pb->y1 + pb->y2 - activefontsettings.font->height) / 2);
01082 pbl = (char*) pb->data;
01083 if (*pbl)
01084 cl = disablecolor;
01085 else
01086 cl = pb->max;
01087 line(x1 + pb->x1,y1 + pb->y1,x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y2, cl);
01088 line(x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y1,x1 + pb->x1,y1 + pb->y2, cl);
01089 }
01090 if (pb->art == 5) {
01091 pw = (Uint16*) pb->data;
01092 pw2 = (Uint16*) pb->data2;
01093
01094 rectangle(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2,disablecolor);
01095
01096 paintsurface2(x1 + pb->x1 + 1,y1 + pb->y1 + 1,x1 + pb->x2 - 1,y1 + pb->y2 - 1);
01097
01098 if (pb->max <= *pw2) {
01099 l = pb->y2 - pb->y1 - 2;
01100 rectangle(x1 + pb->x1 + 1,y1 + pb->y1 + 1 + l * *pw / *pw2,x1 + pb->x2 - 1,y1 + pb->y1 + 1 + l * (*pw + pb->max) / *pw2,disablecolor);
01101 }
01102 else
01103 rectangle(x1 + pb->x1 + 1,y1 + pb->y1 + 1,x1 + pb->x2 - 1,y1 + pb->y2 - 1,disablecolor);
01104
01105 }
01106 delete[] s;
01107 pb->active = false;
01108 npop( activefontsettings );
01109 rebuildtaborder();
01110 }
01111
01112
01113 void tdialogbox::redraw(void)
01114 {
01115 pbutton pb;
01116
01117
01118 knopf(x1,y1,x1 + xsize,y1 + ysize);
01119
01120
01121 rahmen(false, x1,y1,x1 + xsize, y1 + ysize);
01122
01123
01124 activefontsettings.color = white;
01125 activefontsettings.background = 255;
01126 activefontsettings.font = schriften.smallarial;
01127 activefontsettings.justify = centertext;
01128 activefontsettings.length = xsize - 10;
01129 activefontsettings.height = 00;
01130
01131 if (windowstyle & dlg_wintitle ) {
01132 starty = 25;
01133 rahmen(true,x1 + 5,y1 + 3,x1 + xsize - 5,y1 + 20);
01134 bar(x1 + 6,y1 + 4,x1 + xsize - 6,y1 + 19,blue);
01135
01136 activefontsettings.color = textcolor;
01137 showtext2(title, x1 + 5,y1 + 3);
01138 }
01139 else {
01140 starty = 5;
01141 if ((windowstyle & dlg_notitle) == 0)
01142 if (title != NULL)
01143 if (title[0] ) {
01144 activefontsettings.font = schriften.large;
01145 if ( windowstyle & dlg_3dtitle ) {
01146 if ( actmap && actmap->actplayer == 7 ) {
01147 activefontsettings.color = xlattables.a.dark1[textcolor];
01148 showtext2(title, x1 + 4, y1 + 4 );
01149 activefontsettings.color = xlattables.a.light[textcolor];
01150 showtext2(title, x1 + 6, y1 + 6 );
01151 } else {
01152 activefontsettings.color = textcolor + 2;
01153 showtext2(title, x1 + 4, y1 + 4 );
01154 activefontsettings.color = textcolor - 2;
01155 showtext2(title, x1 + 6, y1 + 6 );
01156 }
01157 }
01158
01159 activefontsettings.color = textcolor;
01160 showtext2(title, x1 + 5, y1 + 5 );
01161 starty = 40;
01162 }
01163 }
01164 if (windowstyle & dlg_in3d )
01165 rahmen(true,x1 + 5,y1 + starty,x1 + xsize - 5,y1 + ysize - 5);
01166
01167 pb = firstbutton;
01168 while (pb != NULL) {
01169 if (pb->status) {
01170 if (pb->active)
01171 enablebutton(pb->id);
01172 else
01173 disablebutton(pb->id);
01174 }
01175 pb = pb->next;
01176 }
01177 }
01178
01179
01180 void tdialogbox::buildgraphics(void)
01181 {
01182
01183 if ( x1 == -1 )
01184 x1 = ( agmp->resolutionx - xsize ) / 2;
01185 else
01186 if ( x1 + xsize < 640 )
01187 x1 += (agmp->resolutionx - 640) / 2;
01188
01189 if ( y1 == -1 )
01190 y1 = ( agmp->resolutiony - ysize ) / 2;
01191 else
01192 if ( y1 + ysize < 480 )
01193 y1 += (agmp->resolutiony - 480) / 2;
01194
01195 if ( xsize == -1)
01196 xsize = agmp->resolutionx - xsize*2;
01197 if ( ysize == -1)
01198 ysize = agmp->resolutiony - ysize*2;
01199
01200 if ( pcgo )
01201 delete pcgo;
01202 pcgo = new collategraphicoperations ( x1, y1, x1 + xsize, y1 + ysize );
01203
01204 if (windowstyle & dlg_notitle )
01205 if (windowstyle & dlg_wintitle )
01206 windowstyle ^= dlg_wintitle;
01207
01208 ms = getmousestatus();
01209 if (ms == 2)
01210 mousevisible(false);
01211
01212 if ( !(dlg_mode & 2) ) {
01213 tp = malloc ( imagesize (x1,y1,x1 + xsize,y1 + ysize ) );
01214 getimage(x1,y1,x1 + xsize,y1 + ysize,tp);
01215 imagesaved = true;
01216 }
01217
01218 if ( dlg_mode & 1 ) {
01219 paint ();
01220 } else {
01221 redraw ();
01222 }
01223
01224 rebuildtaborder();
01225 activefontsettings.color = textcolor;
01226 boxstatus = 2;
01227
01228
01229
01230
01231 }
01232
01233
01234
01235 void tdialogbox::done(void)
01236 {
01237 pbutton pb;
01238 pbutton pb2;
01239
01240 if ( boxstatus ) {
01241 ms = getmousestatus();
01242 if (ms == 2)
01243 mousevisible(false);
01244 pb = firstbutton;
01245 while (pb != NULL) {
01246 pb2 = pb->next;
01247 delete ( pb );
01248 pb = pb2;
01249 }
01250
01251 if (imagesaved) {
01252 if ( first == this )
01253 ::repaintDisplay();
01254 else
01255 putimage(x1,y1,tp);
01256 free ( tp );
01257 }
01258 npop( activefontsettings );
01259 if (ms == 2)
01260 mousevisible(true);
01261 }
01262 boxstatus = 0;
01263 }
01264
01265
01266 void tdialogbox::execbutton( pbutton pb, char mouse )
01267 {
01268 int t, l;
01269 Uint16 *pw, *pw2;
01270
01271
01272 if (mouse == false) {
01273 if (pb->art == 0) {
01274 if ((pb->style == 1) || (pb->style == 2))
01275 buttonpressed(pb->id);
01276 }
01277 if (pb->art == 3)
01278 toggleswitch(pb);
01279 }
01280 else {
01281 if (pb->art == 0) {
01282 if (pb->style == 1) {
01283 newknopfdruck(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
01284 if (knopfsuccessful)
01285 buttonpressed(pb->id);
01286 }
01287 if (pb->style == 2) {
01288 mousevisible(false);
01289 pb->pressed = 1;
01290 pb->newpressed = 1;
01291 newknopfdruck4(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
01292 mousevisible(true);
01293 t = ticker;
01294 buttonpressed(pb->id);
01295 pb->newpressed = 2;
01296 while ((mouseparams.x >= x1 + pb->x1) && (mouseparams.x <= x1 + pb->x2) && (mouseparams.y >= y1 + pb->y1) && (mouseparams.y <= y1 + pb->y2) && (mouseparams.taste & 1)) {
01297 if (ticker - t > pb->scrollspeed ) {
01298 t = ticker;
01299 buttonpressed(pb->id);
01300 }
01301 releasetimeslice();
01302 }
01303 mousevisible(false);
01304 newknopfdruck3(x1 + pb->x1,y1 + pb->y1,x1 + pb->x2,y1 + pb->y2);
01305 pb->newpressed = 0;
01306 pb->pressed = 0;
01307 mousevisible(true);
01308 }
01309
01310 }
01311 if (pb->art == 3) {
01312 toggleswitch(pb);
01313 do {
01314 releasetimeslice();
01315 } while (!(mouseparams.taste == 0));
01316 }
01317
01318 if (pb->art == 5) {
01319 pw = (Uint16*) pb->data;
01320 pw2 = (Uint16*) pb->data2;
01321
01322 l = pb->y2 - pb->y1 - 2;
01323
01324 int xb1 = x1 + pb->x1;
01325 int yb1 = y1 + pb->y1;
01326 int xb2 = x1 + pb->x2;
01327 int yb2 = y1 + pb->y2;
01328
01329
01330 if ( mouseparams.y >= yb1 + 1 + l * *pw / *pw2 && mouseparams.y <= yb1 + 1 + l * (*pw + pb->max) / *pw2) {
01331 char mss = getmousestatus ();
01332 if (mss == 2)
01333 mousevisible(false);
01334
01335 int ys1 = yb1 + 1 + l * *pw / *pw2;
01336 int ys1a = ys1;
01337 int ys1b = ys1a;
01338 int ysd = yb1 + 1 + l * (*pw + pb->max) / *pw2 - ys1;
01339 rahmen(true, xb1 + 1, ys1,
01340 xb2 - 1, ys1 + ysd);
01341 int mousestarty = mouseparams.y;
01342
01343 mousevisible( true );
01344
01345 while (mouseparams.taste & 1) {
01346 int i = mouseparams.y - mousestarty ;
01347 ys1 = ys1a + i;
01348 if ( ys1 <= yb1)
01349 ys1 = yb1+1;
01350 if ( ys1 + ysd >= yb2 )
01351 ys1 = yb2 - ysd - 1;
01352
01353 if ( ys1 != ys1b ) {
01354 collategraphicoperations cgo ( x1 + pb->x1, y1 + pb->y1, x1 + pb->x2, y1 + pb->y2 );
01355 ys1b = ys1;
01356
01357 mousevisible(false);
01358 paintsurface2(x1 + pb->x1 + 1,y1 + pb->y1 + 1,x1 + pb->x2 - 1,y1 + pb->y2 - 1 );
01359 rahmen(true, xb1 + 1, ys1, xb2 - 1, ys1 + ysd);
01360 cgo.off();
01361 int j = (ys1 - yb1 - 1) * (*pw2) / l;
01362 if (j != *pw) {
01363 *pw = j;
01364 buttonpressed(pb->id);
01365 }
01366 mousevisible( true );
01367 }
01368 releasetimeslice();
01369 }
01370 mousevisible( false );
01371 showbutton( pb->id );
01372 if (mss == 2)
01373 mousevisible(true);
01374 } else {
01375
01376 l = *pw;
01377 t = mouseparams.y - (pb->y1 + y1);
01378 *pw = (10 * t * (*pw2 - pb->max) / (pb->y2 - pb->y1 - 2) + 5) / 10;
01379 if (*pw != l) {
01380 l = getmousestatus();
01381 if (l == 2)
01382 mousevisible(false);
01383 showbutton(pb->id);
01384 buttonpressed(pb->id);
01385 if (l == 2)
01386 mousevisible(true);
01387 }
01388 }
01389 }
01390
01391 if (pb->art == 6) {
01392
01393 int height = pb->entrynum * 25 + 10;
01394 int starty = y1 + pb->y2;
01395 if ( starty + height > agmp->resolutiony )
01396 starty = agmp->resolutiony - height;
01397
01398 mousevisible(false);
01399
01400 int* pos = (int*) pb->data ;
01401
01402 activefontsettings.font = schriften.smallarial;
01403 activefontsettings.background = lightgray;
01404 activefontsettings.justify = lefttext;
01405 activefontsettings.length = (Uint16) (pb->x2 - pb->x1 - 20 );
01406
01407 void* buf = malloc ( imagesize ( x1 + pb->x1, starty, x1 + pb->x2, starty + height ));
01408 getimage( x1 + pb->x1, starty, x1 + pb->x2, starty + height, buf );
01409
01410 bar ( x1 + pb->x1, starty, x1 + pb->x2, starty + height, lightgray );
01411 rectangle ( x1 + pb->x1, starty, x1 + pb->x2, starty + height, black );
01412
01413 bool first = true;
01414 int oldpos = *pos;
01415
01416 mousevisible(true);
01417 do {
01418 int p = (mouseparams.y - starty - 5);
01419 if ( p < 0 )
01420 p = -1;
01421 else
01422 p /= 25;
01423
01424 if ( (p >= 0 && p < pb->entrynum ) || first )
01425 if ( p != *pos || first ) {
01426 if ( p != *pos && p >= 0 && p < pb->entrynum )
01427 *pos = p;
01428 for ( int i = 0; i < pb->entrynum; ++i ) {
01429 if ( i == *pos )
01430 activefontsettings.color = textcolor;
01431 else
01432 activefontsettings.color = black ;
01433 showtext2 ( pb->entries[i], x1 + pb->x1 + 5, starty + i * 25 + 5 );
01434 }
01435 }
01436 releasetimeslice();
01437 first = false;
01438 } while ((mouseparams.x >= x1 + pb->x1) && (mouseparams.x <= x1 + pb->x2) && (mouseparams.y >= min(starty, y1+pb->y1)) && (mouseparams.y <= starty + height) && (mouseparams.taste & 1)) ;
01439 mousevisible(false);
01440
01441 putimage ( x1 + pb->x1, starty, buf );
01442 free ( buf );
01443 mousevisible(true);
01444 enablebutton( pb->id );
01445 if ( oldpos != *pos )
01446 buttonpressed( pb->id );
01447 }
01448
01449 if ( pb->art > 10 ) {
01450 buttonpressed(pb->id);
01451 while ( mouseinrect ( x1 + pb->x1 , y1 + pb->y1 , x1 + pb->x2 , y1 + pb->y2 ) && ( mouseparams.taste & 1))
01452 releasetimeslice();
01453 }
01454
01455
01456
01457
01458
01459
01460
01461
01462 }
01463 if ((pb->art == 1) || (pb->art == 2)) {
01464 editfield(pb);
01465 buttonpressed(pb->id);
01466 }
01467 }
01468
01469
01470 void tdialogbox::showtabmark(int b)
01471 {
01472 if (b != 0)
01473 xorrectangle(x1 + taborder[b].x1 - 2,y1 + taborder[b].y1 - 2,x1 + taborder[b].x2 + 2,y1 + taborder[b].y2 + 2,15);
01474 }
01475
01476
01477 void tdialogbox::run(void)
01478 {
01479 if ( pcgo ) {
01480 delete pcgo;
01481 pcgo = NULL;
01482 }
01483
01484 int xm, ym, xp, yp;
01485 int i, oldx, oldy, xp2, yp2;
01486 pbutton pb;
01487
01488 taste = ct_invvalue;
01489 if (getmousestatus() == 2) {
01490
01491 if ((mouseparams.x > x1 + 5) && (mouseparams.y > y1 + 3) && (mouseparams.x < x1 + xsize - 5) && (mouseparams.y < y1 + 20) && (mouseparams.taste == 1) && (dlg_mode & 3) == 3 ) {
01492
01493 oldx = x1;
01494 oldy = y1;
01495 xp2 = oldx;
01496 yp2 = oldy;
01497
01498 xm = mouseparams.x;
01499 ym = mouseparams.y;
01500 xp = xm;
01501 yp = ym;
01502
01503 while (mouseparams.taste == 1) {
01504 if ((mouseparams.x != xp) || (mouseparams.y != yp)) {
01505 x1 = oldx + (mouseparams.x - xm);
01506 y1 = oldy + (mouseparams.y - ym);
01507 if (x1 < 0) x1 = 0;
01508 if (y1 < 0) y1 = 0;
01509 if (x1 + xsize >= agmp->resolutionx) x1 = agmp->resolutionx - xsize - 1;
01510 if (y1 + ysize >= agmp->resolutiony) y1 = agmp->resolutiony - ysize - 1;
01511 if ((x1 != xp2) || (y1 != yp2)) {
01512
01513 mousevisible(false);
01514 xorrectangle(xp2,yp2,xp2 + xsize,yp2 + ysize,14);
01515 xorrectangle(x1,y1,x1 + xsize,y1 + ysize,14);
01516 mousevisible(true);
01517
01518 xp2 = x1;
01519 yp2 = y1;
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533 }
01534 xp = mouseparams.x;
01535 yp = mouseparams.y;
01536 }
01537 releasetimeslice();
01538 }
01539
01540
01541 if ((oldx != x1) || (oldy != y1)) {
01542
01543 paint();
01544
01545 if ( prev )
01546 prev->redrawall2( oldx, oldy, oldx + xsize, oldy + ysize );
01547 else
01548 repaintDisplay();
01549
01550 }
01551
01552 }
01553 if (mouseparams.taste == 1) {
01554 pb = firstbutton;
01555 while (pb != NULL) {
01556 if (pb->status)
01557 if (pb->active) {
01558 if ((mouseparams.x >= x1 + pb->x1) && (mouseparams.x <= x1 + pb->x2) && (mouseparams.y >= y1 + pb->y1) && (mouseparams.y <= y1 + pb->y2)) {
01559 execbutton(pb,true);
01560 break;
01561 }
01562 }
01563 pb = pb->next;
01564 }
01565 }
01566 }
01567 if (keypress()) {
01568 getkeysyms ( &taste, &prntkey );
01569 }
01570 else {
01571 taste = ct_invvalue;
01572 prntkey = cto_invvalue;
01573 }
01574
01575 releasetimeslice();
01576
01577 if (((taste == ct_tab) || (taste == ct_shift_tab)) && (tabcount > 0)) {
01578 showtabmark(markedtab);
01579 if (taste == ct_tab)
01580 markedtab++;
01581 else
01582 markedtab--;
01583 if (markedtab > tabcount)
01584 markedtab = 1;
01585 if (markedtab < 1)
01586 markedtab = tabcount;
01587 showtabmark(markedtab);
01588 }
01589 else {
01590 pb = firstbutton;
01591 while (pb != NULL) {
01592 if (pb->markedkeynum > 0)
01593 for (i = 0; i < pb->markedkeynum; i++)
01594 if (markedtab > 0)
01595 if ((pb->markedkey[i] == prntkey) && (taborder[markedtab].id == pb->id))
01596 if (pb->active)
01597 if (pb->status == 1) {
01598 execbutton(pb,false);
01599 taste = ct_invvalue;
01600 prntkey = ct_invvalue;
01601 }
01602 if (pb->keynum > 0)
01603 for (i = 0; i < pb->keynum; i++)
01604 if (pb->key[i] == prntkey)
01605 if (pb->active)
01606 if (pb->status == 1) {
01607 execbutton(pb,false);
01608 taste = ct_invvalue;
01609 prntkey = ct_invvalue;
01610 }
01611 pb = pb->next;
01612 }
01613 }
01614 }
01615
01616
01617
01618 void tdialogbox::toggleswitch(pbutton pb)
01619 {
01620
01621 char *pbl = (char*) pb->data;
01622
01623 if ( pb->style == 10 )
01624 *pbl = 1;
01625 else
01626 *pbl = ! *pbl;
01627
01628
01629 int col;
01630
01631 if (*pbl)
01632 col = pb->min;
01633 else
01634 col = pb->max;
01635
01636 line(x1 + pb->x1,y1 + pb->y1,x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y2, col);
01637 line(x1 + pb->x1 + (pb->y2 - pb->y1),y1 + pb->y1,x1 + pb->x1,y1 + pb->y2, col);
01638
01639 buttonpressed(pb->id);
01640
01641 }
01642
01643
01644 char tdialogbox::checkvalue(int id,
01645 void* p)
01646 {
01647 return true;
01648 }
01649
01650
01651 void tdialogbox::editfield( int id )
01652 {
01653 pbutton pb = firstbutton;
01654 while ( pb ) {
01655 if (pb->id == id )
01656 editfield ( pb );
01657 pb = pb->next;
01658 }
01659 }
01660
01661
01662 void tdialogbox::editfield(pbutton pb)
01663 {
01664 char *ps = NULL;
01665 int *pl = NULL;
01666 Uint16 *pw = NULL;
01667 char *pbt = NULL;
01668 int l;
01669
01670 activefontsettings.font = schriften.smallarial;
01671 activefontsettings.color = textcolor;
01672 activefontsettings.background = dblue;
01673 activefontsettings.length = (Uint16) (pb->x2 - pb->x1 - 10 );
01674
01675 if (pb->art == 1) {
01676 ps = (char*) pb->data;
01677
01678 do {
01679 stredit(ps, x1 + pb->x1 + 5,y1 + pb->y1 + 2,pb->x2 - pb->x1 - 10, pb->max);
01680 } while ( !checkvalue(pb->id,ps) );
01681
01682 }
01683 if (pb->art == 2) {
01684 if (pb->max <= 255 && pb->min >= 0) {
01685 pbt = (char*) pb->data;
01686 l = *pbt;
01687 }
01688 else
01689 if (pb->max <= 65535 && pb->min >= 0) {
01690 pw = (Uint16*) pb->data;
01691 l = *pw;
01692 }
01693 else {
01694 pl = (int*) pb->data;
01695 l = *pl;
01696 }
01697
01698 do {
01699 intedit( &l,x1 + pb->x1 + 5,y1 + pb->y1 + 2,pb->x2 - pb->x1 - 10,pb->min,pb->max);
01700 } while ( !checkvalue(pb->id, &l) );
01701
01702 if (pb->max <= 255 && pb->min >= 0) {
01703 *pbt = l;
01704 }
01705 else
01706 if (pb->max <= 65535 && pb->min >= 0) {
01707 *pw = l;
01708 }
01709 else {
01710 *pl = l;
01711 }
01712 }
01713 }
01714
01715
01716
01717
01718 void tdialogbox::rahmen3(const char * txt,
01719 int x1,
01720 int y1,
01721 int x2,
01722 int y2,
01723 int style)
01724 {
01725 collategraphicoperations cgs( x1, y1, x2, y2 );
01726
01727 Uint16 w;
01728
01729 npush( activefontsettings );
01730 activefontsettings.font = schriften.smallarial;
01731 w = gettextwdth(txt,NULL);
01732 if (style == 1) {
01733 line(x1,y1,x1,y2,black);
01734 line(x1,y2,x2,y2,black);
01735 line(x2,y1,x2,y2,black);
01736 line(x1,y1,x1 + 9,y1,black);
01737 line(x1 + 10 + w + 5,y1,x2,y1,black);
01738 }
01739 activefontsettings.justify = lefttext;
01740 activefontsettings.length = 0;
01741 showtext2(txt,x1 + 12,y1 - activefontsettings.font->height / 2);
01742
01743 npop( activefontsettings );
01744 }
01745
01746
01747 typedef char* tstringa[30];
01748 typedef tstringa* pstringa;
01749
01750
01751 class tdisplaymessage : public tdialogbox {
01752 char status;
01753 int mode;
01754 public:
01755 void init ( tstringa a, int md, int linenum, const char* buttonText = NULL );
01756 virtual void buttonpressed ( int id );
01757 virtual void run ( void );
01758 };
01759
01760 extern tdisplaymessage* messagebox;
01761
01762
01763 void tdisplaymessage::init ( tstringa a, int md, int linenum, const char* buttonText )
01764 {
01765 if ( !buttonText )
01766 buttonText = "~O~K";
01767
01768 tdialogbox::init();
01769
01770 int i,j;
01771 int maxlength = 0;
01772
01773 mode = md;
01774
01775 for (i=0;i<=linenum ;i++ ) {
01776 j = gettextwdth ( a[i], schriften.smallarial );
01777 while ( j > agmp->resolutionx ) {
01778 a[i][strlen(a[i])-1] = 0;
01779 j = gettextwdth ( a[i], schriften.smallarial );
01780 }
01781 if (maxlength < j)
01782 maxlength = j;
01783 }
01784
01785 x1 = 50;
01786 y1 = 50;
01787 if (maxlength < 150)
01788 xsize = 200;
01789 else
01790 xsize = maxlength + 50;
01791
01792 if ( maxlength > agmp->resolutionx - 100 )
01793 x1 = 0;
01794
01795 if ( xsize > agmp->resolutionx )
01796 xsize = agmp->resolutionx;
01797
01798 ysize = 55 + linenum * 20;
01799 windowstyle |= dlg_notitle;
01800 if (mode != 0) {
01801 ysize+=25;
01802 addbutton ( buttonText, 10, ysize - 35 , xsize - 10 , ysize - 10 ,0,1,1,true );
01803 addkey(1, ct_enter);
01804 addkey(1, ct_esc);
01805 addkey(1, ct_enterk );
01806 addkey(1, ct_space );
01807 };
01808
01809 buildgraphics();
01810 activefontsettings.justify = lefttext;
01811 if (mode == 1) {
01812 activefontsettings.color = lightred;
01813 } else {
01814 activefontsettings.color = black;
01815 }
01816
01817 activefontsettings.font = schriften.smallarial;
01818 for (i=0;i <= linenum ;i++ ) {
01819 showtext2( a[i], x1+10, y1+20+i*20 );
01820 }
01821 status = 0;
01822 if ( pcgo ) {
01823 delete pcgo;
01824 pcgo = NULL;
01825 }
01826 }
01827
01828 void tdisplaymessage::buttonpressed ( int id )
01829 {
01830 if ( id == 1) {
01831 status = 1;
01832 }
01833 }
01834
01835 void tdisplaymessage::run ( void )
01836 {
01837 mousevisible(true);
01838 do {
01839 tdialogbox::run();
01840 } while ( status == 0 );
01841 }
01842
01843
01844
01845
01846
01847
01848
01849 void displaymessage( const char* formatstring, int num, ... )
01850 {
01851
01852 va_list paramlist;
01853 va_start ( paramlist, num );
01854
01855 char tempbuf[1000];
01856
01857 int lng = vsprintf( tempbuf, formatstring, paramlist );
01858 if ( lng >= 1000 )
01859 displaymessage ( "dlg_box.cpp / displaymessage: string to long !\nPlease report this error",1 );
01860
01861 va_end ( paramlist );
01862
01863 displaymessage ( ASCString ( tempbuf ), num );
01864 }
01865
01866 void displaymessage( const ASCString& text, int num )
01867 {
01868 const char* a = text.c_str();
01869
01870 tstringa stringtooutput;
01871 memset (stringtooutput, 0, sizeof ( stringtooutput ));
01872 stringtooutput[0] = new char[200];
01873 stringtooutput[0][0] = 0;
01874 char* b = stringtooutput[0];
01875
01876 int linenum = 0;
01877
01878 while ( *a ) {
01879 if (*a == '\n') {
01880 *b = 0;
01881 linenum++;
01882 stringtooutput[linenum] = new char[200];
01883 b = stringtooutput[linenum];
01884 *b = 0;
01885 } else {
01886 *b = *a;
01887 b++;
01888 }
01889 a++;
01890 }
01891
01892 *b = 0;
01893
01894
01895 bool displayInternally = true;
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905 #ifndef NoStdio
01906 if ( num == 2 )
01907 displayInternally = false;
01908 #endif
01909
01910
01911 if ( num == 2 )
01912 displayLogMessage(1, text );
01913
01914
01915
01916 if ( !displayInternally ) {
01917 for ( int i=0; i<= linenum ;i++ )
01918 fprintf(stderr,"%s\n",stringtooutput[i]);
01919 fflush( stderr );
01920 } else {
01921 #ifdef _WIN322_
01922 if ( !gameStartupComplete && num==2 ) {
01923 MessageBox(NULL, text.c_str(), "Fatal Error", MB_ICONERROR | MB_OK | MB_TASKMODAL );
01924 exit(1);
01925 }
01926 #endif
01927
01928 if ( legacyEventSystemActive() ) {
01929 static int messageboxopen = 0;
01930 if ( messageboxopen )
01931 return;
01932
01933 messageboxopen++;
01934 if ( messagebox ) {
01935 if ( messagebox->boxstatus )
01936 messagebox->done();
01937 delete messagebox;
01938 messagebox = NULL;
01939 }
01940
01941 messagebox = new tdisplaymessage;
01942
01943 if ( num== 2 )
01944 messagebox->init( stringtooutput, num, linenum, "~q~uit program");
01945 else
01946 messagebox->init( stringtooutput, num, linenum);
01947
01948 if (num != 0 ) {
01949 messagebox->run();
01950 messagebox->done();
01951 delete messagebox;
01952 messagebox = NULL;
01953 }
01954
01955 messageboxopen--;
01956 } else {
01957 MessagingHub::Instance().warning( text );
01958 }
01959 }
01960
01961 if ( num == 2 ) {
01962 #ifdef _WIN32_
01963
01964 MessageBox(NULL, text.c_str(), "Fatal Error", MB_ICONERROR | MB_OK | MB_TASKMODAL );
01965 exit(1);
01966
01967 #endif
01968 exit ( 1 );
01969 }
01970
01971 for ( int i=linenum; i>=0 ;i-- )
01972 delete[] stringtooutput[i];
01973 }
01974
01975
01976 void removemessage( void )
01977 {
01978 if ( messagebox ) {
01979 if ( messagebox->boxstatus == 2)
01980 messagebox->done();
01981 delete messagebox;
01982 messagebox = NULL;
01983
01984 }
01985 }
01986
01987
01988
01989 void tdialogbox::dispeditstring ( char* st, int x1, int y1 )
01990 {
01991 showtext2(st,x1,y1);
01992 }
01993
01994
01995 void tdialogbox::stredit(char * s,
01996 int x1,
01997 int y1,
01998 int wdth,
01999 int max)
02000 {
02001
02002 char *ss, *ss2, *ss3;
02003 char einfuegen;
02004 int position;
02005 int i;
02006
02007 if ( strlen ( s ) > max )
02008 max = strlen ( s );
02009
02010 activefontsettings.justify = lefttext;
02011 ss = new char[max+5];
02012 ss2 = new char[max+5];
02013 strcpy(ss,s);
02014
02015 activefontsettings.length = wdth;
02016 activefontsettings.height = activefontsettings.font->height;
02017 {
02018 collategraphicoperations cgo ( x1, y1, x1 + wdth, y1 + activefontsettings.height );
02019 dispeditstring ( ss, x1, y1 );
02020 position = strlen(s);
02021 einfuegen = true;
02022 lne(x1,y1,ss,position,einfuegen);
02023 }
02024
02025 int cc;
02026 tkey symkey;
02027 do {
02028 if ( keypress() ) {
02029 getkeysyms ( &symkey, &cc );
02030
02031 } else {
02032 cc = cto_invvalue;
02033 symkey = ct_invvalue;
02034 releasetimeslice();
02035 }
02036
02037 if (cc != cto_invvalue ) {
02038 lne(x1,y1,ss,position,einfuegen);
02039
02040 #ifdef _DOS_ // I hate this DOS keyboard stuff !!!!!!
02041 switch (symkey) {
02042 case cto_einf:
02043 {
02044 if (einfuegen == false)
02045 einfuegen = true;
02046 else
02047 einfuegen = false;
02048 }
02049 break;
02050
02051 case cto_left: if (position >= 1)
02052 position--;
02053 break;
02054
02055 case cto_right: if (position < strlen ( ss ) )
02056 position++;
02057 break;
02058
02059 case cto_pos1: position = 0;
02060 break;
02061
02062 case cto_ende: position = strlen ( ss ) ;
02063 break;
02064
02065 case cto_entf: if ( ss[ position ] != 0 ) {
02066 for (i=0; i< position ;i++ ) {
02067 ss2[i] = ss[i];
02068 }
02069 while ( ss[i] != 0 ) {
02070 ss2[i] = ss [ i + 1 ];
02071 i++;
02072 }
02073 ss3 = ss2;
02074 ss2 = ss;
02075 ss = ss3;
02076
02077 dispeditstring (ss,x1,y1);
02078 }
02079 break;
02080
02081 case cto_right + cto_stp: if ( position < strlen ( ss ) ) {
02082 do {
02083 position++;
02084 } while ( (ss[ position ] != ' ') && ( ss[ position ] != 0 ) );
02085 }
02086 break;
02087
02088 case cto_left + cto_stp: if ( position > 0 ) {
02089 do {
02090 position--;
02091 } while ( ( position > 0 ) && ( ss [ position - 1 ] != ' ') );
02092 }
02093 break;
02094 }
02095 #else
02096 switch (symkey) {
02097 case ct_einf:
02098 {
02099 if (einfuegen == false)
02100 einfuegen = true;
02101 else
02102 einfuegen = false;
02103 }
02104 break;
02105
02106 case ct_left: if (position >= 1)
02107 position--;
02108 break;
02109
02110 case ct_right: if (position < strlen ( ss ) )
02111 position++;
02112 break;
02113
02114 case ct_pos1: position = 0;
02115 break;
02116
02117 case ct_ende: position = strlen ( ss ) ;
02118 break;
02119
02120 case ct_entf: if ( ss[ position ] != 0 ) {
02121 for (i=0; i< position ;i++ ) {
02122 ss2[i] = ss[i];
02123 }
02124 while ( ss[i] != 0 ) {
02125 ss2[i] = ss [ i + 1 ];
02126 i++;
02127 }
02128 ss3 = ss2;
02129 ss2 = ss;
02130 ss = ss3;
02131
02132 dispeditstring (ss,x1,y1);
02133 }
02134 break;
02135
02136 case ct_right + ct_stp: if ( position < strlen ( ss ) ) {
02137 do {
02138 position++;
02139 } while ( (ss[ position ] != ' ') && ( ss[ position ] != 0 ) );
02140 }
02141 break;
02142
02143 case ct_left + ct_stp: if ( position > 0 ) {
02144 do {
02145 position--;
02146 } while ( ( position > 0 ) && ( ss [ position - 1 ] != ' ') );
02147 }
02148 break;
02149 }
02150 #endif
02151
02152 lne(x1,y1,ss,position,einfuegen);
02153
02154 if ( ( cc > 31 ) && ( cc < 256 ) && (strlen(ss) < max ) ) {
02155 i=0;
02156 while ( (ss[i] != 0) && ( i < position ) ) {
02157 ss2[i] = ss[i];
02158 i++;
02159 }
02160 ss2 [ i ] = cc;
02161 if (einfuegen) {
02162 while ( ss[i] != 0) {
02163 ss2[i+1] = ss[i];
02164 i++;
02165 }
02166 ss2[i+1] = 0;
02167 } else {
02168 if (ss[i] != 0) {
02169 i++;
02170 while ( ss[i] != 0) {
02171 ss2[i+1] = ss[i];
02172 i++;
02173 }
02174 ss2[i] = 0;
02175 } else {
02176 ss2[i+1] = 0;
02177 }
02178 }
02179
02180 if (gettextwdth_stredit( ss2, NULL ) < wdth ) {
02181 collategraphicoperations cgo ( x1, y1, x1 + wdth, y1 + activefontsettings.height );
02182 lne(x1,y1,ss,position,einfuegen);
02183 ss3 = ss2;
02184 ss2 = ss;
02185 ss = ss3;
02186 dispeditstring (ss,x1,y1);
02187 position++;
02188 lne(x1,y1,ss,position,einfuegen);
02189 }
02190 }
02191 if ((cc == cto_bspace ) && (position > 0)) {
02192 collategraphicoperations cgo ( x1, y1, x1 + wdth, y1 + activefontsettings.height );
02193 lne(x1,y1,ss,position,einfuegen);
02194 for (i=0; i+1< position ; i++ ) {
02195 ss2[i] = ss[i];
02196 }
02197 i--;
02198 do {
02199 i++;
02200 ss2[i] = ss[i+1];
02201 } while (ss[i+1] != 0 );
02202 ss3 = ss2;
02203 ss2 = ss;
02204 ss = ss3;
02205 position--;
02206 dispeditstring (ss,x1,y1);
02207 lne(x1,y1,ss,position,einfuegen);
02208 }
02209 }
02210 } while ( cc != cto_enter && cc != cto_esc && !( !mouseinrect ( x1, y1, x1 + wdth, y1 + activefontsettings.height) && mouseparams.taste > 0 ) );
02211
02212 lne(x1,y1,ss,position,einfuegen);
02213 if (cc != cto_esc )
02214 strcpy(s,ss);
02215 delete[] ss;
02216 delete[] ss2;
02217 }
02218
02219
02220 int tdialogbox::gettextwdth_stredit ( char* txt, pfont font )
02221 {
02222 return gettextwdth ( txt, font );
02223 }
02224
02225
02226 void tdialogbox::lne(int x1,
02227 int y1,
02228 char * s,
02229 int position,
02230 char einfuegen)
02231 {
02232 int i, j, k;
02233
02234 ASCString ss2 = s;
02235 if ( position < ss2.length() )
02236 ss2.erase(position);
02237
02238 i = x1 + gettextwdth(ss2.c_str(),activefontsettings.font);
02239 j = y1;
02240 k = y1 + activefontsettings.font->height;
02241 collategraphicoperations cgo ( i-1, j, i+1, k );
02242 xorline(i,j,i,k,3);
02243 if (einfuegen == false) {
02244 xorline(i + 1,j,i + 1,k,3);
02245 xorline(i - 1,j,i - 1,k,3);
02246 }
02247 }
02248
02249
02250
02251
02252 void tdialogbox::intedit(int * st,
02253 int x1,
02254 int y1,
02255 int wdth,
02256 int min,
02257 int max)
02258 {
02259 char *ss, *ss2, *ss3;
02260 char einfuegen;
02261 int position;
02262 int j;
02263 int i;
02264 int ml;
02265 char ok;
02266
02267 ml = 12 ;
02268 activefontsettings.justify = lefttext;
02269
02270 ss2 = new char[ml];
02271 ss = new char[ml];
02272 itoa ( *st, ss, 10 );
02273 activefontsettings.height = activefontsettings.font->height;
02274 dispeditstring (ss,x1,y1);
02275 position = strlen(ss) ;
02276 einfuegen = true;
02277
02278 ok = false;
02279
02280 int cc;
02281 tkey symkey;
02282 do {
02283 lne(x1,y1,ss,position,einfuegen);
02284 do {
02285 if ( keypress() ) {
02286 getkeysyms ( &symkey, &cc );
02287 } else {
02288 cc = cto_invvalue;
02289 releasetimeslice();
02290 }
02291
02292 if (cc != cto_invvalue ) {
02293 collategraphicoperations cgo ( x1, y1, x1 + wdth, y1 + activefontsettings.height );
02294
02295 lne(x1,y1,ss,position,einfuegen);
02296 #ifdef _DOS_
02297 switch (symkey) {
02298
02299 case cto_einf: {
02300 if (einfuegen == false)
02301 einfuegen = true;
02302 else
02303 einfuegen = false;
02304 }
02305 break;
02306
02307 case cto_left: if (position >= 1)
02308 position--;
02309 break;
02310
02311 case cto_right: if (position < strlen ( ss ) )
02312 position++;
02313 break;
02314
02315 case cto_pos1: position = 0;
02316 break;
02317
02318 case cto_ende: position = strlen ( ss ) ;
02319 break;
02320
02321 case cto_entf: if ( ss[ position ] != 0 ) {
02322 for (i=0; i< position ;i++ ) {
02323 ss2[i] = ss[i];
02324 }
02325 while ( ss[i] != 0 ) {
02326 ss2[i] = ss [ i + 1 ];
02327 i++;
02328 }
02329 ss3 = ss2;
02330 ss2 = ss;
02331 ss = ss3;
02332
02333 dispeditstring (ss,x1,y1);
02334 }
02335 break;
02336
02337 case cto_right + cto_stp: if ( position < strlen ( ss ) ) {
02338 do {
02339 position++;
02340 } while ( (ss[ position ] != ' ') && ( ss[ position ] != 0 ) );
02341 }
02342 break;
02343
02344 case cto_left + cto_stp: if ( position > 0 ) {
02345 do {
02346 position--;
02347 } while ( ( position > 0 ) && ( ss [ position - 1 ] != ' ') );
02348 }
02349 break;
02350 }
02351 #else
02352 switch (symkey) {
02353
02354 case ct_einf: {
02355 if (einfuegen == false)
02356 einfuegen = true;
02357 else
02358 einfuegen = false;
02359 }
02360 break;
02361
02362 case ct_left: if (position >= 1)
02363 position--;
02364 break;
02365
02366 case ct_right: if (position < strlen ( ss ) )
02367 position++;
02368 break;
02369
02370 case ct_pos1: position = 0;
02371 break;
02372
02373 case ct_ende: position = strlen ( ss ) ;
02374 break;
02375
02376 case ct_entf: if ( ss[ position ] != 0 ) {
02377 for (i=0; i< position ;i++ ) {
02378 ss2[i] = ss[i];
02379 }
02380 while ( ss[i] != 0 ) {
02381 ss2[i] = ss [ i + 1 ];
02382 i++;
02383 }
02384 ss3 = ss2;
02385 ss2 = ss;
02386 ss = ss3;
02387
02388 dispeditstring (ss,x1,y1);
02389 }
02390 break;
02391
02392 case ct_right + ct_stp: if ( position < strlen ( ss ) ) {
02393 do {
02394 position++;
02395 } while ( (ss[ position ] != ' ') && ( ss[ position ] != 0 ) );
02396 }
02397 break;
02398
02399 case ct_left + ct_stp: if ( position > 0 ) {
02400 do {
02401 position--;
02402 } while ( ( position > 0 ) && ( ss [ position - 1 ] != ' ') );
02403 }
02404 break;
02405 }
02406 #endif
02407 if ( (( cc >= '0' && cc <= '9' ) || ( cc == '-' && !position)) && (strlen(ss) < ml-1 ) ) {
02408 i=0;
02409 while ( (ss[i] != 0) && ( i < position ) ) {
02410 ss2[i] = ss[i];
02411 i++;
02412 }
02413 ss2 [ i ] = cc;
02414 if (einfuegen) {
02415 while ( ss[i] != 0) {
02416 ss2[i+1] = ss[i];
02417 i++;
02418 }
02419 ss2[i+1] = 0;
02420 } else {
02421 if (ss[i] != 0) {
02422 i++;
02423 while ( ss[i] != 0) {
02424 ss2[i+1] = ss[i];
02425 i++;
02426 }
02427 }
02428 ss2[i] = 0;
02429 }
02430
02431 if (gettextwdth( ss2, NULL ) < wdth ) {
02432 ss3 = ss2;
02433 ss2 = ss;
02434 ss = ss3;
02435 dispeditstring (ss,x1,y1);
02436 position++;
02437 }
02438 }
02439 if ((cc == 8 ) && (position > 0)) {
02440
02441 for (i=0; i+1< position ; i++ )
02442 ss2[i] = ss[i];
02443
02444 i--;
02445 do {
02446 i++;
02447 ss2[i] = ss[i+1];
02448 } while (ss[i+1] != 0 );
02449 ss3 = ss2;
02450 ss2 = ss;
02451 ss = ss3;
02452 position--;
02453
02454 dispeditstring (ss,x1,y1);
02455 }
02456 lne(x1,y1,ss,position,einfuegen);
02457 }
02458
02459 } while ( (cc != cto_enter) && (cc != cto_esc) && !( !mouseinrect ( x1, y1, x1 + wdth, y1 + activefontsettings.height) && mouseparams.taste > 0 ) );
02460 lne(x1,y1,ss,position,einfuegen);
02461 if (cc != cto_esc ) {
02462 j = strtol ( ss, &ss3, 10 );
02463 if ((ss3 != NULL) && ( (ss3 - ss ) < strlen ( ss ) )) {
02464
02465 position = (ss3 - ss );
02466 lne(x1,y1,ss,position,einfuegen);
02467 ok = false;
02468
02469 } else {
02470
02471 if ( j > max || j < min ) {
02472 ok = false;
02473 displaymessage( "Invalid range ! \n range is %d to %d !", 1, min, max );
02474 } else {
02475 *st = j;
02476 ok = true;
02477 }
02478
02479 }
02480
02481 } else
02482 ok = true;
02483
02484 } while ( ! ok );
02485
02486 delete[] ss;
02487 delete[] ss2;
02488
02489 }
02490
02491
02492 void tdialogbox::paintsurface2 ( int xx1, int yy1, int xx2, int yy2 )
02493 {
02494 if ( dialogtexture )
02495 puttexture( xx1, yy1, xx2, yy2, dialogtexture);
02496 else
02497 bar( xx1, yy1, xx2, yy2, lightgray);
02498
02499 }
02500
02501 void tdialogbox::paintsurface ( int xx1, int yy1, int xx2, int yy2 )
02502 {
02503 paintsurface2( xx1 + x1, yy1 + y1, xx2 + x1, yy2 + y1 );
02504 }
02505
02506
02507
02508
02509
02510
02511 tdialogbox::~tdialogbox()
02512 {
02513 if ( pcgo ) {
02514 delete pcgo;
02515 pcgo = NULL;
02516 }
02517
02518 if ( boxstatus )
02519 done();
02520 boxstatus = 0;
02521
02522 if ( prev ) {
02523 prev->next = NULL;
02524
02525 if ( dlg_mode & 2 )
02526 prev->redrawall2( x1, y1, x1 + xsize, y1 + ysize );
02527 } else {
02528 first = NULL;
02529 repaintDisplay();
02530 }
02531 npop ( activefontsettings );
02532
02533 setEventRouting ( eventQueue, !eventQueue );
02534 }
02535
02536
02537
02538
02539
02540
02541
02542
02543
02544
02545
02546
02547 void tviewtext::setnewlineheight ( int h )
02548 {
02549 activefontsettings.height = h;
02550
02551 if (tvt_maxlineheight > activefontsettings.font->height + 5)
02552 activefontsettings.height = tvt_maxlineheight;
02553 else {
02554 if ( tvt_dispactive )
02555 if ( tvt_yp + activefontsettings.height > tvt_starty ) {
02556 int tvtny1 = tvt_y1 + tvt_yp - tvt_starty + tvt_maxlineheight;
02557 int tvtny2 = tvt_y1 + tvt_yp - tvt_starty + activefontsettings.height;
02558 int tvtnx1 = tvt_x1;
02559 int tvtnx2 = tvt_x1 + tvt_xp;
02560 if (tvtny1 < tvt_y1) {
02561 tvtny1 = tvt_y1;
02562 tvtnx1 = tvt_x1;
02563 }
02564 if (tvtny2 > tvt_y2)
02565 tvtny2 = tvt_y2;
02566 if (tvtnx2 > tvtnx1)
02567 if (tvtny2 > tvtny1)
02568 bar ( tvtnx1, tvtny1, tvtnx2, tvtny2, tvt_background);
02569 };
02570 tvt_maxlineheight = activefontsettings.height ;
02571 }
02572 }
02573
02574 void tviewtext::fillline ( int x1, int x2 )
02575 {
02576 if ( tvt_dispactive )
02577 if ( tvt_yp + activefontsettings.height > tvt_starty ) {
02578 int tvtny1 = tvt_y1 + tvt_yp - tvt_starty;
02579 int tvtny2 = tvt_y1 + tvt_yp - tvt_starty + tvt_maxlineheight;
02580 if (tvtny1 < tvt_y1) {
02581 tvtny1 = tvt_y1;
02582
02583 }
02584 if (tvtny2 > tvt_y2)
02585 tvtny2 = tvt_y2;
02586 if (x2 > x1)
02587 if (tvtny2 > tvtny1)
02588 bar ( x1, tvtny1, x2, tvtny2, tvt_background);
02589 }
02590 }
02591
02592 void tviewtext::nextline ( int einzug, const char* txtptr )
02593 {
02594 if ( tvt_dispactive == 0 && txtptr ) {
02595 if ( ( tvt_startpoint == NULL && (tvt_yp > 500) ) || ( tvt_startpoint && ( tvt_yp > (tvt_startpoint->ypos+500) ))) {
02596 pstartpoint newstartpoint = new ( tstartpoint );
02597 newstartpoint->ypos = tvt_yp;
02598 newstartpoint->xpos = tvt_xp;
02599 newstartpoint->textcolor = tvt_color;
02600 newstartpoint->background = tvt_background;
02601 newstartpoint->font = activefontsettings.font;
02602 newstartpoint->eeinzug = eeinzug;
02603 newstartpoint->aeinzug = aeinzug;
02604 newstartpoint->height = activefontsettings.height;
02605 newstartpoint->next = tvt_startpoint;
02606 newstartpoint->textpointer = txtptr ;
02607 newstartpoint->maxlineheight = tvt_maxlineheight ;
02608 tvt_startpoint = newstartpoint;
02609 }
02610
02611 }
02612
02613 fillline ( tvt_x1 + tvt_xp, tvt_x2 );
02614 tvt_yp += activefontsettings.height;
02615 tvt_xp = einzug;
02616 fillline ( tvt_x1, tvt_x1 + tvt_xp );
02617 *actline = 0;
02618 activefontsettings.height = tvt_maxlineheight = activefontsettings.font->height + 5;
02619
02620 }
02621
02622 void tviewtext::displaysingleline ( char* t)
02623 {
02624 int twdth = gettextwdth ( t , NULL );
02625 if ( tvt_dispactive ) {
02626 if ( tvt_yp >= tvt_starty ) {
02627 if ( tvt_yp < tvt_starty + tvt_y2 - tvt_y1) {
02628 if ( tvt_yp + activefontsettings.height + 1 > tvt_starty + tvt_y2 - tvt_y1)
02629 activefontsettings.height = tvt_y2 - tvt_yp + tvt_starty - tvt_y1 + 1;
02630 if (tvt_x1 + tvt_xp + twdth > tvt_x2)
02631 twdth = activefontsettings.length = tvt_x2 - tvt_x1 - tvt_xp;
02632 else
02633 activefontsettings.length = 0;
02634 showtext2( t, tvt_x1 + tvt_xp, tvt_y1 + tvt_yp - tvt_starty );
02635 }
02636 } else
02637 if ( t[0] )
02638 if ( tvt_yp + activefontsettings.height > tvt_starty ) {
02639 npush ( *agmp );
02640 *agmp = tvt_firstlinebufparm;
02641 if ( activefontsettings.height > tvt_firstlinebufheight )
02642 activefontsettings.height = tvt_firstlinebufheight;
02643 if (tvt_x1 + tvt_xp + twdth > tvt_x2)
02644 twdth = activefontsettings.length = tvt_x2 - tvt_x1 - tvt_xp;
02645 else
02646 activefontsettings.length = 0;
02647 showtext2( t, tvt_xp, 0 );
02648 npop ( *agmp );
02649 putimageprt ( tvt_x1 + tvt_xp, tvt_y1, tvt_x1 + tvt_xp + twdth, tvt_y1 + activefontsettings.height + ( tvt_yp - tvt_starty ), tvt_firstlinebuf, tvt_xp, tvt_starty - tvt_yp );
02650 }
02651 }
02652
02653 tvt_xp += twdth ;
02654 }
02655
02656
02657 void tviewtext::setpos ( int xx1, int yy1, int xx2, int yy2 )
02658 {
02659 tvt_x1 = xx1;
02660 tvt_y1 = yy1;
02661 tvt_x2 = xx2;
02662 tvt_y2 = yy2;
02663 }
02664
02665 void tviewtext::setparams ( int xx1, int yy1, int xx2, int yy2, const char* ttxt, char clr, char bkgr)
02666 {
02667 tvt_x1 = xx1;
02668 tvt_y1 = yy1;
02669 tvt_x2 = xx2;
02670 tvt_y2 = yy2;
02671 tvt_text = ttxt;
02672 tvt_color = clr;
02673 defaulttextcolor = clr;
02674 tvt_background = bkgr;
02675 tvt_maxlineheight = activefontsettings.font->height + 5;
02676 eeinzug = 0;
02677 aeinzug = 0;
02678 tvt_dispactive = 0;
02679 tvt_starty = 0;
02680 tvt_firstlinebufheight = 35;
02681
02682 tvt_firstlinebufparm.resolutionx = xx2 - xx1 + 1;
02683 tvt_firstlinebufparm.resolutiony = tvt_firstlinebufheight;
02684 tvt_firstlinebufparm.windowstatus = 100;
02685 tvt_firstlinebufparm.scanlinelength = xx2 - xx1 + 1;
02686 tvt_firstlinebufparm.scanlinenumber = tvt_firstlinebufheight;
02687 tvt_firstlinebufparm.bytesperscanline = xx2 - xx1 + 1;
02688 tvt_firstlinebufparm.byteperpix = 1;
02689
02690 tvt_startpoint = NULL;
02691 }
02692
02693 void tviewtext::displaytext ( void )
02694 {
02695 auto_ptr<collategraphicoperations> cgo;
02696 if ( tvt_dispactive )
02697 cgo.reset( new collategraphicoperations ( tvt_x1, tvt_y1, tvt_x2, tvt_y2 ) );
02698
02699 tvt_color = defaulttextcolor;
02700 tvt_maxlineheight = activefontsettings.font->height + 5;
02701 eeinzug = 0;
02702 aeinzug = 0;
02703
02704
02705 char *actword, *s5;
02706 const char* s1;
02707 int i;
02708
02709 tvt_xp = 0;
02710 tvt_yp = 0;
02711
02712 npush ( activefontsettings );
02713
02714 actline = new char[200];
02715 actword = new char[200];
02716 s5 = new char[200];
02717
02718 {
02719 tvt_firstlinebuf = new char [ ( tvt_x2 - tvt_x1) * ( tvt_firstlinebufheight + 5 ) ];
02720 memset ( tvt_firstlinebuf , tvt_background, (tvt_x2 - tvt_x1) * ( tvt_firstlinebufheight + 5 ) );
02721
02722 Uint16* pw = (Uint16*) tvt_firstlinebuf;
02723 *pw = (tvt_x2 - tvt_x1);
02724 pw++;
02725 *pw = tvt_firstlinebufheight;
02726 pw++;
02727 tvt_firstlinebufparm.linearaddress = (PointerSizedInt) pw;
02728 }
02729
02730
02731 s1 = tvt_text;
02732 activefontsettings.background = tvt_background;
02733 activefontsettings.color = tvt_color;
02734 activefontsettings.font = schriften.smallarial;
02735 activefontsettings.justify = lefttext;
02736 activefontsettings.height = activefontsettings.font->height + 5;
02737
02738
02739 if (tvt_dispactive) {
02740
02741 if ( tvt_startpoint ) {
02742 pstartpoint startpoint = tvt_startpoint;
02743 while ( startpoint && ( startpoint->ypos+100 > tvt_starty ) )
02744 startpoint = startpoint->next;
02745
02746 if ( startpoint ) {
02747 tvt_color = startpoint->textcolor;
02748 tvt_background = startpoint->background ;
02749 activefontsettings.font = startpoint->font ;
02750 eeinzug = startpoint->eeinzug ;
02751 aeinzug = startpoint->aeinzug ;
02752 tvt_xp = startpoint->xpos;
02753 tvt_yp = startpoint->ypos;
02754 tvt_maxlineheight = startpoint->maxlineheight;
02755 activefontsettings.height = startpoint->height ;
02756 s1 = startpoint->textpointer ;
02757 }
02758 }
02759
02760 }
02761
02762 if ( tvt_text ) {
02763 *actline = 0;
02764 *actword = 0;
02765 do {
02766 i = 0;
02767 while (*s1 != '#' && *s1 != 0 && *s1 != '\n' && *s1 != ' ' && *s1 != '-') {
02768 actword[i] = *s1;
02769 i++;
02770 s1++;
02771 }
02772 if ( *s1 == ' ' || *s1 == '-' ) {
02773 actword[i] = *s1;
02774 i++;
02775 s1++;
02776 }
02777
02778 actword[i] = 0;
02779
02780 strcpy ( s5, actline );
02781 strcat ( s5, actword );
02782
02783 if ( tvt_xp + gettextwdth ( s5, NULL ) < tvt_x2 - tvt_x1 )
02784 strcat ( actline, actword );
02785 else {
02786 displaysingleline ( actline );
02787 nextline ( aeinzug, s1 );
02788 activefontsettings.length = 0;
02789 strcpy ( actline, actword );
02790 }
02791
02792 if (*s1 == '\n') {
02793 displaysingleline ( actline );
02794 nextline ( eeinzug, s1 );
02795 s1++;
02796 }
02797 if (*s1 == 0) {
02798 displaysingleline ( actline );
02799 nextline ( 0, s1 );
02800 }
02801
02802 if (*s1 == '#') {
02803 displaysingleline ( actline );
02804 *actline = 0;
02805 evalcommand ( &s1 );
02806 }
02807 } while ((*s1 != 0) && ((tvt_yp - tvt_starty < tvt_y2 - tvt_y1) || !tvt_dispactive ));
02808 if ( tvt_dispactive )
02809 if (tvt_yp - tvt_starty < tvt_y2 - tvt_y1)
02810 bar ( tvt_x1, tvt_yp + tvt_y1 - tvt_starty, tvt_x2, tvt_y2, tvt_background);
02811
02812 }
02813
02814 delete[] s5;
02815 delete[] actword;
02816 delete[] actline;
02817
02818 delete[] tvt_firstlinebuf;
02819
02820 npop ( activefontsettings );
02821
02822 }
02823
02824
02825
02826 void tviewtext::evalcommand ( const char** s)
02827 {
02828 const char* s3 = *s;
02829 char s4[100];
02830 int k, i = 0,
02831 j = 0;
02832 int tvt_oldx;
02833
02834
02835 memset( s4, 0, sizeof( s4 ));
02836 if (strnicmp(s3, "#COLOR", 6) == 0) {
02837 i+=6;
02838 while (s3[i] != '#') {
02839 s4[j] = s3[i];
02840 j++;
02841 i++;
02842 }
02843 s4[j] = 0;
02844 k = atoi( s4 );
02845 if (k == 256)
02846 activefontsettings.color = tvt_color;
02847 else
02848 activefontsettings.color = k;
02849 }
02850
02851 if (strnicmp(s3, "#BACKGROUND", 11) == 0) {
02852 i+=11;
02853 while (s3[i] != '#') {
02854 s4[j] = s3[i];
02855 j++;
02856 i++;
02857 }
02858 s4[j] = 0;
02859 k = atoi( s4 );
02860 if (k == 256)
02861 activefontsettings.background = tvt_background;
02862 else
02863 activefontsettings.background = k;
02864 }
02865
02866 if (strnicmp(s3, "#FONT", 5) == 0) {
02867 i+=5;
02868 while (s3[i] != '#') {
02869 s4[j] = s3[i];
02870 j++;
02871 i++;
02872 }
02873 s4[j] = 0;
02874
02875 k = atoi ( s4 );
02876 switch (k) {
02877 case 1: activefontsettings.font = schriften.smallarial;
02878 break;
02879 case 2: activefontsettings.font = schriften.arial8;
02880 break;
02881 default: activefontsettings.font = schriften.smallarial;
02882 break;
02883 }
02884 setnewlineheight ( activefontsettings.font->height + 5 );
02885 }
02886
02887 if (strnicmp(s3, "#TAB", 4) == 0) {
02888 tvt_oldx = tvt_xp;
02889 i+=4;
02890 while (s3[i] != '#') {
02891 s4[j] = s3[i];
02892 j++;
02893 i++;
02894 }
02895 s4[j] = 0;
02896
02897 k = atoi ( s4 );
02898
02899 int tvtxp = 0;
02900 if (k)
02901 tvtxp = (tvt_xp / k + 1) * k;
02902
02903 fillline ( tvt_x1 + tvt_xp, tvt_x1 + tvtxp );
02904 tvt_xp = tvtxp;
02905
02906 }
02907 if (strnicmp(s3, "#POS", 4) == 0) {
02908 tvt_oldx = tvt_xp;
02909 i+=4;
02910 while (s3[i] != '#') {
02911 s4[j] = s3[i];
02912 j++;
02913 i++;
02914 }
02915 s4[j] = 0;
02916
02917 k = atoi ( s4 );
02918 fillline ( tvt_x1 + tvt_xp, tvt_x1 + k );
02919 tvt_xp = k;
02920 }
02921
02922 if (strnicmp(s3, "#EEINZUG", 8) == 0) {
02923 tvt_oldx = tvt_xp;
02924 i+=8;
02925 while (s3[i] != '#') {
02926 s4[j] = s3[i];
02927 j++;
02928 i++;
02929 }
02930 s4[j] = 0;
02931
02932 eeinzug = atoi ( s4 );
02933 }
02934 if (strnicmp(s3, "#AEINZUG", 8) == 0) {
02935 tvt_oldx = tvt_xp;
02936 i+=8;
02937 while (s3[i] != '#') {
02938 s4[j] = s3[i];
02939 j++;
02940 i++;
02941 }
02942 s4[j] = 0;
02943
02944 aeinzug = atoi ( s4 );
02945 }
02946
02947 if (strnicmp(s3, "#CRT#", 5) == 0) {
02948 nextline ( eeinzug, NULL );
02949 i=4;
02950 }
02951 if (strnicmp(s3, "#CRTP", 5) == 0) {
02952 i+=5;
02953 while (s3[i] != '#') {
02954 s4[j] = s3[i];
02955 j++;
02956 i++;
02957 }
02958 s4[j] = 0;
02959 if ( s3[i+1] == '\n' )
02960 i++;
02961 k = atoi ( s4 );
02962 setnewlineheight ( activefontsettings.height + k );
02963 nextline ( eeinzug, NULL );
02964 }
02965
02966
02967 (*s)+=i+1;
02968 }
02969
02970
02971 tviewtext::tviewtext()
02972 {
02973 tvt_startpoint = NULL;
02974 }
02975
02976
02977 tviewtext::~tviewtext()
02978 {
02979 while ( tvt_startpoint ) {
02980 pstartpoint startpoint = tvt_startpoint;
02981 tvt_startpoint = tvt_startpoint->next;
02982 delete startpoint;
02983 }
02984 }
02985
02986
02987
02988 void tviewtextwithscrolling::checkscrolling ( void )
02989 {
02990 int pagepressed_scrollspeedmultiplicator = 8;
02991 int tick = ticker;
02992 while ( (skeypress ( ct_down ) || skeypress ( ct_2k )) && (tvt_starty + textsizey < textsizeycomplete)) {
02993 tvt_starty += ticker - tick;
02994 tick = ticker;
02995 if ( tvt_starty + textsizey > textsizeycomplete )
02996 tvt_starty = textsizeycomplete - textsizey;
02997
02998 displaytext();
02999 repaintscrollbar();
03000 }
03001
03002 tick = ticker;
03003 while ( (skeypress ( ct_up ) || skeypress ( ct_8k )) && (tvt_starty > 0) ) {
03004 tvt_starty -= ticker - tick;
03005 tick = ticker;
03006 if ( tvt_starty < 0 )
03007 tvt_starty = 0;
03008
03009 displaytext();
03010 repaintscrollbar();
03011 }
03012
03013 if ( (skeypress ( ct_pos1 ) || skeypress ( ct_7k )) && (tvt_starty > 0)) {
03014 tvt_starty = 0;
03015 displaytext();
03016 repaintscrollbar();
03017 }
03018
03019 if ( (skeypress ( ct_ende ) || skeypress ( ct_1k )) && (tvt_starty < textsizeycomplete - textsizey )) {
03020 tvt_starty = textsizeycomplete - textsizey;
03021 displaytext();
03022 repaintscrollbar();
03023 }
03024
03025
03026 tick = ticker;
03027 while ( (skeypress ( ct_pdown ) || skeypress ( ct_3k )) && (tvt_starty + textsizey < textsizeycomplete)) {
03028 tvt_starty += (ticker - tick) * pagepressed_scrollspeedmultiplicator;
03029 tick = ticker;
03030 if ( tvt_starty + textsizey > textsizeycomplete )
03031 tvt_starty = textsizeycomplete - textsizey;
03032
03033 displaytext();
03034 repaintscrollbar();
03035 }
03036
03037 tick = ticker;
03038 while ( (skeypress ( ct_pup ) || skeypress ( ct_9k )) && (tvt_starty > 0) ) {
03039 tvt_starty -= (ticker - tick) * pagepressed_scrollspeedmultiplicator;
03040 tick = ticker;
03041 if ( tvt_starty < 0 )
03042 tvt_starty = 0;
03043
03044 displaytext();
03045 repaintscrollbar();
03046 }
03047
03048 }
03049
03050
03051
03052
03053
03054 ASCString readtextmessage( int id )
03055 {
03056 char s1[10];
03057 sprintf ( s1, "##%4d", id );
03058 {
03059 char* b = s1;
03060 while ( *b ) {
03061 if ( *b == ' ' )
03062 *b = '0';
03063 b++;
03064 }
03065 }
03066
03067 ASCString txt;
03068
03069 int wldcrdnum = 3;
03070
03071 ASCString tmpstr;
03072 if ( actmap )
03073 tmpstr = actmap->preferredFileNames.mapname[0];
03074
03075 while ( tmpstr.find ( ".map") != string::npos )
03076 tmpstr.replace ( tmpstr.find ( ".map"), 4, ".msg" );
03077
03078 while( tmpstr.find ( ".MAP") != string::npos )
03079 tmpstr.replace ( tmpstr.find ( ".MAP"), 4, ".msg" );
03080
03081 displayLogMessage(7, ASCString("Retrieving message ") + strrr(id) + "; looking for message file " + tmpstr + "\n");
03082
03083
03084 tfindfile ff3 ( tmpstr.c_str() );
03085 tfindfile ff2 ( "*.msg" );
03086 tfindfile ff ( "helpsys?.txt" );
03087
03088
03089 tfindfile* ffa[3] = { &ff3, &ff, &ff2 };
03090
03091 for ( int m = 0; m < wldcrdnum; m++ ) {
03092
03093 tfindfile* pff = ffa[m];
03094
03095 ASCString filefound = pff->getnextname();
03096
03097 while( !filefound.empty() ) {
03098
03099 tnfilestream stream ( filefound.c_str(), tnstream::reading );
03100
03101 ASCString tempstr;
03102
03103 bool data = stream.readTextString ( tempstr );
03104 int started = 0;
03105
03106 while ( data ) {
03107 if ( started ) {
03108 if ( tempstr[0] != ';' ) {
03109 if ( tempstr[0] == '#' && tempstr[1] == '#' ) {
03110 started = 0;
03111 return txt;
03112 } else
03113 txt += tempstr + "\n";
03114 }
03115 } else
03116 if ( tempstr == s1 )
03117 started = 1;
03118
03119 data = stream.readTextString ( tempstr );
03120 }
03121
03122 if ( started ) {
03123 started = 0;
03124 return txt;
03125 }
03126
03127 filefound = pff->getnextname();
03128
03129 }
03130 }
03131
03132 return txt;
03133 }
03134
03135
03136
03137
03138 #define ppicture tpicture*
03139
03140 struct tpicture {
03141 void* pict;
03142 int size;
03143 int width, height;
03144 int x, y;
03145 ppicture next;
03146 char descrip[20];
03147 };
03148
03149 class thelpsystem : public tdialogbox, public tviewtextwithscrolling {
03150 public:
03151 ASCString txt;
03152 char ok;
03153
03154 char scrollbarvisible;
03155 ppicture firstpict;
03156 char action;
03157 int textstart;
03158
03159 void init( int id, const char* titlet );
03160 virtual void setup();
03161 void buildgraphics ( void );
03162 virtual void run ( void );
03163
03164 virtual void buttonpressed( int id);
03165 void repaintscrollbar( void );
03166 void done ( void );
03167 };
03168
03169
03170
03171 void thelpsystem::setup( void )
03172 {
03173 addbutton ( "~O~K", 10, ysize - 30, xsize - 10, ysize - 10, 0, 1, 5, 1 );
03174 addkey ( 5, ct_esc );
03175 addkey ( 5, ct_space );
03176 addkey ( 5, ct_enter );
03177 }
03178
03179 void thelpsystem::init(int id, const char* titlet )
03180 {
03181
03182
03183
03184 tdialogbox::init();
03185 x1 = 70;
03186 y1 = 20;
03187 xsize = 500;
03188 ysize = 440;
03189 textstart = 42;
03190 textsizey = (ysize - textstart - 40);
03191 starty = starty + 10;
03192 title = titlet;
03193 windowstyle ^= dlg_in3d;
03194 action=0;
03195
03196
03197
03198 txt = readtextmessage( id );
03199
03200 if ( txt.empty() ) {
03201 txt = "help topic not found : ";
03202 txt += strrr (id );
03203 }
03204
03205 setup();
03206
03207
03208 setparams ( x1 + 13, y1 + textstart, x1 + xsize - 41, y1 + ysize - 40, txt.c_str(), black, dblue);
03209
03210 tvt_dispactive = 0;
03211
03212 displaytext( );
03213 textsizeycomplete = tvt_yp;
03214 tvt_dispactive = 1;
03215
03216
03217 if (textsizeycomplete >= textsizey) {
03218 scrollbarvisible = true;
03219 addscrollbar(xsize - 30,starty,xsize - 15,ysize - 40,&textsizeycomplete, textsizey, &tvt_starty,1,0);
03220 setscrollspeed ( 1 , 1 );
03221
03222 }
03223 else
03224 scrollbarvisible = false;
03225
03226 tvt_starty = 0;
03227
03228 }
03229
03230 void thelpsystem::repaintscrollbar( void )
03231 {
03232 enablebutton( 1 );
03233 }
03234
03235
03236 void thelpsystem::buildgraphics(void)
03237 {
03238 tdialogbox::buildgraphics();
03239 setpos ( x1 + 13, y1 + textstart, x1 + xsize - 41, y1 + ysize - 40 );
03240 rahmen(true,x1 + 10,y1 + textstart - 2,x1 + xsize - 40,y1 + textstart + textsizey + 2);
03241
03242 mousevisible(true);
03243
03244 activefontsettings.font = schriften.smallarial;
03245 activefontsettings.color = black;
03246 activefontsettings.justify = lefttext;
03247 activefontsettings.background = dblue;
03248 activefontsettings.height = textsizey / linesshown;
03249
03250 firstpict = NULL;
03251 }
03252
03253
03254 void thelpsystem::buttonpressed( int id )
03255 {
03256 tdialogbox::buttonpressed(id);
03257 if (id == 1)
03258 displaytext();
03259
03260 if ( id == 5 )
03261 action = 11;
03262 }
03263
03264
03265 void thelpsystem::run(void)
03266 {
03267 displaytext();
03268 do {
03269 tdialogbox::run();
03270 checkscrolling();
03271
03272 } while (action < 10);
03273 }
03274
03275
03276 void thelpsystem::done(void)
03277 {
03278 ppicture pic1;
03279
03280 tdialogbox::done();
03281 while (firstpict != NULL) {
03282 pic1 = firstpict;
03283 firstpict = firstpict->next;
03284 free ( pic1->pict );
03285 delete ( pic1 );
03286 }
03287 }
03288
03289
03290
03291
03292 void help( int id)
03293 {
03294 ASCString s = readtextmessage( id );
03295
03296 ViewFormattedText vft( "Help System", s, PG_Rect(-1,-1,450,550));
03297 vft.Show();
03298 vft.RunModal();
03299 }
03300
03301
03302 void viewtext2 ( int id)
03303 {
03304
03305 ASCString s = readtextmessage( id );
03306
03307 ViewFormattedText vft( "Message", s, PG_Rect(-1,-1,450,550));
03308 vft.Show();
03309 vft.RunModal();
03310 }
03311
03312
03313
03314
03315 class tviewtextquery : public thelpsystem {
03316 const char* st1;
03317 const char* st2;
03318 public:
03319 void init( int id, const char* titel, const char* s1, const char* s2);
03320 virtual void buttonpressed( int id);
03321 void setup( void );
03322 };
03323
03324
03325 void tviewtextquery::setup( void )
03326 {
03327
03328 if ( st2 ) {
03329 addbutton ( st1, 10, ysize - 30, xsize / 2 - 5, ysize - 10, 0, 1,11, 1 );
03330 addbutton ( st2, xsize / 2 + 5, ysize - 30, xsize - 10, ysize - 10, 0, 1,12, 1 );
03331 }
03332 else
03333 addbutton(st1,10, ysize - 30, xsize - 10, ysize - 10, 0, 1, 11, 1 );
03334
03335 }
03336
03337
03338 void tviewtextquery::init( int id, const char* titel, const char* s1, const char* s2 )
03339 {
03340 st1 = s1;
03341 st2 = s2;
03342
03343 thelpsystem::init(id,titel);
03344
03345 buildgraphics();
03346 }
03347
03348
03349 void tviewtextquery::buttonpressed( int id)
03350 {
03351 thelpsystem::buttonpressed(id);
03352 if (id == 12)
03353 action = 12;
03354 if (id == 11)
03355 action = 11;
03356 }
03357
03358
03359 int legacy_viewtextquery( int id,
03360 const char * title,
03361 const char * s1,
03362 const char * s2)
03363 {
03364 tviewtextquery vtq;
03365 char result;
03366
03367 vtq.init(id,title,s1,s2);
03368 vtq.run();
03369 result = vtq.action - 11;
03370 vtq.done();
03371 return result;
03372 }
03373
03374
03375 class ViewTextQuery : public ASC_PG_Dialog {
03376
03377 public:
03378 ViewTextQuery( int id, const ASCString& title, const ASCString& button1, const ASCString& button2 ) : ASC_PG_Dialog( NULL, PG_Rect(-1, -1, 450, 500 ), title )
03379 {
03380 PG_Rect r;
03381 if ( button2.length() ) {
03382 r = PG_Rect( 10, Height() - 40, Width()/2-15, 30 );
03383 PG_Button* b = new PG_Button( this, PG_Rect( Width()/2+5, Height() - 40, Width()/2-15, 30 ), button2 );
03384 b->sigClick.connect( SigC::bind( SigC::slot( *this, &ViewTextQuery::quitModalLoop ), 1));
03385 b->activateHotkey(0);
03386 } else
03387 r = PG_Rect( 10, Height() - 40, Width() - 20, 30 );
03388
03389
03390
03391 PG_Button* b = new PG_Button( this, r, button1 );
03392 b->sigClick.connect( SigC::bind( SigC::slot( *this, &ViewTextQuery::quitModalLoop ), 0));
03393 b->activateHotkey(0);
03394
03395 new TextRenderer( this, PG_Rect( 10, 30, Width()-20, Height() - 70 ), readtextmessage( id ));
03396 }
03397 };
03398
03399
03400 int viewtextquery( int id,
03401 const char * title,
03402 const char * s1,
03403 const char * s2)
03404 {
03405 if ( legacyEventSystemActive() )
03406 return legacy_viewtextquery( id, title, s1, s2 );
03407 else {
03408 ViewTextQuery vtq( id, title, s1, s2 );
03409 vtq.Show();
03410 return vtq.RunModal();
03411 }
03412 }
03413
03414
03415 tdisplaymessage* messagebox = NULL;
03416
03417
03418
03419
03420
03421 tstringselect :: tstringselect ( )
03422 {
03423 numberoflines = 0;
03424 firstvisibleline = 0;
03425 redline = 0;
03426 startpos = 0;
03427 }
03428
03429
03430 void tstringselect::init(void)
03431 {
03432 tdialogbox::init();
03433
03434 xsize = 570;
03435 ysize = 320;
03436 x1 = ( 640 -xsize ) / 2;
03437 y1 = ( 480 -ysize ) / 2;
03438
03439 sy = 45;
03440
03441 sx = 20;
03442 title = "Text-Box";
03443 windowstyle = windowstyle ^ dlg_in3d;
03444 lnshown = 10;
03445 ey = ysize - 50;
03446 ex = xsize - 30;
03447 setup();
03448
03449 if (startpos >= numberoflines ) startpos = numberoflines-1;
03450 if (startpos > lnshown -1 ) {
03451 firstvisibleline = startpos - ( lnshown - 1 );
03452 redline = startpos;
03453 } else {
03454 redline = startpos;
03455 }
03456
03457 dk = 0;
03458 action = 0;
03459 dx = (ey - sy) / lnshown;
03460 if (numberoflines > lnshown) {
03461 scrollbarvisible = true;
03462 addscrollbar(ex + 10 ,sy ,ex + 20,ey ,&numberoflines,lnshown,&firstvisibleline,1,0);
03463 }
03464 else scrollbarvisible = false;
03465 buildgraphics();
03466 rahmen(true,x1 + sx , y1 + sy,x1 + ex,y1 + ey);
03467 mousevisible(true);
03468 activefontsettings.font = schriften.smallarial;
03469 activefontsettings.color = black;
03470 activefontsettings.justify = lefttext;
03471 activefontsettings.background = lightgray;
03472 activefontsettings.height = 15;
03473 viewtext();
03474 }
03475
03476
03477 void tstringselect::setup(void)
03478 {
03479 }
03480
03481
03482 void tstringselect::buttonpressed(int id)
03483 {
03484 tdialogbox::buttonpressed(id);
03485 if (id == 1) {
03486 if (firstvisibleline > redline) redline = firstvisibleline;
03487 if (firstvisibleline + lnshown - 1 < redline) redline = firstvisibleline + lnshown - 1;
03488 viewtext();
03489 }
03490 }
03491
03492
03493 void tstringselect::run(void)
03494 {
03495 char view;
03496 int my;
03497 int ms;
03498
03499 tdialogbox::run();
03500 if (numberoflines > 0) {
03501 msel = 0;
03502 if (getmousestatus() == 2) {
03503 if ((( ms = mouseparams.taste ) == 0) && (dk == 1)) dk = 2;
03504 if ((mouseparams.x > x1 + 10) & (mouseparams.x < x1 + xsize - 40) && (ms != 0)) {
03505 my = mouseparams.y - y1 - sy;
03506 my = my / dx;
03507 if ((my >= 0) && (my <= lnshown - 1) && (my <= numberoflines - 1)) {
03508 mouseselect = firstvisibleline + my;
03509 if ((mouseselect == redline) && (dk == 2)) {
03510 msel = ms;
03511 dk = 0;
03512 }
03513 else {
03514 redline = mouseselect;
03515 dk = 1;
03516 ms =0;
03517 viewtext();
03518 }
03519 }
03520 }
03521 }
03522 switch (taste) {
03523
03524 case ct_up: {
03525 view = true;
03526 if (redline > 0) redline--;
03527 else view = false;
03528 if ((redline < firstvisibleline) && (firstvisibleline > 0)) {
03529 firstvisibleline--;
03530 showbutton( 1 );
03531 }
03532 if (view) viewtext();
03533 }
03534 break;
03535 case ct_pos1: {
03536 view = false;
03537 if ( (redline > 0) || (firstvisibleline > 0) ) {
03538 view = true;
03539 redline = 0;
03540 firstvisibleline = 0;
03541 }
03542 if (view) viewtext();
03543 }
03544 break;
03545
03546 case ct_ende: {
03547 view = false;
03548 if (redline < numberoflines -1 ) {
03549 view = true;
03550 redline = numberoflines -1 ;
03551 firstvisibleline = numberoflines - lnshown;
03552 }
03553 if (view) viewtext();
03554 }
03555 break;
03556
03557 case ct_down: {
03558 view = true;
03559 if (redline < numberoflines - 1) redline++;
03560 else view = false;
03561 if ((redline > firstvisibleline + lnshown - 1) && (firstvisibleline + lnshown - 1 <= numberoflines)) {
03562 firstvisibleline++;
03563 showbutton( 1 );
03564 }
03565 if (view) viewtext();
03566 }
03567 break;
03568 }
03569 }
03570 else redline = -1;
03571 }
03572
03573
03574 void tstringselect::resettextfield(void)
03575 {
03576 bar(x1 + sx,y1 + sy,x1 + ex,y1 + ey,lightgray);
03577 rahmen(true,x1 + sx ,y1 + sy,x1 + ex,y1 + ey);
03578 }
03579
03580 void tstringselect::get_text(int nr)
03581 {
03582 strcpy(txt,"");
03583 nr = 0;
03584 }
03585
03586 void tstringselect::scrollbar_on(void)
03587 {
03588 scrollbarvisible = true;
03589 addscrollbar(ex + 10 ,sy - 10,ex + 30,ey + 10,&numberoflines,lnshown,&firstvisibleline,1,0);
03590 }
03591
03592
03593 void tstringselect::viewtext(void)
03594 {
03595 char s1[200];
03596 Uint16 yp;
03597 int l;
03598
03599 mousevisible(false);
03600
03601 npush(activefontsettings.length);
03602 activefontsettings.length = ex - sx - 10;
03603 yp = y1 + sy + 5;
03604 l = firstvisibleline;
03605 if (numberoflines > 0) {
03606 while ((l<numberoflines) && (l-firstvisibleline < lnshown)) {
03607 get_text(l);
03608 strcpy(s1,txt);
03609 if (l == redline ) activefontsettings.color=red;
03610 else activefontsettings.color=lightblue;
03611 showtext2(s1,x1+ sx + 5,yp+( l-firstvisibleline ) * dx );
03612 l++;
03613 }
03614
03615 }
03616
03617
03618
03619 npop(activefontsettings.length);
03620 mousevisible(true);
03621 }
03622
03623
03624 void tstringselect::done(void)
03625 {
03626 tdialogbox::done();
03627 while ( mouseparams.taste )
03628 releasetimeslice();
03629 }
03630
03631
03632 class tgetid : public tdialogbox {
03633 public :
03634 tgetid () { onCancel = ReturnZero; };
03635 enum CancelMode { ReturnZero, ReturnOriginal } onCancel;
03636 int action;
03637 int mid;
03638 char nt[200];
03639 void init(void);
03640 int max,min;
03641 virtual void run(void);
03642 virtual void buttonpressed(int id);
03643 };
03644
03645 void tgetid::init(void)
03646 {
03647 tdialogbox::init();
03648 title = nt;
03649 x1 = 200;
03650 xsize = 220;
03651 y1 = 150;
03652 ysize = 140;
03653 action = 0;
03654
03655 if ((mid < min) || (mid > max)) mid = 42;
03656
03657 windowstyle = windowstyle ^ dlg_in3d;
03658
03659
03660 addbutton("~D~one",20,ysize - 40,100,ysize - 20,0,1,1,true);
03661 addkey(1,ct_enter);
03662 addbutton("~C~ancel",120,ysize - 40,200,ysize - 20,0,1,2,true);
03663 addbutton("",20,60,xsize - 20,80,2,1,3,true);
03664 addeingabe(3,&mid,min,max);
03665
03666 buildgraphics();
03667
03668 mousevisible(true);
03669 }
03670
03671
03672 void tgetid::run(void)
03673 {
03674 int orig = mid;
03675 tdialogbox::run ();
03676 pbutton pb = firstbutton;
03677 while ( pb && (pb->id != 3))
03678 pb = pb->next;
03679
03680 if ( pb )
03681 if ( pb->id == 3 )
03682 execbutton( pb , false );
03683
03684 do {
03685 tdialogbox::run();
03686 } while (!((taste == ct_esc) || ((action == 1) || (action == 2))));
03687 if ((action == 2) || (taste == ct_esc)){
03688 if ( onCancel == ReturnZero )
03689 mid = 0;
03690 else
03691 mid = orig;
03692 }
03693 }
03694
03695
03696 void tgetid::buttonpressed(int id)
03697 {
03698 tdialogbox::buttonpressed(id);
03699 switch (id) {
03700
03701 case 1:
03702 case 2: action = id;
03703 break;
03704 }
03705 }
03706
03707
03708 int getid( const char* title, int lval,int min,int max)
03709
03710 { tgetid gi;
03711 gi.onCancel = tgetid::ReturnOriginal;
03712
03713 strcpy( gi.nt, title );
03714 gi.max = max;
03715 gi.min = min;
03716 gi.mid = lval;
03717 gi.init();
03718 gi.run();
03719 gi.done();
03720 return gi.mid;
03721 }
03722
03723
03724 class ChooseString : public tstringselect {
03725 private:
03726 const vector<ASCString>& strings;
03727 const vector<ASCString>& buttons;
03728 char buf[10000];
03729 public :
03730 ChooseString ( const ASCString& _title, const vector<ASCString>& _strings , const vector<ASCString>& _buttons, int defaultEntry );
03731 void setup( );
03732 virtual void buttonpressed(int id);
03733 void run(void);
03734 virtual void get_text(int nr);
03735 };
03736
03737
03738
03739 ChooseString :: ChooseString ( const ASCString& _title, const vector<ASCString>& _strings, const vector<ASCString>& _buttons, int defaultEntry )
03740 : strings ( _strings ), buttons ( _buttons )
03741 {
03742 strcpy ( buf, _title.c_str() );
03743 startpos = defaultEntry;
03744 }
03745
03746
03747 void ChooseString ::setup( )
03748 {
03749 action = 0;
03750 title = buf;
03751 numberoflines = strings.size();
03752 ey = ysize - 50;
03753 if ( buttons.size() > 4 )
03754 xsize = 640;
03755 int width = (xsize-40)/buttons.size();
03756 for ( int i = 0; i< buttons.size(); ++i )
03757 addbutton( buttons[i].c_str(),25 + i*width,ysize - 45,15 + (i+1)*width,ysize - 20,0,1,20+i,true);
03758 }
03759
03760
03761 void ChooseString ::buttonpressed(int id)
03762 {
03763 tstringselect::buttonpressed(id);
03764 if ( id >= 20 )
03765 action =id ;
03766 }
03767
03768
03769 void ChooseString ::get_text(int nr)
03770 {
03771 strcpy ( txt, strings[nr].c_str());
03772 }
03773
03774
03775 void ChooseString ::run(void)
03776 {
03777 do {
03778 tstringselect::run();
03779
03780
03781
03782
03783
03784 } while ( action == 0 );
03785 }
03786
03787
03788
03789
03790
03791
03792
03793
03794
03795 int chooseString ( const ASCString& title, const vector<ASCString>& entries, int defaultEntry )
03796 {
03797 vector<ASCString> b;
03798 b.push_back ( "~O~K");
03799 return chooseString ( title, entries, b, defaultEntry).second;
03800 }
03801
03802
03803
03804
03805 pair<int,int> chooseString ( const ASCString& title, const vector<ASCString>& entries, const vector<ASCString>& buttons, int defaultEntry )
03806 {
03807
03808 if ( legacyEventSystemActive() ) {
03809 ChooseString gps ( title, entries, buttons, defaultEntry );
03810
03811 gps.init();
03812 gps.run();
03813 gps.done();
03814 return make_pair(gps.action-20,gps.redline);
03815 } else {
03816 return new_chooseString ( title, entries, buttons, defaultEntry );
03817 }
03818
03819
03820 }
03821
03822
03823
03824
03825
03826 class StringEdit : public tdialogbox {
03827 public :
03828 ASCString org;
03829 char nt[200];
03830 StringEdit () { onCancel = ReturnZero; };
03831 enum { ReturnZero, ReturnOriginal } onCancel;
03832 int action;
03833 int mid;
03834 char text[200];
03835 void init(void);
03836 int max,min;
03837 virtual void run(void);
03838 virtual void buttonpressed(int id);
03839 };
03840
03841 void StringEdit::init(void)
03842 {
03843 tdialogbox::init();
03844 strcpy ( text, org.c_str() );
03845 title = nt;
03846 x1 = 200;
03847 xsize = 220;
03848 y1 = 150;
03849 ysize = 140;
03850 action = 0;
03851
03852 windowstyle = windowstyle ^ dlg_in3d;
03853
03854
03855 addbutton("~D~one",20,ysize - 40,100,ysize - 20,0,1,1,true);
03856 addkey(1,ct_enter);
03857 addbutton("~C~ancel",120,ysize - 40,200,ysize - 20,0,1,2,true);
03858 addbutton("",20,60,xsize - 20,80,1,1,3,true);
03859 addeingabe(3,text,0,99);
03860
03861 buildgraphics();
03862
03863 mousevisible(true);
03864 }
03865
03866
03867 void StringEdit::run(void)
03868 {
03869 tdialogbox::run ();
03870 pbutton pb = firstbutton;
03871 while ( pb && (pb->id != 3))
03872 pb = pb->next;
03873
03874 if ( pb )
03875 if ( pb->id == 3 )
03876 execbutton( pb , false );
03877
03878 do {
03879 tdialogbox::run();
03880 } while (!((taste == ct_esc) || ((action == 1) || (action == 2))));
03881 if ((action == 2) || (taste == ct_esc)){
03882 if ( onCancel == ReturnZero )
03883 text[0] = 0;
03884 else
03885 strcpy( text, org.c_str() );
03886 }
03887 }
03888
03889
03890 void StringEdit::buttonpressed(int id)
03891 {
03892 tdialogbox::buttonpressed(id);
03893 switch (id) {
03894
03895 case 1:
03896 case 2: action = id;
03897 break;
03898 }
03899 }
03900
03901 ASCString editString( const ASCString& title, const ASCString& defaultValue )
03902 {
03903 StringEdit gi;
03904 gi.org = defaultValue;
03905 gi.onCancel = StringEdit::ReturnOriginal ;
03906
03907 strcpy( gi.nt, title.c_str() );
03908 gi.init();
03909 gi.run();
03910 gi.done();
03911 return gi.text;
03912 }
03913
03914
03915
03916
03917
03918 #if 0
03919
03920 class StringSelect : public tdialogbox {
03921 const vector<ASCString>& entries;
03922 const vector<ASCString>& buttons;
03923 ASCString myTitle;
03924 public :
03925 StringSelect( const ASCString& title, const vector<ASCString>& entries_, const vector<ASCString>& buttons_ );
03926 protected:
03927 char ok;
03928 int sy,ey,sx,ex,action,dx;
03929 int dk;
03930 int msel,mouseselect,redline,lnshown,numberoflines,firstvisibleline,startpos;
03931 char scrollbarvisible;
03932 void init(void);
03933 tstringselect ( );
03934 virtual void run(void);
03935 virtual void buttonpressed(int id);
03936 void scrollbar_on(void);
03937 void viewtext(void);
03938 virtual void resettextfield(void);
03939 virtual void get_text( Uint16 nr);
03940 void done(void);
03941 };
03942
03943
03944 StringSelect :: StringSelect( const ASCString& title, const vector<ASCString>& entries_, const vector<ASCString>& buttons_ )
03945 : entries( entries_ ), buttons ( buttons_ )
03946 {
03947 numberoflines = 0;
03948 firstvisibleline = 0;
03949 redline = 0;
03950 startpos = 0;
03951 myTitle = title;
03952 }
03953
03954
03955 void tstringselect::init(void)
03956 {
03957 tdialogbox::init();
03958
03959 xsize = 570;
03960 ysize = 320;
03961 x1 = ( 640 -xsize ) / 2;
03962 y1 = ( 480 -ysize ) / 2;
03963
03964 sy = 45;
03965
03966 sx = 20;
03967 title = myTitle.c_str();
03968 windowstyle = windowstyle ^ dlg_in3d;
03969 lnshown = 10;
03970 ey = ysize - 50;
03971 ex = xsize - 30;
03972 setup();
03973
03974 if (startpos >= numberoflines )
03975 startpos = numberoflines-1;
03976 if (startpos > lnshown -1 ) {
03977 firstvisibleline = startpos - ( lnshown - 1 );
03978 redline = startpos;
03979 } else {
03980 redline = startpos;
03981 }
03982
03983 dk = 0;
03984 action = 0;
03985 dx = (ey - sy) / lnshown;
03986 if (numberoflines > lnshown) {
03987 scrollbarvisible = true;
03988 addscrollbar(ex + 10 ,sy ,ex + 20,ey ,&numberoflines,lnshown,&firstvisibleline,1,0);
03989 }
03990 else
03991 scrollbarvisible = false;
03992 buildgraphics();
03993 rahmen(true,x1 + sx , y1 + sy,x1 + ex,y1 + ey);
03994 mousevisible(true);
03995 activefontsettings.font = schriften.smallarial;
03996 activefontsettings.color = black;
03997 activefontsettings.justify = lefttext;
03998 activefontsettings.background = lightgray;
03999 activefontsettings.height = 15;
04000 viewtext();
04001 }
04002
04003
04004
04005 void tstringselect::buttonpressed(int id)
04006 {
04007 tdialogbox::buttonpressed(id);
04008 if (id == 1) {
04009 if (firstvisibleline > redline) redline = firstvisibleline;
04010 if (firstvisibleline + lnshown - 1 < redline) redline = firstvisibleline + lnshown - 1;
04011 viewtext();
04012 }
04013 }
04014
04015
04016 void tstringselect::run(void)
04017 {
04018 char view;
04019 int my;
04020 int ms;
04021
04022 tdialogbox::run();
04023 if (numberoflines > 0) {
04024 msel = 0;
04025 if (getmousestatus() == 2) {
04026 if ((( ms = mouseparams.taste ) == 0) && (dk == 1)) dk = 2;
04027 if ((mouseparams.x > x1 + 10) & (mouseparams.x < x1 + xsize - 40) && (ms != 0)) {
04028 my = mouseparams.y - y1 - sy;
04029 my = my / dx;
04030 if ((my >= 0) && (my <= lnshown - 1) && (my <= numberoflines - 1)) {
04031 mouseselect = firstvisibleline + my;
04032 if ((mouseselect == redline) && (dk == 2)) {
04033 msel = ms;
04034 dk = 0;
04035 }
04036 else {
04037 redline = mouseselect;
04038 dk = 1;
04039 ms =0;
04040 viewtext();
04041 }
04042 }
04043 }
04044 }
04045 switch (taste) {
04046
04047 case ct_up: {
04048 view = true;
04049 if (redline > 0) redline--;
04050 else view = false;
04051 if ((redline < firstvisibleline) && (firstvisibleline > 0)) {
04052 firstvisibleline--;
04053 showbutton( 1 );
04054 }
04055 if (view) viewtext();
04056 }
04057 break;
04058 case ct_pos1: {
04059 view = false;
04060 if ( (redline > 0) || (firstvisibleline > 0) ) {
04061 view = true;
04062 redline = 0;
04063 firstvisibleline = 0;
04064 }
04065 if (view) viewtext();
04066 }
04067 break;
04068
04069 case ct_ende: {
04070 view = false;
04071 if (redline < numberoflines -1 ) {
04072 view = true;
04073 redline = numberoflines -1 ;
04074 firstvisibleline = numberoflines - lnshown;
04075 }
04076 if (view) viewtext();
04077 }
04078 break;
04079
04080 case ct_down: {
04081 view = true;
04082 if (redline < numberoflines - 1) redline++;
04083 else view = false;
04084 if ((redline > firstvisibleline + lnshown - 1) && (firstvisibleline + lnshown - 1 <= numberoflines)) {
04085 firstvisibleline++;
04086 showbutton( 1 );
04087 }
04088 if (view) viewtext();
04089 }
04090 break;
04091 }
04092 }
04093 else redline = -1;
04094 }
04095
04096
04097 void tstringselect::resettextfield(void)
04098 {
04099 bar(x1 + sx,y1 + sy,x1 + ex,y1 + ey,lightgray);
04100 rahmen(true,x1 + sx ,y1 + sy,x1 + ex,y1 + ey);
04101 }
04102
04103 void tstringselect::get_text(Uint16 nr)
04104 {
04105 strcpy(txt,"");
04106 nr = 0;
04107 }
04108
04109 void tstringselect::scrollbar_on(void)
04110 {
04111 scrollbarvisible = true;
04112 addscrollbar(ex + 10 ,sy - 10,ex + 30,ey + 10,&numberoflines,lnshown,&firstvisibleline,1,0);
04113 }
04114
04115
04116 void tstringselect::viewtext(void)
04117 {
04118 char s1[200];
04119 Uint16 yp;
04120 int l;
04121
04122 mousevisible(false);
04123
04124 npush(activefontsettings.length);
04125 activefontsettings.length = ex - sx - 10;
04126 yp = y1 + sy + 5;
04127 l = firstvisibleline;
04128 if (numberoflines > 0) {
04129 while ((l<numberoflines) && (l-firstvisibleline < lnshown)) {
04130 get_text(l);
04131 strcpy(s1,txt);
04132 if (l == redline ) activefontsettings.color=red;
04133 else activefontsettings.color=lightblue;
04134 showtext2(s1,x1+ sx + 5,yp+( l-firstvisibleline ) * dx );
04135 l++;
04136 }
04137
04138 }
04139
04140
04141
04142 npop(activefontsettings.length);
04143 mousevisible(true);
04144 }
04145
04146
04147 void tstringselect::done(void)
04148 {
04149 tdialogbox::done();
04150 while ( mouseparams.taste )
04151 releasetimeslice();
04152 }
04153 #endif