コード例 #1
0
ファイル: main.cpp プロジェクト: mgukowsky/cREST
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	switch (msg) {
		case WM_CREATE:
			gRequestSender = new RequestSender(IDC_SEND_BUTTON);
			if (!setup_window(hwnd, hDefaultFont)) {
				MessageBoxA(NULL, "Failed to create dialog item(s)", "Error!", MB_ICONEXCLAMATION | MB_OK);
				return NULL;
			};
			CheckRadioButton(hwnd, IDC_RADIO_GET, IDC_RADIO_OPTIONS, IDC_RADIO_GET);
			break;
		case WM_CTLCOLORLISTBOX:
			return (LONG)gHBRBackground;
		case WM_PAINT:
			paintText(hwnd);
			break;
		case WM_COMMAND:
			handleCommand(hwnd, msg, wParam, lParam);
			break;
		case WM_CLOSE:
			delete gRequestSender;
			WSACleanup();
			PostQuitMessage(0);
			break;
		case WM_DESTROY:
			DestroyWindow(hwnd);
			break;
		default:
			return DefWindowProc(hwnd, msg, wParam, lParam);
	}
	return 0;
}
コード例 #2
0
ファイル: tegra.c プロジェクト: hallor/u-boot
/**
 * Register a new display based on device tree configuration.
 *
 * The frame buffer can be positioned by U-Boot or overriden by the fdt.
 * You should pass in the U-Boot address here, and check the contents of
 * struct tegra_lcd_priv to see what was actually chosen.
 *
 * @param blob			Device tree blob
 * @param priv			Driver's private data
 * @param default_lcd_base	Default address of LCD frame buffer
 * @return 0 if ok, -1 on error (unsupported bits per pixel)
 */
