コード例 #1
0
ファイル: chrome.c プロジェクト: napsy/gsfm
void init_main_window()
{
    struct _view *left_view,
                 *right_view;

    chrome = g_malloc(sizeof(*chrome));
    chrome->views = NULL;
    chrome->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    left_view = create_view();
    right_view = create_view();
    chrome->views = g_list_append(chrome->views, left_view);
    chrome->views = g_list_append(chrome->views, right_view);

    chrome->grid = gtk_grid_new();
    gtk_grid_set_row_homogeneous(GTK_GRID(chrome->grid), TRUE);
    gtk_grid_set_column_homogeneous(GTK_GRID(chrome->grid), TRUE);
    gtk_grid_attach(GTK_GRID(chrome->grid), left_view->view, 0, 0, 1, 1);
    gtk_grid_attach(GTK_GRID(chrome->grid), right_view->view, 1, 0, 1, 1);


    chrome->selected_view = left_view;
    gtk_window_set_title(GTK_WINDOW(chrome->window), "Gtk+ Simple File Manager [gsfm]");
    gtk_window_set_default_size(GTK_WINDOW(chrome->window), 1000, 700);
    gtk_container_add(GTK_CONTAINER(chrome->window), chrome->grid);
    gtk_container_set_border_width(GTK_CONTAINER(chrome->window), 4);

    g_signal_connect(chrome->grid, "button-press-event", G_CALLBACK(window_select_view), NULL);

    install_keyboard_bindings();


    gtk_widget_show_all(chrome->window);
}
コード例 #2
0
ファイル: ui.c プロジェクト: spk121/jahaziel
void ui_init(void)
{
    RAII_VARIABLE(GtkBuilder *, builder, gtk_builder_new(), xgtk_builder_object_unref);
    GError     *error = NULL;

    if(!gtk_builder_add_from_file(builder, UI_FILE, &error))
    {
        g_warning("%s", error->message);
        exit(1);
    }
    ui = g_malloc0_n(1, sizeof(JahUI));
    
    /* Get UI pointers from the Glade file */
    JAH_GET_WIDGET(builder, main_window, ui);
    JAH_GET_WIDGET(builder, connect_dialog, ui);
    JAH_GET_OBJECT(builder, connect_server_combobox_entry, GTK_ENTRY, ui);
    JAH_GET_OBJECT(builder, connect_username_combobox_entry, GTK_ENTRY, ui);
    JAH_GET_OBJECT(builder, statusbar, GTK_STATUSBAR, ui);
    JAH_GET_OBJECT(builder, worker_list_store, GTK_LIST_STORE, ui);
    JAH_GET_OBJECT(builder, call_client_list_view, GTK_TREE_VIEW, ui);

    gtk_builder_connect_signals(builder, NULL);

    gtk_widget_show(ui->main_window);
    
    store = create_store();
    create_view(store, ui->call_client_list_view);
    gtk_widget_show(GTK_WIDGET(ui->call_client_list_view));
}
コード例 #3
0
ファイル: window.c プロジェクト: elechak/blue
static NATIVECALL(view_new){
    Link link = create_view();
    View self = link->value.vptr;
    
    self->fog_parameters[0]=0.0; //Densisty
    self->fog_parameters[1]=0.0; //Start
    self->fog_parameters[2]=0.0; //End

    self->origin = 0;

    //left,  right, bottom, top, near, far
    self->bounds[0] = 0.0;
    self->bounds[1] = 100.0;
    self->bounds[2] = 0.0;
    self->bounds[3] = 100.0;
    self->bounds[4] = 0.0;
    self->bounds[5] = 100.0;

    self->projection = 1;//  0 is Perspective  , 1 is Orthographic

    self->camera_pos = NULL;
    
    BWindow win = This->value.vptr;
    im_append(win->items, link);
    
    return link;
}
コード例 #4
0
ファイル: gfx_test.c プロジェクト: Haifisch/axle
void test_xserv(Screen* vesa_screen) {
	Window* window = create_window(rect_make(point_make(50, 50), size_make(400, 500)));
	window->title = "Color test";
	add_subwindow(vesa_screen->window, window);
	
	Window* label_win = create_window(rect_make(point_make(350, 100), size_make(500, 200)));
	label_win->title = "Text test";
	Label* test_label = create_label(rect_make(point_make(0, 0), label_win->content_view->frame.size), "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque pulvinar dui bibendum nunc convallis, bibendum venenatis mauris ornare. Donec et libero lacus. Nulla tristique auctor pulvinar. Aenean enim elit, malesuada nec dignissim eget, varius ac nunc. Vestibulum varius lectus nisi, in dignissim orci volutpat in. Aliquam eget eros lorem. Quisque tempor est a rhoncus consequat. Quisque vestibulum finibus sapien. Etiam enim sem, vehicula ac lorem vitae, mattis mollis mauris. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus eleifend dui vel nulla suscipit pretium. Suspendisse vel nunc efficitur, lobortis dui convallis, tristique tellus. Ut ut viverra est. Etiam tempor justo risus. Cras laoreet eu sapien et lacinia. Nunc imperdiet blandit purus a semper.");
	add_sublabel(label_win->content_view, test_label);
	add_subwindow(vesa_screen->window, label_win);

	//create evenly spaced subsections
	for (int i = 0; i < 34; i++) {
		double height = window->content_view->frame.size.height / 32;
		View* view = create_view(rect_make(point_make(0, height * i), size_make(window->content_view->frame.size.width, height)));
		add_subview(window->content_view, view);
	}
	for (int i = 0; i < 1000; i++) {
		for (int j = 0; j < window->content_view->subviews->size; j++) {
			View* subview = array_m_lookup(window->content_view->subviews, j);
			set_background_color(subview, color_make(rand() % 256, rand() % 256, rand() % 256));
		}
		sleep(50);
	}
}	
コード例 #5
0
ファイル: chrome.c プロジェクト: napsy/gsfm
void new_view_horizontal(GObject *object, gpointer user_data)
{
    struct _view *view = create_view();
    chrome->views = g_list_append(chrome->views, view);
    gtk_grid_attach_next_to(GTK_GRID(chrome->grid), view->view, chrome->selected_view->view, 
            GTK_POS_RIGHT, 1, 1);
    chrome->selected_view = view;
    gtk_widget_show_all(chrome->grid);
}
コード例 #6
0
ファイル: commandline.c プロジェクト: bsugiarto24/CPE-101
struct view input_view(int argc, char *in[]){
   int i = 0;
   while(strcmp(in[i],"-view")!= 0){
      if(i>=argc-1)
         return create_view(-10,10,-7.5,7.5,1024,768);
      i++;
   }
   double minx = -10;
   double maxx = 10;

