Beispiel #1
0
void CUIGlobals::Dump()
{
	tracescope(ts, _T("UIGlobals...\n\n"));

	traceHEXPTR(m_hInst);
	traceHEXPTR(m_lpDI);
	LPTSTR str = AllocConfigureFlagStr(m_dwFlags);
	trace1(_T("m_dwFlags = %s\n"), str);
	free(str);
	traceSUPERSTR(m_wszUserNames);
	traceHEXPTR(m_pSurface);
	traceHEXPTR(m_pSurface3D);
	traceHEXPTR(m_lpCallback);
	traceBOOL(m_bAllowEditLayout);
	{
		tracescope(__csts, _T("m_ColorSet...\n"));
		traceHEX(m_ColorSet.cTextFore);
		traceHEX(m_ColorSet.cTextHighlight);
		traceHEX(m_ColorSet.cCalloutLine);
		traceHEX(m_ColorSet.cCalloutHighlight);
		traceHEX(m_ColorSet.cBorder);
		traceHEX(m_ColorSet.cControlFill);
		traceHEX(m_ColorSet.cHighlightFill);
		traceHEX(m_ColorSet.cAreaFill);
	}
	traceBOOL(m_bUseColorSet);
	trace(_T("\n"));
	TraceActionFormat(_T("Master ActionFormat 0:"), RefMasterAcFor(0));
	trace(_T("\n\n"));
}
void 
ObjectEventBroker::event_filter(const RPP::QObject<QObject> object,
				const QEvent &event,
				RPP::Symbol method) const
{
  trace1("event_filter, tp = %d", event.type());
  switch (event.type())
    {
    case QEvent::Timer:
      {
	const QTimerEvent &ev_timer = static_cast<const QTimerEvent &>(event);
	object.call("emit", method, RPP::Fixnum(ev_timer.timerId()));
	return;
      }
    case QEvent::ChildAdded:
    case QEvent::ChildRemoved:
    case QEvent::ChildPolished:
      {
	const QChildEvent &ev_child = static_cast<const QChildEvent &>(event);
	object.call("emit", method, RPP::QObject<QObject>(ev_child.child()));
	return;
      }
    case QEvent::DynamicPropertyChange:
      {
	const QDynamicPropertyChangeEvent &ev_dpch 
	  = static_cast<const QDynamicPropertyChangeEvent &>(event);
	object.call("emit", method, qByteArray2v(ev_dpch.propertyName()));
	return;
      }
    default:
	break;
    }
  rb_raise(rb_eNotImpError, "events of type %s cannot be brokered yet", method.to_s());
}
/* 
 * Broker the event.
 * IE, for all registered events we must emit the signal.
 * But this only needs to be done if object has a ruby wrapper.
 *
 * Must return inherited::eventFilter in all cases
 */