static int tegra_display_probe(const void *blob, struct tegra_lcd_priv *priv,
                               void *default_lcd_base)
{
    struct disp_ctl_win window;
    struct dc_ctlr *dc;

    priv->frame_buffer = (u32)default_lcd_base;

    dc = (struct dc_ctlr *)priv->disp;

    /*
     * A header file for clock constants was NAKed upstream.
     * TODO: Put this into the FDT and fdt_lcd struct when we have clock
     * support there
     */
    clock_start_periph_pll(PERIPH_ID_HOST1X, CLOCK_ID_PERIPH,
                           144 * 1000000);
    clock_start_periph_pll(PERIPH_ID_DISP1, CLOCK_ID_CGENERAL,
                           600 * 1000000);
    basic_init(&dc->cmd);
    basic_init_timer(&dc->disp);
    rgb_enable(&dc->com);

    if (priv->pixel_clock)
        update_display_mode(&dc->disp, priv);

    if (setup_window(&window, priv))
        return -1;

    update_window(dc, &window);

    return 0;
}
コード例 #3
0
void x01_gui_window_push(ClickConfigProvider click_config_provider) {
  s_window = window_create();
  setup_window();
  window_set_click_config_provider(s_window, click_config_provider);
  window_set_window_handlers(s_window, (WindowHandlers) {
    .unload = handle_window_unload
  });
コード例 #4
0
ファイル: fdmf_sonic_reducer.c プロジェクト: AndyA/fdmf
int
main( void ) {
  f_c *ebuf, *eout, *rbuf, *rout, *tbuf, *tout;
  f_p ep, rp, tp;
  int chunks;
  double *track_window;
  setup_bufs( &ebuf, &eout, &rbuf, &rout, &tbuf, &tout );
  chunks = calc_chunk_metrics( ebuf, rbuf, tbuf );
  /* ebuf[], rbuf[], and tbuf[] each have chunks valid elements */
  setup_plans( chunks, &ep, &rp, &tp, ebuf, rbuf, tbuf, eout, rout, tout );
  track_window = setup_window( chunks );
  window( ebuf, track_window, chunks );
  window( rbuf, track_window, chunks );
  window( tbuf, track_window, chunks );
  fftw_execute( ep );
  fftw_execute( rp );
  fftw_execute( tp );
  /* now eout[], rout[], and tout[] are valid */
  do_spline( eout, chunks );
  do_spline( rout, chunks );
  do_spline( tout, chunks );
  free_bufs( ebuf, eout, rbuf, rout, tbuf, tout );
  free( track_window );
  destroy_plans( ep, rp, tp );
  return ( 0 );
}
コード例 #5
0
ファイル: fdmf_sonic_reducer.c プロジェクト: AndyA/fdmf
static int
calc_chunk_metrics( f_c * ebuf, f_c * rbuf, f_c * tbuf ) {
  char buf[CHUNKBYTES];
  double *chunk_window;
  int chunkcount = 0;
  f_c *in, *out;
  f_p p;
  in = fftw_malloc( sizeof( f_c ) * CHUNKSAMPS );
  assert( in != NULL );
  out = fftw_malloc( sizeof( f_c ) * CHUNKSAMPS );
  assert( out != NULL );
  p = fftw_plan_dft_1d( CHUNKSAMPS, in, out, FFTW_FORWARD, FFTW_ESTIMATE );
  chunk_window = setup_window( CHUNKSAMPS );
  while ( CHUNKBYTES == read_from_fd( 0, buf, CHUNKBYTES ) ) {
    /* Forget about the last fraction of a second of audio data. */
    /* Process exactly one second of audio data per iteration. */
    double be[NUM_BANDS];       /* band energies */
    audio_to_fftw( buf, in );
    window( in, chunk_window, CHUNKSAMPS );
    fftw_execute( p );          /* post: in[] -> FFT -> out[] is done */
    calc_band_energies( out, be );      /* post: be[] is valid */
    chunk_metrics( be, ebuf, rbuf, tbuf, chunkcount );
    chunkcount++;
    /* post: ebuf[], rbuf[], and tbuf[] have chunkcount valid elements */
  }                             /* post: we got to the end of the input data */
  fftw_free( in );
  fftw_free( out );
  fftw_destroy_plan( p );
  free( chunk_window );
  return chunkcount;
}
コード例 #6
0
ファイル: interactive.cpp プロジェクト: scwatts/notop
// Node menu constructor, takes pointer to calling menu and node container as well as a node name
NodeMenu::NodeMenu(ClusterMenu * _pcluster_menu, NodeContainer * _node_container, std::string _node_name) {
    // NOTE: the way that the node informatiom is updated, the NodeContainer must be parsed so we can access the
    // updated info correctly (otherwise after an update, we would have a reference to containers with old info)
    setup_window(this);
    pcluster_menu = _pcluster_menu;
    pnode_container = _node_container;
    node_name = _node_name;
}
コード例 #7
0
int 
main(int argc, char **argv)
{
   disp = XOpenDisplay(NULL);
   if (!disp)
     {
	printf("ERROR: Cannot connect to display!\n");
	exit(-1);
     }
   g_type_init ();
   setup_window();
   main_loop();
   return 0;
}
コード例 #8
0
static void power_action(const PowerActionData* action)
{
    g_return_if_fail(config.power.enabled && action->get_allow());

    if(*action->show_prompt_ptr)
    {
        GtkWidget* dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
                                                   GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
                                                   "%s", _(action->prompt));
        gtk_dialog_add_buttons(GTK_DIALOG(dialog),
                               _("Return to Login"), GTK_RESPONSE_CANCEL,
                               _(action->name), GTK_RESPONSE_OK, NULL);
        gtk_widget_set_name(dialog, "power_dialog");
        gtk_window_set_title(GTK_WINDOW(dialog), action->name);
        setup_window(GTK_WINDOW(dialog));
        if(action->icon && gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), action->icon))
        {
            GtkWidget* image = gtk_image_new_from_icon_name(action->icon, GTK_ICON_SIZE_DIALOG);
            gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog), image);
        }
        gtk_widget_hide(greeter.ui.login_window);
        gtk_widget_set_sensitive(greeter.ui.power.widget, FALSE);
        gtk_widget_show_all(dialog);
        set_window_position(dialog, &WINDOW_POSITION_CENTER);

        gboolean result = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK;
        gtk_widget_destroy(dialog);
        gtk_widget_show(greeter.ui.login_window);
        update_windows_layout();
        gtk_widget_set_sensitive(greeter.ui.power.widget, TRUE);

        if(!result)
            return;
    }

    GError* error = NULL;
    if(!action->do_action(&error) && error)
    {
        g_warning("Action \"%s\" failed with error: %s.", action->name, error->message);
        show_error(_(action->name), _("Action \"%s\" failed with error: %s."), _(action->name), error->message);
        g_clear_error(&error);
    }
}
コード例 #9
0
int ctr_crypto_interface_write_sector(void *io, const void *buffer, size_t buffer_size, size_t sector)
{
	int res = 0;
	ctr_crypto_interface *crypto_io = io;
	const size_t sector_size = ctr_io_sector_size(crypto_io->lower_io);
	const size_t number_of_sectors = FLOOR(buffer_size, sector_size);
	const size_t block_size = AES_BLOCK_SIZE;
	size_t sectors_per_block = block_size / sector_size;

	if (!sectors_per_block)
		sectors_per_block = 1;

	if (number_of_sectors)
	{
		size_t block_sector_lcm = lcm(sector_size, block_size);

		uint8_t window_buffer[4 * block_sector_lcm + sectors_per_block * sector_size];
		write_window window =
		{
			.window = window_buffer,
			.window_size = sizeof(window_buffer),
			.window_offset = 0,
			.buffer = buffer,
			.buffer_size = buffer_size,
			.buffer_offset = 0,
			.current_sector = sector
		};

		setup_window(io, &window, sector, sector_size, block_size);

		res = process_window(io, &window, sector_size, block_size, input, output);
		while(!res)
		{
			res = process_window(io, &window, sector_size, block_size, input, output);
		}
	}
	return res == 1 ? 0 : res;
}
コード例 #10
0
ファイル: interactive.cpp プロジェクト: scwatts/notop
// Construct ClusterMenu struct and initialise window
ClusterMenu::ClusterMenu() {
    setup_window(this);
}
コード例 #11
0
ファイル: WINDOW.C プロジェクト: Xstarfct/Cgames
/*
 * Name:    finish
 * Purpose: To remove the current window and terminate the program if no
 *           more windows are left.
 * Date:    June 5, 1991
 * Passed:  window:  pointer to current window
 * Notes:   Order of deciding which window becomes current window:
 *          1) If any invisible window with same top and bottom line,
 *          and start_col and end_col, then first invisible one becomes
 *          current window.
 *          2) window above if it exists becomes current window
 *          3) window below if it exists becomes current window
 *          4) window right if it exists becomes current window
 *          5) window left  if it exists becomes current window
 *          6) first available invisible window becomes current window.
 *          When I added vertical windows, this routine became a LOT
 *           more complicated.  To keep things reasonably sane, let's
 *           only close windows that have three common edges, eg.
 *
 *                    ÚÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
 *                    ³      ³    no    ³
 *                    ³      ÃÄÄÄÄÄÂÄÄÄÄ´
 *                    ³      ³yes1 ³yes1³
 *                    ³  no  ÃÄÄÄÄÄÁÄÄÄÄ´
 *                    ³      ³   yes2   ³
 *                    ³      ÃÄÄÄÄÄÄÄÄÄÄ´
 *                    ³      ³   yes2   ³
 *                    ÀÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
 *
 *          Windows with 'no' cannot be closed.  Windows with 'yes' can
 *          be combined with windows that have the same yes number.
 */
