本文整理汇总了C++中Queue_Get函数的典型用法代码示例。如果您正苦于以下问题:C++ Queue_Get函数的具体用法?C++ Queue_Get怎么用?C++ Queue_Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Queue_Get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GraphLayer_Sort
LCUI_API int GraphLayer_Sort( LCUI_GraphLayer *glayer )
{
LCUI_GraphLayer *child_a, *child_b;
int i, j, total;
if( !glayer ) {
return -1;
}
/* 排序前先锁上队列互斥锁 */
Queue_Lock( &glayer->child );
total = Queue_GetTotal( &glayer->child );
/* 使用的是冒泡排序法 */
for(j=0; j<total; ++j)
for(i=total-1; i>=1; --i) {
child_a = (LCUI_GraphLayer*)Queue_Get( &glayer->child, i );
if( !child_a ) {
continue;
}
child_b = (LCUI_GraphLayer*)Queue_Get( &glayer->child, i-1 );
if( !child_b ) {
continue;
}
if( child_a->z_index > child_b->z_index ) {
Queue_Move( &glayer->child, i-1, i);
}
}
/* 解开互斥锁 */
Queue_Unlock( &glayer->child );
return 0;
}
示例2: TextLayer_Get_Char_PixelPos
LCUI_Pos
TextLayer_Get_Char_PixelPos( LCUI_TextLayer *layer, LCUI_Pos char_pos )
/* 获取显示出来的文字相对于文本图层的坐标,单位为像素 */
{
LCUI_Pos pixel_pos;
Text_RowData *row_ptr;
LCUI_CharData *char_ptr;
int rows, cols, total;
pixel_pos.x = pixel_pos.y = 0;
char_pos = TextLayer_Get_Cursor_Pos( layer );
total = Queue_Get_Total( &layer->rows_data );
if( char_pos.y >= total ) {
char_pos.y = total-1;
}
if( char_pos.y < 0 ) {
char_pos.y = 0;
}
/* 累加pos.y行之前几行的高度 */
for( pixel_pos.y=0,rows=0; rows<char_pos.y; ++rows ) {
row_ptr = Queue_Get( &layer->rows_data, rows );
if( !row_ptr ) {
continue;
}
pixel_pos.y += row_ptr->max_size.h;
}
/* 获取当前行的指针 */
row_ptr = Queue_Get( &layer->rows_data, rows );
if( !row_ptr ) {
pixel_pos.y += 2;
return pixel_pos;
}
/* 获取当前行的文字数 */
total = Queue_Get_Total( &row_ptr->string );
if( char_pos.x > total ) {
char_pos.x = total;
}
if( char_pos.x < 0 ) {
char_pos.x = 0;
}
/* 累计宽度 */
for( pixel_pos.x=0,cols=0; cols<char_pos.x; ++cols ) {
char_ptr = Queue_Get( &row_ptr->string, cols );
if( !char_ptr ) {
continue;
}
/* 如果设定了屏蔽字符 */
if( layer->password_char.char_code > 0 ) {
pixel_pos.x += layer->password_char.bitmap.advance.x;
} else {
pixel_pos.x += char_ptr->bitmap.advance.x;
}
}
/* 微调位置 */
pixel_pos.y += 2;
return pixel_pos;
}
示例3: Cancel_Focus
BOOL
Cancel_Focus( LCUI_Widget *widget )
/*
* 功能:取消指定部件的焦点
* 说明:该部件会得到EVENT_FOCUS_OUT事件,并且,会将焦点转移至其它部件
* */
{
if( !widget || !widget->focus ) {
return FALSE;
}
int i, total, focus_pos;
LCUI_Widget *other_widget, **focus_widget;
LCUI_Queue *queue_ptr;
if( widget->parent ) {
focus_widget = &widget->parent->focus_widget;
queue_ptr = &widget->parent->child;
} else {
focus_widget = &LCUI_Sys.focus_widget;
queue_ptr = &LCUI_Sys.widget_list;
}
/* 寻找可获得焦点的其它部件 */
total = Queue_Get_Total( queue_ptr );
focus_pos = WidgetQueue_Get_Pos( queue_ptr, *focus_widget );
for( i=0; i<focus_pos; ++i ) {
other_widget = Queue_Get( queue_ptr, i);
if( other_widget && other_widget->visible
&& other_widget->focus ) {
Handle_Event( &widget->event, EVENT_FOCUS_IN );
*focus_widget = other_widget;
break;
}
}
if( i < focus_pos ) {
return TRUE;
}
/* 排在该部件前面的符合条件的部件没找到,就找排在该部件后面的 */
for( i=focus_pos+1; i<total; ++i ) {
other_widget = Queue_Get( queue_ptr, i);
if( other_widget && other_widget->visible
&& other_widget->focus ) {
Handle_Event( &widget->event, EVENT_FOCUS_IN );
*focus_widget = other_widget;
break;
}
}
/* 没找到就复位焦点 */
if( i >= total ) {
*focus_widget = NULL;
}
return TRUE;
}
示例4: Widget_CancelFocus
/**
* 功能:取消指定部件的焦点
* 说明:该部件会得到EVENT_FOCUSOUT事件,并且,会将焦点转移至其它部件
* */
LCUI_API LCUI_BOOL Widget_CancelFocus( LCUI_Widget *widget )
{
int i, total, focus_pos;
LCUI_Widget *other_widget, **focus_widget;
LCUI_Queue *queue_ptr;
LCUI_WidgetEvent event;
if( !widget || !widget->focus ) {
return FALSE;
}
focus_widget = &RootWidget_GetSelf()->focus_widget;
queue_ptr = Widget_GetChildList( widget->parent );
/* 如果该部件并没获得焦点 */
if( *focus_widget != widget ) {
return FALSE;
}
event.type = EVENT_FOCUSOUT;
Widget_DispatchEvent( widget, &event );
/* 寻找可获得焦点的其它部件 */
total = Queue_GetTotal( queue_ptr );
focus_pos = WidgetQueue_FindPos( queue_ptr, *focus_widget );
for( i=0; i<focus_pos; ++i ) {
other_widget = (LCUI_Widget*)Queue_Get( queue_ptr, i);
if( other_widget && other_widget->visible
&& other_widget->focus ) {
event.type = EVENT_FOCUSIN;
Widget_DispatchEvent( widget, &event );
*focus_widget = other_widget;
break;
}
}
if( i < focus_pos ) {
return TRUE;
}
/* 排在该部件前面的符合条件的部件没找到,就找排在该部件后面的 */
for( i=focus_pos+1; i<total; ++i ) {
other_widget = (LCUI_Widget*)Queue_Get( queue_ptr, i);
if( other_widget && other_widget->visible
&& other_widget->focus ) {
event.type = EVENT_FOCUSIN;
Widget_DispatchEvent( other_widget, &event );
*focus_widget = other_widget;
break;
}
}
/* 没找到就复位焦点 */
if( i >= total ) {
*focus_widget = NULL;
}
return TRUE;
}
示例5: TextLayer_Update_RowSize
static void
TextLayer_Update_RowSize (LCUI_TextLayer *layer, int row )
/* 更新指定行文本位图的尺寸 */
{
int total, i;
LCUI_Size size;
LCUI_CharData *char_data;
Text_RowData *row_data;
LCUI_TextStyle *style;
row_data = Queue_Get( &layer->rows_data, row );
total = Queue_Get_Total( &row_data->string );
style = TextLayer_Get_Current_TextStyle( layer );
if(style == NULL) {
if(layer->default_data.pixel_size > 0) {
size = Size(0, layer->default_data.pixel_size+2);
} else {
size = Size(0, 14);
}
} else {
if(style->pixel_size > 0) {
size = Size(0,style->pixel_size+2);
} else {
size = Size(0,14);
}
}
free( style );
for( i=0; i<total; ++i ) {
char_data = Queue_Get( &row_data->string, i );
size.w += char_data->bitmap.width;
size.w += char_data->bitmap.left;
//height = char_data->bitmap.top;
if( char_data->data != NULL ) {
if( char_data->data->pixel_size != -1 ) {
if( size.h < char_data->data->pixel_size + 2) {
size.h = char_data->data->pixel_size + 2;
}
} else {
if( size.h < 14) {
size.h = 14;
}
}
} else {
if( size.h < 14) {
size.h = 14;
}
}
}
row_data->max_size = size;
}
示例6: TextLayer_Text_GenerateBMP
void
TextLayer_Text_GenerateBMP( LCUI_TextLayer *layer )
/* 为文本图层中的文本生成位图,已存在位图的文字将不重新生成 */
{
BOOL refresh = FALSE;
LCUI_Pos pos;
int i, j, len, rows;
Text_RowData *row_ptr;
LCUI_CharData *char_ptr;
DEBUG_MSG1("enter\n");
DEBUG_MSG1("thread: %lu\n", thread_self());
rows = Queue_Get_Total( &layer->rows_data );
for( pos.y=0,j=0; j<rows; ++j ) {
row_ptr = Queue_Get( &layer->rows_data, j );
len = Queue_Get_Total( &row_ptr->string );
DEBUG_MSG1("row %d, len: %d\n", j, len);
for( pos.x=0,i=0; i<len; ++i) {
char_ptr = Queue_Get( &row_ptr->string, i );
DEBUG_MSG1("generate FontBMP, get char_ptr: %p, char: %c\n",
char_ptr, char_ptr->char_code );
if( !char_ptr || !char_ptr->display ) {
DEBUG_MSG1("no display\n");
continue;
}
if( FontBMP_Valid( &char_ptr->bitmap ) ) {
DEBUG_MSG1("have FontBMP\n");
if( !refresh ) {
pos.x += char_ptr->bitmap.advance.x;
continue;
}
} else {
refresh = TRUE;
DEBUG_MSG1( "generate FontBMP, char code: %d\n", char_ptr->char_code );
TextLayer_Get_Char_BMP ( &layer->default_data, char_ptr );
}
DEBUG_MSG1( "char_data->bitmap.advance.x: %d\n", char_ptr->bitmap.advance.x );
TextLayer_Clear( layer, pos, row_ptr->max_size.h, char_ptr );
char_ptr->need_update = TRUE;
pos.x += char_ptr->bitmap.advance.x;
}
refresh = FALSE;
/* 更新当前行的尺寸 */
TextLayer_Update_RowSize( layer, j );
DEBUG_MSG1("row size: %d,%d\n", row_ptr->max_size.w, row_ptr->max_size.h);
pos.y += row_ptr->max_size.h;
}
DEBUG_MSG1("quit\n");
}
示例7: LCUIApp_RunTask
static int
LCUIApp_RunTask( LCUI_App *app )
{
LCUI_Task *task;
Queue_Lock( &app->tasks );
task = Queue_Get( &app->tasks, 0 );
if( task == NULL ) {
Queue_Unlock( &app->tasks );
return -1;
}
Queue_DeletePointer( &app->tasks, 0 );
if( task->func == NULL ) {
Queue_Unlock( &app->tasks );
return -2;
}
Queue_Unlock( &app->tasks );
/* 调用函数指针指向的函数,并传递参数 */
task->func( task->arg[0], task->arg[1] );
/* 若需要在调用回调函数后销毁参数 */
if( task->destroy_arg[0] ) {
free( task->arg[0] );
}
if( task->destroy_arg[1] ) {
free( task->arg[1] );
}
free( task );
return 0;
}
示例8: LCUIAppList_Delete
/* 从程序列表中删除一个LCUI程序信息 */
static int LCUIAppList_Delete( LCUI_ID app_id )
{
int pos = -1;
LCUI_App *app;
int i, total;
total = Queue_GetTotal(&LCUI_Sys.app_list);
/* 如果程序总数大于0,查找程序信息所在队列的位置 */
if (total > 0) {
for (i = 0; i < total; ++i) {
app = Queue_Get(&LCUI_Sys.app_list, i);
if(app->id == app_id) {
pos = i;
break;
}
}
if(pos < 0) {
return -1;
}
} else {
return -1;
}
/* 从程序显示顺序队列中删除这个程序ID */
Queue_Delete (&LCUI_Sys.app_list, pos);
return 0;
}
示例9: proc_dev_list
/** 处理列表中的设备的数据 */
static void proc_dev_list( void *arg )
{
LCUI_Queue *dev_list;
dev_func_data *data_ptr;
int total, i, timeout_count = 0;
dev_list = (LCUI_Queue *)arg;
while( LCUI_Active() ) {
Queue_Lock( dev_list );
total = Queue_GetTotal( dev_list );
for(i=0; i<total; ++i) {
data_ptr = (dev_func_data*)Queue_Get( dev_list, i );
if( !data_ptr || !data_ptr->proc_func ) {
continue;
}
if( data_ptr->proc_func() ) {
++timeout_count;
}
}
Queue_Unlock( dev_list );
if( timeout_count > 20 ) {
LCUI_MSleep( 10 );
timeout_count = 0;
}
LCUI_MSleep( 5 );
}
LCUIThread_Exit(NULL);
}
示例10: Handle_Widget_KeyboardEvent
int
Handle_Widget_KeyboardEvent( LCUI_Widget *widget, LCUI_Key key )
{
if( !widget ) {
return -1;
}
LCUI_Key *key_data;
LCUI_Event *event;
LCUI_Func *func;
int total, i;
event = Find_Event( &widget->event, EVENT_KEYBOARD );
if( !event ) {
return -2;
}
total = Queue_Get_Total( &event->func_data );
if( total <= 0 ) {
return 1;
}
key_data = (LCUI_Key*)malloc( sizeof(LCUI_Key) );
memcpy( key_data, &key, sizeof(LCUI_Key) );
for (i = 0; i < total; ++i) {
func = Queue_Get( &event->func_data, i );
/* 为第二个参数分配了内存,需要在调用完回调函数后销毁它 */
func->arg[1] = key_data;
func->destroy_arg[1] = TRUE;
/* 添加至程序的任务队列 */
AppTask_Custom_Add( ADD_MODE_ADD_NEW, func );
}
return 0;
}
示例11: WidgetMsg_AddToTask
LCUI_API int WidgetMsg_AddToTask( LCUI_Widget *widget, WidgetMsgData *data_ptr )
{
int i,n;
LCUI_Queue *msg_func;
LCUI_Task *task_ptr, task;
/* LCUI系统消息不能作为任务让程序在主循环里处理 */
if( data_ptr->msg_id < WIDGET_USER ) {
return -1;
}
msg_func = Widget_GetMsgFunc( widget );
if( msg_func == NULL ) {
return -2;
}
n = Queue_GetTotal( msg_func );
for(i=0; i<n; ++i) {
task_ptr = (LCUI_Task*)Queue_Get( msg_func, i );
if( task_ptr == NULL ) {
continue;
}
if( task_ptr->id != data_ptr->msg_id ) {
continue;
}
task.id = widget->app_id;
task.func = task_ptr->func;
task.arg[0] = widget;
task.arg[1] = data_ptr->data.ptr;
task.destroy_arg[0] = FALSE;
task.destroy_arg[1] = data_ptr->need_free;
AppTasks_Add( &task );
}
return 0;
}
示例12: WidgetMsg_Connect
LCUI_API int WidgetMsg_Connect( LCUI_Widget *widget,
uint_t msg_id,
WidgetProcFunc func )
{
int i,n;
LCUI_Queue *msg_func;
LCUI_Task *task_ptr, task;
msg_func = Widget_GetMsgFunc( widget );
if( msg_func == NULL ) {
return -1;
}
n = Queue_GetTotal( msg_func );
for(i=0; i<n; ++i) {
task_ptr = (LCUI_Task*)Queue_Get( msg_func, i );
if( task_ptr == NULL ) {
continue;
}
if( task_ptr->id != msg_id ) {
continue;
}
task_ptr->func = (CallBackFunc)func;
return 0;
}
task.id = msg_id;
task.func = (CallBackFunc)func;
return Queue_Add( msg_func, &task );
}
示例13: GraphLayer_PrintChildList
LCUI_API int GraphLayer_PrintChildList( LCUI_GraphLayer *glayer )
{
int i, n;
LCUI_Queue *child_list;
LCUI_GraphLayer *child;
if( glayer == NULL ) {
return -1;
}
child_list = &glayer->child;
if(child_list == NULL) {
return -1;
}
n = Queue_GetTotal( child_list );
_DEBUG_MSG("total glayer: %d\n", n);
for(i=0; i<n; ++i) {
child = (LCUI_GraphLayer*)Queue_Get( child_list, i );
if( child == NULL ) {
continue;
}
printf("[%d] glayer: %p, z-index: %d, pos: (%d,%d), size: (%d, %d)\n",
i, child, child->z_index, child->pos.x, child->pos.y,
child->graph.w, child->graph.h );
}
return 0;
}
示例14: GraphLayer_DeleteChild
LCUI_API int GraphLayer_DeleteChild( LCUI_GraphLayer *child_glayer )
{
int i, total;
LCUI_Queue *child_list;
LCUI_GraphLayer *tmp_glayer;
if( !child_glayer ) {
return -1;
}
if( !child_glayer->parent ) {
return 0;
}
/* 引用父图层的子图层列表 */
child_list = &child_glayer->parent->child;
total = Queue_GetTotal( child_list );
/* 查找子图层记录 */
for( i=0; i<total; ++i ) {
tmp_glayer = (LCUI_GraphLayer*)Queue_Get( child_list, i );
/* 若找到则删除该子图层记录 */
if( tmp_glayer == child_glayer ) {
Queue_DeletePointer( child_list, i );
child_glayer->parent = NULL;
return 0;
}
}
child_glayer->parent = NULL;
return 0;
}
示例15: GraphLayer_AddChild
LCUI_API int GraphLayer_AddChild( LCUI_GraphLayer *des_ctnr,
LCUI_GraphLayer *glayer )
{
int i, total;
LCUI_GraphLayer *tmp_child;
//_DEBUG_MSG( "des_ctnr: %p, glayer: %p\n", des_ctnr, glayer );
/* 容器图层必须有效 */
if( !des_ctnr ) {
return -1;
}
/* 子图层必须有效,并且不能有父图层 */
if( !glayer || glayer->parent ) {
//_DEBUG_MSG( "!glayer || glayer->parent\n" );
return -2;
}
/* 根据队列中的z值,将子图层存放在队列中适当的位置 */
total = Queue_GetTotal( &des_ctnr->child );
for( i=0; i<total; ++i ) {
tmp_child = (LCUI_GraphLayer*)Queue_Get( &des_ctnr->child, i );
/* 如果比当前位置的图层的z值小,那就对比下一个位置的图层 */
if( glayer->z_index < tmp_child->z_index ) {
continue;
}
/* 将新图层插入至该位置 */
Queue_InsertPointer( &des_ctnr->child, i, glayer );
break;
}
/* 如果没找到位置,则直接添加至末尾 */
if( i >= total ) {
Queue_AddPointer( &des_ctnr->child, glayer );
}
glayer->parent = des_ctnr;
return 0;
}