Ejemplo n.º 1
0
IntRect ScrollbarThemeHaiku::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool)
{
    if (part == BackButtonStartPart)
        return IntRect();

    int thickness = scrollbarThickness();
    if (scrollbar->orientation() == HorizontalScrollbar) {
        int width = buttonWidth(scrollbar->width(), thickness);
        return IntRect(scrollbar->x() + scrollbar->width() - width, scrollbar->y(), width, thickness);
    }

    int height = buttonWidth(scrollbar->height(), thickness);
    return IntRect(scrollbar->x(), scrollbar->y() + scrollbar->height() - height, thickness, height);
}
Ejemplo n.º 2
0
IntRect ScrollbarThemeHaiku::backButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool)
{
    if (part == BackButtonEndPart)
        return IntRect();

    int thickness = scrollbarThickness();
    IntPoint buttonOrigin(scrollbar->x(), scrollbar->y());
    IntSize buttonSize = scrollbar->orientation() == HorizontalScrollbar
                         ? IntSize(buttonWidth(scrollbar->width(), thickness), thickness)
                         : IntSize(thickness, buttonWidth(scrollbar->height(), thickness));
    IntRect buttonRect(buttonOrigin, buttonSize);

    return buttonRect;
}
Ejemplo n.º 3
0
QSize RouteItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    if ( index.column() == 0 ) {
        QTextDocument doc;
        doc.setDefaultFont( option.font );
        doc.setTextWidth( qMax( 128, m_view->contentsRect().width() - m_previewSize - buttonWidth( option ) ) );
        doc.setHtml( text( index ) );
        return QSize( qMax( 256, qRound( m_previewSize + buttonWidth( option ) + doc.size().width() + m_margin * 2 ) ),
                      qMax( m_previewSize + m_margin * 2, qRound( doc.size().height() ) ) );
    }

    return QSize();
}
Ejemplo n.º 4
0
QSize MapItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    if ( index.column() == 0 ) {
        QSize const iconSize = option.decorationSize;
        QTextDocument doc;
        doc.setDefaultFont( option.font );
        doc.setTextWidth( qMax( 200, m_view->contentsRect().width() - iconSize.width() - buttonWidth( option ) - 3 * m_margin ) );
        doc.setHtml( text( index ) );
        return QSize( iconSize.width() + doc.size().width() + buttonWidth( option ) + 3 * m_margin,
                      2 + qMax( iconSize.height(), qRound( doc.size().height() ) ) );
    }

    return QSize();
}
Ejemplo n.º 5
0
/****************************************************************************
 *
 * Combines icon shape masks after a resize
 *
 ****************************************************************************/
