From 6ad1a2a7e704dc1cb73b03ba4c4b430b0302f4bf Mon Sep 17 00:00:00 2001 From: wujiahao17 <315776852@qq.com> Date: Fri, 23 Aug 2024 01:15:57 +0800 Subject: [PATCH] "0000" --- src/app/pagetest1.c | 70 ++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 41 deletions(-) diff --git a/src/app/pagetest1.c b/src/app/pagetest1.c index 4c7ad87..4251e1b 100644 --- a/src/app/pagetest1.c +++ b/src/app/pagetest1.c @@ -1,13 +1,13 @@ - #include "stdint.h" #include "stddef.h" #include "stdio.h" #include "gdd.h" #include "gdd_button.h" #include "wjh_window.h" -#include "page.h" // µ÷ÓÃÍ·Îļþ +#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,23 +31,29 @@ 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 top-left (150x150) - wjh_GetClockControl(main_window, 150, 100); + // 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); - // Adjusted positions for icon buttons to ensure even spacing + // Adjusted positions for icon buttons int icon_size = 90; // Button size adjusted to 90x90 - 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 + 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 // 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), y_start + i * (icon_size + spacing_y), - 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), + (i == 0) ? y_start_above : y_start_below, icon_size, icon_size, + main_window, page_button_paint, NULL); } } @@ -64,82 +70,64 @@ 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; - HDC hdc; - RECT rect; - hwnd = pMsg->hwnd; - if (hwnd == NULL) return false; - hdc = GDD_BeginPaint(hwnd); + HWND hwnd = pMsg->hwnd; + HDC 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; - HDC hdc; - RECT rect; - hwnd = pMsg->hwnd; - if (hwnd == NULL) return false; - hdc = GDD_BeginPaint(hwnd); + HWND hwnd = pMsg->hwnd; + HDC 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; - HDC hdc; - RECT rect; - hwnd = pMsg->hwnd; - if (hwnd == NULL) return false; - hdc = GDD_BeginPaint(hwnd); + HWND hwnd = pMsg->hwnd; + HDC 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(); // Example of navigating to page3 + enter_to_page3(); // Navigate 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(); // Example of navigating to page2 + enter_to_page2(); // Navigate to page2 return true; }