void finish( WINDOW *window )
{
    register WINDOW *wp;   /* for scanning other windows */
    register WINDOW *win;  /* register pointer for window */
    file_infos *file, *fp;  /* for scanning other files */
    int  poof;
    int  cline;
    int  top;
    int  bottom;
    int  start_col;
    int  end_col;
    int  max_letter;
    int  file_change = FALSE;
    line_list_ptr ll;
    line_list_ptr temp_ll;

    win = window;
    entab_linebuff( );
    if (un_copy_line( win->ll, win, TRUE ) == ERROR)
        return;

    file = win->file_info;
    /*
     * remove all hidden windows that point to same file
     */
    file = win->file_info;
    for (wp=g_status.window_list; wp != NULL; wp=wp->next) {
        if (wp->file_info == file) {
            if (!wp->visible) {
                if (wp->prev == NULL) {
                    if (wp->next == NULL)
                        g_status.stop = TRUE;
                    else
                        g_status.window_list = wp->next;
                } else
                    wp->prev->next = wp->next;
                if (wp->next)
                    wp->next->prev = wp->prev;
                --wp->file_info->ref_count;
                free( wp );
                --g_status.window_count;
            }
        }
    }

    if (win->prev == NULL && win->next == NULL)
        g_status.stop = TRUE;

    poof = FALSE;

    if (g_status.stop != TRUE) {
        /*
         * see if there are any invisible windows with same top and bottom,
         *  lines, and start_col and end_col as this window.  start looking at
         *  end of window list.
         */
        top       = win->top_line;
        bottom    = win->bottom_line;
        start_col = win->start_col;
        end_col   = win->end_col;
        wp = g_status.window_list;
        if (wp != NULL) {
            while (wp->next != NULL)
                wp = wp->next;
        }
        while (wp != NULL && poof == FALSE) {
            if (wp->top_line == top         &&  wp->bottom_line == bottom  &&
                    wp->start_col == start_col  &&  wp->end_col == end_col     &&
                    !wp->visible)
                poof = TRUE;
            else
                wp = wp->prev;
        }

        if (poof == FALSE) {
            /*
             * see if there are any windows above
             */
            wp = g_status.window_list;
            while (wp != NULL && poof == FALSE) {
                if (wp->bottom_line+2 == win->top_line &&
                        wp->start_col     == win->start_col &&
                        wp->end_col       == win->end_col   && wp->visible) {
                    poof = TRUE;
                    top  = wp->top_line;
                } else
                    wp = wp->next;
            }
            if (poof == FALSE) {
                /*
                 * see if there are any windows below
                 */
                wp = g_status.window_list;
                while (wp != NULL && poof == FALSE) {
                    if (wp->top_line-2 == win->bottom_line  &&
                            wp->start_col     == win->start_col &&
                            wp->end_col    == win->end_col   && wp->visible) {
                        poof = TRUE;
                        bottom = wp->bottom_line;
                    } else
                        wp = wp->next;
                }
            }
            if (poof == FALSE) {
                /*
                 * see if there are any windows right
                 */
                wp = g_status.window_list;
                while (wp != NULL && poof == FALSE) {
                    if (wp->top_line    == win->top_line  &&
                            wp->bottom_line == win->bottom_line &&
                            wp->start_col-2 == win->end_col     && wp->visible) {
                        poof = TRUE;
                        end_col = wp->end_col;
                    } else
                        wp = wp->next;
                }
            }
            if (poof == FALSE) {
                /*
                 * see if there are any windows left
                 */
                wp = g_status.window_list;
                while (wp != NULL && poof == FALSE) {
                    if (wp->top_line    == win->top_line  &&
                            wp->bottom_line == win->bottom_line &&
                            wp->end_col+2   == win->start_col   && wp->visible) {
                        poof = TRUE;
                        start_col = wp->start_col;
                    } else
                        wp = wp->next;
                }
            }
            if (poof == FALSE) {
                /*
                 * see if there are any other invisible windows.  start looking
                 *  at the end of the window list.
                 */
                wp = g_status.window_list;
                if (wp != NULL) {
                    while (wp->next != NULL)
                        wp = wp->next;
                }
                while (wp != NULL && poof == FALSE) {
                    if (!wp->visible)
                        poof = TRUE;
                    else
                        wp = wp->prev;
                }
            }
        }
        if (poof) {
            wp->visible = TRUE;
            cline = wp->cline - (wp->top_line+wp->ruler);
            wp->top_line = top;
            wp->bottom_line = bottom;
            wp->cline = (wp->top_line+wp->ruler) + cline;
            if (wp->cline > wp->bottom_line)
                wp->cline = wp->top_line+wp->ruler;
            wp->start_col = start_col;
            wp->end_col   = end_col;
            if (start_col == 0 && end_col == g_display.ncols - 1)
                wp->vertical = FALSE;
            else
                wp->vertical = TRUE;
            check_virtual_col( wp, wp->rcol, wp->ccol );
            setup_window( wp );
            show_window_header( wp );
            if (wp->vertical)
                show_vertical_separator( wp );

            /*
             * The window above, below, or previously invisible becomes the new
             *  current window.
             */
            g_status.current_window = wp;
        }
    }

    if (!poof && g_status.stop != TRUE)
        /*
         * cannot close current window
         */
        error( WARNING, win->bottom_line, win7 );
    else {

        /*
         * free unused file memory if necessary
         */
        if (--file->ref_count == 0) {

            /*
             * if a block is marked, unmark it
             */
            if (file == g_status.marked_file) {
                g_status.marked      = FALSE;
                g_status.marked_file = NULL;
            }

            for (fp=g_status.file_list; fp != NULL; fp=fp->next) {
                if (fp->file_no > file->file_no)
                    fp->file_no--;
            }
            file_change = file->file_no;

            /*
             * no window now refers to this file, so remove file from the list
             */
            if (file->prev == NULL)
                g_status.file_list = file->next;
            else
                file->prev->next = file->next;
            if (file->next)
                file->next->prev = file->prev;

            /*
             * free the line pointers, linked list of line pointers, and
             *  file struc.
             */
            ll = file->undo_top;
            while (ll != NULL) {
                temp_ll = ll->next;
                if (ll->line != NULL)
                    my_free( ll->line );
                my_free( ll );
                ll = temp_ll;
            }

            ll = file->line_list;
            while (ll != NULL) {
                temp_ll = ll->next;
                if (ll->line != NULL)
                    my_free( ll->line );
                my_free( ll );
                ll = temp_ll;
            }

#if defined( __MSC__ )
            _fheapmin( );
#endif

            free( file );
            if (--g_status.file_count) {
                show_file_count( g_status.file_count );
                show_avail_mem( );
            }
        }

        /*
         * remove the current window from the window list
         */
        if (win->prev == NULL)
            g_status.window_list = win->next;
        else
            win->prev->next = win->next;

        if (win->next)
            win->next->prev = win->prev;

        if (diff.defined  &&  (diff.w1 == win  ||  diff.w2 == win))
            diff.defined = FALSE;

        /*
         * free the memory taken by the window structure
         */
        free( win );
        --g_status.window_count;

        if (g_status.stop == FALSE) {
            g_status.current_file = wp->file_info;
            wp->file_info->dirty = LOCAL;
            make_ruler( wp );
            show_ruler( wp );
            show_window_count( g_status.window_count );
            if (file_change) {
                for (wp=g_status.window_list; wp!=NULL; wp=wp->next)
                    if (wp->visible)
                        show_window_number_letter( wp );
            } else {
                max_letter = 'a';
                for (wp=g_status.window_list; wp!=NULL; wp=wp->next) {
                    if (wp->file_info == file && wp->letter > max_letter)
                        max_letter = wp->letter;
                }
                if (max_letter < file->next_letter - 1)
                    file->next_letter = max_letter + 1;
            }
        }
    }

    if (g_status.stop == TRUE) {
        if (g_status.sas_defined && g_status.sas_arg < g_status.sas_argc) {
            show_avail_mem( );
            for (bottom=0; bottom <= g_display.nlines; bottom++)
                eol_clear( 0, bottom, g_display.text_color );
            bottom  = g_display.nlines;
            set_prompt( win18, bottom );
            top = getkey( );
            top = getfunc( top );
            eol_clear( 0, bottom, g_display.text_color );
            if (top == RepeatGrep) {
                g_status.command = RepeatGrep;
                g_status.window_list = g_status.current_window = NULL;
                if (search_and_seize( g_status.window_list ) != ERROR)
                    g_status.stop = FALSE;
            }
        }
    }
}
コード例 #12
0
ファイル: WINDOW.C プロジェクト: Xstarfct/Cgames
/*
 * Name:    size_window
 * Purpose: To change the size of the current and one other window.
 * Date:    June 5, 1991
 * Passed:  window:  pointer to current window
 * Notes:   Use the Up and Down arrow keys to make the current window
 *           bigger or smaller.  The window above will either grow
 *           or contract accordingly.
 */
