Exemplo n.º 1
0
void EClassTree::populateWindow() {
	// Create the overall vbox
	_dialogVBox = gtk_vbox_new(FALSE, 12);
	gtk_container_add(GTK_CONTAINER(getWindow()), _dialogVBox);
	
	GtkWidget* paned = gtk_hpaned_new();
	gtk_box_pack_start(GTK_BOX(_dialogVBox), paned, TRUE, TRUE, 0);
	
	// Pack tree view
	gtk_paned_add1(GTK_PANED(paned), createEClassTreeView());
	
	// Pack spawnarg treeview
	gtk_paned_add2(GTK_PANED(paned), GTK_WIDGET(createPropertyTreeView()));
	
	// Pack in dialog buttons
	gtk_box_pack_start(GTK_BOX(_dialogVBox), createButtons(), FALSE, FALSE, 0);
	
	// Set the default size of the window
	GtkWindow* mainWindow = GlobalMainFrame().getTopLevelWindow();
	GdkRectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(mainWindow);
	gtk_window_set_default_size(
		GTK_WINDOW(getWindow()), gint(rect.width * 0.8f), gint(rect.height * 0.8f)
	);

	gtk_paned_set_position(GTK_PANED(paned), static_cast<gint>(rect.width * 0.25f));
}
Exemplo n.º 2
0
	ParticleEditor::ParticleEditor () :
		_widget(gtk_window_new(GTK_WINDOW_TOPLEVEL))
	{
		// Window properties
		gtk_window_set_transient_for(GTK_WINDOW(_widget), GlobalRadiant().getMainWindow());
		gtk_window_set_modal(GTK_WINDOW(_widget), TRUE);
		gtk_window_set_title(GTK_WINDOW(_widget), PARTICLEEDITOR_TITLE);
		gtk_window_set_position(GTK_WINDOW(_widget), GTK_WIN_POS_CENTER_ON_PARENT);

		// Set the default size of the window
		GdkScreen* scr = gtk_window_get_screen(GTK_WINDOW(_widget));
		gint w = gdk_screen_get_width(scr);
		gint h = gdk_screen_get_height(scr);

		gtk_window_set_default_size(GTK_WINDOW(_widget), gint(w * 0.75), gint(h * 0.8));

		// Create the model preview widget
		gint glSize = gint(h * 0.4);
		_particlePreview.setSize(glSize);

		// Signals
		//g_signal_connect(G_OBJECT(_widget), "delete_event", G_CALLBACK(callbackHide), this);

		// Main window contains a VBox
		GtkWidget* vbx = gtk_vbox_new(FALSE, 3);
		gtk_box_pack_start(GTK_BOX(vbx), createPreviewPanel(), FALSE, FALSE, 0);
		gtk_box_pack_end(GTK_BOX(vbx), createButtons(), FALSE, FALSE, 0);
		gtk_container_add(GTK_CONTAINER(_widget), vbx);
	}
/**
 * Handle eraser event: "Delete Stroke" and "Standard", Whiteout is not handled here
 */
void EraseHandler::erase(double x, double y)
{
	XOJ_CHECK_TYPE(EraseHandler);

	this->halfEraserSize = this->handler->getThickness();
	GdkRectangle eraserRect = {
		gint(x - halfEraserSize),
		gint(y - halfEraserSize),
		gint(halfEraserSize * 2),
		gint(halfEraserSize * 2)
	};

	Range* range = new Range(x, y);

	Layer* l = page->getSelectedLayer();

	ElementVector tmp(*l->getElements());
	for (Element* e : tmp)
	{
		if (e->getType() == ELEMENT_STROKE && e->intersectsArea(&eraserRect))
		{
			eraseStroke(l, (Stroke*) e, x, y, range);
		}
	}

	this->view->rerenderRange(*range);
	delete range;
}
Exemplo n.º 4
0
	ModelSelector::ModelSelector () :
		_widget(gtk_window_new(GTK_WINDOW_TOPLEVEL)), _treeStore(gtk_tree_store_new(N_COLUMNS, G_TYPE_STRING,
				G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_PIXBUF)), _infoStore(gtk_list_store_new(2,
				G_TYPE_STRING, G_TYPE_STRING)), _lastModel(""), _lastSkin(-1)
	{
		// Window properties
		gtk_window_set_transient_for(GTK_WINDOW(_widget), GlobalRadiant().getMainWindow());
		gtk_window_set_modal(GTK_WINDOW(_widget), TRUE);
		gtk_window_set_title(GTK_WINDOW(_widget), MODELSELECTOR_TITLE);
		gtk_window_set_position(GTK_WINDOW(_widget), GTK_WIN_POS_CENTER_ON_PARENT);

		// Set the default size of the window
		GtkWindow* mainWindow = GlobalRadiant().getMainWindow();
		gint w;
		gint h;
		gtk_window_get_size(mainWindow,&w,&h);

		gtk_window_set_default_size(GTK_WINDOW(_widget), gint(w * 0.75), gint(h * 0.8));

		// Create the model preview widget
		float previewHeightFactor = GlobalRegistry().getFloat("user/ui/ModelSelector/previewSizeFactor");
		gint glSize = gint(h * previewHeightFactor);
		_modelPreview.setSize(glSize);

		// Signals
		g_signal_connect(G_OBJECT(_widget), "delete_event", G_CALLBACK(callbackHide), this);

		// Main window contains a VBox
		GtkWidget* vbx = gtk_vbox_new(FALSE, 3);
		gtk_box_pack_start(GTK_BOX(vbx), createTreeView(), TRUE, TRUE, 0);
		gtk_box_pack_start(GTK_BOX(vbx), createPreviewAndInfoPanel(), FALSE, FALSE, 0);
		gtk_box_pack_end(GTK_BOX(vbx), createButtons(), FALSE, FALSE, 0);
		gtk_container_add(GTK_CONTAINER(_widget), vbx);
	}
