示例#1
0
//----------------------------------------------------------------------------
// Method: NewControl::paintWindow
//
// Description: 'paintWindow' is called in response to a paint event, 'evt'.
//              It establishes the colors to paint as well as determines
//              how large and where to draw the text.
//----------------------------------------------------------------------------
Boolean NewControl::paintWindow(IPaintEvent& evt)
   {
   IColor clrBackground(defclrBackground);
   IColor clrForeground(defclrForeground);
   IColor clrHilite(defclrHilite);

   IPresSpaceHandle hps = evt.presSpaceHandle();

   // Should make a separate method which sets the logical
   // color table for the HPS into RGB mode and sets all our
   // colors. Also, colors could be cached in private data
   // and only updated when presparams change.
   establishColor(clrBackground, background, defclrBackground);
   establishColor(clrForeground, foreground, defclrForeground);
   establishColor(clrHilite, hilite, defclrHilite);

   evt.clearBackground(clrBackground);

   // Create the text to draw
   IString theText(dummyText);
   IString theNumber(clicks);
   theNumber.rightJustify(4);
   IString both(theText + theNumber);

   POINTL aptl[TXTBOX_COUNT];
   POINTL ptl = {0,0};

   // Find where we're going to draw our text and how big it will be.
   GpiQueryTextBox(hps,
                   strlen((char*)both),
                   (char*)both,
                   TXTBOX_COUNT,
                   aptl);

   long textWidth = MAX(aptl[TXTBOX_TOPRIGHT].x,
                        aptl[TXTBOX_BOTTOMRIGHT].x);
   long textHeight = MAX(aptl[TXTBOX_TOPLEFT].y,
                         aptl[TXTBOX_TOPRIGHT].y);

   // Center the text before drawing it.
   long x = (cx - textWidth) / 2;
   long y = (cy - textHeight) / 2;

   evt.drawText(theText, IPoint(x, y), clrForeground);

   GpiQueryTextBox(hps,
                   strlen((char*)theText),
                   (char*)theText,
                   TXTBOX_COUNT,
                   aptl);

   // Draw the number to the side of the text
   x += aptl[TXTBOX_CONCAT].x;
   evt.drawText(theNumber, IPoint(x, y), clrHilite);

   return true;
   }
示例#2
0
void	HP_HogMode::SetOwnerInPreference(pid_t inOwner) const
{
#if HogMode_UseCFPrefs
    if(inOwner != -1)
    {
        CACFNumber theNumber(static_cast<SInt32>(inOwner));
        CACFPreferences::SetValue(mPrefName, theNumber.GetCFNumber(), false, true, true);
    }
    else
    {
        CACFPreferences::DeleteValue(mPrefName, false, true, true);
    }
    CACFPreferences::Synchronize(false, true, true);
#else
    if(inOwner != -1)
    {
        sSettingsStorage->SetSInt32Value(mPrefName, inOwner);
    }
    else
    {
        sSettingsStorage->RemoveValue(mPrefName);
    }
#endif
}