From f3e1eba561d9fa8760216aad865d3fe46c55b0bd Mon Sep 17 00:00:00 2001 From: wujiahao17 <315776852@qq.com> Date: Fri, 23 Aug 2024 12:14:44 +0800 Subject: [PATCH] "11111" --- src/app/pagetest1.c | 69 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/src/app/pagetest1.c b/src/app/pagetest1.c index 4251e1b..55b7ce7 100644 --- a/src/app/pagetest1.c +++ b/src/app/pagetest1.c @@ -7,7 +7,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,29 +30,23 @@ 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) / 6; // Horizontal spacing between buttons - int spacing_y = 20; // Vertical spacing between buttons - int x_start = spacing_x; - int y_start_above = clock_y - icon_size - spacing_y; // Buttons above the clock - int y_start_below = clock_y + clock_height + spacing_y; // Buttons below the clock + 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 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), - (i == 0) ? y_start_above : y_start_below, icon_size, icon_size, - main_window, page_button_paint, NULL); + 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 +63,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