예제 #1
0
  virtual Bool Read(GeListNode* node, HyperFile* hf, LONG level) override
  {
    Bool result = super::Read(node, hf, level);
    if (!result) return result;

    // VERSION 0

    // Read the custom icon from the HyperFile.
    Bool hasImage;
    if (!hf->ReadBool(&hasImage)) return false;

    if (hasImage)
    {
      if (m_customIcon)
        m_customIcon->FlushAll();
      else
        m_customIcon = BaseBitmap::Alloc();
      if (!hf->ReadImage(m_customIcon)) return false;
    }
    else if (m_customIcon)
      BaseBitmap::Free(m_customIcon);

    // VERSION 1000

    if (level >= 1000)
    {
      if (!hf->ReadBool(&m_protected)) return false;
      if (m_protected)
      {
        if (!hf->ReadString(&m_protectionHash)) return false;
      }
    }

    return result;
  }
예제 #2
0
void PaletteColor::DrawMsg(Int32 x1,Int32 y1,Int32 x2,Int32 y2, const BaseContainer &msg)
{
	OffScreenOn();
	BaseBitmap *bitmap = m_normalBitmap;
	switch(m_hoverState){
		case HOVER_CENTER:
			bitmap = m_hoverBitmap;
			break;
		case HOVER_LEFT:
			bitmap = m_leftHoverBitmap;
			break;
		case HOVER_RIGHT:
			bitmap = m_rightHoverBitmap;
			break;
        case HOVER_DELETE:
            bitmap = m_crossHoverBitmap;
            break;
	}
	DrawBitmap(bitmap,x1,y1,bitmap->GetBw(),bitmap->GetBh(),0,0,bitmap->GetBw(),bitmap->GetBh(),BMP_NORMAL);
}
예제 #3
0
  /// Called from Message() for MSG_GETCUSTOMICON.
  void OnGetCustomIcon(BaseObject* op, GetCustomIconData* data)
  {
    IconData* dIcon = data->dat;
    BaseBitmap* bmp;
    LONG xoff, yoff, xdim, ydim;

    if (m_customIcon)
    {
      if (dIcon->bmp)
      {
        // We can not free the previous bitmap, because it leads to a
        // crash. We copy the custom icon bitmap to the already
        // present bitmap.
        bmp = dIcon->bmp;
        m_customIcon->CopyTo(bmp);
      }
      else
      {
        bmp = m_customIcon->GetClone();
      }
      xoff = 0;
      yoff = 0;
      xdim = bmp->GetBw();
      ydim = bmp->GetBh();
    }
    else
    {
      bmp = dIcon->bmp;
      if (!bmp)
      {
        bmp = BaseBitmap::Alloc();
        bmp->Init(64, 64);
      }
      if (GetIcon(Ocontainer, dIcon))
      {
        dIcon->bmp->CopyTo(bmp);
      }
      xoff = dIcon->x;
      yoff = dIcon->y;
      xdim = dIcon->w;
      ydim = dIcon->h;
    }

    if (bmp)
    {
      // Adjust the IconData.
      dIcon->x = xoff;
      dIcon->y = yoff;
      dIcon->w = xdim;
      dIcon->h = ydim;
      dIcon->bmp = bmp;
      data->filled = true;
    }
    else
    {
      data->filled = false;
    }
  }
예제 #4
0
  virtual Bool CopyTo(NodeData* nDest, GeListNode* node, GeListNode* destNode,
        COPYFLAGS flags, AliasTrans* at) override
  {
    Bool result = super::CopyTo(nDest, node, destNode, flags, at);
    if (!result) return result;
    ContainerObject* dest = (ContainerObject*) nDest;

    // Copy the custom icon to the new NodeData.
    if (dest->m_customIcon)
      BaseBitmap::Free(dest->m_customIcon);
    if (m_customIcon)
      dest->m_customIcon = m_customIcon->GetClone();

    // And the other stuff.. :-)
    dest->m_protected = m_protected;
    dest->m_protectionHash = m_protectionHash;

    return result;
  }
예제 #5
0
  /// Called from Message() for MSG_DESCRIPTION_COMMAND.
  void OnDescriptionCommand(BaseObject* op, DescriptionCommand* cmdData)
  {
    BaseDocument* doc = op->GetDocument();
    const AutoUndo au(doc);
    const LONG id = cmdData->id[0].id;

    switch (id)
    {
      case NRCONTAINER_PACKUP:
        ToggleProtect(op);
        break;
      case NRCONTAINER_ICON_LOAD:
      {
        if (m_protected) break;

        // Ask the user for an image-file.
        Filename flname;
        flname.SetDirectory(GeGetC4DPath(C4D_PATH_DESKTOP));
        Bool ok = flname.FileSelect(FILESELECTTYPE_IMAGES, FILESELECT_LOAD,
            GeLoadString(IDS_SELECTICON));

        if (ok)
        {
          // Ensure the destination bitmap is allocated.
          if (!m_customIcon)
            m_customIcon = BaseBitmap::Alloc();
          else
            m_customIcon->FlushAll();

          // If it is still null here, allocation failed.
          if (!m_customIcon)
            MessageDialog(GeLoadString(IDS_INFO_OUTOFMEMORY));
          else
          {
            IMAGERESULT res = m_customIcon->Init(flname);
            if (res != IMAGERESULT_OK)
            {
              MessageDialog(IDS_INFO_INVALIDIMAGE);
              BaseBitmap::Free(m_customIcon);
            }
            else
            {
              // Scale the bitmap down to 64x64 pixels.
              BaseBitmap* dest = BaseBitmap::Alloc();
              const LONG size = CONTAINEROBJECT_ICONSIZE;
              dest->Init(size, size);
              m_customIcon->ScaleIt(dest, 256, true, true);
              BaseBitmap::Free(m_customIcon);
              m_customIcon = dest;
            }
          }
        }
        break;
      }
      case NRCONTAINER_ICON_CLEAR:
      {
        if (m_protected) break;
        if (m_customIcon)
        {
          // TODO: We possibly require a flag for removing the icon
          // on the next MSG_GETCUSTOMICON message, because Cinema
          // still references this bitmap.
          BaseBitmap::Free(m_customIcon);
        }
        break;
      }
    }
  }