Exemplo n.º 5
0
bool Element::intersectsArea(const GdkRectangle* src)
{
	XOJ_CHECK_TYPE(Element);

	GdkRectangle rect = {
		gint(getX()),
		gint(getY()),
		gint(getElementWidth()),
		gint(getElementHeight())
	};

	return gdk_rectangle_intersect(src, &rect, NULL);
}
Exemplo n.º 6
0
int main(int argc, char *argv[])
{
    int n = gint(), i, x, y;
    long long int a[2020], dp[2020];
    for (i = 0; i < n; ++i){
        a[i] = gint();
        dp[i] = a[i] * n;
    }
    for (x = n - 1; x > 0; --x)
        for(y = 0; y < x; ++y)
            dp[y] = (((dp[y] + x*a[y + n - x]) > (dp[y + 1] + x*a[y])) ? (dp[y] + x*a[y + n - x]) : (dp[y + 1] + x*a[y]));
    pint(dp[0]);
    return 0;
}
Exemplo n.º 7
0
	UMPEditor::UMPEditor (const std::string& umpName)
	{
		_view.setUMPFile(umpName);
		_dialog = gtk_dialog_new_with_buttons(_("UMP Definition"), GlobalRadiant().getMainWindow(),
				GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK,
				GTK_RESPONSE_ACCEPT, NULL);

		gtk_dialog_set_default_response(GTK_DIALOG(_dialog), GTK_RESPONSE_ACCEPT);

		gtk_container_set_border_width(GTK_CONTAINER(_dialog), 12);

		gtk_container_add(GTK_CONTAINER(GTK_DIALOG(_dialog)->vbox), _view.getWidget());

		GdkRectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalRadiant().getMainWindow());
		gtk_window_set_default_size(GTK_WINDOW(_dialog), gint(rect.width / 2), gint(2 * rect.height / 3));
	}
