Пример #1
0
void MYMENU_FileSaveAs()
{
    OPENFILENAMEA ofn;
    ZeroMemory( &ofn, sizeof( ofn ) );
    
    ofn.lStructSize = sizeof( ofn ); // SEE NOTE BELOW
    ofn.hwndOwner = hwnd;
    ofn.lpstrFilter = "CSV Files (*.csv)\0*.csv\0Kiss Files (*.kiss)\0*.kiss\0All Files (*.*)\0*.*\0";
    ofn.lpstrFile = szFileName;
    ofn.nMaxFile = MAX_PATH;
    ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
    ofn.lpstrDefExt = "csv";
    
    if ( GetSaveFileName( &ofn ) ) {
        // out
        FILE* out = fopen( szFileName, "w" );
        if ( out != NULL ) {
            if ( strncmp( ofn.lpstrFile + ofn.nFileExtension, "csv", 3 ) == 0 )
                export_csv( out, table );
            else if ( strncmp( ofn.lpstrFile + ofn.nFileExtension, "kiss", 4 ) == 0 )
                export_kiss( out, table );
            fclose( out );
            set_caption( szFileName );
            unsaved = 0;
        }
    }
}
Пример #2
0
void MYMENU_FileOpen()
{
    OPENFILENAMEA ofn;
    ZeroMemory( &ofn, sizeof( ofn ) );
    
    ofn.lStructSize = sizeof( ofn ); // SEE NOTE BELOW
    ofn.hwndOwner = hwnd;
    ofn.lpstrFilter = "CSV Files (*.csv)\0*.csv\0Kiss Files (*.kiss)\0*.kiss\0All Files (*.*)\0*.*\0";
    ofn.lpstrFile = szFileName;
    ofn.nMaxFile = MAX_PATH;
    ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
    ofn.lpstrDefExt = "csv";
    
    if ( GetOpenFileName( &ofn ) ) {
        if ( prompt_save_changes() ) {
            FILE* fp = fopen( szFileName, "r" );
            if ( fp == NULL )
                return;
            free_table( table );
            free_history();
            // parse
            table = create_table();
            if ( strncmp( ofn.lpstrFile + ofn.nFileExtension, "csv", 3 ) == 0 )
                import_csv( fp, table );
            else if ( strncmp( ofn.lpstrFile + ofn.nFileExtension, "kiss", 4 ) == 0 )
                import_kiss( fp, table );
            fclose( fp );
            set_caption( szFileName );
            auto_adapt_layout( table );
            update_selection_rect();
            update_table_view( hwnd );
            unsaved = 0;
        }
    }
}
Пример #3
0
/* Get a frame from the camera.
   Serial protocol char: I */
void get_frame () {
	unsigned char ch;
	move_image((unsigned char *)DMA_BUF1, (unsigned char *)DMA_BUF2, (unsigned char *)FRAME_BUF, imgWidth, imgHeight); 
	if (overlay_flag) {
		frame[9] = (framecount % 10) + 0x30;
		frame[8] = ((framecount/10)% 10) + 0x30;
		frame[7] = ((framecount/100)% 10) + 0x30;
		set_caption(frame, imgWidth);
	}
	output_start = (unsigned char *)JPEG_BUF;
	output_end = encode_image((unsigned char *)FRAME_BUF, 
	output_start, quality, FOUR_TWO_TWO, imgWidth, imgHeight); 
	image_size = (unsigned int)(output_end - output_start);

	led1_on();

	framecount++;
	uart0SendString(imgHead);
	uart0SendChar((unsigned char)(image_size & 0x000000FF));
	uart0SendChar((unsigned char)((image_size & 0x0000FF00) >> 8));
	uart0SendChar((unsigned char)((image_size & 0x00FF0000) >> 16));
	uart0SendChar(0x00);
	cp = (unsigned char *)JPEG_BUF;
	for (i=0; i<image_size; i++) {
		while (*pPORTHIO & 0x0001) {
			continue;
		}
		uart0SendChar(*cp++);
	}

	while (uart0GetChar(&ch)) {
		// flush input 
		continue;
	}
}
Пример #4
0
	CBasicGUIButton::CBasicGUIButton(GLfloat x_pos, GLfloat y_pos, GLfloat z_pos, GLfloat width, GLfloat height, char *caption)
	: CAbstractGUIItem(x_pos,y_pos,z_pos,width,height)
	{
		set_color(0.4f,0.4f,0.4f);
		text = new CDKText();
		set_caption(caption);
		set_caption_color(0.0f,0.0f,0.0f);
	}
