//*****************************************************************************
// CLASS GeneralPage :: verifyAndSave() - save database info
//*****************************************************************************
IBase :: Boolean GeneralPage :: verifyAndSave( IString& theString,
                                               IString& theEntry,
                                               const IString theName )
{

    /*  verify data for correctness */

    if ((theName.length() == 0) && (employeeId.text().length() == 0 ))
        return true;

    // save person information
    if ((theName.length() == 0 ) && (theName.isAlphanumeric()))
        Key = employeeId.text();
    else
       Key = theName;

    // prime the page from data area
    setEmployeeData();

    //-------------------------------------------------------------------------
    // Save the query
    // The key is either what was passed in or the employee number
    //-------------------------------------------------------------------------
    if (theName.length()>0)
       employeeData.save(theName);
    else
       if ( (!isAquery) &&
            (Key.length()> 0 ))
             employeeData.save(Key);

     return true;
}
/******************************************************************************
* Class AccountPage :: verifyAndSave - Save page information to the database  *
******************************************************************************/
bool AccountPage::verifyAndSave( IString& theString,
                                           IString& theEntry,
                                           const IString saveName )
{
/*-----------------------------------------------------------------------------
| If there is no data or is a query, return.                                  |
-----------------------------------------------------------------------------*/
   if ( ( ! saveName.length() )
        && ( ! Key.length() )
        || isAquery )
      return true;

/*-----------------------------------------------------------------------------
| If able to retrieve the container information,                              |
|  save the information to the database based on the key or query name.       |
-----------------------------------------------------------------------------*/
   if ( setAcctData() )
   {
      if ( ( saveName.length() > 0 ) && ( saveName.isAlphanumeric() ) )
         acctData.save( saveName );
       else
         if ( ( Key.length() > 0 ) && ( Key.isAlphanumeric() ) )
            acctData.save( Key );
   }

   return true;
};
/******************************************************************************
* Class AccountPage :: addAcct - Add the account information to the container *
******************************************************************************/
bool AccountPage::addAcct( IString& user, IString& node )
{
   bool
      rc = true;

/*-----------------------------------------------------------------------------
| Create a container text cursor based on the user ID.                        |
-----------------------------------------------------------------------------*/
   IContainerControl::TextCursor
      txtCur( *pCnr, IString( user ), true, false, true );

/*-----------------------------------------------------------------------------
| Start at the beginning of the cursor.                                       |
| If the cursor contains a duplicate, set the return code to false.           |
-----------------------------------------------------------------------------*/
   for ( txtCur.setToFirst();
         txtCur.isValid();
         txtCur.setToNext() )
   {
      if ( ( (AcctCnrObj*) txtCur.current() )->getNode() == node )
      {
         rc = false;
         break;
      }
   }

/*-----------------------------------------------------------------------------
| If the object doesn't exist,                                                |
|  Add the object to the database.                                            |
|  Create an account container object.                                        |
|  Add the object to the container.                                           |
|  Refresh the container.                                                     |
-----------------------------------------------------------------------------*/
   if ( rc )
   {
      if ( isAquery )
      {
         if ( ! user.length() )
            user = "******";
         if ( ! node.length() )
            node = "*";
      }

      acctData.putItem( user, node, LAcctData::add );
      pAcctCnrObj = new AcctCnrObj( user, node );
      pCnr->addObject( pAcctCnrObj );
      pCnr->refresh();
   }

   return rc;
}
// -------------------------------------------------------------------------
// QueryInfo Class :: inRange() - match check having a range
// -------------------------------------------------------------------------
IBase :: Boolean QueryInfo :: inRange(const IString &c1
                                     ,const IString &c2
                                     ,const IString &range)
{

   if (c2.length() == 0)
      return false;

    IString matchItem, compareItem;

    matchItem   = chopOff(c1);
    compareItem = chopOff(c2);

   if ( (c1.isDigits()) && (c2.isDigits()) ) {
      // compare 2 numbers
      long d1=c1.asInt();
      long d2=c2.asInt();
      return compareIt(d1, d2, range);
   }
   else {
      ADate *date1 = new ADate(c1);
      ADate *date2 = new ADate(c2);
      return compareIt(date1, date2, range);
   } /* endif */

};
Exemplo n.º 5
0
void setMovieWindowHandle(IWindowHandle movieWindowHandle)
{
  if (movieWindowHandle)
  {
    IString unqualifiedFileName = movieFrame->quickFlick->fileName();
    unsigned long lastDelimiterIndex = unqualifiedFileName.lastIndexOf('\\');
    unqualifiedFileName = unqualifiedFileName.subString(lastDelimiterIndex + 1, unqualifiedFileName.length() - lastDelimiterIndex);
    movieFrame->title.setObjectText("QuickFlick");
    movieFrame->title.setViewText(unqualifiedFileName);
    movieFrame->addToWindowList();

    movieFrame->movieWindow = IWindow::windowWithHandle(movieWindowHandle);
    IDMHandler::enableDropOn(movieFrame->movieWindow);
    movieFrame->movieWindow->setItemProvider(movieFrame);
  }

  if (movieFrame->quickFlick->logoWindowHandle())
  {
    movieFrame->logo = IWindow::windowWithHandle(movieFrame->quickFlick->logoWindowHandle());
    IDMHandler::enableDropOn(movieFrame->logo);
    movieFrame->logo->setItemProvider(movieFrame);
  }

  if (movieWindowHandle && QuickFlick::nonEmbeddedDisplay() == QF_NONEMBED_TOFIT)
    movieFrame->reset();
  else
    movieFrame->showWindow();
}
/******************************************************************************
* class FontSelectHandler::enter - Handle combo box selections
******************************************************************************/
bool FontSelectHandler::enter( IControlEvent& event)
{
  IString fontChoice =  ((IComboBox*)event.controlWindow())->text();
  if(fontChoice.length())
  {
/*----------------------------------------------------------------------------|
| Set the new font                                                            |
-----------------------------------------------------------------------------*/
     editorFrame.editorFont().setName(fontChoice);
     editorFrame.editorWindow().setFont(editorFrame.editorFont());
  }
  return true;
}
Exemplo n.º 7
0
Boolean QFMotionPlayer::command(ICommandEvent &event)
{
  IString saveAsFileName;
  FOURCC ioProc;

  switch (event.commandId())
  {
    case PLAY_BUTTON_ID:
      handlePlayCommand();
      return true;

    case MI_MOTION_SAVEAS:
      saveAsFileName = qf.showSaveAsDialog(window_p);
      if (saveAsFileName.length())
      {
        if (movieWindow)
          movieWindow->disable();
        if (qf.controller())
          qf.controller()->disableControls();
        if (isPositionTracking)
        {
          isPositionTracking = false;
          moviePlayer->stopPositionTracking();
          moviePlayer->deletePendingEvents(IMMDevice::positionChangeEvent);
        }

        moviePlayer->stop();

        ((IMMDigitalVideo*)moviePlayer)->saveAs(saveAsFileName, IMMDevice::wait);

        autoStartPerformed = false;
        atEnd = true;
        if (qf.controller())
          qf.controller()->setArmPercent(.0);
        prepareThread = new IThread(new IThreadMemberFn<QFMotionPlayer>(*this, QFMotionPlayer::prepare));
      }
      return true;

    default:
      return false;
  }
}
ListBoxItem :: ListBoxItem ( IDMSourceOperation *srcOp,
                             IListBox           *srcLB,
                             unsigned            index )
  : IDMItem( srcOp,
             IDM::text,
             IDMItem:: moveable | IDMItem::copyable,
             none )
  {
  // Item contents is the list box item text.
  this -> setContents( srcLB->itemText( index ) );
  // Item object is the item index.
  this -> setObject( (void*)index );
  // Try to use rfText...
  IString
    name = this -> generateSourceName(),
    rfs   = rfForThisProcess();
  if ( name.length() )
    { // Text fits, use rfText.
    this -> setSourceName( name );
    rfs += IString( "," ) + IDM::rfText;
    }
  else
    { // Text doesn't fit, use rfSharedMem instead.
    rfs += IString( "," ) + IDM::rfSharedMem;
    this -> setRequiresPreparation();
    }
  // Set up RMFs; we support dropping on shredder, too.
  this -> setRMFs( rmfsFrom( IDM::rmLibrary, rfs ) );
  this -> addRMF( IDM::rmDiscard, IDM::rfUnknown );

  // Use text icon when dragged.
  ISystemPointerHandle
    icon( ISystemPointerHandle::text );
  IDMImage
    image( icon );
  this -> setImage( image );
  }  