Exemplo n.º 8
0
static gboolean
plugin_check_version(GModule *module)
{
	gint (*version_check)(gint) = NULL;

	g_module_symbol(module, "plugin_version_check", (void *) &version_check);

	if (G_UNLIKELY(! version_check))
	{
		geany_debug("Plugin \"%s\" has no plugin_version_check() function - ignoring plugin!",
				g_module_name(module));
		return FALSE;
	}
	else
	{
		gint result = version_check(GEANY_ABI_VERSION);

		if (result < 0)
		{
			msgwin_status_add(_("The plugin \"%s\" is not binary compatible with this "
				"release of Geany - please recompile it."), g_module_name(module));
			geany_debug("Plugin \"%s\" is not binary compatible with this "
				"release of Geany - recompile it.", g_module_name(module));
			return FALSE;
		}
		if (result > GEANY_API_VERSION)
		{
			geany_debug("Plugin \"%s\" requires a newer version of Geany (API >= v%d).",
				g_module_name(module), result);
			return FALSE;
		}
	}
	return TRUE;
}
Exemplo n.º 9
0
void
st_methods_ptr(void)
{
  useclass(Counter);
  usegeneric((gincr)gincr_s,
             (gincrBy1)gincrBy1_s, (gincrBy2)gincrBy2_s, (gincrBy3)gincrBy3_s,
             (gincrBy4)gincrBy4_s, (gincrBy5)gincrBy5_s);

  OBJ cnt = gnew(Counter);
  OBJ ret;

  IMP1 gincr_p    = cos_method_lookup1((SEL)gincr_s   , cos_object_id(cnt));
  IMP1 gincrBy1_p = cos_method_lookup1((SEL)gincrBy1_s, cos_object_id(cnt));
  IMP1 gincrBy2_p = cos_method_lookup1((SEL)gincrBy2_s, cos_object_id(cnt));
  IMP1 gincrBy3_p = cos_method_lookup1((SEL)gincrBy3_s, cos_object_id(cnt));
  IMP1 gincrBy4_p = cos_method_lookup1((SEL)gincrBy4_s, cos_object_id(cnt));
  IMP1 gincrBy5_p = cos_method_lookup1((SEL)gincrBy5_s, cos_object_id(cnt));

  gincrBy1_arg_t arg1 = { 1 };
  gincrBy2_arg_t arg2 = { 1,1 };
  gincrBy3_arg_t arg3 = { 1,1,1 };
  gincrBy4_arg_t arg4 = { 1,1,1,1 };
  gincrBy5_arg_t arg5 = { 1,1,1,1,1 };

  STEST( "method pointer (0 argument )", N, gincr_p   ((SEL)gincr_s   ,cnt,0    ,&ret) );
  STEST( "method pointer (1 argument )", N, gincrBy1_p((SEL)gincrBy1_s,cnt,&arg1,&ret) );
  STEST( "method pointer (2 arguments)", N, gincrBy2_p((SEL)gincrBy2_s,cnt,&arg2,&ret) );
  STEST( "method pointer (3 arguments)", N, gincrBy3_p((SEL)gincrBy3_s,cnt,&arg3,&ret) );
  STEST( "method pointer (4 arguments)", N, gincrBy4_p((SEL)gincrBy4_s,cnt,&arg4,&ret) );
  STEST( "method pointer (5 arguments)", N, gincrBy5_p((SEL)gincrBy5_s,cnt,&arg5,&ret) );
  
  test_assert( gint(cnt) == N+N+2*N+3*N+4*N+5*N );

  grelease(cnt);
}
Exemplo n.º 10
0
void
st_multimethods_ptr(void)
{
  useclass(Counter);
  usegeneric((gaddTo1)gaddTo1_s, (gaddTo2)gaddTo2_s,
             (gaddTo3)gaddTo3_s, (gaddTo4)gaddTo4_s);

  OBJ cnt = gnew(Counter);
  OBJ one = gincr(gnew(Counter));
  OBJ ret;

  U32 cid = cos_object_id(cnt);
  U32 oid = cos_object_id(one);

  IMP2 gaddTo1_p = cos_method_lookup2((SEL)gaddTo1_s, cid, oid);
  IMP3 gaddTo2_p = cos_method_lookup3((SEL)gaddTo2_s, cid, oid, oid);
  IMP4 gaddTo3_p = cos_method_lookup4((SEL)gaddTo3_s, cid, oid, oid, oid);
  IMP5 gaddTo4_p = cos_method_lookup5((SEL)gaddTo4_s, cid, oid, oid, oid, oid);

  STEST( "multimethod pointer (rank 2)", N, gaddTo1_p((SEL)gaddTo1_s,cnt,one,0,&ret) );
  STEST( "multimethod pointer (rank 3)", N, gaddTo2_p((SEL)gaddTo2_s,cnt,one,one,0,&ret) );
  STEST( "multimethod pointer (rank 4)", N, gaddTo3_p((SEL)gaddTo3_s,cnt,one,one,one,0,&ret) );
  STEST( "multimethod pointer (rank 5)", N, gaddTo4_p((SEL)gaddTo4_s,cnt,one,one,one,one,0,&ret) );
  
  test_assert( gint(cnt) == N+2*N+3*N+4*N );

  grelease(cnt);
  grelease(one);
}
Exemplo n.º 11
0
    int
    DDS_Dissector::dissect ()
    {

      gint offset = 0;

      col_set_str(pinfo_->cinfo, COL_PROTOCOL, "OpenDDS");

      col_clear(pinfo_->cinfo, COL_INFO);

      TransportHeader trans =
        demarshal_data<TransportHeader>(tvb_, offset);
      std::string trans_str(format(trans));

      col_add_fstr(pinfo_->cinfo, COL_INFO, "DCPS %s", trans_str.c_str());

      if (tree_ != NULL) {
        proto_item* item =
          proto_tree_add_protocol_format(tree_,
                                         proto_opendds, tvb_, 0, -1,
                                         "OpenDDS DCPS Protocol, %s",
                                         trans_str.c_str());

        proto_tree* trans_tree =
          proto_item_add_subtree(item, ett_trans_header);

        this->dissect_transport_header (trans_tree, trans, offset);

        while (offset < gint(tvb_length(tvb_)))
          {
            DataSampleHeader sample =
              demarshal_data<DataSampleHeader>(tvb_, offset);

            std::string sample_str(format(sample));

            proto_item* item =
              proto_tree_add_none_format
              (trans_tree, hf_sample, tvb_, offset,
               static_cast<gint>(sample.marshaled_size()) +
               sample.message_length_,
               "%s",
               sample_str.c_str()
               );

            proto_tree* sample_tree =
              proto_item_add_subtree(item, ett_sample_header);
            this->dissect_sample_header (sample_tree, sample, offset);

            sample_tree = proto_item_add_subtree (item, ett_sample_header);
            this->dissect_sample_payload (sample_tree, sample, offset);

          }
      }
      return offset;
    }
