Пример #1
0
void CtrlTree::makeImage()
{
    stats_TimerStart( getIntf(), "[Skins] Playlist image",
                      STATS_TIMER_SKINS_PLAYTREE_IMAGE );
    if( m_pImage )
    {
        delete m_pImage;
    }

    // Get the size of the control
    const Position *pPos = getPosition();
    if( !pPos )
    {
        stats_TimerStop( getIntf(), STATS_TIMER_SKINS_PLAYTREE_IMAGE );
        return;
    }
    int width = pPos->getWidth();
    int height = pPos->getHeight();

    int i_itemHeight = itemHeight();

    // Create an image
    OSFactory *pOsFactory = OSFactory::instance( getIntf() );
    m_pImage = pOsFactory->createOSGraphics( width, height );

    VarTree::Iterator it = m_firstPos;

    if( m_pBgBitmap )
    {
        // Draw the background bitmap
        ScaledBitmap bmp( getIntf(), *m_pBgBitmap, width, height );
        m_pImage->drawBitmap( bmp, 0, 0 );

        for( int yPos = 0; yPos < height; yPos += i_itemHeight )
        {
            if( it != m_rTree.end() )
            {
                if( (*it).m_selected )
                {
                    int rectHeight = __MIN( i_itemHeight, height - yPos );
                    m_pImage->fillRect( 0, yPos, width, rectHeight,
                                        m_selColor );
                }
                do
                {
                    it = m_flat ? m_rTree.getNextLeaf( it )
                                : m_rTree.getNextVisibleItem( it );
                } while( it != m_rTree.end() && it->m_deleted );
            }
        }
    }
    else
    {
        // FIXME (TRYME)
        // Fill background with background color
        uint32_t bgColor = m_bgColor1;
        m_pImage->fillRect( 0, 0, width, height, bgColor );
        for( int yPos = 0; yPos < height; yPos += i_itemHeight )
        {
            int rectHeight = __MIN( i_itemHeight, height - yPos );
            if( it != m_rTree.end() )
            {
                uint32_t color = ( it->m_selected ? m_selColor : bgColor );
                m_pImage->fillRect( 0, yPos, width, rectHeight, color );
                do
                {
                    it = m_flat ? m_rTree.getNextLeaf( it )
                                : m_rTree.getNextVisibleItem( it );
                } while( it != m_rTree.end() && it->m_deleted );
            }
            else
            {
                m_pImage->fillRect( 0, yPos, width, rectHeight, bgColor );
            }
            bgColor = ( bgColor == m_bgColor1 ? m_bgColor2 : m_bgColor1 );
        }
    }

    int bitmapWidth = itemImageWidth();

    int yPos = 0;
    it = m_firstPos;
    while( it != m_rTree.end() && yPos < height )
    {
        const GenericBitmap *m_pCurBitmap;
        UString *pStr = (UString*)(it->m_cString.get());
        uint32_t color = ( it->m_playing ? m_playColor : m_fgColor );

        // Draw the text
        if( pStr != NULL )
        {
            int depth = m_flat ? 1 : it->depth();
            GenericBitmap *pText = m_rFont.drawString( *pStr, color, width - bitmapWidth * depth );
            if( !pText )
            {
                stats_TimerStop( getIntf(), STATS_TIMER_SKINS_PLAYTREE_IMAGE );
                return;
            }
            if( it->size() )
                m_pCurBitmap = it->m_expanded ? m_pOpenBitmap : m_pClosedBitmap;
            else
                m_pCurBitmap = m_pItemBitmap;

            if( m_pCurBitmap )
            {
                // Make sure we are centered on the line
                int yPos2 = yPos+(i_itemHeight-m_pCurBitmap->getHeight()+1)/2;
                if( yPos2 >= height )
                {
                    delete pText;
                    break;
                }
                m_pImage->drawBitmap( *m_pCurBitmap, 0, 0,
                                      bitmapWidth * (depth - 1 ), yPos2,
                                      m_pCurBitmap->getWidth(),
                                      __MIN( m_pCurBitmap->getHeight(),
                                             height -  yPos2), true );
            }
            yPos += i_itemHeight - pText->getHeight();
            int ySrc = 0;
            if( yPos < 0 )
            {
                ySrc = - yPos;
                yPos = 0;
            }
            int lineHeight = __MIN( pText->getHeight() - ySrc, height - yPos );
            m_pImage->drawBitmap( *pText, 0, ySrc, bitmapWidth * depth, yPos,
                                  pText->getWidth(),
                                  lineHeight, true );
            yPos += (pText->getHeight() - ySrc );
            delete pText;
        }
        do
        {
            it = m_flat ? m_rTree.getNextLeaf( it )
                : m_rTree.getNextVisibleItem( it );
        } while( it != m_rTree.end() && it->m_deleted );
    }
    stats_TimerStop( getIntf(), STATS_TIMER_SKINS_PLAYTREE_IMAGE );
}
Пример #2
0
wxRect wxWindow::ScrollNoRefresh(int dx, int dy, const wxRect *rectTotal)
{
    wxASSERT_MSG( !dx || !dy, wxT("can't be used for diag scrolling") );

    // the rect to refresh (which we will calculate)
    wxRect rect;

    if ( !dx && !dy )
    {
        // nothing to do
        return rect;
    }

    // calculate the part of the window which we can just redraw in the new
    // location
    wxSize sizeTotal = rectTotal ? rectTotal->GetSize() : GetClientSize();

    wxLogTrace(wxT("scroll"), wxT("rect is %dx%d, scroll by %d, %d"),
               sizeTotal.x, sizeTotal.y, dx, dy);

    // the initial and end point of the region we move in client coords
    wxPoint ptSource, ptDest;
    if ( rectTotal )
    {
        ptSource = rectTotal->GetPosition();
        ptDest = rectTotal->GetPosition();
    }

    // the size of this region
    wxSize size;
    size.x = sizeTotal.x - abs(dx);
    size.y = sizeTotal.y - abs(dy);
    if ( size.x <= 0 || size.y <= 0 )
    {
        // just redraw everything as nothing of the displayed image will stay
        wxLogTrace(wxT("scroll"), wxT("refreshing everything"));

        rect = rectTotal ? *rectTotal : wxRect(0, 0, sizeTotal.x, sizeTotal.y);
    }
    else // move the part which doesn't change to the new location
    {
        // note that when we scroll the canvas in some direction we move the
        // block which doesn't need to be refreshed in the opposite direction

        if ( dx < 0 )
        {
            // scroll to the right, move to the left
            ptSource.x -= dx;
        }
        else
        {
            // scroll to the left, move to the right
            ptDest.x += dx;
        }

        if ( dy < 0 )
        {
            // scroll down, move up
            ptSource.y -= dy;
        }
        else
        {
            // scroll up, move down
            ptDest.y += dy;
        }

#if wxUSE_CARET
        // we need to hide the caret before moving or it will erase itself at
        // the wrong (old) location
        wxCaret *caret = GetCaret();
        if ( caret )
            caret->Hide();
#endif // wxUSE_CARET

        // do move
        wxClientDC dc(this);
        wxBitmap bmp(size.x, size.y);
        wxMemoryDC dcMem;
        dcMem.SelectObject(bmp);

        dcMem.Blit(wxPoint(0,0), size, &dc, ptSource
#if defined(__WXGTK__) && !defined(wxHAS_WORKING_GTK_DC_BLIT)
                + GetClientAreaOrigin()
#endif // broken wxGTK wxDC::Blit
                  );
        dc.Blit(ptDest, size, &dcMem, wxPoint(0,0));

        wxLogTrace(wxT("scroll"),
                   wxT("Blit: (%d, %d) of size %dx%d -> (%d, %d)"),
                   ptSource.x, ptSource.y,
                   size.x, size.y,
                   ptDest.x, ptDest.y);

        // and now repaint the uncovered area

        // FIXME: We repaint the intersection of these rectangles twice - is
        //        it bad? I don't think so as it is rare to scroll the window
        //        diagonally anyhow and so adding extra logic to compute
        //        rectangle intersection is probably not worth the effort

        rect.x = ptSource.x;
        rect.y = ptSource.y;

        if ( dx )
        {
            if ( dx < 0 )
            {
                // refresh the area along the right border
                rect.x += size.x + dx;
                rect.width = -dx;
            }
            else
            {
                // refresh the area along the left border
                rect.width = dx;
            }

            rect.height = sizeTotal.y;

            wxLogTrace(wxT("scroll"), wxT("refreshing (%d, %d)-(%d, %d)"),
                       rect.x, rect.y,
                       rect.GetRight() + 1, rect.GetBottom() + 1);
        }

        if ( dy )
        {
            if ( dy < 0 )
            {
                // refresh the area along the bottom border
                rect.y += size.y + dy;
                rect.height = -dy;
            }
            else
            {
                // refresh the area along the top border
                rect.height = dy;
            }

            rect.width = sizeTotal.x;

            wxLogTrace(wxT("scroll"), wxT("refreshing (%d, %d)-(%d, %d)"),
                       rect.x, rect.y,
                       rect.GetRight() + 1, rect.GetBottom() + 1);
        }

#if wxUSE_CARET
        if ( caret )
            caret->Show();
#endif // wxUSE_CARET
    }

    return rect;
}
Пример #3
0
void
clAuiDockArt::DrawCaption(wxDC& dc, wxWindow* window, const wxString& text, const wxRect& rect, wxAuiPaneInfo& pane)
{
    wxRect tmpRect(wxPoint(0, 0), rect.GetSize());

    // Hackishly prevent assertions on linux
    if(tmpRect.GetHeight() == 0) tmpRect.SetHeight(1);
    if(tmpRect.GetWidth() == 0) tmpRect.SetWidth(1);
#ifdef __WXOSX__
    tmpRect = rect;
    window->PrepareDC(dc);

    // Prepare the colours
    wxColour bgColour, penColour, textColour;
    textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
    bgColour = DrawingUtils::DarkColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 2.0);
    ; // Same as the notebook background colour
    penColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW);
    penColour = bgColour;

    wxFont f = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    dc.SetFont(f);
    dc.SetPen(penColour);
    dc.SetBrush(bgColour);
    dc.DrawRectangle(tmpRect);

    // Fill the caption to look like OSX caption
    wxColour topColour("#d3d2d3");
    wxColour bottomColour("#e8e8e8");
    dc.GradientFillLinear(tmpRect, topColour, bottomColour, wxNORTH);
    
    dc.SetPen(penColour);
    dc.SetBrush(*wxTRANSPARENT_BRUSH);
    dc.DrawRectangle(tmpRect);
    
    int caption_offset = 0;
    if(pane.icon.IsOk()) {
        DrawIcon(dc, tmpRect, pane);
        caption_offset += pane.icon.GetWidth() + 3;
    } else {
        caption_offset = 3;
    }
    dc.SetTextForeground(textColour);
    wxCoord w, h;
    dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h);

    wxRect clip_rect = tmpRect;
    clip_rect.width -= 3; // text offset
    clip_rect.width -= 2; // button padding
    if(pane.HasCloseButton()) clip_rect.width -= m_buttonSize;
    if(pane.HasPinButton()) clip_rect.width -= m_buttonSize;
    if(pane.HasMaximizeButton()) clip_rect.width -= m_buttonSize;

    wxString draw_text = wxAuiChopText(dc, text, clip_rect.width);
    wxSize textSize = dc.GetTextExtent(draw_text);
    
    dc.SetTextForeground(textColour);
    dc.DrawText(draw_text, tmpRect.x + 3 + caption_offset, tmpRect.y + ((tmpRect.height - textSize.y) / 2));
#else
    wxBitmap bmp(tmpRect.GetSize());
    {
        wxMemoryDC memDc;
        memDc.SelectObject(bmp);

        wxGCDC gdc;
        wxDC* pDC = NULL;
        if(!DrawingUtils::GetGCDC(memDc, gdc)) {
            pDC = &memDc;
        } else {
            pDC = &gdc;
        }

        // Prepare the colours
        wxColour bgColour, penColour, textColour;
        textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
        bgColour = DrawingUtils::DarkColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 2.0);
        ; // Same as the notebook background colour
        penColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW);
        penColour = bgColour;

        wxFont f = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
        pDC->SetFont(f);
        pDC->SetPen(penColour);
        pDC->SetBrush(bgColour);
        pDC->DrawRectangle(tmpRect);

        pDC->SetPen(penColour);
        pDC->SetBrush(*wxTRANSPARENT_BRUSH);
        pDC->DrawRectangle(tmpRect);

        int caption_offset = 0;
        if(pane.icon.IsOk()) {
            DrawIcon(gdc, tmpRect, pane);
            caption_offset += pane.icon.GetWidth() + 3;
        } else {
            caption_offset = 3;
        }
        pDC->SetTextForeground(textColour);
        wxCoord w, h;
        pDC->GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h);

        wxRect clip_rect = tmpRect;
        clip_rect.width -= 3; // text offset
        clip_rect.width -= 2; // button padding
        if(pane.HasCloseButton()) clip_rect.width -= m_buttonSize;
        if(pane.HasPinButton()) clip_rect.width -= m_buttonSize;
        if(pane.HasMaximizeButton()) clip_rect.width -= m_buttonSize;

        wxString draw_text = wxAuiChopText(gdc, text, clip_rect.width);

        wxSize textSize = pDC->GetTextExtent(draw_text);
        pDC->SetTextForeground(textColour);
        pDC->DrawText(draw_text, tmpRect.x + 3 + caption_offset, tmpRect.y + ((tmpRect.height - textSize.y) / 2));
        memDc.SelectObject(wxNullBitmap);
    }
    dc.DrawBitmap(bmp, rect.x, rect.y, true);
