コード例 #1
0
ファイル: imaglist.cpp プロジェクト: jonntd/dynamica
// Creates an image list
bool wxImageList::Create(int width, int height, bool mask, int initial)
{
    UINT flags = 0;

    // set appropriate color depth
#ifdef __WXWINCE__
    flags |= ILC_COLOR;
#else
    int dd = wxDisplayDepth();

    if (dd <= 4)       flags |= ILC_COLOR;   // 16 color
    else if (dd <= 8)  flags |= ILC_COLOR8;  // 256 color
    else if (dd <= 16) flags |= ILC_COLOR16; // 64k hi-color
    else if (dd <= 24) flags |= ILC_COLOR24; // 16m truecolor
    else if (dd <= 32) flags |= ILC_COLOR32; // 16m truecolor
#endif

    if ( mask )
        flags |= ILC_MASK;

    // Grow by 1, I guess this is reasonable behaviour most of the time
    m_hImageList = (WXHIMAGELIST) ImageList_Create(width, height, flags,
                                                   initial, 1);
    if ( !m_hImageList )
    {
        wxLogLastError(wxT("ImageList_Create()"));
    }

    return m_hImageList != 0;
}
コード例 #2
0
ファイル: splash.cpp プロジェクト: BauerBox/wxWidgets
static void wxDrawSplashBitmap(wxDC& dc, const wxBitmap& bitmap, int WXUNUSED(x), int WXUNUSED(y))
{
    wxMemoryDC dcMem;

#ifdef USE_PALETTE_IN_SPLASH
    bool hiColour = (wxDisplayDepth() >= 16) ;

    if (bitmap.GetPalette() && !hiColour)
    {
        dcMem.SetPalette(* bitmap.GetPalette());
    }
#endif // USE_PALETTE_IN_SPLASH

    dcMem.SelectObjectAsSource(bitmap);
    dc.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), &dcMem, 0, 0, wxCOPY,
            true /* use mask */);
    dcMem.SelectObject(wxNullBitmap);

#ifdef USE_PALETTE_IN_SPLASH
    if (bitmap.GetPalette() && !hiColour)
    {
        dcMem.SetPalette(wxNullPalette);
    }
