//---------------------------------------------------------------------------
// wxMediaCtrl::NextBackend (static)
//
//
// Search through the RTTI hashmap one at a
// time, attempting to create each derivative
// of wxMediaBackend
//
//
// STL isn't compatible with and will have a compilation error
// on a wxNode, however, wxHashTable::compatibility_iterator is
// incompatible with the old 2.4 stable version - but since
// we're in 2.5+ only we don't need to worry about the new version
//---------------------------------------------------------------------------
const wxClassInfo* wxMediaCtrl::NextBackend(wxClassInfo::const_iterator* it)
{
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for ( wxClassInfo::const_iterator end = wxClassInfo::end_classinfo();
          *it != end; ++(*it) )
    {
        const wxClassInfo* classInfo = **it;
        if ( classInfo->IsKindOf(wxCLASSINFO(wxMediaBackend))  &&
             classInfo != wxCLASSINFO(wxMediaBackend) )
        {
            ++(*it);
            return classInfo;
        }
    }

    //
    // Nope - couldn't successfully find one... fail
    //
    return NULL;
}
Esempio n. 2
0
void wxGxObjectDialog::OnItemSelected(wxListEvent& event)
{
	event.Skip();
    //if(m_bIsSaveDlg)
    //    return;

    wxGxDialogContentView::LPITEMDATA pItemData = (wxGxDialogContentView::LPITEMDATA)event.GetData();
	if(pItemData == NULL)
		return;

	wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pItemData->nObjectID);
    bool bIsDataset = pGxObject->IsKindOf(wxCLASSINFO(wxGxDataset)) || m_FilterArray[m_WildcardCombo->GetCurrentSelection()]->CanChooseObject(pGxObject);
    bool bIsObjContainer = pGxObject->IsKindOf(wxCLASSINFO(wxGxObjectContainer));
    if(!bIsDataset && bIsObjContainer)
    {
        return;
    }

    wxString sTempName;
	long item = wxNOT_FOUND;
	while(1)
    {
        item = m_pwxGxContentView->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if ( item == wxNOT_FOUND )
            break;
		if(sTempName.IsEmpty())
			sTempName += m_pwxGxContentView->GetItemText(item);
		else
			sTempName += wxT("; ") + m_pwxGxContentView->GetItemText(item);
    }
	if(!sTempName.IsEmpty())
        m_sName = sTempName;
	TransferDataToWindow();
}
Esempio n. 3
0
wxPanelTabView::wxPanelTabView(wxPanel *pan, long style)
    : wxTabView(style)
{
  m_panel = pan;
  m_currentWindow = NULL;

  if (m_panel->IsKindOf(wxCLASSINFO(wxTabbedDialog)))
    ((wxTabbedDialog *)m_panel)->SetTabView(this);
  else if (m_panel->IsKindOf(wxCLASSINFO(wxTabbedPanel)))
    ((wxTabbedPanel *)m_panel)->SetTabView(this);

  SetWindow(m_panel);
}
Esempio n. 4
0
bool wxStaticBitmap::Create(wxWindow *parent,
                            wxWindowID id,
                            const wxGDIImage& bitmap,
                            const wxPoint& pos,
                            const wxSize& size,
                            long style,
                            const wxString& name)
{
    if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
        return false;

    // we may have either bitmap or icon: if a bitmap with mask is passed, we
    // will transform it to an icon ourselves because otherwise the mask will
    // be ignored by Windows
    m_isIcon = bitmap.IsKindOf(wxCLASSINFO(wxIcon));

    wxGDIImage *image = ConvertImage( bitmap );
    m_isIcon = image->IsKindOf( wxCLASSINFO(wxIcon) );

    // create the native control
    if ( !MSWCreateControl(wxT("STATIC"), wxEmptyString, pos, size) )
    {
        // control creation failed
        return false;
    }

    // no need to delete the new image
    SetImageNoCopy(image);

    // GetBestSize will work properly now, so set the best size if needed
    SetInitialSize(size);

    // painting manually is reported not to work under Windows CE (see #10093),
    // so don't do it there even if this probably means that alpha is not
    // supported there -- but at least bitmaps without alpha appear correctly
#ifndef __WXWINCE__
    // Windows versions before XP (and even XP if the application has no
    // manifest and so the old comctl32.dll is used) don't draw correctly the
    // images with alpha channel so we need to draw them ourselves and it's
    // easier to just always do it rather than check if we have an image with
    // alpha or not
    if ( wxTheApp->GetComCtl32Version() < 600 )
    {
        Connect(wxEVT_PAINT, wxPaintEventHandler(wxStaticBitmap::DoPaintManually));
    }
#endif // !__WXWINCE__

    return true;
}
Esempio n. 5
0
/// Gets the style combined with the base style
wxRichTextAttr wxRichTextStyleDefinition::GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const
{
    if (m_baseStyle.IsEmpty())
        return m_style;

    bool isParaStyle = IsKindOf(wxCLASSINFO(wxRichTextParagraphStyleDefinition));
    bool isCharStyle = IsKindOf(wxCLASSINFO(wxRichTextCharacterStyleDefinition));
    bool isListStyle = IsKindOf(wxCLASSINFO(wxRichTextListStyleDefinition));
    bool isBoxStyle  = IsKindOf(wxCLASSINFO(wxRichTextBoxStyleDefinition));

    // Collect the styles, detecting loops
    wxArrayString styleNames;
    wxList styles;
    const wxRichTextStyleDefinition* def = this;
    while (def)
    {
        styles.Insert((wxObject*) def);
        styleNames.Add(def->GetName());

        wxString baseStyleName = def->GetBaseStyle();
        if (!baseStyleName.IsEmpty() && styleNames.Index(baseStyleName) == wxNOT_FOUND)
        {
            if (isParaStyle)
                def = sheet->FindParagraphStyle(baseStyleName);
            else if (isCharStyle)
                def = sheet->FindCharacterStyle(baseStyleName);
            else if (isListStyle)
                def = sheet->FindListStyle(baseStyleName);
            else if (isBoxStyle)
                def = sheet->FindBoxStyle(baseStyleName);
            else
                def = sheet->FindStyle(baseStyleName);
        }
        else
            def = NULL;
    }

    wxRichTextAttr attr;
    wxList::compatibility_iterator node = styles.GetFirst();
    while (node)
    {
        wxRichTextStyleDefinition* def = (wxRichTextStyleDefinition*) node->GetData();
        attr.Apply(def->GetStyle(), NULL);
        node = node->GetNext();
    }

    return attr;
}
Esempio n. 6
0
bool wxGenericImageList::Replace( int index, const wxBitmap &bitmap, const wxBitmap &mask )
{
    wxObjectList::compatibility_iterator node = m_images.Item( index );

    wxCHECK_MSG( node, false, wxT("wrong index in image list") );

    wxBitmap* newBitmap = (bitmap.IsKindOf(wxCLASSINFO(wxIcon))) ?
                               new wxBitmap( (const wxIcon&) bitmap )
                               : new wxBitmap(bitmap) ;

    if (index == (int) m_images.GetCount() - 1)
    {
        delete node->GetData();
        m_images.Erase( node );
        m_images.Append( newBitmap );
    }
    else
    {
        wxObjectList::compatibility_iterator next = node->GetNext();
        delete node->GetData();
        m_images.Erase( node );
        m_images.Insert( next, newBitmap );
    }

    if (mask.IsOk())
        newBitmap->SetMask(new wxMask(mask));

    return true;
}
Esempio n. 7
0
bool wxGISCatalogViewsCmd::GetEnabled(void)
{
	if(!m_pTreeView)
	{
        m_pTreeView = m_pApp->GetRegisteredWindowByType(wxCLASSINFO(wxGxTreeView));
	}

	if(m_anContentsWinIDs.empty())
	{
		WINDOWARRAY WinIDsArr = m_pApp->GetChildWindows();
        for(size_t i = 0; i < WinIDsArr.GetCount(); ++i)
		{
            wxWindow* pWnd = wxWindow::FindWindowById(WinIDsArr[i]);
			IGxContentsView* pGxContentsView = dynamic_cast<IGxContentsView*>(pWnd);
            if(pGxContentsView)
                m_anContentsWinIDs.Add(WinIDsArr[i]);
		}
	}

    switch(m_subtype)
	{
		case 2:
            return m_pTreeView != NULL;
		case 0:
		case 1:
            for(size_t i = 0; i < m_anContentsWinIDs.GetCount(); ++i)
            {
                wxWindow* pWnd = wxWindow::FindWindowById(m_anContentsWinIDs[i]);
                if(pWnd && pWnd->IsShown())// && pWnd->HasFocus()
                    return true;
            }
 		default:
			return false;
	}
}
Esempio n. 8
0
bool wxGenericImageList::Replace( int index, const wxBitmap &bitmap, const wxBitmap &mask )
{
    wxObjectList::compatibility_iterator node = m_images.Item( index );

    wxCHECK_MSG( node, false, wxT("wrong index in image list") );

    wxBitmap* newBitmap = (bitmap.IsKindOf(wxCLASSINFO(wxIcon))) ?
                             #if defined(__VISAGECPP__)
                               //just can't do this in VisualAge now, with all this new Bitmap-Icon stuff
                               //so construct it from a bitmap object until I can figure this nonsense out. (DW)
                               new wxBitmap(bitmap)
                             #else
                               new wxBitmap( (const wxIcon&) bitmap )
                             #endif
                               : new wxBitmap(bitmap) ;

    if (index == (int) m_images.GetCount() - 1)
    {
        delete node->GetData();
        m_images.Erase( node );
        m_images.Append( newBitmap );
    }
    else
    {
        wxObjectList::compatibility_iterator next = node->GetNext();
        delete node->GetData();
        m_images.Erase( node );
        m_images.Insert( next, newBitmap );
    }

    if (mask.IsOk())
        newBitmap->SetMask(new wxMask(mask));

    return true;
}
Esempio n. 9
0
static wxGDIImage* ConvertImage( const wxGDIImage& bitmap )
{
    bool isIcon = bitmap.IsKindOf( wxCLASSINFO(wxIcon) );

    if( !isIcon )
    {
        wxASSERT_MSG( wxDynamicCast(&bitmap, wxBitmap),
                      wxT("not an icon and not a bitmap?") );

        const wxBitmap& bmp = (const wxBitmap&)bitmap;
        wxMask *mask = bmp.GetMask();
        if ( mask && mask->GetMaskBitmap() )
        {
            wxIcon* icon = new wxIcon;
            icon->CopyFromBitmap(bmp);

            return icon;
        }

        return new wxBitmap( bmp );
    }

    // copying a bitmap is a cheap operation
    return new wxIcon( (const wxIcon&)bitmap );
}
Esempio n. 10
0
void wxZRColaFrame::OnForwardEventUpdate(wxUpdateUIEvent& event)
{
    wxControl *focusWnd = wxDynamicCast(FindFocus(), wxControl);
    if (focusWnd && focusWnd->IsKindOf(wxCLASSINFO(wxTextCtrl)))
        focusWnd->GetEventHandler()->ProcessEvent(event);
    else
        event.Enable(false);
}
Esempio n. 11
0
void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
                    const wxPoint& aOffset )
{
    DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();

    if( displ_opts->m_DisplayZonesMode != 0 )
        return;

    BOARD * brd = GetBoard( );
    EDA_COLOR_T color = brd->GetLayerColor(m_Layer);

    if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
        return;

#ifdef USE_WX_OVERLAY
    // If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
    if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
      return;
#endif

    if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts->m_ContrastModeDisplay )
    {
        LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;

        if( !IsOnLayer( curr_layer ) )
            ColorTurnToDarkDarkGray( &color );
    }

    if( aDrawMode & GR_HIGHLIGHT )
        ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );

    ColorApplyHighlightFlag( &color );

    SetAlpha( &color, 150 );

    GRSetDrawMode( aDC, aDrawMode );

    int l_trace = m_Width / 2;

    if( aDC->LogicalToDeviceXRel( l_trace ) <= MIN_DRAW_WIDTH )
    {
        GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, 0, color );
        return;
    }

    if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
    {
        GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
    }
    else
    {
        GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
                     m_Start.y + aOffset.y,
                     m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
    }

    // No clearance or netnames for zones
}
void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
                    const wxPoint& aOffset )
{
    auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );

    if( displ_opts->m_DisplayZonesMode != 0 )
        return;

    BOARD* brd = GetBoard();

    auto frame = static_cast<PCB_BASE_FRAME*> ( panel->GetParent() );
    auto color = frame->Settings().Colors().GetLayerColor( m_Layer );

    if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
        return;

