--- /dev/null
+\r
+#include "core.h"\r
+\r
+uchar closebutton[16][40] = {\r
+ "OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",\r
+ "OQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQJJQQQQQQQQJJQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQJJJQQQQQQJJJQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQQJJJQQQQJJJQQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQQQJJJQQJJJQQQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQQQQJJJJJJQQQQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQQQQQJJJJQQQQQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQQQQQJJJJQQQQQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQQQQJJJJJJQQQQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQQQJJJQQJJJQQQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQQJJJQQQQJJJQQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQJJJQQQQQQJJJQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQJJQQQQQQQQJJQQQQQQQQQQQQ$@",\r
+ "OQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ$@",\r
+ "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"\r
+};\r
+\r
+UI_Window *window_root;\r
+\r
+void Initialise_Window(UI_Window *windowctrl)\r
+{\r
+ window_root = windowctrl;\r
+ window_root->client = 0;\r
+ window_root->control = 0;\r
+ window_root->title[0] = 0x00;\r
+ window_root->next = 0;\r
+ return;\r
+}\r
+\r
+UI_Window *Window_Create(const uchar *title, uint flags, uint xsize, uint ysize)\r
+{\r
+ DATA_BootInfo *boot = (DATA_BootInfo *)ADR_BOOTINFO;\r
+ UI_Window *win, *end;\r
+ uint i;\r
+ int x, y;\r
+\r
+ win = MemoryBlock_Allocate_System(sizeof(UI_Window));\r
+ MemoryBlock_Write_Description(win, "UI_Window");\r
+\r
+ for(i = 0; i < (WINDOW_TITLE_LENGTH - 1); i++){\r
+ if(title[i] == 0x00){\r
+ break;\r
+ }\r
+ win->title[i] = title[i];\r
+ }\r
+ win->title[i] = 0x00;\r
+\r
+ win->control = System_Sheet_Get((i + 8) << 3, WINDOW_CONTROL_XSIZE, 0, 0);\r
+ win->client = System_Sheet_Get(xsize, ysize, 0, 0);\r
+ Sheet_Set_Movable(win->control, true);\r
+\r
+ Sheet_Draw_Fill_Rectangle_Gradation_Vertical(win->control, 0xffffff, 0x7cfc00, 0, 0, win->control->size.x - 1, win->control->size.y - 1);\r
+\r
+ Sheet_Draw_Fill_Rectangle(win->client, 0xffffff, 0, 0, win->client->size.x - 1, win->client->size.y - 1);\r
+\r
+ Window_Draw_CloseButton(win, false);\r
+\r
+// Sheet_Draw_Fill_Rectangle(win->control, 0xffffff, 0, 0, win->control->size.x - 1, 0);\r
+// Sheet_Draw_Fill_Rectangle(win->control, 0xffffff, 0, 0, 0, win->control->size.y - 1);\r
+// Sheet_Draw_Fill_Rectangle(win->control, 0x32cd32, win->control->size.x - 1, 0, win->control->size.x - 1, win->control->size.y - 1);\r
+// Sheet_Draw_Fill_Rectangle(win->control, 0x32cd32, 0, win->control->size.y - 1, win->control->size.x - 1, win->control->size.y - 1);\r
+\r
+ x = (boot->scrnx >> 1) - (win->client->size.x >> 1);\r
+ y = (boot->scrny >> 1) - (win->client->size.y >> 1) - (win->control->size.y >> 1);\r
+\r
+ if(x < 0){\r
+ x = 0;\r
+ }\r
+ if(y < 0){\r
+ y = 0;\r
+ }\r
+ Sheet_Draw_Put_String(win->control, 4 + 8, 4, 0x00000000, win->title);\r
+\r
+ Sheet_Set_MouseEventProcedure(win->control, &Window_Control_MouseEventProcedure, 0);\r
+\r
+ Sheet_Show(win->control, x, y, System_Sheet_Get_Top_Of_Height());\r
+ Sheet_Show(win->client, x, y + win->control->size.y, System_Sheet_Get_Top_Of_Height());\r
+\r
+ for(end = window_root; end->next != 0; end = end->next){\r
+\r
+ }\r
+ win->next = 0;\r
+ end->next = win;\r
+\r
+ CHNOS_UI_KeyFocus_Change(win->client);\r
+\r
+ return win;\r
+}\r
+\r
+UI_Window *Window_Create_User(const uchar *title, uint flags, UI_Sheet *client)\r
+{\r
+ DATA_BootInfo *boot = (DATA_BootInfo *)ADR_BOOTINFO;\r
+ UI_Window *win, *end;\r
+ uint i;\r
+ int x, y;\r
+\r
+ win = MemoryBlock_Allocate_System(sizeof(UI_Window));\r
+ MemoryBlock_Write_Description(win, "UI_Window");\r
+\r
+ for(i = 0; i < (WINDOW_TITLE_LENGTH - 1); i++){\r
+ if(title[i] == 0x00){\r
+ break;\r
+ }\r
+ win->title[i] = title[i];\r
+ }\r
+ win->title[i] = 0x00;\r
+\r
+ win->control = System_Sheet_Get((i + 8) << 3, WINDOW_CONTROL_XSIZE, 0, 0);\r
+ win->client = client;\r
+ Sheet_Set_Movable(win->control, true);\r
+\r
+ Sheet_Draw_Fill_Rectangle_Gradation_Vertical(win->control, 0xffffff, 0x7cfc00, 0, 0, win->control->size.x - 1, win->control->size.y - 1);\r
+\r
+ Window_Draw_CloseButton(win, false);\r
+\r
+// Sheet_Draw_Fill_Rectangle(win->control, 0xffffff, 0, 0, win->control->size.x - 1, 0);\r
+// Sheet_Draw_Fill_Rectangle(win->control, 0xffffff, 0, 0, 0, win->control->size.y - 1);\r
+// Sheet_Draw_Fill_Rectangle(win->control, 0x32cd32, win->control->size.x - 1, 0, win->control->size.x - 1, win->control->size.y - 1);\r
+// Sheet_Draw_Fill_Rectangle(win->control, 0x32cd32, 0, win->control->size.y - 1, win->control->size.x - 1, win->control->size.y - 1);\r
+\r
+ x = (boot->scrnx >> 1) - (win->client->size.x >> 1);\r
+ y = (boot->scrny >> 1) - (win->client->size.y >> 1) - (win->control->size.y >> 1);\r
+\r
+ if(x < 0){\r
+ x = 0;\r
+ }\r
+ if(y < 0){\r
+ y = 0;\r
+ }\r
+ Sheet_Draw_Put_String(win->control, 4 + 8, 4, 0x00000000, win->title);\r
+\r
+ Sheet_Set_MouseEventProcedure(win->control, &Window_Control_MouseEventProcedure, 0);\r
+\r
+ Sheet_Show(win->control, x, y, System_Sheet_Get_Top_Of_Height());\r
+\r
+ if(!win->client->visible){\r
+ Sheet_Show(win->client, x, y + win->control->size.y, System_Sheet_Get_Top_Of_Height());\r
+ } else{\r
+ Sheet_Slide(win->client, x, y + win->control->size.y);\r
+ Sheet_UpDown(win->client, System_Sheet_Get_Top_Of_Height());\r
+ }\r
+\r
+ for(end = window_root; end->next != 0; end = end->next){\r
+\r
+ }\r
+ win->next = 0;\r
+ end->next = win;\r
+\r
+ CHNOS_UI_KeyFocus_Change(win->client);\r
+\r
+ return win;\r
+}\r
+\r
+UI_Window *Window_Get_From_Sheet(UI_Sheet *sheet)\r
+{\r
+ UI_Window *now;\r
+\r
+ for(now = window_root->next; now != 0; now = now->next){\r
+ if(now->control == sheet || now->client == sheet){\r
+ return now;\r
+ }\r
+ }\r
+ return 0;\r
+}\r
+\r
+void Window_Control_MouseEventProcedure(UI_MouseEventArguments *e)\r
+{\r
+ UI_Window *focus_win;\r
+\r
+ focus_win = Window_Get_From_Sheet(e->focus);\r
+\r
+ if(focus_win == 0){\r
+ return;\r
+ }\r
+\r
+ if((e->button & MOUSE_BUTTON_L) != 0 && (e->button_before & MOUSE_BUTTON_L) == 0){ /*L down*/\r
+ CHNOS_UI_KeyFocus_Change(focus_win->client);\r
+ Sheet_UpDown(focus_win->client, System_Sheet_Get_Top_Of_Height() - 1);\r
+ if(focus_win->control->size.x - 44 <= e->position_local.x && e->position_local.x <= focus_win->control->size.x - 4 - 1 && 0 <= e->position_local.y && e->position_local.y <= 16 - 1){\r
+ Window_Draw_CloseButton(focus_win, true);\r
+ }\r
+ }\r
+ if((e->button & MOUSE_BUTTON_L) == 0 && (e->button_before & MOUSE_BUTTON_L) != 0){ /*L release*/\r
+ Sheet_Slide(focus_win->client, focus_win->control->position.x, focus_win->control->position.y + focus_win->control->size.y);\r
+ Window_Draw_CloseButton(focus_win, false);\r
+ }\r
+ return;\r
+}\r
+\r
+void Window_Draw_CloseButton(UI_Window *win, bool pressed)\r
+{\r
+ uint x, y, color;\r
+ uchar c;\r
+\r
+ if(pressed){\r
+ Sheet_Draw_Fill_Rectangle_Gradation_Vertical(win->control, 0xff0000, 0xffffff, win->control->size.x - 44, 0, win->control->size.x - 4 - 1, 16 - 1);\r
+ } else{\r
+ Sheet_Draw_Fill_Rectangle_Gradation_Vertical(win->control, 0xffffff, 0xff0000, win->control->size.x - 44, 0, win->control->size.x - 4 - 1, 16 - 1);\r
+ }\r
+\r
+ for(y = 0; y < 16; y++){\r
+ for(x = 0; x < 40; x++){\r
+ c = closebutton[y][x];\r
+ color = 0x000000;\r
+ if(c == '@'){\r
+ //color = 0x8b0000;\r
+ } else if(c == '$'){\r
+ //color = 0xff0000;\r
+ } else if(c == 'Q'){\r
+ //color = 0xff0000;\r
+ } else if(c == 'J'){\r
+ color = 0xffffff;\r
+ } else if(c == 'O'){\r
+ //color = 0xffffff;\r
+ }\r
+ if(color != 0x000000){\r
+ Sheet_Draw_Point(win->control, color, win->control->size.x - 44 + x, y);\r
+ }\r
+ }\r
+ }\r
+\r
+ return;\r
+}\r