#endif // USE_PALETTE_IN_SPLASH
}
コード例 #3
0
ファイル: splash.cpp プロジェクト: EdgarTx/wx
wxSplashScreenWindow::wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style):
    wxWindow(parent, id, pos, size, style)
{
    m_bitmap = bitmap;

#if !defined(__WXGTK__) && wxUSE_PALETTE
    bool hiColour = (wxDisplayDepth() >= 16) ;

    if (bitmap.GetPalette() && !hiColour)
    {
        SetPalette(* bitmap.GetPalette());
    }
#endif

}
コード例 #4
0
ファイル: Model_Usage.cpp プロジェクト: mek-x/moneymanagerex
void Model_Usage::pageview(const wxString& documentPath, const wxString& documentTitle, int plt /* = 0 msec*/)
{
    if (!Option::instance().SendUsageStatistics())
    {
        return;
    }

    static std::string GA_URL_ENDPOINT = "http://www.google-analytics.com/collect?";

    std::string url = GA_URL_ENDPOINT;

    std::vector<std::pair<wxString, wxString>> parameters = {
        { "v", "1" },
        { "t", "pageview" },
        { "tid", "UA-51521761-6" },
        { "cid", uuid() },
        { "dp", documentPath },
        { "dt", documentTitle },
        //        {"geoid", },
        { "ul", Option::instance().Language() },
        { "sr", wxString::Format("%ix%i", wxGetDisplaySize().GetX(), wxGetDisplaySize().GetY()) },
        { "vp", "" },
        { "sd", wxString::Format("%i-bits", wxDisplayDepth()) },
        // application
        { "an", "MoneyManagerEx" },
        { "av", mmex::version::string }, // application version
                                         // custom dimensions
        { "cd1", wxPlatformInfo::Get().GetPortIdShortName() },
        { "plt", wxString::Format("%d", plt)}
    };

    for (const auto& kv : parameters)
    {
        if (kv.second.empty()) continue;
        url += wxString::Format("%s=%s&", kv.first, kv.second).ToStdString();
    }

    url.back() = ' '; // override the last &

	// Spawn thread to send statistics
	SendStatsThread* thread = new SendStatsThread(url);
	if (thread)
		thread->Run();
}
コード例 #5
0
ファイル: dib.cpp プロジェクト: CustomCardsOnline/wxWidgets
bool wxDIB::Create(HBITMAP hbmp)
{
    wxCHECK_MSG( hbmp, false, wxT("wxDIB::Create(): invalid bitmap") );

    // this bitmap could already be a DIB section in which case we don't need
    // to convert it to DIB
    DIBSECTION ds;
    if ( GetDIBSection(hbmp, &ds) )
    {
        m_handle = hbmp;

        // wxBitmap will free it, not we
        m_ownsHandle = false;

        // copy all the bitmap parameters too as we have them now anyhow
        m_width = ds.dsBm.bmWidth;
        m_height = ds.dsBm.bmHeight;
        m_depth = ds.dsBm.bmBitsPixel;

        m_data = ds.dsBm.bmBits;
    }
    else // no, it's a DDB -- convert it to DIB
    {
        // prepare all the info we need
        BITMAP bm;
        if ( !::GetObject(hbmp, sizeof(bm), &bm) )
        {
            wxLogLastError(wxT("GetObject(bitmap)"));

            return false;
        }

        int d = bm.bmBitsPixel;
        if ( d <= 0 )
            d = wxDisplayDepth();

        if ( !Create(bm.bmWidth, bm.bmHeight, d) || !CopyFromDDB(hbmp) )
            return false;
    }

    return true;
}
コード例 #6
0
ファイル: dcscreen.cpp プロジェクト: CobaltBlues/wxWidgets
bool wxScreenDCImpl::StartDrawingOnTop(wxRect* rect)
{
    if (sm_overlayWindow)
        return false;

    Display *dpy = (Display*) wxGetDisplay();
    Pixmap screenPixmap = RootWindow(dpy, DefaultScreen(dpy));

    int x = 0;
    int y = 0;
    int width, height;
    wxDisplaySize(&width, &height);

    if (rect)
    {
        x = rect->x; y = rect->y;
        width = rect->width; height = rect->height;
    }
    sm_overlayWindowX = x;
    sm_overlayWindowY = y;

    XSetWindowAttributes attributes;
    attributes.override_redirect = True;
    unsigned long valueMask = CWOverrideRedirect;

    sm_overlayWindow = (WXWindow) XCreateWindow(dpy, screenPixmap, x, y, width, height, 0,
        wxDisplayDepth(), InputOutput,
        DefaultVisual(dpy, 0), valueMask,
        & attributes);

    if (sm_overlayWindow)
    {
        XMapWindow(dpy, (Window) sm_overlayWindow);
        return true;
    }
    else
        return false;
}
コード例 #7
0
ファイル: effects.cpp プロジェクト: AaronDP/wxWidgets
bool wxEffectsImpl::TileBitmap(const wxRect& rect, wxDC& dc, const wxBitmap& bitmap)
{
    int w = bitmap.GetWidth();
    int h = bitmap.GetHeight();

    wxMemoryDC dcMem;

#if wxUSE_PALETTE
    static bool hiColour = (wxDisplayDepth() >= 16) ;
    if (bitmap.GetPalette() && !hiColour)
    {
        dc.SetPalette(* bitmap.GetPalette());
        dcMem.SetPalette(* bitmap.GetPalette());
    }
#endif // wxUSE_PALETTE

    dcMem.SelectObjectAsSource(bitmap);

    int i, j;
    for (i = rect.x; i < rect.x + rect.width; i += w)
    {
        for (j = rect.y; j < rect.y + rect.height; j+= h)
            dc.Blit(i, j, bitmap.GetWidth(), bitmap.GetHeight(), & dcMem, 0, 0);
    }
    dcMem.SelectObject(wxNullBitmap);

#if wxUSE_PALETTE
    if (bitmap.GetPalette() && !hiColour)
    {
        dc.SetPalette(wxNullPalette);
        dcMem.SetPalette(wxNullPalette);
    }
#endif // wxUSE_PALETTE

    return true;
}
コード例 #8
0
ファイル: utils.cpp プロジェクト: LuaDist/wxwidgets
// Return true if we have a colour display
bool wxColourDisplay()
{
    return wxDisplayDepth() > 1;
}
コード例 #9
0
int Platform::DisplayDepth() {
	return wxDisplayDepth();
}
コード例 #10
0
ファイル: tooltip.cpp プロジェクト: gitrider/wxsj2
void wxMacToolTip::Draw()
{
    if ( m_label.Length() == 0 )
        return ;
    
    if ( m_window == s_ToolTipWindowRef )
    {
        m_shown = true ;
#if TARGET_CARBON
        HMHelpContentRec tag ;
        tag.version = kMacHelpVersion;
        SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ;

        QDLocalToGlobalRect( GetWindowPort( m_window ) , &tag.absHotRect ) ;

        m_helpTextRef.Assign( m_label  , wxFONTENCODING_DEFAULT ) ;
        tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ;
        tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ;
        tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ;
        tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ;
        tag.tagSide = kHMDefaultSide;
        HMDisplayTag( &tag );
#else
        wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) );
        FontFamilyID fontId ;
        Str255 fontName ;
        SInt16 fontSize ;
        Style fontStyle ;
        GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
        GetFNum( fontName, &fontId );
        
        TextFont( fontId ) ;
        TextSize( fontSize ) ;
        TextFace( fontStyle ) ;
        FontInfo fontInfo;
        ::GetFontInfo(&fontInfo);
        short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
        short height = 0 ;
        
        int i = 0 ;
        int length = m_label.Length() ;
        int width = 0 ;
        int thiswidth = 0 ;
        int laststop = 0 ;
        wxCharBuffer text = m_label.mb_str( wxConvLocal)  ;

        while( i < length )
        {
            if( text[i] == 13 || text[i] == 10)
            {
                thiswidth = ::TextWidth( text , laststop , i - laststop ) ;
                if ( thiswidth > width )
                    width = thiswidth ;
                
                height += lineh ;
                laststop = i+1 ;
            }
            i++ ;
        }
        if ( i - laststop > 0 )
        {
            thiswidth = ::TextWidth( text , laststop , i - laststop ) ;
            if ( thiswidth > width )
                width = thiswidth ;
            height += lineh ;
        }
        
        m_rect.left = m_position.x + kTipOffset;
        m_rect.top = m_position.y + kTipOffset;
        m_rect.right = m_rect.left + width + 2 * kTipBorder;

        m_rect.bottom = m_rect.top + height + 2 * kTipBorder;
        Rect r ;
        GetPortBounds( GetWindowPort( m_window ) , &r ) ;
        if ( m_rect.top < 0 )
        {
            m_rect.bottom += -m_rect.top ;
            m_rect.top = 0 ;
        }
        if ( m_rect.left < 0 )
        {
            m_rect.right += -m_rect.left ;
            m_rect.left = 0 ;
        }
        if ( m_rect.right > r.right )
        {
            m_rect.left -= (m_rect.right - r.right ) ;
            m_rect.right = r.right ;
        }
        if ( m_rect.bottom > r.bottom )
        {
            m_rect.top -= (m_rect.bottom - r.bottom) ;
            m_rect.bottom = r.bottom ;
        }
        ClipRect( &m_rect ) ;
        BackColor( whiteColor ) ;
        ForeColor(blackColor ) ;
        GWorldPtr port ;            
        NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ;
        CGrafPtr    origPort ;
        GDHandle    origDevice ;
        
        GetGWorld( &origPort , &origDevice ) ;
        SetGWorld( port , NULL ) ;
        
        m_backpict = OpenPicture(&m_rect);
        
        CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), 
            GetPortBitMapForCopyBits(port), 
            &m_rect, 
            &m_rect, 
            srcCopy, 
            NULL);
        ClosePicture();
        SetGWorld( origPort , origDevice ) ;
        DisposeGWorld( port ) ;
        PenNormal() ;
        
        RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ;
        BackColor( whiteColor ) ;
        RGBForeColor( &tooltipbackground ) ;
        
        PaintRect( &m_rect ) ;
        ForeColor(blackColor ) ;
        FrameRect( &m_rect ) ;
        SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ;
        ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder);
        
        i = 0 ;
        laststop = 0 ;
        height = 0 ;
        
        while( i < length )
        {
            if( text[i] == 13 || text[i] == 10)
            {
                ::DrawText( text , laststop , i - laststop ) ;
                height += lineh ;
                ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height );
                laststop = i+1 ;
            }
            i++ ;
        }
        ::DrawText( text , laststop , i - laststop ) ;
        ::TextMode( srcOr ) ;        