#ifdef USE_WX_OVERLAY
    // If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
    if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
      return;
#endif

    if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts->m_ContrastModeDisplay )
    {
        PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;

        if( !IsOnLayer( curr_layer ) )
            color = COLOR4D( DARKDARKGRAY );
    }

    if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
        color.SetToLegacyHighlightColor();

    color.a = 0.588;

    GRSetDrawMode( aDC, aDrawMode );

    // Draw track as line if width <= 1pixel:
    if( aDC->LogicalToDeviceXRel( m_Width ) <= 1 )
    {
        GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
        return;
    }

    if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
    {
        GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
    }
    else
    {
        GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
                     m_Start.y + aOffset.y,
                     m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
    }

    // No clearance or netnames for zones
}
Esempio n. 13
0
//---------------------------------------------------------------------------
// wxMediaCtrl::NextBackend (static)
//
//
// Search through the RTTI hashmap one at a
// time, attempting to create each derivative
// of wxMediaBackend
//
//
// STL isn't compatible with and will have a compilation error
// on a wxNode, however, wxHashTable::compatibility_iterator is
// incompatible with the old 2.4 stable version - but since
// we're in 2.5+ only we don't need to worry about the new version
//---------------------------------------------------------------------------
const wxClassInfo* wxMediaCtrl::NextBackend(wxClassInfo::const_iterator* it)
{
    for ( wxClassInfo::const_iterator end = wxClassInfo::end_classinfo();
          *it != end; ++(*it) )
    {
        const wxClassInfo* classInfo = **it;
        if ( classInfo->IsKindOf(wxCLASSINFO(wxMediaBackend))  &&
             classInfo != wxCLASSINFO(wxMediaBackend) )
        {
            ++(*it);
            return classInfo;
        }
    }

    //
    // Nope - couldn't successfully find one... fail
    //
    return NULL;
}
Esempio n. 14
0
void wxStaticBitmap::SetImageNoCopy( wxGDIImage* image)
{
    Free();
    InvalidateBestSize();

    m_isIcon = image->IsKindOf( wxCLASSINFO(wxIcon) );
    // the image has already been copied
    m_image = image;

    int x, y;
    int w, h;
    GetPosition(&x, &y);
    GetSize(&w, &h);

#ifdef __WIN32__
    HANDLE handle = (HANDLE)m_image->GetHandle();
    LONG style = ::GetWindowLong( (HWND)GetHWND(), GWL_STYLE ) ;
    ::SetWindowLong( (HWND)GetHWND(), GWL_STYLE, ( style & ~( SS_BITMAP|SS_ICON ) ) |
                     ( m_isIcon ? SS_ICON : SS_BITMAP ) );
    HGDIOBJ oldHandle = (HGDIOBJ)::SendMessage(GetHwnd(), STM_SETIMAGE,
                  m_isIcon ? IMAGE_ICON : IMAGE_BITMAP, (LPARAM)handle);
    // detect if this is still the handle we passed before or
    // if the static-control made a copy of the bitmap!
    if (m_currentHandle != 0 && oldHandle != (HGDIOBJ) m_currentHandle)
    {
        // the static control made a copy and we are responsible for deleting it
        DeleteObject((HGDIOBJ) oldHandle);
    }
    m_currentHandle = (WXHANDLE)handle;
#endif // Win32

    if ( ImageIsOk() )
    {
        int width = image->GetWidth(),
            height = image->GetHeight();
        if ( width && height )
        {
            w = width;
            h = height;

            ::MoveWindow(GetHwnd(), x, y, width, height, FALSE);
        }
    }

    RECT rect;
    rect.left   = x;
    rect.top    = y;
    rect.right  = x + w;
    rect.bottom = y + h;
    ::InvalidateRect(GetHwndOf(GetParent()), &rect, TRUE);
}
Esempio n. 15
0
void MyFrame::OnCharHook(wxKeyEvent& evt)
{
    bool handled = false;

    // This never gets called on OSX (since we moved to wxWidgets-3.0.0), so we
    // rely on the menu accelerators on the MyFrame to provide the keyboard
    // responses. For Windows and Linux, we keep this here so the keystrokes
    // work when other windows like the Drift Tool window have focus.

    if (evt.GetKeyCode() == 'B')
    {
        if (!evt.GetEventObject()->IsKindOf(wxCLASSINFO(wxTextCtrl)))
        {
            int modifiers;
#ifdef __WXOSX__
            modifiers = 0;
            if (wxGetKeyState(WXK_ALT))
                modifiers |= wxMOD_ALT;
            if (wxGetKeyState(WXK_CONTROL))
                modifiers |= wxMOD_CONTROL;
            if (wxGetKeyState(WXK_SHIFT))
                modifiers |= wxMOD_SHIFT;
            if (wxGetKeyState(WXK_RAW_CONTROL))
                modifiers |= wxMOD_RAW_CONTROL;
#else
            modifiers = evt.GetModifiers();
#endif
            if (!modifiers)
            {
                pGuider->ToggleShowBookmarks();
                bookmarks_menu->Check(MENU_BOOKMARKS_SHOW, pGuider->GetBookmarksShown());
                handled = true;
            }
            else if (modifiers == wxMOD_CONTROL)
            {
                pGuider->DeleteAllBookmarks();
                handled = true;
            }
            else if (modifiers == wxMOD_SHIFT)
            {
                pGuider->BookmarkLockPosition();
                handled = true;
            }
        }
    }

    if (!handled)
    {
        evt.Skip();
    }
}
Esempio n. 16
0
void wxTextMeasure::Init()
{
    m_hdc = NULL;
    m_hfontOld = NULL;

    if ( m_dc )
    {
        wxClassInfo* const ci = m_dc->GetImpl()->GetClassInfo();

        if ( ci->IsKindOf(wxCLASSINFO(wxMSWDCImpl)))
        {
            m_useDCImpl = false;
        }
    }
}
Esempio n. 17
0
bool wxGenericImageList::Draw( int index, wxDC &dc, int x, int y,
                        int flags, bool WXUNUSED(solidBackground) )
{
    wxObjectList::compatibility_iterator node = m_images.Item( index );

    wxCHECK_MSG( node, false, wxT("wrong index in image list") );

    wxBitmap *bm = (wxBitmap*)node->GetData();

    if (bm->IsKindOf(wxCLASSINFO(wxIcon)))
        dc.DrawIcon( * ((wxIcon*) bm), x, y);
    else
        dc.DrawBitmap( *bm, x, y, (flags & wxIMAGELIST_DRAW_TRANSPARENT) > 0 );

    return true;
}
Esempio n. 18
0
void wxGxDiscConnection::OnObjectAdded(wxGxCatalogEvent& event)
{
    wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(event.GetObjectID());
	if(!pGxObject)
		return;
    wxString sPath(pGxObject->GetPath(), wxConvUTF8);
    wxString sConnPath(GetPath(), wxConvUTF8);
    if(sPath.StartsWith(sConnPath))
    {
        if(!IsPathWatched(sPath) && pGxObject->IsKindOf(wxCLASSINFO(wxGxFolder)))
        {
            wxFileName oFileName = wxFileName::DirName(sPath);
            m_pWatcher->Add(oFileName);
        }
    }
}
Esempio n. 19
0
bool wxGxContentView::Applies(wxGxSelection* const pSelection)
{
    wxCHECK_MSG(pSelection, false, wxT("Input wxGxSelection pointer is null"));

	for(size_t i = 0; i < pSelection->GetCount(); ++i)
	{
        wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pSelection->GetSelectedObjectId(i));
        if(pGxObject)
        {
            if(pGxObject->IsKindOf(wxCLASSINFO(wxGxObjectContainer)))
            {
                return true;
            }
        }
	}
	return false;
}
Esempio n. 20
0
void wxGxContentView::OnActivated(wxListEvent& event)
{
	//event.Skip();
	LPITEMDATA pItemData = (LPITEMDATA)event.GetData();
	if(pItemData == NULL)
		return;

    wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pItemData->nObjectID);
	IGxObjectWizard* pGxObjectWizard = dynamic_cast<IGxObjectWizard*>(pGxObject);
	if(pGxObjectWizard != NULL)
		if(!pGxObjectWizard->Invoke(this))
			return;

    if(pGxObject->IsKindOf(wxCLASSINFO(wxGxObjectContainer)))
	{
		m_pSelection->Select(pItemData->nObjectID, false, GetId());
	}
}
Esempio n. 21
0
// Collect up all module-derived classes, create an instance of each,
// and register them.
void wxModule::RegisterModules()
{
    for (wxClassInfo::const_iterator it  = wxClassInfo::begin_classinfo(),
                                     end = wxClassInfo::end_classinfo();
         it != end; ++it)
    {
        const wxClassInfo* classInfo = *it;

        if ( classInfo->IsKindOf(wxCLASSINFO(wxModule)) &&
             (classInfo != (& (wxModule::ms_classInfo))) )
        {
            wxLogTrace(TRACE_MODULE, wxT("Registering module %s"),
                       classInfo->GetClassName());
            wxModule* module = (wxModule *)classInfo->CreateObject();
            wxModule::RegisterModule(module);
        }
    }
}
Esempio n. 22
0
int wxGenericImageList::Add( const wxBitmap &bitmap )
{
    wxASSERT_MSG( (bitmap.GetWidth() >= m_width && bitmap.GetHeight() == m_height)
                  || (m_width == 0 && m_height == 0),
                  wxT("invalid bitmap size in wxImageList: this might work ")
                  wxT("on this platform but definitely won't under Windows.") );

    const int index = int(m_images.GetCount());

    if (bitmap.IsKindOf(wxCLASSINFO(wxIcon)))
    {
        m_images.Append( new wxIcon( (const wxIcon&) bitmap ) );
    }
    else
    {
        // Mimic behaviour of Windows ImageList_Add that automatically breaks up the added
        // bitmap into sub-images of the correct size
        if (m_width > 0 && bitmap.GetWidth() > m_width && bitmap.GetHeight() >= m_height)
        {
            int numImages = bitmap.GetWidth() / m_width;
            for (int subIndex = 0; subIndex < numImages; subIndex++)
            {
                wxRect rect(m_width * subIndex, 0, m_width, m_height);
                wxBitmap tmpBmp = bitmap.GetSubBitmap(rect);
                m_images.Append( new wxBitmap(tmpBmp) );
            }
        }
        else
        {
            m_images.Append( new wxBitmap(bitmap) );
        }
    }

    if (m_width == 0 && m_height == 0)
    {
        m_width = bitmap.GetWidth();
        m_height = bitmap.GetHeight();
    }

    return index;
}
Esempio n. 23
0
void wxTextMeasure::Init()
{
    m_context = NULL;
    m_layout = NULL;

#ifndef __WXGTK3__
    m_wdc = NULL;

    if ( m_dc )
    {
        wxClassInfo* const ci = m_dc->GetImpl()->GetClassInfo();

        // Currently the code here only works with wxWindowDCImpl and only in
        // wxGTK2 as wxGTK3 uses Cairo and not Pango for all its DCs.
        if ( ci->IsKindOf(wxCLASSINFO(wxWindowDCImpl)))
        {
            m_useDCImpl = false;
        }
    }
#endif // GTK+ < 3
}
Esempio n. 24
0
 virtual bool BeforeWriteDelegate( wxObjectWriter *WXUNUSED(writer),
                                 const wxObject *object,  
                                 const wxClassInfo* WXUNUSED(classInfo), 
                                 const wxPropertyInfo *propInfo, 
                                 const wxObject *&eventSink, 
                                 const wxHandlerInfo* &handlerInfo )  
 {
     // this approach would be used if the handler would not 
     // be connected really in the designer, so we have to supply 
     // the information
     const wxObject* but = wxAnyGetAsObjectPtr( m_frame->GetProperty(wxT("Button")) );
     if ( object == but && 
          propInfo == wxCLASSINFO( wxButton )->FindPropertyInfo(wxT("OnClick")) )
     {
         eventSink = m_frame;
         handlerInfo = m_frame->GetClassInfo()->
             FindHandlerInfo(wxT("ButtonClickHandler"));
         return true;
     }
     return false;
 }
