示例#1
0
const PixelRect &
TabDisplay::GetButtonSize(unsigned i) const
{
    assert(i < GetSize());

    if (buttons[i]->rc.left < buttons[i]->rc.right)
        return buttons[i]->rc;

    const UPixelScalar margin = 1;

    /*
    bool partialTab = false;
    if ( ((Layout::landscape ^ flip_orientation) && tab_display->GetTabHeight() < get_height()) ||
        ((!Layout::landscape ^ flip_orientation) && tab_display->GetTabWidth() < get_width()) )
      partialTab = true;
    */

    const UPixelScalar finalmargin = 1; //partialTab ? tab_line_height - 1 * margin : margin;
    // Todo make the final margin display on either beginning or end of tab bar
    // depending on position of tab bar

    PixelRect rc;

    if (Layout::landscape ^ flip_orientation) {
        const UPixelScalar but_height =
            (GetTabHeight() - finalmargin) / GetSize() - margin;

        rc.left = 0;
        rc.right = GetTabWidth() - tab_bar.GetTabLineHeight();

        rc.top = finalmargin + (margin + but_height) * i;
        rc.bottom = rc.top + but_height;

    } else {
        const unsigned portraitRows = (GetSize() > 4) ? 2 : 1;

        const unsigned portraitColumnsRow0 = ((portraitRows == 1)
                                              ? GetSize() : GetSize() / 2);
        const unsigned portraitColumnsRow1 = ((portraitRows == 1)
                                              ? 0 : GetSize() - GetSize() / 2);

        const unsigned row = (i > (portraitColumnsRow0 - 1)) ? 1 : 0;

        const UPixelScalar rowheight = (GetTabHeight() - tab_bar.GetTabLineHeight())
                                       / portraitRows - margin;

        const UPixelScalar but_width =
            (GetTabWidth() - finalmargin) /
            ((row == 0) ? portraitColumnsRow0 : portraitColumnsRow1) - margin;

        rc.top = row * (rowheight + margin);
        rc.bottom = rc.top + rowheight;

        rc.left = finalmargin + (margin + but_width) * (row ? (i - portraitColumnsRow0) : i);
        rc.right = rc.left + but_width;
    }

    buttons[i]->rc = rc;
    return buttons[i]->rc;
}
示例#2
0
void HeaderCtrl::LeftDown(Point p, dword keyflags) {
#ifdef _DEBUG
	if(keyflags & K_CTRL) {
		String text;
		for(int i = 0; i < col.GetCount(); i++)
			text += Format(i ? " %d" : "%d", GetTabWidth(i));
		WriteClipboardText(".ColumnWidths(\"" + text + "\");");
		BeepExclamation();
	}
#endif
	split = GetSplit(p.x);
	if(IsNull(split)) return;
	SetCapture();
	if(split >= 0) {
		colRect = GetTabRect(split);
		return;
	}
	li = pushi = -1 - split;
	col[pushi].WhenLeftClick();
#ifdef _DEBUG
	if((keyflags & K_ALT) && pushi >= 0)
		WriteClipboardText(AsString(GetTabWidth(pushi)));
#endif
	if(pushi >= 0) {
		if(!col[pushi].WhenAction) {
			pushi = -1;
			return;
		}
		colRect = GetTabRect(pushi);
		push = true;
	}
	Refresh();
}
示例#3
0
int HeaderCtrl::GetSplit(int px) {
	if(!IsEnabled())
		return Null;
	RefreshDistribution();
	px += sb;
	int cx = GetSize().cx;
	double rs = Denominator();
	int n = col.GetCount();
	int l = GetLastVisibleTab();
	if(mode != SCROLL && abs(px - cx) <= 4 && n > 0 && l >= 0 && GetTabWidth(l) < 4)
		while(--n >= 0)
			if(GetTabWidth(n) >= 4)
				return n;
	double rr = 0;
	int x = 0;
	int first_move = 0;
	while(first_move < n && (!col[first_move].visible || col[first_move].min == col[first_move].max))
		first_move++;
	int last_move = n - 1;
	while(last_move >= 0 && (!col[last_move].visible || col[last_move].min == col[last_move].max))
		last_move--;
	if(mode == PROPORTIONAL)
		last_move--;
	for(int i = 0; i < n; i++) {
		Column& cl = col[i];
		if(cl.visible) {
			bool canmove = (i >= first_move && i <= last_move);
			if(cl.min == cl.max) {
				int j = i;
				while(++j < n && !col[j].visible)
					;
				if(j >= n || col[j].min == col[j].max)
					canmove = false;
			}
			if(mode == SCROLL) {
				x += (int)col[i].ratio;
				if(canmove && px >= x - 3 && px < x + 3 && (i >= n - 1 || GetNextTabWidth(i) >= 4 || px < x))
					return i;
			}
			else {
				rr += rs ? col[i].ratio : 1;
				x = int(rr * cx / (rs ? rs : col.GetCount()));
				if(canmove && px >= x - 3 && px < x + 3 && i < n - 1 && (i >= n - 1 || GetNextTabWidth(i) >= 4 || px < x))
					return i;
			}
			if(px < x)
				return -1 - i;
		}
	}
	return Null;
}
void clEditorConfigSection::PrintToLog()
{
    clDEBUG1() << ".editorconfig (" << filename << ") :" << clEndl;
    if(IsCharsetSet()) {
        clDEBUG1() << "charset:" << GetCharset() << clEndl;
    }
    if(IsIndentSizeSet()) {
        clDEBUG1() << "indent_size:" << GetIndentSize() << clEndl;
    }
    if(IsIndentStyleSet()) {
        clDEBUG1() << "indent_style:" << GetIndentStyle() << clEndl;
    }
    if(IsInsertFinalNewlineSet()) {
        clDEBUG1() << "insert_final_newline:" << IsInsertFinalNewline() << clEndl;
    }
    if(IsSetEndOfLineSet()) {
        clDEBUG1() << "end_of_line:" << GetEndOfLine() << clEndl;
    }
    if(IsTabWidthSet()) {
        clDEBUG1() << "tab_width:" << GetTabWidth() << clEndl;
    }
    if(IsTrimTrailingWhitespaceSet()) {
        clDEBUG1() << "trim_trailing_whitespace:" << IsTrimTrailingWhitespace() << clEndl;
    }
}
示例#5
0
	/// Indent if newline was added.
	void OnCharAdded(wxScintillaEvent &event) {
		// Change this if support for mac files with \r is needed
		if (event.GetKey() == '\n' || event.GetKey() == '\r') {
			int currentLine = GetCurrentLine();
			if (currentLine <= 0) {
				return;
			}

			// width of one indent character
			int indentWidth = (GetUseTabs() ? GetTabWidth() : 1);
			if (indentWidth == 0) {
				return;
			}

			// indent as prev line level
			int indentSize = GetLineIndentation(currentLine - 1);
			SetLineIndentation(currentLine, indentSize);

			// position = (line start pos) + (tabs count) + (space count)
			GotoPos(PositionFromLine(currentLine)
				+ (indentSize / indentWidth)
				+ (indentSize % indentWidth));

			// notify that the text was changed
			ChangeModified(true);
		}
	}