bool 
ObjectEventBroker::eventFilter(QObject *object, QEvent *event)
{
  const QEvent::Type tp = event->type();
  trace1("eventFilter, received type '%d' <<<<<EVENT!!!!>>>>>", tp);
  const RPP::QObject<QObject> v_object(object, RPP::UNSAFE);
  if (v_object.test())
    {
      const char * const method = Events.value(tp);
      if (method)
	{
	  const RPP::Symbol v_method = method;
	  event_filter(v_object, *event, v_method);
	}
    }
  else
    {
      trace1("Watched object %p is not a rb thing", object);
    }
  return inherited::eventFilter(object, event);
} // eventFilter
void
init_graphicsview(RPP::Module qt, RPP::Class)
{
  trace1("init_graphicsview, define R::Qt::GraphicsView, mQt=%p", &qt);
  const RPP::Class cGraphicsView = qt.define_class("GraphicsView", cAbstractScrollArea);
  cGraphicsView.define_alloc_func(cGraphicsView_alloc)
	       .define_private_method("initialize", cGraphicsView_initialize)
	       .define_method("scene=", cGraphicsView_scene_set)
	       .define_method("scene_get", cGraphicsView_scene_get)
	       .define_method("scale=", cGraphicsView_scale_set)
	       ;
} // init_graphicsview
Beispiel #5
0
void
init_lineedit(RPP::Module qt, RPP::Class widget)
{
    trace1("init_lineedit, define R::Qt::Widget, mQt=%p", &qt);
    const RPP::Class cLineEdit = qt.define_class("LineEdit", widget);
    cLineEdit.define_alloc_func(cLineEdit_alloc)
    .define_method("text=", cLineEdit_text_set)
    .define_method("text_get", cLineEdit_text_get)
    .define_method("readOnly=", cLineEdit_setReadOnly)
    .define_method("readOnly_get", cLineEdit_isReadOnly)
    .define_method("maxLength=", cLineEdit_maxLength_set)
    .define_method("maxLength_get", cLineEdit_maxLength_get)
    .define_method("alignment=", cLineEdit_alignment_set)
    .define_method("alignment_get", cLineEdit_alignment_get)
    ;
} // init_lineedit
Beispiel #6
0
void trace_msg_(const char *type, UInt64 id, const void *data, size_t length) {
  // The memory buffer may contain multiple messages. We need to log each one
  // separately.

  size_t remaining = length;
  const UInt8 *ptr = BytePtr(data);

  const Header *header = reinterpret_cast<const Header *>(ptr);
  while (remaining >= sizeof(Header) && header->length() <= remaining) {
    trace1(type, id, ptr, header->length());

    remaining -= header->length();
    ptr += header->length();
    header = reinterpret_cast<const Header *>(ptr);
  }

  if (remaining > 0) {
    detail::write_(Level::Trace, type,
                   "Invalid Leftover:", RawDataToHex(ptr, remaining));
  }
}
Beispiel #7
0
/** :call-seq:
    Color.new						   # The default color. Let's say: black
    Color.new :white					   # or any other QGlobalColor. These are cached.
    Color.new Color
    Color.new Color, alpha
    Color.new Brush
    Color.new '#rgb'					    # must be hexadecimals, case insensitive
    Color.new '#rrggbb'
    Color.new '#rrrgggbbb'
    Color.new '#rrrrggggbbbb'
    Color.new '#rgba'					    # etc
    Color.new red, green, blue, opaqueness = 255	    # all values must be between 0 and 255
    Color.new gray_value, opaqueness = 255  
    Color.new red, green, blue, opaqueness = 1.0	    # all values must be between 0.0 and 1.0
    Color.new gray_value, opaqueness = 1.0  
    Color.new [array_args]				    # splatted
    Color.new Hash					    # same as Control constructor
    Color.new { initblock }				    # same as Control constructor

    Colors have neither parents nor children
 */