int  size_window( WINDOW *window )
{
    char line_buff[(MAX_COLS+1)*2]; /* buffer for char and attribute  */
    int  func;
    int  c;
    int  resize;
    int  show_above_ruler;
    int  old_bottom_line;
    int  old_top_line;
    int  new_bottom_line;
    int  new_top_line;
    register WINDOW *above;
    register WINDOW *win;

    win = window;
    if (win->top_line != 1 && !win->vertical) {
        entab_linebuff( );
        un_copy_line( win->ll, win, TRUE );
        save_screen_line( 0, win->bottom_line, line_buff );

        /*
         * press up or down to change window size
         */
        set_prompt( win4, win->bottom_line );

        /*
         * resizing only affects current window and above visible window
         */
        above = g_status.window_list;
        while (above->bottom_line + 2 != win->top_line || !above->visible)
            above = above->next;
        if (above->vertical)
            /*
             * cannot resize vertical window
             */
            error( WARNING, win->bottom_line, win5 );
        else {
            old_top_line = win->top_line;
            old_bottom_line = above->bottom_line;
            show_above_ruler = FALSE;
            for (func=0; func != AbortCommand && func != Rturn; ) {

                /*
                 * If user has redined the ESC and Return keys, make them Rturn and
                 *  AbortCommand in this function.
                 */
                c = getkey( );
                func = getfunc( c );
                if (c == RTURN || func == NextLine || func == BegNextLine)
                    func = Rturn;
                else if (c == ESC)
                    func = AbortCommand;
                resize = FALSE;

                /*
                 * if LineUp, make current window top line grow and bottom line
                 *  of above window shrink.  if window movement covers up current
                 *  line of window then we must adjust logical line and real line.
                 */
                if (func == LineUp) {
                    if (above->bottom_line > above->top_line + above->ruler) {
                        if (win->rline == (win->cline - (win->top_line+win->ruler-1)))
                            --win->cline;
                        --win->top_line;
                        if (above->cline == above->bottom_line)
                            --above->cline;
                        --above->bottom_line;
                        resize = TRUE;
                        if (mode.ruler) {
                            if (win->ruler == FALSE) {
                                if (win->cline == win->top_line)
                                    ++win->cline;
                                if (win->cline > win->bottom_line)
                                    win->cline = win->bottom_line;
                                win->ruler = TRUE;
                            }
                        }
                    }

                    /*
                     * if LineDown, make current window top line shrink and bottom line
                     *  of above window grow.  if window movement covers up current
                     *  line of window then we must adjust logical line and real line.
                     */
                } else if (func == LineDown) {
                    if (win->bottom_line > win->top_line + win->ruler) {
                        if (win->cline == win->top_line + win->ruler)
                            ++win->cline;
                        ++win->top_line;
                        ++above->bottom_line;
                        resize = TRUE;
                        if (mode.ruler) {
                            if (above->ruler == FALSE) {
                                if (above->cline == above->top_line)
                                    ++above->cline;
                                if (above->cline > above->bottom_line)
                                    above->cline = above->bottom_line;
                                above->ruler = TRUE;
                                make_ruler( above );
                                show_above_ruler = TRUE;
                            }
                        }
                    }
                }

                /*
                 * if we resize a window, then update window size and current and
                 *  real lines if needed.
                 */
                if (resize == TRUE) {
                    setup_window( above );
                    display_current_window( above );
                    if (show_above_ruler) {
                        show_ruler( above );
                        show_ruler_pointer( above );
                        show_above_ruler = FALSE;
                    }
                    setup_window( win );
                    show_window_header( win );
                    win->ruler = mode.ruler;
                    make_ruler( win );
                    show_ruler( win );
                    show_ruler_pointer( win );
                    display_current_window( win );
                    save_screen_line( 0, win->bottom_line, line_buff );

                    /*
                     * press up or down to change window size
                     */
                    set_prompt( win4, win->bottom_line );
                }
            }
            new_top_line = win->top_line;
            new_bottom_line = above->bottom_line;
            for (above=g_status.window_list; above != NULL; above=above->next) {
                if (!above->visible) {
                    if (above->bottom_line == old_bottom_line) {
                        above->bottom_line = new_bottom_line;
                        if (above->cline < new_bottom_line)
                            above->cline = new_bottom_line;
                        setup_window( above );
                    } else if (above->top_line == old_top_line) {
                        above->top_line = new_top_line;
                        if (above->cline < new_top_line)
                            above->cline = new_top_line;
                        if ((long)(above->cline+1L - (above->top_line+above->ruler)) >
                                above->rline)
                            above->cline = (int)above->rline + above->top_line +
                                           above->ruler - 1;
                        setup_window( above );
                    }
                }
            }
        }
        restore_screen_line( 0, win->bottom_line, line_buff );
    } else {
        if (win->vertical)
            /*
             * cannot resize vertical window
             */
            error( WARNING, win->bottom_line, win5 );
        else
            /*
             * cannot resize top window
             */
            error( WARNING, win->bottom_line, win6 );
    }
    return( OK );
}
コード例 #13
0
ファイル: WINDOW.C プロジェクト: Xstarfct/Cgames
/*
 * ×÷ÓÃ: ÔÚ¹â±ê´¦Ë®Æ½Çзִ°¿Ú
 * ²ÎÊý:  window:  µ±Ç°´°¿ÚµÄÖ¸Õë
 */