Пример #5
0
    /**
     * Button
     */
    Button::Button(std::string text, TTF_Font* font, int x_pos, int y_pos, Uint32 flags) {
        visual = SDL_CreateRGBSurface(SDL_HWSURFACE, BUTTON_DEFAULT_WIDTH, BUTTON_DEFAULT_HEIGHT, 32, 0, 0, 0, 0);
        click_sound = NULL;

        set_inner(&visual->clip_rect);
        set_pos(x_pos, y_pos);
        set_size(BUTTON_DEFAULT_WIDTH, BUTTON_DEFAULT_HEIGHT);

        set_active(); // Set the inner object active
        if (flags) i_settings |= flags; // Set the button with the given flags
        set_caption(text, font);
    }
Пример #6
0
void MYMENU_FileNew()
{
    free_table( table );
    free_history();
    // a new table
    table = create_table();
    set_caption( NULL );
    restore_view();
    update_row_tails();
    update_col_tails();
    update_selection_rect();
    update_table_view( hwnd );
    unsaved = 1;
}
Пример #7
0
Файл: tables.cpp Проект: rd8/qGo
// set to offline mode
void Account::set_offline()
{
	gsName = GS_UNKNOWN;
	svname = (QString) NULL;
	acc_name = (QString) NULL;
	status = OFFLINE;

	set_caption();

	num_players = 0;
	num_watchedplayers = 0;
	num_observedgames = 0;
	num_games = 0;
}
Пример #8
0
Console::Console(logging::Message_server &server, scripting::Script_tool& script_tool) : Frame(false), logging::Message_sender(server), script_tool_(script_tool)
{
	set_caption("Console");

	server.add_receiver(&message_viewer_);
	message_viewer_.set_position(float2(0.f, 0.f));
	m_container.add(&message_viewer_);

	input_line_.set_size(float2(0.f, 26.f));
	input_line_.set_focus(true);
	m_container.add(&input_line_);

	input_line_.m_on_accept.add<Console>(&Console::on_input_line_accept, this);

	m_close_button.set_enabled(false);
}
Пример #9
0
void WindowBase::display() {
	if (framerate > 0) {
		double time = 1.0 / framerate - clock.get_elapsed();
		if (time > 0)
			Clock::sleep(time);
	}
	
	frame = clock.get_elapsed();
	clock.reset();
	
	input().swap_buffers();
	swap_buffers();
	
	std::ostringstream ss;
	ss << "fps: " << 1.0 / get_frame_time();
	set_caption(ss.str());
}
Пример #10
0
/* loop inspired by yay
 * http://freecode.com/projects/yay
 */
