示例#1
0
void ArpDocumentButton::Draw(BRect)
{
	enum {
		ShineColor = 0,
		MedShineColor = 1,
		ShadowColor = 2,
		MedShadowColor = 3,
		NumColors = 4
	};
	
	static float ColorTints[NumColors] = {
		.2, B_DARKEN_2_TINT,
		B_DARKEN_4_TINT, B_DARKEN_1_TINT
	};
	
	static int32 StandardMap[NumColors] = {
		ShineColor, MedShineColor,
		ShadowColor, MedShadowColor
	};
	
	static int32 PressedMap[NumColors] = {
		ShadowColor, MedShadowColor,
		ShineColor, MedShineColor
	};
	
	rgb_color bgcolor = LowColor();
	if( mDropped ) bgcolor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
	
	BRect bounds(Bounds());
	
	ArpD(cdb << ADH << "Drawing ArpDocument Button..." << endl);
	ArpD(cdb << ADH << "Initial view bounds=" << bounds << endl);
	
	int32* cmap = mPressed ? PressedMap : StandardMap;
	
	BeginLineArray(8);
	rgb_color curcol;
	
	if( bounds.IsValid() ) {
		ArpD(cdb << ADH << "Drawing interior frame at bounds=" << bounds
						<< endl);
		curcol = tint_color(bgcolor, ColorTints[cmap[MedShineColor]]);
		AddLine( BPoint(bounds.left, bounds.bottom),
				 BPoint(bounds.left, bounds.top),
				 curcol );
		AddLine( BPoint(bounds.left, bounds.top),
				 BPoint(bounds.right, bounds.top),
				 curcol );
		
		curcol = tint_color(bgcolor, ColorTints[cmap[ShadowColor]]);
		AddLine( BPoint(bounds.right, bounds.top),
				 BPoint(bounds.right, bounds.bottom),
				 curcol );
		AddLine( BPoint(bounds.right, bounds.bottom),
				 BPoint(bounds.left, bounds.bottom),
				 curcol );
		
		bounds.InsetBy(1, 1);
	}
	
	if( bounds.IsValid() ) {
		ArpD(cdb << ADH << "Drawing interior frame at bounds=" << bounds
						<< endl);
		curcol = tint_color(bgcolor, ColorTints[cmap[ShineColor]]);
		if( IsFocus() ) curcol = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
		AddLine( BPoint(bounds.left, bounds.bottom),
				 BPoint(bounds.left, bounds.top),
				 curcol );
		AddLine( BPoint(bounds.left, bounds.top),
				 BPoint(bounds.right, bounds.top),
				 curcol );
		
		curcol = tint_color(bgcolor, ColorTints[cmap[MedShadowColor]]);
		if( IsFocus() ) curcol = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
		AddLine( BPoint(bounds.right, bounds.top),
				 BPoint(bounds.right, bounds.bottom),
				 curcol );
		AddLine( BPoint(bounds.right, bounds.bottom),
				 BPoint(bounds.left, bounds.bottom),
				 curcol );
					
		bounds.InsetBy(1, 1);
	}
	
	EndLineArray();
	
	BRect ibounds;
	BBitmap* shownBitmap = 0;
	
	if( mPressed ) bgcolor = tint_color(LowColor(), B_DARKEN_MAX_TINT);
	else if( mMenued ) bgcolor = tint_color(LowColor(), B_DARKEN_2_TINT);
	
	if( bounds.IsValid() ) {
		
		shownBitmap = mDocIcon;
		if( shownBitmap ) ibounds = shownBitmap->Bounds();
		if( mSmallIcon
			&& ( !ibounds.IsValid()
				|| ibounds.Width() > bounds.Width()
				|| ibounds.Height() > bounds.Height() ) ) {
			shownBitmap = mSmallIcon;
			ibounds = shownBitmap->Bounds();
		}
		
		ArpD(cdb << ADH << "Current view bounds=" << bounds
						<< ", icon bounds=" << ibounds << endl);

		SetHighColor(bgcolor);
		const float xdiff = bounds.Width() - ibounds.Width();
		const float xoff = floor(xdiff/2);
		if( xdiff > 0 ) {
			// Fill in background to left and right of bitmap.
			if( xoff > 0 ) {
				FillRect(BRect(bounds.left, bounds.top,
							   bounds.left+xoff-1, bounds.bottom));
			}
			FillRect(BRect(bounds.right-(xdiff-xoff)+1, bounds.top,
						   bounds.right, bounds.bottom));
			bounds.left += xoff;
			bounds.right -= (xdiff-xoff);
			ArpD(cdb << ADH << "Fill view X to bounds=" << bounds << endl);
		} else {
			#if 1
			ibounds.left -= xoff;
			ibounds.right += (xdiff-xoff);
			#endif
			ArpD(cdb << ADH << "Indent icon X to bounds=" << ibounds << endl);
		}
		
		const float ydiff = bounds.Height() - ibounds.Height();
		const float yoff = floor(ydiff/2);
		if( ydiff > 0 ) {
			// Fill in background to left and right of bitmap.
			if( yoff > 0 ) {
				FillRect(BRect(bounds.left, bounds.top,
							   bounds.right, bounds.top+yoff-1));
			}
			FillRect(BRect(bounds.left, bounds.bottom-(ydiff-yoff)+1,
						   bounds.right, bounds.bottom));
			bounds.top += yoff;
			bounds.bottom -= (ydiff-yoff);
			ArpD(cdb << ADH << "Fill view Y to bounds=" << bounds << endl);
		} else {
			#if 1
			ibounds.top -= yoff;
			ibounds.bottom += (ydiff-yoff);
			#endif
			ArpD(cdb << ADH << "Indent icon Y to bounds=" << ibounds << endl);
		}
	}
	
	if( bounds.IsValid() && ibounds.IsValid() && shownBitmap ) {
		ArpD(cdb << ADH << "Drawing icon at bounds=" << bounds
						<< ", icon bounds=" << ibounds << endl);
		SetHighColor(bgcolor);
		SetLowColor(bgcolor);
		FillRect(bounds);
		SetDrawingMode(B_OP_ALPHA);
		SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
		DrawBitmapAsync(shownBitmap, ibounds, bounds);
		SetDrawingMode(B_OP_COPY);
	}
}
示例#2
0
void cDialogueList::ParsingLine(DWORD dwId, LPCTSTR buf)
{
	DWORD dwColor = m_dwDefaultColor;
	WORD wLine = WORD(mMessageMap[dwId].size());
	char wBuff[512] = {0};
	int	nCut = 0;
	int nStrLen = 0;

#ifdef _TL_LOCAL_
	BYTE brk[512];
	int nBrkNum = 0;
	int nTextExtent = 0;
#endif

	while( *buf )																	// 버퍼의 정보가 유효하면, while문을 돌린다.
	{
		if( *buf == '$' )															// 버퍼가 '$'와 같으면,
		{
			if( nStrLen != 0 )														// 문자열 길이가 0과 같지 않으면,
			{
				AddLine( dwId, wBuff, dwColor, wLine, emLink_Null );
				ZeroMemory(
					wBuff,
					sizeof(wBuff));
				nStrLen = 0;
			}

			buf += 2;																// 버퍼 포인터를 2증가한다.

			if( *buf == 's' || *buf == 'S' )										// 버퍼의 글자가 s또는 S이면,
			{
				dwColor = m_dwStressColor;											// 색상을 스트레스 색상으로 세팅한다.
			}
			else																	// 그렇지 않을 경우,
			{
				dwColor = m_dwDefaultColor;											// 일반 색상으로 세팅한다.
			}

			++buf;																	// 버퍼 포인터를 증가한다.

			continue;																// while 계속 진행.
		}

#ifdef _TL_LOCAL_	//for WB
		//---
		wBuff[nStrLen] = *buf;
		if( IsDBCSLeadByte( *buf ) )
		{
			++buf;
			++nStrLen;
			++nCut;

			wBuff[nStrLen] = *buf;
		}

		++buf;
		++nStrLen;
		++nCut;

		nTextExtent = CFONT_OBJ->GetTextExtentEx( 0, wBuff, nCut );

		if( nTextExtent > NPCDIALOG_TEXTWIDTH )
		{
			nBrkNum = g_TBreak.FindThaiWordBreak( wBuff, nStrLen, brk, 512, FTWB_SEPARATESYMBOL );

			if( nBrkNum > 1 )
			{
				buf -= brk[nBrkNum-1];
				wBuff[nStrLen-brk[nBrkNum-1]] = 0;
			}
			else
			{
				wBuff[nStrLen] = 0;
			}

			AddLine( dwId, wBuff, dwColor, wLine, emLink_Null );
			memset( wBuff, 0, 512 );

			nStrLen = 0;
			nCut = 0;
			++wLine;
			if( *buf == ' ' )
			{
				++buf;
			}
		}

		//---
#else
		wBuff[nStrLen] = *buf;														// 임시 버퍼의 문자열 길이의 위치에 버퍼의 값을 세팅한다.

		if( IsDBCSLeadByte( *buf ) )												// 버퍼의 값이 한글 바이트의 첫 바이트라면,
		{
			++buf;																	// 버퍼 포인터를 증가한다.
			++nStrLen;																// 문자열 길이를 증가한다.
			++nCut;																	// 컷팅 길이를 증가한다.
			wBuff[nStrLen] = *buf;													// 임시 버퍼의 문자열 길이에 버퍼의 값을 세팅한다.
		}

		++nCut;																		// 컷팅 정보를 증가한다.
		++buf;																		// 버퍼 포인터를 증가한다.
		++nStrLen;																	// 문자열 길이를 증가한다.

		// 091202 ShinJS --- NPC Script Dialog 의 대화 List Dialog의 Text Width와 문자열의 Width를 비교한다.
		cNpcScriptDialog* pNpcScriptDlg	= GAMEIN->GetNpcScriptDialog();
		WORD wListFontIdx	= (pNpcScriptDlg != NULL ? pNpcScriptDlg->GetConversationListFontIdx() : 0);
		LONG textExtent		= (pNpcScriptDlg != NULL ? CFONT_OBJ->GetTextExtentEx( wListFontIdx, wBuff, nCut ) : nCut);
		LONG listWidth		= (pNpcScriptDlg != NULL ? pNpcScriptDlg->GetConversationListTextWidth() : NPCDIALOG_TEXTLEN);

		// 리스트의 문자열이 Text Width 보다 긴 경우 (NPC Script Dialog 를 못찾은 경우 기존방법 사용)
		if( textExtent > listWidth )
		{
			if( nStrLen != 0 )														// 문자열 길이가 0이 아이념,
			{	
				AddLine( dwId, wBuff, dwColor, wLine, emLink_Null );				// 라인을 추가한다.
				nStrLen = 0;
				ZeroMemory(
					wBuff,
					sizeof(wBuff));
			}

			nCut = 0;
			++wLine;
		}
#endif

	}

	if( nStrLen != 0 )																// 문자열 길이가 0과 같지 않으면,
	{
		wBuff[nStrLen] = ' ';
		AddLine( dwId, wBuff, dwColor, wLine, emLink_Null );
	}
}
示例#3
0
void SkGlyphCache::findIntercepts(const SkScalar bounds[2], SkScalar scale, SkScalar xPos,
        bool yAxis, SkGlyph* glyph, SkScalar* array, int* count) {
    const SkGlyph::Intercept* match = MatchBounds(glyph, bounds);

    if (match) {
        if (match->fInterval[0] < match->fInterval[1]) {
            OffsetResults(match, scale, xPos, array, count);
        }
        return;
    }

    SkGlyph::Intercept* intercept = fAlloc.make<SkGlyph::Intercept>();
    intercept->fNext = glyph->fPathData->fIntercept;
    intercept->fBounds[0] = bounds[0];
    intercept->fBounds[1] = bounds[1];
    intercept->fInterval[0] = SK_ScalarMax;
    intercept->fInterval[1] = SK_ScalarMin;
    glyph->fPathData->fIntercept = intercept;
    const SkPath* path = glyph->fPathData->fPath;
    const SkRect& pathBounds = path->getBounds();
    if (*(&pathBounds.fBottom - yAxis) < bounds[0] || bounds[1] < *(&pathBounds.fTop - yAxis)) {
        return;
    }
    SkPath::Iter iter(*path, false);
    SkPoint pts[4];
    SkPath::Verb verb;
    while (SkPath::kDone_Verb != (verb = iter.next(pts))) {
        switch (verb) {
            case SkPath::kMove_Verb:
                break;
            case SkPath::kLine_Verb:
                AddLine(pts, bounds[0], yAxis, intercept);
                AddLine(pts, bounds[1], yAxis, intercept);
                AddPoints(pts, 2, bounds, yAxis, intercept);
                break;
            case SkPath::kQuad_Verb:
                if (!quad_in_bounds(&pts[0].fY - yAxis, bounds)) {
                    break;
                }
                AddQuad(pts, bounds[0], yAxis, intercept);
                AddQuad(pts, bounds[1], yAxis, intercept);
                AddPoints(pts, 3, bounds, yAxis, intercept);
                break;
            case SkPath::kConic_Verb:
                SkASSERT(0);  // no support for text composed of conics
                break;
            case SkPath::kCubic_Verb:
                if (!cubic_in_bounds(&pts[0].fY - yAxis, bounds)) {
                    break;
                }
                AddCubic(pts, bounds[0], yAxis, intercept);
                AddCubic(pts, bounds[1], yAxis, intercept);
                AddPoints(pts, 4, bounds, yAxis, intercept);
                break;
            case SkPath::kClose_Verb:
                break;
            default:
                SkASSERT(0);
                break;
        }
    }
    if (intercept->fInterval[0] >= intercept->fInterval[1]) {
        intercept->fInterval[0] = SK_ScalarMax;
        intercept->fInterval[1] = SK_ScalarMin;
        return;
    }
    OffsetResults(intercept, scale, xPos, array, count);
}
示例#4
0
// odbiera zdarzenia
int HConsole::HandleKey( int key) {
    /* TODO (#1#): Implement HConsole::HandleKey() */
    if (key=='`'||key=='~') {
        m_bOpen=!m_bOpen;
        return 1;
    }


    if (key==SDLK_BACKSPACE) {
        if ( m_iCursorPos ) { // can we suppress safely?

            // suppress last character if cursor is at the last position
            if ( m_iCursorPos == m_iBuferLenght ) {
                m_iCursorPos--;
                m_iBuferLenght--;
                m_szBuffer[m_iCursorPos] = '\0';
            }
            // suppress previous character of current position
            else {
                for ( int j=m_iCursorPos-1; j<m_iBuferLenght-1; j++ ) {
                    m_szBuffer[j] = m_szBuffer[j+1]; // move chars to left
                }
                m_szBuffer[m_iBuferLenght-1] = '\0';
                m_iBuferLenght--;
                m_iCursorPos--;
            }
        }
    }
    if (key==SDLK_RETURN) {
        AddLine(m_szBuffer);
        m_iCursorPos=0;
        m_iBuferLenght=0;
        memset(m_szBuffer,0,CONBUFFSIZE+1);
        return 1;
    }
    if (key==SDLK_DELETE) {
        if ( m_iCursorPos<m_iBuferLenght ) {
            for (int j=m_iCursorPos; j<m_iBuferLenght-1; j++ ) {
                m_szBuffer[j] = m_szBuffer[j+1]; // move chars to left
            }
            m_szBuffer[m_iBuferLenght-1] = '\0';
            m_iBuferLenght--;
        }
        return 1;
    }
    if (key==SDLK_LEFT) {
        if ( m_iCursorPos ) m_iCursorPos--;
        return 1;
    }
    if (key==SDLK_RIGHT) {
        if ( m_iCursorPos<m_iBuferLenght ) m_iCursorPos++;
        return 1;
    }
    if (key==SDLK_HOME) {
        m_iCursorPos = 0;
        return 1;
    }
    if (key==SDLK_END) {
        m_iCursorPos = m_iBuferLenght;
        return 1;
    }

    AddToBuff(key);

    /*  if(key=='r'||key=='R') HTextureManager::GetSingleton().DumpReport();
        if(key=='l'||key=='L') {
        float start=HTimer::GetSingleton().GetCurrentTime();
        HEngineCore::GetSingleton().SetLoadingScreenTitle("I just like this loading screen!");
        HEngineCore::GetSingleton().LoadingScreenUpdate(0);
        while(HTimer::GetSingleton().GetCurrentTime()-start<1000){
        HEngineCore::GetSingleton().LoadingScreenUpdate((HTimer::GetSingleton().GetCurrentTime()-start)/1000);
        }
        HEngineCore::GetSingleton().LoadingScreenUpdate(1);
        }*/
//  printf("Console received \"%s\" key\n",SDL_GetKeyName((SDLKey)key));
}
示例#5
0
void ECvs::ParseLine (char *line,int len) {
    if (len>2&&line[1]==' '&&strchr (CvsStatusChars,line[0])) {
        AddLine (line+2,-1,line,5);
    } else AddLine (0,-1,line);
}
示例#6
0
// Draw
void
SliderView::Draw(BRect updateRect)
{
	fButtonRect.OffsetTo(ButtonOffset(), 6.0);

	rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT);
	rgb_color lightShadow = tint_color(background, B_DARKEN_1_TINT);
	rgb_color shadow = tint_color(background, B_DARKEN_2_TINT);
	rgb_color darkShadow = tint_color(background, B_DARKEN_4_TINT);

	BRect r(Bounds());
	BeginLineArray(24);
		// outer dark line
		AddLine(BPoint(r.left, r.bottom),
				BPoint(r.left, r.top), lightShadow);
		AddLine(BPoint(r.left + 1.0, r.top),
				BPoint(r.right, r.top), lightShadow);
		AddLine(BPoint(r.right, r.top + 1.0),
				BPoint(r.right, r.bottom), darkShadow);
		AddLine(BPoint(r.right - 1.0, r.bottom),
				BPoint(r.left + 1.0, r.bottom), darkShadow);
		// second line (raised)
		r.InsetBy(1.0, 1.0);
		AddLine(BPoint(r.left, r.bottom),
				BPoint(r.left, r.top), light);
		AddLine(BPoint(r.left + 1.0, r.top),
				BPoint(r.right, r.top), light);
		AddLine(BPoint(r.right, r.top + 1.0),
				BPoint(r.right, r.bottom), shadow);
		AddLine(BPoint(r.right - 1.0, r.bottom),
				BPoint(r.left + 1.0, r.bottom), shadow);
		// third line (normal)
		r.InsetBy(1.0, 1.0);
		AddLine(BPoint(r.left, r.bottom),
				BPoint(r.left, r.top), background);
		AddLine(BPoint(r.left + 1.0, r.top),
				BPoint(r.right, r.top), background);
		AddLine(BPoint(r.right, r.top + 1.0),
				BPoint(r.right, r.bottom), background);
		AddLine(BPoint(r.right - 1.0, r.bottom),
				BPoint(r.left + 1.0, r.bottom), background);
		// fourth line (normal)
		r.InsetBy(1.0, 1.0);
		AddLine(BPoint(r.left, r.bottom),
				BPoint(r.left, r.top), background);
		AddLine(BPoint(r.left + 1.0, r.top),
				BPoint(r.right, r.top), background);
		AddLine(BPoint(r.right, r.top + 1.0),
				BPoint(r.right, r.bottom), background);
		AddLine(BPoint(r.right - 1.0, r.bottom),
				BPoint(r.left + 1.0, r.bottom), background);
		// fifth line (depressed)
		r.InsetBy(1.0, 1.0);
		AddLine(BPoint(r.left, r.bottom),
				BPoint(r.left, r.top), lightShadow);
		AddLine(BPoint(r.left + 1.0, r.top),
				BPoint(r.right, r.top), lightShadow);
		AddLine(BPoint(r.right, r.top + 1.0),
				BPoint(r.right, r.bottom), light);
		AddLine(BPoint(r.right - 1.0, r.bottom),
				BPoint(r.left + 1.0, r.bottom), light);
		// fifth line (strongly depressed)
		r.InsetBy(1.0, 1.0);
		AddLine(BPoint(r.left, r.bottom),
				BPoint(r.left, r.top), darkShadow);
		AddLine(BPoint(r.left + 1.0, r.top),
				BPoint(r.right, r.top), darkShadow);
		AddLine(BPoint(r.right, r.top + 1.0),
				BPoint(r.right, r.bottom), shadow);
		AddLine(BPoint(r.right - 1.0, r.bottom),
				BPoint(r.left + 1.0, r.bottom), shadow);
	EndLineArray();

	r.InsetBy(1.0, 1.0);
	SetLowColor(lightShadow);
	BRect leftOfButton(r.left + 1.0, r.top + 1.0, fButtonRect.left - 2.0, r.bottom);
	if (leftOfButton.IsValid())
		FillRect(leftOfButton, B_SOLID_LOW);
	BRect rightOfButton(fButtonRect.right + 2.0, r.top + 1.0,
						r.right, r.bottom);
	if (rightOfButton.IsValid())
		FillRect(rightOfButton, B_SOLID_LOW);

	// inner shadow and knob out lines
	BeginLineArray(5);
		// shadow
		AddLine(BPoint(r.left, r.bottom),
				BPoint(r.left, r.top), shadow);
		AddLine(BPoint(r.left + 1.0, r.top),
				BPoint(r.right, r.top), shadow);
		// at knob
		if (fButtonRect.left == 6.0)
			AddLine(BPoint(fButtonRect.left - 1.0, r.top),
					BPoint(fButtonRect.left - 1.0, r.bottom), darkShadow);
		else
			AddLine(BPoint(fButtonRect.left - 1.0, r.top),
					BPoint(fButtonRect.left - 1.0, r.bottom), shadow);
		AddLine(BPoint(fButtonRect.left, fButtonRect.bottom + 1.0),
				BPoint(fButtonRect.right + 1.0, fButtonRect.bottom + 1.0), darkShadow);
		AddLine(BPoint(fButtonRect.right + 1.0, fButtonRect.bottom),
				BPoint(fButtonRect.right + 1.0, fButtonRect.top), darkShadow);
	EndLineArray();


	DrawSliderButton(this, fButtonRect, fValue, fFormatString.String(), fTarget->IsEnabled());
}
示例#7
0
static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE);
	OrderData *dat = (OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA);

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		dat = (OrderData*)malloc( sizeof(OrderData));
		SetWindowLongPtr(hTree, GWLP_USERDATA, (LONG_PTR)dat);
		dat->dragging = 0;

		SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE)|TVS_NOHSCROLL);

		SetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, g_ctrl->nButtonHeight, FALSE);
		SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETRANGE, 0, MAKELONG(50,10));
		SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonHeight,0));

		SetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, g_ctrl->nButtonWidth, FALSE);
		SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, MAKELONG(50,10));
		SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonWidth,0));

		SetDlgItemInt(hwndDlg, IDC_BUTTGAP, g_ctrl->nButtonSpace, FALSE);
		SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETRANGE, 0, MAKELONG(20,0));
		SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonSpace,0));

		CheckDlgButton(hwndDlg, IDC_USEFLAT, g_ctrl->bFlatButtons);
		CheckDlgButton(hwndDlg, IDC_AUTORESIZE, g_ctrl->bAutoSize);
		CheckDlgButton(hwndDlg, IDC_SINGLELINE, g_ctrl->bSingleLine);

		BuildTree(hwndDlg);
		EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE);
		EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE);
		EnableWindow(GetDlgItem(hwndDlg, IDC_DELLBUTTON), FALSE);

		OptionshWnd = hwndDlg;
		return TRUE;

	case WM_COMMAND:
		if (HIWORD(wParam) == EN_CHANGE && OptionshWnd) {
			switch(LOWORD(wParam)) {
			case IDC_ENAME: case IDC_EPATH:
				break;
			default:
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			}
			break;
		}

		if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DBLCLK)) {
			int ctrlid = LOWORD(wParam);

			//----- Launch buttons -----

			if (ctrlid == IDC_BROWSE) {
				TCHAR str[MAX_PATH];
				OPENFILENAME ofn = {0};

				GetDlgItemText(hwndDlg, IDC_EPATH, str, sizeof(str));
				ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
				ofn.hwndOwner = hwndDlg;
				ofn.hInstance = NULL;
				ofn.lpstrFilter = NULL;
				ofn.lpstrFile = str;
				ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER;
				ofn.nMaxFile = sizeof(str);
				ofn.nMaxFileTitle = MAX_PATH;
				ofn.lpstrDefExt = _T("exe");
				if (!GetOpenFileName(&ofn))
					break;

				SetDlgItemText(hwndDlg, IDC_EPATH, str);

				break;
			}

			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);

			if (ctrlid == IDC_LBUTTONSET) {
				TVITEM tvi ={0};
				tvi.hItem = TreeView_GetSelection(hTree);
				if (tvi.hItem == NULL)
					break;

				tvi.mask = TVIF_PARAM;
				TreeView_GetItem(hTree, &tvi);

				TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
				TCHAR buf [256];
				// probably, condition not needs
				if (btn->dwFlags & TTBBF_ISLBUTTON) {
					if (!(btn->dwFlags & TTBBF_OPTIONAL)) {
						// create button
						TTBButton ttb = { 0 };
						ttb.cbSize = sizeof(ttb);
						ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
						ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
						ttb.name = NULL;
						ttb.program = NULL;
						int id = btn->id;
						btn = CreateButton(&ttb);
						btn->id = id;

						tvi.lParam = (LPARAM)btn;
						TreeView_SetItem(hTree, &tvi);
					}

					GetDlgItemText(hwndDlg, IDC_ENAME, buf, 255);
					replaceStr(btn->pszName, _T2A(buf));

					tvi.mask = TVIF_TEXT;
					tvi.pszText = buf;
					TreeView_SetItem(hTree, &tvi);

					GetDlgItemText(hwndDlg, IDC_EPATH, buf, 255);
					replaceStrT(btn->ptszProgram, buf);
				}
				break;
			}

			if (ctrlid == IDC_ADDLBUTTON) {
				// create button
				TTBButton ttb = { 0 };
				ttb.cbSize = sizeof(ttb);
				ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
				ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
				ttb.name = LPGEN("Default");
				ttb.program = _T("Execute Path");
				TopButtonInt* b = CreateButton(&ttb);

				// get selection for insert
				TVITEM tvi = {0};
				tvi.hItem = TreeView_GetSelection(hTree);

				// insert item
				AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons);

				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;
			}

			//----- Separators -----

			if (ctrlid == IDC_ADDSEP) {
				// create button
				TTBButton ttb = { 0 };
				ttb.cbSize = sizeof(ttb);
				ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL | TTBBF_OPTIONAL;
				TopButtonInt* b = CreateButton(&ttb);

				// get selection for insert
				TVITEM tvi = {0};
				tvi.hItem = TreeView_GetSelection(hTree);

				// insert item
				AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons);

				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;
			}

			if (ctrlid == IDC_REMOVEBUTTON) {
				TVITEM tvi = {0};
				tvi.hItem = TreeView_GetSelection(hTree);
				if (tvi.hItem == NULL)
					break;

				tvi.mask = TVIF_PARAM;
				TreeView_GetItem(hTree, &tvi);

				TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
				// if button enabled for separator and launch only, no need condition
				// except possible service button introducing
				if (btn->dwFlags & (TTBBF_ISSEPARATOR | TTBBF_ISLBUTTON)) {
					// delete if was added in options
					if (btn->dwFlags & TTBBF_OPTIONAL)
						delete btn;

					TreeView_DeleteItem(hTree,tvi.hItem);

					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				}
				break;
			}
		}
		break;

	case WM_NOTIFY:
		switch(((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
			case PSN_APPLY:
				g_ctrl->nButtonHeight = GetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, NULL, FALSE);
				g_ctrl->nButtonWidth = GetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, NULL, FALSE);
				g_ctrl->nButtonSpace = GetDlgItemInt(hwndDlg, IDC_BUTTGAP, NULL, FALSE);
				
				g_ctrl->bFlatButtons = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_USEFLAT);
				g_ctrl->bAutoSize = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTORESIZE);
				g_ctrl->bSingleLine = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SINGLELINE);

				db_set_dw(0, TTB_OPTDIR, "BUTTHEIGHT", g_ctrl->nButtonHeight);
				db_set_dw(0, TTB_OPTDIR, "BUTTWIDTH", g_ctrl->nButtonWidth);
				db_set_dw(0, TTB_OPTDIR, "BUTTGAP", g_ctrl->nButtonSpace);

				db_set_b(0, TTB_OPTDIR, "UseFlatButton", g_ctrl->bFlatButtons);
				db_set_b(0, TTB_OPTDIR, "SingleLine", g_ctrl->bSingleLine);
				db_set_b(0, TTB_OPTDIR, "AutoSize", g_ctrl->bAutoSize);

				SaveTree(hwndDlg);
				RecreateWindows();
				ArrangeButtons();
			}
			break;

		case IDC_BUTTONORDERTREE:
			switch (((LPNMHDR)lParam)->code) {
			case TVN_BEGINDRAGA:
			case TVN_BEGINDRAGW:
				SetCapture(hwndDlg);
				dat->dragging = 1;
				dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem;
				TreeView_SelectItem(hTree, dat->hDragItem);
				break;

			case NM_CLICK:
				{
					TVHITTESTINFO hti;
					hti.pt.x = (short)LOWORD(GetMessagePos());
					hti.pt.y = (short)HIWORD(GetMessagePos());
					ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
					if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti))
						if (hti.flags & TVHT_ONITEMSTATEICON) {
							SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
							TreeView_SelectItem(hTree, hti.hItem);
						}
				}
				break;

			case TVN_SELCHANGEDA:
			case TVN_SELCHANGEDW:
				{
					HTREEITEM hti = TreeView_GetSelection(hTree);
					if (hti == NULL)
						break;

					TopButtonInt *btn = (TopButtonInt*)((LPNMTREEVIEW)lParam)->itemNew.lParam;

					mir_cslock lck(csButtonsHook);

					if (btn->dwFlags & TTBBF_ISLBUTTON) {
						bool enable = (btn->dwFlags & TTBBF_INTERNAL) !=0;
						EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), enable);
						EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), enable);
						EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVEBUTTON), enable);
						EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), enable);
						if (btn->pszName != NULL)
							SetDlgItemTextA(hwndDlg, IDC_ENAME, btn->pszName);
						else
							SetDlgItemTextA(hwndDlg, IDC_ENAME, "");

						if (btn->ptszProgram != NULL)
							SetDlgItemText(hwndDlg, IDC_EPATH, btn->ptszProgram);
						else
							SetDlgItemTextA(hwndDlg, IDC_EPATH, "");
					}
					else {
						EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVEBUTTON),
								(btn->dwFlags & TTBBF_ISSEPARATOR)?TRUE:FALSE);

						EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE);
						EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE);
						EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), FALSE);
						SetDlgItemTextA(hwndDlg, IDC_ENAME, "");
						SetDlgItemTextA(hwndDlg, IDC_EPATH, "");
					}
				}
			}
			break;
		}
		break;

	case WM_MOUSEMOVE:
		if (dat->dragging) {
			TVHITTESTINFO hti;
			hti.pt.x = (short)LOWORD(lParam);
			hti.pt.y = (short)HIWORD(lParam);
			ClientToScreen(hwndDlg, &hti.pt);
			ScreenToClient(hTree, &hti.pt);
			TreeView_HitTest(hTree, &hti);
			if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
				HTREEITEM it=hti.hItem;
				hti.pt.y -= TreeView_GetItemHeight(hTree)/2;
				TreeView_HitTest(hTree, &hti);
				if (!(hti.flags&TVHT_ABOVE))
					TreeView_SetInsertMark(hTree,hti.hItem,1);
				else 
					TreeView_SetInsertMark(hTree,it,0);
			}
			else {
				if (hti.flags & TVHT_ABOVE) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
				if (hti.flags & TVHT_BELOW) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
				TreeView_SetInsertMark(hTree, NULL, 0);
			}
		}
		break;

	case WM_LBUTTONUP:
		if (dat->dragging) {
			TreeView_SetInsertMark(hTree, NULL, 0);
			dat->dragging = 0;
			ReleaseCapture();

			TVHITTESTINFO hti;
			hti.pt.x = (short)LOWORD(lParam);
			hti.pt.y = (short)HIWORD(lParam);
			ClientToScreen(hwndDlg, &hti.pt);
			ScreenToClient(hTree, &hti.pt);
			hti.pt.y -= TreeView_GetItemHeight(hTree)/2;
			TreeView_HitTest(hTree, &hti);
			if (dat->hDragItem == hti.hItem)
				break;
			if (hti.flags&TVHT_ABOVE)
				hti.hItem=TVI_FIRST;

			TVITEM tvi;
			tvi.mask = TVIF_HANDLE|TVIF_PARAM;
			tvi.hItem = (HTREEITEM) dat->hDragItem;
			TreeView_GetItem(hTree, &tvi);
			if ( (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) || (hti.hItem==TVI_FIRST)) {
				TVINSERTSTRUCT tvis;
				TCHAR name[128];
				tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
				tvis.item.stateMask = 0xFFFFFFFF;
				tvis.item.pszText = name;
				tvis.item.cchTextMax = SIZEOF(name);
				tvis.item.hItem = dat->hDragItem;
				TreeView_GetItem(hTree, &tvis.item);

				TreeView_DeleteItem(hTree, dat->hDragItem);
				tvis.hParent = NULL;
				tvis.hInsertAfter = hti.hItem;
				TreeView_SelectItem(hTree, TreeView_InsertItem(hTree, &tvis));

				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			}
		}
		break;

	case WM_DESTROY:
		if (dat) {
			ImageList_Destroy(dat->himlButtonIcons);
			free(dat);
		}
		OptionshWnd = NULL;
		break;
	}
	return FALSE;
}
示例#8
0
void DebugRenderer::AddFrustum(const Frustum& frustum, const Color& color, bool depthTest)
{
    const Vector3* vertices = frustum.vertices_;
    unsigned uintColor = color.ToUInt();

    AddLine(vertices[0], vertices[1], uintColor, depthTest);
    AddLine(vertices[1], vertices[2], uintColor, depthTest);
    AddLine(vertices[2], vertices[3], uintColor, depthTest);
    AddLine(vertices[3], vertices[0], uintColor, depthTest);
    AddLine(vertices[4], vertices[5], uintColor, depthTest);
    AddLine(vertices[5], vertices[6], uintColor, depthTest);
    AddLine(vertices[6], vertices[7], uintColor, depthTest);
    AddLine(vertices[7], vertices[4], uintColor, depthTest);
    AddLine(vertices[0], vertices[4], uintColor, depthTest);
    AddLine(vertices[1], vertices[5], uintColor, depthTest);
    AddLine(vertices[2], vertices[6], uintColor, depthTest);
    AddLine(vertices[3], vertices[7], uintColor, depthTest);
}
示例#9
0
bool wxTextFile::OnRead(const wxMBConv& conv)
{
    // file should be opened
    wxASSERT_MSG( m_file.IsOpened(), wxT("can't read closed file") );

    // read the entire file in memory: this is not the most efficient thing to
    // do it but there is no good way to avoid it in Unicode build because if
    // we read the file block by block we can't convert each block to Unicode
    // separately (the last multibyte char in the block might be only partially
    // read and so the conversion would fail) and, as the file contents is kept
    // in memory by wxTextFile anyhow, it shouldn't be a big problem to read
    // the file entirely
    size_t bufSize = 0;

    // number of bytes to (try to) read from disk at once
    static const size_t BLOCK_SIZE = 4096;

    wxCharBuffer buf;

    // first determine if the file is seekable or not and so whether we can
    // determine its length in advance
    wxFileOffset fileLength;
    {
        wxLogNull logNull;
        fileLength = m_file.Length();
    }

    // some non-seekable files under /proc under Linux pretend that they're
    // seekable but always return 0; others do return an error
    const bool seekable = fileLength != wxInvalidOffset && fileLength != 0;
    if ( seekable )
    {
        // we know the required length, so set the buffer size in advance
        bufSize = fileLength;
        if ( !buf.extend(bufSize) )
            return false;

        // if the file is seekable, also check that we're at its beginning
        wxASSERT_MSG( m_file.Tell() == 0, wxT("should be at start of file") );

        char *dst = buf.data();
        for ( size_t nRemaining = bufSize; nRemaining > 0; )
        {
            size_t nToRead = BLOCK_SIZE;

            // the file size could have changed, avoid overflowing the buffer
            // even if it did
            if ( nToRead > nRemaining )
                nToRead = nRemaining;

            ssize_t nRead = m_file.Read(dst, nToRead);

            if ( nRead == wxInvalidOffset )
            {
                // read error (error message already given in wxFile::Read)
                return false;
            }

            if ( nRead == 0 )
            {
                // this file can't be empty because we checked for this above
                // so this must be the end of file
                break;
            }

            dst += nRead;
            nRemaining -= nRead;
        }

        wxASSERT_MSG( dst - buf.data() == (wxFileOffset)bufSize,
                      wxT("logic error") );
    }
    else // file is not seekable
    {
        char block[BLOCK_SIZE];
        for ( ;; )
        {
            ssize_t nRead = m_file.Read(block, WXSIZEOF(block));

            if ( nRead == wxInvalidOffset )
            {
                // read error (error message already given in wxFile::Read)
                return false;
            }

            if ( nRead == 0 )
            {
                // if no bytes have been read, presumably this is a
                // valid-but-empty file
                if ( bufSize == 0 )
                    return true;

                // otherwise we've finished reading the file
                break;
            }

            // extend the buffer for new data
            if ( !buf.extend(bufSize + nRead) )
                return false;

            // and append it to the buffer
            memcpy(buf.data() + bufSize, block, nRead);
            bufSize += nRead;
        }
    }

    const wxString str(buf, conv, bufSize);

    // there's no risk of this happening in ANSI build
#if wxUSE_UNICODE
    if ( bufSize > 4 && str.empty() )
    {
        wxLogError(_("Failed to convert file \"%s\" to Unicode."), GetName());
        return false;
    }
#endif // wxUSE_UNICODE

    // we don't need this memory any more
    buf.reset();


    // now break the buffer in lines

    // the beginning of the current line, changes inside the loop
    wxString::const_iterator lineStart = str.begin();
    const wxString::const_iterator end = str.end();
    for ( wxString::const_iterator p = lineStart; p != end; p++ )
    {
        const wxChar ch = *p;
        if ( ch == '\r' || ch == '\n' )
        {
            // Determine the kind of line ending this is.
            wxTextFileType lineType = wxTextFileType_None;
            if ( ch == '\r' )
            {
                wxString::const_iterator next = p + 1;
                if ( next != end && *next == '\n' )
                    lineType = wxTextFileType_Dos;
                else
                    lineType = wxTextFileType_Mac;
            }
            else // ch == '\n'
            {
                lineType = wxTextFileType_Unix;
            }

            AddLine(wxString(lineStart, p), lineType);

            // DOS EOL is the only one consisting of two chars, not one.
            if ( lineType == wxTextFileType_Dos )
                p++;

            lineStart = p + 1;
        }
    }

    // anything in the last line?
    if ( lineStart != end )
    {
        // Add the last line; notice that it is certainly not terminated with a
        // newline, otherwise it would be handled above.
        wxString lastLine(lineStart, end);
        AddLine(lastLine, wxTextFileType_None);
    }

    return true;
}
示例#10
0
void
SeekSlider::Draw(BRect updateRect)
{
    BRect r(Bounds());

    // draw both sides (the original from Be doesn't seem
    // to make a difference for enabled/disabled state)
//	DrawBitmapAsync(fLeftSideBits, r.LeftTop());
//	DrawBitmapAsync(fRightSideBits, BPoint(sliderEnd + 1.0, r.top));
    // colors for the slider area between the two bitmaps
    rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
    rgb_color shadow = tint_color(background, B_DARKEN_2_TINT);
    rgb_color softShadow = tint_color(background, B_DARKEN_1_TINT);
    rgb_color darkShadow = tint_color(background, B_DARKEN_4_TINT);
    rgb_color midShadow = tint_color(background, B_DARKEN_3_TINT);
    rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT);
    rgb_color softLight = tint_color(background, B_LIGHTEN_1_TINT);
    rgb_color green = kSeekGreen;
    rgb_color greenShadow = kSeekGreenShadow;
    rgb_color black = kBlack;
    rgb_color dotGrey = midShadow;
    rgb_color dotGreen = greenShadow;
    // draw frame
    _StrokeFrame(r, softShadow, softShadow, light, light);
    r.InsetBy(1.0, 1.0);
    _StrokeFrame(r, black, black, softShadow, softShadow);
    if (IsEnabled()) {
        // *** enabled look ***
        r.InsetBy(1.0, 1.0);
        // inner shadow
        _StrokeFrame(r, greenShadow, greenShadow, green, green);
        r.top++;
        r.left++;
        _StrokeFrame(r, greenShadow, greenShadow, green, green);
        // inside area
        r.InsetBy(1.0, 1.0);
        SetHighColor(green);
        FillRect(r);
        // dots
        int32 dotCount = (int32)(r.Width() / 6.0);
        BPoint dotPos;
        dotPos.y = r.top + 2.0;
        SetHighColor(dotGreen);

        float knobWidth2 = SEEK_SLIDER_KNOB_WIDTH / 2.0;
        float sliderStart = (r.left + knobWidth2);

        for (int32 i = 0; i < dotCount; i++) {
            dotPos.x = sliderStart + i * 6.0;
            StrokeLine(dotPos, BPoint(dotPos.x, dotPos.y + 6.0));
        }
        // slider handle
        r.top -= 4.0;
        r.bottom += 3.0;
        r.left = fKnobPos - knobWidth2;
        r.right = fKnobPos + knobWidth2;
        // black outline
        float handleBottomSize = 2.0;
        float handleArrowSize = 6.0;
        BeginLineArray(10);
        // upper handle
        AddLine(BPoint(r.left, r.top + handleBottomSize),
                BPoint(r.left, r.top), black);
        AddLine(BPoint(r.left + 1.0, r.top),
                BPoint(r.right, r.top), black);
        AddLine(BPoint(r.right, r.top + 1.0),
                BPoint(r.right, r.top + handleBottomSize), black);
        AddLine(BPoint(r.right - 1.0, r.top + handleBottomSize + 1.0),
                BPoint(fKnobPos, r.top + handleArrowSize), black);
        AddLine(BPoint(fKnobPos - 1.0, r.top + handleArrowSize - 1.0),
                BPoint(r.left + 1.0, r.top + handleBottomSize + 1.0), black);
        // lower handle
        AddLine(BPoint(r.left, r.bottom),
                BPoint(r.left, r.bottom - handleBottomSize), black);
        AddLine(BPoint(r.left + 1.0, r.bottom - handleBottomSize - 1.0),
                BPoint(fKnobPos, r.bottom - handleArrowSize), black);
        AddLine(BPoint(fKnobPos + 1.0, r.bottom - handleArrowSize + 1.0),
                BPoint(r.right, r.bottom - handleBottomSize), black);
        AddLine(BPoint(r.right, r.bottom - handleBottomSize + 1.0),
                BPoint(r.right, r.bottom), black);
        AddLine(BPoint(r.right - 1.0, r.bottom),
                BPoint(r.left + 1.0, r.bottom), black);
        EndLineArray();
        // inner red light and shadow lines
        r.InsetBy(1.0, 1.0);
        handleBottomSize--;
        handleArrowSize -= 2.0;
        BeginLineArray(10);
        // upper handle
        AddLine(BPoint(r.left, r.top + handleBottomSize),
                BPoint(r.left, r.top), kSeekRedLight);
        AddLine(BPoint(r.left + 1.0, r.top),
                BPoint(r.right, r.top), kSeekRedLight);
        AddLine(BPoint(r.right, r.top + 1.0),
                BPoint(r.right, r.top + handleBottomSize), kSeekRedShadow);
        AddLine(BPoint(r.right - 1.0, r.top + handleBottomSize + 1.0),
                BPoint(fKnobPos, r.top + handleArrowSize), kSeekRedShadow);
        AddLine(BPoint(fKnobPos - 1.0, r.top + handleArrowSize - 1.0),
                BPoint(r.left + 1.0, r.top + handleBottomSize + 1.0), kSeekRedLight);
        // lower handle
        AddLine(BPoint(r.left, r.bottom),
                BPoint(r.left, r.bottom - handleBottomSize), kSeekRedLight);
        AddLine(BPoint(r.left + 1.0, r.bottom - handleBottomSize - 1.0),
                BPoint(fKnobPos, r.bottom - handleArrowSize), kSeekRedLight);
        AddLine(BPoint(fKnobPos + 1.0, r.bottom - handleArrowSize + 1.0),
                BPoint(r.right, r.bottom - handleBottomSize), kSeekRedShadow);
        AddLine(BPoint(r.right, r.bottom - handleBottomSize + 1.0),
                BPoint(r.right, r.bottom), kSeekRedShadow);
        AddLine(BPoint(r.right - 1.0, r.bottom),
                BPoint(r.left + 1.0, r.bottom), kSeekRedShadow);
        EndLineArray();
        // fill rest of handles with red
        SetHighColor(kSeekRed);
        r.InsetBy(1.0, 1.0);
        handleArrowSize -= 2.0;
        BPoint arrow[3];
        // upper handle arrow
        arrow[0].x = r.left;
        arrow[0].y = r.top;
        arrow[1].x = r.right;
        arrow[1].y = r.top;
        arrow[2].x = fKnobPos;
        arrow[2].y = r.top + handleArrowSize;
        FillPolygon(arrow, 3);
        // lower handle arrow
        arrow[0].x = r.left;
        arrow[0].y = r.bottom;
        arrow[1].x = r.right;
        arrow[1].y = r.bottom;
        arrow[2].x = fKnobPos;
        arrow[2].y = r.bottom - handleArrowSize;
        FillPolygon(arrow, 3);
    } else {
        // *** disabled look ***
        r.InsetBy(1.0, 1.0);
        _StrokeFrame(r, darkShadow, darkShadow, darkShadow, darkShadow);
        r.InsetBy(1.0, 1.0);
        _StrokeFrame(r, darkShadow, darkShadow, darkShadow, darkShadow);
        r.InsetBy(1.0, 1.0);
        SetHighColor(darkShadow);
        SetLowColor(shadow);
        // stripes
        float width = floorf(StringWidth(fDisabledString.String()));
        float textPos = r.left + r.Width() / 2.0 - width / 2.0;
        pattern stripes = { { 0xc7, 0x8f, 0x1f, 0x3e, 0x7c, 0xf8, 0xf1, 0xe3 } };
        BRect stripesRect(r);
        stripesRect.right = textPos - 5.0;
        FillRect(stripesRect, stripes);
        stripesRect.left = textPos + width + 3.0;
        stripesRect.right = r.right;
        FillRect(stripesRect, stripes);
        // info text
        r.left = textPos - 4.0;
        r.right = textPos + width + 2.0;
        FillRect(r);
        SetHighColor(shadow);
        SetLowColor(darkShadow);
        font_height fh;
        GetFontHeight(&fh);
        DrawString(fDisabledString.String(),
                   BPoint(textPos, r.top + ceilf(fh.ascent) - 1.0));
    }
}
示例#11
0
void
PadView::Draw(BRect updateRect)
{
	rgb_color background = LowColor();
	rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT);
	rgb_color shadow = tint_color(background, B_DARKEN_2_TINT);
	BRect r(Bounds());
	BeginLineArray(4);
		AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top), light);
		AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), light);
		AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), shadow);
		AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), shadow);
	EndLineArray();
	r.InsetBy(1.0, 1.0);
	StrokeRect(r, B_SOLID_LOW);
	r.InsetBy(1.0, 1.0);
	// dots along top
	BPoint dot = r.LeftTop();
	int32 current;
	int32 stop;
	BPoint offset;
	BPoint next;
	if (Orientation() == B_VERTICAL) {
		current = (int32)dot.x;
		stop = (int32)r.right;
		offset = BPoint(0, 1);
		next = BPoint(1, -4);
		r.top += 5.0;
	} else {
		current = (int32)dot.y;
		stop = (int32)r.bottom;
		offset = BPoint(1, 0);
		next = BPoint(-4, 1);
		r.left += 5.0;
	}
	int32 num = 1;
	while (current <= stop) {
		rgb_color col1;
		rgb_color col2;
		if (num == 1) {
			col1 = shadow;
			col2 = background;
		} else if (num == 2) {
			col1 = background;
			col2 = light;
		} else {
			col1 = background;
			col2 = background;
			num = 0;
		}
		SetHighColor(col1);
		StrokeLine(dot, dot, B_SOLID_HIGH);
		SetHighColor(col2);
		dot += offset;
		StrokeLine(dot, dot, B_SOLID_HIGH);
		dot += offset;
		StrokeLine(dot, dot, B_SOLID_LOW);
		dot += offset;
		SetHighColor(col1);
		StrokeLine(dot, dot, B_SOLID_HIGH);
		dot += offset;
		SetHighColor(col2);
		StrokeLine(dot, dot, B_SOLID_HIGH);
		// next pixel
		num++;
		dot += next;
		current++;
	}
	FillRect(r, B_SOLID_LOW);
}
示例#12
0
CredLine *Credits::NewLine()
{
	return AddLine(new CredLine);
}
示例#13
0
文件: Box.cpp 项目: mmanley/Antares
void
BBox::_DrawFancy(BRect labelBox)
{
	BRect rect = Bounds();
	rect.top += TopBorderOffset();

	if (be_control_look != NULL) {
		rgb_color base = ViewColor();
		if (rect.Height() == 1.0) {
			// used as horizontal separator
			be_control_look->DrawGroupFrame(this, rect, rect, base,
				BControlLook::B_TOP_BORDER);
		} else if (rect.Width() == 1.0) {
			// used as vertical separator
			be_control_look->DrawGroupFrame(this, rect, rect, base,
				BControlLook::B_LEFT_BORDER);
		} else {
			// used as box
			be_control_look->DrawGroupFrame(this, rect, rect, base);
		}
		return;
	}

	rgb_color light = tint_color(ViewColor(), B_LIGHTEN_MAX_TINT);
	rgb_color shadow = tint_color(ViewColor(), B_DARKEN_3_TINT);

	if (rect.Height() == 1.0) {
		// used as horizontal separator
		BeginLineArray(2);
			AddLine(BPoint(rect.left, rect.top),
					BPoint(rect.right, rect.top), shadow);
			AddLine(BPoint(rect.left, rect.bottom),
					BPoint(rect.right, rect.bottom), light);
		EndLineArray();
	} else if (rect.Width() == 1.0) {
		// used as vertical separator
		BeginLineArray(2);
			AddLine(BPoint(rect.left, rect.top),
					BPoint(rect.left, rect.bottom), shadow);
			AddLine(BPoint(rect.right, rect.top),
					BPoint(rect.right, rect.bottom), light);
		EndLineArray();
	} else {
		// used as box
		BeginLineArray(8);
			AddLine(BPoint(rect.left, rect.bottom - 1.0),
					BPoint(rect.left, rect.top), shadow);
			AddLine(BPoint(rect.left + 1.0, rect.top),
					BPoint(rect.right - 1.0, rect.top), shadow);
			AddLine(BPoint(rect.left, rect.bottom),
					BPoint(rect.right, rect.bottom), light);
			AddLine(BPoint(rect.right, rect.bottom - 1.0),
					BPoint(rect.right, rect.top), light);

			rect.InsetBy(1.0, 1.0);

			AddLine(BPoint(rect.left, rect.bottom - 1.0),
					BPoint(rect.left, rect.top), light);
			AddLine(BPoint(rect.left + 1.0, rect.top),
					BPoint(rect.right - 1.0, rect.top), light);
			AddLine(BPoint(rect.left, rect.bottom),
					BPoint(rect.right, rect.bottom), shadow);
			AddLine(BPoint(rect.right, rect.bottom - 1.0),
					BPoint(rect.right, rect.top), shadow);
		EndLineArray();
	}
}
示例#14
0
void DebugRenderer::AddBoundingBox(const BoundingBox& box, const Color& color, bool depthTest)
{
    const Vector3& min = box.min_;
    const Vector3& max = box.max_;

    Vector3 v1(max.x_, min.y_, min.z_);
    Vector3 v2(max.x_, max.y_, min.z_);
    Vector3 v3(min.x_, max.y_, min.z_);
    Vector3 v4(min.x_, min.y_, max.z_);
    Vector3 v5(max.x_, min.y_, max.z_);
    Vector3 v6(min.x_, max.y_, max.z_);

    unsigned uintColor = color.ToUInt();

    AddLine(min, v1, uintColor, depthTest);
    AddLine(v1, v2, uintColor, depthTest);
    AddLine(v2, v3, uintColor, depthTest);
    AddLine(v3, min, uintColor, depthTest);
    AddLine(v4, v5, uintColor, depthTest);
    AddLine(v5, max, uintColor, depthTest);
    AddLine(max, v6, uintColor, depthTest);
    AddLine(v6, v4, uintColor, depthTest);
    AddLine(min, v4, uintColor, depthTest);
    AddLine(v1, v5, uintColor, depthTest);
    AddLine(v2, max, uintColor, depthTest);
    AddLine(v3, v6, uintColor, depthTest);
}
示例#15
0
void C4Network2ClientDlg::UpdateText()
{
	// begin updating (clears previous text)
	BeginUpdateText();
	// get core
	const C4Client *pClient = Game.Clients.getClientByID(iClientID);
	if (!pClient)
	{
		// client ID unknown
		AddLineFmt(LoadResStr("IDS_NET_CLIENT_INFO_UNKNOWNID"), iClientID);
	}
	else
	{
		// get client (may be nullptr for local info)
		C4Network2Client *pNetClient = pClient->getNetClient();
		// show some info
		StdCopyStrBuf strInfo;
		if (!pClient->isActivated()) { strInfo.Append(LoadResStr("IDS_MSG_INACTIVE")); strInfo.Append(" "); }
		if (pClient->isLocal()) { strInfo.Append(LoadResStr("IDS_MSG_LOCAL")); strInfo.Append(" "); }
		strInfo.AppendFormat("%s %s (ID #%d)%s",
			LoadResStr(pClient->isHost() ? "IDS_MSG_HOST" : "IDS_MSG_CLIENT"),
			pClient->getName(),
			iClientID,
			::Network.isHost() && pNetClient && !pNetClient->isReady() ? " (!ack)" : "");
		AddLine(strInfo.getData());
		// show addresses
		int iCnt;
		if ((iCnt=pNetClient->getAddrCnt()))
		{
			AddLine(LoadResStr("IDS_NET_CLIENT_INFO_ADDRESSES"));
			for (int i=0; i<iCnt; ++i)
			{
				C4Network2Address addr = pNetClient->getAddr(i);
				AddLineFmt("  %d: %s",
				           i,                        // adress index
				           addr.toString().getData());
			}
		}
		else
			AddLine(LoadResStr("IDS_NET_CLIENT_INFO_NOADDRESSES"));
		// show connection
		if (pNetClient)
		{
			// connections
			if (pNetClient->isConnected())
			{
				AddLineFmt(LoadResStr("IDS_NET_CLIENT_INFO_CONNECTIONS"),
				           pNetClient->getMsgConn() == pNetClient->getDataConn() ? "Msg/Data" : "Msg",
				           ::Network.NetIO.getNetIOName(pNetClient->getMsgConn()->getNetClass()),
						   pNetClient->getMsgConn()->getPeerAddr().ToString().getData(),
				           pNetClient->getMsgConn()->getPingTime());
				if (pNetClient->getMsgConn() != pNetClient->getDataConn())
					AddLineFmt(LoadResStr("IDS_NET_CLIENT_INFO_CONNDATA"),
					           ::Network.NetIO.getNetIOName(pNetClient->getDataConn()->getNetClass()),
					           pNetClient->getDataConn()->getPeerAddr().ToString().getData(),
					           pNetClient->getDataConn()->getPingTime());
			}
			else
				AddLine(LoadResStr("IDS_NET_CLIENT_INFO_NOCONNECTIONS"));
		}
	}
	// update done
	EndUpdateText();
}
示例#16
0
void DebugRenderer::AddBoundingBox(const BoundingBox& box, const Matrix3x4& transform, const Color& color, bool depthTest)
{
    const Vector3& min = box.min_;
    const Vector3& max = box.max_;

    Vector3 v0(transform * min);
    Vector3 v1(transform * Vector3(max.x_, min.y_, min.z_));
    Vector3 v2(transform * Vector3(max.x_, max.y_, min.z_));
    Vector3 v3(transform * Vector3(min.x_, max.y_, min.z_));
    Vector3 v4(transform * Vector3(min.x_, min.y_, max.z_));
    Vector3 v5(transform * Vector3(max.x_, min.y_, max.z_));
    Vector3 v6(transform * Vector3(min.x_, max.y_, max.z_));
    Vector3 v7(transform * max);

    unsigned uintColor = color.ToUInt();

    AddLine(v0, v1, uintColor, depthTest);
    AddLine(v1, v2, uintColor, depthTest);
    AddLine(v2, v3, uintColor, depthTest);
    AddLine(v3, v0, uintColor, depthTest);
    AddLine(v4, v5, uintColor, depthTest);
    AddLine(v5, v7, uintColor, depthTest);
    AddLine(v7, v6, uintColor, depthTest);
    AddLine(v6, v4, uintColor, depthTest);
    AddLine(v0, v4, uintColor, depthTest);
    AddLine(v1, v5, uintColor, depthTest);
    AddLine(v2, v7, uintColor, depthTest);
    AddLine(v3, v6, uintColor, depthTest);
}
示例#17
0
int URLData::read(bool affImage, std::string hour, std::string logname, bool clean)
/*contrat :  Les entrees possible de hour doivent etre -1 ou [0;23]
 *           Bool image est vrai si on veut l'affichage des images
 */
{
    //contenu is the line read by the log parser
    std::string contenu;
    //myExtention is the list of extention to exclude
    std::list<std::string> myExtensions;
    //exclusion is false if do not have to add the line to the database
    bool exclusion;

    //creating the list of extention the exclude
    {
        //opening the extention file
        std::ifstream extension("extension.ini", std::ios::in);
        if(extension)
        {
            while(getline(extension, contenu))
            {
                //add each extention to the list
                if(contenu.substr(0,1)!="#")
                {
                    myExtensions.push_back(contenu);
                }
            }
            extension.close();
        }
        else
        {
            std::cerr << "ERROR 5 : Extention file can not be open, please check extention.ini." << std::endl;
            return 5;
        }
            
    } //extention list created

    //opening the logfile
    std::ifstream fichier(logname, std::ios::in);
    //creating data structure
    struct_log data;

    //if the file is open
    if(fichier)  
    {
        //for each line of the logfile
        while(getline(fichier, contenu))
        {
            #ifdef DEBUG
            std::cout <<"la ligne de log est : "<< std::endl << contenu << std::endl;
            #endif


            //Log parser and store it in a structure
            //emettor's IP
            data.ipEmettor=contenu.substr(0,contenu.find_first_of('[',0));
            contenu=contenu.substr(contenu.find_first_of('[',0)+1,contenu.length());

            //day
            data.day=contenu.substr(0,contenu.find_first_of(':',0));
            contenu=contenu.substr(contenu.find_first_of(':',0)+1,contenu.length());

            //hour
            data.hour=contenu.substr(0,contenu.find_first_of(':',0));
            contenu=contenu.substr(contenu.find_first_of(' ',1)+1,contenu.length());

            //gmt
            data.gmt=contenu.substr(0,contenu.find_first_of(']',0));
            contenu=contenu.substr(contenu.find_first_of('"',0)+1,contenu.length());

            //action
            data.action=contenu.substr(0,contenu.find_first_of('/',0));
            contenu=contenu.substr(contenu.find_first_of('/',2),contenu.length());

            if(clean)
            {
            //urlHit
            data.urlHit = clearURL(contenu.substr(0,contenu.find_first_of(' ',0)));
            contenu=contenu.substr(contenu.find_first_of(' ',0)+1,contenu.length());
            }
            else
            {
            //urlHit
            data.urlHit = contenu.substr(0,contenu.find_first_of(' ',0));
            contenu=contenu.substr(contenu.find_first_of(' ',0)+1,contenu.length());

            }

            //protocol used
            data.protocol=contenu.substr(0,contenu.find_first_of('"',0));
            contenu=contenu.substr(contenu.find_first_of('"',0)+2,contenu.length());

            //returnCode
            data.returnCode=contenu.substr(0,contenu.find_first_of(' ',1));
            contenu=contenu.substr(contenu.find_first_of(' ',2)+1,contenu.length());

            //Octet Quantity
            data.octetQuantity=contenu.substr(0,contenu.find_first_of(' ',1));
            contenu=contenu.substr(contenu.find_first_of('"',1)+1,contenu.length());

            if(clean)
            {
            //referer
            data.referer = clearURL(contenu.substr(0,contenu.find_first_of('"',0)));
            contenu=contenu.substr(contenu.find_first_of('"',1)+3,contenu.length());
            }
            else
            {
            //referer
            data.referer = contenu.substr(0,contenu.find_first_of('"',0));
            contenu=contenu.substr(contenu.find_first_of('"',1)+3,contenu.length());

            }
            

            //browser
            data.browser=contenu.substr(0,contenu.length()-1);


            #ifdef DEBUG

            cout<<data.ipEmettor<<endl;
            cout<<data.day<<endl;
            cout<<data.hour<<endl;
            cout<<data.gmt<<endl;
            cout<<data.action<<endl;
            cout<<data.urlHit<<endl;
            cout<<data.protocol<<endl;
            cout<<data.returnCode<<endl;
            cout<<data.octetQuantity<<endl;
            cout<<data.referer<<endl;
            cout<<data.browser<<endl<<endl;

            #endif

            //check if the extention is correct
            exclusion=false;
            //for each extention
            for (std::list<std::string>::iterator it = myExtensions.begin(); it != myExtensions.end(); it++)
            {
                if((data.urlHit.find(*it)>0) and (data.urlHit.find(*it)<=data.urlHit.length()))
                {
                    exclusion=true;
                }
            }

            //Add the website hited and his referer according to the option in the database
            //check the extention
            if(affImage==true or exclusion==false)
            {
                //then, check the time
                if (std::stoi(hour)==-1 or std::stoi(data.hour)==std::stoi(hour))
                {
                    AddLine(data.urlHit,data.referer);
                }
            }
        }
        fichier.close();
    }
    else
    {
        std::cerr << "ERROR 6 : The logfile can not be open." << std::endl;
        return 6;  
    }
    return 7;
}//--end of read--
示例#18
0
void DebugRenderer::AddLine(const Vector3& start, const Vector3& end, const Color& color, bool depthTest)
{
    AddLine(start, end, color.ToUInt(), depthTest);
}
示例#19
0
void SingleStrokeTemplate::AddLine(float fromX, float fromY, float toX, float toY, uint sampleCount)
{
	AddLine(mpp(fromX, fromY), mpp(toX, toY), sampleCount);
}
示例#20
0
void KVTGIDZA::AddLineToGrid(KVIDGrid * g, Int_t Z, Int_t npoints,
                             Double_t xmin, Double_t xmax, Bool_t log_scale)
{
   //Add a line to the grid 'g' for identification label 'Z' with 'npoints' points calculated between
   //X-coordinates xmin and xmax. Points are omitted if the resulting value of the functional is
   //not a number (TMath::IsNan = kTRUE).
   //
   //For Z<=8 several KVIDZALines are added for common isotopes (p,d,t, 3He, etc.)
   //For Z>8 a line for the current Z is drawn, with the A corresponding to Charity's EAL formula
   //
   //Before using this method the user must have set the name of
   //the parameter in the identification functional which corresponds to the
   //atomic number Z i.e. using
   //      SetParName(i,"Z")
   //with i=the relevant parameter index.
   //
   // If log_scale=kTRUE (default is kFALSE), more points are used at the beginning
   // of the line than at the end, with a logarithmic dependence.

   //A & Z identification
   //on va faire: p,d,t,3He,4He,6He,6Li,7Li,8Li,7Be,9Be, etc.
   static Int_t Ziso[] =
       { 1, 1, 1,
		 	2, 2, 2,
			3, 3, 3,
			4, 4, 4,
			5, 5, 5,
			6, 6, 6,
			7, 7, 7,
			8, 8, 8
   };
   static Int_t Aiso[] =
       { 1, 2, 3,
			3, 4, 6,
			6, 7, 8,
			7, 9, 10,
			10, 11, 12,
			12, 13, 14,
			14, 15, 16,
			15, 16, 17
   };
   static Int_t nisotopes = 24; //number of isotopes in arrays
   static Int_t Zindex_start[] = { -1, 0, 3, 6, 9, 12, 15, 18, 21 };    //index of first isotope for each Z
   static Int_t Zindex_stop[] = { -1, 2, 5, 8, 11, 14, 17, 20, 23 };    //index of last isotope for each Z

   if (Z <= Ziso[nisotopes - 1]) {
      //Z is included in table of isotopes
      //we add several lines corresponding to the tabulated isotopes
      for (int iso = Zindex_start[Z]; iso <= Zindex_stop[Z]; iso++) {   //loop over isotopes for this Z
         //add new line to grid
         KVIDLine *new_line = AddLine(g);

         //set identification label for line
         Double_t idlab = 100. * Ziso[iso] + Aiso[iso];
         SetIdent(new_line, idlab);

         //set Z of line in functional
         SetParameter("Z", (Double_t) Ziso[iso]);
         //loop over points of line
         Int_t p_index = 0;
   Double_t X, dX;
   Double_t Y = 0.;
   Double_t logXmin = TMath::Log( TMath::Max(xmin,1.0) );
   if(log_scale)
      dX = (TMath::Log(xmax) - logXmin)/( npoints - 1. );
   else
      dX = (xmax - xmin) / (Double_t) (npoints - 1);

         for (Int_t i = 0; i < npoints; i++) {

            //x coordinate of this point
      if(log_scale)
         X = TMath::Exp(logXmin + i*dX);
      else
         X = xmin + dX * ((Double_t) i);

            //leave value Y as it is. The value of GetIDFunc()->Eval(ID)
            //is the vertical distance delta_Y from point (X,Y) to the line; therefore the
            //Y coordinate of the point on the line is Y + delta_Y, whatever the value Y.

            //set values of parameters which correspond to X and Y coordinates in grid
            SetParameter("X", X);
            SetParameter("Y", Y);

            Y += Eval((Double_t) Aiso[iso]);

            if (!TMath::IsNaN(Y))
               new_line->SetPoint(p_index++, X, Y);
            else
               Y = 0.;          //reset Y to 0 if it ever becomes NaN
         }
      }
   } else {
      //Z is bigger than largest Z for which we have isotopes
      //we add one line for this Z using mass formula

      //get mass for nucleus
      Int_t A = KVNucleus::GetAFromZ(Z, fMassFormula);
      //add new line to grid
      KVIDLine *new_line = AddLine(g);
      //set identification label for line
      Double_t idlab = 100. * Z + A;
      SetIdent(new_line, idlab);

      //set Z of line in functional
      SetParameter("Z", (Double_t) Z);
      //loop over points of line
      Int_t p_index = 0;
      Double_t Y = 0., X, dX = (xmax - xmin) / (Double_t) (npoints - 1);

      for (Int_t i = 0; i < npoints; i++) {

         //x coordinate of this point
         X = xmin + dX * ((Double_t) i);

         //leave value Y as it is. The value of GetIDFunc()->Eval(ID)
         //is the vertical distance delta_Y from point (X,Y) to the line; therefore the
         //Y coordinate of the point on the line is Y + delta_Y, whatever the value Y.

         //set values of parameters which correspond to X and Y coordinates in grid
         SetParameter("X", X);
         SetParameter("Y", Y);

         Y += Eval((Double_t) A);

         if (!TMath::IsNaN(Y))
            new_line->SetPoint(p_index++, X, Y);
         else
            Y = 0.;             //reset Y to 0 if it ever becomes NaN
      }
   }
}
示例#21
0
void SingleStrokeTemplate::AddTo(float toX, float toY, uint sampleCount)
{
	AddLine(mCurrentAddPoint, mpp(toX, toY), sampleCount);
	mCurrentAddPoint.X = toX;
	mCurrentAddPoint.Y = toY;
}
示例#22
0
bool wxTextFile::OnRead(const wxMBConv& conv)
{
    // file should be opened
    wxASSERT_MSG( m_file.IsOpened(), _T("can't read closed file") );

    // read the entire file in memory: this is not the most efficient thing to
    // do but there is no good way to avoid it in Unicode build because if we
    // read the file block by block we can't convert each block to Unicode
    // separately (the last multibyte char in the block might be only partially
    // read and so the conversion would fail) and, as the file contents is kept
    // in memory by wxTextFile anyhow, it shouldn't be a big problem to read
    // the file entirely
    size_t bufSize = 0,
           bufPos = 0;
    char block[1024];
    wxCharBuffer buf;

    // first determine if the file is seekable or not and so whether we can
    // determine its length in advance
    wxFileOffset fileLength;
    {
        wxLogNull logNull;
        fileLength = m_file.Length();
    }

    // some non-seekable files under /proc under Linux pretend that they're
    // seekable but always return 0; others do return an error
    const bool seekable = fileLength != wxInvalidOffset && fileLength != 0;
    if ( seekable )
    {
        // we know the required length, so set the buffer size in advance
        bufSize = fileLength;
        if ( !buf.extend(bufSize - 1 /* it adds 1 internally */) )
            return false;

        // if the file is seekable, also check that we're at its beginning
        wxASSERT_MSG( m_file.Tell() == 0, _T("should be at start of file") );
    }

    for ( ;; )
    {
        ssize_t nRead = m_file.Read(block, WXSIZEOF(block));

        if ( nRead == wxInvalidOffset )
        {
            // read error (error message already given in wxFile::Read)
            return false;
        }

        if ( nRead == 0 )
        {
            // if no bytes have been read, presumably this is a valid-but-empty file
            if ( bufPos == 0 )
                return true;

            // otherwise we've finished reading the file
            break;
        }

        if ( seekable )
        {
            // this shouldn't happen but don't overwrite the buffer if it does
            wxCHECK_MSG( bufPos + nRead <= bufSize, false,
                         _T("read more than file length?") );
        }
        else // !seekable
        {
            // for non-seekable files we have to allocate more memory on the go
            if ( !buf.extend(bufPos + nRead - 1 /* it adds 1 internally */) )
                return false;
        }

        // append to the buffer
        memcpy(buf.data() + bufPos, block, nRead);
        bufPos += nRead;
    }

    if ( !seekable )
    {
        bufSize = bufPos;
    }

    const wxString str(buf, conv, bufPos);

    // there's no risk of this happening in ANSI build
#if wxUSE_UNICODE
    if ( bufSize > 4 && str.empty() )
    {
        wxLogError(_("Failed to convert file \"%s\" to Unicode."), GetName());
        return false;
    }
#endif // wxUSE_UNICODE

	// we don't need this memory any more
	// PCSX2 : So let's free it using the buffer object's API, instead of some idiotic
	//   low-level hack (bug found thanks to the use of custom heap allocation). --air
	//free(buf.release());
	buf.reset();


    // now break the buffer in lines

    // last processed character, we need to know if it was a CR or not
    wxChar chLast = '\0';

    // the beginning of the current line, changes inside the loop
    wxString::const_iterator lineStart = str.begin();
    const wxString::const_iterator end = str.end();
    for ( wxString::const_iterator p = lineStart; p != end; p++ )
    {
        const wxChar ch = *p;
        switch ( ch )
        {
            case '\n':
                // could be a DOS or Unix EOL
                if ( chLast == '\r' )
                {
                    if ( p - 1 >= lineStart )
                    {
                        AddLine(wxString(lineStart, p - 1), wxTextFileType_Dos);
                    }
                    else
                    {
                        // there were two line endings, so add an empty line:
                        AddLine(wxEmptyString, wxTextFileType_Dos);
                    }
                }
                else // bare '\n', Unix style
                {
                    AddLine(wxString(lineStart, p), wxTextFileType_Unix);
                }

                lineStart = p + 1;
                break;

            case '\r':
                if ( chLast == '\r' )
                {
                    if ( p - 1 >= lineStart )
                    {
                        AddLine(wxString(lineStart, p - 1), wxTextFileType_Mac);
                    }
                    // Mac empty line
                    AddLine(wxEmptyString, wxTextFileType_Mac);
                    lineStart = p + 1;
                }
                //else: we don't know what this is yet -- could be a Mac EOL or
                //      start of DOS EOL so wait for next char
                break;

            default:
                if ( chLast == '\r' )
                {
                    // Mac line termination
                    if ( p - 1 >= lineStart )
                    {
                        AddLine(wxString(lineStart, p - 1), wxTextFileType_Mac);
                    }
                    else
                    {
                        // there were two line endings, so add an empty line:
                        AddLine(wxEmptyString, wxTextFileType_Mac);
                    }
                    lineStart = p;
                }
        }

        chLast = ch;
    }

    // anything in the last line?
    if ( lineStart != end )
    {
        // add unterminated last line
        AddLine(wxString(lineStart, end), wxTextFileType_None);
    }

    return true;
}
示例#23
0
void SingleStrokeTemplate::AddTo(const Point2F& pos, uint sampleCount)
{
	AddLine(mCurrentAddPoint, pos, sampleCount);
	mCurrentAddPoint = pos;
}
示例#24
0
void CLVColumnLabelView::Draw(BRect update_rect)
{
	BRect ViewBounds = Bounds();

	//Draw each column label in turn
	float ColumnBegin = 0.0;
	float ColumnEnd = -1.0;
	bool MergeWithLeft = false;
	int32 NumberOfColumns = fDisplayList->CountItems();
	BPoint Start,Stop;
	for(int32 ColumnDraw = 0; ColumnDraw < NumberOfColumns; ColumnDraw++)
	{
		CLVColumn* ThisColumn = (CLVColumn*)fDisplayList->ItemAt(ColumnDraw);
		if(ThisColumn->IsShown())
		{
			//Figure out where this column is
			ColumnBegin = ThisColumn->fColumnBegin;
			ColumnEnd = ThisColumn->fColumnEnd;
			//Start by figuring out if this column will merge with a shown column to the right
			bool MergeWithRight = false;
			if(ThisColumn->fFlags & CLV_MERGE_WITH_RIGHT)
			{
				for(int32 ColumnCounter = ColumnDraw+1; ColumnCounter < NumberOfColumns;
					ColumnCounter++)
				{
					CLVColumn* NextColumn = (CLVColumn*)fDisplayList->ItemAt(ColumnCounter);
					if(NextColumn->IsShown())
					{
						//The next column is shown
						MergeWithRight = true;
						break;
					}
					else if(!(NextColumn->fFlags & CLV_MERGE_WITH_RIGHT))
						//The next column is not shown and doesn't pass on the merge
						break;
				}
			}
			if(update_rect.Intersects(BRect(ColumnBegin,ViewBounds.top,ColumnEnd,
				ViewBounds.bottom)))
			{
				//Need to draw this column
				BeginLineArray(4);
				//Top line
				Start.Set(ColumnBegin,ViewBounds.top);
				Stop.Set(ColumnEnd-1.0,ViewBounds.top);
				if(MergeWithRight && !(ThisColumn == fColumnClicked && fColumnResizing))
					Stop.x = ColumnEnd;
				AddLine(Start,Stop,BeHighlight);
				//Left line
				if(!MergeWithLeft)
					AddLine(BPoint(ColumnBegin,ViewBounds.top+1.0),
						BPoint(ColumnBegin,ViewBounds.bottom),BeHighlight);
				//Bottom line
				Start.Set(ColumnBegin+1.0,ViewBounds.bottom);
				if(MergeWithLeft)
					Start.x = ColumnBegin;
				Stop.Set(ColumnEnd-1.0,ViewBounds.bottom);
				if(MergeWithRight && !(ThisColumn == fColumnClicked && fColumnResizing))
					Stop.x = ColumnEnd;
				AddLine(Start,Stop,BeShadow);
				//Right line
				if(ThisColumn == fColumnClicked && fColumnResizing)
					AddLine(BPoint(ColumnEnd,ViewBounds.top),BPoint(ColumnEnd,ViewBounds.bottom),
						BeFocusBlue);
				else if(!MergeWithRight)
					AddLine(BPoint(ColumnEnd,ViewBounds.top),BPoint(ColumnEnd,ViewBounds.bottom),
						BeShadow);
				EndLineArray();

				//Add the label
				//Limit the clipping region to the interior of the box
				BRect TextRect(ColumnBegin+1.0,ViewBounds.top+1.0,ColumnEnd-1.0,
					ViewBounds.bottom-1.0);
				BRegion TextRegion;
				TextRegion.Include(TextRect);
				ConstrainClippingRegion(&TextRegion);

				bool focus;
				bool sort_key;
				if(ThisColumn == fColumnClicked && !fColumnResizing)
					focus = true;
				else
					focus = false;
				if(fParent->fSortKeyList.HasItem(ThisColumn) && ThisColumn->fSortMode != NoSort)
					sort_key = true;
				else
					sort_key = false;

				ThisColumn->DrawColumnHeader(this,TextRect,sort_key,focus,fFontAscent);

				//Restore the clipping region
				ConstrainClippingRegion(NULL);
			}
			//Set MergeWithLeft flag for the next column to the appropriate state
			MergeWithLeft = MergeWithRight;
		}
	}

	//Add highlight and shadow to the region after the columns if necessary
	if(ColumnEnd < ViewBounds.right)
	{
		ColumnBegin = ColumnEnd+1.0;
		if(update_rect.Intersects(BRect(ColumnEnd+1.0,ViewBounds.top,ViewBounds.right,
			ViewBounds.bottom)))
		{
			BeginLineArray(3);
			//Top line
			AddLine(BPoint(ColumnBegin,ViewBounds.top),BPoint(ViewBounds.right,ViewBounds.top),
				BeHighlight);
			//Left line
			AddLine(BPoint(ColumnBegin,ViewBounds.top+1.0),BPoint(ColumnBegin,ViewBounds.bottom),
				BeHighlight);
			//Bottom line
			Start.Set(ColumnBegin+1.0,ViewBounds.bottom);
			if(MergeWithLeft)
				Start.x = ColumnBegin;
			Stop.Set(ViewBounds.right,ViewBounds.bottom);
			AddLine(Start,Stop,BeShadow);
			EndLineArray();
		}
	}

	//Draw the dragging box if necessary
	if(fColumnClicked && fColumnDragging)
	{
		float DragOutlineLeft = fPreviousMousePos.x-fDragBoxMouseHoldOffset;
		float GroupBegin = ((CLVDragGroup*)fDragGroups.ItemAt(fDragGroup))->GroupBegin;
		if(DragOutlineLeft < GroupBegin && fSnapGroupBefore == -1)
			DragOutlineLeft = GroupBegin;
		if(DragOutlineLeft > GroupBegin && fSnapGroupAfter == -1)
			DragOutlineLeft = GroupBegin;
		float DragOutlineRight = DragOutlineLeft + fDragBoxWidth;
		BeginLineArray(4);
		AddLine(BPoint(DragOutlineLeft,ViewBounds.top),BPoint(DragOutlineRight,
			ViewBounds.top),BeFocusBlue);
		AddLine(BPoint(DragOutlineLeft,ViewBounds.bottom),BPoint(DragOutlineRight,
			ViewBounds.bottom),BeFocusBlue);
		AddLine(BPoint(DragOutlineLeft,ViewBounds.top+1.0),BPoint(DragOutlineLeft,
			ViewBounds.bottom-1.0),BeFocusBlue);
		AddLine(BPoint(DragOutlineRight,ViewBounds.top+1.0),BPoint(DragOutlineRight,
			ViewBounds.bottom-1.0),BeFocusBlue);
		EndLineArray();
		fPrevDragOutlineLeft = DragOutlineLeft;
		fPrevDragOutlineRight = DragOutlineRight;
	}
}
示例#25
0
void
BitmapView::Draw(BRect rect)
{
	if (fBitmap)
		DrawBitmap(fBitmap, fBitmap->Bounds(), fBitmapRect);
	else {
		SetHighColor(0, 0, 0, 80);
		SetDrawingMode(B_OP_ALPHA);
		DrawString("Drop", fNoPhotoOffsets[0]);
		DrawString("a", fNoPhotoOffsets[1]);
		DrawString("Photo", fNoPhotoOffsets[2]);
		DrawString("Here", fNoPhotoOffsets[3]);
		SetDrawingMode(B_OP_COPY);
	}
	
	if (fBorderStyle == B_FANCY_BORDER) {
		rgb_color base= { 216, 216, 216, 255 };
		rgb_color work;
		
		SetHighColor(base);
		StrokeRect(Bounds().InsetByCopy(2, 2));
		
		BeginLineArray(12);
		
		BRect r(Bounds());

		work = tint_color(base, B_DARKEN_2_TINT);
		AddLine(r.LeftTop(), r.RightTop(), work);
		AddLine(r.LeftTop(), r.LeftBottom(), work);
		r.left++;
		
		work = tint_color(base, B_DARKEN_4_TINT);
		AddLine(r.RightTop(), r.RightBottom(), work);
		AddLine(r.LeftBottom(), r.RightBottom(), work);
		
		r.right--;
		r.top++;
		r.bottom--;

		
		work = tint_color(base, B_LIGHTEN_MAX_TINT);
		AddLine(r.LeftTop(), r.RightTop(), work);
		AddLine(r.LeftTop(), r.LeftBottom(), work);
		r.left++;
		
		work = tint_color(base, B_DARKEN_3_TINT);
		AddLine(r.RightTop(), r.RightBottom(), work);
		AddLine(r.LeftBottom(), r.RightBottom(), work);
		
		// this rect handled by the above StrokeRect, so inset a total of 2 pixels
		r.left++;
		r.right -= 2;
		r.top += 2;
		r.bottom -= 2;
		
		
		work = tint_color(base, B_DARKEN_3_TINT);
		AddLine(r.LeftTop(), r.RightTop(), work);
		AddLine(r.LeftTop(), r.LeftBottom(), work);
		r.left++;
		
		work = tint_color(base, B_LIGHTEN_MAX_TINT);
		AddLine(r.RightTop(), r.RightBottom(), work);
		AddLine(r.LeftBottom(), r.RightBottom(), work);

		r.right--;
		r.top++;
		r.bottom--;
		EndLineArray();
		
		SetHighColor(tint_color(base, B_DARKEN_2_TINT));
		StrokeRect(r);
	} else {
		// Plain border
		SetHighColor(0, 0, 0);	
		StrokeRect(fBitmapRect);
	}
}
示例#26
0
void PaneSwitch::DrawInState(PaneSwitch::State state)
{
	BRect rect(0, 0, 10, 10);
	rect.OffsetTo(Bounds().Width()/2. - 5,Bounds().Height()/2. - 5);

	rgb_color outlineColor = {0, 0, 0, 255};
	rgb_color middleColor = state == kPressed ? kHighlightColor : kNormalColor;

	SetDrawingMode(B_OP_COPY);
	
	switch (state) {
		case kCollapsed:
			BeginLineArray(6);
			
			if (fLeftAligned) {
				AddLine(BPoint(rect.left + 3, rect.top + 1), 
					BPoint(rect.left + 3, rect.bottom - 1), outlineColor);
				AddLine(BPoint(rect.left + 3, rect.top + 1), 
					BPoint(rect.left + 7, rect.top + 5), outlineColor);
				AddLine(BPoint(rect.left + 7, rect.top + 5), 
					BPoint(rect.left + 3, rect.bottom - 1), outlineColor);
					
				AddLine(BPoint(rect.left + 4, rect.top + 3), 
					BPoint(rect.left + 4, rect.bottom - 3), middleColor);
				AddLine(BPoint(rect.left + 5, rect.top + 4), 
					BPoint(rect.left + 5, rect.bottom - 4), middleColor);
				AddLine(BPoint(rect.left + 5, rect.top + 5), 
					BPoint(rect.left + 6, rect.top + 5), middleColor);
			} else {
				AddLine(BPoint(rect.right - 3, rect.top + 1), 
					BPoint(rect.right - 3, rect.bottom - 1), outlineColor);
				AddLine(BPoint(rect.right - 3, rect.top + 1), 
					BPoint(rect.right - 7, rect.top + 5), outlineColor);
				AddLine(BPoint(rect.right - 7, rect.top + 5), 
					BPoint(rect.right - 3, rect.bottom - 1), outlineColor);
					
				AddLine(BPoint(rect.right - 4, rect.top + 3), 
					BPoint(rect.right - 4, rect.bottom - 3), middleColor);
				AddLine(BPoint(rect.right - 5, rect.top + 4), 
					BPoint(rect.right - 5, rect.bottom - 4), middleColor);
				AddLine(BPoint(rect.right - 5, rect.top + 5), 
					BPoint(rect.right - 6, rect.top + 5), middleColor);
			}
			EndLineArray();
			break;

		case kPressed:
			BeginLineArray(7);
			if (fLeftAligned) {
				AddLine(BPoint(rect.left + 1, rect.top + 7), 
					BPoint(rect.left + 7, rect.top + 7), outlineColor);
				AddLine(BPoint(rect.left + 7, rect.top + 1), 
					BPoint(rect.left + 7, rect.top + 7), outlineColor);
				AddLine(BPoint(rect.left + 1, rect.top + 7), 
					BPoint(rect.left + 7, rect.top + 1), outlineColor);
					
				AddLine(BPoint(rect.left + 3, rect.top + 6), 
					BPoint(rect.left + 6, rect.top + 6), middleColor);
				AddLine(BPoint(rect.left + 4, rect.top + 5), 
					BPoint(rect.left + 6, rect.top + 5), middleColor);
				AddLine(BPoint(rect.left + 5, rect.top + 4), 
					BPoint(rect.left + 6, rect.top + 4), middleColor);
				AddLine(BPoint(rect.left + 6, rect.top + 3), 
					BPoint(rect.left + 6, rect.top + 4), middleColor);
			} else {
				AddLine(BPoint(rect.right - 1, rect.top + 7), 
					BPoint(rect.right - 7, rect.top + 7), outlineColor);
				AddLine(BPoint(rect.right - 7, rect.top + 1), 
					BPoint(rect.right - 7, rect.top + 7), outlineColor);
				AddLine(BPoint(rect.right - 1, rect.top + 7), 
					BPoint(rect.right - 7, rect.top + 1), outlineColor);
					
				AddLine(BPoint(rect.right - 3, rect.top + 6), 
					BPoint(rect.right - 6, rect.top + 6), middleColor);
				AddLine(BPoint(rect.right - 4, rect.top + 5), 
					BPoint(rect.right - 6, rect.top + 5), middleColor);
				AddLine(BPoint(rect.right - 5, rect.top + 4), 
					BPoint(rect.right - 6, rect.top + 4), middleColor);
				AddLine(BPoint(rect.right - 6, rect.top + 3), 
					BPoint(rect.right - 6, rect.top + 4), middleColor);
			}
			EndLineArray();
			break;

		case kExpanded:
			BeginLineArray(6);
			AddLine(BPoint(rect.left + 1, rect.top + 3), 
				BPoint(rect.right - 1, rect.top + 3), outlineColor);
			AddLine(BPoint(rect.left + 1, rect.top + 3), 
				BPoint(rect.left + 5, rect.top + 7), outlineColor);
			AddLine(BPoint(rect.left + 5, rect.top + 7), 
				BPoint(rect.right - 1, rect.top + 3), outlineColor);

			AddLine(BPoint(rect.left + 3, rect.top + 4), 
				BPoint(rect.right - 3, rect.top + 4), middleColor);
			AddLine(BPoint(rect.left + 4, rect.top + 5), 
				BPoint(rect.right - 4, rect.top + 5), middleColor);
			AddLine(BPoint(rect.left + 5, rect.top + 5), 
				BPoint(rect.left + 5, rect.top + 6), middleColor);
			EndLineArray();
			break;
	}
}
示例#27
0
void
DataView::DrawSelectionFrame(view_focus which)
{
	if (fFileSize == 0)
		return;

	bool drawBlock = false;
	bool drawLastLine = false;
	BRect block, lastLine;
	int32 spacing = 0;
	if (which == kAsciiFocus)
		spacing++;

	// draw first line

	int32 start = fStart % kBlockSize;
	int32 first = (fStart / kBlockSize) * kBlockSize;

	int32 end = fEnd;
	if (end > first + (int32)kBlockSize - 1)
		end = first + kBlockSize - 1;

	BRect firstLine = SelectionFrame(which, first + start, end);
	firstLine.right += spacing;
	first += kBlockSize;

	// draw block (and last line) if necessary

	end = fEnd % kBlockSize;
	int32 last = (fEnd / kBlockSize) * kBlockSize;

	if (last >= first) {
		if (end == kBlockSize - 1)
			last += kBlockSize;
		if (last > first) {
			block = SelectionFrame(which, first, last - 1);
			block.right += spacing;
			drawBlock = true;
		}
		if (end != kBlockSize - 1) {
			lastLine = SelectionFrame(which, last, last + end);
			lastLine.right += spacing;
			drawLastLine = true;
		}
	}

	SetDrawingMode(B_OP_INVERT);
	BeginLineArray(8);

	// +*******
	// |      *
	// +------+

	const rgb_color color = {0, 0, 0};
	float bottom;
	if (drawBlock)
		bottom = block.bottom;
	else
		bottom = firstLine.bottom;

	AddLine(BPoint(firstLine.left + 1, firstLine.top), firstLine.RightTop(), color);
	AddLine(BPoint(firstLine.right, firstLine.top + 1), BPoint(firstLine.right, bottom), color);

	// *-------+
	// *       |
	// *********

	BRect rect;
	if (start == 0 || (!drawBlock && !drawLastLine))
		rect = firstLine;
	else if (drawBlock)
		rect = block;
	else
		rect = lastLine;

	if (drawBlock)
		rect.bottom = block.bottom;
	if (drawLastLine) {
		rect.bottom = lastLine.bottom;
		rect.right = lastLine.right;
	}
	rect.bottom++;

	AddLine(rect.LeftTop(), rect.LeftBottom(), color);
	AddLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom(), color);

	//     *--------+
	//     *        |
	// +****        |
	// |            |

	if (start && (drawLastLine || drawBlock)) {
		AddLine(firstLine.LeftTop(), firstLine.LeftBottom(), color);

		float right = firstLine.left;
		if (!drawBlock && right > lastLine.right)
			right = lastLine.right;
		AddLine(BPoint(rect.left + 1, rect.top), BPoint(right, rect.top), color);
	}

	// |            |
	// |        *****
	// |        *
	// +--------+

	if (drawLastLine) {
		AddLine(lastLine.RightBottom(), BPoint(lastLine.right, lastLine.top + 1), color);
		if (!drawBlock && lastLine.right <= firstLine.left)
			lastLine.right = firstLine.left + (lastLine.right < firstLine.left ? 0 : 1);
		AddLine(BPoint(lastLine.right, lastLine.top), BPoint(firstLine.right, lastLine.top), color);
	}

	EndLineArray();
	SetDrawingMode(B_OP_COPY);
}