Ejemplo n.º 1
0
/*
 * DoDigit - process a digit typed in
 */
vi_rc DoDigit( void )
{
    vi_rc   rc;

    if( LastEvent == '0' && RepeatDigits == 0 ) {
        LeftTopPos.column = 0;
        GoToColumnOK( 1 );
        DCDisplayAllLines();
        return( ERR_NO_ERR );
    }

    if( RepeatDigits == MAX_REPEAT_STRING - 1 ) {
        DoneRepeat();
        return( ERR_REPEAT_STRING_TOO_LONG );
    }

    if( repeatWindow == NO_WINDOW && EditFlags.RepeatInfo ) {
        rc = NewWindow2( &repeatWindow, &repcntw_info );
        if( rc != ERR_NO_ERR ) {
            DoneRepeat();
            return( rc );
        }
        WindowTitle( repeatWindow, "Repeat Count" );
    }

    RepeatString[RepeatDigits++] = LastEvent;
    RepeatString[RepeatDigits] = 0;
    if( repeatWindow != NO_WINDOW ) {
        UpdateRepeatString( RepeatString );
    }
    return( GOT_A_DIGIT );

} /* DoDigit */
Ejemplo n.º 2
0
/*
 * ResizeWindow - give a window a new size
 */
vi_rc ResizeWindow( window_id wid, windim x1, windim y1, windim x2, windim y2, bool scrflag )
{
    window      *oldw;
//    int         bt, k;
//    char        *txt, *tptr;
//    char        *ot;
//    int         i, j;

    oldw = WINDOW_FROM_ID( wid );
    AccessWindow( oldw );

    if( !ValidDimension( x1, y1, x2, y2, oldw->has_border ) ) {
        ReleaseWindow( oldw );
        return( ERR_WIND_INVALID );
    }
    RestoreOverlap( wid, scrflag );

    AllocWindow( wid, x1, y1, x2, y2, oldw->has_border, oldw->has_gadgets, true,
            oldw->border_color1, oldw->border_color2, oldw->text_color, oldw->background_color );
    MarkOverlap( wid );

    /*
     * display the new text
     */
    ClearWindow( wid );
    if( oldw->title != NULL ) {
        WindowTitle( wid, oldw->title );
    } else {
        DrawBorder( wid );
    }
    DCResize( CurrentInfo );
    DCDisplayAllLines();
    DCUpdate();

    FreeWindow( oldw );
    ReleaseWindow( WINDOW_FROM_ID( wid ) );

    return( ERR_NO_ERR );

} /* ResizeWindow */
Ejemplo n.º 3
0
void CTaskDialog::LayoutWindow(void)
{
	// customize post-creation window styles

	EnableSystemClose(HasFlag(TDF_ALLOW_DIALOG_CANCELLATION));

	// create and position controls

	GenerateControlIDs();
	LayoutControls();
	SetFontControls();
	SetZOrderControls();

	// update various graphical items

	UpdateMainIcon(MainIcon());
	UpdateWindowTitle(WindowTitle());
	UpdateFooterIcon(FooterIcon());

	// set the keyboard focus to the default button
	// and select the default radio button

	SetControlFocus(config_.iDefaultButton);

	if (!HasFlag(TDF_NO_DEFAULT_RADIO_BUTTON) && config_.nDefaultRadioButton != 0)
		CheckDlgButton(config_.nDefaultRadioButton, BST_CHECKED);

	// position dialog

	if (HasFlag(TDF_POSITION_RELATIVE_TO_WINDOW))
		CenterWindow(Parent());
	else
		CenterWindow(::GetDesktopWindow());

	if (HasFlag(TDF_CALLBACK_TIMER))
		CreateCallbackTimer();

	Callback(TDN_DIALOG_CONSTRUCTED);
}
Ejemplo n.º 4
0
/*
 * ResizeWindow - give a window a new size
 */
vi_rc ResizeWindow( window_id wn, int x1, int y1, int x2, int y2, int scrflag )
{
    wind        *tmp, *w;
    int         bt, k;
//    char        *txt, *tptr;
//    char        *ot;
//    int         i, j;

    w = AccessWindow( wn );

    if( !ValidDimension( x1, y1, x2, y2, w->has_border ) ) {
        ReleaseWindow( w );
        return( ERR_WIND_INVALID );
    }

    tmp = AllocWindow( x1, y1, x2, y2, w->has_border, w->border_color1,
                       w->border_color2, w->text_color, w->background_color );
    tmp->id = wn;
    tmp->has_gadgets = w->has_gadgets;
    // txt = MemAlloc( w->width + 1 );
    // tptr = txt;

    RestoreOverlap( wn, scrflag );

    Windows[wn] = tmp;
    tmp->accessed = TRUE;
    ResetOverlap( tmp );
    MarkOverlap( wn );

    /*
     * display the new text
     */
    k = 1;
    bt = (int) w->has_border;
    ClearWindow( wn );
    if( w->title != NULL ) {
        WindowTitle( wn, w->title );
    } else {
        DrawBorder( wn );
    }
#if 0
    for( j = bt; j < w->height - bt; j++ ) {

        ot = &(w->text[(j * w->width) * sizeof( char_info )]);
        for( i = bt; i < w->width - bt; i++ ) {
            *txt++ = ot[i * sizeof( char_info )];
        }
        *txt = 0;
        DisplayLineInWindow( wn, k++, tptr );
        txt = tptr;
    }
#else
    DCResize( CurrentInfo );
    DCDisplayAllLines();
    DCUpdate();
#endif

    FreeWindow( w );

    ReleaseWindow( tmp );
    return( ERR_NO_ERR );

} /* ResizeWindow */
Ejemplo n.º 5
0
/*
 * SelectLineInFile - select a line in a given file
 */