int  split_horizontal( WINDOW *window )
{
    register WINDOW *wp;
    register WINDOW *win;   /* ´°¿ÚµÄ¼Ä´æÆ÷Ö¸Õë */
    WINDOW *temp;
    file_infos *file;       /* ÊôÓÚд°¿ÚµÄÎļþ½á¹¹Ö¸Õë */
    int  rc;

    rc = OK;
    win = window;
    if ( win != NULL) {

        /*
         * ¼ì²éÊÇ·ñÓпշÅÖÃд°¿Ú
         */
        if (win->bottom_line - win->cline < 2) {
            /*
             * ÏòÉÏÒý¶¯¹â±ê
             */
            error( WARNING, win->bottom_line, win1 );
            rc = ERROR;
        } else {
            file = win->file_info;

            assert( file != NULL );

            if (create_window( &temp, win->cline+1, win->bottom_line,
                               win->start_col, win->end_col, file ) == ERROR) {
                /*
                 * ÄÚ´æ²»×ã
                 */
                error( WARNING, win->bottom_line, main4 );
                rc = ERROR;
            }
            if (rc == OK  &&  temp != NULL) {
                entab_linebuff( );
                un_copy_line( win->ll, win, TRUE );
                wp = temp;
                /*
                 * ¼Ç¼µ±Ç°´°¿ÚÒòΪ´´Á¢ÐµĴ°¿Ú¶ø¶ªÉúµÄÐС£
                 * ²¢ÇÒµ÷ÕûËüµÄÒ³´óС
                 */
                win->bottom_line = win->cline;
                setup_window( win );
                display_current_window( win );

                /*
                 * ÉèÖÃеĹâ±êλÖÃ
                 */
                wp->rcol = win->rcol;
                wp->ccol = win->ccol;
                wp->bcol = win->bcol;
                wp->rline = win->rline;
                wp->bin_offset = win->bin_offset;
                wp->ll    = win->ll;
                wp->cline = wp->cline + win->cline - (win->top_line + win->ruler);
                if (wp->cline > wp->bottom_line)
                    wp->cline = wp->bottom_line;
                wp->visible = TRUE;
                wp->vertical = win->vertical;
                wp->letter = file->next_letter++;
                wp->ruler  = mode.ruler;

                /*
                 * еĴ°¿Ú±ä³ÉÁ˵±Ç°´°¿Ú
                 */
                g_status.current_window = wp;

                show_window_count( g_status.window_count );
                show_window_header( wp );
                display_current_window( wp );
                if (wp->vertical)
                    show_vertical_separator( wp );
                make_ruler( wp );
                show_ruler( wp );
                rc = OK;
            }
        }
    } else
        rc = ERROR;
    return( rc );
}
コード例 #14
0
ファイル: WINDOW.C プロジェクト: Xstarfct/Cgames
/*
 * Name:    create_window
 * Purpose: To allocate space for a new window structure and set up some
 *           of the relevant fields.
 * Date:    June 5, 1991
 * Passed:  window: pointer to window pointer
 *          top:    the top line of the new window
 *          bottom: the bottom line of the new window
 *          start_col:  starting column of window on screen
 *          end_col:    ending column of window on screen
 *          file:   the file structure to be associated with the new window
 * Returns: OK if window could be created
 *          ERROR if out of memory
 */