示例#6
0
文件: kguitab.cpp 项目: CarlHuff/kgui
void kGUITabObj::UpdateTabs(void)
{
	if(m_hidetabs)
		m_numtabrows=0;
	else
	{
		int i,x,y,tw;
		int	w;
		int l,r,h,exp;
		int gap=(m_close==true)?18+8:8;

		/* get the pixels size for the left/right and height of the tabs */
		/* from the current skin engine. "exp"=expand size when tab is selected. */
		kGUI::GetSkin()->GetTabSize(&exp,&l,&r,&h);

		w=(GetZoneW())-(exp<<1);	/* allow space for expanded (current) tab */
		m_numtabrows=1;				/* start with one row for tabs */
		y=exp;						/* larger (current) tab is exp pixels taller and wider*2 */
		x=exp+m_starttabx;			/* than all other tabs so leave room for it to expand */
		for(i=0;i<m_numtabs;++i)
		{
			tw=GetTabWidth(i)+gap+l+r;	/* pixel space needed for tab */
			if((x+tw)>w)
			{
				x=exp;	/* need another row to fit tabs so start a new row */
				y+=h;
				++m_numtabrows;
			}
			m_tabx.SetEntry(i,x);	/* save tab position so we don't need to re-calc unless */
			m_taby.SetEntry(i,y);	/* tabs are added */
			x+=tw;
		}
	}
	DirtyandCalcChildZone();	/* child size varies by space needed for the tabs so re-calc */
}
示例#7
0
Image HeaderCtrl::CursorImage(Point p, dword) {
	if(mode == FIXED)
		return Image::Arrow();
	if(HasCapture())
		return split >= 0 ? CtrlsImg::HorzPos() : Image::Arrow();
	int q = GetSplit(p.x);
	return q < 0 ? Image::Arrow()
	             : GetTabWidth(q) < 4 ? CtrlsImg::HorzSplit()
	                                  : CtrlsImg::HorzPos();
}
示例#8
0
void HeaderCtrl::MouseMove(Point p, dword keyflags) {
	if(isdrag) {
		ti = GetLastVisibleTab() + 1;
		for(int i = 0; i < GetCount(); i++)
			if(col[i].visible) {
				Rect r = GetTabRect(i).OffsetedHorz(-sb);
				if(p.x < r.left + r.Width() / 2) {
					ti = i;
					break;
				}
			}
		dragx = p.x;
		Refresh();
		return;
	}
	int q = GetSplit(p.x);
	int cx = ~q;
	if(cx >= 0 && cx < col.GetCount() && !IsNull(col[cx].tip))
		Tip(col[cx].tip);
	if(mode == FIXED)
		return;
	q = IsNull(q) || q >= 0 ? -1 : -1 - q;
	if(q != light)
		Refresh();
	if(!HasCapture())
		return;
	Size sz = GetSize();
	int x = mode == SCROLL ? p.x + sb : min(sz.cx, p.x);
	if(split >= 0) {
		int w = x - colRect.left;
		if(w < 0) w = 0;
		if(w != GetTabWidth(split)) {
			SetTabWidth0(split, w);
			Refresh();
			if(track) {
				Sync();
				Action();
				WhenLayout();
			}
		}
	}
}
示例#9
0
文件: kguitab.cpp 项目: CarlHuff/kgui
void kGUITabObj::Draw(void)
{
	int i,x,y;
	kGUICorners c;
	kGUICorners cc;
	int l,r,h,exp;
	kGUI::GetSkin()->GetTabSize(&exp,&l,&r,&h);
	int gap=(m_close==true)?18+8:8;

	kGUI::PushClip();
	GetCorners(&c);
	kGUI::ShrinkClip(&c);
	
	/* is there anywhere to draw? */
	if(kGUI::ValidClip())
	{
		/* draw background */
		kGUI::DrawRect(c.lx,c.ty+exp+(h*m_numtabrows),c.rx,c.ty+exp+(h*m_numtabrows)+1,DrawColor(145,167,180));
		kGUI::DrawRectBevel(c.lx,c.ty+exp+(h*m_numtabrows)+1,c.rx,c.by,false);
		
		/* draw tab names */
		for(i=0;i<m_numtabs;++i)
		{
			x=c.lx+m_tabx.GetEntry(i);
			y=c.ty+m_taby.GetEntry(i);
			kGUI::GetSkin()->DrawTab(x,y,GetTabWidth(i)+gap,i==m_curtab,i==m_overtab,m_close);
			DrawTab(i,m_tabnames.GetEntryPtr(i),x+6,y+3);
		}

		if(m_numtabs)	/* if no tabs then m_curtab is not valid doh! */
		{
			kGUI::PushClip();
			GetChildCorners(&cc);
			kGUI::ShrinkClip(&cc);
			if(kGUI::ValidClip())
				DrawC(m_tabgroups.GetEntry(m_curtab));	/* draw all children of the currently selected tab */
			kGUI::PopClip();
		}
	}
	kGUI::PopClip();
}
示例#10
0
文件: kguitab.cpp 项目: CarlHuff/kgui
/* only dirty a specific tab at the top, not the whole thing */
void kGUITabObj::DirtyTab(int tab)
{
	kGUICorners c;
	kGUICorners tc;
	int tw;
	int l,r,h,exp;
	int gap=(m_close==true)?18+8:8;

	/* -1 == no current overtab, so ignore */
	if(tab<0 || m_hidetabs)
		return;

	/* calc size of tab area */
	kGUI::GetSkin()->GetTabSize(&exp,&l,&r,&h);
	GetCorners(&c);
	tw=GetTabWidth(tab)+gap+l+r;
	tc.lx=c.lx+m_tabx.GetEntry(tab);
	tc.rx=tc.lx+tw;
	tc.ty=c.ty+m_taby.GetEntry(tab);
	tc.by=tc.ty+h;

	Dirty(&tc);
}
示例#11
0
int IWnd_stc::GetIndentWidth()
{
	return GetUseTabs() ? GetTabWidth() : 1;
}
示例#12
0
// Layout tabs (optional, e.g. if resizing window)
void wxTabView::LayoutTabs(void)
{
  // Make a list of the tab controls, deleting the wxTabLayers.
  wxList controls;

  wxTabLayerList::compatibility_iterator layerNode = m_layers.GetFirst();
  while (layerNode)
  {
    wxTabLayer *layer = (wxTabLayer *)layerNode->GetData();
    wxList::compatibility_iterator tabNode = layer->GetFirst();
    while (tabNode)
    {
      wxTabControl *tab = (wxTabControl *)tabNode->GetData();
      controls.Append(tab);
      wxList::compatibility_iterator next = tabNode->GetNext();
      layer->Erase(tabNode);
      tabNode = next;
    }
    wxTabLayerList::compatibility_iterator nextLayerNode = layerNode->GetNext();
    delete layer;
    m_layers.Erase(layerNode);
    layerNode = nextLayerNode;
  }

  wxTabControl *lastTab = NULL;

  wxTabLayer *currentLayer = new wxTabLayer;
  m_layers.Append(currentLayer);

  wxList::compatibility_iterator node = controls.GetFirst();
  while (node)
  {
    wxTabControl *tabControl = (wxTabControl *)node->GetData();
    if (lastTab)
    {
      // Start another layer (row).
      // Tricky choice: can't just check if will be overlapping the edge, because
      // this happens anyway for 2nd and subsequent rows.
      // Should check this for 1st row, and then subsequent rows should not exceed 1st
      // in length.
      if (((currentLayer == m_layers.GetFirst()->GetData()) && ((lastTab->GetX() + 2*lastTab->GetWidth() + GetHorizontalTabSpacing())
                > GetViewRect().width)) ||
          ((currentLayer != m_layers.GetFirst()->GetData()) && (currentLayer->GetCount() == ((wxTabLayer *)m_layers.GetFirst()->GetData())->GetCount())))
     {
       currentLayer = new wxTabLayer;
       m_layers.Append(currentLayer);
       lastTab = NULL;
     }
    }

    int layer = m_layers.GetCount() - 1;

    tabControl->SetRowPosition(currentLayer->GetCount());
    tabControl->SetColPosition(layer);

    // Top of new tab
    int verticalOffset = (- GetTopMargin()) - ((layer+1)*GetTabHeight());
    // Offset from view top-left
    int horizontalOffset = 0;
    if (!lastTab)
      horizontalOffset = layer*GetHorizontalTabOffset();
    else
      horizontalOffset = lastTab->GetX() + GetTabWidth() + GetHorizontalTabSpacing();

    tabControl->SetPosition(horizontalOffset, verticalOffset);
    tabControl->SetSize(GetTabWidth(), GetTabHeight());

    currentLayer->Append(tabControl);
    lastTab = tabControl;

    node = node->GetNext();
  }

  // Move the selected tab to the bottom
  wxTabControl *control = FindTabControlForId(m_tabSelection);
  if (control)
    MoveSelectionTab(control);

}
示例#13
0
// Automatically positions tabs
// TODO: this should just add the tab to a list, and then
// a layout function (e.g. Realize) should be called when all tabs have been added.
// The view rect could easily change as the view window is resized.
wxTabControl *wxTabView::AddTab(int id, const wxString& label, wxTabControl *existingTab)
{
  // First, find which layer we should be adding to.
  wxTabLayerList::compatibility_iterator node = m_layers.GetLast();
  if (!node)
  {
    wxTabLayer *newLayer = new wxTabLayer;
    node = m_layers.Append(newLayer);
  }
  // Check if adding another tab control would go off the
  // right-hand edge of the layer.
  wxTabLayer *tabLayer = (wxTabLayer *)node->GetData();
  wxList::compatibility_iterator lastTabNode = tabLayer->GetLast();
  if (lastTabNode)
  {
    wxTabControl *lastTab = (wxTabControl *)lastTabNode->GetData();
    // Start another layer (row).
    // Tricky choice: can't just check if will be overlapping the edge, because
    // this happens anyway for 2nd and subsequent rows.
    // Should check this for 1st row, and then subsequent rows should not exceed 1st
    // in length.
    if (((tabLayer == m_layers.GetFirst()->GetData()) && ((lastTab->GetX() + 2*lastTab->GetWidth() + GetHorizontalTabSpacing())
              > GetViewRect().width)) ||
        ((tabLayer != m_layers.GetFirst()->GetData()) && (tabLayer->GetCount() == ((wxTabLayer *)m_layers.GetFirst()->GetData())->GetCount())))
    {
      tabLayer = new wxTabLayer;
      m_layers.Append(tabLayer);
      lastTabNode = wxList::compatibility_iterator();
    }
  }
  int layer = m_layers.GetCount() - 1;

  wxTabControl *tabControl = existingTab;
  if (!existingTab)
    tabControl = OnCreateTabControl();
  tabControl->SetRowPosition(tabLayer->GetCount());
  tabControl->SetColPosition(layer);

  wxTabControl *lastTab = NULL;
  if (lastTabNode)
    lastTab = (wxTabControl *)lastTabNode->GetData();

  // Top of new tab
  int verticalOffset = (- GetTopMargin()) - ((layer+1)*GetTabHeight());
  // Offset from view top-left
  int horizontalOffset = 0;
  if (!lastTab)
    horizontalOffset = layer*GetHorizontalTabOffset();
  else
    horizontalOffset = lastTab->GetX() + GetTabWidth() + GetHorizontalTabSpacing();

  tabControl->SetPosition(horizontalOffset, verticalOffset);
  tabControl->SetSize(GetTabWidth(), GetTabHeight());
  tabControl->SetId(id);
  tabControl->SetLabel(label);
  tabControl->SetFont(* GetTabFont());

  tabLayer->Append(tabControl);
  m_noTabs ++;

  return tabControl;
}
示例#14
0
/* calc the pixel width and maximum pixel height for a given section */
void kGUIText::GetSubSize(int sstart,int slen,unsigned int *pixwidth,unsigned int *pixheight)
{
	unsigned int width;
	unsigned int height;
	unsigned int maxheight;
	kGUIFace *face=0;
	unsigned int size;
	unsigned int *qw=0;
	unsigned int ch;	/* current character */
	unsigned int nb;	/* number of bytes for current character */

	/* optimize: two loops one for rich and one for plain */
	width=0;
	if(GetUseRichInfo()==false)
	{
		/* plain mode, single font and size for whole string */
		maxheight=GetLineHeight();
		if(slen)
		{
			face=kGUIFont::GetFace(GetFontID());
			size=GetFontSize();
			kGUI::SelectFont(face,size);
			qw=face->GetQuickWidths(size);

			width=0;
			while(slen>0)
			{
				ch=GetChar(sstart,&nb);
				//assert(ch!=0,"reading past end of string!");
				sstart+=nb;
				slen-=nb;

				if(ch=='\t')
				{
					int tw;

					tw=GetTabWidth(width);
					if(!tw)
					{
						/* use space width if no defined tabs */
						if(qw && ' '<MAXCCACHE)
							width+=qw[' '];
						else
							width+=face->GetCharWidth(' ');
					}
					width+=tw;
				}
				else
				{
					if(qw && ch<MAXCCACHE)
						width+=qw[ch];
					else
						width+=face->GetCharWidth(ch);
					width+=m_letterspacing;
				}
			}
		}
	}
	else
	{
		/* rich string, can have diff font and size on each character */
		maxheight=0;
		if(slen)
		{
			RICHINFO_DEF *ri;
			unsigned int lastfontid=0;

			size=0;
			while(slen>0)
			{
				ri=GetRichInfoPtr(sstart);
				if((ri->fontid!=lastfontid) || (ri->fontsize!=size))
				{
					size=ri->fontsize;
					lastfontid=ri->fontid;
					face=kGUIFont::GetFace(lastfontid);
					kGUI::SelectFont(face,size);
					qw=face->GetQuickWidths(size);
					height=face->GetPixHeight(size);
					if(height>maxheight)
						maxheight=height;
				}
				ch=GetChar(sstart,&nb);
				assert(ch!=0,"reading past end of string!");
				sstart+=nb;
				slen-=nb;

				if(ch=='\t')
				{
					int tw;

					tw=GetTabWidth(width);
					if(!tw)
					{
						/* use space width if no defined tabs */
						if(qw && ' '<MAXCCACHE)
							width+=qw[' '];
						else
							width+=face->GetCharWidth(' ');
					}
					width+=tw;
				}
				else
				{
					if(qw && ch<MAXCCACHE)
						width+=qw[ch];
					else
						width+=face->GetCharWidth(ch);
					width+=m_letterspacing;
				}
			}
		}
	}
	if(pixwidth)
		pixwidth[0]=width;
	if(pixheight)
		pixheight[0]=maxheight;
}
示例#15
0
const unsigned int kGUIText::CalcFitWidth(unsigned int sstart,unsigned int slen,const unsigned int maxwidth,unsigned int *pixwidth)
{
	int n;
	unsigned int size;
	unsigned int width,cwidth;
	kGUIFace *face=0;
	unsigned int *qw=0;
	unsigned int ch;	/* current character */
	unsigned int nb;	/* number of bytes for current character */

	n=0;
	width=0;
	if(slen)
	{
		if(GetUseRichInfo()==false)
		{
			face=kGUIFont::GetFace(GetFontID());
			size=GetFontSize();
			qw=face->GetQuickWidths(size);
			kGUI::SelectFont(face,size);

			while(slen>0)
			{
				ch=GetChar(sstart,&nb);
				//assert(ch!=0,"reading past end of string!");
				sstart+=nb;
				slen-=nb;

				if(ch==10)
					break;
				if(ch=='\t')
				{
					cwidth=GetTabWidth(width);
					if(!cwidth)
					{
						if(qw && ' '<MAXCCACHE)
							cwidth=qw[' '];
						else
							cwidth=face->GetCharWidth(' ');
					}
				}
				else
				{
					if(qw && ch<MAXCCACHE)
						cwidth=qw[ch];
					else
						cwidth=face->GetCharWidth(ch);
				}
				if((width+cwidth)>maxwidth)
					break;
				n+=nb;
				width+=cwidth;
			}
		}
		else
		{
			RICHINFO_DEF *ri;
			unsigned int lastfontid=0;

			size=0;
			while(slen>0)
			{
				ri=GetRichInfoPtr(sstart);
				if((ri->fontid!=lastfontid) || (ri->fontsize!=size))
				{
					size=ri->fontsize;
					lastfontid=ri->fontid;
					face=kGUIFont::GetFace(lastfontid);
					kGUI::SelectFont(face,size);
					qw=face->GetQuickWidths(size);
				}

				ch=GetChar(sstart,&nb);
				assert(ch!=0,"reading past end of string!");
				sstart+=nb;
				slen-=nb;

				if(ch==10)
					break;
				if(ch=='\t')
				{
					cwidth=GetTabWidth(width);
					if(!cwidth)
					{
						if(qw && ' '<MAXCCACHE)
							cwidth=qw[' '];
						else
							cwidth=face->GetCharWidth(' ');
					}
				}
				else
				{
					if(qw && ch<MAXCCACHE)
						cwidth=qw[ch];
					else
						cwidth=face->GetCharWidth(ch);
				}
				if((width+cwidth)>maxwidth)
					break;
				n+=nb;
				width+=cwidth;
			}
		}
	}
	if(pixwidth)
		pixwidth[0]=width;
	return(n);
}
示例#16
0
void kGUIText::DrawSection(int sstart,int slen,int sx,int x,int y,int rowheight,kGUIColor color)
{
	kGUIFace *face;
	int glyph_index;
	int font_height,font_above,font_below;
	const kGUICorners *clip;
	FT_Face ftface;
	int size;
	bool cachesize;
	int *cacheptr;
	unsigned int ch;	/* current character */
	unsigned int nb;	/* number of bytes for current character */
	int ry;
	bool isbold;

	size=GetFontSize();
	if(!size)
		return;

	if(size<MAXQUICKSIZE)
		cachesize=true;	
	else
		cachesize=false;

	face=kGUIFont::GetFace(GetFontID());
	isbold=face->GetBold();
	ftface=face->GetFace();
	font_height=face->GetPixHeight(size);
	ry=y+rowheight-font_height;
	font_above = face->GetPixAscHeight(size);
	font_below = face->GetPixDescHeight(size);

	kGUI::SelectFont(face,size);

	clip=kGUI::GetClipCorners();
	if(y>clip->by)
		return;

	while(slen>0)
	{
		/* get character in current string encoding mode */
		ch=GetChar(sstart,&nb);
		if(!ch)
			return;
		sstart+=nb;
		slen-=nb;

		/* is this character in the cache? */
		if( cachesize==true && (ch<MAXCCACHE))
			cacheptr=face->m_quickcache[size][ch];
		else
			cacheptr=0;
		if(cacheptr)
		{
			DrawChar( (char *)(cacheptr+5),
						x + cacheptr[2],
						y+font_above-cacheptr[3],
						cacheptr[0], cacheptr[1],
						color);

			x+=cacheptr[4];
			x+=m_letterspacing;
			if(x>clip->rx)
				return;
		}
		else
		{
			if(ch=='\t')
			{
				int tw;

				tw=GetTabWidth(x-sx);
				if(!tw)
				{
					if( cachesize==true && (' '<MAXCCACHE))
					{
						cacheptr=face->m_quickcache[size][(int)' '];
						tw=cacheptr[4];
					}
					else
						tw=face->GetCharWidth(' ');
				}
				x+=tw;
				x+=m_letterspacing;
				if(x>clip->rx)
					return;
			}
			else
			{
				glyph_index = FT_Get_Char_Index( ftface, ch );
				if(glyph_index>0)
				{
					if(!FT_Load_Glyph(ftface, glyph_index, FT_LOAD_DEFAULT))
					{
						if(!FT_Render_Glyph( ftface->glyph, ft_render_mode_normal ))
						{
							if(isbold)
								FT_GlyphSlot_Embolden(ftface->glyph);

							/* cache this character? */
							if( cachesize==true && (ch<MAXCCACHE))
							{
								int bsize=ftface->glyph->bitmap.width*ftface->glyph->bitmap.rows;

								cacheptr = new int[5+((bsize)/sizeof(int))+1];
								face->m_quickcache[size][ch]=cacheptr;
								cacheptr[0]=ftface->glyph->bitmap.width;
								cacheptr[1]=ftface->glyph->bitmap.rows;
								cacheptr[2]=ftface->glyph->bitmap_left;
								cacheptr[3]=ftface->glyph->bitmap_top;
								cacheptr[4]=ftface->glyph->advance.x >> 6;
								memcpy(cacheptr+5,ftface->glyph->bitmap.buffer,bsize);
							}

							/* draw to screen using writepixel */
							DrawChar( (char *)ftface->glyph->bitmap.buffer,
										x + ftface->glyph->bitmap_left,
										y+font_above-ftface->glyph->bitmap_top,
										ftface->glyph->bitmap.width, ftface->glyph->bitmap.rows,
										color);

							x+=ftface->glyph->advance.x >> 6;
							x+=m_letterspacing;
							if(x>clip->rx)
								return;
						}
					}
				}
			}
		}
	}
示例#17
0
文件: kguitab.cpp 项目: CarlHuff/kgui
bool kGUITabObj::UpdateInput(void)
{
	kGUICorners c;
	kGUICorners tc;
	kGUICorners cb;
	int i,tw;
	int l,r,h,exp;
	bool over;
	int gap=(m_close==true)?18+8:8;

	if(m_hidetabs==false)
	{
		/* calc size of tab area */
		kGUI::GetSkin()->GetTabSize(&exp,&l,&r,&h);
		GetCorners(&c);
		c.by=c.ty+exp+(h*m_numtabrows);

		/* is the mouse over the tab button area? */
		over=kGUI::MouseOver(&c);
		if(over)
		{
			/* if i'm not active then activate me */
			/* I need to be active so I can track the mouse when it moves */
			/* off of the tab area so I can unhilight the last tab under the cursor */
			if(m_track==false && m_locked==false)
			{
				m_track=true;
				kGUI::AddUpdateTask(this,CALLBACKNAME(Track));
			}
			/* yes they have mouse over the tabs on the top */
			/* which tab is the mouse over? (if any) */
			for(i=0;i<m_numtabs;++i)
			{
				tw=GetTabWidth(i)+gap+l+r;
				tc.lx=c.lx+m_tabx.GetEntry(i);
				tc.rx=tc.lx+tw;
				tc.ty=c.ty+m_taby.GetEntry(i);
				tc.by=tc.ty+h;

				if(kGUI::MouseOver(&tc))
				{
					if(m_locked==false)
					{
						/* yes mouse is over this tab */
						if(i!=m_overtab)
						{
							DirtyTab(m_overtab);
							DirtyTab(i);
							m_overtab=i;
						}
						/* check for clicking on the close button */
						if(i==m_curtab && m_close && kGUI::GetMouseReleaseLeft()==true)
						{
							/* position of close button */
							cb.lx=tc.rx-r-16;
							cb.rx=cb.lx+14;
							cb.ty=tc.ty+2;
							cb.by=cb.ty+14;
							if(kGUI::MouseOver(&cb))
							{
								kGUIEvent e;

								e.m_value[0].i=m_curtab;		/* tab being closed */

								/* then call tabclicked closed callback, it is up to the app to actually handle */
								Dirty();
								CallEvent(EVENT_CLOSE,&e);
								return(true);
							}
						}
					}

					/* are they rightclicking on the tab? */
					if(kGUI::GetMouseClickRight()==true)
					{
						if(m_locked)
						{
							kGUIEvent e;
							e.m_value[0].i=i;

							CallEvent(EVENT_TRYMOVED,&e);
						}
						else if(m_overtab!=m_curtab)	/* set this to the current tab first */
						{
							kGUIEvent e;

							kGUI::ClearActiveStack();
							e.m_value[0].i=m_curtab;		/* save the old value */
							m_curtab=m_overtab;

							/* then call tabclicked callback */
							CallEvent(EVENT_MOVED,&e);
						}
						/* then call rightclick tab callback */
						CallEvent(EVENT_RIGHTCLICK);
					}
					if(kGUI::GetMouseReleaseLeft()==true)
					{
						if(m_locked)
						{
							kGUIEvent e;
							e.m_value[0].i=i;

							CallEvent(EVENT_TRYMOVED,&e);
						}
						else if(m_overtab!=m_curtab)
						{
							kGUIEvent e;

							kGUI::ClearActiveStack();
							e.m_value[0].i=m_curtab;		/* save the old value */
							m_curtab=m_overtab;
							Dirty();
							/* call the tabclicked callback */
							CallEvent(EVENT_MOVED,&e);
						}
					}
					return(true);
				}
			}
		}

		/* if we got here then the mouse is not hovering over any of the tabs */
		/* so we need to reset the overtab variable back to "not over any" (-1) */
		if(m_overtab!=-1)
		{
			DirtyTab(m_overtab);	/* redraw */
			m_overtab=-1;
		}
	}

	/* send input to children of currently selected tab */
	if(m_numtabs)
		return(UpdateInputC(m_tabgroups.GetEntry(m_curtab)));
	return(false);
}
示例#18
0
int HeaderCtrl::GetNextTabWidth(int i) {
	while(++i < col.GetCount())
		if(col[i].visible)
			return GetTabWidth(i);
	return 0;
}