Exemple #1
0
//右クリックされた際の処理
void TweetList::onListBoxRightClick(wxMouseEvent& event) {
	int x,y;
	event.GetPosition(&x,&y);
	int firstLine = GetVisibleBegin();
	int lastLine = GetVisibleEnd();

	Tweet* firstTweet = tweetList_->at(firstLine);
	Tweet* lastTweet = tweetList_->at(lastLine);

	cout << "First:" << *firstTweet->getText()<< endl;
	cout << "Last:" << *lastTweet->getText()<< endl;

	for(int i=firstLine;i<=lastLine;i++){
		wxRect rect = GetItemRect(i);
		if(rect.y <= y && y < (rect.y + rect.height)){
			cout << "ここが右クリックされた:" << *tweetList_->at(i)->getText() << endl;
			break;
		}
	}
}
Exemple #2
0
//ツイートを読み込んだとき
void TweetList::onGetTweet(GetTweetEvent& event){
	vector<Tweet*>::iterator begin = tweetList_->begin();

	const vector<Tweet*>& loadedTweets = event.getTweetList();

	set<long> appearedUserIdSet;

	long lastTweetId = -1;

	for(int i= (loadedTweets.size() -1); i >= 0; i--){
		Tweet* tweet = loadedTweets.at(i);
		const User* user = tweet->getUser();
		cout << "(" << i << ")[" << *tweet->getText() << "]" << endl;

		if(appearedUserIdSet.find(user->getId()) == appearedUserIdSet.end()){
			appearedUserIdSet.insert(user->getId());

			wxString fileName = "images/user_icon/" + StringUtil::toStr(tweet->getUser()->getId()) + ".bmp";

			if(!util::FileUtil::exists(fileName)){
				//ユーザアイコンが読み込まれていなかったときは、別スレッドで読み込む
				DownloadUserIconTask* thread = new DownloadUserIconTask(this, user->getId(), user->getProfileImageUrl());
				if(thread->Create() != wxTHREAD_NO_ERROR){
					wxLogError(wxT("Can't create thread!"));
				}

				wxGetApp().add(thread);
				thread->Run();
			}
		}

		tweetList_->insert(tweetList_->begin(), tweet);
		lastTweetId = tweet->getId();
	}

	if(lastTweetId != -1){
		setLastReadTweetId(lastTweetId);
	}

	SetItemCount(tweetList_->size());
	RefreshAll();
}
/*
 * TweetListItemManager::updateItem(ListView* list,
                                      VisualNode* control, const QString& type,
                                      const QVariantList& indexPath,
                                      const QVariant& data)

   Implementation of ListItemManager::updateItem()
   Updates an item in the listview using the data provided
 */
void TweetListItemManager::updateItem(ListView* list,
                                      VisualNode* control, const QString& type,
                                      const QVariantList& indexPath,
                                      const QVariant& data)
{
    Q_UNUSED(list);
    Q_UNUSED(type);
    Q_UNUSED(indexPath);

    QObject* obj = qvariant_cast<QObject*>(data);
    Tweet* tweet = qobject_cast<Tweet*>(obj);
    if (tweet)
    {
        TweetItem* titem = static_cast<TweetItem*>(control);
        if (titem)
        {
            titem->updateItem(tweet->getText(), tweet->getDate());
        }
    }
}
Exemple #4
0
//--------------------------------------------------------------
void storeApp::update() {
	double timestamp = ofGetElapsedTimeMillis();
	while(receiver.hasWaitingMessages() )
	{
		// get the next message
		ofxOscMessage m;
		receiver.getNextMessage( &m );
		
		if ( m.getAddress() == "/test" )
		{
			
		}
		else if ( m.getAddress() == "/tweet" )
		{
			if (m.getNumArgs() >= 2)
			{
				string user = "";
				if (m.getArgType(0) == OFXOSC_TYPE_STRING)
				{
					user = m.getArgAsString(0);
				}
				string text = "";
				if (m.getArgType(1) == OFXOSC_TYPE_STRING)
				{
					text = m.getArgAsString(1);
				}
				
				if (user != "" && text!= "") {
					//ofDrawBitmapString( user + ": " + text, 80, 200 );
					//tweet = user + ": " + text;
					if (tweets->tweets->size() < 100)
					{
						tweets->push(new Tweet(user, text));
					}					
				}
			}
		}
		
	}
	
	if (ofGetElapsedTimeMillis() - timestamp > 10)
		cout << "msg parsed in " << ofGetElapsedTimeMillis() - timestamp << endl;
	
	if (ofGetElapsedTimeMillis() - lastTweetTime > 200)
	{
		if (tweets->tweets->size() > 0)
		{
			float margin = 20;
			Tweet *t = tweets->pop();
			string text = t->getUser() + ": " + t->getText();
			
			
			timestamp = ofGetElapsedTimeMillis();
			Tweet *newTweet = new Tweet(t->getUser(), t->getText());
			newTweet->textBlock.init(&defaultFont, &doubleSizedFont, &superSizedFont);
			newTweet->textBlock.setText(text);
			newTweet->textBlock.wrapTextInWidthHM(ofGetWidth()/6 - margin*2);
			newTweet->textBlock.setColor(255, 255, 255, 255);
			newTweet->bound = ofRectangle(
										  activeColumn * ofGetWidth()/6 + margin,
										  margin,
										  ofGetWidth()/6 - margin * 2,
										  ofGetHeight() - margin * 2
										  );
			newTweet->lastShownTime = ofGetElapsedTimeMillis();
			newTweet->live = true;
			
			tweetsOnShow->push(newTweet);
			//cout << "tweets on show: " << tweetsOnShow->tweets->size() << endl;
			
			tweets->tweets->pop_front();
			activeColumn = (activeColumn+1) % 6;
			
			if (tweetsOnShow->tweets->size() > 6)
			{
				tweetsOnShow->tweets->pop_front();
			}
			
			lastTweetTime = ofGetElapsedTimeMillis();
			
			cout << "new tweet init'd in " << ofGetElapsedTimeMillis() - timestamp << endl;
			
			//cout << tweets->tweets->size();
			//cout << " tweet in queue\n";
		}
		
	}
}