#endif
}
Пример #4
0
bool FliFormat::onSave(FileOp* fop)
{
  Sprite* sprite = fop->document->getSprite();
  unsigned char cmap[768];
  unsigned char omap[768];
  s_fli_header fli_header;
  int c, times;
  Palette *pal;

  /* prepare fli header */
  fli_header.filesize = 0;
  fli_header.frames = 0;
  fli_header.width = sprite->getWidth();
  fli_header.height = sprite->getHeight();

  if ((fli_header.width == 320) && (fli_header.height == 200))
    fli_header.magic = HEADER_FLI;
  else
    fli_header.magic = HEADER_FLC;

  fli_header.depth = 8;
  fli_header.flags = 3;
  fli_header.speed = get_time_precision(sprite);
  fli_header.created = 0;
  fli_header.updated = 0;
  fli_header.aspect_x = 1;
  fli_header.aspect_y = 1;
  fli_header.oframe1 = fli_header.oframe2 = 0;

  /* open the file to write in binary mode */
  FileHandle f(open_file_with_exception(fop->filename, "wb"));

  fseek(f, 128, SEEK_SET);

  // Create the bitmaps
  base::UniquePtr<Image> bmp(Image::create(IMAGE_INDEXED, sprite->getWidth(), sprite->getHeight()));
  base::UniquePtr<Image> old(Image::create(IMAGE_INDEXED, sprite->getWidth(), sprite->getHeight()));

  // Write frame by frame
  for (FrameNumber frpos(0);
       frpos < sprite->getTotalFrames();
       ++frpos) {
    /* get color map */
    pal = sprite->getPalette(frpos);
    for (c=0; c<256; c++) {
      cmap[3*c  ] = rgba_getr(pal->getEntry(c));
      cmap[3*c+1] = rgba_getg(pal->getEntry(c));
      cmap[3*c+2] = rgba_getb(pal->getEntry(c));
    }

    /* render the frame in the bitmap */
    clear_image(bmp, 0);
    layer_render(sprite->getFolder(), bmp, 0, 0, frpos);

    /* how many times this frame should be written to get the same
       time that it has in the sprite */
    times = sprite->getFrameDuration(frpos) / fli_header.speed;

    for (c=0; c<times; c++) {
      /* write this frame */
      if (frpos == 0 && c == 0)
        fli_write_frame(f, &fli_header, NULL, NULL,
                        (unsigned char *)bmp->getPixelAddress(0, 0), cmap, W_ALL);
      else
        fli_write_frame(f, &fli_header,
                        (unsigned char *)old->getPixelAddress(0, 0), omap,
                        (unsigned char *)bmp->getPixelAddress(0, 0), cmap, W_ALL);

      /* update the old image and color-map to the new ones to compare later */
      copy_image(old, bmp, 0, 0);
      memcpy(omap, cmap, 768);
    }

    /* update progress */
    fop_progress(fop, (float)(frpos.next()) / (float)(sprite->getTotalFrames()));
  }

  // Write the header and close the file
  fli_write_header(f, &fli_header);

  return true;
}
Пример #5
0
    GraphicsBenchmarkFrame()
        : wxFrame(NULL, wxID_ANY, "wxWidgets Graphics Benchmark")
    {
        SetClientSize(opts.width, opts.height);

#if wxUSE_GLCANVAS
        m_glCanvas = NULL;
        m_glContext = NULL;

        if ( opts.useGL )
        {
            m_glCanvas = new wxGLCanvas(this, wxID_ANY, NULL,
                                        wxPoint(0, 0),
                                        wxSize(opts.width, opts.height));
            m_glContext = new wxGLContext(m_glCanvas);
            m_glContext->SetCurrent(*m_glCanvas);

            glViewport(0, 0, opts.width, opts.height);
            glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            glOrtho(-1, 1, -1, 1, -1, 1);
            glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();

            InitializeTexture(opts.width, opts.height);

            m_glCanvas->Connect(
                wxEVT_PAINT,
                wxPaintEventHandler(GraphicsBenchmarkFrame::OnGLRender),
                NULL,
                this
            );
        }
        else // Not using OpenGL
#endif // wxUSE_GLCANVAS
        {
            Connect(wxEVT_PAINT,
                    wxPaintEventHandler(GraphicsBenchmarkFrame::OnPaint));
        }

        Connect(wxEVT_SIZE, wxSizeEventHandler(GraphicsBenchmarkFrame::OnSize));

        m_bitmapARGB.Create(64, 64, 32);
        m_bitmapARGB.UseAlpha(true);
        m_bitmapRGB.Create(64, 64, 24);

        m_renderer = NULL;
        if ( opts.useGC )
        {
#ifdef __WXMSW__
            if ( opts.renderer == GraphicsBenchmarkOptions::GDIPlus )
                m_renderer = wxGraphicsRenderer::GetGDIPlusRenderer();
            else if ( opts.renderer == GraphicsBenchmarkOptions::Direct2D )
                m_renderer = wxGraphicsRenderer::GetDirect2DRenderer();
            else if ( opts.renderer == GraphicsBenchmarkOptions::Cairo )
                m_renderer = wxGraphicsRenderer::GetCairoRenderer();
            // Check if selected renderer is operational.
            if ( m_renderer )
            {
                wxBitmap bmp(16, 16);
                wxMemoryDC memDC(bmp);
                wxGraphicsContext* gc = m_renderer->CreateContext(memDC);
                if ( !gc )
                {
                    wxPrintf("Couldn't initialize '%s' graphics renderer.\n", m_renderer->GetName().c_str());
                    m_renderer = NULL;
                }
                delete gc;
            }
#endif // __WXMSW__

            if( !m_renderer )
                m_renderer = wxGraphicsRenderer::GetDefaultRenderer();
        }

        Show();
    }
