Esempio n. 1
0
bool UIListbox::MouseHandler(float x, float y) {
	UIPos pos = GetParentPos();
	
	if (items.size() > view_count) {
		//UP BOX
		UIRect up = UIRect( upbox.x + pos.x, upbox.y +pos.y, upbox.w, upbox.h);
		if (up.Intersects(x,y)) {
			//if first click, register it as a click
			if (!mouse_active) {
				mouse_active = true;
				ChangeView(-1);
				
			}
			return true;
		}
		
		//down
		UIRect down = UIRect( downbox.x + pos.x, downbox.y +pos.y, downbox.w, downbox.h);
		if (down.Intersects(x,y)) {
			//if first click, register it as a click
			if (!mouse_active) {
				mouse_active = true;
				ChangeView(1);
				
			}
			return true;
		}
	}
	//Check for selected
	UIRect temp  = UIRect(  pos.x, pos.y, rect.w, rect.h);
	
	if (temp.Intersects(x,y)) {
		//if first click, register it as a click
		if (!mouse_active) {
			mouse_active = true;
			gMouse = this;
			
			float new_y = y -temp.y;
			int old_selected_index = selected_index;
			for (int i = 0; i < view_count; ++i) {
				if (new_y <= item_height * (i +1)) {
					selected_index = view_pos + i;
					break;
				}
			}
			
			//Check to make sure our list box is populated that much
			if (items.size() -1 < selected_index) {
				selected_index = old_selected_index;
			}

		}
		return true;
	}
	
	
	return false;
}
Esempio n. 2
0
void UIWindow::DoLayout() {
	if (mp_root_control) {
		RECT rect;
		::GetClientRect(hwnd_, &rect);
		mp_root_control->DoLayout(UIRect(rect));
	}
}
Esempio n. 3
0
void WorldUIView::drawSurface(){	
	//Utils::LOG("DRAW SURFACE");
	int wXStart = (xOffset-rect.width/2)/sbSize;
	int wYStart = (yOffset-rect.height/2)/sbSize;
	int wWidth = rect.width/sbSize+3;
	int wHeight = rect.height/sbSize+3;
	COORDS crd(0, 0);

	for(int i = wXStart; i < wXStart+wWidth; i++) {
		for(int j = wYStart; j < wYStart+wHeight; j++){
			crd.x = i;
			crd.y = j;
			worldMutex.lock();
			shared_ptr<SurfaceBlock> sb = client->world->getSurfaceBlockByCoords(crd);
			worldMutex.unlock();

			if(sb != NULL){
				int wX = sb->getCoords().x;
				int wY = sb->getCoords().y;	

				UIRect sbRect = UIRect(
					rect.x + rect.width/2 + wX*sbSize - sbSize/2 - xOffset,
					rect.y + rect.height/2 + wY*sbSize - sbSize/2 - yOffset,
					sbSize,
					sbSize
					);

				sb->draw(sbRect);				
			}
		}
	}
}
Esempio n. 4
0
UITextbox::UITextbox(UIWidget *ptr) {
	AddParent(ptr);
	BaseInit();
	height = 19;
	char_height = 13;
	char_width = 8;
	padding = 4.0f;
	SetBounds(UIRect(10,10,100,0));
	SetBgColor(kNone, UIColor(180,180,180,255));

}
Esempio n. 5
0
void WorldUIView::drawObjects(){	
	shared_ptr<World> world = client->world;
	for(vector<shared_ptr<WorldObject>>::iterator it = world->objects.begin(); it != world->objects.end(); it++){
		shared_ptr<WorldObject> wo = *it;
		COORDS crd = wo->getSurfaceBlock()->getCoords();
		UIRect woRect = UIRect(
			rect.x + rect.width/2 + crd.x*sbSize - sbSize/2 - xOffset,
			rect.y + rect.height/2 + crd.y*sbSize - sbSize/2 - yOffset,
			sbSize,
			sbSize
			);
		wo->draw(woRect);
	}
}
Esempio n. 6
0
bool UITextbox::MouseHandler(float x,float y) {
	UIPos pos = GetParentPos();
	UIRect temp = UIRect( pos.x, pos.y, rect.w, rect.h);
	if ( temp.Intersects(x,y) ||  mouse_active ){
		
		//if first click, register it as a click
		if (!mouse_active) {
			mouse_active = true;
			gCarot = this;
		}
		return true;
	}
	
	
	return false;
}
Esempio n. 7
0
// Process WM_PAINT message
void UIWindow::HandleWMPaintMessage() {
	if (mb_resize_needed) {
		DoLayout(); // 计算控件布局
		mb_resize_needed = FALSE;
	}
	PAINTSTRUCT ps;
	HDC hdc = ::BeginPaint(hwnd_, &ps);
	{
		RECT rect;
		::GetClientRect(hwnd_, &rect);
		// Create GDI render engine based on hdc and client rect
		UIGDIRenderEngine engine(hdc, rect.right - rect.left, rect.bottom - rect.top);
		SetCurrentRenderEngine(&engine); 
		Render(UIRect(rect));
		// Dispose render engine
		SetCurrentRenderEngine(NULL);
	}
	::EndPaint(hwnd_, &ps);
}
Esempio n. 8
0
UIListbox::UIListbox(UIWidget *ptr) {
	AddParent(ptr);
	BaseInit();
	char_width = 8;
	char_height = 13;
	SetViewCount(3);
	SetBounds(UIRect(10,10,100,100));
	item_height = 15;
	selected_text = UIColor(0,0,0);
	selected_bg = UIColor(100,142,208);
	SetBgColor(kNone, UIColor(39,39,39));
	SetFontColor(kNone, UIColor(253,253,253));
	button_color = UIColor(159,159,159);
	view_pos = 0;
	selected_index = 0;
	tri_offsetx = 4;
	tri_offsety = 3;
	tri_length = 8;
	chat_mode = false;
	max_lines = 100;
	
	//icon = new UIImage(NULL);
}