#include "XBox.h" void TXBox::Init(int x1, int y1, int aW, int aH, int OwnerX, int OwnerY, u32 aColor) { #define CH 30 //Caption Height unsigned short Left,Right, Top, Bottom, Width, Height, i; Bound.SetBySize(OwnerX + x1, OwnerY + y1, aW, aH); Left = Bound.Left +3; Top = Bound.Top+3; Width = aW - 7; Height = aH - 7; Right = Bound.Right -4; Bottom = Bound.Bottom -4; Caption.Init(Left,Top,Width, CH, 0, 0, clWhite, clMaroon); Content.Set(Left, Top+CH, Right, Bottom); Color = aColor; #undef CH Caption.Border.Color = clGray; OutlineColor = clGray; TextColor = clNearBlack; SelectedColor = clBlue; LineSpacing = 36; CheckPointX = Content.Left +10; TextPstX = Content.Left + 40; ItemsTopY = Content.Top + 15; CheckWidgetSize = 8; TextPixelWidth = 240; Items.FocusIndex =0; Items.SelectedIndex =-1; BoxType = btRadioGroup; } void TXBox::ReDrawItems() { int i, x1, x2, y1, y2; if(Items.Count > drgMAX_COUNT) Items.Count =drgMAX_COUNT; if(CheckWidgetSize > 12)CheckWidgetSize =12; x1 = CheckPointX + Content.Left + 12; y1 = ItemsTopY + Content.Top + 12; x2 = TextPstX + Content.Left; y2 = ItemsTopY + Content.Top; if(BoxType == btRadioGroup){ for(i=0; i 0) ){ Items.SelectedIndex --; ReDrawItems(); } }else if(aKey == VK_RIGHT){ if( (Items.SelectedIndex < Items.Count) && (Items.SelectedIndex > 0) ){ Items.SelectedIndex --; ReDrawItems(); } }else if(aKey == VK_UP){ if(Items.SelectedIndex >0){ Items.SelectedIndex--; ReDrawItems(); } }else if(aKey == VK_DOWN){ if(Items.SelectedIndex <(Items.Count-1)){ Items.SelectedIndex++; ReDrawItems(); } }else if(aKey == VK_F1){ Items.SelectedIndex++; if(Items.SelectedIndex >= Items.Count){ Items.SelectedIndex = 0; } ReDrawItems(); }else if(aKey == VK_TAB){ Items.SelectedIndex++; if(Items.SelectedIndex >= Items.Count){ Items.SelectedIndex = 0; } ReDrawItems(); } if(aKey == VK_EXECUTE){ //Save Data Here }else if(aKey == VK_RETURN){ aMsg = guiMsgReturn; } return aMsg; }else if(BoxType == btGroupBox){ if(aKey == VK_LEFT){ if( Items.SelectedIndex < Items.Count ){ if(Items.CheckList[Items.SelectedIndex]) Items.CheckList[Items.SelectedIndex] =0; else Items.CheckList[Items.SelectedIndex] =1; ReDrawItems(); } }else if(aKey == VK_RIGHT){ if( Items.SelectedIndex < Items.Count ){ if(Items.CheckList[Items.SelectedIndex]) Items.CheckList[Items.SelectedIndex] =0; else Items.CheckList[Items.SelectedIndex] =1; ReDrawItems(); } }else if(aKey == VK_UP){ if(Items.SelectedIndex >0){ Items.SelectedIndex--; ReDrawItems(); } }else if(aKey == VK_DOWN){ if(Items.SelectedIndex <(Items.Count-1)){ Items.SelectedIndex++; ReDrawItems(); } }else if(aKey == VK_F1){ if( (Items.SelectedIndex < Items.Count) && (Items.SelectedIndex > -1) ){ if(Items.CheckList[Items.SelectedIndex]) Items.CheckList[Items.SelectedIndex] =0; else Items.CheckList[Items.SelectedIndex] =1; ReDrawItems(); } }else if(aKey == VK_TAB){ Items.SelectedIndex++; if(Items.SelectedIndex >= Items.Count){ Items.SelectedIndex = 0; } ReDrawItems(); } if(aKey == VK_EXECUTE){ //Save Data Here }else if(aKey == VK_RETURN){ aMsg = guiMsgReturn; } return aMsg; } return aMsg; } void TXBox::sDrawBoxBorder(int x, int y, int x2, int y2, char *chr, int tLen, int aEn, int aSel, unsigned int bClr) { int aW, aH, aTW; unsigned int aClr, aTClr; aTW = tLen * 12 +12; if(aSel){ aClr = clBlue; aTClr = clBlue; }else{ if(aEn){ aClr = clGray; aTClr = clGray; }else{ aClr = clSilver; aTClr = clSilver; } } aW = x2 - x +1; aH = y2 - y +1; VertLineRender(x, y+12, aH-12, aClr); VertLineRender(x+1, y+12, aH-12, aClr); VertLineRender(x2, y+12, aH-12, aClr); VertLineRender(x2-1, y+12, aH-12, aClr); HorizLineRender(x, y+12, 6, aClr); HorizLineRender(x, y+12+1, 6, aClr); HorizLineRender(x, y2, aW, aClr); HorizLineRender(x, y2 -1, aW, aClr); HorizLineRender(x + aTW +6, y+12, aW -6 -aTW, aClr); HorizLineRender(x + aTW +6, y+12+1, aW -6 -aTW, aClr); TextRender_string24(x + 8, y, aTClr, bClr, chr); }