当前位置: 首页>>代码示例>>C++>>正文


C++ BView::Invalidate方法代码示例

本文整理汇总了C++中BView::Invalidate方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::Invalidate方法的具体用法?C++ BView::Invalidate怎么用?C++ BView::Invalidate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BView的用法示例。


在下文中一共展示了BView::Invalidate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BOutlineListView

TestWindow::TestWindow(BApplication* myApp)
	: BWindow(BRect(20,20,100,100),
	  "Code Profile", B_TITLED_WINDOW, 0)
{
	BRect frm = Bounds();

	BView* myview = new BView(BRect(),"testView",0,0);
	
	BOutlineListView* olist =
		new BOutlineListView(BRect(),"MyList",
							B_SINGLE_SELECTION_LIST,B_FOLLOW_NONE);
	if( myview && olist ) {
		myview->AddChild(olist);
		BView* vw = olist;
		vw->SetViewColor(0xc0,0xc0,0xc0);
		vw->Invalidate();
		vw->SetLowColor(0xc0,0xc0,0xc0);
		vw->Invalidate();
		vw->SetHighColor(0x00,0x00,0x00);
		vw->Invalidate();
		vw->SetFont(be_bold_font);
		this->AddChild(myview);
		BRect frm = vw->Frame();
		vw->ResizeTo(1,1);
		vw->Draw(vw->Bounds());
		vw->ResizeToPreferred();
		float w=0,h=0;
		vw->GetPreferredSize(&w,&h);
		printf("Preferred size = %f x %f\n",w,h);
	}
	
	string = new BStringView(BRect(0,0,100,20),"String",
								"Ready to profile...");	
	
	if( string ) {
		string->SetViewColor(0xc0,0xc0,0xc0);
		this->AddChild(string);
		float w=0, h=0;
		string->GetPreferredSize(&w,&h);
		MoveTo(30,30);
		ResizeTo(w,h);
	}
	
	BMenuBar* menu = new BMenuBar(BRect(),"MainMenu",B_FOLLOW_NONE);
	if( menu ) {
		this->AddChild(menu);
		float w=0, h=0;
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
		menu->SetFont(be_plain_font);
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
		menu->SetFont(be_bold_font);
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
		menu->SetFont(be_fixed_font);
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
	}
}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:60,代码来源:Profile.cpp

示例2: FrameMoved

void TScrollViewComponent::FrameMoved(BPoint screenPoint)		
{
	printf("TScrollViewComponent::FrameMoved....\n");
	Invalidate();
	BView *child; 
   	if ( child = ChildAt(0) ) 
   	{
   		child->Invalidate();
   		child->FrameResized(0,0);
		BRect AFrame = this->Frame();
		BRect AFrame2 = child->Frame();
		printf("TScrollViewComponent::FrameMoved Getting ScrollBar\n");
		BScrollBar *truc = this->ScrollBar(B_HORIZONTAL);
		AFrame2 = truc->Frame();
		FPropertyList->SetPropertyValue(PROP_BOTTOM,FloatToStr(AFrame.bottom -2 -((AFrame2.bottom - AFrame2.top))));
		truc = this->ScrollBar(B_VERTICAL);		
		AFrame2 = truc->Frame();
		FPropertyList->SetPropertyValue(PROP_RIGHT,FloatToStr(AFrame.right -2 - ((AFrame2.right-AFrame2.left))));
		FPropertyList->SetPropertyValue(PROP_TOP,FloatToStr(AFrame.top + 2));
		FPropertyList->SetPropertyValue(PROP_LEFT,FloatToStr(AFrame.left + 2));
   	}
   	BScrollView::FrameMoved(screenPoint);
//	FrameMovedComponent(FInternalComponent);
//	FInternalComponent->FrameMovedComponent(FInternalComponent);
}
开发者ID:HaikuArchives,项目名称:BeBuilder,代码行数:25,代码来源:ScrollViewComponent.cpp

示例3: Frame