   double miny = -7.5;
   double maxy = 7.5;

   int width = 1024;
   int height = 768;

   if(i+1<argc && !equalToFlag(argc,in,i+1))
      minx = convert_double(in[i+1],-10);
   else
         return create_view(minx,maxx,miny,maxy,width,height);

   if(i+2<argc && !equalToFlag(argc,in,i+2))
      maxx = convert_double(in[i+2],10);
   else
         return create_view(minx,maxx,miny,maxy,width,height);

   if(i+3<argc && !equalToFlag(argc,in,i+3))
      miny = convert_double(in[i+3],-7.5);
   else
         return create_view(minx,maxx,miny,maxy,width,height);

   if(i+4<argc && !equalToFlag(argc,in,i+4))
      maxy = convert_double(in[i+4],7.5);
   else
         return create_view(minx,maxx,miny,maxy,width,height);

   if(i+5<argc && !equalToFlag(argc,in,i+5))
      width = convert_double(in[i+5],1024);
   else
         return create_view(minx,maxx,miny,maxy,width,height);

   if(i+6<argc && !equalToFlag(argc,in,i+6))
      height = convert_double(in[i+6],768);
   else
         return create_view(minx,maxx,miny,maxy,width,height);

   return create_view(minx,maxx,miny,maxy,width,height);
}
コード例 #7
0
ファイル: window.c プロジェクト: codyd51/axle
static View* create_content_view(Window* window, bool root) {
	if (!window) return NULL;

	int title_height = 20;
	if (window->title_view) {
		title_height = window->title_view->frame.size.height;
	} if (root) title_height = 0;

	Rect inner_frame = rect_make(point_make((window->border_width * 2), title_height), size_make(window->frame.size.width - (window->border_width * 4), window->frame.size.height - title_height - (window->border_width * 2)));
	View* content_view = create_view(inner_frame);
	content_view->background_color = color_make(255, 255, 255);

	return content_view;
}
コード例 #8
0
ファイル: window.c プロジェクト: codyd51/axle
static View* create_title_view(Window* window) {
	if (!window) return NULL;

	Rect title_view_frame = rect_make(point_make(0, 0), size_make(window->frame.size.width, WINDOW_TITLE_VIEW_HEIGHT));
	View* title_view = create_view(title_view_frame);
	title_view->background_color = window->border_color;

	Button* close_button = create_button(rect_make(point_zero(), size_make(CHAR_WIDTH * 2, title_view->frame.size.height)), "X");
	close_button->mousedown_handler = (event_handler)&close_button_clicked;
	add_button(title_view, close_button);

	Button* minimize_button = create_button(rect_make(point_make(rect_max_x(close_button->frame), 0), size_make(CHAR_WIDTH * 2, title_view->frame.size.height)), "-");
	minimize_button->mousedown_handler = (event_handler)&minimize_button_clicked;
	add_button(title_view, minimize_button);

	//add title label to title view
	int label_length = 20 * CHAR_WIDTH;
	Rect label_frame = rect_make(point_make(rect_max_x(minimize_button->frame) + 15, title_view_frame.size.height / 2 - (CHAR_HEIGHT / 2)), size_make(label_length, CHAR_HEIGHT));
	Label* title_label = create_label(label_frame, window->title);
	title_label->text_color = color_black();
	add_sublabel(title_view, title_label);

	Bmp* dots = create_bmp(title_view_frame, create_layer(title_view_frame.size));
	uint8_t* ref = dots->layer->raw;
	for (int y = 0; y < dots->frame.size.height; y++) {
		for (int x = 0; x < dots->frame.size.width; x++) {
			if (!((x + y) % 2)) {
				*ref++ = 50;
				*ref++ = 50;
				*ref++ = 50;
			}
			else {
				*ref++ = 200;
				*ref++ = 160;
				*ref++ = 90;
			}
		}
	}
	add_bmp(title_view, dots);

	return title_view;
}
コード例 #9
0
ファイル: shell.c プロジェクト: playya/Enlightenment
void
shell_init(void)
{

/*    ecore_display_init(NULL);
    ecore_event_signal_init();
    ecore_event_filter_init();
    ecore_event_x_init();

    ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_EXPOSE,
                                   ecore_window_expose);
    ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_MOVE, ecore_mouse_move);
    ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_CONFIGURE,
                                   ecore_window_configure);
    ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_DOWN, ecore_mouse_down);
    ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_UP, ecore_mouse_up);
    ecore_event_filter_handler_add(ECORE_EVENT_KEY_DOWN, ecore_key_down);
*/
    ecore_idle_enterer_add(ecore_idle, NULL);

    create_view();
    drawing_load();
}
コード例 #10
0
ファイル: mazerunner.c プロジェクト: davidrb/mazerunner
int main(int argc, char *argv[])
{
    /* parse command line args */
    for (int i = 1; i+1 < argc; i+=2) {
	if (strcmp(argv[i], "-m") == 0)
	    mazefile = argv[i+1];

	else if (strcmp(argv[i], "-a") == 0)
	    algfile = argv[i+1];
    }

    /* initialize program */
    if (algfile && !load_algorithm(algfile, &algorithm)) {
	fprintf(stderr, "error loading algorithm\n");
	return 1;
    }

    if (!parse_maze(mazefile, &maze)) {
	fprintf(stderr, "error reading maze file\n");
	return 1;
    }

    view = create_view();

    controller = create_controller(
	&view, &maze, &mouse, &algorithm);

    /* run program */
    while(!controller.quit) {
	do_command( &controller, getchar() );
    }

    /* cleanup */
    view.destroy();

    return 0;
}
コード例 #11
0
ファイル: hvscstilwidget.c プロジェクト: OpenEmu/VICE-Core
/** \brief  Create HVSC STIL widget
 *
 * \return  GtkGrid
 */
