Exemplo n.º 1
0
VOID arrange_tree(LONG tree, WORD wint, WORD hint,WORD *maxw, WORD *maxh)
{
	WORD	obj, x, y, rowh, wroot;

	wroot = GET_WIDTH(tree, ROOT);
	if ( wroot )
	{
		x = wint;
		y = hint;
		rowh = 0;
		*maxw = 0;

		for (obj = GET_HEAD(tree, ROOT); obj != ROOT; 
			obj = GET_NEXT(tree, obj))
		{
			if (rowh && (x + GET_WIDTH(tree, obj)) > wroot)
			{
				x = wint;
				y += (rowh + hint);
				rowh = 0;
			}
			SET_X(tree, obj, x);
			SET_Y(tree, obj, y);
			if ( !(GET_FLAGS(tree, obj) & HIDETREE) )
			{
				x += (GET_WIDTH(tree, obj) + wint); 
				*maxw = max(*maxw, x);
				rowh = max(rowh, GET_HEIGHT(tree, obj));
			}
		}
		*maxh = y + rowh + hint;
	}
}
Exemplo n.º 2
0
void
nsGridRowGroupLayout::AddWidth(nsSize& aSize, nscoord aSize2, bool aIsHorizontal)
{
  nscoord& size = GET_WIDTH(aSize, aIsHorizontal);

  if (size == NS_INTRINSICSIZE || aSize2 == NS_INTRINSICSIZE)
    size = NS_INTRINSICSIZE;
  else
    size += aSize2;
}
void
nsGridLayout2::AddWidth(nsSize& aSize, nscoord aSize2, PRBool aIsHorizontal)
{
  nscoord& size = GET_WIDTH(aSize, aIsHorizontal);

  if (size != NS_INTRINSICSIZE) {
    if (aSize2 == NS_INTRINSICSIZE)
      size = NS_INTRINSICSIZE;
    else
      size += aSize2;
  }
}
Exemplo n.º 4
0
Arquivo: video.c Projeto: ACEZLY/p2pvc
int start_video(char *peer, char *port, vid_options_t *vopt) {
  width = GET_WIDTH(vopt->width);
  height = GET_HEIGHT(vopt->height);
  render_type = vopt->render_type;
  disp_bandwidth = vopt->disp_bandwidth;

  display_options_t dopt;
  memset(&dopt, 0, sizeof(display_options_t));

  dopt.intensity_threshold = vopt->intensity_threshold;
  dopt.saturation = vopt->saturation;
  dopt.monochrome = vopt->monochrome;
  dopt.r = vopt->r;
  dopt.g = vopt->g;
  dopt.b = vopt->b;
  dopt.ascii_values = vopt->ascii_values;

  init_screen(&dopt);
  curs_set(0);
  pthread_mutex_init(&conslock, NULL);

  cons = calloc(1, sizeof(connection_t));
  if (p2p_connect(peer, port, &(cons[0]))) {
    fprintf(stderr, "Unable to connect to server.\n");
  } else {
    conslen++;
  }

  pthread_t thr;
  pthread_create(&thr, NULL, &dolisten, (void *)port);

  IplImage* color_img;
  IplImage* resize_img = cvCreateImage(cvSize(width, height), 8, 3);  
  IplImage* edge = cvCreateImage(cvGetSize(resize_img), IPL_DEPTH_8U, 1);

  cv_cap = cvCaptureFromCAM(0);
  char line_buffer[sizeof(unsigned long) + width * depth];
  struct timespec tim, actual_tim;
  tim.tv_sec = 0;
  tim.tv_nsec = (1000000000 - 1) / vopt->refresh_rate;
  int kernel = 7;
  while (1) {
    /* Get each frame */
    color_img = cvQueryFrame(cv_cap);
    if(color_img && resize_img) {
      cvResize(color_img, resize_img, CV_INTER_AREA);
      if (vopt->edge_filter) {
        cvCvtColor(resize_img, edge, CV_BGR2GRAY);
        cvCanny(edge, edge, vopt->edge_lower * kernel * kernel, vopt->edge_upper * kernel * kernel, kernel);
        cvCvtColor(edge, resize_img, CV_GRAY2BGR);
      }
      unsigned long line_index;
      for (line_index = 0; line_index < (resize_img->imageSize / (width * depth)); line_index++) {
        memset(line_buffer, 0, sizeof(line_buffer));
        unsigned long send_index = htonl(line_index);
        memcpy(line_buffer, &send_index, sizeof(unsigned long));
        memcpy(&(line_buffer[sizeof(unsigned long)]), resize_img->imageData + (line_index * width * depth), width * depth);
        p2p_broadcast(&cons, &conslen, &conslock, line_buffer, + sizeof(line_buffer));
      }
      nanosleep(&tim, &actual_tim);
    }
  }

  /* Housekeeping */
  cvReleaseCapture(&cv_cap);
  end_screen();
  return 0;
}
Exemplo n.º 5
0
VOID edit_text(LONG tree, WORD sobj)
{
	LONG	obspec, taddr; 
	WORD	min_width, where, type, deftext, w, h, exitobj, ok;
	GRECT	p;
	BYTE	text[73], valid[73], tmplt[73], name[9]; 

	if (rcs_state != ALRT_STATE)
	{
		get_fields(tree, sobj, &type, &obspec, &p);
		taddr = LLGET(obspec);
		if (type == G_FTEXT || type == G_FBOXTEXT)
			if (LSTRLEN(LLGET(TE_PTMPLT(taddr))) > 72)
				return;
		ini_tree(&tree, TEXTDIAL);
		where = set_obname(tree, TEXTNAME, name, ad_view, sobj);
		set_text(tree, OTMPITEM, (LONG)ADDR(&tmplt[0]), 73);
		set_text(tree, OVALITEM, (LONG)ADDR(&valid[0]), 73);
		set_text(tree, OTEXITEM, (LONG)ADDR(&text[0]), 73);
		LLSTRCPY(LLGET(TE_PTMPLT(taddr)), (LONG)ADDR(&tmplt[0]));
		ted_set(taddr, &tmplt[0], &valid[0], &text[0]);

		if (type == G_TEXT || type == G_BOXTEXT)
		{
			if (LSTRLEN(LLGET(TE_PTEXT(taddr))) > 72)
				return;
			hide_obj(tree, TMPLTTAG);
			hide_obj(tree, OTMPITEM);
			hide_obj(tree, VALIDTAG);
			hide_obj(tree, OVALITEM);
			deftext = OTEXITEM;
		}		   
		else
			deftext = (tmplt[0] != '@')? OTMPITEM: OTEXITEM;
		do {
			exitobj = hndl_dial(tree, deftext, &p);
			desel_obj(tree, exitobj);
			ok = DEFAULT & GET_FLAGS(tree, exitobj);
		} while (ok && !name_ok(name, where, TRUE));

		if (ok)
		{
			rcs_edited = TRUE;
			get_obname(name, ad_view, sobj);
			ted_get(taddr, &tmplt[0], &valid[0], &text[0]);
			if (type == G_TEXT || type == G_FTEXT || type == G_BOXTEXT)
			{
				text_wh(taddr, type, &w, &h);
				min_width = GET_WIDTH(ad_view, sobj);
				if ( w > min_width)
					newsize_obj(ad_view, sobj, w, h, TRUE);
			}
		}

		unhide_obj(tree,TMPLTTAG);
		unhide_obj(tree,OTMPITEM);
		unhide_obj(tree, VALIDTAG);
		unhide_obj(tree,OVALITEM);
		map_tree(tree, ROOT, NIL, (fkt_parm)desel_obj);	/* clear radio buttons */
	}
}
Exemplo n.º 6
0
VOID edit_str(LONG tree, WORD sobj)
{
	LONG	obspec; 
	WORD	where, type, exitobj, ok;
	GRECT	p;
	WORD	min_width, neww, len; 
	BYTE	text[73], name[9]; 

	get_fields(tree, sobj, &type, &obspec, &p);
	len = (WORD)LSTRLEN(LLGET(obspec));
	if (len <= 72)
	{
		ini_tree(&tree, STRDIAL);
		where = set_obname(tree, STRNAME, name, ad_view, sobj);
		set_text(tree, OSTRITEM, (LONG)ADDR(&text[0]), 73);
		LLSTRCPY(LLGET(obspec), (LONG)ADDR(&text[0]));
		if ( rcs_state == ALRT_STATE )
			hide_obj( tree, STRNAME);
		if (!text[0])
			text[0] = '@';
		do {
			exitobj = hndl_dial(tree, OSTRITEM, &p);
			desel_obj(tree, exitobj);
			ok = DEFAULT & GET_FLAGS(tree, exitobj);
		} while ( ok && !name_ok(name, where, TRUE));

		if (ok)
		{
			rcs_edited = TRUE;
			get_obname(name, ad_view, sobj);
			if (text[0] == '@')
				text[0] = '\0';

			if (rcs_state == ALRT_STATE)
			{		
				if (strlen(text) > 40 )
				{
					hndl_alert(1, string_addr(STOOLONG));
					text[40] = '\0';
				}
				update_if(obspec, &text[0]);
				fix_alert(ad_view);
				unhide_obj(tree, STRNAME);
			}
			else
			{
				neww = (WORD)(gl_wchar * strlen(text));
				if (rcs_state == MENU_STATE)
				{
					if (type == G_TITLE)
					{
						if (!newsize_obj(ad_view, sobj, neww,gl_hchar, TRUE))
							text[len] = '\0';
						fix_menu_bar(ad_view);
					}
					else if (in_which_menu(ad_view, sobj) == 1
						&& in_menu(ad_view, sobj) == 1
						&& strlen(text) > 20 )
		    		{
						hndl_alert(1, string_addr(STOOLONG));	
						text[20] = '\0';
					}
					else  if(!newsize_obj(ad_view, sobj, neww,gl_hchar, FALSE))
						text[len] = '\0';
				}
				else if (type == G_STRING || type == G_BUTTON )
				{
					min_width = GET_WIDTH(ad_view, sobj);
					if( neww > min_width )
						if(!newsize_obj(ad_view, sobj, neww,gl_hchar, FALSE))
							text[len] = '\0';
				}
			}
			if( rcs_state != ALRT_STATE)
				update_if(obspec, &text[0]);
		}
	}
}
Exemplo n.º 7
0
void
nsSprocketLayout::ChildResized(nsIFrame* aBox,
                         nsBoxLayoutState& aState, 
                         nsIFrame* aChild,
                         nsBoxSize* aChildBoxSize,
                         nsComputedBoxSize* aChildComputedSize,
                         nsBoxSize* aBoxSizes, 
                         nsComputedBoxSize* aComputedBoxSizes, 
                         const nsRect& aChildLayoutRect, 
                         nsRect& aChildActualRect, 
                         nsRect& aContainingRect,
                         int32_t aFlexes, 
                         bool& aFinished)
                         
