diff --git a/src/app/pagetest1.c b/src/app/pagetest1.c index 9821109..3c28230 100644 --- a/src/app/pagetest1.c +++ b/src/app/pagetest1.c @@ -1,3 +1,7 @@ +//这是一段时钟功能+图标按钮的桌面页面,包括左右两个切换按钮 +//时钟位于上方,图标按钮有十个排列在下半部分,左右两侧分别为切换按钮 +//时钟的固定大小为340*70像素,时钟可以通过wjh_GetClockControl(main_window, 150, 100);创建,150,100为时钟左上角距离窗口x150,y100像素 +//页面跳转函数均已实现 #include "stdint.h" #include "stddef.h" #include "stdio.h" @@ -7,7 +11,6 @@ #include "page.h" // 调用头文件 u8 iconname1[][20] = {"address", "camera", "cart", "controller", "location", "music", "picture", "search", "time", "wifi", "table", "barchart"}; u32 iconflag1 = 0; - // Button click and paint handlers static bool_t left_page_button_paint(struct WindowMsg *pMsg); static bool_t right_page_button_paint(struct WindowMsg *pMsg); @@ -31,28 +34,22 @@ HWND enter_to_page1() { // Create the right page button (50x50) wjh_createButton("right_page_button", BS_NORMAL | WS_UNFILL, 954, 275, 50, 50, main_window, right_page_button_paint, right_page_button_click); - // Create the clock control at the center of the screen - int clock_width = 340; - int clock_height = 70; - int clock_x = (1024 - clock_width) / 2; - int clock_y = (600 - clock_height) / 2; - wjh_GetClockControl(main_window, clock_x, clock_y); + // Create the clock control at the top-left (150x150) + wjh_GetClockControl(main_window, 150, 100); - // Adjusted positions for icon buttons + // Adjusted positions for icon buttons to ensure even spacing int icon_size = 90; // Button size adjusted to 90x90 - int spacing_x = (1024 - 5 * icon_size - 4 * 60) / 2; // Horizontal spacing to center the buttons - int spacing_y = 20; // Vertical spacing between buttons - int x_start = spacing_x; - int y_start_upper = clock_y - icon_size - spacing_y; // Upper row start position - int y_start_lower = clock_y + clock_height + spacing_y; // Lower row start position + int spacing_x = 60; // Horizontal spacing between buttons + int spacing_y = 50; // Vertical spacing between buttons + int x_start = 150; // Start position adjusted to reduce left-side crowding + int y_start = 250; // Buttons are positioned lower on the screen // Create 10 icon buttons in 2 rows and 5 columns for (int i = 0; i < 2; ++i) { // 2 rows - int y_start = (i == 0) ? y_start_upper : y_start_lower; for (int j = 0; j < 5; ++j) { // 5 columns char button_name[20]; sprintf(button_name, "icon_button_%d_%d", i, j); - wjh_createButton(button_name, BS_NORMAL | WS_UNFILL, x_start + j * (icon_size + spacing_x), y_start, + wjh_createButton(button_name, BS_NORMAL | WS_UNFILL, x_start + j * (icon_size + spacing_x), y_start + i * (icon_size + spacing_y), icon_size, icon_size, main_window, page_button_paint, NULL); } } @@ -70,64 +67,82 @@ static bool_t main_window_paint(struct WindowMsg *pMsg) { return false; wjh_setBackBmp(pMsg->hwnd, wjh_Search_BMP("background1")); - // Draw circles to indicate the current page + //通过画圆来记录当前页面,这段代码不要动,颜色也不要改 GDD_SetDrawColor(hdc, RGB(200, 200, 200)); GDD_FillCircle(hdc, 487, 570, 5); GDD_SetDrawColor(hdc, RGB(125, 125, 125)); GDD_FillCircle(hdc, 507, 570, 5); GDD_FillCircle(hdc, 527, 570, 5); + GDD_EndPaint(hwnd, hdc); return true; } // Paint handlers for the left page button static bool_t left_page_button_paint(struct WindowMsg *pMsg) { - HWND hwnd = pMsg->hwnd; - HDC hdc = GDD_BeginPaint(hwnd); + HWND hwnd; + HDC hdc; + RECT rect; + hwnd = pMsg->hwnd; + if (hwnd == NULL) return false; + hdc = GDD_BeginPaint(hwnd); if (hdc == NULL) return false; wjh_setBackBmp(hwnd, wjh_Search_BMP("turn_left")); GDD_EndPaint(hwnd, hdc); + return true; } // Paint handlers for the right page button static bool_t right_page_button_paint(struct WindowMsg *pMsg) { - HWND hwnd = pMsg->hwnd; - HDC hdc = GDD_BeginPaint(hwnd); + HWND hwnd; + HDC hdc; + RECT rect; + hwnd = pMsg->hwnd; + if (hwnd == NULL) return false; + hdc = GDD_BeginPaint(hwnd); if (hdc == NULL) return false; wjh_setBackBmp(hwnd, wjh_Search_BMP("turn_right")); GDD_EndPaint(hwnd, hdc); + return true; } - static bool_t page_button_paint(struct WindowMsg *pMsg) { - HWND hwnd = pMsg->hwnd; - HDC hdc = GDD_BeginPaint(hwnd); + HWND hwnd; + HDC hdc; + RECT rect; + hwnd = pMsg->hwnd; + if (hwnd == NULL) return false; + hdc = GDD_BeginPaint(hwnd); if (hdc == NULL) return false; wjh_setBackBmp(hwnd, wjh_Search_BMP("button1_background")); - wjh_setBackBmpHyaline(hwnd, wjh_Search_ICONBMP(iconname1[(iconflag1++) % 12])); + wjh_setBackBmpHyaline(hwnd, wjh_Search_ICONBMP(iconname1[(iconflag1++)%12])); GDD_EndPaint(hwnd, hdc); + return true; } - // Click handlers for the left page button static bool_t left_page_button_click(struct WindowMsg *pMsg) { + // Logic for navigating to the previous page wjh_deleteWindow(GDD_GetWindowParent(pMsg->hwnd)); - enter_to_page3(); // Navigate to page3 + + enter_to_page3(); // Example of navigating to page3 return true; } // Click handlers for the right page button static bool_t right_page_button_click(struct WindowMsg *pMsg) { + // Logic for navigating to the next page HWND hwnd = GDD_GetWindowParent(pMsg->hwnd); wjh_deleteWindow(hwnd); - enter_to_page2(); // Navigate to page2 + + enter_to_page2(); // Example of navigating to page2 return true; -} +} \ No newline at end of file