GtkWidget *hvsc_stil_widget_create(void)
{
    GtkWidget *grid;
    GtkWidget *label;
    GtkWidget *scroll;


    grid = vice_gtk3_grid_new_spaced(VICE_GTK3_DEFAULT, VICE_GTK3_DEFAULT);

    /* add title label */
    label = gtk_label_new(NULL);
    gtk_widget_set_halign(label, GTK_ALIGN_START);
    gtk_label_set_markup(GTK_LABEL(label), "<b>STIL entry:</b>");
    g_object_set(G_OBJECT(label), "margin-bottom", 16, NULL);

    gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);

    /* add view */
    stil_view = create_view();


    hvsc_stil_widget_create_tags();

    scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_widget_set_vexpand(scroll, TRUE);
    gtk_widget_set_size_request(scroll, 400, 500);
    gtk_widget_set_hexpand(scroll, TRUE);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
            GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_container_add(GTK_CONTAINER(scroll), stil_view);
    gtk_grid_attach(GTK_GRID(grid), scroll, 0, 1, 1, 1);

    gtk_widget_set_vexpand(grid, TRUE);
    gtk_widget_show_all(grid);
    return grid;
}
コード例 #12
0
ファイル: views.c プロジェクト: jens-na/abook-call
char *
add_field_to_view(char *viewname, char *field)
{
	abook_view *v;
	abook_field *f;

	if(
			!(f = find_declared_field(field)) &&
			!(f = find_standard_field(field, 1 /*do_declare*/))
		)
		return _("undeclared field");
	
	if((v = find_view(viewname)) == NULL)
		v = create_view(viewname);
	else if(fields_in_view(v) == MAX_VIEW_FIELDS)
		return _("maximal number of fields per view reached");

	if(v->fields && (find_field(field, v->fields)))
		return _("field already in this view");

	add_field(&v->fields, f);
	
	return NULL;
}
コード例 #13
0
int
main(int argc, char **argv) {
	isc_result_t result;
	isc_logdestination_t destination;

	UNUSED(argc);
	UNUSED(argv);

	dns_result_register();
	result = isc_app_start();
	check_result(result, "isc_app_start()");

	isc_stdtime_get(&now);

	result = isc_mutex_init(&client_lock);
	check_result(result, "isc_mutex_init(&client_lock)");
	ISC_LIST_INIT(clients);

	/*
	 * EVERYTHING needs a memory context.
	 */
	RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);

	cmp = NULL;
	RUNTIME_CHECK(isc_mempool_create(mctx, sizeof(client_t), &cmp)
		      == ISC_R_SUCCESS);
	isc_mempool_setname(cmp, "adb test clients");

	result = isc_entropy_create(mctx, &ectx);
	check_result(result, "isc_entropy_create()");
	result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
	check_result(result, "isc_hash_create()");

	result = isc_log_create(mctx, &lctx, &lcfg);
	check_result(result, "isc_log_create()");
	isc_log_setcontext(lctx);
	dns_log_init(lctx);
	dns_log_setcontext(lctx);

	/*
	 * Create and install the default channel.
	 */
	destination.file.stream = stderr;
	destination.file.name = NULL;
	destination.file.versions = ISC_LOG_ROLLNEVER;
	destination.file.maximum_size = 0;
	result = isc_log_createchannel(lcfg, "_default",
				       ISC_LOG_TOFILEDESC,
				       ISC_LOG_DYNAMIC,
				       &destination, ISC_LOG_PRINTTIME);
	check_result(result, "isc_log_createchannel()");
	result = isc_log_usechannel(lcfg, "_default", NULL, NULL);
	check_result(result, "isc_log_usechannel()");

	/*
	 * Set the initial debug level.
	 */
	isc_log_setdebuglevel(lctx, 2);

	create_managers();

	t1 = NULL;
	result = isc_task_create(taskmgr, 0, &t1);
	check_result(result, "isc_task_create t1");
	t2 = NULL;
	result = isc_task_create(taskmgr, 0, &t2);
	check_result(result, "isc_task_create t2");

	printf("task 1 = %p\n", t1);
	printf("task 2 = %p\n", t2);

	create_view();

	adb = view->adb;

	/*
	 * Lock the entire client list here.  This will cause all events
	 * for found names to block as well.
	 */
	CLOCK();
	lookup("f.root-servers.net.");		/* Should be in hints */
	lookup("www.iengines.com");		/* should fetch */
	lookup("www.isc.org");			/* should fetch */
	lookup("www.flame.org");		/* should fetch */
	lookup("kechara.flame.org.");		/* should fetch */
	lookup("moghedien.flame.org.");		/* should fetch */
	lookup("mailrelay.flame.org.");		/* should fetch */
	lookup("ipv4v6.flame.org.");		/* should fetch */
	lookup("nonexistant.flame.org.");	/* should fail to be found */
	lookup("foobar.badns.flame.org.");	/* should fail utterly (NS) */
	lookup("i.root-servers.net.");		/* Should be in hints */
	lookup("www.firstcard.com.");
	lookup("dns04.flame.org.");
	CUNLOCK();

	sleep(10);

	dns_adb_dump(adb, stderr);

	sleep(10);

	CLOCK();
	lookup("f.root-servers.net.");		/* Should be in hints */
	lookup("www.iengines.com");		/* should fetch */
	lookup("www.isc.org");			/* should fetch */
	lookup("www.flame.org");		/* should fetch */
	lookup("kechara.flame.org.");		/* should fetch */
	lookup("moghedien.flame.org.");		/* should fetch */
	lookup("mailrelay.flame.org.");		/* should fetch */
	lookup("ipv4v6.flame.org.");		/* should fetch */
	lookup("nonexistant.flame.org.");	/* should fail to be found */
	lookup("foobar.badns.flame.org.");	/* should fail utterly (NS) */
	lookup("i.root-servers.net.");		/* Should be in hints */
	CUNLOCK();

	sleep(20);

	dns_adb_dump(adb, stderr);

	isc_task_detach(&t1);
	isc_task_detach(&t2);

	isc_mem_stats(mctx, stdout);
	dns_adb_dump(adb, stderr);

	isc_app_run();

	dns_adb_dump(adb, stderr);

	dns_view_detach(&view);
	adb = NULL;

	fprintf(stderr, "Destroying socket manager\n");
	isc_socketmgr_destroy(&socketmgr);
	fprintf(stderr, "Destroying timer manager\n");
	isc_timermgr_destroy(&timermgr);

	fprintf(stderr, "Destroying task manager\n");
	isc_taskmgr_destroy(&taskmgr);

	isc_log_destroy(&lctx);

	isc_hash_destroy();
	isc_entropy_detach(&ectx);

	isc_mempool_destroy(&cmp);
	isc_mem_stats(mctx, stdout);
	isc_mem_destroy(&mctx);

	isc_app_finish();

	return (0);
}
コード例 #14
0
ファイル: multi_acc.cpp プロジェクト: scchan/hcc_blogs
int main() {

  constexpr int N = 1024 * 1024 * 256;
  constexpr float a = 100.0f;

  std::vector<float> host_x(N);
  std::vector<float> host_y(N);

  // initialize the input data
  std::default_random_engine random_gen;
  std::uniform_real_distribution<float> distribution(-N, N);
  std::generate(host_x.begin(), host_x.end(), [&]() { return distribution(random_gen); });
  std::generate(host_y.begin(), host_y.end(), [&]() { return distribution(random_gen); });

  // CPU implementation of saxpy
  std::vector<float> host_result_y(N);
  for (int i = 0; i < N; i++) {
    host_result_y[i] = a * host_x[i] + host_y[i];
  }
  
  std::vector<hc::accelerator> all_accelerators = hc::accelerator::get_all();
  std::vector<hc::accelerator> accelerators;
  for (auto a = all_accelerators.begin(); a != all_accelerators.end(); a++) {

    // only pick accelerators supported by the HSA runtime
    if (a->is_hsa_accelerator()) {
      accelerators.push_back(*a);
    }
  }

  constexpr int numViewPerAcc = 2;
  int numSaxpyPerView = N/(accelerators.size() * numViewPerAcc);

  std::vector<hc::accelerator_view> acc_views;
  std::vector<hc::array_view<float,1>> x_views;
  std::vector<hc::array_view<float,1>> y_views;
  std::vector<hc::completion_future> futures;

  int dataCursor = 0;
  for (auto acc = accelerators.begin(); acc != accelerators.end(); acc++) {
    for (int i = 0; i < numViewPerAcc; i++) {

      // create a new accelerator_view
      acc_views.push_back(acc->create_view());

      // create array_views that only covers the data portion needed by this accelerator_view
      x_views.push_back(hc::array_view<float,1>(numSaxpyPerView, host_x.data() + dataCursor));
      y_views.push_back(hc::array_view<float,1>(numSaxpyPerView, host_y.data() + dataCursor));
      dataCursor+=numSaxpyPerView;


      auto& x_av = x_views.back();
      auto& y_av = y_views.back();
      hc::completion_future f;
      f = hc::parallel_for_each(acc_views.back(), x_av.get_extent()
                            , [=](hc::index<1> i) [[hc]] {
        y_av[i] = a * x_av[i] + y_av[i];
      });
      futures.push_back(f);


      //printf("dataCursor: %d\n",dataCursor);
    }
  }

  // If N is not a multiple of the number of acc_views,
  // calculate the remaining saxpy on the host
  for (; dataCursor!=N; dataCursor++) {
    host_y[dataCursor] = a * host_x[dataCursor] + host_y[dataCursor];
  }

  // synchronize all the results back to the host
  for(auto v = y_views.begin(); v != y_views.end(); v++) {
    v->synchronize();
  }
  
  // verify the results
  int errors = 0;
  for (int i = 0; i < N; i++) {
    if (fabs(host_y[i] - host_result_y[i]) > fabs(host_result_y[i] * 0.0001f))
      errors++;
  }
  std::cout << errors << " errors" << std::endl;

  return errors;
}
コード例 #15
0
ファイル: calculator.c プロジェクト: codyd51/axle
void calculator_xserv(Point origin) {
	Size button_size = size_make(60, 60);
	int result_view_height = 50;
	int button_spacing = 0;

	//width is button_size * 4 because 3 rows of # buttons + 1 row of operators
	Window* calc_win = create_window(rect_make(origin, size_make(button_size.width * 4, WINDOW_TITLE_VIEW_HEIGHT + result_view_height + button_spacing + (button_size.height * 4))));
	calc_win->title = "Calculator";

	//number display
	View* label_view = create_view(rect_make(point_zero(), size_make(calc_win->frame.size.width, result_view_height)));
	result_label = create_label(rect_make(point_make(10, 10), label_view->frame.size), "0");
	label_view->background_color = color_white();
	add_sublabel(label_view, result_label);
	add_subview(calc_win->content_view, label_view);

	View* button_view = create_view(rect_make(point_make(0, rect_max_y(label_view->frame)), size_make(calc_win->frame.size.width, calc_win->frame.size.height - label_view->frame.size.height)));
	button_view->background_color = color_make(200, 200, 255);
	add_subview(calc_win->content_view, button_view);

	//number buttons 1-9
	for (int col = 0; col < 3; col++) {
		for (int row = 2; row >= 0; row--) {
			int val = ((3 - col) * 3) + row - 2;
			char title[32];
			itoa(val, (char*)&title);

			Button* b = create_button(rect_make(point_make((row * button_size.width) + button_spacing, (col * button_size.height) + button_spacing), button_size), title);
			b->mousedown_handler = (event_handler)&calc_num_click;
			add_button(button_view, b);
		}
	}
	//3 * button spacing to account for above buttons
	Button* zero = create_button(rect_make(point_make(button_spacing, 3 * button_size.height + button_spacing), size_make(button_size.width * 2, button_size.height)), "0");
	zero->mousedown_handler = (event_handler)&calc_num_click;
	add_button(button_view, zero);

	Button* equals = create_button(rect_make(point_make(rect_max_x(zero->frame), 3 * button_size.height + button_spacing), size_make(button_size.width, button_size.height)), "=");
	equals->mousedown_handler = (event_handler)&calc_op_click;
	add_button(button_view, equals);
	
	//operator buttons
	for (int i = 0; i < 4; i++){
		char* title;
		switch (i) {
			case 0:
				title = "/";
				break;
			case 1:
				title = "X";
				break;
			case 2:
				title = "-";
				break;
			case 3:
			default:
				title = "+";
				break;
		}
		Button* b = create_button(rect_make(point_make((3 * button_size.width) + button_spacing, button_size.height * i + button_spacing), button_size), title);
		b->mousedown_handler = (event_handler)&calc_op_click;
		add_button(button_view, b);
	}

	present_window(calc_win);
}
コード例 #16
0
 //---------------------------------------------------------------------
 void deallocate()
 {
   Base::deallocate();
   _view = create_view(Base::data());
 }