/******************************************************************************
* Class AccountPage :: command - Catch and process command events.            *
******************************************************************************/
bool AccountPage::command( ICommandEvent& cmdEvent )
{
   IString
      theUser = userId.text(),
      theNode = nodeSys.text();
   LAcctData::Rule
      theRule = LAcctData::na;
   bool
      rc = false;
   unsigned int
      count = 0;

/*-----------------------------------------------------------------------------
| Create a container object cursor based on the selected objects.             |
| Process the command events.                                                 |
-----------------------------------------------------------------------------*/
   IContainerControl::ObjectCursor
      soc( *pCnr, IContainerObject::selected );

   switch ( cmdEvent.commandId() )
   {
/*-----------------------------------------------------------------------------
| User pressed the UNDO button.                                               |
| Reset the account data to the original account data.                        |
| Reset the container.                                                        |
| Reset the entryfields.                                                      |
-----------------------------------------------------------------------------*/
      case ID_BUTTON_UNDO:
      {
         acctData = origAcctData;
         fillCnr();
         userId.setText( "" );
         nodeSys.setText( "" );
         rc = true;
         break;
      }

/*-----------------------------------------------------------------------------
| User pressed the REMOVE button.                                             |
| Iterate through the selected objects,                                       |
|  remove the object from the the database.                                   |
-----------------------------------------------------------------------------*/
      case ID_BUTTON_REMOVE:
      {
         for ( soc.setToFirst();
               soc.isValid();
               soc.setToNext() )
         {
            AcctCnrObj
               *pObj = (AcctCnrObj *) soc.current();
            acctData.putItem( pObj->getUserId(),
                              pObj->getNode(),
                              LAcctData::remove );
            ++count;
         }

/*-----------------------------------------------------------------------------
| If no container objects were selected,                                      |
|  notify the user.                                                           |
-----------------------------------------------------------------------------*/
         if ( ! count )
         {
            IMessageBox
               warning( owner() );
            warning.show( STR_MSG_REMOVE,
                          IMessageBox::enterButton
                          | IMessageBox::informationIcon );
         }
/*-----------------------------------------------------------------------------
| Else remove the selected objects from the container.                        |
| Refresh the container.                                                      |
-----------------------------------------------------------------------------*/
         else
         {
            pCnr->removeSelectedObjects();
            userId.setText( "" );
            nodeSys.setText( "" );
            pCnr->refresh();
         }
         rc = true;
         break;
      }

/*-----------------------------------------------------------------------------
| User pressed the CHANGE button.                                             |
| Ignore all but the first selected container object.                         |
| Update the entryfields with the selected container object information.      |
-----------------------------------------------------------------------------*/
      case ID_BUTTON_CHANGE:
      {
         soc.setToFirst();
         if ( soc.isValid() )
         {
            if ( theUser.length() )
            {
               changeAcct( theUser, theNode, (AcctCnrObj*) soc.current() );
               userId.setText( "" );
               nodeSys.setText( "" );
            }

         }
/*-----------------------------------------------------------------------------
| If no container objects were selected,                                      |
|  notify the user.                                                           |
-----------------------------------------------------------------------------*/
         else
         {
            IMessageBox
               warning( owner() );
            warning.show( STR_MSG_CHANGE,
                          IMessageBox::enterButton
                          | IMessageBox::informationIcon );
         }

/*-----------------------------------------------------------------------------
| Deselect any container objects.                                             |
-----------------------------------------------------------------------------*/
         unMark();
         rc = true;
         break;
      }

/*-----------------------------------------------------------------------------
| User pressed the ADD button.                                                |
| Add the entryfield information to the database and container.               |
| Reset the entryfields.                                                      |
-----------------------------------------------------------------------------*/
      case ID_BUTTON_ADD:
      {
         if ( theUser.length() )
         {
            addAcct( theUser, theNode );
            userId.setText( "" );
            nodeSys.setText( "" );
         }

/*-----------------------------------------------------------------------------
| Deselect any container objects.                                             |
-----------------------------------------------------------------------------*/
         unMark();
         rc = true;
         break;
      }

/*-----------------------------------------------------------------------------
| User pressed the HELP button.                                               |
| Show the help for the account page.                                         |
-----------------------------------------------------------------------------*/
      case ID_BUTTON_HELP:
      {
         IHelpWindow::helpWindow( this )->
            show( IResourceId( ID_ACCOUNT_PAGE ) );
         rc = true;
         break;
      }

   }

   return rc;
};
/*------------------------------------------------------------------------------
| ContainerCutPasteHandler::command                                            |
|                                                                              |
| Handle the command events associated with the clipboard (Cut, Copy,          |
| and Paste).                                                                  |
------------------------------------------------------------------------------*/
bool ContainerCutPasteHandler::command ( ICommandEvent& event)
{
  switch(event.commandId())
  {
    case MI_CUT           :
    case MI_COPY          :
    {

      // Create a clipboard object.
      IClipboard clipboard(event.controlWindow()->handle());


      // Find the cursored object in the container.
      Department* cursoredObject = (Department*)(container().cursoredObject());

      // If a Copy request, utilize delayed rendering to put the data of
      // of the private format on the clipboard. If a Cut request, put
      // the data directly on the clipboard since the object won't be
      // around later when the renderFormat code needs it.
      // We maintain an "objectList" collection to keep track of 
      // the objects copied onto the clipboard so that renderFormat
      // knows which objects to render.
      // We also store text data for the objects so that applications
      // that don't support the private format can paste the data into a
      // text editor.

      // Clear the collection used to keep track of clipboard objects.
      objectList->removeAll();

      // If the cursored object is selected, loop through all other
      // selected objects and store the objects in our set.
      if (container().isSelected(cursoredObject))
      {
        unsigned long count = 0;
        IString objectsAsText("\0");
        IContainerControl::ObjectCursor cursor(container(), IContainerObject::selected);
        for (cursor.setToFirst(); cursor.isValid(); cursor.setToNext())
        {
          count++;
          Department* selectedObject = (Department*)(container().objectAt(cursor));
          objectList->add(selectedObject);
          objectsAsText = objectsAsText +  selectedObject->text();
        }


        // Empty the clipboard to establish ownership
        clipboard.empty();

        // Put the data on the clipboard.  We put our private
        // format first since it has the most information.
        // We use 0 for the data on a Copy request because
        // we want to delay the rendering until
        // the paste operation.
        // If this is a Cut, put the data on the clipboard
        // instead of using delayed rendering because we delete
        // the object.

        if (event.commandId() == MI_CUT)
        {
          IString string = selectedData();
          clipboard.setData(Department::renderedFormat, (const char*)string, string.length()+1);
          objectList->removeAll();
          container().deleteSelectedObjects();
        }
        else
          clipboard.setData(Department::renderedFormat, 0, 0);
        
        clipboard.setText(objectsAsText);
      }
      else
      {
        // If the object is not selected, repeat the above procedure
        // for the cursored object.
        objectList->add(cursoredObject);

        // Empty the clipboard to establish ownership
        clipboard.empty();

        // Put the data on the clipboard (using
        // delayed rendering for a Copy. Delete the object
        // if a Cut request.
        IString objectAsText = cursoredObject->text();
        if (event.commandId() == MI_CUT)
        {
           IString string = selectedData();
           clipboard.setData(Department::renderedFormat, (const char*)string, string.length()+1);
           objectList->removeAll();
           container().removeObject(cursoredObject);
           delete cursoredObject;
        }
        else
          clipboard.setData(Department::renderedFormat, 0,0);

        clipboard.setText(objectAsText);
      }
      return true;
    }
    case MI_PASTE         :
    {
      IClipboard clipboard(event.controlWindow()->handle());

      // If the clipboard has data of the private format,
      // get the data and build objects from it.
      // Note:  To see the text format of the data, paste
      // from the clipboard using any text editor that
      // supports the clipboard.
      if (clipboard.hasData(Department::renderedFormat))
      {
         IString strCount, strObject, objectsAsString;

         // Query the data on the clipboard.
         char* data = (char*)clipboard.data(Department::renderedFormat);

         // Parse the string into our data fields.
         data >> strCount >> separator >> objectsAsString;

         // Extract the number of objects stored in the string.
         unsigned long count = strCount.asUnsigned();

         // Turn refresh off to eliminate multiple painting.
         container().setRefreshOff();

         // Construct new objects from the data.
         for( int i=0; i<count; i++)
         {
           objectsAsString >> strObject >> separator >> objectsAsString;
           Department* department = new Department();
           department->initializeFromString(strObject);
           container().addObject(department);
         }

         // Enable refresh and refresh the container.
         container().setRefreshOn();
         container().refresh();
      }
      return true;
    }
  }
Editor::Editor ()
       :IFrameWindow(ID_MAIN_WINDOW),
        title(this),
        flyText(ID_FLYTEXT, &toolBar),
        infoText(ID_INFOTEXT, this, this),
        flyHelpHandler(&flyText, &infoText, 0, 0),
        editWindow(ID_EDITOR, this, this),
        toolBar(ID_TOOLBAR, this, IToolBar::aboveClient, false,
                IToolBar::classDefaultStyle
                | IToolBar::dragDrop),
        cutButton       (IC_ID_CUT,        &toolBar, &toolBar,
               IRectangle(), IToolBarButton::defaultStyle() |
               IToolBarButton::dragDelete ),
        copyButton      (IC_ID_COPY,       &toolBar, &toolBar,
               IRectangle(), IToolBarButton::defaultStyle() |
               IToolBarButton::dragDelete ),
        pasteButton     (IC_ID_PASTE,      &toolBar, &toolBar,
               IRectangle(), IToolBarButton::defaultStyle() |
               IToolBarButton::dragDelete ),
        boldButton      (IC_ID_BOLD,       &toolBar, &toolBar,
               IRectangle(), IToolBarButton::defaultStyle() |
               IToolBarButton::transparentBitmap ),
        italicButton    (IC_ID_ITALIC,     &toolBar, &toolBar,
               IRectangle(), IToolBarButton::defaultStyle() |
               IToolBarButton::transparentBitmap ),
        underscoreButton(IC_ID_UNDERSCORE, &toolBar, &toolBar,
               IRectangle(), IToolBarButton::defaultStyle() |
               IToolBarButton::transparentBitmap ),
        fontCombo(ID_FONTCOMBO, &toolBar, &toolBar, IRectangle(),
                  IBaseComboBox::classDefaultStyle &
                  ~IBaseComboBox::simpleType |
                  IBaseComboBox::readOnlyDropDownType),
        menu(ID_MAIN_WINDOW,this),
        fontSelectHandler(*this),
        editFont(),
        commandhandler(&editFont, &toolBar, &editWindow, &menu)
{
/*----------------------------------------------------------------------------|
| Set the icon and title text                                                 |
-----------------------------------------------------------------------------*/
   setIcon( id() );
   title.setTitleText(ID_MAIN_WINDOW);



/*----------------------------------------------------------------------------|
| Add the buttons to the toolbar                                              |
-----------------------------------------------------------------------------*/
   toolBar.addAsLast(&cutButton,true);
   toolBar.addAsLast(&copyButton);
   toolBar.addAsLast(&pasteButton);
   toolBar.addAsLast(&boldButton,true);
   toolBar.addAsLast(&italicButton);
   toolBar.addAsLast(&underscoreButton);
   toolBar.addAsLast(&fontCombo,true);

/*----------------------------------------------------------------------------|
| Set up latchable style for font property buttons                            |
| Note: When in bitmapAndTextView, latching a toolbar button will show the    |
| gray background for the bitmap.  To eliminate the gray background, set      |
| the transparent color to gray and turn on the transparent style for the     |
| button.  If you do not use the bitmapAndTextView and you have many buttons  |
| with the latchable style, consider not enabling the transparent style as    |
| transparency incurs additional overhead and increases performance time.     |
-----------------------------------------------------------------------------*/
   boldButton.enableLatching();
   italicButton.enableLatching();
   underscoreButton.enableLatching();

   boldButton.setTransparentColor(IColor::kPaleGray);
   italicButton.setTransparentColor(IColor::kPaleGray);
   underscoreButton.setTransparentColor(IColor::kPaleGray);

/*----------------------------------------------------------------------------|
| Load up font combo box with face names                                      |
-----------------------------------------------------------------------------*/
   fontCombo.setLimit(10);
#ifndef IC_MOTIF
   IFont::FaceNameCursor fontCursor;
   for ( fontCursor.setToFirst(); fontCursor.isValid(); fontCursor.setToNext())
   {
     IString faceName = IFont::faceNameAt(fontCursor);
     fontCombo.addAsLast(faceName);
     if (faceName.length() > fontCombo.limit())
       fontCombo.setLimit(faceName.length());
   }
#endif

/*----------------------------------------------------------------------------|
| Set up title for toolbar when floating                                      |
-----------------------------------------------------------------------------*/
   toolBar.setFloatingTitle(STR_TOOLBAR);

/*----------------------------------------------------------------------------|
| Setup the editor                                                            |
-----------------------------------------------------------------------------*/
   setClient(&editWindow);
   editWindow.setFont(editFont);
   try
   {
     editWindow.importFromFile("toolbar.not");
   }
   catch( ... )
   {
      IMessageBox
         msgBox( this );
      msgBox.setTitle( STR_MSGBOX_TITLE );
      msgBox.show( STR_FILE_NOT_FOUND,
                   IMessageBox::okButton |
                   IMessageBox::warningIcon);
   }
   editWindow.setTop(1);

/*----------------------------------------------------------------------------|
| Add the info frame extension                                                |
-----------------------------------------------------------------------------*/
   addExtension(&infoText, IFrameWindow::belowClient);

/*----------------------------------------------------------------------------|
| Set up and add the help handler                                             |
-----------------------------------------------------------------------------*/
   flyHelpHandler.setLongStringTableOffset(OFFSET_INFOTEXT);
   flyHelpHandler.handleEventsFor(&toolBar);

/*----------------------------------------------------------------------------|
| For Motif, disable the Floating menuitem.                                   |
-----------------------------------------------------------------------------*/
#ifdef IC_MOTIF
                                            // On Motif, changing a toolbar location
                                            // to floating is not allowed.  Only
                                            // the initial location can be set
                                            // to floating.  Therefore, disable
                                            // the menuitem on Motif since it
                                            // would have no effect.
  menu.enableItem( ID_TOOLBAR_FLOATING, false );
#endif

/*----------------------------------------------------------------------------|
| Attach the Command Handler to the frame                                     |
-----------------------------------------------------------------------------*/
   commandhandler.handleEventsFor(this);

/*----------------------------------------------------------------------------|
| Allow the font select handler to handle events for font combo box.          |
-----------------------------------------------------------------------------*/
   fontSelectHandler.handleEventsFor(&fontCombo);

   moveSizeToClient(IRectangle(IPoint(100,100),
                               ISize(editFont.avgCharWidth()*80,
                                     editFont.maxCharHeight()*15)));
}
Exemplo n.º 12
0
void IString::change(IString a, IString b, int i){
	int start = this->find(a);
	if(start != -1)
		this->replace(start, a.length(), b);
}