{
      nsRect childCurrentRect(aChildLayoutRect);

      bool isHorizontal = IsHorizontal(aBox);
      nscoord childLayoutWidth  = GET_WIDTH(aChildLayoutRect,isHorizontal);
      nscoord& childActualWidth  = GET_WIDTH(aChildActualRect,isHorizontal);
      nscoord& containingWidth   = GET_WIDTH(aContainingRect,isHorizontal);   
      
      //nscoord childLayoutHeight = GET_HEIGHT(aChildLayoutRect,isHorizontal);
      nscoord& childActualHeight = GET_HEIGHT(aChildActualRect,isHorizontal);
      nscoord& containingHeight  = GET_HEIGHT(aContainingRect,isHorizontal);

      bool recompute = false;

      // if we are a horizontal box see if the child will fit inside us.
      if ( childActualHeight > containingHeight) {
            // if we are a horizontal box and the child is bigger than our height

            // ok if the height changed then we need to reflow everyone but us at the new height
            // so we will set the changed index to be us. And signal that we need a new pass.

            nsSize min = aChild->GetMinSize(aState);            
            nsSize max = nsBox::BoundsCheckMinMax(min, aChild->GetMaxSize(aState));
            AddMargin(aChild, max);

            if (isHorizontal)
              childActualHeight = max.height < childActualHeight ? max.height : childActualHeight;
            else
              childActualHeight = max.width < childActualHeight ? max.width : childActualHeight;

            // only set if it changes
            if (childActualHeight > containingHeight) {
                 containingHeight = childActualHeight;

              // remember we do not need to clear the resized list because changing the height of a horizontal box
              // will not affect the width of any of its children because block flow left to right, top to bottom. Just trust me
              // on this one.
              aFinished = false;

              // only recompute if there are flexes.
              if (aFlexes > 0) {
                // relayout everything
                recompute = true;
                InvalidateComputedSizes(aComputedBoxSizes);
                nsComputedBoxSize* node = aComputedBoxSizes;

                while(node) {
                  node->resized = false;
                  node = node->next;
                }

              }              
            }
      } 
      
      if (childActualWidth > childLayoutWidth) {
            nsSize min = aChild->GetMinSize(aState);
            nsSize max = nsBox::BoundsCheckMinMax(min, aChild->GetMaxSize(aState));
            
            AddMargin(aChild, max);

            // our width now becomes the new size

            if (isHorizontal)
              childActualWidth = max.width < childActualWidth ? max.width : childActualWidth;
            else
              childActualWidth = max.height < childActualWidth ? max.height : childActualWidth;

            if (childActualWidth > childLayoutWidth) {
               aChildComputedSize->size = childActualWidth;
               aChildBoxSize->min = childActualWidth;
               if (aChildBoxSize->pref < childActualWidth)
                  aChildBoxSize->pref = childActualWidth;
               if (aChildBoxSize->max < childActualWidth)
                  aChildBoxSize->max = childActualWidth;

              // if we have flexible elements with us then reflex things. Otherwise we can skip doing it.
              if (aFlexes > 0) {
                InvalidateComputedSizes(aComputedBoxSizes);

                nsComputedBoxSize* node = aComputedBoxSizes;
                aChildComputedSize->resized = true;

                while(node) {
                  if (node->resized)
                      node->valid = true;
                
                  node = node->next;
                }

                recompute = true;
                aFinished = false;
              } else {
                containingWidth += aChildComputedSize->size - childLayoutWidth;
              }              
            }
      }

      if (recompute)
            ComputeChildSizes(aBox, aState, containingWidth, aBoxSizes, aComputedBoxSizes);

      if (!childCurrentRect.IsEqualInterior(aChildActualRect)) {
        // the childRect includes the margin
        // make sure we remove it before setting 
        // the bounds.
        nsMargin margin(0,0,0,0);
        aChild->GetMargin(margin);
        nsRect rect(aChildActualRect);
        if (rect.width >= margin.left + margin.right && rect.height >= margin.top + margin.bottom) 
          rect.Deflate(margin);

        aChild->SetBounds(aState, rect);
        aChild->Layout(aState);
      }

}
Exemplo n.º 8
0
VOID objc_xywh(LONG tree, WORD obj, GRECT *p)
{
	objc_offset((OBJECT FAR *)tree, obj, &p->g_x, &p->g_y);
	p->g_w = GET_WIDTH(tree, obj);
	p->g_h = GET_HEIGHT(tree, obj);
}