Example #1
0
void LoadGlobalSettings(void)
{
	g_Settings->LogIconSize = 10;
	g_Settings->bLogLimitNames = db_get_b(NULL, CHAT_MODULE, "LogLimitNames", 1) != 0;
	g_Settings->bShowTime = db_get_b(NULL, CHAT_MODULE, "ShowTimeStamp", 1) != 0;
	g_Settings->bSoundsFocus = db_get_b(NULL, CHAT_MODULE, "SoundsFocus", 0) != 0;
	g_Settings->bShowTimeIfChanged = (BOOL)db_get_b(NULL, CHAT_MODULE, "ShowTimeStampIfChanged", 0) != 0;
	g_Settings->bTimeStampEventColour = (BOOL)db_get_b(NULL, CHAT_MODULE, "TimeStampEventColour", 0) != 0;
	g_Settings->iEventLimit = db_get_w(NULL, CHAT_MODULE, "LogLimit", 100);
	g_Settings->dwIconFlags = db_get_dw(NULL, CHAT_MODULE, "IconFlags", 0x0000);
	g_Settings->dwTrayIconFlags = db_get_dw(NULL, CHAT_MODULE, "TrayIconFlags", 0x1000);
	g_Settings->dwPopupFlags = db_get_dw(NULL, CHAT_MODULE, "PopupFlags", 0x0000);
	g_Settings->LoggingLimit = db_get_w(NULL, CHAT_MODULE, "LoggingLimit", 100);
	g_Settings->bLoggingEnabled = (BOOL)db_get_b(NULL, CHAT_MODULE, "LoggingEnabled", 0) != 0;
	g_Settings->bFlashWindow = (BOOL)db_get_b(NULL, CHAT_MODULE, "FlashWindow", 0) != 0;
	g_Settings->bFlashWindowHighlight = (BOOL)db_get_b(NULL, CHAT_MODULE, "FlashWindowHighlight", false) != 0;
	g_Settings->bHighlightEnabled = (BOOL)db_get_b(NULL, CHAT_MODULE, "HighlightEnabled", 1) != 0;
	g_Settings->crLogBackground = db_get_dw(NULL, CHAT_MODULE, "ColorLogBG", GetSysColor(COLOR_WINDOW));
	g_Settings->crUserListColor = db_get_dw(NULL, CHATFONT_MODULE, "Font18Col", RGB(0, 0, 0));
	g_Settings->crUserListHeadingsColor = db_get_dw(NULL, CHATFONT_MODULE, "Font19Col", RGB(170, 170, 170));
	g_Settings->bStripFormat = (BOOL)db_get_b(NULL, CHAT_MODULE, "StripFormatting", 0) != 0;
	g_Settings->bTrayIconInactiveOnly = (BOOL)db_get_b(NULL, CHAT_MODULE, "TrayIconInactiveOnly", 1) != 0;
	g_Settings->bPopupInactiveOnly = (BOOL)db_get_b(NULL, CHAT_MODULE, "PopupInactiveOnly", 1) != 0;
	g_Settings->bAddColonToAutoComplete = (BOOL)db_get_b(NULL, CHAT_MODULE, "AddColonToAutoComplete", 1) != 0;
	g_Settings->iPopupStyle = db_get_b(NULL, CHAT_MODULE, "PopupStyle", 1);
	g_Settings->iPopupTimeout = db_get_w(NULL, CHAT_MODULE, "PopupTimeout", 3);
	g_Settings->crPUBkgColour = db_get_dw(NULL, CHAT_MODULE, "PopupColorBG", GetSysColor(COLOR_WINDOW));
	g_Settings->crPUTextColour = db_get_dw(NULL, CHAT_MODULE, "PopupColorText", 0);
	g_Settings->bShowContactStatus = db_get_b(NULL, CHAT_MODULE, "ShowContactStatus", 0) != 0;
	g_Settings->bContactStatusFirst = db_get_b(NULL, CHAT_MODULE, "ContactStatusFirst", 0) != 0;

	LoadColors();

	if (ci.OnLoadSettings)
		ci.OnLoadSettings();

	InitSetting(&g_Settings->pszTimeStamp, "HeaderTime", _T("[%H:%M]"));
	InitSetting(&g_Settings->pszTimeStampLog, "LogTimestamp", _T("[%d %b %y %H:%M]"));
	InitSetting(&g_Settings->pszIncomingNick, "HeaderIncoming", _T("%n:"));
	InitSetting(&g_Settings->pszOutgoingNick, "HeaderOutgoing", _T("%n:"));
	InitSetting(&g_Settings->pszHighlightWords, "HighlightWords", _T("%m"));

	InitSetting(&g_Settings->pszLogDir, "LogDirectory", _T("%miranda_logpath%\\%proto%\\%userid%.log"));
	g_Settings->bLogIndentEnabled = db_get_b(NULL, CHAT_MODULE, "LogIndentEnabled", 1) != 0;

	LOGFONT lf;
	if (g_Settings->UserListFont)
		DeleteObject(g_Settings->UserListFont);
	LoadMsgDlgFont(18, &lf, NULL);
	g_Settings->UserListFont = CreateFontIndirect(&lf);

	if (g_Settings->UserListHeadingsFont)
		DeleteObject(g_Settings->UserListHeadingsFont);
	LoadMsgDlgFont(19, &lf, NULL);
	g_Settings->UserListHeadingsFont = CreateFontIndirect(&lf);

	SetIndentSize();
}
Example #2
0
// ============================================================================================
// ================================ Texture helpers ===========================================
// ============================================================================================
bool Renderer::LoadAssets()
{
	if ( !LoadFontAndText() )
		return false;

	LoadColors();

	if( !InitializeTextures() )
		return false;

	return true;
}
Example #3
0
void LoadLogFonts(void)
{
	for (int i=0; i < OPTIONS_FONTCOUNT; i++)
		LoadMsgDlgFont(i, &ci.aFonts[i].lf, &ci.aFonts[i].color);
	LoadColors();

	if (ci.hListBkgBrush != NULL)
		DeleteObject(ci.hListBkgBrush);
	ci.hListBkgBrush = CreateSolidBrush(g_Settings->crUserListBGColor);

	if (ci.hListSelectedBkgBrush != NULL)
		DeleteObject(ci.hListSelectedBkgBrush);
	ci.hListSelectedBkgBrush = CreateSolidBrush(g_Settings->crUserListSelectedBGColor);
}
Example #4
0
void InitMap (char M)
{
    char x, y;
    char c;
    char a;

    for (y = 0; y < MAP_SIZE_Y; y++)
    {
        for (x = 0; x < MAP_SIZE_X; x++)
        {
            c = MAP[M][y+1][x];
            a = 0;
            switch (c)
            {
            case ' ':   a = OBJECT_SPACE;   break;  // space
            case '.':   a = OBJECT_DIRT;   break;  // dirt
            case 'o':
            case 'O':   a = OBJECT_BOULDER;   break;  // boulder
            case '=':   a = OBJECT_WALL;   break;  // wall
            case '+':   a = OBJECT_JEWEL;   break;  // jewel
            case 'm':
            case 'M':   a = OBJECT_BORN; m_cManX = x;  m_cManY = y;  break;  // man
            case 'h':
            case 'H':   a = OBJECT_HOME;   break;  // man
            case 'x':   
            case 'X':   a = OBJECT_BUTTERFLY;   break;  // butterfly
            case 'f':   
            case 'F':   a = OBJECT_FIREFLY;   break;  // firefly
            case 0x23:  a = OBJECT_TIT_WALL;   break;  // titanium wall

            }
            SetMap(y, x, a);
        }
    }

    LoadColors(M);


    m_cBornTimer = 20;
    m_cNeededJewels = MAP[M][0][32];
    m_cJewels = 0;
    m_bScrMovedX = 1;   // Уходим на нужное место
    m_bScrMovedY = 1;
    m_bAlive = 0;
    str_cpy(m_strStatusBar, STR_STATUS_BAR);
    m_bEnd = false;
}
Example #5
0
void COFSNcDlg2::LoadSkin()
{
	CComPtr<IXMLDOMDocument> pDoc = NULL;
	CComPtr<IXMLDOMNode> pRoot = NULL;
	
	LoadSkinXML(&pDoc, &pRoot);
	if(pRoot)
	{
		CRect r, rMin, rMax;
		r.SetRectEmpty();
		rMin.SetRectEmpty();
		rMax.SetRectEmpty();
		LoadWindow(pRoot, r, rMin, rMax);
//		SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER);
		LoadColors(pRoot);
		LoadPictures(pRoot);
		LoadSkin(pRoot);
		
		SetMinTrackSize(rMin.Size());
		if(!rMax.IsRectEmpty())
			SetMaxTrackSize(rMax.Size());
	}
}
Example #6
0
SaveGraph()
{
   short tx=rasInfo->RxOffset,ty=rasInfo->RyOffset;
   
   Scrollit(-tx,-ty);
   DisplaySprites(FALSE);

   fileRequester->fr_Hail="Save Graph as file";
   strcpy(fileRequester->fr_Dir,"pw:graph");
   strcpy(fileRequester->fr_File,lastgraph); /* Last maze loaded */
   LoadColors(&PlayScreen->ViewPort,FR_COLORS);

#if 1 || REGISTERED_USER
   if(FileRequest(fileRequester))
   {
      strcpy(fr_path,fileRequester->fr_Dir);
      strcpy(fr_name,fileRequester->fr_File);
      strcpy(filename,fr_path);
      if ( !strchr("/:\0",fr_path[strlen(fr_path)-1]) && strlen(fr_path))
         strcat(filename,"/");
      if (strlen(filename) > 1 && strlen(fr_name))
      {
         strcat(filename,fr_name);
         WriteGraph(filename);
      }
   }
#else
   AutoRequest(PlayWindow,&registertext[0],&regpostext,&regnegtext,0L,0L,320,61);
#endif
   SetMazeColors();
   Scrollit(tx,ty);
   ScreenToFront(PlayScreen);
   DisplaySprites(sprites_on);
   ToggleScreenToFront(1);

   return 0;
}
Example #7
0
void LoadPlugs(const TCHAR* ModuleName)
{
  HANDLE hSScr=Info.SaveScreen(0,0,-1,-1);
  {
    const TCHAR* MsgItems[]={GetMsg(mName),GetMsg(mLoading)};
    Info.Message(&MainGuid,&MessageLoadingGuid,0,NULL,MsgItems,sizeof(MsgItems)/sizeof(MsgItems[0]),0);
  }
  TCHAR PluginsFolder[MAX_PATH],PluginsMask[MAX_PATH],*NamePtr;
  lstrcpy(UnknownPluginName,GetMsg(mUnknown));
  lstrcpy(PluginsFolder,ModuleName);
  NamePtr=(TCHAR*)FSF.PointToName(PluginsFolder);
  lstrcpy(NamePtr,_T("\\Formats\\"));
  wsprintf(PluginsMask,_T("%s*.fmt"),PluginsFolder);

  HANDLE FindHandle;
  WIN32_FIND_DATA fdata;
  int Done=((FindHandle=FindFirstFile(PluginsMask,&fdata))==INVALID_HANDLE_VALUE);
  while(!Done)
  {
    TCHAR PluginName[MAX_PATH];
    wsprintf(PluginName,_T("%s%s"),PluginsFolder,fdata.cFileName);
    HMODULE hModule=LoadLibrary(PluginName);
    if (hModule!=NULL)
    {
      struct PluginItem CurPlugin;
      CurPlugin.hModule=hModule;
      CurPlugin.Type=0;
      CurPlugin.pLoadSyntaxModule=(PLUGINLOADSYNTAXMODULE)GetProcAddress(hModule,"LoadSyntaxModule");
      CurPlugin.pSetColorizeInfo=(PLUGINSETCOLORIZEINFO)GetProcAddress(hModule,"SetColorizeInfo");
      CurPlugin.pGetParams=(PLUGINGETPARAMS)GetProcAddress(hModule,"GetParams");
      CurPlugin.pColorize=(PLUGINCOLORIZE)GetProcAddress(hModule,"Colorize");
      CurPlugin.pInput=(PLUGININPUT)GetProcAddress(hModule,"Input");
      CurPlugin.pGetSyntaxCount=(PLUGINGETSYNTAXCOUNT)GetProcAddress(hModule,"GetSyntaxCount");
      CurPlugin.pExit=(PLUGINEXIT)GetProcAddress(hModule,"Exit");

      if(CurPlugin.pLoadSyntaxModule)
        CurPlugin.Type=CurPlugin.pLoadSyntaxModule(PluginName,&Info);
      int accept_plug=true;
      if(CurPlugin.pSetColorizeInfo)
      {
        ColorizeInfo lInfo;
        lInfo.size=sizeof(lInfo);
        lInfo.version=VER_ALL;
        lInfo.api=VER_API;
        lInfo.cachestr=PARSER_CACHESTR;
        lstrcpy(lInfo.folder,PluginsFolder);
        lInfo.pAddColor=addcolor;
        lInfo.pGetLine=getline;
        lInfo.pAddState=addstate;
        lInfo.pGetCursor=getcursor;
        lInfo.pCallParser=callparser;
        accept_plug=CurPlugin.pSetColorizeInfo(&lInfo);
      }

      if(accept_plug)
      {
        unsigned long subcount=1;
        if(CurPlugin.pGetSyntaxCount)
          subcount=CurPlugin.pGetSyntaxCount();

        if(subcount)
        {
          struct PluginItem *NewPluginsData=(struct PluginItem *)realloc(PluginsData,sizeof(*PluginsData)*(PluginsCount+subcount));
          if (NewPluginsData==NULL)
            break;
          PluginsData=NewPluginsData;
          for(unsigned long i=0;i<subcount;i++)
          {
            CurPlugin.Index=i;
            CurPlugin.Mask=NULL;
            CurPlugin.Start=NULL;
            CurPlugin.Params=0;
            const TCHAR *mask,*start,*name=NULL;
            TCHAR buff_mask[2048],buff_start[2048];
            lstrcpy(buff_mask,_T("")); lstrcpy(buff_start,_T(""));
            if(CurPlugin.pGetParams)
            {
              CurPlugin.Params=CurPlugin.pGetParams(CurPlugin.Index,PAR_GET_PARAMS,NULL);
              CurPlugin.pGetParams(CurPlugin.Index,PAR_GET_NAME,(const char**)&name);
              //load mask
              if(name&&(CurPlugin.Params&PAR_MASK_CACHE))
              {
                if(!CurPlugin.pGetParams(CurPlugin.Index,PAR_GET_MASK,(const char**)&mask))
                  mask=_T("");
                lstrcpy(buff_mask,mask);
                if(CurPlugin.Params&PAR_MASK_STORE)
                {
                  CFarSettings settings(MainGuid);
                  settings.Change(PLUGIN_MASK_KEY);
                  settings.Get(name,buff_mask,ArraySize(buff_mask));
                }
              }
              //load starts
              if(name&&(CurPlugin.Params&PAR_FILESTART_CACHE))
              {
                if(!CurPlugin.pGetParams(CurPlugin.Index,PAR_GET_FILESTART,(const char**)&start))
                  start=_T("");
                lstrcpy(buff_start,start);
                if(CurPlugin.Params&PAR_FILESTART_STORE)
                {
                  CFarSettings settings(MainGuid);
                  settings.Change(PLUGIN_START_KEY);
                  settings.Get(name,buff_start,ArraySize(buff_start));
                }
              }
            }
            if(name) CurPlugin.Name=name;
            else CurPlugin.Name=UnknownPluginName;
            if(lstrlen(buff_mask))
              CurPlugin.Mask=(TCHAR*)malloc((lstrlen(buff_mask)+1)*sizeof(TCHAR));
            if(CurPlugin.Mask)
              lstrcpy(CurPlugin.Mask,buff_mask);
            if(lstrlen(buff_start))
              CurPlugin.Start=(TCHAR*)malloc((lstrlen(buff_start)+1)*sizeof(TCHAR));
            if(CurPlugin.Start)
              lstrcpy(CurPlugin.Start,buff_start);
            if(CurPlugin.pGetParams)
            { //load colors
              int ColorCount; ABColor* Colors;
              if((CurPlugin.Params&PAR_COLORS_STORE)&&CurPlugin.pGetParams(CurPlugin.Index,PAR_GET_COLOR_COUNT,(const char **)&ColorCount)&&CurPlugin.pGetParams(CurPlugin.Index,PAR_GET_COLOR,(const char **)&Colors))
              {
                LoadColors(name,Colors,ColorCount);
              }
            }
            PluginsData[PluginsCount]=CurPlugin;
            PluginsCount++;
          }
        }
      }
      else
        FreeLibrary(hModule);
    }
    Done=!FindNextFile(FindHandle,&fdata);
  }
  FindClose(FindHandle);
  Info.RestoreScreen(hSScr);
}
Example #8
0
/**
 * Creates a control from the given XMLNode as a child of the given
 * parent.
 *
 * @param form the WndForm object
 * @param LookUpTable The parent CallBackTable
 * @param node The XMLNode that represents the control
 * @param eDialogStyle The parent's dialog style
 */
