コード例 #1
0
    bool do_horizontal(UINT event_type, POINT pt, 
      dom::element &splitter_el, dom::element &first, dom::element &second,
      dom::element &parent_el)
    {
      // which element width we will change?

      RECT rc_parent = parent_el.get_location();
      RECT rc = first.get_location();

      // if width of first element is less than half of parent we
      // will change its width.
      bool change_first = 
        (rc.right - rc.left) < (rc_parent.right - rc_parent.left)/2;


      if(!change_first)
        rc = second.get_location();

      if(event_type == MOUSE_DOWN)
      {
         pressed_offset = pt.x;
         splitter_el.set_capture();
         return false; // don't need updates
      }
      // mouse move handling
      if(pt.x == pressed_offset)
        return false; // don't need updates

      int width = rc.right - rc.left;

      wchar_t buf[32];
      if(change_first)
      {
        width += (pt.x - pressed_offset);
        if(width >= 0)
        {
          first.delay_measure();
          second.delay_measure();

          swprintf(buf,L"%dpx", width);
          first.set_style_attribute("width",buf);
          second.set_style_attribute("width",L"100%%");
        }
      }
      else
      {
        width -= (pt.x - pressed_offset);
        if(width >= 0)
        {
          first.delay_measure();
          second.delay_measure();

          swprintf(buf,L"%dpx", width);
          first.set_style_attribute("width",L"100%%");
          second.set_style_attribute("width",buf);
        }
      }
      return true; // need update
    }
コード例 #2
0
    bool do_vertical(UINT event_type, POINT pt, 
      dom::element &splitter_el, dom::element &first, dom::element &second,
      dom::element &parent_el)
    {
      RECT rc_parent = parent_el.get_location();
      RECT rc = first.get_location();

      // if width of first element is less than half of parent we
      // will change its width.
      bool change_first = 
        (rc.bottom - rc.top) < (rc_parent.bottom - rc_parent.top)/2;

      if(!change_first)
        rc = second.get_location();

      if(event_type == MOUSE_DOWN)
      {
         pressed_offset = pt.y;
         splitter_el.set_capture();
         return false; // don't need updates
      }
      // mouse move handling
      if(pt.y == pressed_offset)
        return false; // don't need updates

      int height = rc.bottom - rc.top;

      wchar_t buf[32];

      if(change_first)
      {
        height += (pt.y - pressed_offset);
        if(height >= 0)
        {
          first.delay_measure();
          second.delay_measure();

          swprintf(buf,L"%dpx", height);
          first.set_style_attribute("height",buf);
          second.set_style_attribute("height",L"100%%");
        }
      }
      else
      {
        height -= (pt.y - pressed_offset);
        if(height >= 0)
        {
          first.delay_measure();
          second.delay_measure();

          swprintf(buf,L"%dpx", height);
          first.set_style_attribute("height",L"100%%");
          second.set_style_attribute("height",buf);
        }
      }
      return true;
    }