www.pudn.com > CommSettings.rar > UnitOptions.cpp


//--------------------------------------------------------------------------- 
 
#include  
#pragma hdrstop 
 
#include "UnitOptions.h" 
#include "TestSetData.h" 
#include "yb_base.h" 
//--------------------------------------------------------------------------- 
#pragma package(smart_init) 
#pragma resource "*.dfm" 
TFormOptions *FormOptions; 
//--------------------------------------------------------------------------- 
__fastcall TFormOptions::TFormOptions(TComponent* Owner) 
    : TForm(Owner) 
{ 
  Font->Name    = AppLang.FontName; 
  Font->Charset = AppLang.Charset ; 
  Font->Size    = AppLang.FontSize; 
 
  TMsgStrings Msgs; 
  Caption = Msgs.Str_Caption; 
 
  gbLang    ->Caption = Msgs.Str_Language; 
  gbFontSize->Caption = Msgs.Str_FontSize; 
 
  rbLanAuto->Caption = ""; //Msgs.Msg[Msgs.Str_Auto       ]; 
  rbLanEnu ->Caption = ""; //Msgs.Msg[Msgs.Str_English    ]; 
  rbLanChs ->Caption = ""; //Msgs.Msg[Msgs.Str_SimpChinese]; 
  rbLanCht ->Caption = ""; //Msgs.Msg[Msgs.Str_TridChinese]; 
 
  rbFsAuto  ->Caption = Msgs.Str_Auto  ; 
  rbFsSmall ->Caption = Msgs.Str_Small ; 
  rbFsMedium->Caption = Msgs.Str_Medium; 
  rbFsLarge ->Caption = Msgs.Str_Large ; 
 
  BnOK    ->Caption = Msgs.Str_OK    ; 
  BnCancel->Caption = Msgs.Str_Cancel; 
 
  switch(AppCfg.Cfg.Language) 
   { 
     case TAppCfg::lgEnu: rbLanEnu->Checked = true; break; 
     case TAppCfg::lgChs: rbLanChs->Checked = true; break; 
     case TAppCfg::lgCht: rbLanCht->Checked = true; break; 
     default:            rbLanAuto->Checked = true; break; 
   } 
 
  switch(AppCfg.Cfg.FontSize) 
   { 
     case TAppCfg::fsSmall : rbFsSmall ->Checked = true; break; 
     case TAppCfg::fsMedium: rbFsMedium->Checked = true; break; 
     case TAppCfg::fsLarge : rbFsLarge ->Checked = true; break; 
     default               : rbFsAuto  ->Checked = true; break; 
   } 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormOptions::BnCancelClick(TObject *Sender) 
{ 
  ModalResult = IDCANCEL; 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormOptions::BnOKClick(TObject *Sender) 
{ 
  if(rbLanEnu->Checked) 
    AppCfg.Cfg.Language = TAppCfg::lgEnu; 
  else if(rbLanChs->Checked) 
    AppCfg.Cfg.Language = TAppCfg::lgChs; 
  else if(rbLanCht->Checked) 
    AppCfg.Cfg.Language = TAppCfg::lgCht; 
  else 
    AppCfg.Cfg.Language = TAppCfg::lgAuto; 
 
  //------ 
  if(rbFsSmall->Checked) 
    AppCfg.Cfg.FontSize = TAppCfg::fsSmall; 
  else if(rbFsMedium->Checked) 
    AppCfg.Cfg.FontSize = TAppCfg::fsMedium; 
  else if(rbFsLarge->Checked) 
    AppCfg.Cfg.FontSize = TAppCfg::fsLarge; 
  else 
    AppCfg.Cfg.FontSize = TAppCfg::fsAuto; 
 
  //------ 
  AppCfg.ApplyLang(); 
  AppCfg.Save(); 
  ModalResult = IDOK; 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormOptions::ImageLangAutoMouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  if(Button == mbLeft) 
   { 
     rbLanAuto->Checked = true; 
   } 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormOptions::ImageLangEnglishMouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  if(Button == mbLeft) 
   { 
     rbLanEnu->Checked = true; 
   } 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormOptions::ImageLangChsMouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  if(Button == mbLeft) 
   { 
     rbLanChs->Checked = true; 
   } 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormOptions::ImageLangChtMouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  if(Button == mbLeft) 
   { 
     rbLanCht->Checked = true; 
   } 
} 
//--------------------------------------------------------------------------- 
 
__fastcall TFormOptions::TMsgStrings::TMsgStrings() 
{ 
  switch(AppLang.LangType) 
   { 
     case TAppLang::ltGbk: 
          _Msg = _Msg_Chs; 
          break; 
 
     case TAppLang::ltBig5: 
          _Msg = _Msg_Cht; 
          break; 
 
     default: 
          _Msg = _Msg_Enu; 
          break; 
   } 
} 
//--------------------------------------------------------------------------- 
 
AnsiString __fastcall TFormOptions::TMsgStrings::fGetMsg(int mt) 
{ 
  return AppLang.FromGBK(_Msg[mt]); 
} 
//--------------------------------------------------------------------------- 
 
char *TFormOptions::TMsgStrings::_Msg_Chs[] = 
{ 
  "选项"            , //Str_Caption      =  0 
  "语言"            , //Str_Language     =  1 
  "字体"            , //Str_FontSize     =  2 
  "编辑"            , //Str_EditStatus   =  3 
  "回车"            , //Str_PressEnter   =  4 
  "自动"            , //Str_Auto         =  5 
  "英语"            , //Str_English      =  6 
  "简体中文"        , //Str_SimpChinese  =  7 
  "繁体中文"        , //Str_TridChinese  =  8 
  "小"              , //Str_Small        =  9 
  "中"              , //Str_Medium       = 10 
  "大"              , //Str_Large        = 11 
  "确定"            , //Str_OK           = 12 
  "取消"            , //Str_Cancel       = 13 
}; 
//--------------------------------------------------------------------------- 
 
char *TFormOptions::TMsgStrings::_Msg_Cht[] = 
{ 
  "選項"            , //Str_Caption      =  0 
  "語言"            , //Str_Language     =  1 
  "字體"            , //Str_FontSize     =  2 
  "編輯"            , //Str_EditStatus   =  3 
  "回車"            , //Str_PressEnter   =  4 
  "自動"            , //Str_Auto         =  5 
  "英語"            , //Str_English      =  6 
  "簡體中文"        , //Str_SimpChinese  =  7 
  "繁體中文"        , //Str_TridChinese  =  8 
  "小"              , //Str_Small        =  9 
  "中"              , //Str_Medium       = 10 
  "大"              , //Str_Large        = 11 
  "確定"            , //Str_OK           = 12 
  "取消"            , //Str_Cancel       = 13 
}; 
//--------------------------------------------------------------------------- 
 
char *TFormOptions::TMsgStrings::_Msg_Enu[] = 
{ 
  "Options"            , //Str_Caption      =  0 
  "Language"           , //Str_Language     =  1 
  "Font Size"          , //Str_FontSize     =  2 
  "Edit"               , //Str_EditStatus   =  3 
  "Press Enter"        , //Str_PressEnter   =  4 
  "Auto"               , //Str_Auto         =  5 
  "English"            , //Str_English      =  6 
  "Simplified Chinese" , //Str_SimpChinese  =  7 
  "Triditional Chinese", //Str_TridChinese  =  8 
  "Small"              , //Str_Small        =  9 
  "Medium"             , //Str_Medium       = 10 
  "Large"              , //Str_Large        = 11 
  "OK"                 , //Str_OK           = 12 
  "Cancel"             , //Str_Cancel       = 13 
}; 
//---------------------------------------------------------------------------