#include "Dialog.h" #include "Text.h" #include "Fenster.h" #include "Bildschirm.h" #include "AsynchronCall.h" #include "RenderThread.h" #include "AuswahlBox.h" #include "Schrift.h" #include "Knopf.h" using namespace Framework; // Inhalt der MultiplChoiceDialog Klasse aus Dialog.h MultiplChoiceDialog::MultiplChoiceDialog() : ReferenceCounter() { entrys = new RCArray(); ids = new Array(); } MultiplChoiceDialog::~MultiplChoiceDialog() { entrys->release(); ids->release(); } // Fügt eine Auswahlmöglichkeit hinzu void MultiplChoiceDialog::addChoice( const char *text, void *id ) { entrys->add( new Text( text ) ); ids->add( id ); } // Zeigt den dialog an und wartet auf benutzereingabe void *MultiplChoiceDialog::anzeigen( Schrift *zSchrift ) { void *result = 0; bool ex = 0; WNDCLASS wc = F_Normal( 0 ); wc.lpszClassName = "Dialog"; WFenster *f = new WFenster(); f->setVSchließAktion( [&ex]( void *p, void *o ) { ex = true; } ); f->setMausAktion( _ret1ME ); f->setTastaturAktion( _ret1TE ); f->erstellen( WS_OVERLAPPEDWINDOW, wc ); f->setSize( 200, 200 ); f->setPosition( Bildschirmmitte( (WFenster *)f->getThis() ) ); f->setVerschiebbar( 1 ); f->setAnzeigeModus( 1 ); Bildschirm *b = new Bildschirm2D( (WFenster *)f->getThis() ); f->setBildschirm( (Bildschirm *)b->getThis() ); b->update(); RenderTh *r = new RenderTh(); r->setBildschirm( (Bildschirm *)b->getThis() ); r->beginn(); AuswahlBox *ab = new AuswahlBox(); ab->setPosition( 10, 10 ); ab->setSize( 180, 20 ); ab->setHintergrundFarbe( 0xFF000000 ); ab->setRahmenBreite( 1 ); ab->setRahmenFarbe( 0xFFFFFFFF ); ab->setMaxAuskappHeight( 120 ); ab->setMausRahmenBreite( 1 ); ab->setMausRahmenFarbe( 0xFF005500 ); ab->setMausAlphaFeldFarbe( 0x00008700 ); ab->setMausAlphaFeldStrength( -8 ); ab->setAuswRahmenBreite( 1 ); ab->setAuswRahmenFarbe( 0xFF00FF00 ); ab->setAuswAlphaFeldFarbe( 0x0000FF00 ); ab->setAuswAlphaFeldStrength( -8 ); ab->setStyle( AuswahlBox::Style::Normal ); ab->setSchriftZ( (Schrift *)zSchrift->getThis() ); for( auto i = entrys->getIterator(); i; i++ ) ab->addEintrag( i->getText() ); ab->setMausEreignis( _ret1ME ); b->addMember( ab ); Knopf *ok = new Knopf(); ok->setStyle( Knopf::Style::Normal ); ok->setPosition( 50, 150 ); ok->setSize( 100, 20 ); ok->setSchriftZ( (Schrift *)zSchrift->getThis() ); ok->setText( "Ok" ); ok->setMausEreignis( [this, &ex, &result, ab]( void *p, void *o, MausEreignis me ) { if( me.id == ME_RLinks ) { result = ids->get( ab->getAuswahl() ); ex = true; } return 1; } ); b->addMember( ok ); MSG msg; while( GetMessage( &msg, NULL, 0, 0 ) > 0 && !ex ) { if( !ex ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } } r->beenden(); r->release(); b->release(); f->setBildschirm( 0 ); f->setAnzeigeModus( 0 ); f->zerstören(); f->release(); ok->release(); ab->release(); return result; }