Uint32 event_loop(void)
{
    char caption[256];
    Uint16 quit = 0;
    Uint32 frame = 0;
    int play_yuv = 0;
    unsigned int start_ticks = 0;

    while (!quit) {

        set_caption(caption, frame, 256);
        SDL_WM_SetCaption(caption, NULL);

        /* wait for SDL event */
        if (P.mode == NONE || P.mode == MASTER) {
            SDL_WaitEvent(&event);
        } else if (P.mode == SLAVE) {
            if (!event_dispatcher()) {
                SDL_WaitEvent(&event);
            }
        }

        switch (event.type)
        {
            case SDL_KEYDOWN:
                switch (event.key.keysym.sym)
                {
                    case SDLK_SPACE:
                        play_yuv = 1; /* play it, sam! */
                        while (play_yuv) {
                            start_ticks = SDL_GetTicks();
                            set_caption(caption, frame, 256);
                            SDL_WM_SetCaption( caption, NULL );

                            /* check for next frame existing */
                            if (read_frame()) {
                                draw_frame();
                                /* insert delay for real time viewing */
                                if (SDL_GetTicks() - start_ticks < 40)
                                    SDL_Delay(40 - (SDL_GetTicks() - start_ticks));
                                frame++;
                                send_message(NEXT);
                            } else {
                                play_yuv = 0;
                            }
                            /* check for any key event */
                            if (SDL_PollEvent(&event)) {
                                if (event.type == SDL_KEYDOWN) {
                                    /* stop playing */
                                    play_yuv = 0;
                                }
                            }
                        }
                        break;
                    case SDLK_RIGHT: /* next frame */
                        /* check for next frame existing */
                        if (read_frame()) {
                            draw_frame();
                            frame++;
                            send_message(NEXT);
                        }
                        break;
                    case SDLK_LEFT: /* previous frame */
                        if (frame > 1) {
                            frame--;
                            fseek(fd, ((frame-1) * P.frame_size), SEEK_SET);
                            if (P.diff) {
                                fseek(P.fd2, ((frame-1) * P.frame_size), SEEK_SET);
                            }
                            read_frame();
                            draw_frame();
                            send_message(PREV);
                        }
                        break;
                    case SDLK_UP: /* zoom in */
                        P.zoom++;
                        set_zoom_rect();
                        screen = SDL_SetVideoMode(P.zoom_width,
                                                  P.zoom_height,
                                                  P.bpp, P.vflags);
                        video_rect.w = P.zoom_width;
                        video_rect.h = P.zoom_height;
                        SDL_DisplayYUVOverlay(my_overlay, &video_rect);
                        send_message(ZOOM_IN);
                        break;
                    case SDLK_DOWN: /* zoom out */
                        P.zoom--;
                        set_zoom_rect();
                        screen = SDL_SetVideoMode(P.zoom_width,
                                                  P.zoom_height,
                                                  P.bpp, P.vflags);
                        video_rect.w = P.zoom_width;
                        video_rect.h = P.zoom_height;
                        SDL_DisplayYUVOverlay(my_overlay, &video_rect);
                        send_message(ZOOM_OUT);
                        break;
                    case SDLK_r: /* rewind */
                        if (frame > 1) {
                            frame = 1;
                            fseek(fd, 0, SEEK_SET);
                            if (P.diff) {
                                fseek(P.fd2, 0, SEEK_SET);
                            }
                            read_frame();
                            draw_frame();
                            send_message(REW);
                        }
                        break;
                    case SDLK_g: /* display grid */
                        P.grid = ~P.grid;
                        if (P.zoom < 1)
                            P.grid = 0;
                        draw_frame();
                        break;
                    case SDLK_m: /* show mb-data on stdout */
                        P.mb = ~P.mb;
                        if (P.zoom < 1)
                            P.mb = 0;
                        draw_frame();
                        break;
                    case SDLK_F5: /* Luma data only */
                        P.y_only = ~P.y_only;
                        P.cb_only = 0;
                        P.cr_only = 0;
                        draw_frame();
                        send_message(Y_ONLY);
                        break;
                    case SDLK_F6: /* Cb data only */
                        P.cb_only = ~P.cb_only;
                        P.y_only = 0;
                        P.cr_only = 0;
                        draw_frame();
                        send_message(CB_ONLY);
                        break;
                    case SDLK_F7: /* Cr data only */
                        P.cr_only = ~P.cr_only;
                        P.y_only = 0;
                        P.cb_only = 0;
                        send_message(CR_ONLY);
                        draw_frame();
                        break;
                    case SDLK_F8: /* display all color planes */
                        P.y_only = 0;
                        P.cb_only = 0;
                        P.cr_only = 0;
                        draw_frame();
                        send_message(ALL_PLANES);
                        break;
                    case SDLK_h: /* histogram */
                        P.hist = ~P.hist;
                        draw_frame();
                        break;
                    case SDLK_F1: /* MASTER-mode */
                        if (create_message_queue()) {
                            P.mode = MASTER;
                        }
                        break;
                    case SDLK_F2: /* SLAVE-mode */
                        if (P.mode == MASTER) {
                            destroy_message_queue();
                        }
                        if (connect_message_queue()) {
                            P.mode = SLAVE;
                        }
                        break;
                    case SDLK_F3: /* NONE-mode */
                        destroy_message_queue();
                        P.mode = NONE;
                        break;
                    case SDLK_q: /* quit */
                        quit = 1;
                        send_message(QUIT);
                        break;
                    default:
                        break;
                } /* switch key */
                break;
            case SDL_QUIT:
                quit = 1;
                break;
            case SDL_VIDEOEXPOSE:
                SDL_DisplayYUVOverlay(my_overlay, &video_rect);
                break;
            case SDL_MOUSEBUTTONDOWN:
                /* If the left mouse button was pressed */
                if (event.button.button == SDL_BUTTON_LEFT ) {
                    show_mb(event.button.x, event.button.y);
                }
                break;

            default:
                break;

        } /* switch event type */

    } /* while */

    return quit;
}
Пример #11
0
int main(int argc, char **argv)
{
    int c, image_index, image_count, incr, i;
    SDL_Event event;
    DispContext dc_s, *dc = &dc_s;
    const SDL_VideoInfo *vi;

    for(;;) {
        c = getopt(argc, argv, "h");
        if (c == -1)
            break;
        switch(c) {
        case 'h':
        show_help:
            help();
            break;
        default:
            exit(1);
        }
    }

    if (optind >= argc)
        goto show_help;

    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
        fprintf(stderr, "Could not init SDL\n");
        exit(1);
    }
    memset(dc, 0, sizeof(*dc));

    vi = SDL_GetVideoInfo();
    dc->screen_w = vi->current_w;
    dc->screen_h = vi->current_h;
    dc->is_full_screen = 0;

    image_count = argc - optind;
    image_index = 0;
    if (load_image(dc, argv[optind + image_index]) < 0)
        exit(1);
    dc->background_type = BG_TILED;

    {
        int w, h;

        if (image_count > 1 || (dc->img_w < 256 || dc->img_h < 256)) {
            w = DEFAULT_W;
            h = DEFAULT_H;
        } else {
            w = clamp_int(dc->img_w, 32, dc->screen_w);
            h = clamp_int(dc->img_h, 32, dc->screen_h);
        }
        open_window(dc, w, h, 0);
        set_caption(dc, argv + optind, image_index, image_count);
    }

    center_image(dc);
    draw_image(dc);

    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

    for(;;) {
        if (!SDL_WaitEvent(&event))
            continue;
        switch(event.type) {
        case SDL_KEYDOWN:
            switch (event.key.keysym.sym) {
            case SDLK_ESCAPE:
            case SDLK_q:
                goto done;
            case SDLK_SPACE: /* next image */
            case SDLK_n:
                incr = 1;
                goto prev_next;
            case SDLK_p: /* previous image */
                incr = -1;
            prev_next:
                if (image_count > 1) {
                    for(i = 0; i < image_count; i++) {
                        image_index += incr;
                        if (image_index < 0)
                            image_index = image_count - 1;
                        else if (image_index >= image_count)
                            image_index = 0;
                        if (load_image(dc, argv[optind + image_index]) == 0)
                            break;
                    }
                    if (i == image_count)
                        exit(1);
                    set_caption(dc, argv + optind, image_index, image_count);
                    center_image(dc);
                    draw_image(dc);
                }
                break;
            case SDLK_LEFT:
                pan_image(dc, 32, 0);
                break;
            case SDLK_RIGHT:
                pan_image(dc, -32, 0);
                break;
            case SDLK_UP:
                pan_image(dc, 0, 32);
                break;
            case SDLK_DOWN:
                pan_image(dc, 0, -32);
                break;
            case SDLK_c:
                center_image(dc);
                draw_image(dc);
                break;
            case SDLK_b:
                dc->background_type ^= 1;
                draw_image(dc);
                break;
            case SDLK_f:
                dc->is_full_screen ^= 1;
                if (dc->is_full_screen) {
                    /* save old windows size */
                    dc->win_w = dc->screen->w;
                    dc->win_h = dc->screen->h;
                    open_window(dc, dc->screen_w, dc->screen_h, 1);
                } else {
                    open_window(dc, dc->win_w, dc->win_h, 0);
                }
                center_image(dc);
                draw_image(dc);
                break;
            default:
                break;
            }
            break;
        case SDL_VIDEORESIZE:
            {
                open_window(dc, event.resize.w, event.resize.h, 0);
                center_image(dc);
                draw_image(dc);
            }
            break;
        case SDL_QUIT:
            goto done;
        case SDL_MOUSEMOTION:
            if (event.motion.state) {
                pan_image(dc, event.motion.xrel, event.motion.yrel);
            }
            break;
        case SDL_USEREVENT:
            if (dc->frame_count > 1) {
                /* show next frame */
                if (dc->frame_index == (dc->frame_count - 1)) {
                    if (dc->loop_count == 0 ||
                        dc->loop_counter < (dc->loop_count - 1)) {
                        dc->frame_index = 0;
                        dc->loop_counter++;
                    } else {
                        break;
                    }
                } else {
                    dc->frame_index++;
                }
                draw_image(dc);
                restart_frame_timer(dc);
            }
            break;
        default:
            break;
        }
    }
 done:

    SDL_FreeSurface(dc->screen);
    return 0;
}