Ejemplo n.º 1
0
nglNativeObjectType nglDataTypesRegistry::RegisterDataType(const nglString& rMimeType, nglNativeObjectType Type, nglDataObjectCreatorFunc pCreator)
{
#ifdef _WIN32_
  if (!Type)
    Type = RegisterClipboardFormat((LPCTSTR)(rMimeType.GetChars()));
  if (!Type)
  {
    NGL_LOG(_T("nglNativeObjectTypesRegistry"), NGL_LOG_ERROR, _T("RegisterDragAndDropNativeType: Can't RegisterClipboardFormat(\")%s\")"), rMimeType.GetChars());
  }
#endif
  
  {
    std::map<nglString, nglNativeObjectType>::iterator it = mRegisteredNativeTypes.find(rMimeType);
    
    if (it != mRegisteredNativeTypes.end())
      Type = it->second;
    else
    // dynamically generate a new Type
    {
      if (Type == 'nui3')
      {
        uint32 size = mRegisteredNativeTypes.size(); // use the size (on 24bits, we should not have any overflow:) ) of the map as a unique index
        Type = ('n' << 24) | (size & 0xffffff);
      }

      // LBTODO ?
      mDataObjectCreators[rMimeType] = pCreator;
      mRegisteredNativeTypes[rMimeType] = Type;
    }
  }
  
  return Type;
}
Ejemplo n.º 2
0
bool ProjectGenerator::MsgError(const nglString& error)
{
  nglString msg;
  msg.Format(_T("error %ls"), error.GetChars());
  NGL_OUT(msg);
  nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), _T("Project Creator"), msg, eMB_OK);
  pMessageBox->QueryUser();  
  return false;
}
Ejemplo n.º 3
0
void nglConsole::OnOutput(const nglString& rText)
{
  // 'char' mode : string buffer is considered to use the locale's encoding
  Append(rText.GetChars());

  // Write to the standard win32 console:
#ifdef USE_STANDARD_WIN32_CONSOLE
  unsigned long res = 0;
  WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),rText.GetChars(),rText.GetLength(),&res,NULL);