Пример #6
0
void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize,
                                 ColourAllocated fill, int alphaFill,
                                 ColourAllocated outline, int alphaOutline,
                                 int /*flags*/) {
#if wxUSE_GRAPHICS_CONTEXT
    wxGCDC dc(*(wxMemoryDC*)hdc);
    wxColour penColour(wxColourFromCAandAlpha(outline, alphaOutline));
    wxColour brushColour(wxColourFromCAandAlpha(fill, alphaFill));
    dc.SetPen(wxPen(penColour));
    dc.SetBrush(wxBrush(brushColour));
    dc.DrawRoundedRectangle(wxRectFromPRectangle(rc), cornerSize);
    return;
#else

#ifdef wxHAVE_RAW_BITMAP

    // TODO:  do something with cornerSize
    wxUnusedVar(cornerSize);

    int x, y;
    wxRect r = wxRectFromPRectangle(rc);
    wxBitmap bmp(r.width, r.height, 32);
    wxAlphaPixelData pixData(bmp);
    pixData.UseAlpha();

    // Set the fill pixels
    ColourDesired cdf(fill.AsLong());
    int red   = cdf.GetRed();
    int green = cdf.GetGreen();
    int blue  = cdf.GetBlue();

    wxAlphaPixelData::Iterator p(pixData);
    for (y=0; y<r.height; y++) {
        p.MoveTo(pixData, 0, y);
        for (x=0; x<r.width; x++) {
            p.Red()   = wxPy_premultiply(red,   alphaFill);
            p.Green() = wxPy_premultiply(green, alphaFill);
            p.Blue()  = wxPy_premultiply(blue,  alphaFill);
            p.Alpha() = alphaFill;
            ++p;
        }
    }

    // Set the outline pixels
    ColourDesired cdo(outline.AsLong());
    red   = cdo.GetRed();
    green = cdo.GetGreen();
    blue  = cdo.GetBlue();
    for (x=0; x<r.width; x++) {
        p.MoveTo(pixData, x, 0);
        p.Red()   = wxPy_premultiply(red,   alphaOutline);
        p.Green() = wxPy_premultiply(green, alphaOutline);
        p.Blue()  = wxPy_premultiply(blue,  alphaOutline);
        p.Alpha() = alphaOutline;
        p.MoveTo(pixData, x, r.height-1);
        p.Red()   = wxPy_premultiply(red,   alphaOutline);
        p.Green() = wxPy_premultiply(green, alphaOutline);
        p.Blue()  = wxPy_premultiply(blue,  alphaOutline);
        p.Alpha() = alphaOutline;
    }

    for (y=0; y<r.height; y++) {
        p.MoveTo(pixData, 0, y);
        p.Red()   = wxPy_premultiply(red,   alphaOutline);
        p.Green() = wxPy_premultiply(green, alphaOutline);
        p.Blue()  = wxPy_premultiply(blue,  alphaOutline);
        p.Alpha() = alphaOutline;
        p.MoveTo(pixData, r.width-1, y);
        p.Red()   = wxPy_premultiply(red,   alphaOutline);
        p.Green() = wxPy_premultiply(green, alphaOutline);
        p.Blue()  = wxPy_premultiply(blue,  alphaOutline);
        p.Alpha() = alphaOutline;
    }

    // Draw the bitmap
    hdc->DrawBitmap(bmp, r.x, r.y, true);

#else
    wxUnusedVar(cornerSize);
    wxUnusedVar(alphaFill);
    wxUnusedVar(alphaOutline);
    RectangleDraw(rc, outline, fill);
#endif
#endif
}
Пример #7
0
AboutWindow::AboutWindow(void)
	: BWindow(BRect(0.0, 0.0, 420.0, 266.0), "About Vision", B_TITLED_WINDOW,
			  B_WILL_DRAW | B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{
	/*
	 * Function purpose: Construct
	 */

	BRect bounds(Bounds());
	BBitmap* bmp(NULL);

	fBackground = new BView(bounds, "background", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
	fBackground->SetViewColor(255, 255, 255);
	AddChild(fBackground);

	if ((bmp = BTranslationUtils::GetBitmap('bits', "vision")) != 0) {
		// BRect logo_bounds (bmp->Bounds());

		fLogo =
			new ClickView(bmp->Bounds().OffsetByCopy(16, 16), "image", B_FOLLOW_LEFT | B_FOLLOW_TOP,
						  B_WILL_DRAW, "http://vision.sourceforge.net");
		fBackground->AddChild(fLogo);
		fLogo->SetViewBitmap(bmp);
		delete bmp;

		bounds.Set(0.0, fLogo->Frame().bottom + 12, Bounds().right, Bounds().bottom);
	}

	fCredits = new BTextView(bounds, "credits", bounds.OffsetToCopy(B_ORIGIN).InsetByCopy(20, 0),
							 B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);

	fCredits->MakeSelectable(false);
	fCredits->MakeEditable(false);
	fCredits->SetStylable(true);
	fCredits->SetAlignment(B_ALIGN_CENTER);
	fBackground->AddChild(fCredits);

	fCreditsText = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
				   "Unit A\n[Vision]\n"
				   "{A-Z}\n"
				   "Alan Ellis (voidref)\n"
				   "Rene Gollent (AnEvilYak)\n"
				   "Todd Lair (tlair)\n"
				   "Wade Majors (kurros)\n\n\n\n"

				   "\n\n\n\nUnit B\n[Bowser]\n"
				   "{A-Z}\n"
				   "Andrew Bazan (Hiisi)\n"
				   "Rene Gollent (AnEvilYak)\n"
				   "Todd Lair (tlair)\n"
				   "Brian Luft (Electroly)\n"
				   "Wade Majors (kurros)\n"
				   "Jamie Wilkinson (project)\n\n\n\n"

				   "\n\n\n\nBrought to you in part by contributions from\n"
				   "{A-Z}\n"
				   "Seth Flaxman (Flax)\n"
				   "Joshua Jensen\n"
				   "Gord McLeod (G_McLeod)\n"
				   "John Robinson ([geo])\n"
				   "Bjorn Oksholen (GuinnessM)\n"
				   "Jean-Baptiste M. Quéru (jbq)\n"
				   "Humdinger\n"
				   "\n\n\n"

				   "\n\n\n\nUnit C\n[Support Crew]\n"
				   "Assistant to Wade Majors: Patches\n"
				   "Music Supervisor: Baron Arnold\n"
				   "Assistant to Baron Arnold: Ficus Kirkpatrick\n"
				   "Stunt Coordinator: Gilligan\n"
				   "Nude Scenes: Natalie Portman\n"
				   "Counselors: regurg and helix\n\n\n"
				   "No animals were injured during the production of this IRC client\n\n\n"
				   "Soundtrack available on Catastrophe Records\n\n\n\n"

				   "\n\n\n\nSpecial Thanks\n\n"
				   "Olathe\n"
				   "Terminus\n"
				   "Bob Maple\n"
				   "Ted Stodgell\n"
				   "Seth Flaxman\n"
				   "David Aquilina\n"
				   "Kurt von Finck\n"
				   "Kristine Gouveia\n"
				   "Be, Inc., Menlo Park, CA\n"
				   "Pizza Hut, Winter Haven, FL (now give me that free pizza Mike)\n\n\n"

				   "send all complaints and nipple pictures to kaye\n\n\n"

				   "\n\n\n\n\n"
				   "\"A human being should be able to change "
				   "a diaper, plan an invasion, butcher a "
				   "hog, conn a ship, design a building, "
				   "write a sonnet, balance accounts, build "
				   "a wall, set a bone, comfort the dying, "
				   "take orders, give orders, cooperate, act "
				   "alone, solve equations, analyze a new "
				   "problem, pitch manure, program a com"
				   "puter, cook a tasty meal, fight effi"
				   "ciently, die gallantly. Specialization "
				   "is for insects.\" -- Robert A. Heinlein";

	rgb_color myBlack = {0, 0, 0, 255};
	fTextRun.count = 1;
	fTextRun.runs[0].offset = 0;
	fTextRun.runs[0].font = *be_fixed_font;
	fTextRun.runs[0].color = myBlack;

	fCredits->Insert(fCreditsText, &fTextRun);

	// Center window
	BRect frame(BScreen().Frame());
	MoveTo(frame.Width() / 2 - Frame().Width() / 2, frame.Height() / 2 - Frame().Height() / 2);
	fScrollRunner = new BMessageRunner(BMessenger(this), new BMessage(M_ABOUT_SCROLL), 50000);
}
Пример #8
0
bool wxIcon::LoadFile(
    const wxString& filename, wxBitmapType type,
    int desiredWidth, int desiredHeight )
{
    UnRef();

    if ( type == wxBITMAP_TYPE_ICON_RESOURCE )
    {
        OSType theId = 0 ;

        if ( filename == wxT("wxICON_INFORMATION") )
        {
            theId = kAlertNoteIcon ;
        }
        else if ( filename == wxT("wxICON_QUESTION") )
        {
            theId = kAlertCautionIcon ;
        }
        else if ( filename == wxT("wxICON_WARNING") )
        {
            theId = kAlertCautionIcon ;
        }
        else if ( filename == wxT("wxICON_ERROR") )
        {
            theId = kAlertStopIcon ;
        }
        else
        {
#if 0
            Str255 theName ;
            OSType theType ;
            wxMacStringToPascal( name , theName ) ;

            Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
            if ( resHandle != 0L )
            {
                GetResInfo( resHandle , &theId , &theType , theName ) ;
                ReleaseResource( resHandle ) ;
            }
#endif
        }

        if ( theId != 0 )
        {
            IconRef iconRef = NULL ;
            verify_noerr( GetIconRef( kOnSystemDisk, kSystemIconsCreator, theId, &iconRef ) ) ;
            if ( iconRef )
            {
                m_refData = new wxIconRefData( (WXHICON) iconRef ) ;

                return true ;
            }
        }

        return false ;
    }
    else
    {
        wxBitmapHandler *handler = wxBitmap::FindHandler( type );

        if ( handler )
        {
            wxBitmap bmp ;
            if ( handler->LoadFile( &bmp , filename, type, desiredWidth, desiredHeight ))
            {
                CopyFromBitmap( bmp ) ;

                return true ;
            }

            return false ;
        }
        else
        {
#if wxUSE_IMAGE
            wxImage loadimage( filename, type );
            if (loadimage.Ok())
            {
                if ( desiredWidth == -1 )
                    desiredWidth = loadimage.GetWidth() ;
                if ( desiredHeight == -1 )
                    desiredHeight = loadimage.GetHeight() ;
                if ( desiredWidth != loadimage.GetWidth() || desiredHeight != loadimage.GetHeight() )
                    loadimage.Rescale( desiredWidth , desiredHeight ) ;

                wxBitmap bmp( loadimage );
                CopyFromBitmap( bmp ) ;

                return true;
            }
#endif
        }
    }
    return true ;
}
Пример #9
0
wxIcon::wxIcon( const char bits[], int width, int height )
{
    wxBitmap bmp( bits, width, height ) ;
    CopyFromBitmap( bmp ) ;
}
Пример #10
0
void CtrlImage::draw( OSGraphics &rImage, int xDest, int yDest, int w, int h )
{
    const Position *pPos = getPosition();
    if( !pPos )
        return;

    int width = pPos->getWidth();
    int height = pPos->getHeight();
    if( width <= 0 || height <= 0 )
        return;

    rect region( pPos->getLeft(), pPos->getTop(),
                 pPos->getWidth(), pPos->getHeight() );
    rect clip( xDest, yDest, w, h );
    rect inter;
    if( !rect::intersect( region, clip, &inter ) )
        return;

    if( m_resizeMethod == kScale )
    {
        // Use scaling method
        if( width != m_pImage->getWidth() ||
            height != m_pImage->getHeight() )
        {
            OSFactory *pOsFactory = OSFactory::instance( getIntf() );
            // Rescale the image with the actual size of the control
            ScaledBitmap bmp( getIntf(), *m_pBitmap, width, height );
            delete m_pImage;
            m_pImage = pOsFactory->createOSGraphics( width, height );
            m_pImage->drawBitmap( bmp, 0, 0 );
        }
        rImage.drawGraphics( *m_pImage,
                             inter.x - pPos->getLeft(),
                             inter.y - pPos->getTop(),
                             inter.x, inter.y,
                             inter.width, inter.height );
    }
    else if( m_resizeMethod == kMosaic )
    {
        int xDest0 = pPos->getLeft();
        int yDest0 = pPos->getTop();

        // Use mosaic method
        while( width > 0 )
        {
            int curWidth = __MIN( width, m_pImage->getWidth() );
            height = pPos->getHeight();
            int curYDest = yDest0;
            while( height > 0 )
            {
                int curHeight = __MIN( height, m_pImage->getHeight() );
                rect region1( xDest0, curYDest, curWidth, curHeight );
                rect inter1;
                if( rect::intersect( region1, clip, &inter1 ) )
                {
                    rImage.drawGraphics( *m_pImage,
                                   inter1.x - region1.x,
                                   inter1.y - region1.y,
                                   inter1.x, inter1.y,
                                   inter1.width, inter1.height );
                }
                curYDest += curHeight;
                height -= m_pImage->getHeight();
            }
            xDest0 += curWidth;
            width -= m_pImage->getWidth();
        }
    }
    else if( m_resizeMethod == kScaleAndRatioPreserved )
    {
        int w0 = m_pBitmap->getWidth();
        int h0 = m_pBitmap->getHeight();

        int scaled_height = width * h0 / w0;
        int scaled_width  = height * w0 / h0;

        // new image scaled with aspect ratio preserved
        // and centered inside the control boundaries
        int w, h;
        if( scaled_height > height )
        {
            w = scaled_width;
            h = height;
            m_x = ( width - w ) / 2;
            m_y = 0;
        }
        else
        {
            w = width;
            h = scaled_height;
            m_x = 0;
            m_y = ( height - h ) / 2;
        }

        // rescale the image if size changed
        if( w != m_pImage->getWidth() ||
            h != m_pImage->getHeight() )
        {
            OSFactory *pOsFactory = OSFactory::instance( getIntf() );
            ScaledBitmap bmp( getIntf(), *m_pBitmap, w, h );
            delete m_pImage;
            m_pImage = pOsFactory->createOSGraphics( w, h );
            m_pImage->drawBitmap( bmp, 0, 0 );
        }

        // draw the scaled image at offset (m_x, m_y) from control origin
        rect region1( pPos->getLeft() + m_x, pPos->getTop() + m_y, w, h );
        rect inter1;
        if( rect::intersect( region1, inter, &inter1 ) )
        {
            rImage.drawGraphics( *m_pImage,
                                 inter1.x - pPos->getLeft() - m_x,
                                 inter1.y - pPos->getTop() - m_y,
                                 inter1.x, inter1.y,
                                 inter1.width, inter1.height );
        }
    }
}
Пример #11
0
	void ImageHelper::SaveJPGImage(const achar* filepath, int32_t width, int32_t height, void* data, bool rev)
	{
#if _WIN32
		//GDI+を初期化する。
		Gdiplus::GdiplusStartupInput gdiplusStartupInput;
		ULONG_PTR gdiplusToken;
		Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

		{
			// bmpを作成する。
			Gdiplus::Bitmap bmp(width, height);

			auto p = (Color*) data;
			for (int32_t y = 0; y < height; y++)
			{
				for (int32_t x = 0; x < width; x++)
				{
					if (rev)
					{
						auto src = p[x + width * (height - 1 - y)];
						Gdiplus::Color dst(src.R, src.G, src.B);
						bmp.SetPixel(x, y, dst);
					}
					else
					{
						auto src = p[x + width * y];
						Gdiplus::Color dst(src.R, src.G, src.B);
						bmp.SetPixel(x, y, dst);
					}
				}
			}

			// 保存
			CLSID id;
			UINT encoderNum = 0;
			UINT encoderSize = 0;
			Gdiplus::GetImageEncodersSize(&encoderNum, &encoderSize);
			if (encoderSize == 0)
			{
				Gdiplus::GdiplusShutdown(gdiplusToken);
				return;
			}

			auto imageCodecInfo = (Gdiplus::ImageCodecInfo*) malloc(encoderSize);
			Gdiplus::GetImageEncoders(encoderNum, encoderSize, imageCodecInfo);

			for (UINT i = 0; i < encoderNum; i++)
			{
				if (wcscmp(imageCodecInfo[i].MimeType, L"image/jpeg") == 0)
				{
					id = imageCodecInfo[i].Clsid;
					free(imageCodecInfo);
					imageCodecInfo = nullptr;
					break;
				}
			}

			if (imageCodecInfo != nullptr)
			{
				free(imageCodecInfo);
				return;
			}

			bmp.Save(filepath, &id);
		}

		//GDI+を終了する。
		Gdiplus::GdiplusShutdown(gdiplusToken);
		return;
#else
		return;
#endif // _WIN32
		
	}
Пример #12
0
void Mouse(char ch)
{
 if(ch=='o')
  bar(0);
 else if(ch=='n')
      {
       setfillstyle(SOLID_FILL,15);
       hidemouse();
       bar(42,62,598,458);
       mousecall();
       setcolor(c);
       bar(c);
      }
 int cl,x5,y5,tool;
 int x1=604,y1=70,z=616,w=84;
 setfillstyle(cc,c);
 bar(12,290,27,310);       //fillp show bar
 do
 {
  if(ch=='n')
  {
   ch='k';
   if(tool==4)
    fout<<"setfillstyle(SOLID_FILL,"<<c<<");\n";
   else
       if(tool==1)
	fout<<"setfillstyle(SOLID_FILL,15);\n";
       else
	   if(tool==6)
	    fout<<"setfillstyle("<<cc<<','<<c<<");\n";
   fout<<"setcolor("<<c<<");\n";
   fout<<"rectangle(42,62,598,458);\n";
  }
  mousecall();
  x1=604,y1=70,z=616,w=84;
  for(int i=0;i<8;i++,y1+=25,w+=25)
  {
   mousepos(cl,x5,y5);
   if(x5>=x1&&x5<=z&&y5>=y1&&y5<=w)
    if(cl==1)
     {
      static int v=1;
      if(v!=c)
      {
       fout<<"setfillstyle(SOLID_FILL,"<<c<<");\n";
       fout<<"setcolor("<<c<<");\n";
       fout<<"rectangle(42,62,598,458);\n";
       v=c;
      }
      c=i;
      setfillstyle(cc,c);
      bar(12,290,27,310);
      setfillstyle(SOLID_FILL,c);

     }
  }

  x1=621,y1=70,z=633,w=84;
  for( i=8;i<16;i++,y1+=25,w+=25)
  {
   mousepos(cl,x5,y5);
   if(x5>=x1&&x5<=z&&y5>=y1&&y5<=w)
    if(cl==1)
    {
     static int v=0;
     c=i;

       setfillstyle(cc,c);
       bar(12,290,27,310);
       setfillstyle(SOLID_FILL,c);
     if(v!=c)
     {
      fout<<"setfillstyle(SOLID_FILL,"<<c<<");\n";
      fout<<"setcolor("<<c<<");\n";
      fout<<"rectangle(42,62,598,458);\n";
      v=c;
     }
    }
  }

  x1=605,y1=320,z=637,w=457;
  for(i=7;i<11;i++,y1+=25,w+=25)
  {
   mousepos(cl,x5,y5);
   if(x5>=x1&&x5<=z&&y5>=y1&&y5<=w)
    if(cl==1)
     {
      static int v=0;
      cc=i;
      setfillstyle(cc,c);
      bar(12,290,27,310);
      if(v!=cc)
      {
       fout<<"setfillstyle("<<cc<<','<<c<<");\n";
       v=cc;
      }
     }
  }
  x1=5,y1=320,z=37,w=457;
  for(i=2;i<7;i++,y1+=25,w+=25)
  {
   mousepos(cl,x5,y5);
   if(x5>=x1&&x5<=z&&y5>=y1&&y5<=w)
    if(cl==1)
     {
      static int v=0;
      cc=i;
      setfillstyle(cc,c);
      bar(12,290,27,310);
      if(v!=cc)
      {
       fout<<"setfillstyle("<<cc<<','<<c<<");\n";
       v=cc;
      }
     }
  }

  bar(c);
  delay(100);
  mousepos(cl,x5,y5);

  if(x5>=621&&x5<=635&&y5>=3&&y5<=16)     //changes made !!!
  {
   if(cl==1)
   {
    hidemouse();
    break;
   }
  }

  mousepos(cl,x5,y5);
  int gg=0;

  gg=help_bar(gg);

  while(x5>=24&&x5<=36&&y5>=70&&y5<=84)
  {
   mousepos(cl,x5,y5);
   setcolor(0);
   settextstyle(SMALL_FONT,0,4);
   outtextxy(45,464,"RECTANGLE ");
   gg=1;
   if(cl==1)
   {
    tool=0;
   }
  }

  gg=help_bar(gg);
  static int er=1;
  mousepos(cl,x5,y5);
  while(x5>=6&&x5<=18&&y5>=145&&y5<=159)
  {
   mousepos(cl,x5,y5);
   setcolor(0);
   settextstyle(SMALL_FONT,0,4);
   outtextxy(45,464,"ERASER ");
   gg=1;

   if(cl==1 && er==1)
   {
    tool=1;
    bar(15);
    fout<<"setfillstyle(SOLID_FILL,15);\n";
    fout<<"setcolor(15);\n";
    er=2;
   }
  }


  if(tool!=1)
  {
   bar(c);
   er=1;
  }
  gg=help_bar(gg);

  mousepos(cl,x5,y5);

  while(x5>=6&&x5<=18&&y5>=70&&y5<=84)
  {
   mousepos(cl,x5,y5);
   setcolor(0);
   settextstyle(SMALL_FONT,0,4);
   outtextxy(45,464,"LINE");
   gg=1;

   if(cl==1)
   {
    tool=2;
   }
  }

  gg=help_bar(gg);

  mousepos(cl,x5,y5);

  while(x5>=6&&x5<=18&&y5>=90&&y5<=109)
  {
   mousepos(cl,x5,y5);
   setcolor(0);
   settextstyle(SMALL_FONT,0,4);
   outtextxy(45,464,"CIRCLE");
   gg=1;

   if(cl==1)
   {
    tool=3;
   }
  }

  gg=help_bar(gg);

  mousepos(cl,x5,y5);

  while(x5>=24&&x5<=36&&y5>=120&&y5<=134)
  {
   mousepos(cl,x5,y5);
   setcolor(0);
   settextstyle(SMALL_FONT,0,4);
   outtextxy(45,464,"BUCKET");
   gg=1;
   if(cl==1)
   {
    if(cc!=1)
    {
     fout<<"setfillstyle(SOLID_FILL,"<<c<<");\n";
     cc=1;
    }
    tool=4;
   }
  }

  gg=help_bar(gg);

   mousepos(cl,x5,y5);

  while(x5>=24&&x5<=36&&y5>=90&&y5<=109)
  {
   mousepos(cl,x5,y5);
   setcolor(0);
   settextstyle(SMALL_FONT,0,4);
   outtextxy(45,464,"BRUSH ");
   gg=1;
   if(cl==1)
   {
    tool=5;
   }
  }


  gg=help_bar(gg);


  mousepos(cl,x5,y5);

  while(x5>=6&&x5<=18&&y5>=120&&y5<=134)
  {
   mousepos(cl,x5,y5);
   setcolor(0);
   settextstyle(SMALL_FONT,0,4);
   gg=1;
   outtextxy(45,464,"FILLER");
   if(cl==1)
   {
    tool=6;
   }
  }

  gg=help_bar(gg);

  mousepos(cl,x5,y5);
  static int v=0;
  if(x5>39 && x5<78 && y5>=42 && y5<=55)     //save
  {
   if(cl==1)
   {
    char f[20];
    hidemouse();
    SBMP("temp.bmp");
    if(op('b'))
    {
     strcpy(f,s);
     if(!strchr(f,'.'))
      strcat(f,".bmp");
     int check;
     check=rename("temp.bmp",f);
     if(check==-1)
     {
      remove(f);
      rename("temp.bmp",f);
     }
    }

    if(v==0)
    {
     if(op('c'))
     {
      v=1;
      if(!strchr(s,'.'))
       strcat(s,".cpp");
      strcpy(::f,s);
     }
     else if(bmp("temp.bmp",0,0))
	  {}
	  else
	   bmp(f,0,0);

    }
    if(bmp(f,0,0));
    else
     bmp("temp.bmp",0,0);
    mousecall();
   }
  }

   mousepos(cl,x5,y5);

  if(x5>=10 && x5<39 && y5>=42 && y5<=55)          //open
  {
   if(cl==1)
   {
    hidemouse();
    SBMP("temp.bmp");
    if(op('o'))
    {
     if(!strchr(s,'.'))
      strcat(s,".bmp");

     if(bmp(s,0,0))
     {
      settextstyle(2,0,7);
      cleardevice();
      setcolor(RED);
      outtextxy(200,220," SUCH FILE DOES NOT EXIST");
      outtextxy(200,280,"PRESS ENTER TO CONTINUE:");
      getch();
      bmp("temp.bmp",0,0);
     }
     }
    else
     bmp("temp.bmp",0,0);
    mousecall();
   }

  }

    mousepos(cl,x5,y5);
  if(x5>78 && x5<111 && y5>=42 && y5<=55)          //new
  { if(cl==1)
  {
   v=0;
   main('n');
  }
  }


    mousepos(cl,x5,y5);
 if(x5>111 && x5<174 && y5>=42 && y5<=55)          //password change
  { if(cl==1)
   {
    hidemouse();
    SBMP("temp.bmp");
    if(op('p'))
    {
     ofstream fout("pass.txt");
     char t[20];
     for(int m=0;s[m]!='\0';m++)
     {
      t[m]=s[m]-27;
     }
     t[m]='\0';
     fout<<t;
     fout.close();
    }
    bmp("temp.bmp",0,0);
    mousecall();

   }
  }


    mousepos(cl,x5,y5);
 if(x5>174 && x5<217 && y5>=42 && y5<=55)          //help
  { if(cl==1)
   {
    hidemouse();
    SBMP("temp.bmp");
    help();
    bmp("temp.bmp",0,0);
    mousecall();
   }
  }



  while(x5>43 && x5<597 && y5>63  && y5<457)
  {
   mousepos(cl,x5,y5);
   mousecall();
   if(cl==1 && x5>43 && x5<597 && y5>63  && y5<457 )
   {
    double a,b,p,x1,y1,x2,y2;
    static int v1=0,v2=0,v3=0,v4=0;
    double r;
    switch(tool)
    {
     case 0://rectangle

     mousecall();
     x1=x5;
     y1=y5;

     delay(500);
     restrict(43,597,63,457);
     mousepos(cl,x5,y5);

     x2=x5,y2=y5;
     setcolor(c);
     hidemouse();
     rectangle(x1,y1,x2,y2);
     if(v1!=x1 || v2!=x2 || v3!=y1 || v4!=y2)
     {
      fout<<"rectangle("<<x1<<','<<y1<<','<<x2<<','<<y2<<");\n";
      v1=x1,v2=x2,v3=y1,v4=y2;
     }
     mousecall();
     restrict(0,640,0,480);
	  break;
   case 1:eraser();
	  break;
   case 2://line();

   mousecall();
   x1=x5;
   y1=y5;

   delay(500);
   restrict(43,597,63,457);
   mousepos(cl,x5,y5);

   x2=x5,y2=y5;
   setcolor(c);
   hidemouse();
   line(x1,y1,x2,y2);
   if(v1!=x1 || v2!=x2 || v3!=y1 || v4!=y2)
   {
    fout<<"line("<<x1<<','<<y1<<','<<x2<<','<<y2<<");\n";
    v1=x1,v2=x2,v3=y1,v4=y2;
   }
   mousecall();
   restrict(0,640,0,480);
	  break;
   case 3://circle();

   mousecall();
   x1=x5;
   y1=y5;

   delay(500);

   restrict(43,597,63,457);
   mousepos(cl,x5,y5);

   x2=x5,y2=y5;
   a=(x1-x2)*(x1-x2),b=(y1-y2)*(y1-y2);
   p=a+b;
   r=SQRT(p);
   setcolor(c);
   int c1=x1+r,c2=x1-r,c3=y1+r,c4=y1-r;
   hidemouse();
   circle(x1,y1,r);
   if(v1!=x1 || v2!=y1)
   {
    fout<<"circle("<<x1<<','<<y1<<','<<r<<");\n";
    v1=x1,v2=y1;
   }
   if(c1>597 || c2<43 || c3>457 || c4<63)
    SCREEN();
   mousecall();
   restrict(0,640,0,480);
   break;
   case 4:bucket();
	  break;
   case 5:brush(x5,y5);
	  break;
   case 6:fillp();
	  break;
   default:brush(x5,y5);
    }
   }
  }
 }while(1);
}
dlgAbout::dlgAbout(wxWindow* parent)
{
    if (!wxXmlResource::Get()->LoadObject(this, parent, _T("dlgAbout"), _T("wxScrollingDialog")))
    {
        cbMessageBox(_("There was an error loading the \"About\" dialog from XRC file."),
                     _("Information"), wxICON_EXCLAMATION);
        return;
    }

    XRCCTRL(*this, "wxID_CANCEL", wxButton)->SetDefault();

    const wxString description = _("Welcome to ") + appglobals::AppName + _T(" ") +
                                 appglobals::AppVersion + _T("!\n") + appglobals::AppName +
                                 _(" is a full-featured IDE (Integrated Development Environment) "
                                   "aiming to make the individual developer (and the development team) "
                                   "work in a nice programming environment offering everything he/they "
                                   "would ever need from a program of that kind.\n"
                                   "Its pluggable architecture allows you, the developer, to add "
                                   "any kind of functionality to the core program, through the use of "
                                   "plugins...\n");

    wxString file = ConfigManager::ReadDataPath() + _T("/images/splash_1312.png");
    wxImage im; im.LoadFile(file, wxBITMAP_TYPE_PNG); im.ConvertAlphaToMask();
    wxBitmap bmp(im);
    wxMemoryDC dc;
    dc.SelectObject(bmp);
    cbSplashScreen::DrawReleaseInfo(dc);

    wxStaticBitmap *bmpControl = XRCCTRL(*this, "lblTitle", wxStaticBitmap);
    bmpControl->SetSize(im.GetWidth(),im.GetHeight());
    bmpControl->SetBitmap(bmp);

    XRCCTRL(*this, "lblBuildTimestamp", wxStaticText)->SetLabel(wxString(_("Build: ")) + appglobals::AppBuildTimestamp);
    XRCCTRL(*this, "txtDescription",    wxTextCtrl)->SetValue(description);
    XRCCTRL(*this, "txtThanksTo",       wxTextCtrl)->SetValue(_(
        "Developers:\n"
        "--------------\n"
        "Yiannis Mandravellos: Developer - Project leader\n"
        "Thomas Denk         : Developer\n"
        "Lieven de C**k      : Developer\n"
        "\"tiwag\"             : Developer\n"
        "Martin Halle        : Developer\n"
        "Biplab Modak        : Developer\n"
        "Jens Lody           : Developer\n"
        "Yuchen Deng         : Developer\n"
        "Teodor Petrov       : Developer\n"
        "Daniel Anselmi      : Developer\n"
        "Yuanhui Zhang       : Developer\n"
        "Damien Moore        : Developer\n"
        "Micah Ng            : Developer\n"
        "Ricardo Garcia      : All-hands person\n"
        "Paul A. Jimenez     : Help and AStyle plugins\n"
        "Thomas Lorblanches  : CodeStat and Profiler plugins\n"
        "Bartlomiej Swiecki  : wxSmith RAD plugin\n"
        "Jerome Antoine      : ThreadSearch plugin\n"
        "Pecan Heber         : Keybinder, BrowseTracker, DragScroll\n"
        "                      CodeSnippets plugins\n"
        "Arto Jonsson        : CodeSnippets plugin (passed on to Pecan)\n"
        "Darius Markauskas   : Fortran support\n"
        "Mario Cupelli       : Compiler support for embedded systems\n"
        "                      User's manual\n"
        "Jonas Zinn          : Misc. wxSmith AddOns and plugins\n"
        "Mirai Computing     : cbp2make tool\n"
        "Anders F Bjoerklund : wxMac compatibility\n"
        "\n"
        "Contributors (in no special order):\n"
        "-----------------------------------\n"
        "Daniel Orb          : RPM spec file and packages\n"
        "byo,elvstone, me22  : Conversion to Unicode\n"
        "pasgui              : Providing Ubuntu nightly packages\n"
        "Hakki Dogusan       : DigitalMars compiler support\n"
        "ybx                 : OpenWatcom compiler support\n"
        "Tim Baker           : Patches for the direct-compile-mode\n"
        "                      dependencies generation system\n"
        "David Perfors       : Unicode tester and future documentation writer\n"
        "Sylvain Prat        : Initial MSVC workspace and project importers\n"
        "Chris Raschko       : Design of the 3D logo for Code::Blocks\n"
        "J.A. Ortega         : 3D Icon based on the above\n"
        "Alexandr Efremo     : Providing OpenSuSe packages\n"
        "Huki                : Misc. Code-Completion improvements\n"
        "stahta01            : Misc. patches for several enhancements\n"
        "BlueHazzard         : Misc. patches for several enhancements\n"
        "\n"
        "All contributors that provided patches.\n"
        "The wxWidgets project (http://www.wxwidgets.org).\n"
        "wxScintilla (http://sourceforge.net/projects/wxscintilla).\n"
        "TinyXML parser (http://www.grinninglizard.com/tinyxml).\n"
        "Squirrel scripting language (http://www.squirrel-lang.org).\n"
        "The GNU Software Foundation (http://www.gnu.org).\n"
        "Last, but not least, the open-source community."));
    XRCCTRL(*this, "txtLicense", wxTextCtrl)->SetValue(LICENSE_GPL);

    XRCCTRL(*this, "lblName",    wxStaticText)->SetLabel(appglobals::AppName);
    XRCCTRL(*this, "lblVersion", wxStaticText)->SetLabel(appglobals::AppActualVersionVerb);
    XRCCTRL(*this, "lblSDK",     wxStaticText)->SetLabel(appglobals::AppSDKVersion);
    XRCCTRL(*this, "lblAuthor",  wxStaticText)->SetLabel(_("The Code::Blocks Team"));
    XRCCTRL(*this, "lblEmail",   wxStaticText)->SetLabel(appglobals::AppContactEmail);
    XRCCTRL(*this, "lblWebsite", wxStaticText)->SetLabel(appglobals::AppUrl);

#ifdef __WXMAC__
    // Courier 8 point is not readable on Mac OS X, increase font size:
    wxFont font1 = XRCCTRL(*this, "txtThanksTo", wxTextCtrl)->GetFont();
    font1.SetPointSize(10);
    XRCCTRL(*this, "txtThanksTo", wxTextCtrl)->SetFont(font1);

    wxFont font2 = XRCCTRL(*this, "txtLicense", wxTextCtrl)->GetFont();
    font2.SetPointSize(10);
    XRCCTRL(*this, "txtLicense", wxTextCtrl)->SetFont(font2);
#endif
    Fit();
    CentreOnParent();
}
Пример #14
0
MusicRemoteWidget::MusicRemoteWidget(QWidget *parent)
    : MusicAbstractMoveWidget(parent)
{
    setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint);
    drawWindowShadow(false);

    QBitmap bmp(size());
    bmp.fill();
    QPainter p(&bmp);
    p.setPen(Qt::NoPen);
    p.setBrush(Qt::black);
    p.drawRoundedRect(bmp.rect(), 4, 4);
    setMask(bmp);

    setMouseTracking(true);

    m_showMainWindow = new QPushButton(this);
    m_PreSongButton = new QPushButton(this);
    m_NextSongButton = new QPushButton(this);
    m_PlayButton = new QPushButton(this);
    m_SettingButton = new QPushButton(this);
    m_mainWidget = new QWidget(this);
    m_mainWidget->setObjectName("mainWidget");

    m_showMainWindow->setStyleSheet(MusicUIObject::MPushButtonStyle04);
    m_showMainWindow->setIcon(QIcon(":/image/windowicon"));
    m_PreSongButton->setIcon(QIcon(":/desktopTool/previousP"));
    m_NextSongButton->setIcon(QIcon(":/desktopTool/nextP"));
    m_PlayButton->setIcon(QIcon(":/desktopTool/play"));
    m_SettingButton->setIcon(QIcon(":/desktopTool/setting"));
    m_showMainWindow->setToolTip(tr("showMainWindow"));
    m_PreSongButton->setToolTip(tr("Privious"));
    m_NextSongButton->setToolTip(tr("Next"));
    m_PlayButton->setToolTip(tr("Play"));
    m_SettingButton->setToolTip(tr("showSetting"));
    m_showMainWindow->setCursor(QCursor(Qt::PointingHandCursor));
    m_PreSongButton->setCursor(QCursor(Qt::PointingHandCursor));
    m_NextSongButton->setCursor(QCursor(Qt::PointingHandCursor));
    m_PlayButton->setCursor(QCursor(Qt::PointingHandCursor));
    m_SettingButton->setCursor(QCursor(Qt::PointingHandCursor));
    connect(m_showMainWindow, SIGNAL(clicked()), SIGNAL(musicWindowSignal()));
    connect(m_PlayButton, SIGNAL(clicked()), SIGNAL(musicKeySignal()));
    connect(m_PreSongButton, SIGNAL(clicked()), SIGNAL(musicPlayPriviousSignal()));
    connect(m_NextSongButton, SIGNAL(clicked()), SIGNAL(musicPlayNextSignal()));
    connect(m_SettingButton, SIGNAL(clicked()), SIGNAL(musicSettingSignal()));

    m_volumeWidget = new QWidget(m_mainWidget);
    QHBoxLayout *volumnLayout = new QHBoxLayout(m_volumeWidget);
    volumnLayout->setContentsMargins(0, 0, 0, 0);
    volumnLayout->setSpacing(1);
    m_volumeLabel = new QLabel(m_volumeWidget);
    m_volumeLabel->setStyleSheet(MusicUIObject::MCustomStyle26);
    m_volumeLabel->setFixedSize(QSize(20, 20));
    m_volumeSlider = new QSlider(Qt::Horizontal, m_volumeWidget);
    m_volumeSlider->setRange(0, 100);
    m_volumeSlider->setStyleSheet(MusicUIObject::MSliderStyle04);
    m_volumeSlider->setFixedWidth(45);
    volumnLayout->addWidget(m_volumeLabel);
    volumnLayout->addWidget(m_volumeSlider);
    m_volumeSlider->setCursor(QCursor(Qt::PointingHandCursor));
    connect(m_volumeSlider, SIGNAL(valueChanged(int)), SLOT(musicVolumeChanged(int)));
}
Пример #15
0
    void SetBackgroundColours(wxColour colStart, wxColour colEnd)
    {
        if ( !colStart.IsOk() )
        {
            // Determine the best colour(s) to use on our own.
#ifdef __WXMSW__
            wxUxThemeEngine* const theme = GetTooltipTheme();
            if ( theme )
            {
                wxUxThemeHandle hTheme(GetParent(), L"TOOLTIP");

                COLORREF c1, c2;
                if ( FAILED(theme->GetThemeColor
                                   (
                                        hTheme,
                                        TTP_BALLOONTITLE,
                                        0,
                                        TMT_GRADIENTCOLOR1,
                                        &c1
                                    )) ||
                    FAILED(theme->GetThemeColor
                                  (
                                        hTheme,
                                        TTP_BALLOONTITLE,
                                        0,
                                        TMT_GRADIENTCOLOR2,
                                        &c2
                                  )) )
                {
                    c1 = 0xffffff;
                    c2 = 0xf0e5e4;
                }

                colStart = wxRGBToColour(c1);
                colEnd = wxRGBToColour(c2);
            }
            else
#endif // __WXMSW__
            {
                colStart = wxSystemSettings::GetColour(wxSYS_COLOUR_INFOBK);
            }
        }

        if ( colEnd.IsOk() )
        {
            // Use gradient-filled background bitmap.
            const wxSize size = GetClientSize();
            wxBitmap bmp(size);
            {
                wxMemoryDC dc(bmp);
                dc.Clear();
                dc.GradientFillLinear(size, colStart, colEnd, wxDOWN);
            }

            SetBackgroundBitmap(bmp);
        }
        else // Use solid colour.
        {
            SetBackgroundColour(colStart);
        }
    }
Пример #16
0
wxIcon::wxIcon( char **bits )
{
    wxBitmap bmp( bits ) ;
    CopyFromBitmap( bmp ) ;
}
Пример #17
0
void CtrlList::makeImage()
{
    if( m_pImage )
    {
        delete m_pImage;
    }

    // Get the size of the control
    const Position *pPos = getPosition();
    if( !pPos )
    {
        return;
    }
    int width = pPos->getWidth();
    int height = pPos->getHeight();
    int itemHeight = m_rFont.getSize() + LINE_INTERVAL;

    // Create an image
    OSFactory *pOsFactory = OSFactory::instance( getIntf() );
    m_pImage = pOsFactory->createOSGraphics( width, height );

    VarList::ConstIterator it = m_rList[m_lastPos];

    // Draw the background
    if( m_pBitmap )
    {
        // A background bitmap is given, so we scale it, ignoring the
        // background colors
        ScaledBitmap bmp( getIntf(), *m_pBitmap, width, height );
        m_pImage->drawBitmap( bmp, 0, 0 );

        // Take care of the selection color
        for( int yPos = 0; yPos < height; yPos += itemHeight )
        {
            int rectHeight = __MIN( itemHeight, height - yPos );
            if( it != m_rList.end() )
            {
                if( (*it).m_selected )
                {
                    m_pImage->fillRect( 0, yPos, width, rectHeight,
                                        m_selColor );
                }
                it++;
            }
        }
    }
    else
    {
        // No background bitmap, so use the 2 background colors
        // Current background color
        uint32_t bgColor = m_bgColor1;
        for( int yPos = 0; yPos < height; yPos += itemHeight )
        {
            int rectHeight = __MIN( itemHeight, height - yPos );
            if( it != m_rList.end() )
            {
                uint32_t color = ( (*it).m_selected ? m_selColor : bgColor );
                m_pImage->fillRect( 0, yPos, width, rectHeight, color );
                it++;
            }
            else
            {
                m_pImage->fillRect( 0, yPos, width, rectHeight, bgColor );
            }
            // Flip the background color
            bgColor = ( bgColor == m_bgColor1 ? m_bgColor2 : m_bgColor1 );
        }
    }

    // Draw the items
    int yPos = 0;
    for( it = m_rList[m_lastPos]; it != m_rList.end() && yPos < height; it++ )
    {
        UString *pStr = (UString*)(it->m_cString.get());
        uint32_t color = ( it->m_playing ? m_playColor : m_fgColor );

        // Draw the text
        GenericBitmap *pText = m_rFont.drawString( *pStr, color, width );
        if( !pText )
        {
            return;
        }
        yPos += itemHeight - pText->getHeight();
        int ySrc = 0;
        if( yPos < 0 )
        {
            ySrc = - yPos;
            yPos = 0;
        }
        int lineHeight = __MIN( pText->getHeight() - ySrc, height - yPos );
        m_pImage->drawBitmap( *pText, 0, ySrc, 0, yPos, pText->getWidth(),
                              lineHeight, true );
        yPos += (pText->getHeight() - ySrc );
        delete pText;

    }
}
Пример #18
0
void wxDynamicSashWindowImpl::DrawSash(int x, int y) const
{
    int i, j;

    wxScreenDC dc;
    dc.StartDrawingOnTop(m_container);

    wxBitmap bmp(8, 8);
    wxMemoryDC bdc;
    bdc.SelectObject(bmp);
    bdc.DrawRectangle(-1, -1, 10, 10);
    for (i = 0; i < 8; i++)
    {
        for (j = 0; j < 8; j++)
        {
            if ((i + j) & 1)
                bdc.DrawPoint(i, j);
        }
    }

    wxBrush brush(bmp);
    dc.SetBrush(brush);
    dc.SetLogicalFunction(wxXOR);

    if ((m_dragging == DSR_CORNER) &&
        (m_window->GetWindowStyle() & wxDS_DRAG_CORNER) != 0)
    {
        int cx = 0;
        int cy = 0;

        m_container->ClientToScreen(&cx, &cy);
        m_container->ClientToScreen(&x, &y);

        if (cx < x && cy < y)
        {
            dc.DrawRectangle(cx - 2, cy - 2, x - cx + 4, 4);
            dc.DrawRectangle(x - 2, cy + 2, 4, y - cy);
            dc.DrawRectangle(cx - 2, cy + 2, 4, y - cy);
            dc.DrawRectangle(cx + 2, y - 2, x - cx - 4, 4);
        }
    }
    else
    {
        int body_w, body_h;
        m_container->GetClientSize(&body_w, &body_h);

        if (y < 0)
            y = 0;
        if (y > body_h)
            y = body_h;
        if (x < 0)
            x = 0;
        if (x > body_w)
            x = body_w;

        if (m_dragging == DSR_HORIZONTAL_TAB)
            x = 0;
        else
            y = 0;

        m_container->ClientToScreen(&x, &y);

        int w, h;
        w = body_w;  h = body_h;

        if (m_dragging == DSR_HORIZONTAL_TAB)
            dc.DrawRectangle(x, y - 2, w, 4);
        else
            dc.DrawRectangle(x - 2, y, 4, h);
    }

    dc.EndDrawingOnTop();
}
wxCodeCompletionBox::wxCodeCompletionBox(wxWindow* parent, wxEvtHandler* eventObject, size_t flags)
    : wxCodeCompletionBoxBase(parent)
    , m_index(0)
    , m_stc(NULL)
    , m_startPos(wxNOT_FOUND)
    , m_useLightColours(false)
    , m_eventObject(eventObject)
    , m_tipWindow(NULL)
    , m_flags(flags)
{
    SetBackgroundStyle(wxBG_STYLE_PAINT);
    m_ccFont = DrawingUtils::GetDefaultFixedFont();
    SetCursor(wxCURSOR_HAND);

    // Update the BOX_WIDTH to contains at least 30 chars
    static int once = false;
    if(!once) {
        once = true;
        wxMemoryDC memDC;
        wxBitmap bmp(1, 1);
        memDC.SelectObject(bmp);
        memDC.SetFont(m_ccFont);
        wxString sampleString('X', 50);
        wxSize sz = memDC.GetTextExtent(sampleString);
        BOX_WIDTH = sz.GetWidth() + SCROLLBAR_WIDTH;
    }

    // Calculate the size of the box
    int singleLineHeight = GetSingleLineHeight();
    int boxHeight = singleLineHeight * LINES_PER_PAGE;
    int boxWidth = BOX_WIDTH; // 100 pixels
    wxSize boxSize = wxSize(boxWidth, boxHeight);
    wxRect rect(boxSize);

    // Set the default bitmap list
    BitmapLoader* bmpLoader = clGetManager()->GetStdIcons();
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/class"));              // 0
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/struct"));             // 1
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/namespace"));          // 2
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/member_public"));      // 3
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/typedef"));            // 4
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/member_private"));     // 5
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/member_public"));      // 6
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/member_protected"));   // 7
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/function_private"));   // 8
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/function_public"));    // 9
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/function_protected")); // 10
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/typedef"));            // 11
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/enum"));               // 12
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/enumerator"));         // 13
    m_bitmaps.push_back(bmpLoader->LoadBitmap("mime/16/cpp"));              // 14
    m_bitmaps.push_back(bmpLoader->LoadBitmap("mime/16/h"));                // 15
    m_bitmaps.push_back(bmpLoader->LoadBitmap("mime/16/text"));             // 16
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/cpp_keyword"));        // 17

    InitializeDefaultBitmaps();

    // Increase the size by 2 pixel for each dimension
    rect.Inflate(2, 2);
    SetSize(rect);
    m_canvas->SetBackgroundStyle(wxBG_STYLE_PAINT);
    m_canvas->Bind(wxEVT_LEFT_DOWN, &wxCodeCompletionBox::OnLeftDClick, this);
    m_canvas->Bind(wxEVT_LEFT_DCLICK, &wxCodeCompletionBox::OnLeftDClick, this);
    m_canvas->Bind(wxEVT_MOUSEWHEEL, &wxCodeCompletionBox::OnMouseScroll, this);

    // Default colorus (dark theme)
    clColourPalette palette = DrawingUtils::GetColourPalette();

    m_lightBorder = wxColour("rgb(77, 77, 77)");
    m_darkBorder = wxColour("rgb(54, 54, 54)");
    m_penColour = palette.penColour;
    m_bgColour = palette.bgColour;
    m_textColour = palette.textColour;
    m_selectedTextColour = palette.selecteTextColour;
    m_selection = palette.selectionBgColour;
    m_scrollBgColour = wxColour("rgb(50, 50, 50)");

    IManager* manager = ::clGetManager();
    if(manager) {
        IEditor* editor = manager->GetActiveEditor();
        if(editor) {
            wxColour bgColour = editor->GetCtrl()->StyleGetBackground(0);
            if(!DrawingUtils::IsDark(bgColour)) {
                m_useLightColours = true;
                // Need bright colours
                m_lightBorder = *wxWHITE;
                m_darkBorder = wxColour("rgb(207, 207, 207)");
                m_scrollBgColour = wxColour("rgb(198, 198, 198)");
            }
        }
    }

    m_bmpDown = wxXmlResource::Get()->LoadBitmap("cc-box-down");
    m_bmpDownEnabled = m_bmpDown.ConvertToDisabled();

    m_bmpUp = wxXmlResource::Get()->LoadBitmap("cc-box-up");
    m_bmpUpEnabled = m_bmpUp.ConvertToDisabled();

    if(m_useLightColours) {
        // swap between the disabled and enabeld bitmaps
        {
            wxBitmap tmpBitmap;
            tmpBitmap = m_bmpDown;
            m_bmpDown = m_bmpDownEnabled;
            m_bmpDownEnabled = tmpBitmap;
        }

        {
            wxBitmap tmpBitmap;
            tmpBitmap = m_bmpUp;
            m_bmpUp = m_bmpUpEnabled;
            m_bmpUpEnabled = tmpBitmap;
        }
    }
}
Пример #20
0
bool wxWindowsPrintPreview::RenderPageFragment(float scaleX, float scaleY,
                                               int *nextFinalLine,
                                               wxPrinterDC& printer,
                                               wxMemoryDC& finalDC,
                                               const wxRect& rect,
                                               int pageNum)
{
    // compute 'rect' equivalent in the small final bitmap:
    const wxRect smallRect(wxPoint(0, *nextFinalLine),
                           wxPoint(int(rect.GetRight() * scaleX),
                                   int(rect.GetBottom() * scaleY)));
    wxLogTrace("printing",
               "rendering fragment of page %i: [%i,%i,%i,%i] scaled down to [%i,%i,%i,%i]",
               pageNum,
               rect.x, rect.y, rect.GetRight(), rect.GetBottom(),
               smallRect.x, smallRect.y, smallRect.GetRight(), smallRect.GetBottom()
               );

    // create DC and bitmap compatible with printer DC:
    wxBitmap large(rect.width, rect.height, printer);
    if ( !large.IsOk() )
        return false;

    // render part of the page into it:
    {
        PageFragmentDC memoryDC(&printer, large,
                                rect.GetPosition(),
                                wxSize(m_pageWidth, m_pageHeight));
        if ( !memoryDC.IsOk() )
            return false;

        memoryDC.Clear();

        if ( !RenderPageIntoDC(memoryDC, pageNum) )
            return false;
    } // release bitmap from memoryDC

    // now scale the rendered part down and blit it into final output:

    wxImage img;
    {
        wxDIB dib(large);
        if ( !dib.IsOk() )
            return false;
        large = wxNullBitmap; // free memory a.s.a.p.
        img = dib.ConvertToImage();
    } // free the DIB now that it's no longer needed, too

    if ( !img.IsOk() )
        return false;

    img.Rescale(smallRect.width, smallRect.height, wxIMAGE_QUALITY_HIGH);
    if ( !img.IsOk() )
        return false;

    wxBitmap bmp(img);
    if ( !bmp.IsOk() )
        return false;

    img = wxNullImage;
    finalDC.DrawBitmap(bmp, smallRect.x, smallRect.y);
    if ( bmp.IsOk() )
    {
        *nextFinalLine += smallRect.height;
        return true;
    }

    return false;
}
Пример #21
0
wxDragResult wxPageContainer::OnDropTarget(wxCoord x, wxCoord y, int nTabPage, wxWindow * wnd_oldContainer)
{
	// Disable drag'n'drop for disabled tab
	if(!((wxPageContainer *)wnd_oldContainer)->m_pagesInfoVec[nTabPage].GetEnabled())
		return wxDragCancel;

	wxLogTrace(wxTraceMask(), _("Old Page Index = %i"), nTabPage);
	wxPageContainer * oldContainer = (wxPageContainer *)wnd_oldContainer;
	int nIndex = -1;
	wxPageInfo pgInfo;
	int where = HitTest(wxPoint(x, y), pgInfo, nIndex);
	wxLogTrace(wxTraceMask(), _("OnDropTarget: index by HitTest = %i"), nIndex);
	wxFlatNotebook * oldNotebook = (wxFlatNotebook *)oldContainer->GetParent();
	wxFlatNotebook * newNotebook = (wxFlatNotebook *)GetParent();

	if(oldNotebook == newNotebook)
	{
		if(nTabPage >= 0)
		{
			switch(where)
			{
			case wxFNB_TAB:
				MoveTabPage(nTabPage, nIndex);
				break;
			case wxFNB_NOWHERE:
				{
				}
				break;
			default:
				break;
			}
		}
	}
	else if ( GetParent()->GetWindowStyleFlag() & wxFNB_ALLOW_FOREIGN_DND )
	{
#if defined(__WXMSW__) || defined(__WXGTK__)
		if(nTabPage >= 0)
		{
			wxWindow * window = oldNotebook->GetPage(nTabPage);
			if(window)
			{
				wxString caption = oldContainer->GetPageText(nTabPage);

				// Pass the image to the new container
				// incase that the new container (this) does not have image list we dont pass the image
				// to the new notebook
				int newIndx( wxNOT_FOUND );

				if( m_ImageList ) 
				{
					int imageindex = oldContainer->GetPageImageIndex(nTabPage);
					if( imageindex >= 0 )
					{
						wxBitmap bmp( (*oldContainer->GetImageList())[imageindex] );
						m_ImageList->Add( bmp );
						newIndx = static_cast<int>(m_ImageList->GetCount() - 1);
					}
				}
				
				oldNotebook->RemovePage( nTabPage );
				window->Reparent( newNotebook );
				newNotebook->InsertPage(nIndex, window, caption, true, newIndx);
			}
		}
#endif
	}
	return wxDragMove;
}
Пример #22
0
// build a texture to hold minimum sized rectangles and icons used to render the chart bar
// this texture is only updated if the color scheme or chart bar height change
void Piano::BuildGLTexture()
{
    int h = GetHeight();

    wxBrush tbackBrush; // transparent back brush
    ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle();
    if(style->chartStatusWindowTransparent)
        tbackBrush = wxColour(1,1,1);
    else
        tbackBrush = m_backBrush;

    wxBrush brushes[] = { m_scBrush, m_cBrush, m_svBrush, m_vBrush, m_slBrush, m_tBrush, m_uvBrush };

    m_tex_piano_height = h;
    m_texw = 64;
    m_texh = ((sizeof brushes) / (sizeof *brushes)) * h;
    m_texh += 4*16; // for icons;

    m_texh = NextPow2(m_texh);

    if(!m_tex)
        glGenTextures( 1, &m_tex );

    glBindTexture(GL_TEXTURE_2D, m_tex);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 

    wxBitmap bmp(m_texw, m_texh);
    wxMemoryDC dc(bmp);

    dc.SetPen( *wxTRANSPARENT_PEN );
    dc.SetBrush(tbackBrush);
    dc.DrawRectangle(0, 0, m_texw, m_texh);

    // draw the needed rectangles with minimal width
    wxPen ppPen( GetGlobalColor( _T("CHBLK") ), 1, wxPENSTYLE_SOLID );
    dc.SetPen( ppPen );
    for(unsigned int b = 0; b < (sizeof brushes) / (sizeof *brushes); b++) {
        unsigned int x = 0, y = h * b;

        dc.SetBrush(brushes[b]);

        int u = 3, v = 2;
        dc.DrawRectangle(x+u, y+v, 3, h-2*v);
        x+=3+2*u;
        
        dc.DrawRoundedRectangle(x+u, y+v, 9, h-2*v, 4);
        x+=9+2*u;

        int w = 3;
        dc.DrawRoundedRectangle(x+u, y+v, 12, h-2*v, 4);
        dc.SetBrush( m_backBrush );
        dc.DrawRoundedRectangle(x+u+w, y+v+w, 12-2*w, h-2*v-2*w, 3);
        x+=12+2*u;

        if(x >= m_texw)
            printf("texture too small\n");
    }
    dc.SelectObject( wxNullBitmap );

    wxImage image = bmp.ConvertToImage();

    unsigned char *data = new unsigned char[4*m_texw*m_texh], *d = data, *e = image.GetData(), *a = image.GetAlpha();
    for(unsigned int i=0; i<m_texw*m_texh; i++) {
        if(style->chartStatusWindowTransparent &&
           e[0] == 1 && e[1] == 1 && e[2] == 1)
            d[3] = 0;
        else
            d[3] = 255;

        memcpy(d, e, 3), d+=4, e+=3;
    }

    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, m_texw, m_texh, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
    delete [] data;

    // put the bitmaps in below
    wxBitmap *bitmaps[] = {m_pInVizIconBmp, m_pTmercIconBmp, m_pSkewIconBmp, m_pPolyIconBmp};

    for(unsigned int i = 0; i < (sizeof bitmaps) / (sizeof *bitmaps); i++) {
        int iw = bitmaps[i]->GetWidth(), ih = bitmaps[i]->GetHeight();
        wxASSERT(ih <= 16);

        wxImage im = bitmaps[i]->ConvertToImage();
        unsigned char *data = new unsigned char[4*iw*ih], *d = data, *e = im.GetData(), *a = im.GetAlpha();
        for(int j = 0; j<iw*ih; j++) {
            memcpy(d, e, 3), d+=3, e+=3;
            *d = *a, d++, a++;
        }

        int off = ((sizeof brushes) / (sizeof *brushes))*h + 16*i;
        glTexSubImage2D( GL_TEXTURE_2D, 0, 0, off, iw, ih, GL_RGBA, GL_UNSIGNED_BYTE, data );
        delete [] data;
    }
}
Пример #23
0
void wxTabNavigatorWindow::Create(wxWindow* parent)
{
	long style = 0;
	if(  !wxDialog::Create(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, style) )
		return;

	wxBoxSizer *sz = new wxBoxSizer( wxVERTICAL );
	SetSizer( sz );

	long flags = wxLB_SINGLE | wxNO_BORDER ;
	m_listBox = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxSize(200, 150), 0, NULL, flags);

	static int panelHeight = 0;
	if( panelHeight == 0 )
	{
		wxMemoryDC mem_dc;

		// bitmap must be set before it can be used for anything
		wxBitmap bmp(10, 10);
		mem_dc.SelectObject(bmp);

		wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
		font.SetWeight( wxBOLD );
		mem_dc.SetFont(font);
		int w;
		mem_dc.GetTextExtent(wxT("Tp"), &w, &panelHeight);
		panelHeight += 4; // Place a spacer of 2 pixels

		// Out signpost bitmap is 24 pixels
		if( panelHeight < 24 )
			panelHeight = 24;
	}

	m_panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxSize(200, panelHeight));

	sz->Add( m_panel );
	sz->Add( m_listBox, 1, wxEXPAND );
	
	SetSizer( sz );

	// Connect events to the list box
	m_listBox->Connect(wxID_ANY, wxEVT_KEY_UP, wxKeyEventHandler(wxTabNavigatorWindow::OnKeyUp), NULL, this); 
	//Connect(wxEVT_CHAR_HOOK, wxCharEventHandler(wxTabNavigatorWindow::OnKeyUp), NULL, this);
	m_listBox->Connect(wxID_ANY, wxEVT_NAVIGATION_KEY, wxNavigationKeyEventHandler(wxTabNavigatorWindow::OnNavigationKey), NULL, this); 
	m_listBox->Connect(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler(wxTabNavigatorWindow::OnItemSelected), NULL, this);
	
	// Connect paint event to the panel
	m_panel->Connect(wxID_ANY, wxEVT_PAINT, wxPaintEventHandler(wxTabNavigatorWindow::OnPanelPaint), NULL, this);
	m_panel->Connect(wxID_ANY, wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(wxTabNavigatorWindow::OnPanelEraseBg), NULL, this);

	SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE) );
	m_listBox->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
	PopulateListControl( static_cast<wxFlatNotebook*>( parent ) );

	// Create the bitmap, only once
	if( !m_bmp.Ok() )
	{
		wxImage img(signpost_xpm);
		img.SetAlpha(signpost_alpha, true);
		m_bmp =  wxBitmap(img); 
	}
}
Пример #24
0
int main( int argc, char const * const argv[] )
{
   fbDevice_t &fb = getFB();
   image_t img ;
   memset( &img, 0, sizeof( img ) );
   
   if( 1 < argc )
   {
      if( imageFromFile( argv[1], img ) )
         printf( "%s: %u x %u pixels\n", argv[1], img.width_, img.height_ );
      else
         perror( argv[1] );
      
   }
   else
   {
      img.pixData_ = fb.getRow(0);
      img.width_   = fb.getWidth();
      img.height_  = fb.getHeight();
      img.alpha_   = 0 ;
   }

   if( img.pixData_ )
   {
      dither_t dither( (unsigned short const *)img.pixData_, img.width_, img.height_ );
      unsigned bpl = bitmap_t::bytesPerRow(img.width_);

      unsigned char * const bitmapBytes = new unsigned char[bpl*img.height_];
      bitmap_t bmp( bitmapBytes, img.width_, img.height_ );
      for( unsigned row = 0 ; row < img.height_ ; row++ )
      {
         unsigned char mask = 0x80 ;
         unsigned char *outRow = bitmapBytes+row*bpl ;
         for( unsigned col = 0 ; col < img.width_ ; col++ )
         {
            if( dither.isBlack(col,row) )
               *outRow |= mask ;
            else
               *outRow &= ~mask ;

            mask >>= 1 ;
            if( 0 == mask ){
               mask = 0x80 ;
               outRow++ ;
            }
         } // each column
      } // each row

      void const *outData ;
      unsigned outSize ;
      if( bitmapToPNG( bmp, outData, outSize ) )
      {
         printf( "%u bytes of output\n", outSize );
         char const *outFile = ( 2 < argc ) ? argv[2] : "/tmp/img.png" ;
         FILE *fOut = fopen( outFile, "wb" );
         if( fOut )
         {
            fwrite( outData, 1, outSize, fOut );
            fclose( fOut );
            printf( "%u bytes written to %s\n", outSize, outFile );
         }
         else
            perror( outFile );
         free((void *)outData);
      }
      else
         printf( "Error converting bitmap\n" );
   }
Пример #25
0
    void OnPaint(wxPaintEvent& WXUNUSED(event))
    {
        if ( opts.usePaint )
        {
            {
                wxPaintDC dc(this);
                wxGCDC gcdc;
                if ( m_renderer )
                {
                    wxGraphicsContext* gc = m_renderer->CreateContext(dc);
                    gcdc.SetGraphicsContext(gc);
                }
                BenchmarkDCAndGC("paint", dc, gcdc);
            }
            // Since some renderers use back buffers and hence
            // drawing results are not displayed when the test
            // is running then wait a second after graphics
            // contents is commited to DC to present the output.
            wxSleep(1);
        }

        if ( opts.useClient )
        {
            {
                wxClientDC dc(this);
                wxGCDC gcdc;
                if ( m_renderer )
                {
                    wxGraphicsContext* gc = m_renderer->CreateContext(dc);
                    gcdc.SetGraphicsContext(gc);
                }
                BenchmarkDCAndGC("client", dc, gcdc);
            }
            // Since some renderers use back buffers and hence
            // drawing results are not displayed when the test
            // is running then wait a second after graphics
            // contents is commited to DC to present the output.
            wxSleep(1);
        }

        if ( opts.useMemory )
        {
            {
                wxBitmap bmp(opts.width, opts.height);
                wxMemoryDC dc(bmp);
                wxGCDC gcdc;
                if ( m_renderer )
                {
                    wxGraphicsContext* gc = m_renderer->CreateContext(dc);
                    gcdc.SetGraphicsContext(gc);
                }
                BenchmarkDCAndGC("default memory", dc, gcdc);
            }
            {
                wxBitmap bmp(opts.width, opts.height, 24);
                wxMemoryDC dc(bmp);
                wxGCDC gcdc;
                if ( m_renderer )
                {
                    wxGraphicsContext* gc = m_renderer->CreateContext(dc);
                    gcdc.SetGraphicsContext(gc);
                }
                BenchmarkDCAndGC("RGB memory", dc, gcdc);
            }
            {
                wxBitmap bmp(opts.width, opts.height, 32);
                bmp.UseAlpha(false);
                wxMemoryDC dc(bmp);
                wxGCDC gcdc;
                if ( m_renderer )
                {
                    wxGraphicsContext* gc = m_renderer->CreateContext(dc);
                    gcdc.SetGraphicsContext(gc);
                }
                BenchmarkDCAndGC("0RGB memory", dc, gcdc);
            }
            {
                wxBitmap bmp(opts.width, opts.height, 32);
                bmp.UseAlpha(true);
                wxMemoryDC dc(bmp);
                wxGCDC gcdc;
                if ( m_renderer )
                {
                    wxGraphicsContext* gc = m_renderer->CreateContext(dc);
                    gcdc.SetGraphicsContext(gc);
                }
                BenchmarkDCAndGC("ARGB memory", dc, gcdc);
            }

        }

        wxTheApp->ExitMainLoop();
    }
Пример #26
0
wxImageList *PointMan::Getpmarkicon_image_list( void )
{
    // First find the largest bitmap size
    int w = 0;
    int h = 0;

    ODMarkIcon *pmi;

    for( unsigned int i = 0; i < m_pIconArray->GetCount(); i++ ) {
        pmi = (ODMarkIcon *) m_pIconArray->Item( i );
        w = wxMax(w, pmi->picon_bitmap->GetWidth());
        h = wxMax(h, pmi->picon_bitmap->GetHeight());

        // toh, 10.09.29
        // User defined icons won't be displayed in the list if they are larger than 32x32 pixels (why???)
        // Work-around: limit size
        if( w > 32 ) w = 32;
        if( h > 32 ) h = 32;

    }

    // Build an image list large enough

    if( NULL != pmarkicon_image_list ) {
        pmarkicon_image_list->RemoveAll();
        delete pmarkicon_image_list;
    }
    pmarkicon_image_list = new wxImageList( w, h );

    // Add the icons
    for( unsigned int ii = 0; ii < m_pIconArray->GetCount(); ii++ ) {
        pmi = (ODMarkIcon *) m_pIconArray->Item( ii );
        wxImage icon_image = pmi->picon_bitmap->ConvertToImage();

        // toh, 10.09.29
        // After limiting size user defined icons will be cut off
        // Work-around: rescale in one or both directions
        int h0 = icon_image.GetHeight();
        int w0 = icon_image.GetWidth();

        wxImage icon_larger;
        if( h0 <= h && w0 <= w ) {
            // Resize & Center smaller icons in the bitmap, so menus won't look so weird.
            icon_larger = icon_image.Resize( wxSize( w, h ), wxPoint( (w-w0)/2, (h-h0)/2 ) );
        } else {
            // rescale in one or two directions to avoid cropping, then resize to fit to cell
            int h1 = h;
            int w1 = w;
            if( h0 > h ) w1 = wxRound( (double) w0 * ( (double) h / (double) h0 ) );

            else if( w0 > w ) h1 = wxRound( (double) h0 * ( (double) w / (double) w0 ) );

            icon_larger = icon_image.Rescale( w1, h1 );
            icon_larger = icon_larger.Resize( wxSize( w, h ), wxPoint( 0, 0 ) );
        }

        pmarkicon_image_list->Add( icon_larger );
    }
    
    m_markicon_image_list_base_count = pmarkicon_image_list->GetImageCount(); 

    // Create and add "x-ed out" icons,
    // Being careful to preserve (some) transparency
    for( unsigned int ii = 0; ii < m_pIconArray->GetCount(); ii++ ) {

        wxImage img = pmarkicon_image_list->GetBitmap( ii ).ConvertToImage() ;
        img.ConvertAlphaToMask( 128 );

        unsigned char r,g,b;
        img.GetOrFindMaskColour(&r, &g, &b);
        wxColour unused_color(r,g,b);

        wxBitmap bmp0( img );
    
        wxBitmap bmp(w, h, -1 );
        wxMemoryDC mdc( bmp );
        mdc.SetBackground( wxBrush( unused_color) );
        mdc.Clear();
        mdc.DrawBitmap( bmp0, 0, 0 );
        wxColour wxRed;
        GetGlobalColor( wxS( "URED" ), &wxRed );
        wxPen red( wxRed );
        mdc.SetPen( red );
        int xm = bmp.GetWidth();
        int ym = bmp.GetHeight();
        mdc.DrawLine( 2, 2, xm-2, ym-2 );
        mdc.DrawLine( xm-2, 2, 2, ym-2 );
        mdc.SelectObject( wxNullBitmap );
        
        wxMask *pmask = new wxMask(bmp, unused_color);
        bmp.SetMask( pmask );

        pmarkicon_image_list->Add( bmp );
    }
        
    return pmarkicon_image_list;
}
Пример #27
0
HRESULT CGifSmileyCtrl::OnDrawSmiley(ATL_DRAWINFO& di, bool bCustom=false)
{
	USES_CONVERSION;
	if (di.dwDrawAspect != DVASPECT_CONTENT)
	{
		return E_FAIL;
	}
	if ( bCustom && !IsVisible(di))
	{
		return S_OK;
	}
	if (!m_pGifImage)
	{
		return E_FAIL;
	}
	RECT& rc = *(RECT*)di.prcBounds;

	HRGN hOldRgn, hNewRgn;

	if (!IsRectEmpty(&m_rectPos))
	{   //strange workaround for drawing zoom out smileys (look MS calculate it one pix larger than exactly)
		if (rc.bottom-rc.top-1 == m_rectPos.bottom-m_rectPos.top 
			&& rc.right-rc.left== m_rectPos.right-m_rectPos.left)
			rc.top+=1;
	}

	if ( bCustom )SelectSmileyClipRgn(di.hdcDraw, rc, hOldRgn, hNewRgn, TRUE);

	InflateRect(&rc,-1,0); //border offset to fix blinked cursor painting
	if ( (m_dwFlags&REO_INVERTEDSELECT) == 0 || !bCustom || m_bTransparent)
		DoDrawSmiley(di.hdcDraw, rc, rc.right-rc.left,rc.bottom-rc.top, m_nFrameSize.Width, m_nFrameSize.Height);
	else
	{
		Bitmap bmp(rc.right-rc.left,rc.bottom-rc.top, PixelFormat32bppARGB);
		Graphics g(&bmp);
		COLORREF col=(COLORREF)(m_clrBackColor);
		SolidBrush brush(Color(GetRValue(col),GetGValue(col),GetBValue(col)));
		g.FillRectangle( &brush, 0 ,0, rc.right-rc.left, rc.bottom-rc.top);
		HDC hdc=g.GetHDC();
		RECT mrc={0};
		mrc.right=rc.right-rc.left;
		mrc.bottom=rc.bottom-rc.top;
		DoDrawSmiley(hdc, mrc, mrc.right-mrc.left,mrc.bottom-mrc.top, m_nFrameSize.Width, m_nFrameSize.Height);
		InvertRect(hdc, &mrc);
		BitBlt(di.hdcDraw, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hdc, 0, 0, SRCCOPY );
		g.ReleaseHDC(hdc);       
	}
	if ((m_dwFlags&REO_SELECTED) == REO_SELECTED && bCustom)
	{
		//Draw frame around
		HBRUSH oldBrush=(HBRUSH)SelectObject(di.hdcDraw, GetStockObject(NULL_BRUSH)); 
		HPEN oldPen=(HPEN)SelectObject(di.hdcDraw, GetStockObject(BLACK_PEN));
		::Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom );
		SelectObject(di.hdcDraw, oldBrush);
		SelectObject(di.hdcDraw, oldPen);
	}
	AdvanceFrame();
	if (!bCustom) 
		m_bPaintValid=false;
	ResetClip(di.hdcDraw, hOldRgn, hNewRgn);

	return S_OK;
}
Пример #28
0
    stash::sth_glyph* stash::sth_font::get_glyph(unsigned int codepoint, short isize)
    {
        // Find code point and size.
        std::pair<unsigned int,int> key(codepoint, isize);

        if (glyphs.find( key ) != glyphs.end() )
            return &glyphs.find( key )->second;

        // Could not find glyph, create it.
        int advance,lsb,x0,y0,x1,y1;
        int g = stbtt_FindGlyphIndex(&font, codepoint);
        float scale = stbtt_ScaleForPixelHeight(&font, isize/10.0f);
        stbtt_GetGlyphHMetrics(&font, g, &advance, &lsb);
        stbtt_GetGlyphBitmapBox(&font, g, scale,scale, &x0,&y0,&x1,&y1);

        int gw = x1-x0;
        int gh = y1-y0;

        // Find row where the glyph can be fit (vertically first, then horizontally)
        sth_row* br = 0;
        int rh = (gh+7) & ~7;
        for (size_t i = 0; i < rows->size() && !br; ++i)
        {
            if (rows->at(i).h == rh && rows->at(i).x+gw+1 <= tw)
                br = &rows->at(i);
        }

        // If no row found, add new.
        if (br == NULL)
        {
            short py = 0;
            // Check that there is enough space.
            if (rows->size())
            {
                py = rows->back().y + rows->back().h+1;
                if (py+rh > th)
                    return 0;
            }
            // Init and add row
            rows->push_back( sth_row(0,py,rh) );
            br = &rows->back();
        }

        // Init glyph.
        sth_glyph glyph;

        glyph.codepoint = codepoint;
        glyph.size = isize;
        glyph.x0 = br->x;
        glyph.y0 = br->y;
        glyph.x1 = glyph.x0+gw;
        glyph.y1 = glyph.y0+gh;
        glyph.xadv = scale * advance;
        glyph.xoff = (float)x0;
        glyph.yoff = (float)y0;

//                glyphs[ key ] = glyphs[ key ];
        glyphs[ key ] = glyph;

        // Advance row location.
        br->x += gw+1;

        // Rasterize
        std::vector< unsigned char > bmp(gw*gh);
        if( bmp.size() )
        {
            stbtt_MakeGlyphBitmap(&font, &bmp[0], gw,gh,gw, scale,scale, g);

            // Update texture
            glBindTexture(GL_TEXTURE_2D, tex);
            glPixelStorei(GL_UNPACK_ALIGNMENT,1);
            glTexSubImage2D(GL_TEXTURE_2D, 0, glyph.x0,glyph.y0, gw,gh, GL_ALPHA,GL_UNSIGNED_BYTE,&bmp[0]);
        }

        return &glyphs[ key ];
    }
