Ejemplo n.º 1
0
void TBButton::OnCaptureChanged(bool captured)
{
	if (captured && m_auto_repeat_click)
		PostMessageDelayed(TBIDC("auto_click"), nullptr, auto_click_first_delay);
	else if (!captured)
	{
		if (TBMessage *msg = GetMessageByID(TBIDC("auto_click")))
			DeleteMessage(msg);
	}
}
Ejemplo n.º 2
0
void TBProgressSpinner::SetValue(int value)
{
	assert(value >= 0); // If this happens, you probably have unballanced Begin/End calls.
	m_value = value;
	if (value > 0)
	{
		// Start animation
		if (!GetMessageByID(TBID(1)))
		{
			m_frame = 0;
			PostMessageDelayed(TBID(1), nullptr, spin_speed);
		}
	}
	else
	{
		// Stop animation
		if (TBMessage *msg = GetMessageByID(TBID(1)))
			DeleteMessage(msg);
	}
}
Ejemplo n.º 3
0
message_node *GetMessageByName(int class_id,char *message_name,class_node **found_class)
{
   int message_id;

   message_id = GetIDByName(message_name);
   if (message_id == INVALID_ID)
   {
      eprintf("GetMessageByName can't find name %s\n",message_name);
      return NULL;
   }
   return GetMessageByID(class_id,message_id,found_class);
}
Ejemplo n.º 4
0
void ResourceEditWindow::UpdateWidgetList(bool immediately)
{
	if (!immediately)
	{
		TBID id = TBIDC("update_widget_list");
		if (!GetMessageByID(id))
			PostMessage(id, nullptr);
	}
	else
	{
		m_widget_list_source.DeleteAllItems();
		AddWidgetListItemsRecursive(m_build_container, 0);

		m_widget_list->InvalidateList();
	}
}
Ejemplo n.º 5
0
BOOL ServerBBS::ReplyMessageByID(UINT nID, CHAR*	szReplyMessage, INT	nReplyLength )
{
__ENTER_FUNCTION
	MessageEntry_t*	pCur = GetMessageByID( nID );
	if(pCur)
	{
		pCur->bHasReply			=	1;
		g_pTimeManager->SetTime();
		pCur->nReHour			=	(BYTE)g_pTimeManager->GetHour();
		pCur->nReMin			=	(BYTE)g_pTimeManager->GetMinute();
		pCur->nReplyMsgLength	=	nReplyLength;
		memcpy(pCur->szReplyMessage, szReplyMessage, nReplyLength);
		IncSerial();//序列号递增
		return	TRUE;
	}
	else
	{
		return	FALSE;
	}
__LEAVE_FUNCTION
	return	FALSE;
}
Ejemplo n.º 6
0
void SetEachClassMessagesPropagate(class_node *c)
{
   int i;

   /* if no superclass, then there is no propagate message */
   if (c->super_ptr == NULL)
      return;

   /* there is a parent, so look for a propagate message */
   for (i=0;i<c->num_messages;i++)
   {
      c->messages[i].propagate_message = 
	 GetMessageByID(c->super_ptr->class_id,c->messages[i].message_id,
			&c->messages[i].propagate_class);
      /*
      if (c->messages[i].propagate_message != NULL)
      {
	 dprintf("%i %i 0x%x\n",c->class_id,c->messages[i].message_id,&c->messages[i].propagate_class);
      }
      */
   }

}
Ejemplo n.º 7
0
void TBScroller::Scroll(float start_speed_ppms_x, float start_speed_ppms_y)
{
	// Set start values
	m_scroll_start_ms = TBSystem::GetTimeMS();
	GetTargetScrollXY(m_scroll_start_scroll_x, m_scroll_start_scroll_y);
	m_scroll_start_speed_ppms_x = start_speed_ppms_x;
	m_scroll_start_speed_ppms_y = start_speed_ppms_y;

	// Calculate duration for the scroll (each axis independently)
	m_scroll_duration_x_ms = m_func.GetDurationFromSpeed(m_scroll_start_speed_ppms_x);
	m_scroll_duration_y_ms = m_func.GetDurationFromSpeed(m_scroll_start_speed_ppms_y);

	if (StopIfAlmostStill())
		return;

	// Post the pan message if we don't already have one
	if (!GetMessageByID(TBIDC("scroll")))
	{
		// Update expected translation
		GetTargetChildTranslation(m_expected_scroll_x, m_expected_scroll_y);

		PostMessageDelayed(TBIDC("scroll"), nullptr, (uint32)PAN_MSG_DELAY_MS);
	}
}
Ejemplo n.º 8
0
void TBEditField::CaretBlinkStop()
{
	// Remove the blink message if we have one
	if (TBMessage *msg = GetMessageByID(TBIDC("blink")))
		DeleteMessage(msg);
}
Ejemplo n.º 9
0
void TBEditField::CaretBlinkStart()
{
	// Post the delayed blink message if we don't already have one
	if (!GetMessageByID(TBIDC("blink")))
		PostMessageDelayed(TBIDC("blink"), nullptr, CARET_BLINK_TIME);
}
Ejemplo n.º 10
0
bool MainWindow::OnEvent(const TBWidgetEvent &ev)
{
	if (ev.type == EVENT_TYPE_CLICK)
	{
		if (ev.target->GetID() == TBIDC("new"))
		{
			new MainWindow();
			return true;
		}
		if (ev.target->GetID() == TBIDC("msg"))
		{
			PostMessage(TBIDC("instantmsg"), nullptr);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("busymsg"))
		{
			if (ev.target->GetValue() == 1)
			{
				// Post the first "busy" message when we check the checkbox.
				assert(!GetMessageByID(TBIDC("busy")));
				if (!GetMessageByID(TBIDC("busy")))
				{
					PostMessage(TBIDC("busy"), nullptr);
					TBMessageWindow *msg_win = new TBMessageWindow(this, TBIDC("test_dialog"));
					msg_win->Show("Message window", "The message loop is now constantly busy with messages to process.\n\n"
								"The main thread should be working hard, but input & animations should still be running smoothly.");
				}
			}
			else
			{
				// Remove any pending "busy" message when we uncheck the checkbox.
				assert(GetMessageByID(TBIDC("busy")));
				if (TBMessage *busymsg = GetMessageByID(TBIDC("busy")))
					DeleteMessage(busymsg);
			}
			return true;
		}
		else if (ev.target->GetID() == TBIDC("delayedmsg"))
		{
			PostMessageDelayed(TBIDC("delayedmsg"), nullptr, 2000);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("TBWindow.close"))
		{
			// Intercept the TBWindow.close message and stop it from bubbling
			// to TBWindow (prevent the window from closing)
			TBMessageWindow *msg_win = new TBMessageWindow(this, TBIDC("confirm_close_dialog"));
			TBMessageWindowSettings settings(TB_MSG_YES_NO, TBIDC("Icon48"));
			settings.dimmer = true;
			settings.styling = true;
			msg_win->Show("Are you sure?", "Really <color #0794f8>close</color> the window?", &settings);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("confirm_close_dialog"))
		{
			if (ev.ref_id == TBIDC("TBMessageWindow.yes"))
				Close();
			return true;
		}
		else if (ev.target->GetID() == TBIDC("reload skin bitmaps"))
		{
			int reload_count = 10;
			double t1 = TBSystem::GetTimeMS();
			for (int i = 0; i < reload_count; i++)
				g_tb_skin->ReloadBitmaps();
			double t2 = TBSystem::GetTimeMS();

			TBStr message;
			message.SetFormatted("Reloading the skin graphics %d times took %dms", reload_count, (int)(t2 - t1));
			TBMessageWindow *msg_win = new TBMessageWindow(ev.target, TBID());
			msg_win->Show("GFX load performance", message);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test context lost"))
		{
			g_renderer->InvokeContextLost();
			g_renderer->InvokeContextRestored();
			TBMessageWindow *msg_win = new TBMessageWindow(ev.target, TBID());
			msg_win->Show("Context lost & restore",
							"Called InvokeContextLost and InvokeContextRestored.\n\n"
							"Does everything look fine?");
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-layout"))
		{
			TBStr resource_file("Demo/demo01/ui_resources/");
			resource_file.Append(ev.target->data.GetString());
			new LayoutWindow(resource_file);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-connections"))
		{
			new ConnectionWindow();
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-list"))
		{
			new AdvancedListWindow(&advanced_source);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-image"))
		{
			new ImageWindow();
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-page"))
		{
			new PageWindow();
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-animations"))
		{
			new AnimationsWindow();
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-scroll-container"))
		{
			new ScrollContainerWindow();
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-skin-conditions"))
		{
			(new DemoWindow())->LoadResourceFile("Demo/demo01/ui_resources/test_skin_conditions01.tb.txt");
			(new DemoWindow())->LoadResourceFile("Demo/demo01/ui_resources/test_skin_conditions02.tb.txt");
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-resource-edit"))
		{
			ResourceEditWindow *res_edit_win = new ResourceEditWindow();
			res_edit_win->Load("Demo/demo01/ui_resources/resource_edit_test.tb.txt");
			GetParent()->AddChild(res_edit_win);
			return true;
		}
		else if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("debug settings"))
		{
#ifdef TB_RUNTIME_DEBUG_INFO
			ShowDebugInfoSettingsWindow(GetParentRoot());
#else
			TBMessageWindow *msg_win = new TBMessageWindow(ev.target, TBID());
			msg_win->Show("Debug settings",
							"Debug settings is only available in builds "
							"compiled with TB_RUNTIME_DEBUG_INFO defined.\n\n"
							"Debug builds enable this by default.");
#endif
			return true;
		}
	}
	return DemoWindow::OnEvent(ev);
}
Ejemplo n.º 11
0
/* returns the return value of the blakod */
int SendBlakodMessage(int object_id,int message_id,int num_parms,parm_node parms[])
{
	object_node *o;
	class_node *c,*propagate_class;
	message_node *m;
	val_type message_ret;
	
	int prev_interpreting_class;
	char *prev_bkod;

	int propagate_depth = 0;

	prev_bkod = bkod;
	prev_interpreting_class = kod_stat.interpreting_class;
	
	o = GetObjectByID(object_id);
	if (o == NULL)
	{
		bprintf("SendBlakodMessage can't find OBJECT %i\n",object_id);
		return NIL;
	}
	
	c = GetClassByID(o->class_id);
	if (c == NULL)
	{
		eprintf("SendBlakodMessage OBJECT %i can't find CLASS %i\n",
			object_id,o->class_id);
		return NIL;
	}
	
	m = GetMessageByID(c->class_id,message_id,&c);
	
	if (m == NULL)
	{
		bprintf("SendBlakodMessage CLASS %s (%i) OBJECT %i can't find a handler for MESSAGE %s (%i)\n",
			c->class_name,c->class_id,object_id,GetNameByID(message_id),message_id);
		return NIL;
	}
	
	m->called_count++;
	
	kod_stat.num_messages++;
	stack[message_depth].class_id = c->class_id;
	stack[message_depth].message_id = m->message_id;
	stack[message_depth].propagate_depth = 0;
	stack[message_depth].num_parms = num_parms;
	memcpy(stack[message_depth].parms,parms,num_parms*sizeof(parm_node));
	stack[message_depth].bkod_ptr = bkod;
	if (message_depth > 0)
		stack[message_depth-1].bkod_ptr = prev_bkod;
	message_depth++;
	if (message_depth > kod_stat.message_depth_highest)
		kod_stat.message_depth_highest = message_depth;
	
	if (message_depth >= MAX_DEPTH)
	{
		bprintf("SendBlakodMessage sending to CLASS %s (%i), depth is %i, aborted!\n",
			c->class_name,c->class_id,message_depth);
		
		kod_stat.interpreting_class = prev_interpreting_class;
		message_depth--;
		bkod = prev_bkod;
		
		return NIL;
	}
	
	if (m->trace_session_id != INVALID_ID)
	{
		trace_session_id = m->trace_session_id;
		m->trace_session_id = INVALID_ID;
	}
	
	if (trace_session_id != INVALID_ID)
		TraceInfo(trace_session_id,c->class_name,m->message_id,num_parms,parms);
	
	kod_stat.interpreting_class = c->class_id;
	
	bkod = m->handler;
	
	propagate_depth = 1;

	while (InterpretAtMessage(object_id,c,m,num_parms,parms,&message_ret) 
		== RETURN_PROPAGATE)
	{
		propagate_class = m->propagate_class;
		m = m->propagate_message;
		
		if (m == NULL)
		{
			bprintf("SendBlakodMessage can't propagate MESSAGE %s (%i) in CLASS %s (%i)\n",
				GetNameByID(message_id),message_id,c->class_name,c->class_id);
			message_depth -= propagate_depth;
			kod_stat.interpreting_class = prev_interpreting_class;
			bkod = prev_bkod;
			return NIL;
		}
		
		if (propagate_class == NULL)
		{
			bprintf("SendBlakodMessage can't find class to propagate to, from "
				"MESSAGE %s (%i) in CLASS %s (%i)\n",GetNameByID(message_id),message_id,c->class_name,c->class_id);
			message_depth -= propagate_depth;
			kod_stat.interpreting_class = prev_interpreting_class;
			bkod = prev_bkod;
			return NIL;
		}
		
		c = propagate_class;
		
		m->called_count++;
		
		if (m->trace_session_id != INVALID_ID)
		{
			trace_session_id = m->trace_session_id;
			m->trace_session_id = INVALID_ID;
		}
		
		if (trace_session_id != INVALID_ID)
			TraceInfo(trace_session_id,"(propagate)",m->message_id,num_parms,parms);
		
		kod_stat.interpreting_class = c->class_id;
		
		stack[message_depth-1].bkod_ptr = bkod;

		stack[message_depth].class_id = c->class_id;
		stack[message_depth].message_id = m->message_id;
		stack[message_depth].propagate_depth = propagate_depth;
		stack[message_depth].num_parms = num_parms;
		memcpy(stack[message_depth].parms,parms,num_parms*sizeof(parm_node));
		stack[message_depth].bkod_ptr = m->handler;
		message_depth++;
		propagate_depth++;

		bkod = m->handler;

	}
	
	message_depth -= propagate_depth;
	kod_stat.interpreting_class = prev_interpreting_class;
	bkod = prev_bkod;
	
	return message_ret.int_val;
}
Ejemplo n.º 12
0
bool TBScroller::IsScrolling()
{
	return GetMessageByID(TBIDC("scroll")) ? true : false;
}