static Window *
LoadChild(WndForm &form, ContainerWindow &parent, Color background_color,
          CallBackTableEntry *LookUpTable,
          XMLNode node, const DialogStyle eDialogStyle,
          int bottom_most=0)
{
  Window *window = NULL;

  // Determine name, coordinates, width, height
  // and caption of the control
  const TCHAR* Name = GetName(node);
  const TCHAR* Caption = GetCaption(node);
  RECT rc = parent.get_client_rect();
  ControlPosition pos = GetPosition(node, rc, bottom_most);
  if (!pos.no_scaling)
    pos.x = ScaleWidth(pos.x, eDialogStyle);

  ControlSize size = GetSize(node, rc, pos);
  if (!size.no_scaling)
    size.cx = ScaleWidth(size.cx, eDialogStyle);

  WindowStyle style;

  if (!StringToIntDflt(node.getAttribute(_T("Visible")), 1))
    style.hide();

  if (StringToIntDflt(node.getAttribute(_T("Border")), 0))
    style.border();

  bool advanced = _tcschr(Caption, _T('*')) != NULL;

  // PropertyControl (WndProperty)
  if (_tcscmp(node.getName(), _T("Edit")) == 0) {
    WndProperty *W;
    int CaptionWidth;
    bool ReadOnly;
    bool MultiLine;

    // Determine the width of the caption field
    CaptionWidth = StringToIntDflt(node.getAttribute(_T("CaptionWidth")), 0);

    if (Layout::ScaleSupported())
      CaptionWidth = Layout::Scale(CaptionWidth);

    CaptionWidth = ScaleWidth(CaptionWidth, eDialogStyle);

    // Determine whether the control is multiline or readonly
    MultiLine = StringToIntDflt(node.getAttribute(_T("MultiLine")), 0);
    ReadOnly = StringToIntDflt(node.getAttribute(_T("ReadOnly")), 0);

    // Load the event callback properties
    WndProperty::DataChangeCallback_t DataNotifyCallback =
      (WndProperty::DataChangeCallback_t)
      GetCallBack(LookUpTable, node, _T("OnDataNotify"));

    WindowControl::OnHelpCallback_t OnHelpCallback =
      (WindowControl::OnHelpCallback_t)
      GetCallBack(LookUpTable, node, _T("OnHelp"));

    // Create the Property Control
    style.control_parent();

    EditWindowStyle edit_style;
    if (ReadOnly)
      edit_style.read_only();
    else
      edit_style.tab_stop();

    if (is_embedded() || Layout::scale_1024 < 2048)
      /* sunken edge doesn't fit well on the tiny screen of an
         embedded device */
      edit_style.border();
    else
      edit_style.sunken_edge();

    if (MultiLine) {
      edit_style.multiline();
      edit_style.vscroll();
    }

    window = W = new WndProperty(parent, Caption,
                                 pos.x, pos.y, size.cx, size.cy,
                                 CaptionWidth, background_color,
                                 style, edit_style,
                                 DataNotifyCallback);

    // Set the fore- and background color
    LoadColors(*W, node);

    // Set the help function event callback
    W->SetOnHelpCallback(OnHelpCallback);

    // Load the help text
    W->SetHelpText(StringToStringDflt(node.getAttribute(_T("Help")), _T("")));

    // If the control has (at least) one DataField child control
    if (node.nChildNode(_T("DataField")) > 0){
      // -> Load the first DataField control
      DataField *data_field =
        LoadDataField(node.getChildNode(_T("DataField"), 0),
                      LookUpTable, eDialogStyle);

      if (data_field != NULL)
        // Tell the Property control about the DataField control
        W->SetDataField(data_field);
    }

  // ButtonControl (WndButton)
  } else if (_tcscmp(node.getName(), _T("Button")) == 0) {
    // Determine ClickCallback function
    WndButton::ClickNotifyCallback_t ClickCallback =
      (WndButton::ClickNotifyCallback_t)
      GetCallBack(LookUpTable, node, _T("OnClick"));

    // Create the ButtonControl

    ButtonWindowStyle bstyle(style);
    bstyle.tab_stop();
    bstyle.multiline();

    window = new WndButton(parent, Caption,
                           pos.x, pos.y, size.cx, size.cy,
                           bstyle, ClickCallback);

  } else if (_tcscmp(node.getName(), _T("CheckBox")) == 0) {
    // Determine ClickCallback function
    CheckBoxControl::ClickNotifyCallback_t ClickCallback =
      (CheckBoxControl::ClickNotifyCallback_t)
      GetCallBack(LookUpTable, node, _T("OnClick"));

    // Create the CheckBoxControl

    style.tab_stop();

    window = new CheckBoxControl(parent, Caption,
                                 pos.x, pos.y, size.cx, size.cy,
                                 style,
                                 ClickCallback);

  // SymbolButtonControl (WndSymbolButton) not used yet
  } else if (_tcscmp(node.getName(), _T("SymbolButton")) == 0) {
    // Determine ClickCallback function
    WndButton::ClickNotifyCallback_t ClickCallback =
      (WndButton::ClickNotifyCallback_t)
      GetCallBack(LookUpTable, node, _T("OnClick"));

    // Create the SymbolButtonControl

    style.tab_stop();

    window = new WndSymbolButton(parent, Caption,
                                 pos.x, pos.y, size.cx, size.cy,
                                 style, background_color,
                                 ClickCallback);

  // PanelControl (WndPanel)
  } else if (_tcscmp(node.getName(), _T("Panel")) == 0) {
    // Create the PanelControl

    style.control_parent();

    PanelControl *frame = new PanelControl(parent,
                                           pos.x, pos.y, size.cx, size.cy,
                                           background_color, style);

    window = frame;

    // Load children controls from the XMLNode
    LoadChildrenFromXML(form, *frame, background_color,
                        LookUpTable, &node, eDialogStyle);

  // KeyboardControl
  } else if (_tcscmp(node.getName(), _T("Keyboard")) == 0) {
    KeyboardControl::OnCharacterCallback_t CharacterCallback =
      (KeyboardControl::OnCharacterCallback_t)
      GetCallBack(LookUpTable, node, _T("OnCharacter"));

    // Create the KeyboardControl
    KeyboardControl *kb =
      new KeyboardControl(parent,
                          pos.x, pos.y, size.cx, size.cy, background_color,
                          CharacterCallback, style);

    window = kb;
  // DrawControl (WndOwnerDrawFrame)
  } else if (_tcscmp(node.getName(), _T("Canvas")) == 0) {
    // Determine DrawCallback function
    WndOwnerDrawFrame::OnPaintCallback_t PaintCallback =
      (WndOwnerDrawFrame::OnPaintCallback_t)
      GetCallBack(LookUpTable, node, _T("OnPaint"));

    // Create the DrawControl
    WndOwnerDrawFrame* canvas =
      new WndOwnerDrawFrame(parent,
                            pos.x, pos.y, size.cx, size.cy,
                              style, PaintCallback);

    window = canvas;

  // FrameControl (WndFrame)
  } else if (_tcscmp(node.getName(), _T("Label")) == 0){
    // Create the FrameControl
    WndFrame* frame = new WndFrame(parent,
                                   pos.x, pos.y, size.cx, size.cy,
                                   background_color, style);

    // Set the caption
    frame->SetCaption(Caption);

    window = frame;

  // ListBoxControl (WndListFrame)
  } else if (_tcscmp(node.getName(), _T("List")) == 0){
    // Determine ItemHeight of the list items
    unsigned item_height =
      Layout::Scale(StringToIntDflt(node.getAttribute(_T("ItemHeight")), 18));

    // Create the ListBoxControl

    style.tab_stop();

    if (is_embedded() || Layout::scale_1024 < 2048)
      /* sunken edge doesn't fit well on the tiny screen of an
         embedded device */
      style.border();
    else
      style.sunken_edge();

    window = new WndListFrame(parent,
                              pos.x, pos.y, size.cx, size.cy,
                              style,
                              item_height);

  // TabControl (Tabbed)
  } else if (_tcscmp(node.getName(), _T("Tabbed")) == 0) {
    // Create the TabControl

    style.control_parent();

    TabbedControl *tabbed = new TabbedControl(parent,
                                              pos.x, pos.y, size.cx, size.cy,
                                              style);

    window = tabbed;

    const unsigned n = node.nChildNode();
    for (unsigned i = 0; i < n; ++i) {
      // Load each child control from the child nodes
      Window *child = LoadChild(form, *tabbed, background_color,
                                LookUpTable,
                                node.getChildNode(i), eDialogStyle);
      if (child != NULL)
        tabbed->AddClient(child);
        continue;
    }
  } else if (_tcscmp(node.getName(), _T("Custom")) == 0) {
    // Create a custom Window object with a callback
    CreateWindowCallback_t create =
        (CreateWindowCallback_t)GetCallBack(LookUpTable, node, _T("OnCreate"));
    if (create == NULL)
      return NULL;

    window = create(parent,
                    pos.x, pos.y, size.cx, size.cy, style);
  }

  if (window != NULL) {
    if (!string_is_empty(Name))
      form.AddNamed(Name, window);

    if (advanced)
      form.AddAdvanced(window);

    form.AddDestruct(window);
  }

  return window;
}
Example #9
0
/**
 * This function returns a WndForm created either from the ressources or
 * from the XML file in XCSoarData(if found)
 * @param LookUpTable The CallBackTable
 * @param FileName The XML filename to search for in XCSoarData
 * @param Parent The parent window (e.g. XCSoarInterface::main_window)
 * @param resource The resource to look for
 * @return The WndForm object
 */