void ConfigureIconWindow(button_info *b)
{
#ifndef NO_ICONS
  int x,y,w,h;
  int xoff,yoff;
  int framew,xpad,ypad;
  XFontStruct *font;
  int BW,BH;

  if(!b || !(b->flags&b_Icon))
    return;

  if(!b->IconWin)
    {
      fprintf(stderr,"%s: DEBUG: Tried to configure erroneous iconwindow\n",
	      MyName);
      exit(2);
    }

  buttonInfo(b,&x,&y,&xpad,&ypad,&framew);
  framew=abs(framew);

  font = buttonFont(b);
  w = b->icon->width;
  h = b->icon->height;
  BW = buttonWidth(b);
  BH = buttonHeight(b);

  w=min(w,BW-2*(xpad+framew));

  if(b->flags&b_Title && font && !(buttonJustify(b)&b_Horizontal))
    h=min(h,BH-2*(ypad+framew)-font->ascent-font->descent);
  else
    h=min(h,BH-2*(ypad+framew));

  if(w < 1 || h < 1)
    {
      XMoveResizeWindow(Dpy, b->IconWin, 2000,2000,1,1);
      return; /* No need drawing to this */
    }

  if(buttonJustify(b)&b_Horizontal)
    xoff=0;
  else
    xoff=(BW-w)>>1;

  if(b->flags&b_Title && font && !(buttonJustify(b)&b_Horizontal))
    yoff=(BH-(h+font->ascent+font->descent))>>1;
  else
Ejemplo n.º 6
0
QRect RouteItemDelegate::position( Element element, const QStyleOptionViewItem& option ) const
{   
    int const width = buttonWidth( option );
    QPoint const firstColumn = option.rect.topLeft() + QPoint( m_margin, m_margin );
    QPoint const secondColumn = firstColumn + QPoint( m_previewSize + m_margin, 0 );
    QPoint const thirdColumn = QPoint( option.rect.width() - width - option.decorationSize.width(), firstColumn.y() );

    switch (element) {
    case Text:
        return QRect( secondColumn, QSize( thirdColumn.x() - secondColumn.x(), option.rect.height() ) );
    case OpenButton:
    case DownloadButton:
    {
        QStyleOptionButton optionButton = button( element, option );
        QSize size = option.fontMetrics.size( 0, optionButton.text ) + QSize( 4, 4 );
        QSize buttonSize = QApplication::style()->sizeFromContents( QStyle::CT_PushButton, &optionButton, size );
        buttonSize.setWidth( width );
        return QRect( thirdColumn, buttonSize );
    }
    case RemoveFromCacheButton:
    case RemoveFromCloudButton:
    {
        QStyleOptionButton optionButton = button( element, option );
        QSize size = option.fontMetrics.size( 0, optionButton.text ) + QSize( 4, 4 );
        QSize buttonSize = QApplication::style()->sizeFromContents( QStyle::CT_PushButton, &optionButton, size );
        buttonSize.setWidth( width );
        return QRect( thirdColumn + QPoint( 0, buttonSize.height() ), buttonSize );
    }
    case Progressbar:
    {
        QSize const progressSize = QSize( width, option.fontMetrics.height() + 4 );
        return QRect( thirdColumn + QPoint( 0, 10 ), progressSize );
    }
    case Preview:
    {
        return QRect( firstColumn, QSize( m_previewSize, m_previewSize) );
    }
    case UploadToCloudButton:
    {
        QStyleOptionButton optionButton = button( element, option );
        QSize size = option.fontMetrics.size( 0, optionButton.text ) + QSize( 4, 4 );
        QSize buttonSize = QApplication::style()->sizeFromContents( QStyle::CT_PushButton, &optionButton, size );
        buttonSize.setWidth( width );
        return QRect( thirdColumn + QPoint( 0, buttonSize.height() * 2 ), buttonSize );
    }
    }
    
    return QRect();
}
Ejemplo n.º 7
0
void get_button_root_geometry(rectangle *r, const button_info *b)
{
	int x;
	int y;
	int f;
	Window win;

	r->width = buttonWidth(b);
	r->height = buttonHeight(b);
	buttonInfo(b, &r->x, &r->y, &x, &y, &f);
	XTranslateCoordinates(
		Dpy, MyWindow, Root, r->x, r->y, &r->x, &r->y, &win);

	return;
}
Ejemplo n.º 8
0
Archivo: button.c Proyecto: att/uwin
/**
*** GetInternalSize()
**/
void GetInternalSize(button_info *b,int *x,int *y,int *w,int *h)
{
  int f;
  int px,py;
  buttonInfo(b,x,y,&px,&py,&f);
  f=abs(f);

  *w=buttonWidth(b)-2*(px+f);
  *h=buttonHeight(b)-2*(py+f);

  *x+=f+px;
  *y+=f+py;

  if (*w < 1)
    *w = 1;
  if (*h < 1)
    *h = 1;

  return;
}
Ejemplo n.º 9
0
/**
*** RedrawButton()
*** Writes out title, if any, and displays the bevel right, by calling 
*** RelieveWindow. If clean is nonzero, also clears background.
**/
void RedrawButton(button_info *b,int clean)
{
  int i,j,k,BH,BW;
  int f,x,y,px,py;
  int ix,iy,iw,ih;
  XFontStruct *font=buttonFont(b);
  XGCValues gcv;
  unsigned long gcm=0;
  int rev=0;
  int justify=buttonJustify(b);

  BW = buttonWidth(b);
  BH = buttonHeight(b);

  buttonInfo(b,&x,&y,&px,&py,&f);
  GetInternalSize(b,&ix,&iy,&iw,&ih);

  /* This probably isn't the place for this, but it seems to work here and not
     elsewhere, so... */
  if((buttonSwallowCount(b)==3) && b->IconWin!=None)
    XSetWindowBorderWidth(Dpy,b->IconWin,0);

  /* ----------------------------------------------------------------------- */

  if(b->flags&b_Hangon || b==CurrentButton)  /* Hanging or held down by user */
    rev=1;
  if(b->flags&b_Action) /* If this is a Desk button that takes you to here.. */
    {
      int n=0;
      while(n<4 && (!b->action[n] || strncasecmp(b->action[n],"Desk",4)))
	n++;
      if(n<4)
	{
	  k=sscanf(&b->action[n][4],"%d%d",&i,&j);
	  if(k==2 && i==0 && j==new_desk)
	    rev=1;
	}
    }
  RelieveWindow(MyWindow,f,x,y,BW,BH,buttonHilite(b),buttonShadow(b),rev);

  /* ----------------------------------------------------------------------- */

  f=abs(f);

  if(clean && BW>2*f && BH>2*f)
    {
      gcm = GCForeground;
      gcv.foreground=buttonBack(b);
      XChangeGC(Dpy,NormalGC,gcm,&gcv);

      if(b->flags&b_Container)
	{
	  int x1=x+f,y1=y+f;
	  int w1=px,h1=py,w2=w1,h2=h1;
	  int w=BW-2*f,h=BH-2*f;
	  w2+=iw - b->c->num_columns*b->c->ButtonWidth;
	  h2+=ih - b->c->num_rows*b->c->ButtonHeight;

	  if(w1)XFillRectangle(Dpy,MyWindow,NormalGC,x1,y1,w1,h);
	  if(w2)XFillRectangle(Dpy,MyWindow,NormalGC,x1+w-w2,y1,w2,h);
	  if(h1)XFillRectangle(Dpy,MyWindow,NormalGC,x1,y1,w,h1);
	  if(h2)XFillRectangle(Dpy,MyWindow,NormalGC,x1,y1+h-h2,w,h2);
	}
      else 
	XFillRectangle(Dpy,MyWindow,NormalGC,x+f,y+f,BW-2*f,BH-2*f);
    }

  /* ----------------------------------------------------------------------- */

  /* If a title is to be shown, truncate it until it fits */
  if(b->flags&b_Title && font)
    {
      int l,i,xpos;
      char *s;
      int just=justify&b_TitleHoriz; /* Left, center, right */

      gcm = GCForeground | GCFont; 
      gcv.foreground=buttonFore(b);
      gcv.font = font->fid;
      XChangeGC(Dpy,NormalGC,gcm,&gcv);

      if(justify&b_Horizontal)
	{
	  if(b->flags&b_Icon)
	    {
	      ix+=b->icon->width+buttonXPad(b);
	      iw-=b->icon->width+buttonXPad(b);
	    }
	  else if (buttonSwallowCount(b)==3)
	    {
	      ix+=b->icon_w+buttonXPad(b);
	      iw-=b->icon_w+buttonXPad(b);
	    }
	}

      s=b->title;
      l=strlen(s);
      i=XTextWidth(font,s,l);

      if(i>iw)
	{
	  if(just==2)
	    {
	      while(i>iw && *s)
		i=XTextWidth(font,++s,--l);
	    }
	  else /* Left or center - cut off its tail */
	    {
	      while(i>iw && l>0)
		i=XTextWidth(font,s,--l);
	    }
	}
      if(just==0) /* Left */
	xpos=ix;
      else if(just==2) /* Right */
	xpos=max(ix,ix+iw-i);
      else /* Centered, I guess */
 	xpos=ix+(iw-i)/2;

      if(*s && l>0 && BH>=font->descent+font->ascent) /* Clip it somehow? */
	{
	  /* If there is more than the title, put it at the bottom */
          /* Unless stack flag is set, put it to the right of icon */
	  if((b->flags&b_Icon || (buttonSwallowCount(b)==3)) &&
	     !(justify&b_Horizontal))
	    {
	      XDrawString(Dpy,MyWindow,NormalGC,xpos,
			  iy+ih-font->descent,s,l);
	      /* Shrink the space available for icon/window */
	      ih-=font->descent+font->ascent;
	    }
	  /* Or else center vertically */
	  else
	    {
	      XDrawString(Dpy,MyWindow,NormalGC,xpos,
			  iy+(ih+font->ascent-font->descent)/2,s,l);
	    }
	}
    }
}
Ejemplo n.º 10
0
Archivo: parse.c Proyecto: att/uwin
char *expand_action(char *in_action, button_info *b)
{
  char *variables[] =
  {
    "$",
    "fg",
    "bg",
    "left",
    "-left",
    "right",
    "-right",
    "top",
    "-top",
    "bottom",
    "-bottom",
    "width",
    "height",
    NULL
  };
  char *action = NULL;
  char *src;
  char *dest;
  char *string = NULL;
  char *rest;
  int px;
  int py;
  int val = 0;
  int offset;
  int x;
  int y;
  int f;
  int i;
  unsigned int w = 0;
  unsigned int h = 0;
  Window win;
  extern int dpw;
  extern int dph;

  /* create a temporary storage for expanding */
  action = (char *)malloc(MAX_MODULE_INPUT_TEXT_LEN);
  if (!action)
  {
    /* could not alloc memory */
    return NULL;
  }

  /* calculate geometry */
  if (b)
  {
    w = buttonWidth(b);
    h = buttonHeight(b);
    buttonInfo(b, &x, &y, &px, &py, &f);
    XTranslateCoordinates(Dpy, MyWindow, Root, x, y, &x, &y, &win);
  }

  for (src = in_action, dest = action; *src != 0; src++)
  {
    if (*src != '$')
    {
      *(dest++) = *src;
    }
    else
    {
      char *dest_org = dest;
      Bool is_string = False;
      Bool is_value = False;

      *(dest++) = *(src++);
      i = GetTokenIndex(src, variables, -1, &rest);
      if (i == -1)
      {
	src--;
	continue;
      }
      switch (i)
      {
      case 0: /* $ */
	continue;
      case 1: /* fg */
	string = UberButton->c->fore;
	is_string = True;
	break;
      case 2: /* bg */
	string = UberButton->c->back;
	is_string = True;
	break;
      case 3: /* left */
	val = x;
	is_value = True;
	break;
      case 4: /* -left */
	val = dpw - x - 1;
	is_value = True;
	break;
      case 5: /* right */
	val = x + w;
	is_value = True;
	break;
      case 6: /* -right */
	val = dpw - x - w - 1;
	is_value = True;
	break;
      case 7: /* top */
	val = y;
	is_value = True;
	break;
      case 8: /* -top */
	val = dph - y - 1;
	is_value = True;
	break;
      case 9: /* bottom */
	val = y + h;
	is_value = True;
	break;
      case 10: /* -bottom */
	val = dph - y - h - 1;
	is_value = True;
	break;
      case 11: /* width */
	val = w;
	is_value = True;
	break;
      case 12: /* height */
	val = h;
	is_value = True;
	break;
      default: /* unknown */
	src--;
	continue;
      } /* switch */
      dest = dest_org;
      src = --rest;
      if (is_value)
      {
	if (MAX_MODULE_INPUT_TEXT_LEN - (dest - action) <= 16)
	{
	  /* out of space */
	  free(action);
	  return NULL;
	}
	/* print the number into the string */
	sprintf(dest, "%d%n", val, &offset);
	dest += offset;
      }
      else if (is_string)
      {
	if (MAX_MODULE_INPUT_TEXT_LEN - (dest - action) <= strlen(string))
	{
	  /* out of space */
	  free(action);
	  return NULL;
	}
	/* print the colour name into the string */
	if (string)
	{
	  sprintf(dest, "%s%n", string, &offset);
	  dest += offset;
	}
      }
    } /* if */
  } /* for */
  *dest = 0;
  return action;
}