#endif
    }
}
コード例 #11
0
ファイル: ScreenWx.cpp プロジェクト: cdaffara/symbiandump-mw4
int screenDepthPerComponent(Widget*)
{
    return wxDisplayDepth();
}
コード例 #12
0
ファイル: ScreenWx.cpp プロジェクト: cdaffara/symbiandump-mw4
int screenDepth(Widget* widget)
{
    return wxDisplayDepth();
}
コード例 #13
0
bool CODListBox::SetCBMCharset(byte *buffer, int nLength)
{
	byte *pbInputCharset, *pbOrderedCharset;
	wxBitmap unmaskedStd;
	wxBitmap unmaskedSel;
	wxMask *maskStd;
	wxMask *maskSel;
	wxMemoryDC srcDC;
	wxMemoryDC dstDC;
	int iScreenDepth;
	int iXCnt, iYCnt;
	byte bCharsetByte;


	// allocate memory
	pbInputCharset = (byte*)malloc(0x0800);
	if( pbInputCharset==NULL )
	{
		return false;
	}
	pbOrderedCharset = (byte*)malloc(0x0800);
	if( pbOrderedCharset==NULL )
	{
		free( pbInputCharset );
		return false;
	}

	// construct input charset
	switch( nLength )
	{
	case 2048:
	case 4096:
		// complete charset, no startaddress
		memcpy(pbInputCharset, buffer, 2048);
		break;
	case 2050:
	case 4098:
		// complete charset with startaddress
		memcpy(pbInputCharset, buffer+2, 2048);
		break;
	default:
		free(pbInputCharset);
		free(pbOrderedCharset);
		break;
	}

	// convert charset to bitmap order
	for(iYCnt=0; iYCnt<8; ++iYCnt)
	{
		for(iXCnt=0; iXCnt<256; ++iXCnt)
		{
			bCharsetByte  = pbInputCharset[iYCnt+(iXCnt<<3)];

#ifndef __WIN32__								// don't invert the charset on Win32 systems (my personal flavor)
			bCharsetByte ^= 0xff;
#endif
			bCharsetByte  = abMirrorTab[bCharsetByte];
			pbOrderedCharset[iXCnt+(iYCnt<<8)] = bCharsetByte;
		}
	}

	// get current screen depth
	iScreenDepth = wxDisplayDepth();

	// create a bitmap from the byte array
	wxBitmap charsetBitmapMono((const char*)pbOrderedCharset, 0x0800, 8, 1);

	// free the byte arrays
	free(pbInputCharset);
	free(pbOrderedCharset);

	// create 2 masks from the bitmap
	maskStd = new wxMask(charsetBitmapMono);
	maskSel = new wxMask(charsetBitmapMono);

	unmaskedStd = wxBitmap(0x0800, 8, iScreenDepth);
	unmaskedSel = wxBitmap(0x0800, 8, iScreenDepth);

	stdBitmap = wxBitmap(0x0800, 8, iScreenDepth);
	selBitmap = wxBitmap(0x0800, 8, iScreenDepth);


	srcDC.SelectObject(unmaskedStd);
	srcDC.SetBackground(tBrushStdForeground);
	srcDC.Clear();
	srcDC.SelectObject(wxNullBitmap);

	srcDC.SelectObject(unmaskedSel);
	srcDC.SetBackground(tBrushSelForeground);
	srcDC.Clear();
	srcDC.SelectObject(wxNullBitmap);

	unmaskedStd.SetMask(maskStd);
	unmaskedSel.SetMask(maskSel);

	// clear the destination standard bitmap
	dstDC.SelectObject(stdBitmap);
	dstDC.SetBackground(tBrushStdBackground);
	dstDC.Clear();
	dstDC.SelectObject(wxNullBitmap);

	// clear the destination selected bitmap
	dstDC.SelectObject(selBitmap);
	dstDC.SetBackground(tBrushSelBackground);
	dstDC.Clear();
	dstDC.SelectObject(wxNullBitmap);

	// blit the standard bitmap
	srcDC.SelectObject(unmaskedStd);
	dstDC.SelectObject(stdBitmap);
	dstDC.Blit(0, 0, 0x0800, 8, &srcDC, 0, 0, wxCOPY, true);
	srcDC.SelectObject(wxNullBitmap);
	dstDC.SelectObject(wxNullBitmap);

	srcDC.SelectObject(unmaskedSel);
	dstDC.SelectObject(selBitmap);
	dstDC.Blit(0, 0, 0x0800, 8, &srcDC, 0, 0, wxCOPY, true);
	srcDC.SelectObject(wxNullBitmap);
	dstDC.SelectObject(wxNullBitmap);

	charWidth = 8;
	charHeigth = 8;

	return true;
}