KBlocksKeyboardPlayer::KBlocksKeyboardPlayer(KXmlGuiWindow *parent, string name, bool netMode) { mpGame = 0; mPauseFlag = false; mpKeyWindow = 0; mPlayerName = name; mNetMode = netMode; if (parent) { mpKeyShortcuts = parent->actionCollection(); } else { mpKeyWindow = new KXmlGuiWindow(); mpKeyWindow->setupGUI(); mpKeyWindow->setFixedWidth(192); mpKeyWindow->setFixedHeight(32); mpKeyWindow->show(); mpKeyShortcuts = mpKeyWindow->actionCollection(); } bindKeys(); mActionList.clear(); }
void initialize() { jobList = createList(); using_history(); bindKeys(); initSignals(jumpBack); }
Player::Player(const glm::vec3& position, float size) : Super() { delete _input; delete _physics; _input = new PlayerInput; _physics = new PhysicsComponent(new physics::SphereCollider(position, size)); bindKeys(); _render = new RenderComponent("assets/models/box.obj", "assets/textures/color.png"); setPosition(position); }
PDFWindow :: PDFWindow(const QString& filename, PDFViewerConfig& config, QWidget* parent) : Config(config), PDF(filename, config.initialDPI(), config.offsetBetweenPages(), config.hinting(), parent), QWidget(parent) { Layout.setContentsMargins(0, 0, 0, 0); Layout.addWidget(&PDF); setLayout(&Layout); bindKeys(); setFocus(Qt::OtherFocusReason); }
int main( int argc, char **argv ) { #ifdef __APPLE__ string macDir = get_mac_dir(); string configFile = macDir + "/../configuration.ini"; #else string configFile = "configuration.ini"; #endif load_configuration(configFile); SDL_Surface *surface; SDL_Event event; int videoFlags; videoFlags = SDL_OPENGL; // Enable OpenGL in SDL videoFlags |= SDL_GL_DOUBLEBUFFER; // Enable double buffering //videoFlags |= SDL_HWPALETTE; // Store the palette in hardware if ( displayFullscreen ) videoFlags |= SDL_FULLSCREEN; if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { fprintf( stderr, "Video initialization failed: %s\n", SDL_GetError( ) ); //Quit( 1 ); } if (hardwareCursor) SDL_ShowCursor(SDL_DISABLE); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); surface = SDL_SetVideoMode( displayWidth, displayHeight, displayBpp, videoFlags ); SDL_WM_SetCaption("Torque Tracer","icon"); bindKeys(); OpenGL_init(); #ifdef __APPLE__ string fontPath = macDir + "/Contents/Resources/Vera.ttf"; const char *fontFile = strdup(fontPath.c_str()); #else const char *fontFile = "Vera.ttf"; #endif load_font(fontFile, &font[0], 18); ////////////////////////////////////// // torque curve initial points - for debugging /*torqueCurve.push_back( vector2fSet(-0.7, -0.7) ); torqueCurve.push_back( vector2fSet(-0.7 + incrementX * 1, -0.7 + incrementY*2) ); torqueCurve.push_back( vector2fSet(-0.7 + incrementX * 2, -0.7 + incrementY*3) );*/ bool exitApplication = false; while ( true ) { if (exitApplication == true) break; SDL_PollEvent( &event ); SDL_PumpEvents(); sdl_mouseUpdate(); if (event.type == SDL_QUIT) exitApplication = true; //////////////////////////////////////////// // check keyboard keys unsigned char *keyState = (unsigned char *) SDL_GetKeyState(NULL); for ( unsigned int klv=0 ; klv<BUTTONS_KEYBOARD ; klv++) { if ( keyState[klv] && keyboardButtons[klv].pressedLf == false ) { keyboardButtons[klv].pressedLf = true; if (keyboardButtons[klv].action == ACTION_QUIT) exitApplication = true; if (keyboardButtons[klv].action == ACTION_TOGGLE_MODE) { if (inputMode == INPUT_MODE_RESIZE) inputMode = INPUT_MODE_DRAW; else if (inputMode == INPUT_MODE_DRAW) inputMode = INPUT_MODE_ENTER_TEXT; else if (inputMode == INPUT_MODE_ENTER_TEXT) inputMode = INPUT_MODE_RESIZE; //printf("toggle mode\n"); } if (keyboardButtons[klv].action == ACTION_TORQUE_ZOOM_IN) { if (incrementY < 6) incrementY *= 1.25; } if (keyboardButtons[klv].action == ACTION_TORQUE_ZOOM_OUT) { if (incrementY > 0.05) incrementY /= 1.25; } if (keyboardButtons[klv].action == ACTION_WRITE_FILE) { writeTorqueCurve(); } if (keyboardButtons[klv].action == ACTION_TOGGLE_TORQUE_UNITS) { if (torqueMode == TORQUEMODE_METRIC) torqueMode = TORQUEMODE_IMPERIAL; else torqueMode = TORQUEMODE_METRIC; } if (inputMode == INPUT_MODE_ENTER_TEXT) { // this covers numbers if ( SDLK_0 <= klv && klv <= SDLK_9 ) enteredText += klv ; if ( klv == SDLK_PERIOD) enteredText += "."; if ( klv == SDLK_n ) enteredText += "Nm @"; if ( klv == SDLK_f ) enteredText += "ft-lbs @"; if ( klv == SDLK_k ) enteredText += "kW @"; if ( klv == SDLK_h || klv == SDLK_b ) enteredText += "bhp @"; if ( klv == SDLK_BACKSPACE ) { // if you're backspacing over an @ sign, just clear the whole string to start over if (enteredText[enteredText.size()-1] == '@') enteredText.resize(0); if ( enteredText.size() > 0) enteredText.resize(enteredText.size()-1); } if ( klv == SDLK_RETURN ) { processEnteredText(); } } } else if (!keyState[klv] && keyboardButtons[klv].pressedLf == true) { keyboardButtons[klv].pressedLf = false; } } /////////////////////////////////////// // check mouse stuff for (unsigned int mlv=0 ; mlv<BUTTONS_MOUSE ; mlv++) { if ( inputMode == INPUT_MODE_DRAW) { if (mouseButtons[mlv].pressed && mouseButtons[mlv].pressedLf == false) { if ( mlv == 1) // left click { // no negative values please if (mousePos.a[0] > gridStartX && mousePos.a[1] > gridStartY) { insertPointInCurve(mousePos); } } else if ( mlv == 3) // right click { // erase on right-click ////////////////////////////////////////////// // this works //if (torqueCurve.size() > 0) // torqueCurve.pop_back(); ////////////////////////////////////////////// // but we should probably erase whatever were closest to if ( torqueCurve.size() == 0) { break; } if ( torqueCurve.size() == 1) { torqueCurve.pop_back(); } if (closestPointToMouse == torqueCurve.size()-1) { torqueCurve.pop_back(); break; } vector<c_vector2f>::iterator it; unsigned int index = 0; for ( it=torqueCurve.begin() ; it<torqueCurve.end()-1 ; it++ ) { if (index == closestPointToMouse) { torqueCurve.erase(it,it+1); break; } index++; } } } } else if (inputMode == INPUT_MODE_RESIZE) { if ( mouseButtons[mlv].pressed) // left click or right click { if ( (mousePos.a[0] > pictureL-0.1) && (mousePos.a[0] < pictureL+0.1) ) { pictureL = mousePos.a[0]; //printf("l-border\n"); } if ( (mousePos.a[0] > pictureR-0.1) && (mousePos.a[0] < pictureR+0.1) ) { pictureR = mousePos.a[0]; //printf("r-border\n"); } if ( (mousePos.a[1] > pictureT-0.1) && (mousePos.a[1] < pictureT+0.1) ) { pictureT = mousePos.a[1]; //printf("t-border\n"); } if ( (mousePos.a[1] > pictureB-0.1) && (mousePos.a[1] < pictureB+0.1) ) { pictureB = mousePos.a[1]; //printf("b-border\n"); } } } } // debug text for (unsigned int l=0 ; l<torqueCurve.size() ; l++ ) { //printf("(%f,%f)\n", torqueCurve[l].a[0], torqueCurve[l].a[1]); } //printf("\n"); OpenGL_render(); SDL_GL_SwapBuffers(); } printf("done.\n"); // reset resolution SDL_Quit(); ///////////////////////////////////// // every generation of windows gets // progressively lamer. xp requires // this to exit cleanly. // C'est la micro$oft #ifdef WIN32 FatalExit(666); #endif return 0; }
kdvi::kdvi( char *fname, QWidget *, const char *name ) : KTopLevelWidget( name ) { msg = NULL; ssmenu = NULL; hbl = NULL; prefs = NULL; keys = new KAccel(this); readConfig(); setMinimumSize( 400, 60 ); setCaption( kapp->getCaption() ); tipgroup = new QToolTipGroup( this, "TipGroup" ); connect( tipgroup, SIGNAL(showTip(const char *)), SLOT(showTip(const char *)) ); connect( tipgroup, SIGNAL(removeTip()), SLOT(removeTip()) ); // Create KPanner for toolBar2 and dviwindow kpan = new KPanner( this, "panner", KPanner::O_VERTICAL|KPanner::U_ABSOLUTE, 100); setView( kpan, TRUE ); setFrameBorderWidth( 4 ); kpan->setAbsSeparator( pannerValue ); connect( kpan, SIGNAL(positionChanged()), SLOT(pannerChanged()) ); // Create a dvi window dviwin = new dviWindow( basedpi, mfmode, paper, makepk, kpan->child1(), "dviWindow" ); connect( dviwin, SIGNAL(currentPage(int)), SLOT(setPage(int)) ); connect( dviwin, SIGNAL(shrinkChanged(int)), SLOT(shrinkChanged(int)) ); connect( dviwin, SIGNAL(fileChanged()), SLOT(fileChanged()) ); connect( dviwin, SIGNAL(statusChange(const char *)), SLOT(showTip(const char *)) ); connect( dviwin, SIGNAL(setPoint(QPoint)), SLOT(showPoint(QPoint)) ); // Create a menubar menuBar = NULL; makeMenuBar(); // Create toolbars toolBar = NULL; makeButtons(); makeToolBar2( kpan->child0() ); // Create a statusbar statusBar = NULL; makeStatusBar( i18n("No document") ); // Lay out widgets QBoxLayout *l; l = new QBoxLayout( kpan->child0(), QBoxLayout::LeftToRight ); l->addWidget( toolBar2 ); l->activate(); l = new QBoxLayout( kpan->child1(), QBoxLayout::LeftToRight ); l->addWidget( dviwin ); l->activate(); // Create RMB menu rmbmenu = new QPopupMenu; rmbmenu->setMouseTracking( TRUE ); rmbmenu->connectItem( rmbmenu->insertItem(i18n("Toggle Menubar")), this, SLOT(toggleShowMenubar()) ); rmbmenu->connectItem( rmbmenu->insertItem(i18n("Mark page")), marklist, SLOT(markSelected()) ); rmbmenu->connectItem( rmbmenu->insertItem(i18n("Redraw")), dviwin, SLOT(drawPage()) ); rmbmenu->connectItem( rmbmenu->insertItem(i18n("Preferences ...")), this, SLOT(optionsPreferences()) ); // Bind keys bindKeys(); updateMenuAccel(); // Drag and drop KDNDDropZone * dropZone = new KDNDDropZone( this , DndURL); connect( dropZone, SIGNAL( dropAction( KDNDDropZone *) ), SLOT( dropEvent( KDNDDropZone *) ) ); // Read config options applyPreferences(); selectSmall(); dviwin->installEventFilter( this ); message( "" ); openFile(QString(fname)); }