void
WorkspacesView::_UpdateParentClipping()
{
	if (fParentWhichDrawsOnChildren != NULL) {
		_CleanupParentClipping();
		_ExcludeFromParentClipping();
		fParentWhichDrawsOnChildren->Invalidate(fCurrentFrame);
		fCurrentFrame = Frame();
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:10,代码来源:Workspaces.cpp

示例4: copy_colors

void ArpTextControl::copy_colors(BView* v)
{
	// Make no assumptions about the structure of the children.
	if( !v ) return;
	int32 num = v->CountChildren();
	for( int32 i=0; i<num; i++ ) {
		BView* child = v->ChildAt(i);
		if( child ) {
			copy_colors(child);
			BTextView* text = dynamic_cast<BTextView*>(child);
			if( text ) {
				text->SetFontAndColor(NULL, B_FONT_ALL, &PV_FillForeColor);
			}
			child->SetViewColor(PV_FillBackColor);
			child->SetLowColor(PV_FillBackColor);
			child->SetHighColor(PV_FillForeColor);
			child->Invalidate();
		}
	}
}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:20,代码来源:ViewStubs.cpp

示例5: SnowMakerThread

int32 SnowView::SnowMakerThread(void *p_this)
{
	SnowView *_this = (SnowView *)p_this;
	BView *p = _this->Parent();
	BRect portion(0,0,(_this->fCachedWsWidth/PORTION_GRAN)-1, (_this->fCachedWsHeight/PORTION_GRAN)-1);
	int nf = _this->fNumFlakes;
	BRegion reg(BRect(-1,-1,-1,-1));
	while (p && _this->fAttached) {
		snooze(INTERVAL/(10*(nf?nf:1)));
		int32 cw = _this->fCurrentWorkspace;
		bool drawThisOne = false;
//printf("processing flake %d...\n", current);
		//for (; (current%(fNumFlakes/4); current++)
		if (reg.Intersects(portion)) {
			for (int i = 0; !drawThisOne && i < nf; i++) {
				/* if we find at least one flake in this rect, draw it */
				if ((_this->fFlakes[cw][i].weight) && (
					portion.Intersects(BRect(_this->fFlakes[cw][i].opos - BPoint(4,4), _this->fFlakes[cw][i].opos + BPoint(4,4))) || 
					portion.Intersects(BRect(_this->fFlakes[cw][i].pos - BPoint(4,4), _this->fFlakes[cw][i].pos + BPoint(4,4))))) {
						drawThisOne = true;
				}
			}
		}
		//if (!drawThisOne)
			//printf("!Invalidate(%f, %f, %f, %f)\n", portion.left, portion.top, portion.right, portion.bottom);
		/* avoid deadlock on exit */
		if (drawThisOne && (_this->LockLooperWithTimeout(2000) == B_OK)) {
//			printf("Invalidate(%f, %f, %f, %f)\n", portion.left, portion.top, portion.right, portion.bottom);
			p->Invalidate(portion);
			_this->UnlockLooper();
		}
		portion.OffsetBy(_this->fCachedWsWidth/PORTION_GRAN, 0);
		if (portion.left >= _this->fCachedWsWidth) { /* right wrap */
			//printf("rigth wrap to %ld\n", _this->fCachedWsWidth);
			portion.OffsetTo(0, portion.top+(_this->fCachedWsHeight/PORTION_GRAN));
		}
		if (portion.top >= _this->fCachedWsHeight) {
			portion.OffsetTo(0,0);
			/* avoid deadlock on exit */
			if (_this->LockLooperWithTimeout(5000) == B_OK) {
//printf("calculating flakes...\n");
				_this->Calc();
//printf("done calculating flakes.\n");
				_this->GetClippingRegion(&reg);
				//printf("Region:\n");
				//reg.PrintToStream();
				_this->UnlockLooper();
			}
		}	
	}
#if 0
	BView *p = _this->Parent();
	while (p && _this->fAttached) {
		snooze(INTERVAL/_this->fNumFlakes);
//printf("processing flake %d...\n", current);
		//for (; (current%(fNumFlakes/4); current++)
		/* avoid deadlock on exit */
		if (_this->LockLooperWithTimeout(2000) == B_OK) {
			if (_this->fFlakes[_this->fCurrentWorkspace][current].weight) {
				p->Invalidate(BRect(_this->fFlakes[_this->fCurrentWorkspace][current].opos - BPoint(4,4),
									_this->fFlakes[_this->fCurrentWorkspace][current].opos + BPoint(4,4)));
				p->Invalidate(BRect(_this->fFlakes[_this->fCurrentWorkspace][current].pos - BPoint(4,4),
									_this->fFlakes[_this->fCurrentWorkspace][current].pos + BPoint(4,4)));
			}
			_this->UnlockLooper();
			current++;
			current %= _this->fNumFlakes;
			if (!current) {
				/* avoid deadlock on exit */
				if (_this->LockLooperWithTimeout(2000) == B_OK) {
printf("calculating flakes...\n");
					_this->Calc();
printf("done calculating flakes.\n");
					_this->UnlockLooper();
				}
			}	
		}
	}
#endif
	return B_OK;
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:81,代码来源:SnowView.cpp

示例6: r

void
EBePrivateWin::DispatchMessage(BMessage *bMsg, BHandler *handler)
{
	bool handled = true;

	if(bMsg->what == 'etk_')
	{
		int32 what = 0;
		bMsg->FindInt32("etk:what", &what);

		switch(what)
		{
			case ETK_BEOS_QUIT:
				doQuit = true;
				PostMessage(B_QUIT_REQUESTED);
				break;

			case ETK_BEOS_CONTACT_TO:
				{
					fContactor = EMessenger();
					const char *buffer = NULL;
					ssize_t size = -1;
					if(bMsg->FindData("etk:messenger", B_ANY_TYPE, (const void**)&buffer, &size) != B_OK) break;
					if(buffer == NULL || size <= 0) break;
					fContactor.Unflatten(buffer, (size_t)size);
				}
				break;

			case ETK_BEOS_SET_BACKGROUND:
				{
					rgb_color bkColor;
					if(bMsg->FindInt32("background", (int32*)&bkColor) != B_OK) break;
					fTopView->SetViewColor(bkColor);
					fTopView->Invalidate();
				}
				break;

			case ETK_BEOS_SET_LOOK:
				{
					int8 look;
					if(bMsg->FindInt8("look", &look) != B_OK) break;
					switch((e_window_look)look)
					{
						case E_BORDERED_WINDOW_LOOK:
							SetLook(B_BORDERED_WINDOW_LOOK);
							break;

						case E_NO_BORDER_WINDOW_LOOK:
							SetLook(B_NO_BORDER_WINDOW_LOOK);
							break;

						case E_TITLED_WINDOW_LOOK:
							SetLook(B_TITLED_WINDOW_LOOK);
							break;

						case E_DOCUMENT_WINDOW_LOOK:
							SetLook(B_DOCUMENT_WINDOW_LOOK);
							break;

						case E_MODAL_WINDOW_LOOK:
							SetLook(B_MODAL_WINDOW_LOOK);
							break;

						case E_FLOATING_WINDOW_LOOK:
							SetLook(B_FLOATING_WINDOW_LOOK);
							break;

						default:
							break;
					}
				}
				break;

			case ETK_BEOS_SET_TITLE:
				{
					const char *title = NULL;
					if(bMsg->FindString("title", &title) != B_OK) break;
					SetTitle(title);
				}
				break;

			case ETK_BEOS_SET_WORKSPACES:
				{
					uint32 workspaces = 0;
					if(bMsg->FindInt32("workspaces", (int32*)&workspaces) != B_OK) break;
					if(workspaces == 0) workspaces = current_workspace() + 1;
					SetWorkspaces(workspaces);
				}
				break;

			case ETK_BEOS_GET_WORKSPACES:
				{
					uint32 workspaces = Workspaces();
					bMsg->AddInt32("workspaces", *((int32*)&workspaces));
				}
				break;

			case ETK_BEOS_ICONIFY:
				if(!IsMinimized()) Minimize(true);
				break;
//.........这里部分代码省略.........
开发者ID:D-os,项目名称:EasyToolkitAndExtension,代码行数:101,代码来源:etk-window.cpp

示例7: MessageReceived


//.........这里部分代码省略.........
					BTextControl *textControl = dynamic_cast<BTextControl*>(changedView);
					preferences.ReplaceString(prefsID.String(), textControl->Text());
				}
				else if (is_instance_of(changedView, BCheckBox))
				{
					//a checkbox value was changed, update preferences with new bool value(on/off)
					BCheckBox *checkBox = dynamic_cast<BCheckBox*>(changedView);
					preferences.ReplaceBool(prefsID.String(), checkBox->Value());
				}
				else if (is_instance_of(changedView, BSlider))
				{
					//a slider value was changed, update preferences with new slider value
					BSlider *slider = dynamic_cast<BSlider*>(changedView);
					preferences.ReplaceInt32(prefsID.String(), slider->Value());
				}
				else if (is_instance_of(changedView, ColourButton))
				{
					//a colourcontrol value was changed, update preferences with new colour
					ColourButton *colourControl = dynamic_cast<ColourButton*>(changedView);
					preferences.ReplaceData(prefsID.String(),B_RGB_COLOR_TYPE, &colourControl->Value(), sizeof(rgb_color));
				}
				prefsLock.Unlock();
			}
		}
		break;
		case PrefsConstants::K_LOAD_PREFERENCES:
		{
			//set preferences view values to values of the preferences message
			BString prefsID;
			if (message->FindString(K_PREFS_ID, &prefsID) == B_OK)
			{
				//find out which view value has to be updated
				BView *changedView = m_parent->FindView(prefsID.String());
				prefsLock.Lock();
				char *name;
				uint32 type;
				int32 count;
				for (int32 i = 0; preferences.GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i++)
				{
					//find out what kind of field we are using
					switch (type)
					{
						case B_INT32_TYPE:
						{
							int32 value;
							preferences.FindInt32(name, &value);
							if (is_instance_of(changedView, BSlider))
							{
								BSlider *slider = dynamic_cast<BSlider*>(changedView);
								slider->SetValue(value);
							}
						}
						break;
						case B_BOOL_TYPE:
						{
							bool value;
							preferences.FindBool(name, &value);
							if (is_instance_of(changedView, BCheckBox))
							{
								BCheckBox *checkBox = dynamic_cast<BCheckBox*>(changedView);
								checkBox->SetValue(value);
							}
						}
						break;
						case B_RGB_COLOR_TYPE:
						{
							rgb_color *colour;
							ssize_t size;
							preferences.FindData(name, B_RGB_COLOR_TYPE, (const void**)&colour, &size);
							if (is_instance_of(changedView, ColourButton))
							{
								ColourButton *colourControl = dynamic_cast<ColourButton*>(changedView);
								colourControl->SetValue(*colour);
							}
						}
						break;
						case B_STRING_TYPE:
						{
							BString string;
							preferences.FindString(name, &string);
							if (is_instance_of(changedView, ColourButton))
							{
								BTextControl *textControl = dynamic_cast<BTextControl*>(changedView);
								textControl->SetText(string.String());
							}
						}
						break;
					}
				} 				
				prefsLock.Unlock();
				//make sure the new view values are drawn!
				changedView->Invalidate();
			}
		}
		break;
		default:
			BWindow::MessageReceived(message);
		break;
	}
}
开发者ID:HaikuArchives,项目名称:BeTeX,代码行数:101,代码来源:PrefsWindow.cpp


注:本文中的BView::Invalidate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。