コード例 #1
0
ファイル: LCUI_Work.c プロジェクト: soar-penguin/LCUI
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;
}
コード例 #2
0
ファイル: LCUI_Work.c プロジェクト: soar-penguin/LCUI
static void 
_End_DragEvent( LCUI_Widget *widget, LCUI_MouseEvent *event )
{
	drag_event.cursor_pos = event->global_pos;
	drag_event.new_pos = Pos_Sub( event->global_pos, __offset_pos );
	drag_event.first_click = 0;
	drag_event.end_click = 1;
	Handle_Event( &widget->event, EVENT_DRAG );
}
コード例 #3
0
ファイル: LCUI_Work.c プロジェクト: soar-penguin/LCUI
static void 
_Start_DragEvent( LCUI_Widget *widget, LCUI_MouseEvent *event )
{
	drag_event.cursor_pos = event->global_pos;
	/* 用全局坐标减去部件的全局坐标,得到偏移坐标 */ 
	__offset_pos = Pos_Sub( event->global_pos, Get_Widget_Global_Pos( widget ) );
	/* 得出部件的新全局坐标 */
	drag_event.new_pos = Pos_Sub( event->global_pos, __offset_pos );
	drag_event.first_click = 1;
	drag_event.end_click = 0;
	/* 处理部件的拖动事件 */
	Handle_Event( &widget->event, EVENT_DRAG );
}
コード例 #4
0
ファイル: LCUI_Work.c プロジェクト: soar-penguin/LCUI
BOOL 
Set_Focus( LCUI_Widget *widget )
/* 
 * 功能:为部件设置焦点
 * 说明:上个获得焦点的部件会得到EVENT_FOCUS_OUT事件,而当前获得焦点的部件会得到
 * EVENT_FOCUS_IN事件。
 * */
{
	if( widget ) {
		/* 先处理上级部件的焦点 */
		if( widget->parent ) {
			Set_Focus( widget->parent );
		}
		if( !widget->focus ) {
			return FALSE;
		}
	} else {
		return FALSE;
	}
	
	LCUI_Widget **focus_widget;
	
	if( widget->parent ) {
		focus_widget = &widget->parent->focus_widget;
	} else {
		focus_widget = &LCUI_Sys.focus_widget; 
	}
	if( *focus_widget ) {
		/* 如果上次和这次的部件不一样 */
		if( *focus_widget != widget ) {
			Handle_Event( &(*focus_widget)->event, EVENT_FOCUS_OUT );
		}
	}
	Handle_Event( &widget->event, EVENT_FOCUS_IN );
	/* 保存新焦点位置 */
	*focus_widget = widget;
	return TRUE;
}
コード例 #5
0
ファイル: LCUI_Work.c プロジェクト: soar-penguin/LCUI
BOOL
Reset_Focus( LCUI_Widget* widget )
/* 复位指定部件内的子部件的焦点 */
{	
	LCUI_Widget** focus_widget;
	
	if( widget ) {
		focus_widget = &widget->focus_widget; 
	} else {
		focus_widget = &LCUI_Sys.focus_widget; 
	}
	if( *focus_widget ) {
		Handle_Event( &(*focus_widget)->event, EVENT_FOCUS_OUT );
	}
	
	*focus_widget = NULL;
	return TRUE;
}
コード例 #6
0
ファイル: LCUI_Work.c プロジェクト: soar-penguin/LCUI
static void 
Widget_Clicked(LCUI_MouseEvent *event)
/*
 * 功能:用于处理click事件,并保存被点击后的部件的指针
 * 说明:在鼠标左键被按下/释放时,都会调用这个函数
 **/
{
	LCUI_Widget *widget;
	if( !event ) {
		return;
	}
	
	widget = event->widget;
	switch( Mouse_LeftButton(event) ) {
	    case PRESSED:
		DEBUG_MSG("mouse left button pressed\n");
		click_widget = widget;
		/* 焦点转移给该部件 */
		Set_Focus( widget );
		if( Widget_Have_Event( widget, EVENT_DRAG ) ) {
			/* 开始处理部件的拖动 */
			DEBUG_MSG("widget have EVENT_DRAG\n");
			_Start_DragEvent( widget, event );
		}
		widget = Get_ResponseStatusChange_Widget( widget ); 
		if( !widget ) {
			DEBUG_MSG("widget not response status change\n");
			break;
		}
		/* 如果当前鼠标指针覆盖到的部件已被启用 */  
		if( event->widget->enabled && widget->enabled ) {
			Set_Widget_Status (widget, WIDGET_STATUS_CLICKING); 
		} else {
			Set_Widget_Status (widget, WIDGET_STATUS_DISABLE);
		}
		break;
		
	    case FREE: 
		DEBUG_MSG("mouse left button free\n");
		if( !click_widget ) {
			/* 如果是点击屏幕空白处,则复位焦点 */
			Reset_Focus( NULL );
			break;
		}
		if( Widget_Have_Event( click_widget, EVENT_DRAG ) ) {
			DEBUG_MSG("end drag\n");
			_End_DragEvent( click_widget, event );
		}
		if(click_widget == widget) {
			click_widget = NULL;
			/* 如果点击时和点击后都在同一个按钮部件内进行的,
			 * 触发CLICKED事件,将部件中关联该事件的回调函数发送至
			 * 任务队列,使之在主循环中执行 
			 * */
			
			widget = Get_ResponseEvent_Widget( event->widget, EVENT_CLICKED );
			if( widget && widget->enabled ) {
				Handle_Event(&widget->event, EVENT_CLICKED);
			}
			widget = Get_ResponseStatusChange_Widget(event->widget);
			if( !widget ) {
				break;
			}
			if(widget->enabled) {
				Set_Widget_Status (widget, WIDGET_STATUS_CLICKED);
				Set_Widget_Status (widget, WIDGET_STATUS_OVERLAY);
				break;
			}
			Set_Widget_Status (widget, WIDGET_STATUS_DISABLE);
			break;
		}
		/* 否则,将恢复之前点击的鼠标的状态 */ 
		widget = Get_ResponseStatusChange_Widget(click_widget);
		click_widget = NULL;
		if( !widget ) {
			break;
		}
		if(widget->enabled) {
			Set_Widget_Status (widget, WIDGET_STATUS_NORMAL);
		} else {
			Set_Widget_Status (widget, WIDGET_STATUS_DISABLE);
		}
	}
}
コード例 #7
0
ファイル: POST09.CPP プロジェクト: tlepage/Academic
void main(void)
{
    student_struct student_list[MAX_STUDENTS]; // Array of students
    int user_choice=0;                         // User choice

    FILE *grades=NULL, *students=NULL; // Files for student/grade info

//
// Open and check for errors in grades file
//
    if ((grades = fopen("grades.dat", "r")) == NULL)
    {
	 cerr << "Error opening grades.dat!\n";
	 exit(1);
    }

//
// Open and check for error in student file
//
    if ((students = fopen("Students.dat", "r")) == NULL)
    {
	 cerr << "Error opening students.dat!\n";
	 exit(1);
    }

//
// Reset all student structures
//
    ResetStudents(student_list);

//
// Read the grades in from the grades file
//
    ReadGrades(grades, student_list);

//
// Read the students in from the students file
//
    ReadStudents(students, student_list);
    cout << "Student file read.\n";

//
// Calculate needed student information
//
    CalculateInfo(student_list);
    cout << "Grades updated.\n\n\n";

//
// Loop to run functions chosen by user
//
    do
    {
	 user_choice = Main_Menu(); // Get user choice from menu screen

	 Handle_Event(user_choice, student_list); // Handle user choices

    }while(user_choice != EXIT_NUMBER); // End loop when user enters exit
								// condition

//
// Close both files
//
    fclose(grades);
    fclose(students);
}