WndForm *
LoadDialog(CallBackTableEntry *LookUpTable, SingleWindow &Parent,
               const TCHAR* resource)
{
  WndForm *form = NULL;

  // Find XML file or resource and load XML data out of it
  XMLNode node = xmlOpenResourceHelper(resource);

  // TODO code: put in error checking here and get rid of exits in xmlParser
  // If XML error occurred -> Error messagebox + cancel
  if (node.isEmpty()) {
    ShowXMLError();
    return NULL;
  }

  // If the main XMLNode is of type "Form"
  if (_tcsicmp(node.getName(), _T("Form")) != 0)
    // Get the first child node of the type "Form"
    // and save it as the dialog node
    node = node.getChildNode(_T("Form"));

  // If Node does not exists -> Error messagebox + cancel
  if (node.isEmpty()) {
    ShowXMLError();
    return NULL;
  }

  // Determine the dialog style of the dialog
  DialogStyle dialog_style = GetDialogStyle(node);

  // Determine the dialog size
  const TCHAR* Caption = GetCaption(node);
  const RECT rc = Parent.get_client_rect();
  ControlPosition pos = GetPosition(node, rc);
  ControlSize size = GetSize(node, rc, pos);

  InitScaleWidth(size, rc, dialog_style);

  // Correct dialog size and position for dialog style
  switch (dialog_style) {
  case dsFullWidth:
    pos.x = rc.left;
    pos.y = rc.top;
    size.cx = rc.right - rc.left; // stretch form to full width of screen
    size.cy = rc.bottom - rc.top;
    break;
  case dsScaledCentered:
    pos = SetPositionCentered(pos, rc, size);
    break;
  }

  // Create the dialog
  WindowStyle style;
  style.hide();
  style.control_parent();

  form = new WndForm(Parent, pos.x, pos.y, size.cx, size.cy, Caption, style);

  // Set fore- and background colors
  LoadColors(*form, node);

  // Load the children controls
  LoadChildrenFromXML(*form, *form, LookUpTable, &node, dialog_style);

  // If XML error occurred -> Error messagebox + cancel
  if (XMLNode::GlobalError) {
    ShowXMLError();
    delete form;
    return NULL;
  }

  // Return the created form
  return form;
}
Example #10
0
void Task_Animate (void)
{
    static      bit     bSlow = 0;      // Some objects animated slow
    static      char    s_cPhase = 0;   // Animation phase: 0..3
    static near char    x, y;           // Declared as 'near' to increaze speed
    static near char    A, B;           // Current map point and object
    static      char   *pmap;

                char    temp;

    //for (;;)
    {
        CLRWDT();
        OS_Bsem_Set(BS_MAP_FREE);       // Free map

        OS_Flag_Wait_11(i_cStep, 0x04);
        OS_Flag_Set_0(i_cStep, 0x04);

        OS_Bsem_Wait(BS_MAP_FREE);

        bSlow = !bSlow;
        if (!bSlow) s_cPhase++;


        //------------------------------------------------------------------------------
        //  When all jewels are picked, change all colors to light white to
        //  immitate a flash blink.
        //------------------------------------------------------------------------------
        
        if (m_bBlinked)
        {
            LoadColors(m_cCurMap);
            m_bBlinked = 0;
        }
        //------------------------------------------------------------------------------
        //  Restore colors after flashing
        //------------------------------------------------------------------------------
        
        if (m_bBlink)                                       // Зажигаем вспышку
        {
            for (x = 0; x < 32; x++) m_Colors[x] = CL_LTWHITE;
            m_bBlinked = 1; // Говорим, что ее нужно погасить при следующем вызове
            m_bBlink = 0;
        }
        

        //------------------------------------------------------------------------------
        //  Make animation for all elements on map
        //------------------------------------------------------------------------------
        
        pmap = (char*)m_Map;

        for (y = 0; y < MAP_SIZE_Y; y++) 
        {   
            OS_Yield();                       
            for (x = 0; x < MAP_SIZE_X; x++) 
            {
                A = *pmap;                      // Current element
                B = A & 0x1F;
                if (B < 4) goto NEXT;           // Space, dirt, boulder, wall
                if (B  == 0x1F) goto NEXT;      // Last stage of bang
                
                if (B == OBJECT_MAN_EYES && bSlow)
                {   
                    A = OBJECT_MAN;
                    goto CONTINUE;
                }
                
                B &= 0x1C;
                if (B == OBJECT_LEFT_MAN || B == OBJECT_RIGHT_MAN || (B==OBJECT_BANG && bSlow))
                {
                    // Running man
                    temp = A + 1;
                    A &= ~3;
                    A |= (temp & 3);
                    goto CONTINUE;
                }
                
                
                if (!bSlow) continue;
                
                if (B == OBJECT_JEWEL || B == OBJECT_BUTTERFLY || B == OBJECT_FIREFLY)
                {
                    A &= ~3;
                    A |= (s_cPhase & 3);
                    goto CONTINUE;
                }
                
                if (B == OBJECT_TIT_WALL && (A & 0xC0))     // Home
                {
                    if (((A & 0x80) && (m_cNeededJewels <= m_cJewels)) || 
                        ((A & 0x40) && m_cBornTimer))
                    {
                        A ^= 1;
                        goto CONTINUE;
                    }
                }
            CONTINUE:;
                *pmap = A;
            NEXT:;
                pmap++;
            }
        }
    }
}