static VALUE
cColor_initialize(int argc, VALUE *argv, VALUE v_self)
{
  trace1("cColor_initialize, argc=%d", argc);
  RPP::QColor self = v_self;
  VALUE v_colorsym, v_g, v_b, v_a;
  rb_scan_args(argc, argv, "04", &v_colorsym, &v_g, &v_b, &v_a);
  track4("cColor_initialize(%s, %s, %s, %s)", v_colorsym, v_g, v_b, v_a);
  const RPP::Object colorsym = v_colorsym;
  const RPP::Object g = v_g, b = v_b, a = v_a;
  switch (colorsym.type())
    {
    case T_HASH:
	return self.call("setupQuickyhash", colorsym);
    case T_NIL:
	if (rb_block_given_p())
	  {
	    trace("instance_eval on block");
	    return self.instance_eval();
	  }
	trace("default color assign");
	*self = QColor();
	return Qnil;
    case T_DATA:
	if (colorsym.is_kind_of(cColor)) 
	  {
	    trace("when Color");
	    if (!g.isNil()) colorsym.call("alpha=", g);
	    *self = *RPP::QColor(colorsym);
	    return Qnil;
	  }
	if (colorsym.is_kind_of(cBrush))
	  {
	    trace("when Brush");
	    *self = *RPP::QColor(colorsym.call("color"));
	    return Qnil;
	  }
	break;
    case T_STRING:
      {
	trace("when String");
	const char *s = RPP::String(colorsym);
	if (*s == '#')
	  {
	    const size_t l = strlen(s);
	    char t[l + 1];
	    strcpy(t, s);
	    s = t;
	    for (char *u = t; *u; u++)
	      *u = toupper(*u);
	    switch (l)
	      {
	      case 5:
		{
		  // 17 * 0xf = 17 * 15 = 255. How nice.
		  const int alpha = hex2int(t[4]) * 17;
		  t[4] = 0;
		  QColor * const r = new QColor(t);
		  r->setAlpha(alpha);
		  *self = *r;
		  return Qnil;
		}
	      case 9:
		{
		  const int alpha = hex2int(t[7]) * 16 + hex2int(t[8]);
		  t[7] = 0;
		  QColor * const r = new QColor(t);
		  r->setAlpha(alpha);
		  *self = *r;
		  return Qnil;
		}
	      case 13:
		{
		  const int alpha = hex2int(t[10]) * 256 + hex2int(t[11]) * 16 + hex2int(t[12]);
		  t[10] = 0;
		  QColor * const r = new QColor(t);
		  r->setAlphaF(alpha / 4096.0);
		  *self = *r;
		  return Qnil;
		}
	      case 17:
		{
		  const int alpha = hex2int(t[13]) * 65536 + hex2int(t[14]) * 256 
				    + hex2int(t[15]) * 16 + hex2int(t[16]);
		  t[13] = 0;
		  QColor * const r = new QColor(t);
		  r->setAlphaF(alpha / 65536.0);
		  *self = *r;
		  return Qnil;
		}
	      default:
		  break;
	      } // switch strlen
	    return cColorWrap(new QColor(s));
	  } // strings starting with '#'
	QColor * const r = new QColor(s);
	trace5("ordinary string '%s' -> r:%d, g:%d, b: %d, a:%d", s, r->red(), r->green(), 
	       r->blue(), r->alpha());
	trace1("QColorptr = %p", r);
	*self = *r;
	return Qnil;
      }
    case T_ARRAY:
      {
	trace("when Array");
	const RPP::Array ary(colorsym, RPP::VERYUNSAFE);
	return cColor_initialize(ary.len(), ary.ptr(), self);
      }
    case T_FIXNUM:
      {
	trace("when Fixnum");
	if (b.isNil())
	  {
	    const int gray = colorsym.to_i();
	    const int alpha = g.isNil() ? 255 : g.to_i();
	    *self = QColor(gray, gray, gray, alpha);
	    return Qnil;
	  }
	const int alpha = a.isNil() ? 255 : a.to_i();
	*self = QColor(colorsym.to_i(), g.to_i(), b.to_i(), alpha);
	return Qnil;
      }
    case T_FLOAT:
      {
	trace("when Float");
	if (b.isNil())
	  {
	    const double gray = colorsym.to_f();
	    const double alpha = g.isNil() ? 1.0 : g.to_i();
	    *self = QColor(gray, gray, gray, alpha);
	    return Qnil;
	  }
	const double alpha = a.isNil() ? 1.0 : a.to_i();
	*self = QColor(colorsym.to_f(), g.to_f(), b.to_f(), alpha);
	return Qnil;
      }
    case T_SYMBOL:
      {
	trace("when Symbol");
	const Qt::GlobalColor gc = cColor_sym2color(cColor, colorsym);
	*self = QColor(gc);
	return Qnil;
      }
    } // switch TYPE colorsym
  rb_raise(rb_eArgError, "invalid color %s, %s, %s, %s", colorsym.inspect(), g.inspect(),
	   b.inspect(), a.inspect());
} // cColor_initialize
Beispiel #8
0
void main(int argc, char **argv) {
    char *ptr;
    int n;

    debug1("DEBUG: main( %d, **argv )\n",argc);
    if (argc < 2 || argc > 3) {
	fprintf(stderr,
		"\nERROR:   Invalid number of arguments: %d\nCommand: %s",
		argc-1,*argv);
	for (n=1; n<argc; n++)
	    fprintf(stderr," \"%s\"",argv[n]);
	fprintf(stderr,"\nUsage:   %s device [baudrate]\n\n",*argv);
#ifndef INIT_BUG_WORKAROUND
	exit(3);
#endif
    }
    debug("\n\n\nDEBUG: Running...\n");
    fd = open(ISSUE, O_RDONLY);
    trace1("TRACE: /etc/issue status = %d\n",fd);
    if (fd < 0) {
	perror("ERROR");
    } else {
	trace1("TRACE: File exists: %s\n", ISSUE);
	put(13);
#ifdef SUPER_SMALL
	while ((n=read(fd,Buffer,sizeof(Buffer))) > 0)
	    write(1,Buffer,n);
#else
	when();
	host();
	*Buffer = '\0';
	while (read(fd,Buffer,1) > 0) {
	    ch = *Buffer;
	    trace1("TRACE: Found '%c'\n", ch);
	    if (ch == '\\' || ch == '@') {
		Buffer[1] = ch;
		read(fd,Buffer+1,1);
	    }
	    switch (ch) {
		case '\n':
		    put(' ');
		    put(ch);
		    break;
		case '\\':
		    ch = Buffer[1];
		    debug1("DEBUG: Found '\\%c'\n",ch);
		    switch(ch) {
			case '0':			/* NUL */
			    ch = 0;
			case '\\':
			case '@':
			    put(ch);
			    break;
			case 'b':			/* BS Backspace */
			    put(8);
			    break;
			case 'f':			/* FF Formfeed */
			    put(12);
			    break;
			case 'n':			/* LF Linefeed */
			    put(10);
			    break;
			case 's':			/* SP Space */
			    put(32);
			    break;
			case 't':			/* HT Tab */
			    do {
				put(' ');
			    } while (col & 7);
			    break;
			case 'r':			/* CR Return */
			    ch=13;
			default:			/* Anything else */
			    put('\\');
			    put(ch);
			    break;
		    }
		    break;
		case '@':
		    ch = Buffer[1];
		    debug1("DEBUG: Found '@%c'\n",ch);
		    switch(ch) {
			case '@':
			    put(ch);
			    break;
			case 'B':			/* Baud Rate */
			    if (argv > 2) {
				state(argv[2]);
				state(" Baud");
			    } else
				state("Terminal");
			    break;
			case 'D':			/* Date */
			    state(Date);
			    break;
			case 'H':			/* Host */
			    state(Host);
			    break;
			case 'L':			/* Line used */
			    if (argv > 1) {
				ptr = rindex(argv[1],'/');
				if (ptr == NULL)
				    ptr = argv[1];
			    } else
				ptr = NULL;
			    if (ptr == NULL)
				ptr = "tty";
			    state(ptr);
			    break;
			case 'S':			/* System */
			    state("ELKS");
			    break;
			case 'T':			/* Time */
			    state(Time);
			    break;
#if 0
			case 'U':			/* Users */
			    state("1 user");
			    break;
#endif
#ifdef ELKS_VERSION
			case 'V':			/* Version */
			    state(ELKS_VERSION);
			    break;
#endif
			default:
			    put('@');
			    put(ch);
			    break;
		    }
		    break;
		default:
		    put(ch);
		    break;
	    }
	    *Buffer = '\0';
	}
#endif
	close(fd);
    }
    trace1("TRACE: Finished with %s\n", ISSUE);
    for (;;) {
	state("login: "******"DEBUG: Execv failed.\n\n");
	    exit(2);
	}
    }
}
Beispiel #9
0
void state(char *s) {
    trace1("TRACE: state( \"%s\" )\n",s);
    write(1,s,strlen(s));
}