vi_rc SelectLineInFile( selflinedata *sfd )
{
    int         i, winflag;
    int         leftcol = 0, key2;
    bool        done = FALSE, redraw = TRUE;
    bool        hiflag = FALSE, drawbord = FALSE;
    int         farx, text_lines;
    linenum     pagetop = 1, lln = 1;
    char        tmp[MAX_STR];
    hilst       *ptr;
    linenum     cln;
    linenum     endline;
    vi_rc       rc;
    vi_key      key;

    /*
     * create the window
     */
    cln = sfd->cln;
    endline = sfd->f->fcbs.tail->end_line;
    farx = sfd->wi->x2;
    if( sfd->show_lineno ) {
        farx++;
    }
    if( sfd->hilite != NULL ) {
        hiflag = TRUE;
    }
    rc = NewWindow2( &cWin, sfd->wi );
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }
    if( !sfd->is_menu ) {
        WindowAuxUpdate( cWin, WIND_INFO_HAS_SCROLL_GADGETS, TRUE );
        DrawBorder( cWin );
    }
    oWin = sfd->eiw;
    isMenu = sfd->is_menu;
    PushMouseEventHandler( SelectLineMouseHandler );
    KillCursor();
    text_lines = WindowAuxInfo( cWin, WIND_INFO_TEXT_LINES );
    sfd->sl = -1;
    if( sfd->title != NULL ) {
        WindowTitle( cWin, sfd->title );
    }
    pagetop = text_lines * (cln / text_lines);
    if( cln % text_lines != 0 ) {
        pagetop++;
    }
    key = 0;
    if( LastEvent == VI_KEY( MOUSEEVENT ) ) {
        DisplayMouse( TRUE );
    }

    /*
     * now, allow free scrolling and selection
     */
    while( !done ) {

        if( redraw ) {
            if( sfd->show_lineno ) {
                MySprintf(tmp, "%l/%l", cln, endline );
                i = sfd->wi->x2 - sfd->wi->x1;
                WindowBorderData( cWin, tmp, i - strlen( tmp ) );
                drawbord = TRUE;
            }
            if( hiflag ) {
                ptr = sfd->hilite;
                ptr += cln - 1;
                if( ptr->_char == (char)-1 ) {
                    if( cln > lln ) {
                        cln++;
                    } else if( cln < lln ) {
                        cln--;
                    }
                }
            }
            if( drawbord ) {
                DrawBorder( cWin );
            }
            displayGenericLines( sfd->f, pagetop, leftcol, cln, &(sfd->wi->hilight), sfd->hilite, sfd->vals, sfd->valoff );
        }
        lln = cln;
        redraw = TRUE;
        drawbord = FALSE;
        mouseLine = -1;
        rlMenu = FALSE;
        if( key == VI_KEY( MOUSEEVENT ) ) {
            DisplayMouse( TRUE );
        }
        key = GetNextEvent( TRUE );
        if( hiflag && ((key >= VI_KEY( ALT_A ) && key <= VI_KEY( ALT_Z )) ||
                       (key >='a' && key <= 'z') || (key >= 'A' && key <= 'Z') ||
                       (key >= '1' && key <= '9')) ) {
            i = 0;
            if( key >= VI_KEY( ALT_A ) && key <= VI_KEY( ALT_Z ) ) {
                key2 = key - VI_KEY( ALT_A ) + 'A';
            } else if( key >= 'a' && key <= 'z' ) {
                key2 = key - 'a' + 'A';
            } else {
                key2 = key;
            }
            ptr = sfd->hilite;
            while( ptr->_char != '\0' ) {
                if( toupper( ptr->_char ) == key2 ) {
                    cln = i + 1;
                    key = VI_KEY( ENTER );
                    break;
                }
                ++i;
                ++ptr;
            }
        }

        /*
         * check if a return-event has been selected
         */
        if( sfd->retevents != NULL ) {
            i = 0;
            if( key == VI_KEY( MOUSEEVENT ) ) {
                if( mouseWin == oWin && LastMouseEvent == MOUSE_PRESS ) {
                    DisplayMouse( FALSE );
                    sfd->event = sfd->retevents[mouseLine];
                    key = VI_KEY( ENTER );
                }
            } else {
                while( sfd->retevents[i] != 0 ) {
                    if( key == sfd->retevents[i] ) {
                        sfd->event = key;
                        key = VI_KEY( ENTER );
                        break;
                    }
                    i++;
                }
            }
        }

        /*
         * process key stroke
         */
        switch( key ) {
        case VI_KEY( MOUSEEVENT ):
            DisplayMouse( FALSE );
            if( hiflag ) {
                ptr = sfd->hilite;
                ptr += mouseLine;
                if( ptr->_char == (char) -1 ) {
                    break;
                }
            }
            if( rlMenu && sfd->allow_rl != NULL ) {
                *(sfd->allow_rl) = rlMenuNum;
                done = TRUE;
                break;
            }
            if( mouseScroll != MS_NONE ) {
                switch( mouseScroll ) {
                case MS_UP: goto evil_up;
                case MS_DOWN: goto evil_down;
                case MS_PAGEUP: goto evil_pageup;
                case MS_PAGEDOWN: goto evil_pagedown;
                case MS_EXPOSEDOWN:
                    adjustCLN( &cln, &pagetop, pagetop + text_lines - cln - 1, endline, text_lines );
                    adjustCLN( &cln, &pagetop, 1, endline, text_lines );
                    drawbord = TRUE;
                    break;
                case MS_EXPOSEUP:
                    adjustCLN( &cln, &pagetop, pagetop - cln, endline, text_lines );
                    adjustCLN( &cln, &pagetop, -1, endline, text_lines );
                    drawbord = TRUE;
                    break;

                }
                break;
            }
            switch( LastMouseEvent ) {
            case MOUSE_DRAG:
                if( mouseWin != cWin ) {
                    break;
                }
                cln = mouseLine + pagetop;
                break;
            case MOUSE_RELEASE:
                if( !sfd->is_menu ) {
                    break;
                }
                if( mouseWin == cWin ) {
                    cln = mouseLine + pagetop;
                    if( cln <= endline ) {
                        goto evil_enter;
                    }
                }
                break;
            case MOUSE_DCLICK:
                if( mouseWin != cWin ) {
                    AddCurrentMouseEvent();
                    done = TRUE;
                } else {
                    cln = mouseLine + pagetop;
                    if( cln <= endline ) {
                        goto evil_enter;
                    }
                }
                break;
            case MOUSE_PRESS_R:
                if( mouseWin != cWin ) {
                    AddCurrentMouseEvent();
                    done = TRUE;
                }
                break;
            case MOUSE_PRESS:
                if( mouseWin != cWin ) {
                    AddCurrentMouseEvent();
                    done = TRUE;
                } else {
                    cln = mouseLine + pagetop;
                }
                break;
            }
            break;

        case VI_KEY( ESC ):
            done = TRUE;
            break;

        evil_enter:
        case VI_KEY( ENTER ):
        case ' ':
            /*
             * see if we need to do a callback for this
             */
            if( sfd->checkres != NULL ) {
                line    *cline;
                fcb     *cfcb;
                char    data[64];

                i = cln - 1;
                GimmeLinePtr( cln, sfd->f, &cfcb, &cline );
                strcpy( data, cline->data );
                RemoveLeadingSpaces( data );
                winflag = FALSE;
                strcpy( tmp, sfd->vals[i] );
                rc = sfd->checkres( data, tmp, &winflag );
                if( winflag ) {
                    if( winflag == 2 ) {
                        winflag = TRUE;
                    } else {
                        winflag = FALSE;
                    }
                }
                if( winflag ) {
                    MoveWindowToFront( cWin );
                }
                if( rc == ERR_NO_ERR ) {
                    AddString2( &(sfd->vals[i]), tmp );
                    redraw = TRUE;
                }
                break;

            /*
             * no value window, so just return line selected
             */
            } else {
                if( isMenu && InvokeMenuHook( CurrentMenuNumber, cln ) == -1 ) {
                    break;
                }
                sfd->sl = cln;
                done = TRUE;
            }
            break;

        case VI_KEY( LEFT ):
        case 'h':
            if( sfd->allow_rl != NULL ) {
                *(sfd->allow_rl) = -1;
                done = TRUE;
            }
            break;

        case VI_KEY( RIGHT ):
        case 'l':
            if( sfd->allow_rl != NULL ) {
                *(sfd->allow_rl) = 1;
                done = TRUE;
            }
            break;

        evil_up:
        case VI_KEY( UP ):
        case 'k':
            drawbord = adjustCLN( &cln, &pagetop, -1, endline, text_lines );
            break;

        evil_down:
        case VI_KEY( DOWN ):
        case 'j':
            drawbord = adjustCLN( &cln, &pagetop, 1, endline, text_lines );
            break;

        case VI_KEY( CTRL_PAGEUP ):
            drawbord = adjustCLN( &cln, &pagetop, -cln + 1, endline, text_lines );
            break;

        case VI_KEY( CTRL_PAGEDOWN ):
            drawbord = adjustCLN( &cln, &pagetop, endline - cln, endline, text_lines );
            break;

        evil_pageup:
        case VI_KEY( PAGEUP ):
        case VI_KEY( CTRL_B ):
            drawbord = adjustCLN( &cln, &pagetop, -text_lines, endline, text_lines );
            break;

        evil_pagedown:
        case VI_KEY( PAGEDOWN ):
        case VI_KEY( CTRL_F ):
            drawbord = adjustCLN( &cln, &pagetop, text_lines, endline, text_lines );
            break;

        case VI_KEY( HOME ):
            drawbord = TRUE;
            cln = 1;
            pagetop = 1;
            break;

        case VI_KEY( END ):
            drawbord = TRUE;
            cln = endline;
            pagetop = endline - text_lines + 1;
            if( pagetop < 1 ) {
                pagetop = 1;
            }
            break;

        default:
            redraw = FALSE;
            break;

        }

    }
    PopMouseEventHandler();
    CloseAWindow( cWin );
    RestoreCursor();
    SetWindowCursor();
    return( rc );

} /* SelectLineInFile */
Ejemplo n.º 6
0
// Main - Set things up, call the pattern generator.
int main (void) {

  int i;

  // Reserve the pixel data memory.
  galaxyData_t galaxy;                // Contains an array of pointers to pixels.
  color_t actualPixels[PIXEL_COUNT];  // Sets aside memory for the actual pixels.

  galaxy.size = PIXEL_COUNT;

  // Map the array of pointers to the actual pixel memory.
  for (i = 0; i < PIXEL_COUNT; i++) {
    galaxy.pixels[i] = &actualPixels[i];
  }

  // Seed the pseudorandom number generator.
  srand(25);

  // Initialize the PIC hardware
  HardwareInit();

  // Initialize the emulator hardware.
#ifdef EMULATE
  // Init the display window.
  // SDL, Simple DirectMedia Layer, is a library for access to the keyboard,
  // and graphics hardware.  See www.libsdl.org  
  if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO|SDL_INIT_TIMER) < 0) {
    fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
    exit(EXIT_FAILURE);
  } else {
    // Register an exit callback to cleanup SDL.
    atexit(SDL_Quit);
  }

   // Initialize the SDL surfaces.
  SDL_CreateWindowAndRenderer(INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT,
                              SDL_WINDOW_RESIZABLE, &sdlWindow, &sdlRenderer);
  if ((sdlWindow == NULL) || (sdlRenderer == NULL)) {
    fprintf(stderr, "Unable to create SDL window or renderer! %s\n", SDL_GetError());
    exit(EXIT_FAILURE);
  }

  // Set the window title
  WindowTitle(delayMultiplier);

  // Clear the window to black.
  SDL_SetRenderDrawColor(sdlRenderer, 0, 0, 0, 255);
  SDL_RenderClear(sdlRenderer);
  SDL_RenderPresent(sdlRenderer);

  // Generate the output pixel map
  GeneratePixelMap(INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT);

  // Print version information.
  if (strlen(PRERELEASE_VERSION) == 0) {
    printf("Galaxy Emulator v%s.%s.%s\n", MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION);
  } else {
    printf("Galaxy Emulator v%s.%s.%s-%s\n", MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION, PRERELEASE_VERSION);
  }
  printf("Keys: ESC, <ctrl> c, q - Quit\n");
  printf("      +                - Increase emulation speed\n");
  printf("      -                - Decrease emulation speed\n");
  printf("      0                - Set emulation speed to 100%%\n");
  printf("      p                - Pause / unpause the simulation\n");
  printf("      SPACE            - Go to another pattern\n");
  printf("The emulator window must have focus for the key presses to work.\n");