Пример #29
0
void ProcessDateTime::UpdateTexture()
{
	Status stat;
	RectF layoutBox;
	SIZE textSize;

	RectF boundingBox(0.0f, 0.0f, 32.0f, 32.0f);

	UpdateCurrentText();

	if (bUpdateTexture)
	{
		bUpdateTexture = false;

		if (hFont)
		{
			DeleteObject(hFont);
			hFont = NULL;
		}

		hFont = GetFont();

		if (!hFont)
			return;
	}

	StringFormat format(Gdiplus::StringFormat::GenericTypographic());

	SetStringFormat(format);

	HDC hdc = CreateCompatibleDC(NULL);

	Font font(hdc, hFont);
	Graphics graphics(hdc);
	graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);
	if (strCurrentText.IsValid())
	{

		stat = graphics.MeasureString(strCurrentText, -1, &font, PointF(0.0f, 0.0f), &format, &boundingBox);
		if (stat != Ok)
			Log::writeError(LOG_RTSPSERV, 1, "TextSource::UpdateTexture: Gdiplus::Graphics::MeasureString failed: %u", (int)stat);
		if (bUseOutline)
		{
			//Note: since there's no path widening in DrawOutlineText the padding is half than what it was supposed to be.
			boundingBox.Width += outlineSize;
			boundingBox.Height += outlineSize;
		}
	}

	DeleteDC(hdc);
	hdc = NULL;

	if (boundingBox.Height < size)
	{
		textSize.cy = size;
		boundingBox.Height = float(size);
	}
	else
		textSize.cy = LONG(boundingBox.Height + EPSILON);

	textSize.cx = LONG(boundingBox.Width + EPSILON);
	//textSize.cx &= 0xFFFFFFFE;
	//textSize.cy &= 0xFFFFFFFE;

	textSize.cx += textSize.cx % 2;
	textSize.cy += textSize.cy % 2;

	ClampVal(textSize.cx, 32, 8192);
	ClampVal(textSize.cy, 32, 8192);
	//----------------------------------------------------------------------
	// write image

	{
		HDC hTempDC = CreateCompatibleDC(NULL);

		BITMAPINFO bi;
		zero(&bi, sizeof(bi));

		void* lpBits;

		BITMAPINFOHEADER &bih = bi.bmiHeader;
		bih.biSize = sizeof(bih);
		bih.biBitCount = 32;
		bih.biWidth = textSize.cx;
		bih.biHeight = textSize.cy;
		bih.biPlanes = 1;

		HBITMAP hBitmap = CreateDIBSection(hTempDC, &bi, DIB_RGB_COLORS, &lpBits, NULL, 0);

		Bitmap      bmp(textSize.cx, textSize.cy, 4 * textSize.cx, PixelFormat32bppARGB, (BYTE*)lpBits);

		Graphics graphics(&bmp);

		SolidBrush  brush(Gdiplus::Color(GetAlphaVal(opacity) | (color & 0x00FFFFFF)));

		DWORD bkColor;

		
		bkColor = ((strCurrentText.IsValid()) ? GetAlphaVal(0) : GetAlphaVal(0));

		if (textSize.cx > boundingBox.Width || textSize.cy > boundingBox.Height)
		{
			stat = graphics.Clear(Gdiplus::Color(0x00000000));
			if (stat != Gdiplus::Ok)
				Log::writeError(LOG_RTSPSERV, 1, "TextSource::UpdateTexture: Graphics::Clear failed: %u", (int)stat);

			SolidBrush *bkBrush = new SolidBrush(Gdiplus::Color(bkColor));

			graphics.FillRectangle(bkBrush, boundingBox);

			delete bkBrush;
		}
		else
		{
			stat = graphics.Clear(Gdiplus::Color(bkColor));
			if (stat != Ok)
				Log::writeError(LOG_RTSPSERV, 1, "TextSource::UpdateTexture: Graphics::Clear failed: %u", (int)stat);
		}

		graphics.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);
		graphics.SetCompositingMode(Gdiplus::CompositingModeSourceOver);
		graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);

		if (strCurrentText.IsValid())
		{
			if (bUseOutline)
			{
				boundingBox.Offset(outlineSize / 2, outlineSize / 2);

				FontFamily fontFamily;
				GraphicsPath path;

				font.GetFamily(&fontFamily);

				path.AddString(strCurrentText, -1, &fontFamily, font.GetStyle(), font.GetSize(), boundingBox, &format);

				DrawOutlineText(&graphics, font, path, format, &brush);
			}
			else
			{
				stat = graphics.DrawString(strCurrentText, -1, &font, boundingBox, &format, &brush);
				if (stat != Gdiplus::Ok)
					Log::writeError(LOG_RTSPSERV, 1, "TextSource::UpdateTexture: Graphics::DrawString failed: %u", (int)stat);
			}
		}

		//----------------------------------------------------------------------
		// upload texture

		if (textureSize.cx != textSize.cx || textureSize.cy != textSize.cy)
		{
			if (texture)
			{
				delete texture;
				texture = NULL;
			}

			mcpy(&textureSize, &textSize, sizeof(textureSize));
			texture = CreateTexture(textSize.cx, textSize.cy, GS_BGRA, lpBits, FALSE, FALSE);
		}
		else if (texture)
			SetImage(texture,lpBits, GS_IMAGEFORMAT_BGRA, 4 * textSize.cx);

		if (!texture)
		{
			Log::writeError(LOG_RTSPSERV,1,"TextSource::UpdateTexture: could not create texture");
			DeleteObject(hFont);
		}

		DeleteDC(hTempDC);
		DeleteObject(hBitmap);
	}
}
Пример #30
0
std::auto_ptr<Gosu::ImageData> Gosu::Graphics::createImage(
    const Bitmap& src, unsigned srcX, unsigned srcY,
    unsigned srcWidth, unsigned srcHeight, unsigned borderFlags)
{
    static const unsigned maxSize = MAX_TEXTURE_SIZE;

    // Special case: If the texture is supposed to have hard borders,
    // is quadratic, has a size that is at least 64 pixels but less than 256
    // pixels and a power of two, create a single texture just for this image.
    if ((borderFlags & bfTileable) == bfTileable &&
        srcWidth == srcHeight &&
        (srcWidth & (srcWidth - 1)) == 0 &&
        srcWidth >= 64)
    {
        std::tr1::shared_ptr<Texture> texture(new Texture(srcWidth));
        std::auto_ptr<ImageData> data;
        
        // Use the source bitmap directly if the source area completely covers
        // it.
        if (srcX == 0 && srcWidth == src.width() &&
            srcY == 0 && srcHeight == src.height())
        {
            data = texture->tryAlloc(*this, pimpl->queues, texture, src, 0);
        }
        else
        {
            Bitmap trimmedSrc;
            trimmedSrc.resize(srcWidth, srcHeight);
            trimmedSrc.insert(src, 0, 0, srcX, srcY, srcWidth, srcHeight);
            data = texture->tryAlloc(*this, pimpl->queues, texture, trimmedSrc, 0);
        }
        
        if (!data.get())
            throw std::logic_error("Internal texture block allocation error");
        return data;
    }
    
    // Too large to fit on a single texture. 
    if (srcWidth > maxSize - 2 || srcHeight > maxSize - 2)
    {
        Bitmap bmp(srcWidth, srcHeight);
        bmp.insert(src, 0, 0, srcX, srcY, srcWidth, srcHeight);
        std::auto_ptr<ImageData> lidi;
        lidi.reset(new LargeImageData(*this, bmp, maxSize - 2, maxSize - 2, borderFlags));
        return lidi;
    }
    
    Bitmap bmp;
    applyBorderFlags(bmp, src, srcX, srcY, srcWidth, srcHeight, borderFlags);

#if 0
    std::mutex::scoped_lock lock(pimpl->texMutex);
#endif
    
    // Try to put the bitmap into one of the already allocated textures.
    for (Impl::Textures::iterator i = pimpl->textures.begin(); i != pimpl->textures.end(); ++i)
    {
        std::tr1::shared_ptr<Texture> texture(*i);
        
        std::auto_ptr<ImageData> data;
        data = texture->tryAlloc(*this, pimpl->queues, texture, bmp, 1);
        if (data.get())
            return data;
    }
    
    // All textures are full: Create a new one.
    
    std::tr1::shared_ptr<Texture> texture;
    texture.reset(new Texture(maxSize));
    pimpl->textures.push_back(texture);
    
    std::auto_ptr<ImageData> data;
    data = texture->tryAlloc(*this, pimpl->queues, texture, bmp, 1);
    if (!data.get())
        throw std::logic_error("Internal texture block allocation error");

    return data;
}