Esempio n. 25
0
/* MainApp::onMenu
 * Called when a menu item is selected in the application
 *******************************************************************/
void MainApp::onMenu(wxCommandEvent& e)
{
	// Find applicable action
	string action = "";
	SAction* s_action = NULL;
	for (unsigned a = 0; a < actions.size(); a++)
	{
		if (actions[a]->getWxId() == e.GetId())
		{
			action = actions[a]->getId();
			s_action = actions[a];
			break;
		}
	}

	// If action is valid, send to all action handlers
	bool handled = false;
	if (!action.IsEmpty())
	{
		current_action = action;
		handled = doAction(action);

		// Check if triggering object is a menu item
		if (s_action && s_action->type == SAction::CHECK)
		{
			if (e.GetEventObject() && e.GetEventObject()->IsKindOf(wxCLASSINFO(wxMenuItem)))
			{
				wxMenuItem* item = (wxMenuItem*)e.GetEventObject();
				item->Check(s_action->toggled);
			}
		}

		current_action = "";
	}

	// If not handled, let something else handle it
	if (!handled)
		e.Skip();
}
Esempio n. 26
0
bool wxGISCatalogMainCmd::GetEnabled(void)
{
    wxCHECK_MSG(m_pGxApp, false, wxT("Application pointer is null"));

    wxGxSelection* pSel = m_pGxApp->GetGxSelection();
    wxGxCatalogBase* pCat = GetGxCatalog();

    switch(m_subtype)
	{
		case 0://Up One Level
            if(pCat && pSel)
            {
                wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetFirstSelectedObjectId());
                return pGxObject != NULL && pGxObject->GetParent();
            }
            return false;
		case 1:
			return true;
		case 2:
			//check if wxGxDiscConnection
            if(pCat && pSel)
            {
                wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetFirstSelectedObjectId());
                return pGxObject != NULL && pGxObject->IsKindOf(wxCLASSINFO(wxGxDiscConnection));
            }
			return false;
		case 3:
			return true;
		case 4://delete
             if(pCat && pSel)
             {
                for(size_t i = 0; i < pSel->GetCount(); ++i)
                {
                    wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetSelectedObjectId(i));
					IGxObjectEdit* pGxObjectEdit = dynamic_cast<IGxObjectEdit*>(pGxObject);
					if(pGxObjectEdit && pGxObjectEdit->CanDelete())
						return true;
                }
             }
             return false;
		case 5:
            if(pSel)
                return pSel->CanUndo();
			return false;
		case 6:
            if(pSel)
                return pSel->CanRedo();
			return false;
        case 7:
            if(pCat && pSel)
            {
                wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetFirstSelectedObjectId());
                wxGxObjectContainer* pCont = wxDynamicCast(pGxObject, wxGxObjectContainer);
                if(pCont)
                    return pCont->CanCreate(enumGISContainer, enumContFolder);
            }
			return false;
		case 8://Rename
            if(pCat && pSel)
            {
                size_t nCounter(0);
                for(size_t i = 0; i < pSel->GetCount(); ++i)
                {
                    wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetSelectedObjectId(i));
	                IGxObjectEdit* pGxObjectEdit = dynamic_cast<IGxObjectEdit*>(pGxObject);
	                if(pGxObjectEdit && pGxObjectEdit->CanRename())
                        nCounter++;
                }
                return nCounter == 1 ? true : false;
            }
            return false;
		case 9://Refresh
            if(pSel)
                return pSel->GetCount() > 0;
			return false;
		case 10://Properties
			//check if IGxObjectEditUI
            if(pCat && pSel)
            {
                wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetLastSelectedObjectId());
                return dynamic_cast<IGxObjectEditUI*>(pGxObject);
            }
			return false;
        case 11://Copy
             if(pCat && pSel)
             {
                for(size_t i = 0; i < pSel->GetCount(); ++i)
                {
                    wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetSelectedObjectId(i));
					IGxObjectEdit* pGxObjectEdit = dynamic_cast<IGxObjectEdit*>(pGxObject);
                    if(pGxObjectEdit && pGxObjectEdit->CanCopy(""))
                        return true;
                }
             }
             return false;
        case 12://Cut
             if(pCat && pSel)
             {
                for(size_t i = 0; i < pSel->GetCount(); ++i)
                {
                    wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetSelectedObjectId(i));
					IGxObjectEdit* pGxObjectEdit = dynamic_cast<IGxObjectEdit*>(pGxObject);
                    if(pGxObjectEdit && pGxObjectEdit->CanMove(""))
                        return true;
                }
             }
             return false;
        case 13://Paste
        {
            IViewDropTarget* pViewDropTarget = dynamic_cast<IViewDropTarget*>(wxWindow::FindFocus());
            if(pViewDropTarget)
            {
                if( pViewDropTarget->CanPaste() )
                {
                    wxClipboardLocker locker;
                    bool bMove(false);
                    if(!locker)
                    {
                        //
                    }
                    else
                    {
                    
                        wxTextDataObject data;                        
                        if(wxTheClipboard->GetData( data ))
                        {
                            if(data.GetText() == wxString(wxT("cut")))
                                bMove = true;
                        }                    
                    }

                    for(size_t i = 0; i < pSel->GetCount(); ++i)
                    {
                        IGxDropTarget* pGxDropTarget = dynamic_cast<IGxDropTarget*>(pCat->GetRegisterObject(pSel->GetSelectedObjectId(i)));
                        if(pGxDropTarget && wxIsDragResultOk(pGxDropTarget->CanDrop(bMove == true ? wxDragMove : wxDragCopy)))
                            return true;
                    }
                }
            }
        }
             return false;
		default:
			return false;
	}
}
Esempio n. 27
0
int wxCALLBACK GxObjectCVCompareFunction(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
{
    wxGxCatalogBase* pCatalog = GetGxCatalog();
    if(!pCatalog)
        return 0;

    wxGxContentView::LPITEMDATA pItem1 = (wxGxContentView::LPITEMDATA)item1;
 	wxGxContentView::LPITEMDATA pItem2 = (wxGxContentView::LPITEMDATA)item2;
    LPSORTDATA psortdata = (LPSORTDATA)sortData;

    wxGxObject* pGxObject1 = pCatalog->GetRegisterObject(pItem1->nObjectID);
    wxGxObject* pGxObject2 = pCatalog->GetRegisterObject(pItem2->nObjectID);

    if(psortdata->currentSortCol == 0)
        return GxObjectCompareFunction(pGxObject1, pGxObject2, psortdata->bSortAsc);
    else
    {
	    IGxObjectSort* pGxObjectSort1 = dynamic_cast<IGxObjectSort*>(pGxObject1);
        IGxObjectSort* pGxObjectSort2 = dynamic_cast<IGxObjectSort*>(pGxObject2);
        if(pGxObjectSort1 && !pGxObjectSort2)
		    return psortdata->bSortAsc == 0 ? 1 : -1;
        if(!pGxObjectSort1 && pGxObjectSort2)
		    return psortdata->bSortAsc == 0 ? -1 : 1;
        if(pGxObjectSort1 && pGxObjectSort2)
        {
            bool bAlwaysTop1 = pGxObjectSort1->IsAlwaysTop();
            bool bAlwaysTop2 = pGxObjectSort2->IsAlwaysTop();
            if(bAlwaysTop1 && !bAlwaysTop2)
		        return psortdata->bSortAsc == 0 ? 1 : -1;
            if(!bAlwaysTop1 && bAlwaysTop2)
		        return psortdata->bSortAsc == 0 ? -1 : 1;
            bool bSortEnables1 = pGxObjectSort1->IsSortEnabled();
            bool bSortEnables2 = pGxObjectSort2->IsSortEnabled();
            if(!bSortEnables1 || !bSortEnables1)
                return 0;
        }

        bool bContainerDst1 = pGxObject1->IsKindOf(wxCLASSINFO(wxGxDataset)) || pGxObject1->IsKindOf(wxCLASSINFO(wxGxDatasetContainer));
        bool bContainerDst2 = pGxObject2->IsKindOf(wxCLASSINFO(wxGxDataset)) || pGxObject2->IsKindOf(wxCLASSINFO(wxGxDatasetContainer));
        bool bContainer1 = pGxObject1->IsKindOf(wxCLASSINFO(wxGxObjectContainer));
        bool bContainer2 = pGxObject2->IsKindOf(wxCLASSINFO(wxGxObjectContainer));
        if(bContainer1 && !bContainerDst1 && bContainerDst2)
	        return psortdata->bSortAsc == 0 ? 1 : -1;
        if(bContainer2 && !bContainerDst2 && bContainerDst1)
	        return psortdata->bSortAsc == 0 ? -1 : 1;
        if(bContainer1 && !bContainer2)
	        return psortdata->bSortAsc == 0 ? 1 : -1;
        if(!bContainer1 && bContainer2)
	        return psortdata->bSortAsc == 0 ? -1 : 1;

        if(psortdata->currentSortCol == 1)
        {
            return pGxObject1->GetCategory().CmpNoCase(pGxObject2->GetCategory()) * (psortdata->bSortAsc == 0 ? -1 : 1);
        }
        else if(psortdata->currentSortCol == 2)
        {
            if(!bContainerDst1 && bContainerDst2)
                return psortdata->bSortAsc == 0 ? -1 : 1;
            else if(bContainerDst1 && !bContainerDst2)
                return psortdata->bSortAsc == 0 ? 1 : -1;
            else if(!bContainerDst1 && !bContainerDst2)
                return 0;
            else
            {
                IGxDataset* pDSt1 = dynamic_cast<IGxDataset*>(pGxObject1);
                IGxDataset* pDSt2 = dynamic_cast<IGxDataset*>(pGxObject2);
                long diff = long(pDSt1->GetSize().ToULong()) - long(pDSt2->GetSize().ToULong());
                return diff * (psortdata->bSortAsc == 0 ? -1 : 1);
            }
        }
        else if(psortdata->currentSortCol == 3)
        {
            if(!bContainerDst1 && bContainerDst2)
                return psortdata->bSortAsc == 0 ? 1 : -1;
            else if(bContainerDst1 && !bContainerDst2)
                return psortdata->bSortAsc == 0 ? -1 : 1;
            else if(!bContainerDst1 && !bContainerDst2)
                return 0;
            else
            {
                IGxDataset* pDSt1 = dynamic_cast<IGxDataset*>(pGxObject1);
                IGxDataset* pDSt2 = dynamic_cast<IGxDataset*>(pGxObject2);
                return (pDSt1->GetModificationDate() - pDSt2->GetModificationDate()).GetSeconds().ToLong() * (psortdata->bSortAsc == 0 ? -1 : 1);
            }
        }
    }
    return 0;
}
Esempio n. 28
0
void wxGISCatalogMainCmd::OnClick(void)
{
    wxCHECK_RET(m_pGxApp && m_pApp, wxT("Application pointer is null"));

    wxGxSelection* pSel = m_pGxApp->GetGxSelection();
    wxGxCatalogBase* pCat = GetGxCatalog();
    
    switch(m_subtype)
	{
		case 0:
            if(pSel && pCat)
            {
                wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetFirstSelectedObjectId());
                if(!pGxObject)
                    return; 
				wxGxObject* pParentGxObject = pGxObject->GetParent();
                if(pParentGxObject)
                {
                    pSel->Select(pParentGxObject->GetId(), false, wxGxSelection::INIT_ALL);
                }
                /*
				if(wxIsKindOf(pParentGxObject, wxGxObjectContainer))
                {
                    pSel->Select(pParentGxObject->GetId(), false, wxGxSelection::INIT_ALL);
                }
				else
				{
					wxGxObject* pGrandParentGxObject = pParentGxObject->GetParent();
					pSel->Select(pGrandParentGxObject->GetId(), false, wxGxSelection::INIT_ALL);
				}
                */
            }
			break;
		case 1://	1	Connect Folder
		{
			wxDirDialog dlg(dynamic_cast<wxWindow*>(m_pApp), wxString(_("Choose a folder to connect")));
			if(pSel && pCat && dlg.ShowModal() == wxID_OK)
			{
                wxGxCatalog* pGxCatalog = wxDynamicCast(pCat, wxGxCatalog);
                if(pGxCatalog)
                {
                    wxGxDiscConnections* pGxDiscConnections = wxDynamicCast(pGxCatalog->GetRootItemByType(wxCLASSINFO(wxGxDiscConnections)), wxGxDiscConnections);
                    if(pGxDiscConnections && pGxDiscConnections->ConnectFolder(dlg.GetPath()))
                        return;
                    else
                        wxMessageBox(_("Cannot connect folder"), _("Error"), wxOK | wxICON_ERROR);
                }
			}
			return;
		}
		case 2://	2	Disconnect Folder - duplicate Delete command 
		{
            if(pSel && pCat)
            {
                wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetFirstSelectedObjectId());
                wxGxDiscConnection* pGxDiscConnection = wxDynamicCast(pGxObject, wxGxDiscConnection);
                if(pGxDiscConnection && pGxDiscConnection->Delete())
                    return;
                else
                    wxMessageBox(_("Cannot disconnect folder"), _("Error"), wxOK | wxICON_ERROR);
            }
			return;
		}
		case 8:
            if(pSel && pCat)
            {
                wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetLastSelectedObjectId());
                wxGxView* pGxView = dynamic_cast<wxGxView*>(wxWindow::FindFocus());
                if(pGxView && pGxObject)
                    pGxView->BeginRename(pGxObject->GetId());
            }
			break;
        case 4:
            if(pSel && pCat)
            {
                bool bAskToDelete(true);

				wxGISAppConfig oConfig = GetConfig();
				bAskToDelete = oConfig.ReadBool(enumGISHKCU, m_pApp->GetAppName() + wxString(wxT("/catalog/ask_delete")), bAskToDelete);
                if(bAskToDelete)
                {
                    //show ask dialog
                    wxWindow* pWnd = dynamic_cast<wxWindow*>(m_pApp);
					wxRichMessageDialog dlg(pWnd, wxString::Format(_("Do you really want to delete %d item(s)"), pSel->GetCount()), wxString(_("Delete confirm")), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION | wxSTAY_ON_TOP | wxCENTRE);
					dlg.SetExtendedMessage(wxString(_("The result of operation cannot be undone!\nThe deleted items will remove from disk and will not put to the recycled bin.")));
					dlg.ShowCheckBox("Use my choice and do not show this dialog in future");

					int nRes = dlg.ShowModal();

					if(oConfig.IsOk())
						oConfig.Write(enumGISHKCU, m_pApp->GetAppName() + wxString(wxT("/catalog/ask_delete")), !dlg.IsCheckBoxChecked());

                    if(nRes == wxID_NO)
                        return;
                }

                for(size_t i = 0; i < pSel->GetCount(); ++i)
                {
					wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetSelectedObjectId(i));
                    IGxObjectEdit* pGxObjectEdit = dynamic_cast<IGxObjectEdit*>(pGxObject);
                    if(pGxObjectEdit && pGxObjectEdit->CanDelete())
                    {
                        if(!pGxObjectEdit->Delete())
                        {
                            wxWindow* pWnd = dynamic_cast<wxWindow*>(m_pApp);
                            if(i == pSel->GetCount() - 1)
                            {
                                wxMessageBox(wxString::Format(_("Delete '%s'failed"), pGxObject->GetName().c_str()), _("Error"), wxOK | wxICON_ERROR, pWnd);
                                return;
                            }

                            int nRes = wxMessageBox(wxString::Format(_("Cannot delete '%s'\nContinue?"), pGxObject->GetName().c_str()), _("Error"), wxYES_NO | wxICON_QUESTION, pWnd);
                            if(nRes == wxNO)
                                return;
                        }
                    }
                }
            }
            return;
        case 5:
            if(pSel && pCat)
            {
                long nSelId = wxNOT_FOUND;
                if(pSel->CanUndo())
                {
                    nSelId = pSel->Undo(wxNOT_FOUND);
                } 
                if(pCat->GetRegisterObject(nSelId))
		        {
			        pSel->Select(nSelId, false, wxGxSelection::INIT_ALL);
		        }
            }
            return;
        case 6:
            if(pSel && pCat)
            {
                long nSelId = wxNOT_FOUND;
                if(pSel->CanRedo())
                {
                    nSelId = pSel->Redo(wxNOT_FOUND);
                } 
                if(pCat->GetRegisterObject(nSelId))
		        {
			        pSel->Select(nSelId, false, wxGxSelection::INIT_ALL);
		        }
            }
            return; 
        case 9:
            if(pSel && pCat)
            {
                for(size_t i = 0; i < pSel->GetCount(); ++i)
                {
					wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetSelectedObjectId(i));
					if(pGxObject)
                        pGxObject->Refresh();
                }           
            }
            return;
        case 10:
            if(pSel && pCat)
            {
				wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetLastSelectedObjectId());
                IGxObjectEditUI* pGxObjectEdit = dynamic_cast<IGxObjectEditUI*>(pGxObject);
                if(pGxObjectEdit)
                    pGxObjectEdit->EditProperties(dynamic_cast<wxWindow*>(m_pApp));
            }
            return;
        case 11://copy
            if(pSel && pCat)
            {
                wxDataObjectComposite *pDragData = new wxDataObjectComposite();

                wxGISStringDataObject *pNamesData = new wxGISStringDataObject(wxDataFormat(wxT("application/x-vnd.wxgis.gxobject-name")));
                pDragData->Add(pNamesData, true);

                wxFileDataObject *pFileData = new wxFileDataObject();
                pDragData->Add(pFileData, false);

                for(size_t i = 0; i < pSel->GetCount(); ++i)
                {
					wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetSelectedObjectId(i));
					if(pGxObject)
                    {
                        wxString sSystemPath(pGxObject->GetPath(), wxConvUTF8);

                        pFileData->AddFile(sSystemPath);
                        pNamesData->AddString(pGxObject->GetFullName());
                    }
                }
                //! Lock clipboard
                wxClipboardLocker locker;
                if(!locker)
                    wxMessageBox(_("Can't open clipboard"), _("Error"), wxOK | wxICON_ERROR);
                else
                {
                    //! Put data to clipboard
                    if(!wxTheClipboard->AddData(pDragData))
                        wxMessageBox(_("Can't copy file(s) to the clipboard"), _("Error"), wxOK | wxICON_ERROR);
                }

            }
    		return;
        case 12://cut
            if(pSel && pCat)
            {
                wxDataObjectComposite *pDragData = new wxDataObjectComposite();

                wxGISStringDataObject *pNamesData = new wxGISStringDataObject(wxDataFormat(wxT("application/x-vnd.wxgis.gxobject-name")));
                pDragData->Add(pNamesData, true);

                wxFileDataObject *pFileData = new wxFileDataObject();
                pDragData->Add(pFileData, false);

                pDragData->Add(new wxTextDataObject(wxT("cut")));

                for(size_t i = 0; i < pSel->GetCount(); ++i)
                {
					wxGxObject* pGxObject = pCat->GetRegisterObject(pSel->GetSelectedObjectId(i));
					if(pGxObject)
                    {
                        wxString sSystemPath(pGxObject->GetPath(), wxConvUTF8);

                        pFileData->AddFile(sSystemPath);
                        pNamesData->AddString(pGxObject->GetFullName());
                    }
                }
                //! Lock clipboard
                wxClipboardLocker locker;
                if(!locker)
                    wxMessageBox(_("Can't open clipboard"), _("Error"), wxOK | wxICON_ERROR);
                else
                {
                    //! Put data to clipboard
                    if(!wxTheClipboard->AddData(pDragData))
                        wxMessageBox(_("Can't copy file(s) to the clipboard"), _("Error"), wxOK | wxICON_ERROR);
                }

            }
    		return;
        case 13://paste
            if(pSel && pCat)
            {
                IGxDropTarget* pTarget = dynamic_cast<IGxDropTarget*>(pCat->GetRegisterObject(pSel->GetFirstSelectedObjectId()));
                if(!pTarget)
                    return;
                wxClipboardLocker locker;
                if(!locker)
                    wxMessageBox(_("Can't open clipboard"), _("Error"), wxOK | wxICON_ERROR);
                else
                {
                    wxTextDataObject data;
                    bool bMove(false);
                    if(wxTheClipboard->GetData( data ))
                    {
                        if(data.GetText() == wxString(wxT("cut")))
                            bMove = true;
                    }

                    wxGISStringDataObject data_names(wxDataFormat(wxT("application/x-vnd.wxgis.gxobject-name")));
                    if(wxTheClipboard->GetData( data_names ))
                    {
                        pTarget->Drop(data_names.GetStrings(), bMove);
                        return;
                    }                    

                    wxFileDataObject filedata;
                    if( wxTheClipboard->GetData( filedata ) )
                    {
                        pTarget->Drop(wxGISDropTarget::PathsToNames(filedata.GetFilenames()), bMove);
                        return;
                    }
                }
            }
            return;
        case 7:
            if(pSel && pCat)
            {
                //create folder
                long nSelId = pSel->GetFirstSelectedObjectId();
                wxGxObject* pGxObject = pCat->GetRegisterObject(nSelId);
                wxGxAutoRenamer* pGxFolder = dynamic_cast<wxGxAutoRenamer*>(pGxObject);
                if(!pGxFolder)
                    return;

                wxGxView* pGxView = dynamic_cast<wxGxView*>(wxWindow::FindFocus());

                CPLString sFolderPath = CheckUniqPath(pGxObject->GetPath(), CPLString(wxString(_("New folder")).mb_str(wxConvUTF8)), true, " ");
                pGxFolder->BeginRenameOnAdd(pGxView, sFolderPath);
                if(!CreateDir(sFolderPath))
                {
                    wxMessageBox(_("Create folder error!"), _("Error"), wxICON_ERROR | wxOK );
                    pGxFolder->BeginRenameOnAdd(NULL, "");
                    return;
                }
            }
            return;
        case 3:
		default:
			return;
	}
}
Esempio n. 29
0
DLL_LOCAL void registerInfo(VALUE klass, bool bfree = false)
{
	infoklassholder[wxCLASSINFO(T)]=klass;
	registerType<T>(klass, bfree);
}
void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
                  const wxPoint& aOffset )
{
    BOARD * brd = GetBoard( );
    EDA_COLOR_T color = brd->GetLayerColor(m_Layer);

    if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
        return;

#ifdef USE_WX_OVERLAY
    // If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
    if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
      return;
#endif

    if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay )
    {
        LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;

        if( !IsOnLayer( curr_layer ) )
            ColorTurnToDarkDarkGray( &color );
    }

    if( aDrawMode & GR_HIGHLIGHT )
        ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );

    ColorApplyHighlightFlag( &color );

    SetAlpha( &color, 150 );

    GRSetDrawMode( aDC, aDrawMode );

    int l_trace = m_Width / 2;

    if( aDC->LogicalToDeviceXRel( l_trace ) <= MIN_DRAW_WIDTH )
    {
        GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, 0, color );
        return;
    }

    if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
    {
        GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
    }
    else
    {
        GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
                     m_Start.y + aOffset.y,
                     m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
    }

    if( panel->GetScreen()->m_IsPrinting )
        return;

    // Show clearance for tracks, not for zone segments
    if( ShowClearance( this ) )
    {
        GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset,
                 m_Width + (GetClearance() * 2), color );
    }

    DrawShortNetname( panel, aDC, aDrawMode, color );
}