#endif

  // Hand off control to the pattern generator.
  GeneratePattern(&galaxy);

  // We can only get this far on the emulator.
  exit(EXIT_SUCCESS);  // Required on the emu target for SDL cleanup.
  return(0);  // Never happens.
}
Ejemplo n.º 7
0
// Handle messages from the SDL framework for keyboard and window events.
command_e HandleEvents(void) {
  
  // Vars
  SDL_Event event;
  command_e returnValue = DONOTHING;

  // Events that occured in SDL (button pushes, window resize, etc) are stored
  // in a queue as they happen.  SDL_PollEvent grabs the first event off the
  // front of the line and stored it in the provided location (&event).  When
  // there are no events left in the queue, SDL_PollEvent returns FALSE and the
  // while block is skipped.
  while (SDL_PollEvent(&event)) {

    // Process according to the type of event that occured.
    switch(event.type) {

      // A keyboard button was pushed...
      case SDL_KEYDOWN:
        // printf("Key: %i \n", (int)event.key.keysym.sym );

        // <ctrl> c, and ESC keys exit the program.
        if (((event.key.keysym.mod & KMOD_CTRL) && (event.key.keysym.sym == SDLK_c)) ||  // <ctrl> c
            (event.key.keysym.sym == SDLK_ESCAPE) ||   // ESC
            (event.key.keysym.sym == SDLK_q)) {
          returnValue = DOEXIT;
        }

        // + key increases emulation speed by decreasing delay multiplier.
        if ((event.key.keysym.sym == SDLK_EQUALS) ||
            (event.key.keysym.sym == SDLK_PLUS) ||
            (event.key.keysym.sym == SDLK_KP_PLUS)) {
          delayMultiplier --;
          if (delayMultiplier < 0) {
            delayMultiplier = 0;
          }
          WindowTitle(delayMultiplier);
          // printf("Delay Multiplier: %f\n", delayMultiplier / 10.0);
        }

        // - key decreases emulation speed by increasing delay multiplier.
        if ((event.key.keysym.sym == SDLK_MINUS) ||
            (event.key.keysym.sym == SDLK_KP_MINUS)) {
          delayMultiplier ++;
          if (delayMultiplier > 100) {
            delayMultiplier = 100;
          }
          WindowTitle(delayMultiplier);
          // printf("Delay Multiplier: %4.1f\n", delayMultiplier / 10.0);
        }

        // 0 key reset emulation speed to 1.
        if ((event.key.keysym.sym == SDLK_0) ||
            (event.key.keysym.sym == SDLK_KP_0)) {
          delayMultiplier = 10;
          WindowTitle(delayMultiplier);
          // printf("Delay Multiplier: %4.1f\n", delayMultiplier / 10.0);
        }

        // Space goes to next pattern.
        if (event.key.keysym.sym == SDLK_SPACE) {
          returnValue = DONEXTPATTERN;
        }

        // p pauses the simulation.
        if (event.key.keysym.sym == SDLK_p) {
          returnValue = DOPAUSE;
        }
        
        break;
        
      // Someone closed the window, pressed <ctrl c> in the terminal, or killed the process.
      case SDL_QUIT:
        returnValue = DOEXIT;
        break;

      // Some other thing happened to the window.
      case SDL_WINDOWEVENT:
        
        // We only care about resize events.
        if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
          // printf("Resize to: %i, %i\n", event.window.data1, event.window.data2);
          GeneratePixelMap(event.window.data1, event.window.data2);
        }
        break;

      default:
        break;
    } // End event type switch
  } // End event polling loop.
  return (returnValue);
} // End HandleEvents()
Ejemplo n.º 8
0
// Pattern generation.
void GeneratePattern(galaxyData_t *galaxy) {
  
  // Vars
  int pattern = 0;
  int initial = TRUE;
  outputMapping_e currentOutputMap = MAP_FULL;
  long int timer = 0;
#ifdef EMULATE
  unsigned char pause = FALSE;
#endif /* EMULATE */

  // Set the initial pixel state to all black.
  ColorAll(galaxy, PIXEL_BLACK);

  // Run the pattern loop.
  FOREVER {

#ifdef EMULATE
    // Handle keyboard and window events.
    switch(HandleEvents()) {
      case DOEXIT:
        return;  // Return to the main function for exit.
      case DONEXTPATTERN:
        // Pick a new pattern.
        pattern = rand() % PATTERN_COUNT;
        initial = TRUE;
        timer = 0;
        // printf("Pattern: %i\n", pattern);
        break;
      case DOPAUSE:
        pause = pause ? FALSE : TRUE;
        WindowTitle(pause ? 1000000 : delayMultiplier);  // Kludge
        break;
      case DONOTHING:
      default:
        break;
    }

    // Write to the emulator output.
    UpdateEmuOutput(galaxy, currentOutputMap);

    // If paused, restart (continue) the FOREVER loop without further processing.
    if (pause) continue; 

#else /* EMULATE */
    
    // Write to the serial port.
    WriteLights(galaxy, currentOutputMap);

#endif /* EMULATE */

    // Run the selected pattern from the patternFunctions array.
    patternList[pattern].patternFunction(galaxy, initial, &currentOutputMap);

    // Set for the first pass when a new pattern is chosen, but can be unset now.
    initial = FALSE;  

    // Have we run the pattern long enough?
    timer++;
    if (timer >= patternList[pattern].iterations) {
      // Timer expired.  Choose a new pattern and set the initial flag.
      pattern = rand() % PATTERN_COUNT;
      initial = TRUE;
      timer = 0;
    }
  } // End of FOREVER Loop
} // End GeneratePattern()
Ejemplo n.º 9
0
void CApplication::OpenWindow(size_t iWidth, size_t iHeight, bool bFullscreen, bool bResizeable)
{
	glfwInit();

	m_bFullscreen = bFullscreen;

	if (HasCommandLineSwitch("--fullscreen"))
		m_bFullscreen = true;

	if (HasCommandLineSwitch("--windowed"))
		m_bFullscreen = false;

	m_iWindowWidth = iWidth;
	m_iWindowHeight = iHeight;

    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 0);
    glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE);

	glfwOpenWindowHint(GLFW_WINDOW_RESIZABLE, bResizeable?GL_TRUE:GL_FALSE);

	if (m_bMultisampling)
		glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);

	if (HasCommandLineSwitch("--debug-gl"))
	{
		glfwOpenWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);

		if (!glDebugMessageCallbackARB)
			TMsg("Your drivers do not support GL_ARB_debug_output, so no GL debug output will be shown.\n");
	}

	glfwOpenWindowHint(GLFW_DEPTH_BITS, 16);
	glfwOpenWindowHint(GLFW_RED_BITS, 8);
	glfwOpenWindowHint(GLFW_GREEN_BITS, 8);
	glfwOpenWindowHint(GLFW_BLUE_BITS, 8);
	glfwOpenWindowHint(GLFW_ALPHA_BITS, 8);

	TMsg(sprintf(tstring("Opening %dx%d %s %s window.\n"), iWidth, iHeight, bFullscreen?"fullscreen":"windowed", bResizeable?"resizeable":"fixed-size"));

	if (!(m_pWindow = (size_t)glfwOpenWindow(iWidth, iHeight, m_bFullscreen?GLFW_FULLSCREEN:GLFW_WINDOWED, WindowTitle().c_str(), NULL)))
	{
		glfwTerminate();
		return;
	}

	int iScreenWidth;
	int iScreenHeight;

	GetScreenSize(iScreenWidth, iScreenHeight);

	if (!m_bFullscreen)
	{
		// The taskbar is at the bottom of the screen. Pretend the screen is smaller so the window doesn't clip down into it.
		// Also the window's title bar at the top takes up space.
		iScreenHeight -= 70;

		int iWindowX = (int)(iScreenWidth/2-m_iWindowWidth/2);
		int iWindowY = (int)(iScreenHeight/2-m_iWindowHeight/2);
		glfwSetWindowPos((GLFWwindow)m_pWindow, iWindowX, iWindowY);
	}

	glfwSetWindowCloseCallback(&CApplication::WindowCloseCallback);
	glfwSetWindowSizeCallback(&CApplication::WindowResizeCallback);
	glfwSetKeyCallback(&CApplication::KeyEventCallback);
	glfwSetCharCallback(&CApplication::CharEventCallback);
	glfwSetMousePosCallback(&CApplication::MouseMotionCallback);
	glfwSetMouseButtonCallback(&CApplication::MouseInputCallback);
	glfwSetScrollCallback(&CApplication::MouseWheelCallback);
	glfwSwapInterval( 1 );
	glfwSetTime( 0.0 );

	InitJoystickInput();

	SetMouseCursorEnabled(true);

	GLenum err = gl3wInit();
	if (0 != err)
		exit(0);

	DumpGLInfo();

	if (glDebugMessageCallbackARB)
	{
		glDebugMessageCallbackARB(GLDebugCallback, nullptr);

		tstring sMessage("OpenGL Debug Output Activated");
		glDebugMessageInsertARB(GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, 0, GL_DEBUG_SEVERITY_LOW_ARB, sMessage.length(), sMessage.c_str());
	}

	glEnable(GL_CULL_FACE);
	glEnable(GL_DEPTH_TEST);
	glLineWidth(1.0);

	m_bIsOpen = true;

	m_pRenderer = CreateRenderer();
	m_pRenderer->Initialize();

	glgui::RootPanel()->SetSize((float)m_iWindowWidth, (float)m_iWindowHeight);
}
Ejemplo n.º 10
0
QString MenuCommands::Get(int ind, What w) const
{
    int cur = 0;

    if (cur++ == ind)
        return (w == Key ? FileKey() : (w == Title? FileTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? NewWinKey() : (w == Title? NewWinTitle() : GetStr(NewWinShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenFileKey() : (w == Title? OpenFileTitle() : GetStr(OpenFileShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenLocKey() : (w == Title? OpenLocTitle() : GetStr(OpenLocShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SaveAsKey() : (w == Title? SaveAsTitle() : GetStr(SaveAsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SavePdfKey() : (w == Title? SavePdfTitle() : GetStr(SavePdfShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportKey() : (w == Title? ImportTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? ImportIEKey() : (w == Title? ImportIETitle() : GetStr(ImportIEShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportFFKey() : (w == Title? ImportFFTitle() : GetStr(ImportFFShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportHtmlKey() : (w == Title? ImportHtmlTitle() : GetStr(ImportHtmlShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportXmlKey() : (w == Title? ImportXmlTitle() : GetStr(ImportXmlShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ExportKey() : (w == Title? ExportTitle() : GetStr(ExportShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrintKey() : (w == Title? PrintTitle() : GetStr(PrintShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PreviewKey() : (w == Title? PreviewTitle() : GetStr(PreviewShortcuts())));

    if (cur++ == ind)
        return (w == Key ? QuitKey() : (w == Title? QuitTitle() : GetStr(QuitShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EditKey() : (w == Title? EditTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? UndoKey() : (w == Title? UndoTitle() : GetStr(UndoShortcuts())));

    if (cur++ == ind)
        return (w == Key ? RedoKey() : (w == Title? RedoTitle() : GetStr(RedoShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CutKey() : (w == Title? CutTitle() : GetStr(CutShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CopyKey() : (w == Title? CopyTitle() : GetStr(CopyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PasteKey() : (w == Title? PasteTitle() : GetStr(PasteShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FindKey() : (w == Title? FindTitle() : GetStr(FindShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NextKey() : (w == Title? NextTitle() : GetStr(NextShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrevKey() : (w == Title? PrevTitle() : GetStr(PrevShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrefsKey() : (w == Title? PrefsTitle() : GetStr(PrefsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ViewKey() : (w == Title? ViewTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? AppStylesKey() : (w == Title? AppStylesTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? StatusKey() : (w == Title? StatusTitle() : GetStr(StatusShortcuts())));

    if (cur++ == ind)
        return (w == Key ? MenuKey() : (w == Title? MenuTitle() : GetStr(MenuShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TabKey() : (w == Title? TabTitle() : GetStr(TabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NavKey() : (w == Title? NavTitle() : GetStr(NavShortcuts())));

    if (cur++ == ind)
        return (w == Key ? BooksKey() : (w == Title? BooksTitle() : GetStr(BooksShortcuts())));

//  if (cur++ == ind)
//      return (w == Key ? Key() : (w == Title? Title() : GetStr(Shortcuts())));

    if (cur++ == ind)
        return (w == Key ? StopKey() : (w == Title? StopTitle() : GetStr(StopShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadKey() : (w == Title? ReloadTitle() : GetStr(ReloadShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LargerKey() : (w == Title? LargerTitle() : GetStr(LargerShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NormalKey() : (w == Title? NormalTitle() : GetStr(NormalShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SmallerKey() : (w == Title? SmallerTitle() : GetStr(SmallerShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TextOnlyKey() : (w == Title? TextOnlyTitle() : GetStr(TextOnlyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EncodeKey() : (w == Title? EncodeTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? SourceKey() : (w == Title? SourceTitle() : GetStr(SourceShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FullKey() : (w == Title? FullTitle() : GetStr(FullShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HistoryKey() : (w == Title? HistoryTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? BackKey() : (w == Title? BackTitle() : GetStr(BackShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ForwKey() : (w == Title? ForwTitle() : GetStr(ForwShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HomeKey() : (w == Title? HomeTitle() : GetStr(HomeShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LastTabKey() : (w == Title? LastTabTitle() : GetStr(LastTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LastTabsKey() : (w == Title? LastTabsTitle() : GetStr(LastTabsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SessionKey() : (w == Title? SessionTitle() : GetStr(SessionShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AllHistKey() : (w == Title? AllHistTitle() : GetStr(AllHistShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ClearKey() : (w == Title? ClearTitle() : GetStr(ClearShortcuts())));

    if (cur++ == ind)
        return (w == Key ? BookmarksKey() : (w == Title? BookmarksTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? AllBooksKey() : (w == Title? AllBooksTitle() : GetStr(AllBooksShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AddBookKey() : (w == Title? AddBookTitle() : GetStr(AddBookShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PrivacyKey() : (w == Title? PrivacyTitle() : ""));
    
    if (cur++ == ind)
        return (w == Key ? PrivateKey() : (w == Title? PrivateTitle() : GetStr(PrivateShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? JavaScriptKey() : (w == Title? JavaScriptTitle() : GetStr(JavaScriptShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? ImagesKey() : (w == Title? ImagesTitle() : GetStr(ImagesShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? CookiesKey() : (w == Title? CookiesTitle() : GetStr(CookiesShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PlugInsKey() : (w == Title? PlugInsTitle() : GetStr(PlugInsShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? AgentKey() : (w == Title? AgentTitle() : GetStr(AgentShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PopUpsKey() : (w == Title? PopUpsTitle() : GetStr(PopUpsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ProxyKey() : (w == Title? ProxyTitle() : GetStr(ProxyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EmptyKey() : (w == Title? EmptyTitle() : GetStr(EmptyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ResetKey() : (w == Title? ResetTitle() : GetStr(ResetShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FullResetKey() : (w == Title? FullResetTitle() : GetStr(FullResetShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ToolsKey() : (w == Title? ToolsTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? CompatKey() : (w == Title? CompatTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? SearchKey() : (w == Title? SearchTitle() : GetStr(SearchShortcuts())));

    if (cur++ == ind)
        return (w == Key ? KeyboardKey() : (w == Title? KeyboardTitle() : GetStr(KeyboardShortcuts())));

    if (cur++ == ind)
        return (w == Key ? InspectorKey() : (w == Title? InspectorTitle() : GetStr(InspectorShortcuts())));

    if (cur++ == ind)
        return (w == Key ? InspectKey() : (w == Title? InspectTitle() : GetStr(InspectShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OptionsKey() : (w == Title? OptionsTitle() : GetStr(OptionsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? WindowKey() : (w == Title? WindowTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? NextTabKey() : (w == Title? NextTabTitle() : GetStr(NextTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrevTabKey() : (w == Title? PrevTabTitle() : GetStr(PrevTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NewTabKey() : (w == Title? NewTabTitle() : GetStr(NewTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloseTabKey() : (w == Title? CloseTabTitle() : GetStr(CloseTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloseOtherKey() : (w == Title? CloseOtherTitle() : GetStr(CloseOtherShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloneTabKey() : (w == Title? CloneTabTitle() : GetStr(CloneTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadTabKey() : (w == Title? ReloadTabTitle() : GetStr(ReloadTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadAllKey() : (w == Title? ReloadAllTitle() : GetStr(ReloadAllShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenNewTabKey() : (w == Title? OpenNewTabTitle() : GetStr(OpenNewTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenAdBlockKey() : (w == Title? OpenAdBlockTitle() : GetStr(OpenAdBlockShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SwapFocusKey() : (w == Title? SwapFocusTitle() : GetStr(SwapFocusShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CopyAddrKey() : (w == Title? CopyAddrTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? DownsKey() : (w == Title? DownsTitle() : GetStr(DownsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TorrentsKey() : (w == Title? TorrentsTitle() : GetStr(TorrentsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HelpKey() : (w == Title? HelpTitle() : GetStr(HelpShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OnlineKey() : (w == Title? OnlineTitle() : GetStr(OnlineShortcuts())));

    if (cur++ == ind)
        return (w == Key ? UpdatesKey() : (w == Title? UpdatesTitle() : GetStr(UpdatesShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AboutKey() : (w == Title? AboutTitle() : GetStr(AboutShortcuts())));

    return "";
}
Ejemplo n.º 11
0
/*
 * doGREP - perform GREP on a specified file
 */
static vi_rc doGREP( char *dirlist )
{
    int         i, clist, n = 0;
    window_id   wn, optwin;
    char        **list;
    window_info tw, wi;
    vi_key      evlist[4] = { VI_KEY( F1 ), VI_KEY( F2 ), VI_KEY( F3 ), VI_KEY( DUMMY ) };
    int         s, e, cnt;
    bool        show_lineno;
    selectitem  si;
    vi_rc       rc;

    /*
     * prepare list array
     */
    list = (char **) MemAlloc( sizeof( char *) * MAX_FILES );

    /*
     * create info. window
     */
    rc = NewWindow( &wn, dirw_info.x1, dirw_info.y1 + 4, dirw_info.x2,
        dirw_info.y1 + 6, 1, dirw_info.border_color1, dirw_info.border_color2,
        &dirw_info.text );
    if( rc != ERR_NO_ERR ) {
        MemFree( list );
        return( rc );
    }
    WindowTitle( wn, "File Being Searched" );


    clist = initList( wn, dirlist, list );
    /*
     * got list of matches, so lets select an item, shall we?
     */
    CloseAWindow( wn );
    rc = ERR_NO_ERR;
    if( clist ) {

        /*
         * define display window dimensions
         */
        memcpy( &tw, &dirw_info, sizeof( window_info ) );
        tw.x1 = 14;
        tw.x2 = EditVars.WindMaxWidth - 2;
        i = tw.y2 - tw.y1 + 1;
        if( tw.has_border ) {
            i -= 2;
        }
        if( clist < i ) {
            tw.y2 -= ( i - clist );
        }
        if( clist > i ) {
            show_lineno = TRUE;
        } else {
            show_lineno = FALSE;
        }

        /*
         * build options window
         */
        memcpy( &wi, &extraw_info, sizeof( window_info ) );
        wi.x1 = 0;
        wi.x2 = 13;
        rc = DisplayExtraInfo( &wi, &optwin, EditOpts, NumEditOpts );
        if( rc != ERR_NO_ERR ) {
            return( rc );
        }

        /*
         * process selections
         */
        for( ;; ) {

            if( n + 1 > clist ) {
                n = clist - 1;
            }
            memset( &si, 0, sizeof( si ) );
            si.wi = &tw;
            si.title = "Files With Matches";
            si.list = list;
            si.maxlist = clist;
            si.num = n;
            si.retevents = evlist;
            si.event = VI_KEY( DUMMY );
            si.show_lineno = show_lineno;
            si.cln = n + 1;
            si.eiw = optwin;

            rc = SelectItem( &si );
            n = si.num;

            if( rc != ERR_NO_ERR || n < 0 ) {
                break;
            }
            if( si.event == VI_KEY( F3 ) ) {
                s = 0;
                e = clist - 1;
            } else {
                s = e = n;
            }
            for( cnt = s; cnt <= e; cnt++ ) {
                rc = getFile( list[cnt] );
                if( rc != ERR_NO_ERR ) {
                    break;
                }
            }
            if( rc != ERR_NO_ERR || si.event == VI_KEY( DUMMY ) ||
                si.event == VI_KEY( F1 ) || si.event == VI_KEY( F3 ) ) {
                break;
            }
            MemFree( list[n] );
            for( i = n; i < clist - 1; i++ ) {
                list[i] = list[i + 1];
            }
            clist--;
            if( clist == 0 ) {
                break;
            }
            MoveWindowToFrontDammit( optwin, FALSE );
        }
        CloseAWindow( optwin );

    } else if( rc == ERR_NO_ERR ) {
        Message1( "String \"%s\" not found", sString );
        rc = DO_NOT_CLEAR_MESSAGE_WINDOW;
    }

    /*
     * cleanup
     */
    MemFreeList( clist, list );
    return( rc );

} /* DoFGREP */