int  create_window( WINDOW **window, int top, int bottom, int start_col,
                    int end_col, file_infos *file )
{
    WINDOW *wp;             /* temporary variable - use it instead of **window */
    register WINDOW *prev;
    int  rc;                /* return code */

    rc = OK;
    /*
     * allocate space for new window structure
     */
    if ((*window = (WINDOW *)calloc( 1, sizeof(WINDOW) )) == NULL) {
        /*
         * out of memory
         */
        error( WARNING, g_display.nlines, main4 );
        rc = ERROR;
    } else {

        /*
         * set up appropriate fields
         */
        wp              = *window;
        wp->file_info   = file;
        wp->top_line    = top+1;
        wp->bottom_line = bottom;
        wp->start_col   = start_col;
        wp->end_col     = end_col;
        wp->bin_offset  = 0;
        wp->ruler       = mode.ruler;
        make_ruler( wp );
        wp->cline       = wp->top_line + wp->ruler;
        if (start_col == 0 && end_col == g_display.ncols-1)
            wp->vertical = FALSE;
        else
            wp->vertical = TRUE;
        wp->prev        = NULL;
        wp->next        = NULL;

        setup_window( wp );

        /*
         * add window into window list
         */
        prev = g_status.current_window;
        if (prev) {
            (*window)->prev = prev;
            if (prev->next)
                prev->next->prev = *window;
            (*window)->next = prev->next;
            prev->next = *window;
        }
        if (g_status.window_list == NULL)
            g_status.window_list = *window;

        /*
         * record that another window is referencing this file
         */
        ++file->ref_count;
        file->dirty = LOCAL;
        ++g_status.window_count;
    }
    return( rc );
}
コード例 #15
0
ファイル: wparse.cpp プロジェクト: Fabianx/cstk
void WParse::init(FILE* fp) 
{
	parse(fp);
	setup_window();
}
コード例 #16
0
ファイル: main.c プロジェクト: accatyyc/ShaderCaster
int main()
{
	
    if (!glfwInit()) {
        return -1;
	}

	GLFWwindow *window = setup_window(640, 480, "Hellurr!!");

	glewExperimental = GL_TRUE;
	glewInit();

	// Create Vertex buffer object, containing our 4 vertices.
	// This allows us to draw a full screen quad, so we can
	// later on do raycasting in the fragment shader
	GLuint vbo;
	glGenBuffers(1, &vbo);
	glBindBuffer(GL_ARRAY_BUFFER, vbo);
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

	// Compile shaders. The vertex shader is just pass-through
	char *f_shader_source = read_file("default.frag");
	GLuint v_shader = compile_shader(vertex_shader, GL_VERTEX_SHADER);
	GLuint f_shader = compile_shader((const char *)f_shader_source, GL_FRAGMENT_SHADER);
	GLuint program = create_program(v_shader, f_shader);
	free((void *)f_shader_source);

	// Bind shader attributes with a vertex array object
	GLuint vao;
	glGenVertexArrays(1, &vao);
  	glBindVertexArray(vao);
	
	GLint vertex_handle = glGetAttribLocation(program, "in_vertex");
	glVertexAttribPointer(vertex_handle, 2, GL_FLOAT, GL_FALSE, 0, 0);
	glEnableVertexAttribArray(vertex_handle);

   	// Pass the frame buffer size to the fragment shader
	int width, height;
	glfwGetFramebufferSize(window, &width, &height);
	GLint size_handle = glGetUniformLocation(program, "buffer_size");
   	glUniform2i(size_handle, width, height);

	GLint cursor_handle = glGetUniformLocation(program, "mouse_position");

	// Enable vsync
	glfwSwapInterval(1);
	
    // Loop until the user closes the window
    while (!glfwWindowShouldClose(window))
    {
		double xpos, ypos;
		glfwGetCursorPos(window, &xpos, &ypos);
		glUniform2f(cursor_handle, xpos / 640, ypos / 480);
		
		// Draw our full screen quad
		glBindVertexArray(vao);
		glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

        // Swap front and back buffers
        glfwSwapBuffers(window);
		glfwPollEvents();
    }

    glfwTerminate();

	return 0;
}
コード例 #17
0
ファイル: uae-control.c プロジェクト: ApolloniaUK/PUAE
/*****************************************
* Main program                           *
*****************************************/
int main()
{
    int quit = 0, i;
    struct IntuiMessage *msg;
    struct Gadget *button;
    struct StringInfo *strinfo;
    char buf[257];
    UWORD koodi, msgID;
    ULONG classi, number;
    APTR address;
    ULONG CycleTags[3];

    CycleTags[0] = GTCY_Active;
    CycleTags[1] = (ULONG) & number;
    CycleTags[2] = TAG_DONE;

    /* Read UAE configuration */
    i = GetUaeConfig(&config);
    i = setup_window();
    if (i == 0) {
	quit_program(1, "Cannot setup a window!");
	return 1;
    }
    while (quit == 0) {
	WaitPort(window->UserPort);
	while (msg = (struct IntuiMessage *) GT_GetIMsg(window->UserPort)) {
	    classi = msg->Class;
	    koodi = msg->Code;
	    address = msg->IAddress;
	    if (classi == IDCMP_GADGETUP) {
		msgID = ((struct Gadget *) msg->IAddress)->GadgetID;
		button = (struct Gadget *) msg->IAddress;
		if (button->SpecialInfo) {
		    strinfo = (struct StringInfo *) button->SpecialInfo;
		}
	    } else
		msgID = msg->Code;

	    GT_ReplyIMsg((struct IntuiMessage *) msg);
	    switch (classi) {
	    case IDCMP_CLOSEWINDOW:
		quit = 1;
		break;
	    case IDCMP_GADGETUP:
		switch (msgID) {
		case GAD_EXITEMU:
		    ExitEmu();
		    break;
		case GAD_EJECT_DF0:
		    EjectDisk(0);
		    Delay(30);
		    GetUaeConfig(&config);
		    print_drive_status();
		    break;
		case GAD_EJECT_DF1:
		    EjectDisk(1);
		    Delay(30);
		    GetUaeConfig(&config);
		    print_drive_status();
		    break;
		case GAD_EJECT_DF2:
		    EjectDisk(2);
		    Delay(30);
		    GetUaeConfig(&config);
		    print_drive_status();
		    break;
		case GAD_EJECT_DF3:
		    EjectDisk(3);
		    Delay(30);
		    GetUaeConfig(&config);
		    print_drive_status();
		    break;
		case GAD_SOUND:
		    if (config.do_output_sound)
			DisableSound();
		    else
			EnableSound();

		    Delay(30);
		    GetUaeConfig(&config);
		    break;
		case GAD_JOYSTICK:
		    if (config.do_fake_joystick)
			DisableJoystick();
		    else
			EnableJoystick();

		    Delay(30);
		    GetUaeConfig(&config);
		    break;
		case GAD_FRAMERATE:
		    SetFrameRate(strinfo->LongInt);
		    Delay(30);
		    GetUaeConfig(&config);
		    break;
		case GAD_INSERT_DF0:
		    strcpy(buf, config.df0_name);
		    if (get_string(buf, 255)) {
			InsertDisk((UBYTE *) buf, 0);
			Delay(30);
			GetUaeConfig(&config);
			print_drive_status();
		    }
		    break;
		case GAD_INSERT_DF1:
		    strcpy(buf, config.df1_name);
		    if (get_string(buf, 255)) {
			InsertDisk((UBYTE *) buf, 1);
			Delay(30);
			GetUaeConfig(&config);
			print_drive_status();
		    }
		    break;
		case GAD_INSERT_DF2:
		    strcpy(buf, config.df2_name);
		    if (get_string(buf, 255)) {
			InsertDisk((UBYTE *) buf, 2);
			Delay(30);
			GetUaeConfig(&config);
			print_drive_status();
		    }
		    break;
		case GAD_INSERT_DF3:
		    strcpy(buf, config.df3_name);
		    if (get_string(buf, 255)) {
			InsertDisk((UBYTE *) buf, 3);
			Delay(30);
			GetUaeConfig(&config);
			print_drive_status();
		    }
		    break;
		case GAD_LANGUAGE:
		    number = config.keyboard;
		    number++;
		    if (number == 5)
			number = 0;
		    ChangeLanguage(number);
		    Delay(30);
		    GetUaeConfig(&config);
		    break;
		case GAD_RESET:
		    ColdReboot();
		    break;
		case GAD_DEBUG:
		    DebugFunc();
		    break;
		default:
		    break;
		}
		break;
	    default:
		break;
	    }
	}
    }
    quit_program(0, "");
    return (0);
}
コード例 #18
0
ファイル: main.c プロジェクト: AsherBond/MondocosmOS
int main(int argc, char *argv[])
{
    const char *input, *source, *output;
    char *title;
    struct Cell_head cellhd;
    GDALDatasetH hDS;
    GDALRasterBandH hBand;
    struct GModule *module;
    struct {
	struct Option *input, *source, *output, *band, *title;
    } parm;
    struct {
	struct Flag *o, *f, *e, *r, *h, *v;
    } flag;
    int min_band, max_band, band;
    struct band_info info;
    int flip;
    struct Ref reference;

    G_gisinit(argv[0]);

    module = G_define_module();
    G_add_keyword(_("raster"));
    G_add_keyword(_("import"));
    G_add_keyword(_("input"));
    G_add_keyword(_("external"));
    module->description =
	_("Links GDAL supported raster data as a pseudo GRASS raster map.");

    parm.input = G_define_standard_option(G_OPT_F_INPUT);
    parm.input->description = _("Name of raster file to be linked");
    parm.input->required = NO;
    parm.input->guisection = _("Input");

    parm.source = G_define_option();
    parm.source->key = "source";
    parm.source->description = _("Name of non-file GDAL data source");
    parm.source->required = NO;
    parm.source->type = TYPE_STRING;
    parm.source->key_desc = "name";
    parm.source->guisection = _("Input");
    
    parm.output = G_define_standard_option(G_OPT_R_OUTPUT);
    
    parm.band = G_define_option();
    parm.band->key = "band";
    parm.band->type = TYPE_INTEGER;
    parm.band->required = NO;
    parm.band->description = _("Band to select (default: all)");
    parm.band->guisection = _("Input");

    parm.title = G_define_option();
    parm.title->key = "title";
    parm.title->key_desc = "phrase";
    parm.title->type = TYPE_STRING;
    parm.title->required = NO;
    parm.title->description = _("Title for resultant raster map");
    parm.title->guisection = _("Metadata");

    flag.f = G_define_flag();
    flag.f->key = 'f';
    flag.f->description = _("List supported formats and exit");
    flag.f->guisection = _("Print");
    flag.f->suppress_required = YES;

    flag.o = G_define_flag();
    flag.o->key = 'o';
    flag.o->description =
	_("Override projection (use location's projection)");

    flag.e = G_define_flag();
    flag.e->key = 'e';
    flag.e->description = _("Extend location extents based on new dataset");

    flag.r = G_define_flag();
    flag.r->key = 'r';
    flag.r->description = _("Require exact range");

    flag.h = G_define_flag();
    flag.h->key = 'h';
    flag.h->description = _("Flip horizontally");

    flag.v = G_define_flag();
    flag.v->key = 'v';
    flag.v->description = _("Flip vertically");

    if (G_parser(argc, argv))
	exit(EXIT_FAILURE);

    GDALAllRegister();

    if (flag.f->answer) {
	list_formats();
	exit(EXIT_SUCCESS);
    }

    input = parm.input->answer;
    source = parm.source->answer;
    output = parm.output->answer;

    flip = 0;
    if (flag.h->answer)
	flip |= FLIP_H;
    if (flag.v->answer)
	flip |= FLIP_V;

    if (parm.title->answer) {
	title = G_store(parm.title->answer);
	G_strip(title);
    }
    else
	title = NULL;

    if (!input && !source)
	G_fatal_error(_("One of options <%s> or <%s> must be given"),
		      parm.input->key, parm.source->key);

    if (input && source)
	G_fatal_error(_("Option <%s> and <%s> are mutually exclusive"),
		      parm.input->key, parm.source->key);
    
    if (input && !G_is_absolute_path(input)) {
	char path[GPATH_MAX];
	getcwd(path, sizeof(path));
	strcat(path, "/");
	strcat(path, input);
	input = G_store(path);
    }

    if (!input)
	input = source;

    hDS = GDALOpen(input, GA_ReadOnly);
    if (hDS == NULL)
	return 1;

    setup_window(&cellhd, hDS, &flip);

    check_projection(&cellhd, hDS, flag.o->answer);

    Rast_set_window(&cellhd);

    if (parm.band->answer)
	min_band = max_band = atoi(parm.band->answer);
    else
	min_band = 1, max_band = GDALGetRasterCount(hDS);

    G_verbose_message(_("Proceeding with import..."));

    if (max_band > min_band) {
	if (I_find_group(output) == 1)
	    G_warning(_("Imagery group <%s> already exists and will be overwritten."), output);
	I_init_group_ref(&reference);
    }

    for (band = min_band; band <= max_band; band++) {
	char *output2, *title2 = NULL;

	G_message(_("Reading band %d of %d..."),
		  band, GDALGetRasterCount( hDS ));

	hBand = GDALGetRasterBand(hDS, band);
	if (!hBand)
	    G_fatal_error(_("Selected band (%d) does not exist"), band);

	if (max_band > min_band) {
	    G_asprintf(&output2, "%s.%d", output, band);
	    if (title)
		G_asprintf(&title2, "%s (band %d)", title, band);
	    G_debug(1, "Adding raster map <%s> to group <%s>", output2, output);
	    I_add_file_to_group_ref(output2, G_mapset(), &reference);
	}
	else {
	    output2 = G_store(output);
	    if (title)
		title2 = G_store(title);
	}

	query_band(hBand, output2, flag.r->answer, &cellhd, &info);
	create_map(input, band, output2, &cellhd, &info, title, flip);

	G_free(output2);
	G_free(title2);
    }

    if (flag.e->answer)
	update_default_window(&cellhd);

    /* Create the imagery group if multiple bands are imported */
    if (max_band > min_band) {
    	I_put_group_ref(output, &reference);
	I_put_group(output);
	G_message(_("Imagery group <%s> created"), output);
    }

    exit(EXIT_SUCCESS);
}
コード例 #19
0
ファイル: main.cpp プロジェクト: VeganPower/VkTest
VkResult init_Vulkan(VkInstance& vk_instance, VkDevice* out_device, DrawCommandBuffer* out_draw_command_buffer, SwapChain* out_swap_chain)
{
    if ((out_device == nullptr) || (out_swap_chain == nullptr))
    {
        return VK_ERROR_INITIALIZATION_FAILED;
    }
    VkApplicationInfo app_info = {};
    app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
    app_info.pNext = nullptr;
    app_info.pApplicationName = "VT Test";
    app_info.applicationVersion = 0x00000001;
    app_info.pEngineName = "Noengine";
    app_info.engineVersion = 0x00;
    app_info.apiVersion = VK_MAKE_VERSION(1, 0, 2);

    std::vector<const char *> enabledExtensions = { VK_KHR_SURFACE_EXTENSION_NAME };
    enabledExtensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);

    VkInstanceCreateInfo instance_info = {};
    instance_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
    instance_info.pNext = nullptr;
    instance_info.flags = 0;
    instance_info.pApplicationInfo = &app_info;
    instance_info.enabledLayerCount = 0;
    instance_info.ppEnabledLayerNames = nullptr;
    instance_info.enabledExtensionCount = static_cast<uint32_t>(enabledExtensions.size());
    instance_info.ppEnabledExtensionNames = enabledExtensions.data();

    VK_THROW(vkCreateInstance(&instance_info, nullptr, &vk_instance)); // Create Vulkan library instance

    out_swap_chain->instance = GetModuleHandle(NULL);
    out_swap_chain->window = setup_window(out_swap_chain->instance, 800, 600, "vk_test");

    uint32_t gpu_count = 0;
    // Get number of available physical devices
    VK_THROW(vkEnumeratePhysicalDevices(vk_instance, &gpu_count, nullptr));
    assert(gpu_count > 0);

    std::vector<VkPhysicalDevice> physicalDevices(gpu_count); // Enumerate devices
    VK_THROW(vkEnumeratePhysicalDevices(vk_instance, &gpu_count, physicalDevices.data()));
    bool surface_created = false;
    VkPhysicalDeviceProperties gpu_properties;
    VkPhysicalDeviceFeatures gpu_feature;
    for (uint32_t gidx = 0; gidx < gpu_count; ++gidx)
    {
        VkPhysicalDevice gpu = physicalDevices[gidx];
        vkGetPhysicalDeviceProperties(gpu, &gpu_properties);
        std::cout << gidx << "Driver Version: " << gpu_properties.driverVersion << "\n";
        std::cout << gidx << "Device Name:    " << gpu_properties.deviceName << "\n";
        std::cout << gidx << "Device Type:    " << gpu_properties.deviceType << "\n";
        std::cout << gidx << "API Version:    " << VK_VERSION_MAJOR(gpu_properties.apiVersion) << "." << VK_VERSION_MINOR(gpu_properties.apiVersion) << "." << VK_VERSION_PATCH(gpu_properties.apiVersion) << "\n";

        // we can choose a gpu based on the features here.
        vkGetPhysicalDeviceFeatures(gpu, &gpu_feature);

        VkResult err = create_surface(vk_instance, gpu, out_device, out_draw_command_buffer, out_swap_chain);
        if (err == VK_SUCCESS)
        {
            surface_created = true;
            break;
        }
    }
    if (!surface_created)
    {
        return VK_ERROR_INITIALIZATION_FAILED;
    }

    return VK_SUCCESS;
}
コード例 #20
0
ファイル: main.c プロジェクト: gfunkmonk2/mate-games
int
main (int argc, char **argv)
{
  GOptionContext *context;
  gboolean retval;
  GError *error = NULL;

  if (!games_runtime_init ("gnibbles"))
    return 1;

#ifdef ENABLE_SETGID
  setgid_io_init ();
#endif

  gtk_clutter_init (&argc, &argv);
  context = g_option_context_new (NULL);

#if GLIB_CHECK_VERSION (2, 12, 0)
  g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
#endif

  g_option_context_add_group (context, gtk_get_option_group (TRUE));

  retval = g_option_context_parse (context, &argc, &argv, &error);
  g_option_context_free (context);
  if (!retval) {
    g_print ("%s", error->message);
    g_error_free (error);
    exit (1);
  }

  g_set_application_name (_("Nibbles"));

  gtk_window_set_default_icon_name ("mate-gnibbles");
  srand (time (NULL));

  highscores = games_scores_new ("gnibbles",
                                 scorecats, G_N_ELEMENTS (scorecats),
                                 "game speed", NULL,
                                 0 /* default category */,
                                 GAMES_SCORES_STYLE_PLAIN_DESCENDING);

  games_conf_initialise ("Gnibbles");
  properties = gnibbles_properties_new ();
  setup_window ();
  gnibbles_load_pixmap (properties->tilesize);
  gnibbles_load_logo (properties->tilesize);

#ifdef GGZ_CLIENT
  network_init ();
  network_gui_update ();
#endif

  gtk_action_set_sensitive (pause_action, FALSE);
  gtk_action_set_sensitive (resume_action, FALSE);
  gtk_action_set_sensitive (end_game_action, FALSE);
  gtk_action_set_visible (resume_action, paused);
  gtk_action_set_visible (new_game_action, !ggz_network_mode);
  gtk_action_set_visible (player_list_action, ggz_network_mode);

  gtk_main ();

  gnibbles_properties_destroy (properties);
  games_conf_shutdown ();

  games_runtime_shutdown ();

  return 0;
}