#endif

  // I don't care if this is slow, its really mandatory in win32.
  vector<nglString> vec;
  uint ret=rText.Tokenize(vec, _T('\n'));
  for (uint i=0; i<ret; i++)
  {
    OutputDebugString(vec[i].GetChars()); // fixme! to be removed ?
    OutputDebugString(_T("\n"));
  }
}
Ejemplo n.º 4
0
bool nglKernel::SetClipboard(const nglString& rString)
{
  if (OpenClipboard(mHWnd))
  {
    EmptyClipboard();

    HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, rString.GetLength()+1); 
    if (hglbCopy == NULL) 
    { 
      CloseClipboard(); 
      return false; 
    } 

    char* lptstrCopy = (char*)GlobalLock(hglbCopy); 
    memcpy(lptstrCopy, rString.GetChars(), rString.GetLength()+1); 
    GlobalUnlock(hglbCopy); 

    SetClipboardData(CF_TEXT, hglbCopy); 
    CloseClipboard();
    return true;
  }
  return false;
}
Ejemplo n.º 5
0
void nuiMessageBox::Init(const nglString& rTitle, nuiWidget* pContents, nuiMessageBoxType type, bool showIcon)
{
  SetObjectClass(_T("nuiMessageBox"));
  mType = type;
  
  mKeyDown = false;

  mClickedButton = ButtonCancel;
  

  nuiVBox* pVBox = new nuiVBox();
  pVBox->SetExpand(nuiExpandShrinkAndGrow);
  pVBox->SetObjectName(_T("nuiMessageBox::Client"));
  AddChild(pVBox);
  
  nuiLabel* pTitle = new nuiLabel(rTitle);
  pTitle->SetObjectName(_T("nuiMessageBox::Title"));
  pTitle->SetObjectClass(_T("nuiMessageBox::Title"));
  pVBox->AddCell(pTitle);
  
  nuiHBox* pHBox = new nuiHBox(2);
  pHBox->SetExpand(nuiExpandShrinkAndGrow);
  pHBox->SetObjectName(_T("nuiMessageBox::Contents"));
  pVBox->AddCell(pHBox);
  pVBox->SetCellExpand(pVBox->GetNbCells()-1, nuiExpandShrinkAndGrow);

  if (showIcon)
  {
    nuiSimpleContainer* pIcon = new nuiSimpleContainer();
    nglString objectName;
    objectName.Format(_T("nuiMessageBox::Icon"), rTitle.GetChars());
    pIcon->SetObjectName(objectName);
    pHBox->SetCell(0, pIcon, nuiCenter);
  }
  
  pHBox->SetCell(1, pContents);
  pHBox->SetCellExpand(1, nuiExpandShrinkAndGrow);
  
  mpBtnBox = new nuiHBox();
  mpBtnBox->SetObjectName(_T("nuiMessageBox::ButtonBox"));
  pVBox->AddCell(mpBtnBox);

  mpBtnBox->AddCell(NULL);
  mpBtnBox->SetCellExpand(mpBtnBox->GetNbCells()-1, nuiExpandShrinkAndGrow);

  
  switch (mType)
  {
    case eMB_OK:
      mpBtnBox->AddCell(CreateOK());
      mpBtnBox->SetPosition(nuiCenter);
      break;
      
    case eMB_Cancel:
      mpBtnBox->AddCell(CreateCancel());
      mpBtnBox->SetPosition(nuiCenter);
      break;
      
    case eMB_OKCancel:
      mpBtnBox->AddCell(CreateOK());
      mpBtnBox->AddCell(CreateCancel());
      break;
      
    case eMB_RetryOKCancel:
      mpBtnBox->AddCell(CreateRetry());
      mpBtnBox->AddCell(CreateOK());
      mpBtnBox->AddCell(CreateCancel());
      break;
      
    case eMB_YesNo:
      mpBtnBox->AddCell(CreateYes());
      mpBtnBox->AddCell(CreateNo());
      break;
      
    case eMB_Custom:
      break;
  }
  
  
  SetPosition(nuiCenter);
  GetTopLevel()->SetFocus(this);
  
  // default decoration
  nuiDefaultDecoration::MessageBox(this);
}
Ejemplo n.º 6
0
void nuiAudioDeviceManager::RegisterAPI(const nglString& rAPIName, nuiAudioDeviceAPI* pAPI)
{
  NGL_LOG(_T("nuiAudioDeviceManager"), NGL_LOG_DEBUG, _T("RegisterAPI('%s') [0x%x]\n"), rAPIName.GetChars(), pAPI);
  nuiAudioAPIMap::const_iterator end = mAPIs.end();
  nuiAudioAPIMap::const_iterator it = mAPIs.find(rAPIName);
  if (it != end)
  {
    nuiAudioDeviceAPI* pOldAPI = it->second;
    NGL_LOG(_T("nuiAudioDeviceManager"), NGL_LOG_DEBUG, _T("\tkilling previous entry for this API [0x%p]\n"), pOldAPI);
    delete pOldAPI;
  }
  mAPIs[rAPIName] = pAPI;
  Update();
}
Ejemplo n.º 7
0
int nuiTCPClient::Send(const nglString& rString)
{
  return Send((uint8*)rString.GetChars(), rString.GetLength());
}
Ejemplo n.º 8
0
size_t nuiPipe::Write(const nglString& rString)
{
  return Write((const uint8*)rString.GetChars(), rString.GetLength());
}
Ejemplo n.º 9
0
size_t nuiTCPClient::BufferedSend(const nglString& rString, bool BufferOnly)
{
  return BufferedSend((uint8*)rString.GetChars(), rString.GetLength(), BufferOnly);
}
Ejemplo n.º 10
0
bool nglPath_SetVolume(nglPathVolume& rVolume,
                       nglString& rMPoint,
                       nglString& rDevice,
                       nglString& rFSType,
                       nglString& rOptions)
{
  rVolume.mPath     = nglPath(rMPoint);
  rVolume.mFlags = nglPathVolume::Offline;
  rVolume.mType  = nglPathVolume::eTypeUnknown;

  if ((rMPoint == _T("none")) ||
      (rMPoint == _T("/")) ||
      (rMPoint == _T("/boot")) ||
      (rMPoint == _T("/usr")) ||
      (rMPoint == _T("/usr/local")) ||
      (rMPoint == _T("/var")) ||
      (rMPoint == _T("/tmp")) ||
      (rMPoint == _T("/home")))
  {
    rVolume.mFlags |= nglPathVolume::System;
  }

  if (!rDevice.Compare(_T("/dev/hd"), 0, 7))
  {
    int controler = (rDevice[7] - 'a') / 2 + 1;
    int channel = (rDevice[7] - 'a') % 2;
    int partition = rDevice[8] - '0';
    rVolume.mComment.Format(_T("%s on %d%s partition (%s on %d%s IDE controler)"),
      rFSType.GetChars(),
      partition, _intrank(partition),
      channel ? _T("slave") : _T("master"),
      controler, _intrank(controler));
  }
  else
  if (!rDevice.Compare(_T("/dev/sd"), 0, 7))
  {
    int dev = rDevice[7] - 'a';
    int partition = rDevice[8] - '0';
    rVolume.mComment.Format(_T("%s on %d%s partition (%d%s SCSI device)"),
      rFSType.GetChars(),
      partition, _intrank(partition),
      dev, _intrank(dev));
    rVolume.mType = nglPathVolume::eTypeHD;
  }
  else
  if ((!rDevice.Compare(_T("/dev/sr"), 0, 7)) ||
      (!rDevice.Compare(_T("/dev/sg"), 0, 7)))
  {
    int dev = rDevice[7] - '0' + 1;
    rVolume.mComment.Format(_T("%s (%d%s SCSI device)"),
      rFSType.GetChars(),
      dev, _intrank(dev));
      rVolume.mFlags |= nglPathVolume::Removable;
      rVolume.mType = nglPathVolume::eTypeCD;
  }
  else
  if (!rDevice.Compare(_T("/dev/fd"), 0, 7))
  {
    int dev = rDevice[7] - '0' + 1;
    rVolume.mComment.Format(_T("%d%s floppy"), dev, _intrank(dev));
    rVolume.mFlags |= nglPathVolume::Removable;
    rVolume.mType = nglPathVolume::eTypeFloppy;
  }

  if (rFSType == _T("smbfs"))
  {
    rVolume.mComment.Format(_T("%s (SMB)"), rDevice.GetChars());
    rVolume.mType = nglPathVolume::eTypeNetwork;
  }
  else
  if (rFSType == _T("nfs"))
  {
    rVolume.mComment.Format(_T("%s (NFS)"), rDevice.GetChars());
    rVolume.mType = nglPathVolume::eTypeNetwork;
  }
  else
  if ((rFSType == _T("proc")) ||
      (rFSType == _T("devfs")) ||
      (rFSType == _T("usbdevfs")) ||
      (rFSType == _T("devpts")))
  {
    rVolume.mComment =  rFSType;
    rVolume.mFlags |= nglPathVolume::System;
  }

  if (nglPath_IsRO(rOptions))
    rVolume.mFlags |= nglPathVolume::ReadOnly;

  return true;
}