Esempio n. 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;
   }
Esempio n. 2
0
void ServerWindow::DCCChatDialog(BString theNick, BString theIP, BString thePort)
{
	BString theText(theNick);
	theText << " wants to begin a DCC chat with you.";
	BAlert *myAlert = new BAlert("DCC Request", theText.String(), "Accept",
		"Refuse");
	BMessage *myMessage = new BMessage(CHAT_ACCEPT);
	myMessage->AddString("nick", theNick.String());
	myMessage->AddString("ip", theIP.String());
	myMessage->AddString("port", thePort.String());
	BInvoker *myInvoker = new BInvoker(myMessage, this);
	myAlert->Go(myInvoker);
}
Esempio n. 3
0
void
ServerAgent::DCCChatDialog(BString theNick, BString theIP, BString thePort)
{
  BString theText(theNick);
  theText << S_SERVER_DCC_CHAT_PROMPT;
  BAlert *myAlert = new BAlert("DCC request", theText.String(), "Accept",
    "Refuse");
  myAlert->SetFeel (B_FLOATING_APP_WINDOW_FEEL);
  BMessage *myMessage = new BMessage(M_CHAT_ACCEPT);
  myMessage->AddString("nick", theNick.String());
  myMessage->AddString("ip", theIP.String());
  myMessage->AddString("port", thePort.String());
  BInvoker *myInvoker = new BInvoker(myMessage, this);
  myAlert->Go(myInvoker);
}
Esempio n. 4
0
// =============================================================================
// CWindow::DrawTextAt
// Draws text at a given location in the window
// -----------------------------------------------------------------------------
void CWindow::DrawTextAt(std::string theString,
                         int x,
                         int y,
                         CColour theColour /* = CColour::Black */,
                         unsigned int fontSize /* = 12 */,
                         EFontType fontType /* = kFontTypeDefault */)
{
    CFont *theFont = NULL;
    theFont = TextUtilities::GetFont(fontType);
    
    CText theText(theString, *theFont, fontSize);
    theText.setColor(theColour);
    theText.setPosition((float) x, (float) y);
    
    draw(theText);
}
Esempio n. 5
0
void SourceEdit::OnConvertPaste(NMHDR* hdr, LRESULT* res)
{
  SCNXConvertPaste* cp = (SCNXConvertPaste*)hdr;
  *res = 0;

  // Get the source of the data
  COleDataObject data;
  if (cp->source)
    data.Attach((LPDATAOBJECT)(cp->source),FALSE);
  else
    data.AttachClipboard();

  // Try to interpret tables and leading white space
  if (data.IsDataAvailable(CF_UNICODETEXT))
  {
    CStringW theText(cp->utext,cp->ulen);
    CStringW newText, line;
    newText.Preallocate(theText.GetLength());

    bool foundTable = false;
    bool inTable = false;

    int charPos = 0, lineCount = 0;
    while (GetNextLine(theText,line,charPos))
    {
      if (inTable)
      {
        CArray<CStringW> tokens;
        TokenizeLine(line,tokens);

        // Separate multiple tokens with tabs: if less than two tokens,
        // we're at the end of the table
        if (tokens.GetSize() > 1)
        {
          line.Empty();
          for (int j = 0; j < tokens.GetSize(); j++)
          {
            if (j > 0)
              line.AppendChar(L'\t');
            line.Append(tokens.GetAt(j));
          }
        }
        else
          inTable = false;
      }
      else
      {
        // Look for the start of a table
        if (line.Left(6).CompareNoCase(L"table ") == 0)
        {
          inTable = true;
          foundTable = true;
        }

        // Replace any leading blocks of 4 spaces
        int i = 0;
        while (i >= 0)
        {
          if (line.Mid(i,4).Compare(L"    ") == 0)
          {
            line.Delete(i,3);
            line.SetAt(i,L'\t');
            i++;
          }
          else
            i = -1;
        }
      }

      if (lineCount > 0)
        newText.AppendChar(L'\n');
      newText.Append(line);
      lineCount++;
    }

    CString newTextUtf = TextFormat::UnicodeToUTF8(newText);
		cp->text = new char[newTextUtf.GetLength() + 1];
    strcpy(cp->text,newTextUtf);
    *res = 1;
  }
}