//
// ICListSlider::Activate
//
// Activate the control
//
Bool ICListSlider::Activate()
{
  // Activate the ICSlider component first, this will initialise the client rect
  if (ICSlider::Activate())
  {
    // Check and setup the vars
    for (List<ListBoxWatcher>::Iterator i(&listBoxes); *i; i++)
    {
      ListBoxWatcher *ptr = *i;

      ActivateVar(ptr->count, VarSys::VI_INTEGER);
      ActivateVar(ptr->top  , VarSys::VI_INTEGER);
      ActivateVar(ptr->vis  , VarSys::VI_INTEGER);
    }

    // Force recalculation of knob size
    knobPct = -1.0F;
    resizeKnob = TRUE;

    // Set up initial values
    GetSliderValue();

    return (TRUE);
  }
  else
  {
    return (FALSE);
  }
}
    //
    // MapObj::Activate
    //
    Bool MapObj::Activate()
    {
      if (IControl::Activate())
      {
        ActivateVar(hitPoints);
        ActivateVar(armour);

        return (TRUE);
      }
      else
      {
        return (FALSE);
      }
    }
  //
  // Activate
  //
  // Activate this control
  //
  Bool Mission::Activate()
  {
    if (ICWindow::Activate())
    {
      ActivateVar(defaultRule);
      ActivateVar(fixedRule);

      // Find required controls
      ruleList = IFace::Find<ICDropList>("RuleList", this, TRUE)->GetListBox();
      ruleList->DeleteAllItems();

      // Add the 'no rule' option
      ruleList->AddTextItem("None", NULL);

      // Get all rule sets
      if (const NBinTree<Mods::Mod> *rules = Mods::GetMods(Mods::Types::RuleSet))
      {
        // Add each one to the list
        for (NBinTree<Mods::Mod>::Iterator r(rules); *r; ++r)
        {
          ruleList->AddTextItem((*r)->GetName().str, TRANSLATE(((*r)->GetDescription().str)));       
        }
      }

      addonList = IFace::Find<ICListBox>("AddonList", this, TRUE);
      addonList->DeleteAllItems();

      // Get all addons
      if (const NBinTree<Mods::Mod> *addons = Mods::GetMods(Mods::Types::Addon))
      {
        // Add each on to the list
        for (NBinTree<Mods::Mod>::Iterator a(addons); *a; ++a)
        {
          addonList->AddTextItem((*a)->GetName().str, TRANSLATE(((*a)->GetDescription().str)));
        }
      }

      // Download the settings from the mission
      Download();

      return (TRUE);
    }

    return (FALSE);
  }
  //
  // Activate
  //
  // Activate this control
  //
  Bool Login::Activate()
  {
    if (ICWindow::Activate())
    {
      // Activate the vars
      ActivateVar(user);
      ActivateVar(newUser);

      // Find the list of users
      userList = IFace::Find<ICListBox>("UserList", this, TRUE);

      // Build the list of users
      BuildUserList();

      return (TRUE);
    }

    return (FALSE);
  }
//
// ColorButton::Activate
//
Bool ColorButton::Activate()
{
  if (ICButton::Activate())
  {
    // Check and setup the var
    ActivateVar(var, VarSys::VI_INTEGER);
    return (TRUE);
  }

  return (FALSE);
}
  //
  // Activate
  //
  // Activate this control
  //
  Bool TeamList::Activate()
  {
    if (ICWindow::Activate())
    {
      // Find all the important controls
      teamList = IFace::Find<ICListBox>("TeamList", this);
      if (!teamList.Alive())
      {
        ERR_CONFIG(("Could not find 'TeamList' in the TeamList"))
      }

      // Build the list of teams
      BuildList();

      // Activate vars
      ActivateVar(currentTeam);
      ActivateVar(createTeam);
 
      return (TRUE);
    }

    return (FALSE);
  }
    //
    // HandleEvent
    //
    // Pass any events to the registered handler
    //
    U32 Color::HandleEvent(Event &e)
    {
      if (e.type == ::Input::EventID())
      {
        // Input events
        switch (e.subType)
        {
          case ::Input::MOUSEBUTTONDOWN:
          case ::Input::MOUSEBUTTONDBLCLK:
          {
            if (e.input.code == ::Input::LeftButtonCode())
            {
              Point<S32> mouse(e.input.mouseX, e.input.mouseY);
              if (InClient(mouse))
              {
                // Figure out which day (if any) was clicked on
                mouse = ScreenToClient(mouse);

                colorSelected->SetIntegerValue(mouse.x / GetSize().y);
              }
            }
            break;
          }
        }
      }
      else if (e.type == IFace::EventID())
      {
        switch (e.subType)
        {
          case IFace::NOTIFY:
          {
            // Do specific handling
            switch (e.iface.p1)
            {
              case IControlNotify::Activating:
              {
                // Activate vars
                ActivateVar(colorCurrent);
                ActivateVar(colorSelected);
                break;
              }

              case IControlNotify::Deactivated:
              {
                // Deactivate vars
                colorCurrent->Deactivate();
                colorSelected->Deactivate();
                break;
              }

              case ContextMsg::SetTeam:
              {
                teamId = e.iface.p2;
                break;
              }

              case ContextMsg::ClearTeam:
              {
                teamId = U32_MAX;
                break;
              }
            }
          }
        }
      }

      return (IControl::HandleEvent(e));  
    }