コード例 #17
0
    //---------------------------------------------------------------------
    template<typename CTYPE> void allocate(const CTYPE &shape)
    {
      Base::template allocate(shape);

      _view = create_view(Base::data());
    }
コード例 #18
0
 ViewBenchmarkData(const CTYPE &shape):
 ArrayBenchmarkData<ATYPE>(shape),
 _view(create_view(ArrayBenchmarkData<ATYPE>::data()))
 {
 }
コード例 #19
0
ファイル: gui.c プロジェクト: pterjan/cardpeek-navigo
int gui_create(application_callback_t run_script_cb,
	       application_callback_t run_command_cb)
{
  GtkWidget *view;
  GtkWidget *text;
  GtkWidget *vpaned;
  GtkWidget *vbox;
  GtkWidget *entry;
  GtkWidget *frame1;
  GtkWidget *frame2;
  GtkWidget *status;
  GtkWidget *menu;

  RUN_LUA_SCRIPT = run_script_cb;
  RUN_LUA_COMMAND = run_command_cb;

  MAIN_WINDOW = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(MAIN_WINDOW),600,400);
  gtk_container_set_border_width (GTK_CONTAINER (MAIN_WINDOW), 0);
  g_signal_connect (MAIN_WINDOW, "delete_event", gtk_main_quit, NULL); /* dirty */
  
  CARDTREE = cardtree_new();

  vbox = gtk_vbox_new (FALSE, 0);

  vpaned = gtk_vpaned_new ();

  view = create_view (CARDTREE);
  frame1 = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type(GTK_FRAME(frame1),GTK_SHADOW_ETCHED_IN);
  gtk_container_add (GTK_CONTAINER(frame1),view);
  gtk_paned_add1 (GTK_PANED (vpaned), frame1);
   
  text = create_text ();
  SCROLL_TEXT = GTK_SCROLLED_WINDOW(text);
  frame2 = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type(GTK_FRAME(frame2),GTK_SHADOW_ETCHED_IN);
  gtk_container_add (GTK_CONTAINER(frame2),text);
  gtk_paned_add2 (GTK_PANED (vpaned), frame2);

  log_activate(gui_logfunction);

  entry = create_command_entry ();

  status = gtk_statusbar_new ();
  
  menu = create_menubar(MAIN_WINDOW);

  gtk_box_pack_start (GTK_BOX (vbox), menu, FALSE, TRUE, 0);

  gtk_box_pack_start (GTK_BOX (vbox), vpaned, TRUE, TRUE, 0);

  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, TRUE, 0);

  gtk_box_pack_start (GTK_BOX (vbox), status, FALSE, TRUE, 0);

  gtk_container_add (GTK_CONTAINER (MAIN_WINDOW), vbox);

  gtk_widget_show_all (MAIN_WINDOW);

  /*gtk_widget_size_request(vpaned,&requisition);*/

  gtk_paned_set_position(GTK_PANED (vpaned), 256);


  return 1;
}
コード例 #20
0
ファイル: view.c プロジェクト: mrirecon/view
extern struct view_s* window_new(const char* name, long* pos, const long dims[DIMS], const complex float* x)
{
	struct view_s* v = create_view(name, pos, dims, x);

	GtkBuilder* builder = gtk_builder_new();
	// gtk_builder_add_from_file(builder, "viewer.ui", NULL);
	gtk_builder_add_from_string(builder, viewer_gui, -1, NULL);

	v->gtk_drawingarea = GTK_WIDGET(gtk_builder_get_object(builder, "drawingarea1"));
	v->gtk_viewport = GTK_WIDGET(gtk_builder_get_object(builder, "scrolledwindow1"));

	v->gtk_winlow = GTK_ADJUSTMENT(gtk_builder_get_object(builder, "winlow"));
	v->gtk_winhigh = GTK_ADJUSTMENT(gtk_builder_get_object(builder, "winhigh"));

	v->gtk_entry = GTK_ENTRY(gtk_builder_get_object(builder, "entry"));
	PangoFontDescription* desc = pango_font_description_new();
	pango_font_description_set_family(desc, "mono");
	pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
	pango_font_description_set_absolute_size(desc, 10 * PANGO_SCALE);
	gtk_widget_override_font(GTK_WIDGET(v->gtk_entry), desc);
	pango_font_description_free(desc);

	v->gtk_zoom = GTK_ADJUSTMENT(gtk_builder_get_object(builder, "zoom"));
	v->gtk_aniso = GTK_ADJUSTMENT(gtk_builder_get_object(builder, "aniso"));

	v->gtk_mode = GTK_COMBO_BOX(gtk_builder_get_object(builder, "mode"));
	gtk_combo_box_set_active(v->gtk_mode, 0);

	v->gtk_flip = GTK_COMBO_BOX(gtk_builder_get_object(builder, "flip"));
	gtk_combo_box_set_active(v->gtk_flip, 0);

	v->gtk_transpose = GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(builder, "transpose"));

	for (int j = 0; j < DIMS; j++) {

		char pname[10];
		snprintf(pname, 10, "pos%02d", j);
		v->gtk_posall[j] = GTK_ADJUSTMENT(gtk_builder_get_object(builder, pname));
		gtk_adjustment_set_upper(v->gtk_posall[j], v->dims[j] - 1);
		gtk_adjustment_set_value(v->gtk_posall[j], 0);

		snprintf(pname, 10, "check%02d", j);
		v->gtk_checkall[j] = GTK_CHECK_BUTTON(gtk_builder_get_object(builder, pname));
	}

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(v->gtk_checkall[v->xdim]), TRUE);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(v->gtk_checkall[v->ydim]), TRUE);

	gtk_builder_connect_signals(builder, v);

	GtkWindow* window = GTK_WINDOW(gtk_builder_get_object(builder, "window1"));
	g_object_unref(G_OBJECT(builder));

	gtk_window_set_title(window, name);

	gtk_widget_show(GTK_WIDGET(window));

	nr_windows++;

	refresh_callback(NULL, v);
	geom_callback(NULL, v);
	window_callback(NULL, v);

	return v;
}