Exemplo n.º 12
0
Arquivo: main.c Projeto: zhuyadong/COS
int main(int argc, char **argv)
{
	cos_init();
	{
		OBJ map = aMap();
		I32 count = argc < 2 ? 33 : atoi(argv[1]);
		for (U32 i=0; i<count; ++i) {
			gputAt(map, aInt(i), aInt(i));
		}
		for (U32 i=0; i<count; i+=2) {
			gputAt(map, aInt(i), aInt(999999));
		}
		{
			I32 i555 = gint(ggetAt(map, aInt(30)));
			I32 i556 = gint(ggetAt(map, aInt(31)));
			printf("555=%d 556=%d\n", i555, i556);
		}
	}
	return 0;
}
Exemplo n.º 13
0
int main(int argc, char *argv[])
{
    int primes[168] = {
        2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
        73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151,
        157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233,
        239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317,
        331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419,
        421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503,
        509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607,
        613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
        709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811,
        821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911,
        919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997
    };
    int t = gint();
    int i, a, b, gcd, ans, tmp;
    while(t--){
        a = gint();
        b = gint();
        gcd = euclid_gcd(a, b);
        ans = 1;
        for (i = 0; i < 168; ++i)
        {
            if (gcd <= 1)
                break;
            tmp = 0;
            while(!(gcd % primes[i])){
                gcd /= primes[i];
                tmp++;
            }
            ans *= tmp + 1;
        }
        if(gcd > 1)
            ans *= 2;
        pint(ans);
        putchar_unlocked('\n');
    }
    return 0;
}
Exemplo n.º 14
0
/* callback for when tabs switch */
static void tab_switch(gboolean b, struct window *w) {
  gint(current) = gtk_notebook_get_current_page(GTK_NOTEBOOK(w->notebook));
  if(b) {
    if (current == gtk_notebook_get_n_pages(GTK_NOTEBOOK(w->notebook)) -1 ) {
      current = 0;
    } else {
      current = current + 1;
    }
  } else {
    if (current == 0) {
      current = gtk_notebook_get_n_pages(GTK_NOTEBOOK(w->notebook)) - 1;
    } else {
      current = current -1;
    }
  }
  gtk_notebook_set_current_page(GTK_NOTEBOOK(w->notebook), current);
}
Exemplo n.º 15
0
void
st_multimethods(void)
{
  useclass(Counter);

  OBJ cnt = gnew(Counter);
  OBJ one = gincr(gnew(Counter));

  STEST( "multimethod (rank 2)", N, gaddTo1(cnt,one) );
  STEST( "multimethod (rank 3)", N, gaddTo2(cnt,one,one) );
  STEST( "multimethod (rank 4)", N, gaddTo3(cnt,one,one,one) );
  STEST( "multimethod (rank 5)", N, gaddTo4(cnt,one,one,one,one) );
  
  test_assert( gint(cnt) == N+2*N+3*N+4*N );
  grelease(cnt);
  grelease(one);
}
Exemplo n.º 16
0
void
st_nextmethods(void)
{
  enum { P = N/2 };
  useclass(MilliCounter);

  OBJ cnt = gnew(MilliCounter);

  STEST( "method + next method (0 argument )", P, gincr(cnt) );
  STEST( "method + next method (1 argument )", P, gincrBy1(cnt,1) );
  STEST( "method + next method (2 arguments)", P, gincrBy2(cnt,1,1) );
  STEST( "method + next method (3 arguments)", P, gincrBy3(cnt,1,1,1) );
  STEST( "method + next method (4 arguments)", P, gincrBy4(cnt,1,1,1,1) );
  STEST( "method + next method (5 arguments)", P, gincrBy5(cnt,1,1,1,1,1) );
  
  test_assert( gint(cnt) == P+P+2*P+3*P+4*P+5*P );
  grelease(cnt);
}
Exemplo n.º 17
0
void
st_methods(void)
{
  useclass(Counter);

  OBJ cnt = gnew(Counter);

  STEST( "method (0 argument )", N, gincr(cnt) );
  STEST( "method (1 argument )", N, gincrBy1(cnt,1) );
  STEST( "method (2 arguments)", N, gincrBy2(cnt,1,1) );
  STEST( "method (3 arguments)", N, gincrBy3(cnt,1,1,1) );
  STEST( "method (4 arguments)", N, gincrBy4(cnt,1,1,1,1) );
  STEST( "method (5 arguments)", N, gincrBy5(cnt,1,1,1,1,1) );
  
  test_assert( gint(cnt) == N+N+2*N+3*N+4*N+5*N );

  grelease(cnt);
}
Exemplo n.º 18
0
int main()
{
	bitcheck( 64 );
	bitcheck( 108 ); // 64 + 32 + 8 + 4
	bitcheck( 132 ); // 128 + 4
	bitcheck( 323 ); // (256) + 64 + 2 + 1

	printf("0x12345678 & 0xff = %x\n", (0x12345678 & 0xff) );

	std::vector < uchar > uc_vec(4);
	uc_vec[0] = 0x87;
	uc_vec[1] = 0x65;
	uc_vec[2] = 0x43;
	uc_vec[3] = 0x21;
	printf("gint(uc_vec, 1, 2) = %x\n", gint(uc_vec, 1, 2) );

	return 1;
}
Exemplo n.º 19
0
void
st_pxymultimethods(void)
{
  useclass(Counter, Proxy);

  OBJ cnt = gnew(Counter);
  OBJ pxy = gnewWith(Proxy,cnt);
  OBJ one = gincr(gnew(Counter));

  grelease(cnt);

  STEST( "multimethod through proxy (rank 2)", N, gaddTo1(pxy,one) );
  STEST( "multimethod through proxy (rank 3)", N, gaddTo2(pxy,one,one) );
  STEST( "multimethod through proxy (rank 4)", N, gaddTo3(pxy,one,one,one) );
  STEST( "multimethod through proxy (rank 5)", N, gaddTo4(pxy,one,one,one,one) );
  
  test_assert( gint(pxy) == N+2*N+3*N+4*N );
  grelease(pxy);
  grelease(one);
}
Exemplo n.º 20
0
void
st_pxymethods(void)
{
  useclass(Counter, Proxy);

  OBJ cnt = gnew(Counter);
  OBJ pxy = gnewWith(Proxy,cnt);

  grelease(cnt);

  STEST( "method through proxy (0 argument )", N, gincr(pxy) );
  STEST( "method through proxy (1 argument )", N, gincrBy1(pxy,1) );
  STEST( "method through proxy (2 arguments)", N, gincrBy2(pxy,1,1) );
  STEST( "method through proxy (3 arguments)", N, gincrBy3(pxy,1,1,1) );
  STEST( "method through proxy (4 arguments)", N, gincrBy4(pxy,1,1,1,1) );
  STEST( "method through proxy (5 arguments)", N, gincrBy5(pxy,1,1,1,1,1) );

  test_assert( gint(pxy) == N + N+2*N+3*N+4*N+5*N );
  
  grelease(pxy);
}
Exemplo n.º 21
0
void GroupDialog_cycle()
{
  g_current_page = (g_current_page + 1) % g_pages.size(); 
  gtk_notebook_set_current_page(GTK_NOTEBOOK(g_GroupDlg.m_pNotebook), gint(g_current_page));
}
Exemplo n.º 22
0
int libpbc_config_getint (pool * p, const char *key, int def)
{
    return (gint (p, key, def));
}
Exemplo n.º 23
0
void GroupDialog_setPage(GtkWidget* page)
{
  g_current_page = gtk_notebook_page_num(GTK_NOTEBOOK(g_GroupDlg.m_pNotebook), page);
  gtk_notebook_set_current_page(GTK_NOTEBOOK(g_GroupDlg.m_pNotebook), gint(g_current_page));
}
Exemplo n.º 24
0
toktype yylex()
{
	register	ptrall	bufptr;	
	register	toktype		val;	
	register	struct	exp	*locxp;

	bufptr = tokptr;		/*copy in the global value*/
   top:
	if (bufptr < tokub){
		gtoken(val, bufptr);
		switch(yylval = val){
			case	PARSEEOF :
					yylval = val = PARSEEOF;
					break;
			case	INT:
					locxp = xp++;
					glong(locxp->xvalue, bufptr);
				  makevalue:
					locxp->xtype = XABS;
					locxp->xloc = 0;
					locxp->xname = NULL;
					yylval = (int)locxp;
					break;
			case	FLTNUM:	/*case patched on 3-Jan-80*/
					locxp = xp++;
					gdouble(locxp->doubval.dvalue, bufptr);
					/*
					 *	We make sure that locxp->xvalue
					 *	is not in the range suitable for
					 *	a short literal.  The field
					 *	xvalue is only used for
					 *	integers, not doubles, but when
					 *	we test for short literals
					 *	in ascode.c, we look
					 *	at the field xvalue when
					 *	it encounters an in line
					 *	floating number. Ergo,
					 *	give it a bad value.
					 */
					locxp->xvalue = -1;
					goto makevalue;
			case	NAME:
					gptr(yylval, bufptr);
					lastnam = (struct symtab *)yylval;
					break;
			case	SIZESPEC:
			case 	REG:
			case	INSTn:
			case	INST0:
					gchar(yylval, bufptr);
					break;
			case	IJXXX:
					gchar(yylval, bufptr);
					gptr(lastjxxx, bufptr);
					break;
			case	ILINESKIP:
					gint(yylval, bufptr);
					lineno += yylval;
					goto top;
			case	SKIP:	
					eatskiplg(bufptr);
					goto top;
			case	VOID:	
					goto top;
			case 	STRING:
					strptr = &strbuf[strno ^= 1];
					strptr->str_lg = *((lgtype *)bufptr);
					movestr(&strptr->str[0],
						(char *)bufptr + sizeof(lgtype),
						strptr->str_lg);
					eatstrlg(bufptr);
					yylval = (int)strptr;
					break;
			case 	ISTAB:
			case	ISTABSTR:
			case	ISTABNONE:
			case	ISTABDOT:
			case	IALIGN:
					gptr(yylval, bufptr);
					break;
		} /*end of the switch*/

#ifdef DEBUG

		if (toktrace)
		switch(val){
			case 	INT:	printf("Class integer val %d\n",
						((struct exp *)yylval)->xvalue);
					break;
			case 	FLTNUM: printf("Class floating point num value %4.3f\n",
					((struct exp *)yylval) -> doubval.dvalue);
					break;
			case	NAME:	printf("Class name, \"%.8s\"\n",
						((struct symtab *)yylval)->name);
					break;
			case	REG:	printf("Class register, number %d\n",
						yylval);
					break;
			case	INSTn:	printf("Class INSTn, %.8s\n",
						itab[0xFF &yylval]->name);
					break;
			case	IJXXX:	printf("Class IJXXX, %.8s\n",
						itab[0xFF &yylval]->name);
					break;
			case	INST0:	printf("Class INST0, %.8s\n",
						itab[0xFF &yylval]->name);
					break;
			case	STRING:	printf("Class string, length %d\n",
						((struct strdesc *)yylval)->str_lg);
					break;
			default:	printf("Pass: %d Tok: %d Other class: %d, 0%o, '%c'\n",
						passno,
						bufptr -  firsttoken,
						val,val, val);
					break;
		}		/*end of the debug switch*/
#endif

	}	/*end of this buffer*/
	else {
		if (useVM){
			bufno += 1;
			emptybuf = emptybuf->tok_next;
			if (emptybuf == 0){
				struct	tokbufdesc *newdallop;
				int	i;
				if (passno == 2)
					goto badread;
				emptybuf = newdallop = 
				  (struct tokbufdesc *)sbrk(
					TOKDALLOP*sizeof (struct tokbufdesc));
				if (emptybuf == (struct tokbufdesc *)-1)
					goto badwrite;
				for (i=0; i < TOKDALLOP; i++){
					buftail->tok_next = newdallop;
					buftail = newdallop;
					newdallop += 1;
				}
				buftail->tok_next = 0;
			}	/*end of need to get more buffers*/
			(toktype *)bufptr = &(emptybuf->toks[0]);
			if (passno == 1)
				scan_dot_s(emptybuf);
		} else {	/*don't use VM*/
			bufno ^= 1;
			emptybuf = &tokbuf[bufno];
			((toktype *)bufptr) = &(emptybuf->toks[0]);
			if (passno == 1){
				/*
				 *	First check if there are things to write
				 *	out at all
				 */
				if (emptybuf->tok_count >= 0){
					if (fwrite(emptybuf, sizeof *emptybuf, 1, tmpfil) != 1){
					  badwrite:
						yyerror("Unexpected end of file writing the interpass tmp file");
						exit(2);
					}
				}
				scan_dot_s(emptybuf);
			} else {	/*pass 2*/
				if (fread(emptybuf, sizeof *emptybuf, 1, tmpfil) != 1){
				  badread:
					yyerror("Unexpected end of file while reading the interpass tmp file");
					exit(1);
				}
			}	/*end of pass2*/
		}	/*end of using a real live file*/
		(char *)tokub = (char *)bufptr + emptybuf->tok_count;
#ifdef DEBUG
		firsttoken = bufptr;
		if (debug)
			printf("created buffernumber %d with %d tokens\n",
				bufno, emptybuf->tok_count);
#endif
			goto top;
	}	/*end of reading/creating a new buffer*/
	tokptr = bufptr;		/*copy back the global value*/
	return(val);
}	/*end of yylex*/
Exemplo n.º 25
0
gboolean get_xmmsctrl_info(struct TrackInfo *ti, void *handle, int session)
{
        gchar *(*xmms_remote_get_playlist_title)(gint session, gint pos);
        gint (*xmms_remote_get_playlist_time)(gint session, gint pos);
        gboolean (*xmms_remote_is_playing)(gint session);
        gboolean (*xmms_remote_is_paused)(gint session);
        gint (*xmms_remote_get_playlist_pos)(gint session);
        gint (*xmms_remote_get_output_time)(gint session);

	if (!handle)
          {
            return FALSE;
          }

        get_func(xmms_remote_get_playlist_title);
        get_func(xmms_remote_get_playlist_time);
        get_func(xmms_remote_is_playing);
        get_func(xmms_remote_is_paused);
        get_func(xmms_remote_get_playlist_pos);
        get_func(xmms_remote_get_output_time);

	if (!(xmms_remote_get_playlist_title && xmms_remote_get_playlist_time &&
			xmms_remote_is_playing && xmms_remote_is_paused &&
			xmms_remote_get_playlist_pos && xmms_remote_get_output_time)) {
		trace("xmmsctrl not initialized properly");
		return FALSE;
	}

	if ((*xmms_remote_is_playing)(session)) {
		if ((*xmms_remote_is_paused)(session))
			ti->status = PLAYER_STATUS_PAUSED;
		else
			ti->status = PLAYER_STATUS_PLAYING;
	} else
		ti->status = PLAYER_STATUS_STOPPED;
	trace("Got state %d", ti->status);

	if (ti->status != PLAYER_STATUS_STOPPED) {
 		int pos = (*xmms_remote_get_playlist_pos)(session);
 		trace("Got position %d", pos);

		char *title = (*xmms_remote_get_playlist_title)(session, pos);

		if (title) {
			trace("Got title %s", title);
			const char *sep = purple_prefs_get_string(PREF_XMMS_SEP);
			if (strlen(sep) != 1) {
				trace("Delimiter size should be 1. Cant parse status.");
				return FALSE;
			}

                        char regexp[STRLEN];
                        sprintf(regexp, "^(.*)\\%s(.*)\\%s(.*)$", sep, sep);
                        pcre *re = regex(regexp, 0);
                        capture(re, title, strlen(title), ti->artist, ti->album, ti->track);
                        pcre_free(re);
                        g_free(title);
		}

		ti->totalSecs = (*xmms_remote_get_playlist_time)(session, pos)/1000;
		ti->currentSecs = (*xmms_remote_get_output_time)(session)/1000;
	}
	return TRUE;
}
Exemplo n.º 26
0
static void
binary_dt_2nd_pass (GeglOperation *operation,
                    gint           width,
                    gint           height,
                    gfloat         thres_lo,
                    GeglDTMetric   metric,
                    gfloat        *src,
                    gfloat        *dest)
{
  gint u, y;
  gint q, w, *t, *s;
  gfloat *g, *row_copy;

  gfloat (*dt_f)   (gfloat, gfloat, gfloat);
  gint   (*dt_sep) (gint, gint, gfloat, gfloat);

  switch (metric)
    {
      case GEGL_DT_METRIC_CHESSBOARD:
        dt_f   = cdt_f;
        dt_sep = cdt_sep;
        break;
      case GEGL_DT_METRIC_MANHATTAN:
        dt_f   = mdt_f;
        dt_sep = mdt_sep;
        break;
      default: /* GEGL_DT_METRIC_EUCLIDEAN */
        dt_f   = edt_f;
        dt_sep = edt_sep;
        break;
    }

  /* sorry for the variable naming, they are taken from the paper */

  s = gegl_calloc (sizeof (gint), width);
  t = gegl_calloc (sizeof (gint), width);
  row_copy = gegl_calloc (sizeof (gfloat), width);

  /* this could be parallelized */
  for (y = 0; y < height; y++)
    {
      q = 0;
      s[0] = 0;
      t[0] = 0;
      g = dest + y * width;

      dest[0 + y * width] = MIN (dest[0 + y * width], 1.0);
      dest[width - 1 + y * width] = MIN (dest[width - 1 + y * width], 1.0);

      for (u = 1; u < width; u++)
        {
          while (q >= 0 &&
                 dt_f (t[q], s[q], g[s[q]]) >= dt_f (t[q], u, g[u]) + EPSILON)
            {
              q --;
            }

          if (q < 0)
            {
              q = 0;
              s[0] = u;
            }
          else
            {
              /* function Sep from paper */
              w = dt_sep (s[q], u, g[s[q]], g[u]);
              w += 1;

              if (w < width)
                {
                  q ++;
                  s[q] = u;
                  t[q] = w;
                }
            }
        }

      memcpy (row_copy, g, width * sizeof (gfloat));

      for (u = width - 1; u >= 0; u--)
        {
          if (u == s[q])
            g[u] = row_copy[u];
          else
            g[u] = dt_f (u, s[q], row_copy[s[q]]);

          if (q > 0 && u == t[q])
            {
              q--;
            }
        }

      gegl_operation_progress (operation,
                               (gdouble) y / (gdouble) height / 2.0 + 0.5, "");
    }

  gegl_free (t);
  gegl_free (s);
  gegl_free (row_copy);
}
Exemplo n.º 27
0
void PageView::selectObjectAt(double x, double y)
{
	XOJ_CHECK_TYPE(PageView);

	int selected = this->page->getSelectedLayerId();
	GdkRectangle matchRect = { gint(x - 10), gint(y - 10), 20, 20 };

	Stroke* strokeMatch = NULL;
	double gap = 1000000000;

	Element* elementMatch = NULL;

	// clear old selection anyway
	this->xournal->getControl()->clearSelection();

	ListIterator<Layer*> it = this->page->layerIterator();
	while (it.hasNext() && selected)
	{
		Layer* l = it.next();

		ListIterator<Element*> eit = l->elementIterator();
		while (eit.hasNext())
		{
			Element* e = eit.next();
			if (e->intersectsArea(&matchRect))
			{
				if (e->getType() == ELEMENT_STROKE)
				{
					Stroke* s = (Stroke*) e;
					double tmpGap = 0;
					if (s->intersects(x, y, 5, &tmpGap))
					{
						if (gap > tmpGap)
						{
							gap = tmpGap;
							strokeMatch = s;
						}
					}
				}
				else
				{
					elementMatch = e;
				}
			}
		}

		selected--;
	}

	if (strokeMatch)
	{
		elementMatch = strokeMatch;
	}

	if (elementMatch)
	{
		xournal->setSelection(new EditSelection(
		                          xournal->getControl()->getUndoRedoHandler(), elementMatch, this, page));

		repaintPage();
	}
}
Exemplo n.º 28
0
void PageView::startText(double x, double y)
{
	XOJ_CHECK_TYPE(PageView);

	this->xournal->endTextAllPages(this);

	if (this->textEditor == NULL)
	{
		// Is there already a textfield?
		ListIterator<Element*> eit = this->page->getSelectedLayer()->elementIterator();

		Text* text = NULL;

		while (eit.hasNext())
		{
			Element* e = eit.next();

			if (e->getType() == ELEMENT_TEXT)
			{
				GdkRectangle matchRect = { gint(x - 10), gint(y - 10), 20, 20 };
				if (e->intersectsArea(&matchRect))
				{
					text = (Text*) e;
					break;
				}
			}
		}

		bool ownText = false;
		if (text == NULL)
		{
			ToolHandler* h = xournal->getControl()->getToolHandler();
			ownText = true;
			text = new Text();
			text->setX(x);
			text->setY(y);
			text->setColor(h->getColor());
			text->setFont(settings->getFont());
		}
		else
		{

			//We can try to add an undo action here. The initial text shows up in this
			//textEditor element.
			this->oldtext = text;
			//text = new Text(*oldtext);
			//need to clone the old text so that references still work properly.
			//cloning breaks things a little. do it manually
			text = new Text();
			text->setX(oldtext->getX());
			text->setY(oldtext->getY());
			text->setColor(oldtext->getColor());
			text->setFont(oldtext->getFont());
			text->setText(oldtext->getText());

			Layer* layer = this->page->getSelectedLayer();
			layer->removeElement(this->oldtext, false);
			layer->addElement(text);
			//perform the old swap onto the new text drawn.
		}

		this->textEditor = new TextEditor(this, xournal->getWidget(), text, ownText);
		if (!ownText)
		{
			this->textEditor->mousePressed(x - text->getX(), y - text->getY());
		}

		this->rerenderPage();
	}
	else
	{
		Text* text = this->textEditor->getText();
		GdkRectangle matchRect = {gint(x - 10), gint(y - 10), 20, 20 };
		if (!text->intersectsArea(&matchRect))
		{
			endText();
		}
		else
		{
			this->textEditor->mousePressed(x - text->getX(), y - text->getY());
		}
	}
}
Exemplo n.º 29
0
inttoktype yylex()
{
	register	ptrall	bufptr;	
	register	inttoktype		val;	
	register	struct	exp	*locxp;
	/*
	 *	No local variables to be allocated; this saves
	 *	one piddling instruction..
	 */
	static	int	Lastjxxx;

	bufptr = tokptr;		/*copy in the global value*/
   top:
	if (bufptr < tokub){
		gtoken(val, bufptr);
		switch(yylval = val){
		case	PARSEEOF:
				yylval = val = PARSEEOF;
				break;
		case	BFINT:
		case	INT:
				if (xp >= &explist[NEXP])
				     yyerror("Too many expressions; try simplyfing");
				else
				    locxp = xp++;
				locxp->e_number = Znumber;
				locxp->e_number.num_tag = TYPL;
				glong(locxp->e_xvalue, bufptr);
			  makevalue:
				locxp->e_xtype = XABS;
				locxp->e_xloc = 0;
				locxp->e_xname = NULL;
				yylval = (int)locxp;
				break;
		case	BIGNUM:	
				if (xp >= &explist[NEXP])
				     yyerror("Too many expressions; try simplyfing");
				else
				    locxp = xp++;
				gnumber(locxp->e_number, bufptr);
				goto makevalue;
		case	NAME:
				gptr(yylval, bufptr);
				lastnam = (struct symtab *)yylval;
				break;
		case	SIZESPEC:
		case 	REG:
				gchar(yylval, bufptr);
				break;
		case	INSTn:
		case	INST0:
				gopcode(yyopcode, bufptr);
				break;
		case	IJXXX:
				gopcode(yyopcode, bufptr);
				/* We can't cast Lastjxxx into (int *) here.. */
				gptr(Lastjxxx, bufptr);
				lastjxxx = (struct symtab *)Lastjxxx;
				break;
		case	ILINESKIP:
				gint(yylval, bufptr);
				lineno += yylval;
				goto top;
		case	SKIP:	
				eatskiplg(bufptr);
				goto top;
		case	VOID:	
				goto top;
		case 	STRING:
		case 	ISTAB:
		case	ISTABSTR:
		case	ISTABNONE:
		case	ISTABDOT:
		case	IALIGN:
				gptr(yylval, bufptr);
				break;
		} 
#ifdef DEBUG
		if (toktrace){
		char	*tok_to_name();
		printf("P: %d T#: %4d, %s ",
			passno, bufptr -  firsttoken, tok_to_name(val));
		switch(val){
		case 	INT:	printf("val %d",
					((struct exp *)yylval)->e_xvalue);
				break;
		case	BFINT:	printf("val %d",
					((struct exp *)yylval)->e_xvalue);
				break;
		case 	BIGNUM: bignumprint(((struct exp*)yylval)->e_number);
				break;
		case	NAME:	printf("\"%.8s\"",
					FETCHNAME((struct symtab *)yylval));
				break;
		case	REG:	printf(" r%d",
					yylval);
				break;
		case	IJXXX:
		case	INST0:	
		case	INSTn:	printf("%.8s",
						FETCHNAME(ITABFETCH(yyopcode)));
				break;
		case	STRING:
			printf("length %d, seekoffset %d, place 0%o ",
				((struct strdesc *)yylval)->sd_strlen,
				((struct strdesc *)yylval)->sd_stroff,
				((struct strdesc *)yylval)->sd_place
				);
			if (((struct strdesc *)yylval)->sd_place & STR_CORE)
				printf("value\"%*s\"",
					((struct strdesc *)yylval)->sd_strlen,
					((struct strdesc *)yylval)->sd_string);
			break;
		}  		/*end of the debug switch*/
		printf("\n");
		}
#endif DEBUG

	} else {	/* start a new buffer */
	    if (useVM){
		if (passno == 2){
			tok_temp = emptybuf->tok_next;
			emptybuf->tok_next = tok_free;
			tok_free = emptybuf;
			emptybuf = tok_temp;
		} else {
			emptybuf = emptybuf->tok_next;
		}
		bufno += 1;
		if (emptybuf == 0){
			struct	tokbufdesc *newdallop;
			int	i;
			if (passno == 2)
				goto badread;
			emptybuf = newdallop = (struct tokbufdesc *)
			  Calloc(TOKDALLOP, sizeof (struct tokbufdesc));
			for (i=0; i < TOKDALLOP; i++){
				buftail->tok_next = newdallop;
				buftail = newdallop;
				newdallop += 1;
			}
			buftail->tok_next = 0;
		}	/*end of need to get more buffers*/
		(bytetoktype *)bufptr = &(emptybuf->toks[0]);
		if (passno == 1)
			scan_dot_s(emptybuf);
	    } else {	/*don't use VM*/
		bufno ^= 1;
		emptybuf = &tokbuf[bufno];
		((bytetoktype *)bufptr) = &(emptybuf->toks[0]);
		if (passno == 1){
			/*
			 *	First check if there are things to write
			 *	out at all
			 */
			if (emptybuf->tok_count >= 0){
			    if (writeTEST((char *)emptybuf, sizeof *emptybuf, 1, tokfile)){
				yyerror("Unexpected end of file writing the interpass tmp file");
				exit(2);
			    }
			}
			scan_dot_s(emptybuf);
		} else {	/*pass 2*/
		    if (readTEST((char *)emptybuf, sizeof *emptybuf, 1, tokfile)){
			 badread:
			     yyerror("Unexpected end of file while reading the interpass tmp file");
			     exit(1);
		    }
		}
	    }	/*end of using a real live file*/
	    (char *)tokub = (char *)bufptr + emptybuf->tok_count;
#ifdef DEBUG
	    firsttoken = bufptr;
	    if (debug)
		printf("created buffernumber %d with %d tokens\n",
			bufno, emptybuf->tok_count);
#endif DEBUG
	    goto top;
	}	/*end of reading/creating a new buffer*/
	tokptr = bufptr;		/*copy back the global value*/
	return(val);
}	/*end of yylex*/
Exemplo n.º 30
0
GtkWidget* GroupDialog_getPage()
{
  return gtk_notebook_get_nth_page(GTK_NOTEBOOK(g_GroupDlg.m_pNotebook), gint(g_current_page));
}