OSDN Git Service

svn rev.329より移動。
[chnosproject/CHNOSProject.git] / CHNOSProject / chnos / tolset_chn_000 / chnos_010 / chnos / shtfunc.c
diff --git a/CHNOSProject/chnos/tolset_chn_000/chnos_010/chnos/shtfunc.c b/CHNOSProject/chnos/tolset_chn_000/chnos_010/chnos/shtfunc.c
new file mode 100644 (file)
index 0000000..f7da5a5
--- /dev/null
@@ -0,0 +1,718 @@
+\r
+#include "core.h"\r
+\r
+//\83V\81[\83g\90§\8cä\97p\93à\95\94\8aÖ\90\94\81Bsheet.c\88È\8aO\82©\82ç\82Í\8cÄ\82Ñ\8fo\82µ\8bÖ\8e~\81B\r
+//\82»\82Ì\91ã\82í\82è\81A\83V\81[\83g\97L\8cø\90«\83`\83F\83b\83N\82Í\82 \82é\92ö\93x\8fÈ\82­\81B\r
+//\8cÄ\82Ñ\8fo\82µ\91¤\82Ì\8aÖ\90\94\82Å\81A\83V\81[\83g\82ª\97L\8cø\82Å\82 \82é\82±\82Æ\82ð\8am\94F\82µ\82Ä\82©\82ç\93n\82·\82±\82Æ\81B\r
+\r
+//uint Sheet_Internal_GetLocation[P,Q,R,S](UI_Sheet *sheet, DATA_Location2D *dest);\r
+//\8f\91\82«\8d\9e\82Ý\89Â\94\\82È\82à\82Á\82Æ\82à\92[\82Ì\8ae\8dÀ\95W\82ð\90e\83V\81[\83g\82Å\82Ì\8dÀ\95W\82Å\8b\81\82ß\82é\81Bdest\82É\8dÀ\95W\82ð\8ai\94[\81B\r
+//\90e\82ª\82È\82¢\83V\81[\83g\82Ì\8fê\8d\87\82Í\81A\96ß\82è\92l\82ª1\82É\82È\82è\81Alocation\82ª(0,0)\82Å\82 \82é\82Æ\89¼\92è\82³\82ê\82é\81B\r
+//\90e\82Ì\82 \82é\83V\81[\83g\82Ì\8fê\8d\87\82Í\81A\96ß\82è\92l\82ª0\82É\82È\82è\81A\8ae\8dÀ\95W\82ª\8ai\94[\82³\82ê\82é\81B\r
+\r
+uint Sheet_Internal_GetLocationP(UI_Sheet *sheet, DATA_Location2D *dest)\r
+{\r
+       if(sheet->parent == Null){\r
+               dest->x = 0;\r
+               dest->y = 0;\r
+               return 1;\r
+       }\r
+       dest->x = sheet->location.x;\r
+       dest->y = sheet->location.y;\r
+\r
+       return 0;\r
+}\r
+\r
+uint Sheet_Internal_GetLocationQ(UI_Sheet *sheet, DATA_Location2D *dest)\r
+{\r
+       if(sheet->parent == Null){\r
+               dest->x = 0;\r
+               dest->y = (int)sheet->size.y - 1;\r
+               return 1;\r
+       }\r
+       dest->x = sheet->location.x;\r
+       dest->y = sheet->location.y + (int)sheet->size.y - 1;\r
+\r
+       return 0;\r
+}\r
+\r
+uint Sheet_Internal_GetLocationR(UI_Sheet *sheet, DATA_Location2D *dest)\r
+{\r
+       if(sheet->parent == Null){\r
+               dest->x = (int)sheet->size.x - 1;\r
+               dest->y = (int)sheet->size.y - 1;\r
+               return 1;\r
+       }\r
+       dest->x = sheet->location.x + (int)sheet->size.x - 1;\r
+       dest->y = sheet->location.y + (int)sheet->size.y - 1;\r
+\r
+       return 0;\r
+}\r
+\r
+uint Sheet_Internal_GetLocationS(UI_Sheet *sheet, DATA_Location2D *dest)\r
+{\r
+       if(sheet->parent == Null){\r
+               dest->x = (int)sheet->size.x - 1;\r
+               dest->y = 0;\r
+               return 1;\r
+       }\r
+       dest->x = sheet->location.x + (int)sheet->size.x - 1;\r
+       dest->y = sheet->location.y;\r
+\r
+       return 0;\r
+}\r
+\r
+//uint Sheet_Internal_MapInitialize(UI_Sheet *parent);\r
+//map\82ð\8f\89\8aú\89»\82·\82é\81B\r
+//\82·\82Å\82É\83}\83b\83v\82ª\8am\95Û\82³\82ê\82Ä\82¢\82½\8fê\8d\87\82Í\81A\89ð\95ú\82µ\82½\8cã\82É\8dÄ\8am\95Û\82·\82é\81B\r
+//\83}\83b\83v\82Ì\8dÄ\8d\\90¬\82à\8e©\93®\82Å\8ds\82¤\81B\r
+\r
+uint Sheet_Internal_MapInitialize(UI_Sheet *parent)\r
+{\r
+       if(parent->flags.bit.using_map){\r
+               parent->flags.bit.using_map = False;\r
+               System_Memory_Free(parent->map, parent->mapsize);\r
+       }\r
+\r
+       parent->mapsize = parent->size.x * parent->size.y * 4;\r
+       parent->map = (uint *)System_Memory_Allocate(parent->mapsize);\r
+       parent->flags.bit.using_map = True;\r
+\r
+       Sheet_Internal_MapRebuild(parent, 0, 0, parent->size.x - 1, parent->size.y - 1);\r
+\r
+       #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+               debug("Sheet_Internal_MapInitialize:[0x%08X] map:[0x%08X]\n", parent, parent->map);\r
+       #endif\r
+\r
+       return 0;\r
+}\r
+\r
+//uint Sheet_Internal_Map[Write, Clear]FromSheet(UI_Sheet *sheet, bool force);\r
+//\8ae\83V\81[\83g\82Ì\94Í\88Í\93à\82Ì\83}\83b\83v\82ð\90\90¬\82·\82é\81B\r
+//force\82ªFalse\82Ì\8e\9e\82Í\81Amap\82ÌNull\82Ü\82½\82Í\8e©\95ª\82Ì\83A\83h\83\8c\83X\82Ì\95\94\95ª\82µ\82©\82¢\82\82ç\82È\82¢\81B\r
+//force\82ªTrue\82Ì\8e\9e\82Í\81Amap\82Ì\94Í\88Í\93à\82É\8b­\90§\93I\82É\8f\91\82«\8d\9e\82Þ\81B\r
+\r
+uint Sheet_Internal_MapWriteFromSheet(UI_Sheet *sheet, bool force, int px0, int py0, int px1, int py1)\r
+{\r
+       int x, y;\r
+       DATA_Location2D p, r;\r
+\r
+       if(sheet->parent == Null){\r
+               #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+                       debug("Sheet_Internal_MapWriteFromSheet:Null parent.\n");\r
+               #endif\r
+               return 1;\r
+       }\r
+\r
+       if(sheet->parent->map == Null){\r
+               #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+                       debug("Sheet_Internal_MapWriteFromSheet:Null map.\n");\r
+               #endif\r
+               return 2;\r
+       }\r
+\r
+       if(!sheet->flags.bit.visible){\r
+               return 0;\r
+       }\r
+\r
+       Sheet_Internal_GetLocationP(sheet, &p);\r
+       Sheet_Internal_GetLocationR(sheet, &r);\r
+\r
+       if(p.x < px0){\r
+               p.x = px0;\r
+       }\r
+       if(p.y < py0){\r
+               p.y = py0;\r
+       }\r
+       if(r.x > px1){\r
+               r.x = px1;\r
+       }\r
+       if(r.y > py1){\r
+               r.y = py1;\r
+       }\r
+\r
+       if(p.x < 0){\r
+               p.x = 0;\r
+       }\r
+       if(p.y < 0){\r
+               p.y = 0;\r
+       }\r
+       if(r.x >= (int)sheet->parent->size.x){\r
+               r.x = (int)sheet->parent->size.x - 1;\r
+       }\r
+       if(r.y >= (int)sheet->parent->size.y){\r
+               r.y = (int)sheet->parent->size.y - 1;\r
+       }\r
+\r
+       if(force){\r
+               if(sheet->flags.bit.using_invcol){\r
+                       for(y = p.y; y <= r.y; y++){\r
+                               for(x = p.x; x <= r.x; x++){\r
+                                       if(sheet->IsVisiblePixel(sheet, x, y)){\r
+                                               sheet->parent->map[y * sheet->parent->size.x + x] = (uint)sheet;\r
+                                       }\r
+                               }\r
+                       }\r
+               } else{\r
+                       for(y = p.y; y <= r.y; y++){\r
+                               for(x = p.x; x <= r.x; x++){\r
+                                       sheet->parent->map[y * sheet->parent->size.x + x] = (uint)sheet;\r
+                               }\r
+                       }\r
+               }\r
+       } else{\r
+               if(sheet->flags.bit.using_invcol){\r
+                       for(y = p.y; y <= r.y; y++){\r
+                               for(x = p.x; x <= r.x; x++){\r
+                                       if(sheet->parent->map[y * sheet->parent->size.x + x] == Null && sheet->IsVisiblePixel(sheet, x, y)){\r
+                                               sheet->parent->map[y * sheet->parent->size.x + x] = (uint)sheet;\r
+                                       }\r
+                               }\r
+                       }\r
+               } else{\r
+                       for(y = p.y; y <= r.y; y++){\r
+                               for(x = p.x; x <= r.x; x++){\r
+                                       if(sheet->parent->map[y * sheet->parent->size.x + x] == Null){\r
+                                               sheet->parent->map[y * sheet->parent->size.x + x] = (uint)sheet;\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+uint Sheet_Internal_MapClearFromSheet(UI_Sheet *sheet, bool force, int px0, int py0, int px1, int py1)\r
+{\r
+       int x, y;\r
+       DATA_Location2D p, r;\r
+\r
+       if(sheet->parent == Null){\r
+               #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+                       debug("Sheet_Internal_MapClearFromSheet:Null parent.\n");\r
+               #endif\r
+               return 1;\r
+       }\r
+\r
+       if(sheet->parent->map == Null){\r
+               #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+                       debug("Sheet_Internal_MapClearFromSheet:Null map.\n");\r
+               #endif\r
+               return 2;\r
+       }\r
+\r
+       Sheet_Internal_GetLocationP(sheet, &p);\r
+       Sheet_Internal_GetLocationR(sheet, &r);\r
+\r
+       if(p.x < px0){\r
+               p.x = px0;\r
+       }\r
+       if(p.y < py0){\r
+               p.y = py0;\r
+       }\r
+       if(r.x > px1){\r
+               r.x = px1;\r
+       }\r
+       if(r.y > py1){\r
+               r.y = py1;\r
+       }\r
+\r
+       if(p.x < 0){\r
+               p.x = 0;\r
+       }\r
+       if(p.y < 0){\r
+               p.y = 0;\r
+       }\r
+       if(r.x >= (int)sheet->parent->size.x){\r
+               r.x = (int)sheet->parent->size.x - 1;\r
+       }\r
+       if(r.y >= (int)sheet->parent->size.y){\r
+               r.y = (int)sheet->parent->size.y - 1;\r
+       }\r
+\r
+       if(force){\r
+               for(y = p.y; y <= r.y; y++){\r
+                       for(x = p.x; x <= r.x; x++){\r
+                               sheet->parent->map[y * sheet->parent->size.x + x] = Null;\r
+                       }\r
+               }\r
+       } else{\r
+               for(y = p.y; y <= r.y; y++){\r
+                       for(x = p.x; x <= r.x; x++){\r
+                               if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){\r
+                                       sheet->parent->map[y * sheet->parent->size.x + x] = Null;\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+//bool Sheet_Internal_IsLocationInRangeOfSheet(UI_Sheet *sheet, int px, int py);\r
+//\82»\82Ì\83V\81[\83g\82ª\81A\82»\82Ì\83V\81[\83g\82Ì\90e\93à\95\94\82Å\82Ì\8dÀ\95W\82Å\82 \82é(px, py)\82ð\8aÜ\82Þ\82©\82Ç\82¤\82©\82ð\95Ô\82·\81B\r
+//\83V\81[\83g\82ª\96³\8cø\82Å\82à\81AFalse\82ð\95Ô\82·\82¾\82¯\82Å\82 \82é\81B\r
+//\90e\82ª\82¢\82È\82¢\83V\81[\83g\82Å\82±\82Ì\8aÖ\90\94\82ð\8eÀ\8ds\82µ\82Ä\82à\96³\88Ó\96¡\82¾\82Æ\8ev\82í\82ê\82é\82Ì\82Å\81AFalse\82ð\95Ô\82·\82¾\82¯\82Å\82 \82é\81B\r
+\r
+bool Sheet_Internal_IsLocationInRangeOfSheet(UI_Sheet *sheet, int px, int py)\r
+{\r
+       if(sheet == Null){\r
+               return False;\r
+       }\r
+       if(sheet->parent == Null){\r
+               return False;\r
+       }\r
+\r
+       if(sheet->location.x > px || sheet->location.y > py){\r
+               return False;\r
+       }\r
+       if(sheet->location.x + (int)sheet->size.x - 1 < px || sheet->location.y + (int)sheet->size.y - 1 < py){\r
+               return False;\r
+       }\r
+\r
+       return True;\r
+}\r
+\r
+//bool Sheet_Internal_IsRangeOverlappedWithSheet(UI_Sheet *sheet, int px0, int py0, int px1, int py1);\r
+//\8ew\92è\82³\82ê\82½\83V\81[\83g\82ª\88ø\90\94\82Ì\8dÀ\95W\94Í\88Í\93à\82É\8fd\82È\82é\82©\82Ç\82¤\82©\82ð\95Ô\82·\81B\r
+\r
+bool Sheet_Internal_IsRangeOverlappedWithSheet(UI_Sheet *sheet, int px0, int py0, int px1, int py1)\r
+{\r
+       if(sheet == Null){\r
+               return False;\r
+       }\r
+       if(sheet->parent == Null){\r
+               return False;\r
+       }\r
+\r
+       if(sheet->location.x > px1){\r
+               return False;\r
+       }\r
+\r
+       if(sheet->location.y > py1){\r
+               return False;\r
+       }\r
+\r
+       if(sheet->location.x + (int)sheet->size.x - 1 < px0){\r
+               return False;\r
+       }\r
+\r
+       if(sheet->location.y + (int)sheet->size.y - 1 < py0){\r
+               return False;\r
+       }\r
+\r
+       return True;\r
+}\r
+\r
+//UI_Sheet *Sheet_Internal_GetSheetFromLocation(UI_Sheet *parent, int px, int py)\r
+//\90e\93à\95\94\82Å\82Ì(px, py)\82É\82¨\82¯\82é\81A\89Â\8e\8b\8fó\91Ô\82Ì\82à\82Á\82Æ\82à\8d\82\82¢\8d\82\82³\82Ì\83V\81[\83g\82ð\95Ô\82·\81B\r
+//\82±\82Ì\8aÖ\90\94\82Í\82«\82Á\82Æ\92x\82¢\82Ì\82Å\81Amap\82ª\97\98\97p\82Å\82«\82È\82¢\8e\9e\82Ì\82Ý\81A\8eg\97p\82·\82é\82×\82«\82Å\82 \82é\81B\r
+//\83G\83\89\81[\82ª\94­\90\82µ\82½\8e\9e\82Í\81ANull\82ð\95Ô\82·\82¾\82¯\82Å\82 \82é\81B\r
+\r
+UI_Sheet *Sheet_Internal_GetSheetFromLocation(UI_Sheet *parent, int px, int py)\r
+{\r
+       uint i;\r
+       UI_Sheet *sheet, *search;\r
+\r
+       sheet = Null;\r
+\r
+       search = parent->child;\r
+       for(i = 0; i < SHEET_MAX_CHILDREN; i++){\r
+               if(search == Null){\r
+                       break;\r
+               }\r
+               if(Sheet_Internal_IsLocationInRangeOfSheet(search, px, py) && search->flags.bit.visible){\r
+                       sheet = search;\r
+               }\r
+               search = search->next;\r
+       }\r
+\r
+       return sheet;\r
+}\r
+\r
+//uint Sheet_Internal_MapRebuild(UI_Sheet *parent, int px0, int py0, int px1, int py1);\r
+//\82»\82Ì\94Í\88Í\93à\82Ì\83}\83b\83v\82ð\8a®\91S\82É\8dÄ\8d\\90¬\82·\82é\81B\r
+uint Sheet_Internal_MapRebuild(UI_Sheet *parent, int px0, int py0, int px1, int py1)\r
+{\r
+       uint i;\r
+       UI_Sheet *search;\r
+\r
+       search = parent->child;\r
+       for(i = 0; i < SHEET_MAX_CHILDREN; i++){\r
+               if(search == Null){\r
+                       break;\r
+               }\r
+               if(Sheet_Internal_IsRangeOverlappedWithSheet(search, px0, py0, px1, py1)){\r
+                       Sheet_Internal_MapWriteFromSheet(search, True, px0, py0, px1, py1);\r
+               }\r
+               search = search->next;\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+//uint Sheet_Internal_MapRefresh(UI_Sheet *sheet, int px0, int py0, int px1, int py1);\r
+//\82»\82Ì\94Í\88Í\93à\82Ì\83}\83b\83v\82ð\81Asheet\82É\95Ï\8dX\82ª\82 \82Á\82½\82Æ\82µ\82Ä\81A\8dÅ\8f¬\8cÀ\82Å\8dÄ\8d\\90¬\82·\82é\81B\r
+//\8dÀ\95W\82Ímap(parent)\82È\82Ì\82Å\92\8d\88Ó\81B\r
+//sheet\82Ì\8d\82\82³\82Ü\82Å\82Í\82·\82×\82Ä\8dÄ\8d\\90¬\82·\82é\81B\r
+//\93¯\8e\9e\82É\81A\8dX\90V\82µ\82½\83V\81[\83g\82É\91Î\82µ\82Ä\8dÄ\95`\89æ\82ð\82©\82¯\82é\81B\r
+uint Sheet_Internal_MapRefresh(UI_Sheet *sheet, int px0, int py0, int px1, int py1)\r
+{\r
+       UI_Sheet *search;\r
+       //int x, y;\r
+       uint i;\r
+       UI_Sheet **write_sheet;\r
+       uint write_sheets;\r
+\r
+       write_sheet = (UI_Sheet **)System_Memory_Allocate(4 * SHEET_MAX_CHILDREN);\r
+\r
+       if(px0 < 0){\r
+               px0 = 0;\r
+       }\r
+       if(py0 < 0){\r
+               py0 = 0;\r
+       }\r
+       if(px1 >= (int)sheet->parent->size.x){\r
+               px1 = (int)sheet->parent->size.x - 1;\r
+       }\r
+       if(py1 >= (int)sheet->parent->size.y){\r
+               py1 = (int)sheet->parent->size.y - 1;\r
+       }\r
+\r
+       write_sheets = 0;\r
+\r
+       search = sheet->parent->child;\r
+       for(i = 0; i < SHEET_MAX_CHILDREN; i++){\r
+               if(search == Null){\r
+                       break;\r
+               }\r
+               if(Sheet_Internal_IsRangeOverlappedWithSheet(search, px0, py0, px1, py1)){\r
+                       Sheet_Internal_MapClearFromSheet(search, False, px0, py0, px1, py1);\r
+                       write_sheet[write_sheets] = search;\r
+                       write_sheets++;\r
+               }\r
+               if(search == sheet){\r
+                       break;\r
+               }\r
+               search = search->next;\r
+       }\r
+\r
+\r
+       for(; write_sheets != 0; ){\r
+               write_sheets--;\r
+               Sheet_Internal_MapWriteFromSheet(write_sheet[write_sheets], False, px0, py0, px1, py1);\r
+               Sheet_Internal_RefreshSheet(write_sheet[write_sheets], px0, py0, px1, py1);\r
+       }\r
+\r
+/*\r
+       for(y = py0; y <= py1; y++){\r
+               for(x = px0; x <= px1; x++){\r
+                       if(sheet->parent->map[y * sheet->parent->size.x + x] == Null){\r
+                               search = Sheet_Internal_GetSheetFromLocation(sheet->parent, x, y);\r
+                               if(search != Null){\r
+                                       Sheet_Internal_MapWriteFromSheet(search, False, px0, py0, px1, py1);\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+*/\r
+\r
+       System_Memory_Free(write_sheet, 4 * SHEET_MAX_CHILDREN);\r
+\r
+       return 0;\r
+}\r
+\r
+//uint Sheet_Internal_RefreshSheet(UI_Sheet *sheet, int px0, int py0, int px1, int py1);\r
+//\90e\83O\83\8d\81[\83o\83\8b\8dÀ\95W\82Å\82Ì\83V\81[\83gvram\83\8a\83t\83\8c\83b\83V\83\85\81B\r
+uint Sheet_Internal_RefreshSheet(UI_Sheet *sheet, int px0, int py0, int px1, int py1)\r
+{\r
+       uint retv;\r
+\r
+       #ifdef CHNOSPROJECT_DEBUG_CALLLINK\r
+               debug("Sheet_Internal_RefreshSheet:Called from[0x%08X].\n", *((uint *)(&sheet - 1)));\r
+       #endif\r
+\r
+       if(sheet->parent == Null){\r
+               #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+                       debug("Sheet_Internal_RefreshSheet:[0x%08X]Null parent.\n", sheet);\r
+               #endif\r
+               return 1;\r
+       }\r
+\r
+       if(!sheet->parent->flags.bit.buffer_configured){\r
+               #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+                       debug("Sheet_Internal_RefreshSheet:[0x%08X]Not buffer_configured parent.\n", sheet);\r
+               #endif\r
+               return 2;\r
+       }\r
+\r
+       if(sheet->RefreshSheet == Null){\r
+               #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+                       debug("Sheet_Internal_RefreshSheet:[0x%08X]Null Refresh function.\n", sheet);\r
+               #endif\r
+               return 3;\r
+       }\r
+\r
+       if(!sheet->flags.bit.visible){\r
+               return 0;\r
+       }\r
+\r
+       retv = sheet->RefreshSheet(sheet, px0, py0, px1, py1);\r
+\r
+       if(sheet->flags.bit.autorefresh_upperlevel && sheet->parent->parent != Null){\r
+               //\96³\8cÀ\8dÄ\8bA\82ð\96h\82®\82½\82ß\81A\88ê\8e\9e\93I\82É\8fã\88Ê\8aK\91w\83I\81[\83g\83\8a\83t\83\8c\83b\83V\83\85\82ð\96³\8cø\82É\82·\82é\r
+               sheet->flags.bit.autorefresh_upperlevel = False;\r
+               Sheet_RefreshSheet(sheet->parent, px0, py0, px1, py1);\r
+               sheet->flags.bit.autorefresh_upperlevel = True;\r
+       }\r
+\r
+       if(retv != 0){\r
+               return 10 + retv;\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+//uint Sheet_Internal_SlideSub(UI_Sheet *sheet, int rpx, int rpy);\r
+//slide\8d\82\91¬\89»\83T\83u\8aÖ\90\94\81B\83V\81[\83g\82Ì\8dÀ\95W\82à\95Ï\8dX\82·\82é\81B\88ø\90\94\82Í\81A\88Ú\93®\97Ê\82ð\8e¦\82·\95\84\8d\86\82 \82è\90®\90\94\81B\r
+uint Sheet_Internal_SlideSub(UI_Sheet *sheet, int rpx, int rpy)\r
+{\r
+       int xsize, ysize;\r
+       DATA_Location2D A, B;\r
+       int apx, apy;\r
+\r
+       #ifdef CHNOSPROJECT_DEBUG_CALLLINK\r
+               debug("Sheet_Internal_SlideSub:Called from[0x%08X].\n", *((uint *)(&sheet - 1)));\r
+       #endif\r
+\r
+       xsize = (int)sheet->size.x;\r
+       ysize = (int)sheet->size.y;\r
+\r
+       if(rpx < 0){\r
+               apx = -rpx;\r
+       } else{\r
+               apx = rpx;\r
+       }\r
+\r
+       if(rpy < 0){\r
+               apy = -rpy;\r
+       } else{\r
+               apy = rpy;\r
+       }\r
+\r
+       sheet->flags.bit.visible = False;\r
+\r
+       if(apx >= xsize || apy >= ysize){\r
+               Sheet_Internal_MapRefresh(sheet, sheet->location.x, sheet->location.y, sheet->location.x + xsize - 1, sheet->location.y + ysize - 1);\r
+               sheet->location.x += rpx;\r
+               sheet->location.y += rpy;\r
+               sheet->flags.bit.visible = True;\r
+               Sheet_Internal_MapRefresh(sheet, sheet->location.x, sheet->location.y, sheet->location.x + xsize - 1, sheet->location.y + ysize - 1);\r
+\r
+               Sheet_RefreshSheet_All(sheet);\r
+               return 0;\r
+       }\r
+\r
+       if(rpx == 0){\r
+               //x\95û\8cü\82É\88Ú\93®\82µ\82È\82¢\r
+               if(rpy < 0){\r
+                       //y\82Ì\95\89\82Ì\95û\8cü\82É\88Ú\93®=\8fã\95û\8cü\r
+                       A.x = sheet->location.x;\r
+                       A.y = sheet->location.y + ysize - apy;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + xsize - 1, A.y + apy - 1);\r
+                       sheet->location.x += rpx;\r
+                       sheet->location.y += rpy;\r
+                       sheet->flags.bit.visible = True;\r
+                       A.y -= ysize;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + xsize - 1, A.y + apy - 1);\r
+               } else if(rpy > 0){\r
+                       //y\82Ì\90³\82Ì\95û\8cü\82É\88Ú\93®=\89º\95û\8cü\r
+                       A.x = sheet->location.x;\r
+                       A.y = sheet->location.y;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + xsize - 1, A.y + apy - 1);\r
+                       sheet->location.x += rpx;\r
+                       sheet->location.y += rpy;\r
+                       sheet->flags.bit.visible = True;\r
+                       A.y += ysize;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + xsize - 1, A.y + apy - 1);\r
+               } else{\r
+                       //y\95û\8cü\82É\82à\88Ú\93®\82µ\82È\82¢=\82»\82Ì\82Ü\82Ü\r
+                       sheet->flags.bit.visible = True;\r
+               }\r
+       } else if(rpx < 0){\r
+               //x\82Ì\95\89\82Ì\95û\8cü\82É\88Ú\93®\r
+               if(rpy < 0){\r
+                       //y\82Ì\95\89\82Ì\95û\8cü\82É\88Ú\93®=\8d\8fã\95û\8cü\r
+                       A.x = sheet->location.x;\r
+                       A.y = sheet->location.y + ysize - apy;\r
+                       B.x = sheet->location.x + xsize - apx;\r
+                       B.y = sheet->location.y;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + xsize - 1, A.y + apy - 1);\r
+                       Sheet_Internal_MapRefresh(sheet, B.x, B.y, B.x + apx - 1, B.y + ysize - apy);\r
+                       sheet->location.x += rpx;\r
+                       sheet->location.y += rpy;\r
+                       sheet->flags.bit.visible = True;\r
+                       A.x -= apx;\r
+                       A.y -= ysize;\r
+                       B.x -= xsize;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + xsize - 1, A.y + apy - 1);\r
+                       Sheet_Internal_MapRefresh(sheet, B.x, B.y, B.x + apx - 1, B.y + ysize - apy);\r
+               } else if(rpy > 0){\r
+                       //y\82Ì\90³\82Ì\95û\8cü\82É\88Ú\93®=\8d\89º\95û\8cü\r
+                       A.x = sheet->location.x;\r
+                       A.y = sheet->location.y;\r
+                       B.x = sheet->location.x + xsize - apx;\r
+                       B.y = sheet->location.y + apy;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + xsize - 1, A.y + apy - 1);\r
+                       Sheet_Internal_MapRefresh(sheet, B.x, B.y, B.x + apx - 1, B.y + ysize - apy);\r
+                       sheet->location.x += rpx;\r
+                       sheet->location.y += rpy;\r
+                       sheet->flags.bit.visible = True;\r
+                       A.x -= apx;\r
+                       A.y += ysize;\r
+                       B.x -= xsize;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + xsize - 1, A.y + apy - 1);\r
+                       Sheet_Internal_MapRefresh(sheet, B.x, B.y, B.x + apx - 1, B.y + ysize - apy);\r
+               } else{\r
+                       //y\95û\8cü\82É\88Ú\93®\82µ\82È\82¢=\8d\95û\8cü\r
+                       A.x = sheet->location.x + xsize - apx;\r
+                       A.y = sheet->location.y;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + apx - 1, A.y + ysize - 1);\r
+                       sheet->location.x += rpx;\r
+                       sheet->location.y += rpy;\r
+                       sheet->flags.bit.visible = True;\r
+                       A.x -= xsize;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + apx - 1, A.y + ysize - 1);\r
+               }\r
+       } else{\r
+               //x\82Ì\90³\82Ì\95û\8cü\82É\88Ú\93®\r
+               if(rpy < 0){\r
+                       //y\82Ì\95\89\82Ì\95û\8cü\82É\88Ú\93®=\89E\8fã\95û\8cü\r
+                       A.x = sheet->location.x;\r
+                       A.y = sheet->location.y + ysize - apy;\r
+                       B.x = sheet->location.x;\r
+                       B.y = sheet->location.y;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + xsize - 1, A.y + apy - 1);\r
+                       Sheet_Internal_MapRefresh(sheet, B.x, B.y, B.x + apx - 1, B.y + ysize - apy);\r
+                       sheet->location.x += rpx;\r
+                       sheet->location.y += rpy;\r
+                       sheet->flags.bit.visible = True;\r
+                       A.x += apx;\r
+                       A.y -= ysize;\r
+                       B.x += xsize;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + xsize - 1, A.y + apy - 1);\r
+                       Sheet_Internal_MapRefresh(sheet, B.x, B.y, B.x + apx - 1, B.y + ysize - apy);\r
+               } else if(rpy > 0){\r
+                       //y\82Ì\90³\82Ì\95û\8cü\82É\88Ú\93®=\89E\89º\95û\8cü\r
+                       A.x = sheet->location.x;\r
+                       A.y = sheet->location.y;\r
+                       B.x = sheet->location.x;\r
+                       B.y = sheet->location.y + apy;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + xsize - 1, A.y + apy - 1);\r
+                       Sheet_Internal_MapRefresh(sheet, B.x, B.y, B.x + apx - 1, B.y + ysize - apy);\r
+                       sheet->location.x += rpx;\r
+                       sheet->location.y += rpy;\r
+                       sheet->flags.bit.visible = True;\r
+                       A.x += apx;\r
+                       A.y += ysize;\r
+                       B.x += xsize;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + xsize - 1, A.y + apy - 1);\r
+                       Sheet_Internal_MapRefresh(sheet, B.x, B.y, B.x + apx - 1, B.y + ysize - apy);\r
+               } else{\r
+                       //y\95û\8cü\82É\88Ú\93®\82µ\82È\82¢=\89E\95û\8cü\r
+                       A.x = sheet->location.x;\r
+                       A.y = sheet->location.y;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + apx - 1, A.y + ysize - 1);\r
+                       sheet->location.x += rpx;\r
+                       sheet->location.y += rpy;\r
+                       sheet->flags.bit.visible = True;\r
+                       A.x += xsize;\r
+                       Sheet_Internal_MapRefresh(sheet, A.x, A.y, A.x + apx - 1, A.y + ysize - 1);\r
+               }\r
+       }\r
+\r
+       Sheet_RefreshMap_All(sheet);\r
+       return 0;\r
+}\r
+\r
+uint Sheet_Internal_ChangeHeight(UI_Sheet *sheet, uint height)\r
+{\r
+       UI_Sheet **search;\r
+       uint i;\r
+\r
+//At First, clear old height link.\r
+       search = &sheet->parent->child;\r
+       for(i = 0; i < SHEET_MAX_CHILDREN; i++){\r
+               if(*search == sheet){\r
+                       *search = sheet->next;\r
+                       break;\r
+               }\r
+               search = &(*search)->next;\r
+       }\r
+\r
+//Next, set new height link.\r
+       if(!sheet->flags.bit.topmost){\r
+               search = &sheet->parent->child;\r
+               for(i = 0; i < SHEET_MAX_CHILDREN; i++){\r
+                       if(i == height){\r
+                               #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+                                       debug("Sheet_Internal_ChangeHeight:Search:Break(height).\n");\r
+                               #endif\r
+                               break;\r
+                       }\r
+                       if(*search == Null){\r
+                               #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+                                       debug("Sheet_Internal_ChangeHeight:Search:Break(End of link).\n");\r
+                               #endif\r
+                               break;\r
+                       }\r
+                       if((*search)->flags.bit.topmost){\r
+                               #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+                                       debug("Sheet_Internal_ChangeHeight:Search:Break(Under topmost sheet).\n");\r
+                               #endif\r
+                               break;\r
+                       }\r
+                       search = &(*search)->next;\r
+               }\r
+       } else{ /*topmost sheet. ignore height.*/\r
+               search = &sheet->parent->child;\r
+               for(i = 0; i < SHEET_MAX_CHILDREN; i++){\r
+                       if(*search == Null){\r
+                               #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+                                       debug("Sheet_Internal_ChangeHeight:Search:Break(Top most).\n");\r
+                               #endif\r
+                               break;\r
+                       }\r
+                       search = &(*search)->next;\r
+               }\r
+       }\r
+       if(i == SHEET_MAX_CHILDREN){\r
+               #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+                       debug("Sheet_Internal_ChangeHeight:Number of sheets is over SHEET_MAX_CHILDREN.\n");\r
+               #endif\r
+               return 3;\r
+       }\r
+       sheet->next = *search;\r
+       *search = sheet;\r
+\r
+       return 0;\r
+}\r
+\r
+//SheetXX_Internal_IsVisiblePixel(UI_Sheet *sheet, int px, int py)\r
+//\90e\83V\81[\83g\93à\8dÀ\95W\82É\82¨\82¯\82é\81A\8ew\92è\82³\82ê\82½\83V\81[\83g\82Ì\83s\83N\83Z\83\8b(px, py)\82ª\89Â\8e\8b\8fó\91Ô\82Å\82 \82é\82©\82Ç\82¤\82©\82ð\95Ô\82·\81B\r
+//\88ø\90\94\83`\83F\83b\83N\82Í\82·\82×\82Ä\8fÈ\97ª\82µ\82Ä\82¢\82é\82Ì\82Å\81A\8cÄ\82Ñ\8fo\82µ\8c³\82Å\8cµ\96§\82É\83`\83F\83b\83N\82·\82é\95K\97v\82ª\82 \82é\81B\r
+\r
+//\89º\82Ì\8aÖ\90\94\82Í\81A\93§\96¾\90F\83\82\81[\83h\83I\83t\8e\9e\82É\8ew\92è\82³\82ê\82é\81A\83_\83~\81[\8aÖ\90\94\82Å\82 \82é\81B\r
+bool Sheet_Internal_IsVisiblePixel_Invalid(UI_Sheet *sheet, int px, int py)\r
+{\r
+       return True;\r
+}\r
+\r
+uint Sheet_Internal_RefreshSheet_Invalid(struct UI_SHEET *sheet, int px0, int py0, int px1, int py1)\r
+{\r
+       #ifdef CHNOSPROJECT_DEBUG_SHEET\r
+               debug("Sheet_Internal_RefreshSheet_Invalid:Invalid refresh request.\n");\r
+       #endif\r
+       return 0;\r
+}\r