コード例 #1
0
ファイル: RelationData.cpp プロジェクト: jeremysalwen/douml
RelationData::RelationData(const BrowserRelation * model,
                           BrowserRelation * r)
    : ClassMemberData((ClassMemberData *) model->get_data()),
      Labeled<RelationData>(all, 0), is_deleted(FALSE), is_unconsistent(FALSE)
{
    RelationData * md = (RelationData *) model->get_data();

    type = md->type;
    name = md->name;
    a = md->a;
    b = md->b;
    set_association(md->association);
    original_id = 0;

    if (md->start == model) {
        SetStart(r);

        if (md->end_removed_from == 0) {
            // bi dir, self to model became self to r
            SetEnd(new BrowserRelation((md->get_end_class() == (BrowserClass *) model->parent())
                                      ? (BrowserClass *) r->parent() : md->get_end_class(),
                                      this));
            end_removed_from = 0;
        }
        else {
            // uni dir
            SetEnd(0);
            end_removed_from = (md->end_removed_from == (BrowserClass *) model->parent())
                               ? (BrowserClass *) r->parent() : md->end_removed_from;
            connect(end_removed_from->get_data(), SIGNAL(deleted()),
                    this, SLOT(end_deleted()));
        }
    }
    else {
        // bi dir, self to model became self to r
        SetEnd(r);
        SetStart(new BrowserRelation((md->get_start_class() == (BrowserClass *) model->parent())
                                     ? (BrowserClass *) r->parent() : md->get_start_class(),
                                     this));
        end_removed_from = 0;
    }

    if (get_start_class() == md->get_start_class())
        // to not have two times the same role name
        a.role = 0;

    if ((end != 0) && (get_end_class() == md->get_end_class()))
        // to not have two times the same role name
        b.role = 0;
}
コード例 #2
0
ファイル: Card.cpp プロジェクト: arabwes/Hind
Card::Card(string tFName, string tName, string tSuit, int tVal, int tNum, string tFile, string tFacedown)
{
	fullName = tFName;	//Full name of card. (ie. Ace of Spade)
	name = tName;		//Name of card such as King or 5
	suit = tSuit;		//Suit of card such as Club
	value = tVal;		//Value of card (Ace can be 1 or 11 points in Blackjack)
	number = tNum;		//Number of card to help find filename
	selected = false;		//Flag to tell if card is selected
	fileName = tFile;	//Filename for card image
	facedownFileName = tFacedown; 
	faceDown = true;
	Texture = LoadTexture(facedownFileName, TransColor);
	
	//Coordinates of card's position
	x = 0;
	y = 0;
	//Definition of sprite sheet
	NumCol = 1;
	FrameW = 71;
	FrameH = 96;
	Delay = 135;
	ScaleX = 1;
	ScaleY = 1;
	SetStart(0); 
	SetEnd(0);
	SetDirection(1);
}
コード例 #3
0
ファイル: hlist.cpp プロジェクト: peteratebs/webcwebbrowser
int HTMLList::SetProperty(HTMLAttributeType Property, WEBC_CHAR *value, HTMLDocument *pDocument, int call_base)
{
	if (pDocument == 0)
	{
		pDocument = GetDocument();
	}

	switch (Property)
	{
		case HTML_ATTRIB_TYPE:
			SetListStyleType(_atolisttype(value));
			return (1);
			
		case HTML_ATTRIB_START:
		{
			long i = webc_atoi(value);
			SetStart(UTIL_SAFE_LONG_TO_SHORT(i));
			return (1);
		}
			
		default:
			break;
	}

	if (call_base)
	{
		return (HTMLFlow::SetProperty(Property, value, pDocument, call_base));
	}

	return (0);
}
コード例 #4
0
void SelfPlay()
{
	printf("\n\n--------------The Bot Will Now Play itself to Some Randomized Depth-------------\n\n");
	printf("Press Any Key To See The Next Move\n");
	BOARD *board=new BOARD;
	SetStart(board);
	getchar();
	while(1)
	{
		MOVE *list=new MOVE;
		GenMoves(board,list);
		if(list->Count==0)
		{
			printf("%c LOST THE GAME\n\n",PceSideChar[board->Side]);
			break;
		}
		int Depth=5+rand()%4;
		vector<int>BestMove=SearchPos(board,Depth);
		PrintBoard(board);
		MakeMove(board,BestMove);
		getchar();
		getchar();
	}
	StartGame();
}
コード例 #5
0
void MazeRenderer::CreateFromMazeGenerator(const MazeGenerator& mg, irr::scene::ISceneManager *smgr)
{
	XSize = mg.YSize;
	YSize = mg.XSize;
	SetStart(mg.StartY,mg.StartX);
	SetEnd(mg.EndY,mg.EndX);

	CreateFromVectorString(smgr,mg.Convert());

	CollisionManager = smgr->getSceneCollisionManager();
}
コード例 #6
0
ファイル: chat_keydefs.c プロジェクト: d3x0r/SACK
static size_t GetInputIndex(  PUSER_INPUT_BUFFER pci )
{
			PTEXT start = pci->CollectionBuffer;
			size_t index = 0;
			SetStart( start );
			while( start != pci->CollectionBuffer )
			{
				index += GetTextSize( start );
				start = NEXTLINE( start );
			}
			index += pci->CollectionIndex;
			return index;
}
コード例 #7
0
void ReformatInput( PCHAT_LIST list )
{
		if( !list->input.phb_Input->pBlock )
		{
			list->input.phb_Input->pBlock = list->input.phb_Input->region->pHistory.root.next;
			list->input.phb_Input->pBlock->nLinesUsed = 1;
			list->input.phb_Input->pBlock->pLines[0].flags.deleted = 0;
			list->input.phb_Input->nLine = 1;
		}
		list->input.phb_Input->pBlock->pLines[0].pLine = list->input.CommandInfo->CollectionBuffer;
		SetStart( list->input.phb_Input->pBlock->pLines[0].pLine );
		{
			DECLTEXT( blank_eol, "" );
			list->input.phb_Input->pBlock->pLines[0].nLineLength = LineLengthExEx( list->input.phb_Input->pBlock->pLines[0].pLine, FALSE, 8, (PTEXT)&blank_eol );
		}
		//if( !pdp->flags.bDirect && pdp->flags.bWrapCommand )
		BuildDisplayInfoLines( list->input.phb_Input, list->input_font );
}
コード例 #8
0
ファイル: RelationData.cpp プロジェクト: jeremysalwen/douml
void RelationData::garbage(BrowserRelation * r)
{
    if (r == start) {
        SetStart(0);

        if ((end == 0) ||
            (end->get_data() == 0)) // bi-dir rel, reverse rel wasn't read
            delete this;
    }
    else if (start == 0)
        // end -> start read, but start -> end not read
        delete this;
    else {
        SetEnd(0);

        if (start == 0)
            delete this;
    }
}
コード例 #9
0
ファイル: linemarkertable.cpp プロジェクト: JianwenSun/cc
bool Location::Expand(const Location * pLocation)
{
    AssertIfNull(pLocation);

    bool LocationChanged = false;

    if (pLocation->StartsBefore(this))
    {
        SetStart(pLocation);
        LocationChanged = true;
    }

    if (pLocation->EndsAfter(this))
    {
        SetEnd(pLocation);
        LocationChanged = true;
    }

    return LocationChanged;
}
コード例 #10
0
void MovieLooperUI::PositionIndicator::MouseMoved(BPoint pt, uint32 code, const BMessage *msg)
{
	if (startMoving)
	{
		// if there is a change in x
		// and it's not too small
		// and it's not past endCoord
		if (floor(pt.x) != floor(startCoord)
			&& pt.x >= 3.0
			&& pt.x <= (endCoord-5.0))
		{
			SetStart((int64)floor((pt.x/(Bounds().Width()-6.0))*frameCount));
			float oldCoord = startCoord;
			startCoord = pt.x;
			if (oldCoord > startCoord)
				Draw(BRect(1.0,1.0,oldCoord+4.0,Bounds().bottom-1.0));
			else
				Draw(BRect(1.0,1.0,startCoord+4.0,Bounds().bottom-1.0));
		}
	}
	else if (endMoving)
	{
		// if there is a change in x
		// and it's not too big
		// and it's not past startCoord
		if (floor(pt.x) != floor(endCoord)
			&& pt.x <= Bounds().right-3.0
			&& pt.x >= (startCoord+5.0))
		{
			SetEnd((int64)floor((pt.x/(Bounds().Width()-6.0))*frameCount));
			float oldCoord = endCoord;
			endCoord = pt.x;
			if (oldCoord < endCoord)
				Draw(BRect(oldCoord-4.0,1.0,Bounds().right-1.0,Bounds().bottom-1.0));
			else
				Draw(BRect(endCoord-4.0,1.0,Bounds().right-1.0,Bounds().bottom-1.0));
			
		}
	}
}
コード例 #11
0
ファイル: class_edge_mod.cpp プロジェクト: cpavlina/kicad
void EDGE_MODULE::Flip( const wxPoint& aCentre )
{
    wxPoint pt;

    switch( GetShape() )
    {
    case S_ARC:
        SetAngle( -GetAngle() );
        //Fall through
    default:
    case S_SEGMENT:
        pt = GetStart();
        MIRROR( pt.y, aCentre.y );
        SetStart( pt );

        pt = GetEnd();
        MIRROR( pt.y, aCentre.y );
        SetEnd( pt );

        MIRROR( m_Start0.y, 0 );
        MIRROR( m_End0.y, 0 );
        break;

    case S_POLYGON:
        // polygon corners coordinates are always relative to the
        // footprint position, orientation 0
        for( auto iter = m_Poly.Iterate(); iter; iter++ )
        {
            MIRROR( iter->y, 0 );
        }
	break;
    }

    // DRAWSEGMENT items are not usually on copper layers, but
    // it can happen in microwave apps.
    // However, currently, only on Front or Back layers.
    // So the copper layers count is not taken in account
    SetLayer( FlipLayer( GetLayer() ) );
}
コード例 #12
0
PTEXT win_get_line(HANDLE hFile)
{
//   extern HANDLE hStdin;
   #define WORKSPACE 1024  // character for workspace
   PTEXT workline=(PTEXT)NULL;
   uint32_t length = 0;
   do
   {
      // create a workspace to read input from the file.
      workline=SegAppend(workline,SegCreate(WORKSPACE));
      SetEnd( workline );
      // read a line of input from the file.
      if( !ReadConsole( hFile
                           , GetText(workline)
                           , WORKSPACE
                           , &length
                           , NULL) ) // if no input read.
      {
         if (PRIORLINE(workline)) // if we've read some.
         {
            PTEXT t;
            workline=PRIORLINE(workline); // go back one.
            SegBreak(t = NEXTLINE(workline));
            LineRelease(t);  // destroy the current segment.
         }
         else
         {
            LineRelease(workline);            // destory only segment.
            workline = NULL;
         }
         break;  // get out of the loop- there is no more to read.
      }
   }
   while (GetText(workline)[length-1]!='\n'); //while not at the end of the line.
   if (workline&&length)  // if I got a line, and there was some length to it.
      SetStart(workline);   // set workline to the beginning.
   return(workline);      // return the line read from the file.
}
コード例 #13
0
ファイル: RelationData.cpp プロジェクト: jeremysalwen/douml
RelationData::RelationData(UmlCode e, int id)
    : Labeled<RelationData>(all, id), is_deleted(FALSE), is_unconsistent(FALSE), type(e)
{
    a.isa_class_relation = b.isa_class_relation = FALSE;
    a.isa_volatile_relation = b.isa_volatile_relation = FALSE;
    a.isa_const_relation = b.isa_const_relation = FALSE;
    a.is_derived = b.is_derived =  FALSE;
    a.is_derivedunion = b.is_derivedunion =  FALSE;
    a.is_ordered = b.is_ordered =  FALSE;
    a.is_unique = b.is_unique =  FALSE;
    a.uml_visibility = b.uml_visibility = UmlDefaultVisibility;
    a.cpp_virtual_inheritance = b.cpp_virtual_inheritance = FALSE;
    a.cpp_visibility = b.cpp_visibility = UmlDefaultVisibility;
    a.cpp_mutable = b.cpp_mutable = FALSE;
    a.java_transient = b.java_transient = FALSE;
    a.idl_truncatable_inheritance = b.idl_truncatable_inheritance = FALSE;
    a.idl_case = b.idl_case = 0;
    name = default_name(e);
    SetStart(0);
    SetEnd(0);
    end_removed_from = 0;
    original_id = 0;
}
コード例 #14
0
void EDGE_MODULE::Flip(const wxPoint& aCentre )
{
    wxPoint pt;

    switch( GetShape() )
    {
    case S_ARC:
        SetAngle( -GetAngle() );
        //Fall through
    default:
    case S_SEGMENT:
        pt = GetStart();
        pt.y -= aCentre.y;
        pt.y  = -pt.y;
        pt.y += aCentre.y;
        SetStart( pt );

        pt = GetEnd();
        pt.y -= aCentre.y;
        pt.y  = -pt.y;
        pt.y += aCentre.y;
        SetEnd( pt );

        NEGATE( m_Start0.y );
        NEGATE( m_End0.y );
        break;

    case S_POLYGON:
        // polygon corners coordinates are always relative to the
        // footprint position, orientation 0
        for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
            NEGATE( m_PolyPoints[ii].y );
    }

    SetLayer( FlipLayer( GetLayer() ) );
}
コード例 #15
0
void PlayBot()
{
	printf("\n\nAt Any Time In The Game If You Want To See The Grid Indexing In Which You Have To Make A Move\n\n");
	printf("During Enter A Move Command...Just Press 0 And Press Enter \n\n");
	BOARD *board=new BOARD;
	SetStart(board);
	printf("The Starting Board\n\n");
	PrintBoard(board);
	char Inp[200];
	int Side;
	printf("\nChoose Your Side...\n\n0. For Black\n1. For White\n");
	scanf("%d",&Side);
	if(Side==0)
	{
		MOVE *list1=new MOVE;
		GenMoves(board,list1);
		vector<int>BestMove1=SearchPos(board,8);
		MakeMove(board,BestMove1);
		PrintBoard(board);
	}
	while(1)
	{
		printf("\n\nEnter Your Move\n");
		getchar();
		scanf("%[^\n]",&Inp);
		if(Inp[0]=='0')
		{
			PrintIndex();
			continue;
		}
		else if(Inp[0]=='1')
		{
			printf("\nYour Possible MoveList is\n");
			MOVE *YourMoveList=new MOVE;
			GenMoves(board,YourMoveList);
			PrintMoveList(YourMoveList);
		}
		vector<int>Move=ParseMove(Inp);
		if(MoveExists(board,Move))
			MakeMove(board,Move);
		else
		{
			MOVE *User=new MOVE;
			GenMoves(board,User);
			if(User->Count==0)
			{
				printf("Sorry You Lost\n\n");
				break;
			}
			else
				printf("Invalid Move...Enter Again\n\n");
			continue;
		}
		PrintBoard(board);
		printf("-----------------------------------Bot's Turn----------------------------------\n");
		MOVE *Bot=new MOVE;
		GenMoves(board,Bot);
		if(Bot->Count==0)
		{
			printf("--------------------------Congratulations You Win--------------------------\n");
			break;
		}
		vector<int>BestMove=SearchPos(board,8);
		MakeMove(board,BestMove);
		PrintBoard(board);
	}
	StartGame();	
}
コード例 #16
0
/**
 Constructor.
*/
CGXDLMSSeasonProfile::CGXDLMSSeasonProfile(std::string name, CGXDateTime start, std::string weekName)
{
    SetName(name);
    SetStart(start);
    SetWeekName(weekName);
}
コード例 #17
0
/**********************************************************************
* CTextRun::Speak() *
*-------------------*
*	Description:  
*       Uses *plStart and *plEnd to find the nearest start and 
*       endpoints for speaking (to the nearest word).
*       Returns these values in plStart and plEnd.
*		Speaks the text associated with this CTextRun from *plStart 
*       to *plEnd.  
*       
*       If *plStart is not within the range, then 
*       start at the beginning.  If lEnd is not within range, then
*       end at the end.  
*
* 	Return:
*       S_OK
*       E_POINTER
*		Return value of CTextRun::Speak()
**********************************************************************/
HRESULT CTextRun::Speak( ISpVoice &rVoice, 
                               long *plStart,
                               long *plEnd )
{
    if ( !plStart || !plEnd )
    {
        return E_POINTER;
    }
    _ASSERTE( m_cpTextRange );
    if ( !m_cpTextRange )
    {
        return E_UNEXPECTED;
    }

    // Save the old range
    long lOldStart = GetStart();
    long lOldEnd = GetEnd();

    // Out of range start or end means we start speaking from the start
    // or end (resp.) of the text range.
    
    if ( WithinRange( *plStart ) )
    {
        // The start needs to be moved
        SetStart( *plStart );
    }
    else
    {
        *plStart = GetStart();
    }

    if ( WithinRange( *plEnd ) )
    {
        // The end needs to be moved
        SetEnd( *plEnd );
    }
    else
    {
        *plEnd = GetEnd();
    }

    // Expand to include whole words
    m_cpTextRange->Expand( tomWord, NULL );

    // Get the new start and end so that we can pass them back
    m_cpTextRange->GetStart( plStart );
    m_cpTextRange->GetEnd( plEnd );

    // We should never speak past the end of this run, even if expanding to include
    // whole words caused extra text to be included 
    // (e.g. if you typed "This is a sentence" and dictated some text that 
    // consumed leading spaces right afterwards)
    *plStart = __max( *plStart, lOldStart );
    *plEnd = __min( *plEnd, lOldEnd );
    SetStart( *plStart );
    SetEnd( *plEnd );

    // Pass to the CTextRun::Speak() that speaks an entire run
    HRESULT hr = Speak( rVoice );

    // Restore the old range limits
    SetStart( lOldStart );
    SetEnd( lOldEnd );

    return hr;
}   /* CTextRun::Speak */
コード例 #18
0
/**********************************************************************
* CTextRun::Concatenate *
*-----------------------*
*	Description:  
*		If possible, concatenates pNext (pPrev if fConcatAfter is false)
*       onto the end of this.
*       Another CTextRun can always be concatenated on, unless it 
*       contains dictation.
*
* 	Return:
*		E_NOMERGE if could not be merged (because pTextRun is dictation)
*       E_FULLMERGE
**********************************************************************/
MERGERESULT CTextRun::Concatenate( CTextRun *pTextRun, bool fConcatAfter )
{
    if ( !pTextRun || !m_cpTextRange )
    {
        return E_NOMERGE;
    }

    // Check for compatibility: In this case, neither mergee can be 
    // a dict run
    if ( IsDict() || pTextRun->IsDict() )
    {
        return E_NOMERGE;
    }

    // lNewBound will be the new end (resp. start) of the run, if the 
    // concatenation is successful
    long lNewBound;
   
    // Concatenation is possible iff one run ends exactly where the other
    // begins.
    // If concatenation is possible, do it.
    if ( fConcatAfter )
    {
        // Will be concatenating pTextRun onto the end of this
        if ( GetEnd() != pTextRun->GetStart() )
        {
            // They are not consecutive runs
            return E_NOMERGE;
        }

        // lNewBound will be the new end of the run, if the 
        // concatenation is successful
        lNewBound = pTextRun->GetEnd();
        
        // Swallow up pTextRun by setting our end to its end
        SetEnd( lNewBound );

        // Make pTextRun degenerate
        pTextRun->SetStart( lNewBound );
        
    }
    else
    {
        // Will be concatenating pTextRun onto the beginning of this
        if ( GetStart() != pTextRun->GetEnd() )
        {
            return E_NOMERGE;
        }

        // lNewBound will be the new start of the run, if the 
        // concatenation is successful
        lNewBound = pTextRun->GetStart();

        // Swallow up pTextRun by setting our start to its start
        SetStart( lNewBound );

        // Make pTextRun degenerate
        pTextRun->SetEnd( lNewBound );
    }

    return E_FULLMERGE;
}   /* CTextRun::Concatenate */
コード例 #19
0
ファイル: RelationData.cpp プロジェクト: jeremysalwen/douml
BrowserRelation * RelationData::set_start_end(BrowserRelation * s, BrowserClass * e)
{
    SetStart(s);
    if (! uni_directional(type))
        SetEnd(new BrowserRelation(e, this));
    else {
        end_removed_from = e;
        connect(e->get_data(), SIGNAL(deleted()), this, SLOT(end_deleted()));
    }

    if (a.uml_visibility == UmlDefaultVisibility) {
        QString st = ((BrowserClass *) s->parent())->get_stereotype();

        switch (type) {
        case UmlGeneralisation:
        case UmlRealize:
            a.uml_visibility = UmlPublic;

            if (GenerationSettings::cpp_get_default_defs())
                a.cpp_decl = (ClassDialog::cpp_stereotype(st) != "enum")
                             ? "${type}" : "";

            if (GenerationSettings::java_get_default_defs())
                a.java_decl = "${type}";

            if (GenerationSettings::php_get_default_defs())
                a.php_decl = "${type}";

            if (GenerationSettings::python_get_default_defs())
                a.python_decl = "${type}";

            if (GenerationSettings::idl_get_default_defs())
                a.idl_decl = (ClassDialog::idl_stereotype(st) != "enum")
                             ? "${type}" : "";

            break;

        case UmlDependency:
            if (GenerationSettings::cpp_get_default_defs())
                a.cpp_decl = "#include in source";

            if (GenerationSettings::php_get_default_defs())
                a.php_decl = "${type}";

            if (GenerationSettings::python_get_default_defs())
                a.python_decl = "${type}";

            break;

        default:
            a.uml_visibility =
                ((BrowserNode *) start->parent())->get_visibility(UmlRelations);
            default_decls(a, type,
                          ((BrowserNode *) start->parent())->get_data()->get_stereotype());
        }
    }

    if (end != 0) {
        if (b.uml_visibility == UmlDefaultVisibility)
            b.uml_visibility = e->get_visibility(UmlRelations);

        default_decls(b, type,
                      ((BrowserNode *) end->parent())->get_data()->get_stereotype());
    }
    else
        b.uml_visibility = end_removed_from->get_visibility(UmlRelations);

    return end;
}
コード例 #20
0
ファイル: Event.cpp プロジェクト: HaikuArchives/MeV
bool CEvent::SetAttribute( enum E_EventAttribute inAttr, int32 inValue )
{
	uint8		cmd = Command();

	switch (inAttr) {
	case EvAttr_StartTime:					// start time
		SetStart( inValue );
		return true;

	case EvAttr_Duration:						// event duration
		if (HasProperty( Prop_Duration ))
		{
			SetDuration(1 > inValue ? 1 : inValue);
			return true;
		}
		return false;
	
	case EvAttr_StopTime:						// event stop time
		return false;						// Can't set stop -- must set duration

	case EvAttr_Type:						// event type
		SetCommand( CLAMP( EvtType_End, inValue, EvtType_Count - 1 ) );
		return true;

	case EvAttr_Selected:						// Whether it's selected or not
		SetSelected( inValue != 0 );
		return true;
	
	case EvAttr_Channel:						// virtual channel number
		if (HasProperty( Prop_Channel ))
			SetVChannel( CLAMP( 0L, inValue, Max_Destinations ) );
		return true;
	
	case EvAttr_Pitch:						// pitch attribute
		if (	cmd == EvtType_Note || cmd == EvtType_NoteOff)
		{
			note.pitch = CLAMP( 0L, inValue, 127 );
			return true;
		}
		else if (cmd == EvtType_PolyATouch)
		{
			aTouch.pitch = CLAMP( 0L, inValue, 127 );
			return true;
		}
		else return false;

	case EvAttr_AttackVelocity:				// attack velocity
		if (	cmd == EvtType_Note || cmd == EvtType_NoteOff)
		{
			note.attackVelocity = CLAMP( 1L, inValue, 127 );
	
			return true;
		}
		else return false;

	case EvAttr_ReleaseVelocity:				// release velocity
		if (	cmd == EvtType_Note || cmd == EvtType_NoteOff)
		{
			note.releaseVelocity = CLAMP( 0L, inValue, 127 );
			return true;
		}
		else return false;

	case EvAttr_AfterTouch:					// aftertouch value
		if (	cmd == EvtType_PolyATouch)
		{
			aTouch.value = CLAMP( 0L, inValue, 127 );
			return true;
		}
		else return false;

	case EvAttr_Program:						// program number attribute
		if (	cmd == EvtType_ProgramChange)
		{
			programChange.program = CLAMP( 0L, inValue, 127 );
			return true;
		}
		return false;

	case EvAttr_ProgramBank:					// program bank number
		if (	cmd == EvtType_ProgramChange)
		{
			inValue = CLAMP( 0L, inValue, 0x3fff );
			programChange.bankMSB = inValue >> 7;
			programChange.bankLSB = inValue & 0x7f;
			return true;
		}
		return false;

	case EvAttr_VPos:						// arbitrary vertical position
		if (HasProperty( Prop_VertPos )) repeat.vPos = CLAMP( 0L, inValue, 63 );
		return false;

	case EvAttr_ControllerNumber:				// controller number
		if (cmd == EvtType_Controller)
		{
			controlChange.controller = CLAMP( 0L, inValue, 127 );
		}
		return false;

	case EvAttr_ControllerValue8:				// 8-bit controller value
		if (cmd == EvtType_Controller)
		{
			controlChange.MSB = CLAMP( 0L, inValue, 127 );
			controlChange.LSB = 0;
		}
		return false;

	case EvAttr_ControllerValue16:			// 16-bit controller value
		if (	cmd == EvtType_Controller)
		{
			inValue = CLAMP( 0L, inValue, 0x3fff );
			controlChange.MSB = inValue >> 7;
			controlChange.LSB = inValue & 0x7f;
			return true;
		}
コード例 #21
0
ファイル: nuiLayout.cpp プロジェクト: JamesLinus/nui3
bool nuiLayoutConstraint::Set(const nglString& rDescription)
{
  int index = 0;
  nglUChar c = rDescription.GetNextUChar(index);

  if (c == '[')
  {
    // Fix start + ?
    int pos = index;
    int end = index;
    c = rDescription.GetNextUChar(index);
    while (c != ',' && c != '}')
    {
      end = index;
      c = rDescription.GetNextUChar(index);
    }

    nglString anchor1 = rDescription.Extract(pos, index - pos - 1);
    anchor1.Trim();

    if (c == ',')
    {
      // Fix stop or fix size
      int pos = index;
      int end = index;
      c = rDescription.GetNextUChar(index);
      while (c != ']' && c != '}')
      {
        end = index;
        c = rDescription.GetNextUChar(index);
      }

      nglString anchor2 = rDescription.Extract(pos, index - pos - 1);
      anchor2.Trim();

      if (c == ']')
      {
        // Start and Stop:
        SetStartAndStop(anchor1, anchor2);
        return true;
      }
      else if (c == '}')
      {
        // Start and size:
        SetStartAndSize(anchor1, anchor2.GetCFloat());
        return true;
      }

    }
    else if (c == '}')
    {
      // Fix start
      SetStart(anchor1);
      return true;
    }
    
  }
  else if (c == '{')
  {
    // Fix end + ?
    int pos = index;
    int end = index;
    c = rDescription.GetNextUChar(index);
    while (c != ',' && c != '}' && c != ']')
    {
      end = index;
      c = rDescription.GetNextUChar(index);
    }

    nglString anchor1 = rDescription.Extract(pos, index - pos - 1);
    anchor1.Trim();

    if (c == ',')
    {
      // Fix stop or fix size
      int pos = index;
      int end = index;
      c = rDescription.GetNextUChar(index);

      while (c != ']' && c != '}' && c != ',')
      {
        end = index;
        c = rDescription.GetNextUChar(index);
      }

      nglString anchor2 = rDescription.Extract(pos, index - pos - 1);
      anchor2.Trim();

      if (c == ']')
      {
        // size and Stop:
        SetStopAndSize(anchor2, anchor1.GetCFloat());
        return true;
      }
      else if (c == '}')
      {
        // Midle and size:
        if (anchor2.IsFloat())
          SetMiddleAndSize(anchor1, anchor2.GetCFloat());
        else
          SetMiddle(anchor1, anchor2);
        return true;
      }
      else if (c == ',')
      {
        nglString anchor2 = rDescription.Extract(pos, index - pos - 1);
        anchor2.Trim();

        // Fix stop or fix size
        int pos = index;
        int end = index;
        c = rDescription.GetNextUChar(index);

        while (c != '}')
        {
          end = index;
          c = rDescription.GetNextUChar(index);
        }

        nglString anchor3 = rDescription.Extract(pos, index - pos - 1);
        anchor3.Trim();

        SetMiddleAndSize(anchor1, anchor2, anchor3.GetCFloat());
        return true;
      }

    }
    else if (c == '}')
    {
      // Fix middle
      if (anchor1.IsFloat())
        SetMiddleAndSize(nglString::Null, anchor1.GetCFloat());
      else
        SetMiddle(anchor1);
      return true;
    }
    else if (c == ']')
    {
      // Fix stop
      SetStop(anchor1);
      return true;
    }
  }
  else
  {
    SetSize(rDescription.GetCFloat());
    return true;
  }

  return false;
}
コード例 #22
0
ファイル: nsTypeAheadFind.cpp プロジェクト: hibrium/Pale-Moon
nsresult
nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer,
                                     nsISelectionController *aSelectionController,
                                     bool aIsFirstVisiblePreferred,
                                     bool aFindPrev,
                                     nsIPresShell **aPresShell,
                                     nsPresContext **aPresContext)
{
  NS_ENSURE_ARG_POINTER(aContainer);
  NS_ENSURE_ARG_POINTER(aPresShell);
  NS_ENSURE_ARG_POINTER(aPresContext);

  *aPresShell = nullptr;
  *aPresContext = nullptr;

  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
  if (!docShell)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();

  nsRefPtr<nsPresContext> presContext;
  docShell->GetPresContext(getter_AddRefs(presContext));

  if (!presShell || !presContext)
    return NS_ERROR_FAILURE;

  nsIDocument* doc = presShell->GetDocument();

  if (!doc)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIContent> rootContent;
  nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(doc));
  if (htmlDoc) {
    nsCOMPtr<nsIDOMHTMLElement> bodyEl;
    htmlDoc->GetBody(getter_AddRefs(bodyEl));
    rootContent = do_QueryInterface(bodyEl);
  }

  if (!rootContent)
    rootContent = doc->GetRootElement();
 
  nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(rootContent));

  if (!rootNode)
    return NS_ERROR_FAILURE;

  uint32_t childCount = rootContent->GetChildCount();

  if (!mSearchRange) {
    mSearchRange = new nsRange(rootContent);
  }

  if (!mEndPointRange) {
    mEndPointRange = new nsRange(rootContent);
  }

  mSearchRange->SelectNodeContents(rootNode);

  mEndPointRange->SetEnd(rootNode, childCount);
  mEndPointRange->Collapse(false); // collapse to end

  // Consider current selection as null if
  // it's not in the currently focused document
  nsCOMPtr<nsIDOMRange> currentSelectionRange;
  nsCOMPtr<nsIPresShell> selectionPresShell = GetPresShell();
  if (aSelectionController && selectionPresShell && selectionPresShell == presShell) {
    nsCOMPtr<nsISelection> selection;
    aSelectionController->GetSelection(
      nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
    if (selection)
      selection->GetRangeAt(0, getter_AddRefs(currentSelectionRange));
  }

  if (!mStartPointRange) {
    mStartPointRange = new nsRange(doc);
  }

  if (!currentSelectionRange) {
    // Ensure visible range, move forward if necessary
    // This uses ignores the return value, but usese the side effect of
    // IsRangeVisible. It returns the first visible range after searchRange
    IsRangeVisible(presShell, presContext, mSearchRange, 
                   aIsFirstVisiblePreferred, true, 
                   getter_AddRefs(mStartPointRange), nullptr);
  }
  else {
    int32_t startOffset;
    nsCOMPtr<nsIDOMNode> startNode;
    if (aFindPrev) {
      currentSelectionRange->GetStartContainer(getter_AddRefs(startNode));
      currentSelectionRange->GetStartOffset(&startOffset);
    } else {
      currentSelectionRange->GetEndContainer(getter_AddRefs(startNode));
      currentSelectionRange->GetEndOffset(&startOffset);
    }
    if (!startNode)
      startNode = rootNode;    

    // We need to set the start point this way, other methods haven't worked
    mStartPointRange->SelectNode(startNode);
    mStartPointRange->SetStart(startNode, startOffset);
  }

  mStartPointRange->Collapse(true); // collapse to start

  *aPresShell = presShell;
  NS_ADDREF(*aPresShell);

  *aPresContext = presContext;
  NS_ADDREF(*aPresContext);

  return NS_OK;
}
コード例 #23
0
void EMVideoTransitionClip::MoveClip(int64 p_vNewTime)
{
	SetStart(p_vNewTime);
}
コード例 #24
0
nsresult
nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer,
                                     nsISelectionController *aSelectionController,
                                     bool aIsFirstVisiblePreferred,
                                     bool aFindPrev,
                                     nsIPresShell **aPresShell,
                                     nsPresContext **aPresContext)
{
  NS_ENSURE_ARG_POINTER(aContainer);
  NS_ENSURE_ARG_POINTER(aPresShell);
  NS_ENSURE_ARG_POINTER(aPresContext);

  *aPresShell = nullptr;
  *aPresContext = nullptr;

  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
  if (!docShell)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();

  nsRefPtr<nsPresContext> presContext;
  docShell->GetPresContext(getter_AddRefs(presContext));

  if (!presShell || !presContext)
    return NS_ERROR_FAILURE;

  nsIDocument* doc = presShell->GetDocument();

  if (!doc)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIContent> rootContent;
  nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(doc));
  if (htmlDoc) {
    nsCOMPtr<nsIDOMHTMLElement> bodyEl;
    htmlDoc->GetBody(getter_AddRefs(bodyEl));
    rootContent = do_QueryInterface(bodyEl);
  }

  if (!rootContent)
    rootContent = doc->GetRootElement();
 
  nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(rootContent));

  if (!rootNode)
    return NS_ERROR_FAILURE;

  if (!mSearchRange) {
    mSearchRange = new nsRange(doc);
  }
  nsCOMPtr<nsIDOMNode> searchRootNode = rootNode;

  // Hack for XMLPrettyPrinter. nsFind can't handle complex anonymous content.
  // If the root node has an XBL binding then there's not much we can do in
  // in general, but we can try searching the binding's first child, which
  // in the case of XMLPrettyPrinter contains the visible pretty-printed
  // content.
  nsXBLBinding* binding = rootContent->GetXBLBinding();
  if (binding) {
    nsIContent* anonContent = binding->GetAnonymousContent();
    if (anonContent) {
      searchRootNode = do_QueryInterface(anonContent->GetFirstChild());
    }
  }
  mSearchRange->SelectNodeContents(searchRootNode);

  if (!mStartPointRange) {
    mStartPointRange = new nsRange(doc);
  }
  mStartPointRange->SetStart(searchRootNode, 0);
  mStartPointRange->Collapse(true); // collapse to start

  if (!mEndPointRange) {
    mEndPointRange = new nsRange(doc);
  }
  nsCOMPtr<nsINode> searchRootTmp = do_QueryInterface(searchRootNode);
  mEndPointRange->SetEnd(searchRootNode, searchRootTmp->Length());
  mEndPointRange->Collapse(false); // collapse to end

  // Consider current selection as null if
  // it's not in the currently focused document
  nsCOMPtr<nsIDOMRange> currentSelectionRange;
  nsCOMPtr<nsIPresShell> selectionPresShell = GetPresShell();
  if (aSelectionController && selectionPresShell && selectionPresShell == presShell) {
    nsCOMPtr<nsISelection> selection;
    aSelectionController->GetSelection(
      nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
    if (selection)
      selection->GetRangeAt(0, getter_AddRefs(currentSelectionRange));
  }

  if (!currentSelectionRange) {
    // Ensure visible range, move forward if necessary
    // This uses ignores the return value, but usese the side effect of
    // IsRangeVisible. It returns the first visible range after searchRange
    IsRangeVisible(presShell, presContext, mSearchRange, 
                   aIsFirstVisiblePreferred, true, 
                   getter_AddRefs(mStartPointRange), nullptr);
  }
  else {
    int32_t startOffset;
    nsCOMPtr<nsIDOMNode> startNode;
    if (aFindPrev) {
      currentSelectionRange->GetStartContainer(getter_AddRefs(startNode));
      currentSelectionRange->GetStartOffset(&startOffset);
    } else {
      currentSelectionRange->GetEndContainer(getter_AddRefs(startNode));
      currentSelectionRange->GetEndOffset(&startOffset);
    }
    if (!startNode)
      startNode = rootNode;    

    // We need to set the start point this way, other methods haven't worked
    mStartPointRange->SelectNode(startNode);
    mStartPointRange->SetStart(startNode, startOffset);
  }

  mStartPointRange->Collapse(true); // collapse to start

  presShell.forget(aPresShell);
  presContext.forget(aPresContext);

  return NS_OK;
}
コード例 #25
0
CORE_PROC( PTEXT, GatherLineEx )( PTEXT *pOutput, INDEX *pIndex, int bInsert, int bSaveCR, int bData, PTEXT pInput )
// if data - assume data is coming from a preformatted source
// otherwise use escape as command entry and clear buffer...
{
	// this routine should be used to process user type character
	// input into a legible line buffer....
	// results in a complete line....
	// the line returned must be used - the output buffer
	// is an accumulator and will contain any partial input buffer
	// which remaineder if an EOL sequence was found....

	// build line in buffer using standard console
	// behavior... 

	INDEX pos
       , len = 0
       , size
       , maxlen = 0;
	PTEXT pReturn = NULL;
	PTEXT pDelete = NULL;
	TEXTCHAR character;
	TEXTSTR output;

	if( !pOutput ) // must supply a holder for partial collection...
		return NULL;

	if( !pInput ) // nothing new input - just using previous collection...
	{
		if( *pOutput )
		{
			// use prior partial as new input....
			pInput = *pOutput;
			pDelete = pInput; // this is never deleted if we use prior...
			SetStart( pInput );
			*pOutput = NULL;
		}
		else
			return NULL;
	}
	// probably first pass of gathering...
	if( !*pOutput )
	{
		*pOutput = SegCreate( BUILD_LINE_OUTPUT_SIZE );
		if( pIndex )
			*pIndex = 0;
		SetTextSize( *pOutput, 0 );
		output = GetText( *pOutput );
		len = 0;
	}
	else if( pIndex )
	{
		output = GetText( *pOutput );
		len = *pIndex;
		if( (*pOutput)->data.size != len )
		{
			if( bInsert )
			{
				// creates a new segment inbetween here.....
				*pOutput = SplitLine( *pOutput, *pIndex );
				output = GetText( *pOutput );
				len = *pIndex = GetTextSize( *pOutput );
			}
			else
			{
				maxlen = (*pOutput)->data.size;
			}
		}
	}
	else
	{
		output = GetText( *pOutput );
		len = GetTextSize( *pOutput );
	}

	while( pInput )
	{
		size = GetTextSize( pInput );
		for( pos = 0; pos < size; pos++ )
		{
			switch( character = GetText( pInput )[pos] )
			{
			case '\x1b':
				if( !bData )
				{
					SetEnd( *pOutput );
					SetStart( *pOutput )
					{
						SetTextSize( *pOutput, 0 );
					}
					SetTextSize( *pOutput, 0 );
					output = GetText( *pOutput );
					len = 0;
				}
				else
					goto defaultcase;
				break;
			case '\x7f': // handle unix type delete too ? perhaps...
				if( !bInsert )
				{
					PTEXT pNext;
					// this will slide from the middle to the end...
					// if bInsert - then prior to entrying this switch
					// the data was split and THIS segment is set to zero.
					pNext = *pOutput;
					if( len != (maxlen = GetTextSize( *pOutput )) )
					{
						MemCpy( output + len, output+len+1, maxlen - len );
						SetTextSize( *pOutput, --maxlen );
					}
					else
					{
						PTEXT pDel;
						pNext = *pOutput;
						do {
							pDel = pNext;
							pNext = NEXTLINE( pNext );
							if( pDel != *pOutput )
							{
								SegGrab( pDel );
								LineRelease( pDel );
							}
						} while( pNext && !GetTextSize( pNext ) );
						if( pNext )
						{
							size_t len2;
							output = GetText( pNext );
							len2 = GetTextSize( pNext ) - 1;
							*pOutput = pNext;
							len = 0;
							MemCpy( output, output+1, len2 );
							SetTextSize( pNext, len2 );
						}
					}
				}
				else // was insert is either at end....
				{
					// I dunno perform sliding delete operation...
					// must refresh the output string....
					{
						PTEXT pNext, pDel;
						pNext = *pOutput;
						do {
							pDel = pNext;
							pNext = NEXTLINE( pNext );
							if( pDel != *pOutput )
							{
								SegGrab( pDel );
								LineRelease( pDel );
							}
						} while( pNext && !GetTextSize( pNext ) );
						if( pNext )
						{
							size_t len2;
							TEXTCHAR *data;
							data = GetText( pNext );
							MemCpy( data, data+1, len2 = (GetTextSize( pNext ) - 1 ));
							SetTextSize( pNext, len2 );
						}
					}
				}
				break;
			case '\b':
				/* perhaps consider using split for backspace in a line...*/
				if( !bInsert )
				{
					PTEXT pNext;
					size_t maxlen;
					// this will slide from the middle to the end...
					// if bInsert - then prior to entrying this switch
					// the data was split and THIS segment is set to zero.
					pNext = *pOutput;
					maxlen = GetTextSize( *pOutput );
					while( !maxlen && PRIORLINE( *pOutput ) )
					{
						*pOutput = PRIORLINE( *pOutput );
						len = maxlen = GetTextSize( *pOutput );
					}
					if( maxlen )
					{
						if( len != maxlen )
						{
							size_t sz;
							sz = maxlen - len;
							MemCpy( output + len - 1, output + len, sz );
							SetTextSize( *pOutput, maxlen - 1 );
							len--;
						}
						else
						{
							SetTextSize( *pOutput, --len );
						}
					}
				}
				else // was insert is either at end....
				{
					if( len )
					{
						SetTextSize( *pOutput, --len );
					}
					else
					{
						if( PRIORLINE( *pOutput ) )
						{
							*pOutput = PRIORLINE( *pOutput );
							len = GetTextSize( *pOutput );
						}

						if( len )
							SetTextSize( *pOutput, --len );
					}
				}
				break;
			case '\r': // ignore this character...
				if( !bSaveCR )
					break;
				// falls through .. past this and saves the return...
				if(0)
			case '\n':
				if( !pReturn )
				{
					// transfer *pOutput to pReturn....
					pReturn = *pOutput;
					SetEnd( pReturn );
					output = GetText( pReturn );
					len = GetTextSize( pReturn );
					output[len] = character;
					SetTextSize( pReturn, ++len );
					// begin next collection in case more data is in the input...
					*pOutput = SegCreate( BUILD_LINE_OUTPUT_SIZE );
					SetTextSize( *pOutput, 0 );
					output = GetText( *pOutput );
					len = 0;
					break;
				}
				// store carriage return... 
			default:
    defaultcase:
				output[len++] = character;

				if( (maxlen && len == maxlen ) ||
                len == BUILD_LINE_OUTPUT_SIZE )
				{
					PTEXT pTemp;
					SetTextSize( *pOutput, len );
					if( !NEXTLINE( *pOutput ) )
					{
						SegAppend( *pOutput, pTemp = SegCreate( BUILD_LINE_OUTPUT_SIZE ) );
						SetTextSize( pTemp, 0 );
					}
					else
					{
						pTemp = NEXTLINE( *pOutput );
						maxlen = GetTextSize( pTemp );
					}
					*pOutput = pTemp;
					output = GetText( *pOutput );
					len = 0;
				}
				else
				{
					if( bInsert ) // insertion happens at end of segment
                             // and the segment is broken...
					{
						if( !pIndex || ( len > *pIndex ) )
							SetTextSize( *pOutput, len );
					}
					else
						if( len > GetTextSize( *pOutput ) )
						{
							SetTextSize( *pOutput, len );
						}
				}

				break;
			}
		}
コード例 #26
0
/** 
 Constructor.
*/
CGXDLMSSeasonProfile::CGXDLMSSeasonProfile(basic_string<char> name, CGXDateTime start, basic_string<char> weekName)
{
    SetName(name);
    SetStart(start);
    SetWeekName(weekName);
}
コード例 #27
0
ファイル: Animation.cpp プロジェクト: chengkaizone/HelperTip
CAnimationItem& CAnimationItem::SetPoint( CPoint pt )
{
	SetStart( pt );
	return SetFinish( pt );
}