コード例 #1
0
ファイル: pcp_about_fade.c プロジェクト: now/slackedit
static LRESULT CALLBACK FadeCtrl_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    LPFADECTRL lpfc = (LPFADECTRL)GetWindowLong(hwnd, GWL_USERDATA);

    switch (uMsg)
    {
        case WM_NCCREATE:
            lpfc = (LPFADECTRL)Mem_Alloc(sizeof(FADECTRL));

            if (lpfc == NULL)
                return (FALSE);

            SetWindowLong(hwnd, GWL_USERDATA, (LONG)lpfc);
        return (TRUE);
        case WM_CREATE:
            lpfc->bFadingIn = TRUE;
            GetClientRect(hwnd, &lpfc->rc);
            lpfc->hwnd      = hwnd;
            lpfc->pPageList = List_CreateList(PageList_CreateData, PageList_DeleteData, NULL, NULL, 0);
        return (TRUE);
        case WM_DESTROY:
            FadeCtrl_Deactivate(hwnd);
            List_DestroyList(lpfc->pPageList);
        break;
        case FC_ADDPAGE:
            List_AddNodeAtTail(lpfc->pPageList, (PVOID)lParam);
        return (TRUE);
        case FC_REMOVEPAGE:
            List_DeleteNode(lpfc->pPageList, List_GetNode(lpfc->pPageList, (INT)wParam));
        return (TRUE);
        case FC_GETCURRENTPAGE:
        return ((LRESULT)lpfc->pfcCurrentPage);
        case FC_ACTIVATE:
            if ((lpfc->hTread = BEGINTHREADEX(0, 0, FadeCtrl_ThreadProc, lpfc, 0, &lpfc->dwThreadID)) == NULL)
                return (FALSE);

            // We don't need the handle so close it
            CloseHandle(lpfc->hTread);

            lpfc->bActive = TRUE;
        return (TRUE);
        case FC_DEACTIVATE:
            if (!PostThreadMessage(lpfc->dwThreadID, WM_QUIT, 0, 0L))
                return (FALSE); // Still active

            lpfc->bActive = FALSE;
        return (TRUE);
        case FC_TOGGLEACTIVE:
            if (lpfc->bActive)
                return (FadeCtrl_Deactivate(hwnd));
            else
                return (FadeCtrl_Activate(hwnd));
        break;
    }

    return (DefWindowProc(hwnd, uMsg, wParam, lParam));
}
コード例 #2
0
ファイル: test_Iterator.c プロジェクト: jwchong93/LinkedList
void test_getIterator_should_create_an_iterator_and_point_to_the_LinkedList()
{
	LinkedList *testList = malloc(sizeof(LinkedList));
	Iterator *iter;
	iter = getIterator(testList);
	TEST_ASSERT_NOT_NULL(iter);
	//Make sure Iterator refer to the same linked list.
	TEST_ASSERT_EQUAL(testList,iter->list);
	//And it is points to the head.
	TEST_ASSERT_EQUAL(testList->head,iter->current);
	//Make sure the function pointer point to the function that refer the next element.
	TEST_ASSERT_EQUAL(&getNext,iter->next);
	List_DestroyList(testList);
	destroyIterator(iter);
}
コード例 #3
0
ファイル: test_Iterator.c プロジェクト: jwchong93/LinkedList
void test_getNext_will_update_the_pointer_point_to_the_next_location_for_1000_elements()
{
	LinkedList *testList = createLinkedList();
	Element elem[1000];
	Element *testElement;
	int i;
	for(i=0;i<1000;i++)
	{
		List_Add(&elem[i],testList);
	
	}
	testElement = testList->head;
	for(i=0;i<1000;i++)
	{
		TEST_ASSERT_EQUAL(&elem[i],testElement);
		testElement = getNext(testElement);	
	}

	TEST_ASSERT_EQUAL(NULL,testElement);
	List_DestroyList(testList);
}
コード例 #4
0
ファイル: test_Iterator.c プロジェクト: jwchong93/LinkedList
void test_getNext_will_update_the_pointer_point_to_the_next_location()
{
	LinkedList *testList = createLinkedList();
	Element *elem0 = malloc(sizeof(Element));
	Element *elem1 = malloc(sizeof(Element));
	Element *elem2 = malloc(sizeof(Element));
	Element *testElement;
	List_Add(elem0,testList);
	List_Add(elem1,testList);
	List_Add(elem2,testList);
	testElement = testList->head;
	TEST_ASSERT_EQUAL(elem0,testElement);
	testElement = getNext(testElement);
	TEST_ASSERT_EQUAL(elem1,testElement);
	testElement = getNext(testElement);
	TEST_ASSERT_EQUAL(elem2,testElement);
	testElement = getNext(testElement);
	TEST_ASSERT_EQUAL(NULL,testElement);
	List_DestroyList(testList);
	
}
コード例 #5
0
ファイル: test_Iterator.c プロジェクト: jwchong93/LinkedList
void test_getNext_function_properly_through_iterator()
{
	LinkedList *testList = createLinkedList();
	Iterator *iter;
	Element elem[1000];
	int i;
	for(i=0;i<1000;i++)
	{
		List_Add(&elem[i],testList);
	
	}
	//testElement = testList->head;
	iter = getIterator(testList);
	for(i=0;i<1000;i++)
	{
		TEST_ASSERT_EQUAL(&elem[i],iter->current);
		iter->current = iter->next(iter->current);
	}

	TEST_ASSERT_EQUAL(NULL,iter->current);
	List_DestroyList(testList);
	destroyIterator(iter);
}
コード例 #6
0
/*
	Destroy the data inside the iterator 
	
	Input: iter		Iterator that going to be destroyed
	
	Output: none
	
	Return: none
*/
void destroyIterator(Iterator *iter)
{
	List_DestroyList(iter->list);
	free(iter);
}
コード例 #7
0
/*
	Destroy all the element inside the stack
	
	Input: stack			Stack that going to be destroyed
	
	Output: none
	
	Return: none
*/
void destroyStack(Stack *stack)
{
	LinkedList *list = (LinkedList*)stack;
	List_DestroyList(list);
}
コード例 #8
0
ファイル: file_interface.c プロジェクト: now/slackedit
void FileInterface_DestroyFileHandling(void)
{
    List_DestroyList(s_lpFileList);
    FileNotify_DestroyNotifier(s_lpNotifyStruct);
}