Beispiel #1
0
ExtractedStrings wxcXmlResourceCmp::FindStrings(const wxString& filename, wxXmlNode* node)
{
    ExtractedStrings arr;

    wxXmlNode* n = node;
    if(n == NULL) return arr;
    n = n->GetChildren();

    while(n) {
        if((node->GetType() == wxXML_ELEMENT_NODE) &&
           // parent is an element, i.e. has subnodes...
           (n->GetType() == wxXML_TEXT_NODE || n->GetType() == wxXML_CDATA_SECTION_NODE) &&
           // ...it is textnode...
           (node /*not n!*/->GetName() == wxT("label") ||
            (node /*not n!*/->GetName() == wxT("value") && !n->GetContent().IsNumber()) ||
            node /*not n!*/->GetName() == wxT("help") || node /*not n!*/->GetName() == wxT("longhelp") ||
            node /*not n!*/->GetName() == wxT("tooltip") || node /*not n!*/->GetName() == wxT("htmlcode") ||
            node /*not n!*/->GetName() == wxT("title") || node /*not n!*/->GetName() == wxT("item")))
            // ...and known to contain translatable string
            // subnodes:
            if(n->GetType() == wxXML_ELEMENT_NODE) {
                ExtractedStrings a2 = FindStrings(filename, n);
                WX_APPEND_ARRAY(arr, a2);
            }

        n = n->GetNext();
    }
    return arr;
}
Beispiel #2
0
wxBlockIntSelectionIterator::wxBlockIntSelectionIterator( const wxArrayBlockInt &blocks,
                                                          wxBLOCKINT_SELITER_Type type )
{
    m_type = type;
    WX_APPEND_ARRAY(m_blocks, blocks);
    m_blocks.Sort(wxblockint_sort_topleft_bottomright);
    Reset();
}
Beispiel #3
0
wxSheetSelectionIterator::wxSheetSelectionIterator( const wxArraySheetBlock &blocks,
                                                    wxSheetSelectionIter_Type type)
                                                          
{
    m_type = -1;
    WX_APPEND_ARRAY(m_blocks, blocks);    
    Reset(type);
}
Beispiel #4
0
void wxSheetSelection::Copy(const wxSheetSelection &source)
{
    m_blocks.Clear();
    WX_APPEND_ARRAY(m_blocks, source.GetBlockArray());
    m_bounds = source.GetBoundingBlock();
    m_minimized = source.IsMinimzed();
    m_options = source.GetOptions();
}
Beispiel #5
0
wxSheetSelectionIterator::wxSheetSelectionIterator( const wxSheetSelection &sel,
                                                    wxSheetSelectionIter_Type type)
                                                          
{
    m_type = -1;
    WX_APPEND_ARRAY(m_blocks, sel.GetBlockArray());
    Reset(type);
}
Beispiel #6
0
wxArrayLong *
DeckLibraryTab::DeleteBranch (wxTreeItemId oItemId, bool bFirstCall)
{
    wxArrayLong *pRefArray = new wxArrayLong (), *pOtherArray;
    long lCardRef = (long) &oItemId;
    wxTreeItemIdValue cookie;
    MyTreeItemData *pData;

    m_bNoEvents = TRUE;

    if (!oItemId.IsOk ()) {
        wxLogError (wxT ("DeleteBranch : Bad Item ID"));
        return NULL;
    }

    // For foolproofness, we don't allow deleting the whole tree this way
    //if (oItemId == m_oRootId)
    //{
//	  Update();
//	  return NULL;
    //}

    pData = (MyTreeItemData *) m_pTree->GetItemData (oItemId);

    if (pData != NULL) {
        lCardRef = pData->GetValue ();
        if (lCardRef >= 0) {
            // Remember the card to remove, actual deleting will be later
            pRefArray->Add (lCardRef);
        }
    }

    // Recursively process the children
    wxTreeItemId oChildId = m_pTree->GetFirstChild (oItemId, cookie);
    while (oChildId.IsOk ()) {
        pOtherArray = DeleteBranch (oChildId, FALSE);
        if (pOtherArray != NULL) {
            WX_APPEND_ARRAY (*pRefArray, *pOtherArray);
            delete pOtherArray;
        }
        oChildId = m_pTree->GetNextChild (oItemId, cookie);
    }

    // after all the recursive processing has taken place,
    // update the view
    if (bFirstCall) {
        // Actually delete the cards
        for (unsigned int i = 0; i < pRefArray->Count (); i++) {
            m_pModel->DelFromLibrary (pRefArray->Item (i), -1, FALSE);
        }

        m_bNoEvents = FALSE;
        Update ();
        delete pRefArray;
        return NULL;
    }
    return pRefArray;
}
Beispiel #7
0
void wxCmdLineParserData::SetArguments(const wxString& cmdLine)
{
    m_arguments.clear();

    m_arguments.push_back(wxTheApp->GetAppName());

    wxArrayString args = wxCmdLineParser::ConvertStringToArgs(cmdLine);

    WX_APPEND_ARRAY(m_arguments, args);
}
Beispiel #8
0
ExtractedStrings
XmlResApp::FindStrings(const wxString& filename, wxXmlNode *node)
{
    ExtractedStrings arr;

    wxXmlNode *n = node;
    if (n == NULL) return arr;
    n = n->GetChildren();

    while (n)
    {
        if ((node->GetType() == wxXML_ELEMENT_NODE) &&
            // parent is an element, i.e. has subnodes...
            (n->GetType() == wxXML_TEXT_NODE ||
            n->GetType() == wxXML_CDATA_SECTION_NODE) &&
            // ...it is textnode...
            (
                node/*not n!*/->GetName() == wxT("label") ||
                (node/*not n!*/->GetName() == wxT("value") &&
                               !n->GetContent().IsNumber()) ||
                node/*not n!*/->GetName() == wxT("help") ||
                node/*not n!*/->GetName() == wxT("longhelp") ||
                node/*not n!*/->GetName() == wxT("tooltip") ||
                node/*not n!*/->GetName() == wxT("htmlcode") ||
                node/*not n!*/->GetName() == wxT("title") ||
                node/*not n!*/->GetName() == wxT("item")
            ))
            // ...and known to contain translatable string
        {
            if (!flagGettext ||
                node->GetAttribute(wxT("translate"), wxT("1")) != wxT("0"))
            {
                arr.push_back
                    (
                        ExtractedString
                        (
                            ConvertText(n->GetContent()),
                            filename,
                            n->GetLineNumber()
                        )
                    );
            }
        }

        // subnodes:
        if (n->GetType() == wxXML_ELEMENT_NODE)
        {
            ExtractedStrings a2 = FindStrings(filename, n);
            WX_APPEND_ARRAY(arr, a2);
        }

        n = n->GetNext();
    }
    return arr;
}
Beispiel #9
0
bool RecBookFile::TypAdaptation( wxArrayPtrVoid params, AxProgressDlg *dlg )
{
	// params 0: nbfiles (unused)
	// params 1: paths (unused)
	// params 2: filenames 
	// params 3: is the cache ok ?
	// params 4: fast adaptation ? (unused)
	
	wxArrayString *filenames = (wxArrayString*)params[2];
	bool isCacheOk = *(bool*)params[3];

    // name of model to generate - temporary...
    RecTypModel model( "rec_typ_adapt" );
	if ( isCacheOk || wxFileExists( GetTypCacheFilename() ) )
		model.Open( GetTypCacheFilename() );
	else
		model.New();
    
    // name of adapted model to generate - temporary...
    RecTypModel outModel( "rec_typ_adapt_out" );
    outModel.New();
	params.Add( &outModel );
    
    bool failed = false;
    
    if ( !failed )
        failed = !model.AddFiles( params, dlg );

    if ( !failed )  
        failed = !model.Commit( dlg );
		
	if ( !failed )
		failed = !model.SaveAs( GetTypCacheFilename() );
        
    if ( !failed )  
        failed = !model.Adapt( params, dlg );
    
    if ( !failed )
        failed = !outModel.SaveAs( GetTypFilename() );
		
	if ( !failed )
	{
		if ( isCacheOk )
		{
			WX_APPEND_ARRAY( m_optFiles, *filenames );
		}
		else
		{
			m_optFiles = *filenames;
		}
	}

    return ( !failed );
}
// Copy constructor needed by the xml serializer class copy constructor
// or by default implementation of the xsSerializable::Clone() function.
// You haven't to define it if you don't plan to use the Clone() function
// or serializer class copy constructor.
Settings::Settings(Settings &obj) : xsSerializable(obj)
{
	// copy values from source object

	m_nIntData = obj.m_nIntData;
	m_nLongData = obj.m_nLongData;
	m_nDoubleData = obj.m_nDoubleData;
	m_nFloatData = obj.m_nFloatData;
	m_fBoolData = obj.m_fBoolData;
	m_nCharData = obj.m_nCharData;
	m_sTextData = obj.m_sTextData;
	m_nPointData = obj.m_nPointData;
	m_nSizeData = obj.m_nSizeData;
	m_nRealPointData = obj.m_nRealPointData;
	m_PenData = obj.m_PenData;
	m_BrushData = obj.m_BrushData;
	m_FontData = obj.m_FontData;
	m_nColourData = obj.m_nColourData;

	// copy array items
	WX_APPEND_ARRAY(m_arrStringData, obj.m_arrStringData);
	WX_APPEND_ARRAY(m_arrRealPointData, obj.m_arrRealPointData);

	// copy list item
	wxRealPointListNode *node = obj.m_lstRealPointData.GetFirst();
	while(node)
	{
		m_lstRealPointData.Append(new wxRealPoint(*node->GetData()));
		node = node->GetNext();
	}

	// copy dynamic instances of xsSerializable class or other derived classes
	m_pDynamicSerializableObject = (SerializableObject*)obj.m_pDynamicSerializableObject->Clone();

	// copy static instances of xsSerializable class or other derived classes
	m_StaticSerializableObject.m_sTextData = obj.m_StaticSerializableObject.m_sTextData;

	// mark class data members which should be serialized
	MarkDataMembers();
}
Beispiel #11
0
void wxCmdLineParserData::SetArguments(const wxString& cmdLine)
{
    m_arguments.clear();

    if(wxTheApp && wxTheApp->argc > 0)
        m_arguments.push_back(wxTheApp->argv[0]);
    else
        m_arguments.push_back(wxEmptyString);

    wxArrayString args = wxCmdLineParser::ConvertStringToArgs(cmdLine);

    WX_APPEND_ARRAY(m_arguments, args);
}
Beispiel #12
0
wxSFGridShape::wxSFGridShape(const wxSFGridShape& obj) : wxSFRectShape(obj)
{
    m_nRows = obj.m_nRows;
    m_nCols = obj.m_nCols;
    m_nCellSpace = obj.m_nCellSpace;

    RemoveStyle(sfsSIZE_CHANGE);

    m_arrCells.Clear();
    WX_APPEND_ARRAY(m_arrCells, obj.m_arrCells);

    MarkSerializableDataMembers();
}
Beispiel #13
0
ExtractedStrings wxcXmlResourceCmp::FindStrings()
{
    ExtractedStrings arr, a2;

    wxXmlDocument doc;
    if(!doc.Load(m_xrcFile)) {
        m_retCode = 1;
        return arr;
    }
    a2 = FindStrings(m_xrcFile, doc.GetRoot());

    WX_APPEND_ARRAY(arr, a2);
    return arr;
}
Beispiel #14
0
bool wxBlockIntSelection::SelectBlock( const wxBlockInt &block, bool combineNow,
                                       wxArrayBlockInt *addedBlocks )
{
    wxCHECK_MSG(!block.IsEmpty(), false, wxT("Invalid block") );

    //TestBlocks();

    wxArrayBlockInt extraBlocks;
    wxArrayBlockInt *extra = &extraBlocks;

    if (addedBlocks != NULL)
    {
        addedBlocks->Clear();
        extra = addedBlocks;
    }

    extra->Add(block);

    int n, count = m_blocks.GetCount();
    wxBlockInt top, bottom, left, right;

    for (n=0; n<count; n++)
    {
        for (int k=0; k<int(extra->GetCount()); k++)
        {
            if (m_blocks[n].Combine(extra->Item(k), top, bottom, left, right))
            {
                extra->RemoveAt(k);
                if (!top.IsEmpty())    extra->Add(top);
                if (!bottom.IsEmpty()) extra->Add(bottom);
                if (!left.IsEmpty())   extra->Add(left);
                if (!right.IsEmpty())  extra->Add(right);
                //DoMinimize( *extra );
                n = -1;
                break;
            }
        }
    }

    if (extra->GetCount() > 0u)
    {
        WX_APPEND_ARRAY(m_blocks, *extra);
        if (combineNow)
            Minimize();

        return true;
    }

    return false;
}
Beispiel #15
0
void wxAppConsoleBase::ProcessPendingEvents()
{
    if ( m_bDoPendingEventProcessing )
    {
        wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);

        wxCHECK_RET( m_handlersWithPendingDelayedEvents.IsEmpty(),
                     "this helper list should be empty" );

        // iterate until the list becomes empty: the handlers remove themselves
        // from it when they don't have any more pending events
#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 */
        while (!m_handlersWithPendingEvents.IsEmpty())
        {
            // In ProcessPendingEvents(), new handlers might be added
            // and we can safely leave the critical section here.
            wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);

            // NOTE: we always call ProcessPendingEvents() on the first event handler
            //       with pending events because handlers auto-remove themselves
            //       from this list (see RemovePendingEventHandler) if they have no
            //       more pending events.
            m_handlersWithPendingEvents[0]->ProcessPendingEvents();

            wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);
        }

        // now the wxHandlersWithPendingEvents is surely empty; however some event
        // handlers may have moved themselves into wxHandlersWithPendingDelayedEvents
        // because of a selective wxYield call in progress.
        // Now we need to move them back to wxHandlersWithPendingEvents so the next
        // call to this function has the chance of processing them:
        if (!m_handlersWithPendingDelayedEvents.IsEmpty())
        {
            WX_APPEND_ARRAY(m_handlersWithPendingEvents, m_handlersWithPendingDelayedEvents);
            m_handlersWithPendingDelayedEvents.Clear();
        }

        wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);
    }
}
Beispiel #16
0
wxArrayString XmlResApp::FindStrings(wxXmlNode *node)
{
    wxArrayString arr;

    wxXmlNode *n = node;
    if (n == NULL) return arr;
    n = n->GetChildren();

    while (n)
    {
        if ((node->GetType() == wxXML_ELEMENT_NODE) &&
            // parent is an element, i.e. has subnodes...
            (n->GetType() == wxXML_TEXT_NODE ||
            n->GetType() == wxXML_CDATA_SECTION_NODE) &&
            // ...it is textnode...
            (
                node/*not n!*/->GetName() == _T("label") ||
                (node/*not n!*/->GetName() == _T("value") &&
                               !n->GetContent().IsNumber()) ||
                node/*not n!*/->GetName() == _T("help") ||
                node/*not n!*/->GetName() == _T("longhelp") ||
                node/*not n!*/->GetName() == _T("tooltip") ||
                node/*not n!*/->GetName() == _T("htmlcode") ||
                node/*not n!*/->GetName() == _T("title") ||
                node/*not n!*/->GetName() == _T("item")
            ))
            // ...and known to contain translatable string
        {
            if (!flagGettext ||
                node->GetPropVal(_T("translate"), _T("1")) != _T("0"))
            {
                arr.Add(ConvertText(n->GetContent()));
            }
        }

        // subnodes:
        if (n->GetType() == wxXML_ELEMENT_NODE)
        {
            wxArrayString a2 = FindStrings(n);
            WX_APPEND_ARRAY(arr, a2);
        }

        n = n->GetNext();
    }
    return arr;
}
void wxAppConsoleBase::ProcessPendingEvents()
{
    if ( m_bDoPendingEventProcessing )
    {
        wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);

        wxCHECK_RET( m_handlersWithPendingDelayedEvents.IsEmpty(),
                     "this helper list should be empty" );

        // iterate until the list becomes empty: the handlers remove themselves
        // from it when they don't have any more pending events
        while (!m_handlersWithPendingEvents.IsEmpty())
        {
            // In ProcessPendingEvents(), new handlers might be added
            // and we can safely leave the critical section here.
            wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);

            // NOTE: we always call ProcessPendingEvents() on the first event handler
            //       with pending events because handlers auto-remove themselves
            //       from this list (see RemovePendingEventHandler) if they have no
            //       more pending events.
            m_handlersWithPendingEvents[0]->ProcessPendingEvents();

            wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);
        }

        // now the wxHandlersWithPendingEvents is surely empty; however some event
        // handlers may have moved themselves into wxHandlersWithPendingDelayedEvents
        // because of a selective wxYield call in progress.
        // Now we need to move them back to wxHandlersWithPendingEvents so the next
        // call to this function has the chance of processing them:
        if (!m_handlersWithPendingDelayedEvents.IsEmpty())
        {
            WX_APPEND_ARRAY(m_handlersWithPendingEvents, m_handlersWithPendingDelayedEvents);
            m_handlersWithPendingDelayedEvents.Clear();
        }

        wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);
    }

    // Garbage collect all objects previously scheduled for destruction.
    DeletePendingObjects();
}
Beispiel #18
0
// Add paths e.g. from the PATH environment variable
void wxPathList::AddEnvList (const wxString& envVariable)
{
    // The space has been removed from the tokenizers, otherwise a
    // path such as "C:\Program Files" would be split into 2 paths:
    // "C:\Program" and "Files"; this is true for both Windows and Unix.

    static const wxChar PATH_TOKS[] =
#if defined(__WINDOWS__)
        wxT(";"); // Don't separate with colon in DOS (used for drive)
#else
        wxT(":;");
#endif

    wxString val;
    if ( wxGetEnv(envVariable, &val) )
    {
        // split into an array of string the value of the env var
        wxArrayString arr = wxStringTokenize(val, PATH_TOKS);
        WX_APPEND_ARRAY(*this, arr);
    }
}
Beispiel #19
0
wxArrayString XmlResApp::FindStrings()
{
    wxArrayString arr, a2;

    for (size_t i = 0; i < parFiles.Count(); i++)
    {
        if (flagVerbose)
            wxPrintf(_T("processing ") + parFiles[i] +  _T("...\n"));

        wxXmlDocument doc;
        if (!doc.Load(parFiles[i]))
        {
            wxLogError(_T("Error parsing file ") + parFiles[i]);
            retCode = 1;
            continue;
        }
        a2 = FindStrings(doc.GetRoot());
        WX_APPEND_ARRAY(arr, a2);
    }

    return arr;
}
Beispiel #20
0
void ShareProperties::CreateControls()
{    
    ////@begin ShareProperties content construction
    if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_DIALOG_SHARE_ADD")))
        wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
    m_pCtrlLocalShares = XRCCTRL(*this, "ID_COMBOBOX_SHARE_LOCALNAME", wxBitmapComboBox);
    m_pCtrlSmbPrintOptions = XRCCTRL(*this, "ID_PANEL_SMB_PRINTER", wxPanel);
    m_pCtrlSmbDriver = XRCCTRL(*this, "ID_COMBOBOX_SMBDRIVER", wxComboBox);
    m_pCtrlSmbPrivate = XRCCTRL(*this, "ID_RADIOBUTTON_SMB_PRIVATE", wxRadioButton);
    m_pCtrlSmbPublic = XRCCTRL(*this, "ID_RADIOBUTTON_SMB_PUBLIC", wxRadioButton);
    m_pCtrlSmbPrintUsername = XRCCTRL(*this, "ID_TEXTCTRL_SMBPRINT_USERNAME", wxTextCtrl);
    m_pCtrlSmbPrintPassword = XRCCTRL(*this, "ID_TEXTCTRL_SMBPRINT_PASSWORD", wxTextCtrl);
    m_pCtrlCupsOptions = XRCCTRL(*this, "ID_PANEL_CUPSOPTIONS", wxPanel);
    m_pCtrlCupsPrivate = XRCCTRL(*this, "ID_RADIOBUTTON_CUPS_PRIVATE", wxRadioButton);
    m_pCtrlCupsPublic = XRCCTRL(*this, "ID_RADIOBUTTON_CUPS_PUBLIC", wxRadioButton);
    m_pCtrlUsbOptions = XRCCTRL(*this, "ID_PANEL_USBIP", wxPanel);
    m_pCtrlSmbDiskOptions = XRCCTRL(*this, "ID_PANEL_SMBOPTIONS", wxPanel);
    m_pCtrlMountPoint = XRCCTRL(*this, "ID_TEXTCTRL_SHARE_MOUNTPOINT", wxTextCtrl);
    m_pCtrlUsername = XRCCTRL(*this, "ID_TEXTCTRL_SHARE_USERNAME", wxTextCtrl);
    m_pCtrlPassword = XRCCTRL(*this, "ID_TEXTCTRL_SHARE_PASSWORD", wxTextCtrl);
    // Set validators
    if (FindWindow(XRCID("ID_COMBOBOX_SMBDRIVER")))
        FindWindow(XRCID("ID_COMBOBOX_SMBDRIVER"))->SetValidator( wxGenericValidator(& m_sSmbDriver) );
    if (FindWindow(XRCID("ID_RADIOBUTTON_SMB_PUBLIC")))
        FindWindow(XRCID("ID_RADIOBUTTON_SMB_PUBLIC"))->SetValidator( wxGenericValidator(& m_bSmbPublic) );
    if (FindWindow(XRCID("ID_TEXTCTRL_SMBPRINT_USERNAME")))
        FindWindow(XRCID("ID_TEXTCTRL_SMBPRINT_USERNAME"))->SetValidator( MyValidator(& m_sSmbPrintUsername) );
    if (FindWindow(XRCID("ID_TEXTCTRL_SMBPRINT_PASSWORD")))
        FindWindow(XRCID("ID_TEXTCTRL_SMBPRINT_PASSWORD"))->SetValidator( MyValidator(& m_sSmbPrintPassword) );
    if (FindWindow(XRCID("ID_COMBOBOX_CUPSDRIVER")))
        FindWindow(XRCID("ID_COMBOBOX_CUPSDRIVER"))->SetValidator( wxGenericValidator(& m_sCupsDriver) );
    if (FindWindow(XRCID("ID_RADIOBUTTON_CUPS_PUBLIC")))
        FindWindow(XRCID("ID_RADIOBUTTON_CUPS_PUBLIC"))->SetValidator( wxGenericValidator(& m_bCupsPublic) );
    if (FindWindow(XRCID("ID_TEXTCTRL_SHARE_MOUNTPOINT")))
        FindWindow(XRCID("ID_TEXTCTRL_SHARE_MOUNTPOINT"))->SetValidator( MyValidator(& m_sMountPoint) );
    if (FindWindow(XRCID("ID_TEXTCTRL_SHARE_USERNAME")))
        FindWindow(XRCID("ID_TEXTCTRL_SHARE_USERNAME"))->SetValidator( MyValidator(& m_sSmbDiskUsername) );
    if (FindWindow(XRCID("ID_TEXTCTRL_SHARE_PASSWORD")))
        FindWindow(XRCID("ID_TEXTCTRL_SHARE_PASSWORD"))->SetValidator( MyValidator(& m_sSmbDiskPassword) );
    ////@end ShareProperties content construction

    // Create custom windows not generated automatically here.

    ////@begin ShareProperties content initialisation
    ////@end ShareProperties content initialisation

    int minw = 0;
    int minh = 0;
    int w, h;
    m_pCtrlSmbDiskOptions->Show(false);
    m_pCtrlSmbPrintOptions->Show(true);
    m_pCtrlCupsOptions->Show(false);
    InvalidateBestSize();
    Layout();
    m_pCtrlSmbPrintOptions->SetMinSize(m_pCtrlSmbPrintOptions->GetBestSize());
    GetBestSize(&minw, &minh);

    m_pCtrlSmbDiskOptions->Show(false);
    m_pCtrlSmbPrintOptions->Show(false);
    m_pCtrlCupsOptions->Show(true);
    InvalidateBestSize();
    Layout();
    m_pCtrlCupsOptions->SetMinSize(m_pCtrlSmbDiskOptions->GetBestSize());
    GetBestSize(&w, &h);
    if (w > minw)
        minw = w;
    if (h > minh)
        minh = h;

    m_pCtrlCupsOptions->Show(false);
    m_pCtrlSmbDiskOptions->Show(true);
    m_pCtrlSmbPrintOptions->Show(false);
    InvalidateBestSize();
    Layout();
    m_pCtrlSmbDiskOptions->SetMinSize(m_pCtrlSmbPrintOptions->GetBestSize());
    GetBestSize(&w, &h);
    if (w > minw)
        minw = w;
    if (h > minh)
        minh = h;
    SetMinSize(wxSize(minw, minh));

    if (m_iCurrentShare != -1) {
        ShareGroup sg = m_pCfg->aGetShareGroups().Item(m_iCurrentShare);
        wxBitmap bm = wxNullBitmap;
        m_pCtrlLocalShares->Append(sg.m_sShareName, bm, &sg);
        m_pCtrlLocalShares->SetSelection(0);
        m_pCtrlLocalShares->Enable(false);
        SetTitle(_("Modify shared resource - OpenNX"));
        switch (sg.m_eType) {
            case SharedResource::SHARE_UNKNOWN:
                break;
            case SharedResource::SHARE_SMB_DISK:
                m_pCtrlCupsOptions->Show(false);
                m_pCtrlSmbPrintOptions->Show(false);
                m_pCtrlSmbDiskOptions->Show(true);
                m_sMountPoint = sg.m_sAlias;
                m_sSmbDiskUsername = sg.m_sUsername;
                if (m_sSmbDiskUsername.IsEmpty())
                    m_sSmbDiskUsername = ::wxGetUserId();
                m_sSmbDiskPassword = sg.m_sPassword;
                Layout();
                break;
            case SharedResource::SHARE_SMB_PRINTER:
                m_pCtrlCupsOptions->Show(false);
                m_pCtrlSmbDiskOptions->Show(false);
                m_pCtrlSmbPrintOptions->Show(true);
                m_sSmbDriver = sg.m_sDriver;
                m_sSmbPrintUsername = sg.m_sUsername;
                if (m_sSmbPrintUsername.IsEmpty())
                    m_sSmbPrintUsername = ::wxGetUserId();
                m_sSmbPrintPassword = sg.m_sPassword;
                if (sg.m_bPublic)
                    m_pCtrlSmbPublic->SetValue(true);
                else
                    m_pCtrlSmbPrivate->SetValue(true);
                Layout();
                break;
            case SharedResource::SHARE_CUPS_PRINTER:
                m_pCtrlSmbPrintOptions->Show(false);
                m_pCtrlSmbDiskOptions->Show(false);
                m_pCtrlCupsOptions->GetSizer()->Layout();
                m_pCtrlCupsOptions->Show(true);
                if (sg.m_bPublic)
                    m_pCtrlCupsPublic->SetValue(true);
                else
                    m_pCtrlCupsPrivate->SetValue(true);
                Layout();
                break;
        }
        m_pCtrlMountPoint->SetValue(m_sMountPoint);
    } else {
        // Fetch list of shares
        if (m_bUseSmb) {
            SmbClient sc;
            m_aShares = sc.GetShares();
        }
        if (m_bUseCups) {
            CupsClient cc;
            ArrayOfShares cupsShares = cc.GetShares();
            WX_APPEND_ARRAY(m_aShares, cupsShares);
        }
        // Apparently, wxGTK (perhaps GTK itself) has a bug which
        // results in data pointers not being associated properly to the
        // ComboBox, if that ComboBox is sorted (wxCB_SORT attribute).
        // As a woraround, we use an *unsorted* ComboBox and sort the
        // shares before adding them to the ComboBox.
        m_aShares.Sort(cmpshares);

        // Build ComboBox content
        for (size_t i = 0; i < m_aShares.GetCount(); i++) {
            wxBitmap bm;
            switch (m_aShares[i].sharetype) {
                case SharedResource::SHARE_SMB_DISK:
                    bm = GetBitmapResource(wxT("res/smbfolder.png"));
                    break;
                case SharedResource::SHARE_SMB_PRINTER:
                    bm = GetBitmapResource(wxT("res/smbprinter.png"));
                    break;
                case SharedResource::SHARE_CUPS_PRINTER:
                    bm = GetBitmapResource(wxT("res/cupsprinter.png"));
                    break;
                default:
                    bm = wxNullBitmap;
                    break;
            }
            m_pCtrlLocalShares->Append(m_aShares[i].name, bm, m_aShares[i].GetThisVoid());
        }

        if (m_aShares.GetCount() > 0) {
            // Select first element of ComboBox
            m_pCtrlLocalShares->SetSelection(0);
            SharedResource *res = wxDynamicCast(m_pCtrlLocalShares->GetClientData(0), SharedResource);
            wxASSERT(res);
            switch (res->sharetype) {
                case SharedResource::SHARE_UNKNOWN:
                    break;
                case SharedResource::SHARE_SMB_DISK:
                    m_pCtrlSmbPrintOptions->Show(false);
                    m_pCtrlCupsOptions->Show(false);
                    m_pCtrlSmbDiskOptions->Show(true);
                    m_sMountPoint = wxT("$(SHARES)/") + res->name;
                    Layout();
                    break;
                case SharedResource::SHARE_SMB_PRINTER:
                    m_pCtrlSmbDiskOptions->Show(false);
                    m_pCtrlCupsOptions->Show(false);
                    m_pCtrlSmbPrintOptions->Show(true);
                    m_sSmbDriver = wxT("laserjet");
                    Layout();
                    break;
                case SharedResource::SHARE_CUPS_PRINTER:
                    m_pCtrlSmbDiskOptions->Show(false);
                    m_pCtrlSmbPrintOptions->Show(false);
                    m_pCtrlCupsOptions->Show(true);
                    Layout();
                    break;
            }
        } else {
            wxLogMessage(_("No shares found"));
            m_pCtrlLocalShares->Enable(false);
            m_pCtrlMountPoint->Enable(false);
            m_pCtrlUsername->Enable(false);
            m_pCtrlPassword->Enable(false);
        }
    }
}
Beispiel #21
0
/**
 * MyFrame::Compile
 * This function compiles given src file. It calls MyFrame::GetCompileData to
 * receave data.
 * @param index about file from buffer list
 * @return int 0 on success, 1 on failure
 */
int MyFrame::Compile ( int index ) {

    //Safety checks
    if ( !stc )
        return 1;
    if ( ProcessIsRunning )
        return 1;
    
    // these are used to get the first error
    bool isFirstErrorFound = false;
    wxString strFirstErrorFile;
    int intFirstErrorLine;
        
    // File that we are about to compile
    wxFileName objFile( bufferList[ index ]->GetFileName() );
    objFile.Normalize();

    // Get compiler cmdline and check it. if empty return.
    wxString strCompile( GetCompileData( index ) );
    if( !strCompile.Len() )
        return 1;

    // Log compiler output and input
    strCompilerOutput.Empty();
    strCompilerOutput.Add("[bold]Command executed:[/bold]");
    strCompilerOutput.Add(strCompile);

    // If Active path is activated then set current working path
    // to show to the location of the src file.
    if( Prefs.ActivePath )
        ::wxSetWorkingDirectory( objFile.GetPath() );

    // Execute fbc and retreave results.
    wxArrayString arrOutput, arrErrOutput;
    int intCompileResult = wxExecute( strCompile, arrOutput, arrErrOutput );

    // if there was any output from fbc then get output messages and put them
    // into console area
    if ( arrOutput.Count() || arrErrOutput.Count() ) {
        // define variables
        wxString        strOutput;
        wxString        strTemp;
        wxFileName      objOutputFile;
        long            intOutput;
        long            intLine;
        int             intBraceStart;
        int             intBraceEnd;
        bool            isOutputHeader = false;
        
        wxString        strDebug;

        // Becouse fbc returns Outputs via both std and error channels,
        // we need to join them here.
        WX_APPEND_ARRAY( arrOutput, arrErrOutput );

        // Putput logging:
        strCompilerOutput.Add( "" );
        strCompilerOutput.Add( "[bold]Compiler output:[/bold]" );

        // Loop through arrOutput
        for ( unsigned int cnt = 0; cnt < arrOutput.Count(); cnt++ ) {
            if ( arrOutput[cnt].IsEmpty() )
                continue;

            // Log compiler output
            strCompilerOutput.Add( arrOutput[cnt] );

            intBraceStart = arrOutput[cnt].First( '(' );
            intBraceEnd = arrOutput[cnt].First( ')' );

            // if intBraceStart is not -1 then probably line number was found.
            // as fbc returns things: file(linenumber): Error|Warning nr: Output message
            // As it might be any message then test if first part is a filename.
            // colon[:] - win32
            // slash[/] -linux
#ifdef __WXMSW__

            if( intBraceStart != -1 && intBraceEnd != -1 && arrOutput[cnt].GetChar(1) == ':' ) {
#else
            if( intBraceStart != -1 && intBraceEnd != -1 && arrOutput[cnt].GetChar(0) == '/' ) {
#endif
                // Get possible line and error number.
                strTemp = arrOutput[cnt].Mid( intBraceStart + 1, intBraceEnd - intBraceStart - 1);

                // if this is a number:
                if ( strTemp.IsNumber() ) {
                    strTemp.ToLong( &intLine );
                    // Get possible file name and check if it is indeed a filename
                    objOutputFile = arrOutput[cnt].Left( intBraceStart );
                    objOutputFile.Normalize();
                    if ( objOutputFile.IsOk() && objOutputFile.FileExists() ) {
                        //Now that it's indeed is a filename, get line, error/warning number
                        //and Output message on that line
                        strTemp = arrOutput[cnt].Mid( intBraceEnd + 4 );
                        strTemp = strTemp.Mid( strTemp.Find( ' ' ) + 1 );
                        strOutput = strTemp.Mid( strTemp.Find( ':' ) + 2 );
                        strTemp = strTemp.Left( strTemp.Find( ':' ) );
                        strTemp.ToLong( &intOutput );
                        isOutputHeader = true;
                    }
                }
            }

            // If is Output header ( includes filename, Output number and line number then
            // add generated values. Else just add original message.
            if( isOutputHeader ) {
                isOutputHeader = false;
                if ( intOutput == 0 )
                    intOutput = -1;
                if ( !isFirstErrorFound ) {
                    strFirstErrorFile = objOutputFile.GetFullPath();
                    intFirstErrorLine = intLine;
                    isFirstErrorFound = true;
                }
                AddListItem(intLine, intOutput, objOutputFile.GetFullPath(), strOutput);
            }
            else {
                // Replace all tabs.
                arrOutput[cnt].Replace( "\t", "  " );
                AddListItem(-1, -1, "", arrOutput[cnt]);
            }
        }

        // Open console area
        if ( !HSplitter->IsSplit() ) {
            HSplitter->SplitHorizontally( FBCodePanel, FBConsole, ConsoleSize );
            FB_View->Check(Menu_Result, true);
        }

    }
    else {
        // Since there was no output then close console area
        // -if no error then it is not needed.
        if ( HSplitter->IsSplit() ) {
Beispiel #22
0
bool wxRibbonButtonBar::TryCollapseLayout(wxRibbonButtonBarLayout* original,
                                          size_t first_btn, size_t* last_button)
{
    size_t btn_count = m_buttons.Count();
    size_t btn_i;
    int used_height = 0;
    int used_width = 0;
    int available_width = 0;
    int available_height = 0;

    for(btn_i = first_btn + 1; btn_i > 0; /* decrement is inside loop */)
    {
        --btn_i;
        wxRibbonButtonBarButtonBase* button = m_buttons.Item(btn_i);
        wxRibbonButtonBarButtonState large_size_class = button->GetLargestSize();
        wxSize large_size = button->sizes[large_size_class].size;
        int t_available_height = wxMax(available_height,
            large_size.GetHeight());
        int t_available_width = available_width + large_size.GetWidth();
        wxRibbonButtonBarButtonState small_size_class = large_size_class;
        if(!button->GetSmallerSize(&small_size_class))
        {
            return false;
        }
        wxSize small_size = button->sizes[small_size_class].size;
        int t_used_height = used_height + small_size.GetHeight();
        int t_used_width = wxMax(used_width, small_size.GetWidth());

        if(t_used_height > t_available_height)
        {
            ++btn_i;
            break;
        }
        else
        {
            used_height = t_used_height;
            used_width = t_used_width;
            available_width = t_available_width;
            available_height = t_available_height;
        }
    }

    if(btn_i >= first_btn || used_width >= available_width)
    {
        return false;
    }
    if(last_button != NULL)
    {
        *last_button = btn_i;
    }

    wxRibbonButtonBarLayout* layout = new wxRibbonButtonBarLayout;
    WX_APPEND_ARRAY(layout->buttons, original->buttons);
    wxPoint cursor(layout->buttons.Item(btn_i).position);
    bool preserve_height = false;
    if(btn_i == 0)
    {
        // If height isn't preserved (i.e. it is reduced), then the minimum
        // size for the button bar will decrease, preventing the original
        // layout from being used (in some cases).
        // It may be a good idea to always preserve the height, but for now
        // it is only done when the first button is involved in a collapse.
        preserve_height = true;
    }

    for(; btn_i <= first_btn; ++btn_i)
    {
        wxRibbonButtonBarButtonInstance& instance = layout->buttons.Item(btn_i);
        instance.base->GetSmallerSize(&instance.size);
        instance.position = cursor;
        cursor.y += instance.base->sizes[instance.size].size.GetHeight();
    }

    int x_adjust = available_width - used_width;

    for(; btn_i < btn_count; ++btn_i)
    {
        wxRibbonButtonBarButtonInstance& instance = layout->buttons.Item(btn_i);
        instance.position.x -= x_adjust;
    }

    layout->CalculateOverallSize();

    // Sanity check
    if(layout->overall_size.GetWidth() >= original->overall_size.GetWidth() ||
        layout->overall_size.GetHeight() > original->overall_size.GetHeight())
    {
        delete layout;
        wxFAIL_MSG("Layout collapse resulted in increased size");
        return false;
    }

    if(preserve_height)
    {
        layout->overall_size.SetHeight(original->overall_size.GetHeight());
    }

    m_layouts.Add(layout);
    return true;
}
Beispiel #23
0
bool wxBlockDoubleSelection::SelectBlock( const wxBlockDouble &block, bool combineNow)
{
    // It's valid to select a block with a width and height 0 since that means that point
    //wxCHECK_MSG(!block.IsEmpty(), false, wxT("Invalid block") );

    wxArrayBlockDouble extra;
    extra.Add(block);
    wxBlockDouble top, bottom, left, right;

    for (int n=0; n<int(m_blocks.GetCount()); n++)
    {
        for (int k=0; k<int(extra.GetCount()); k++)
        {
            bool done = false;

            // Doubles are different than ints - roundoff error problems
            // always use the bigger block to soak up the smaller blocks
            // this reduces problems with tiny roundoff error produced blocks
            if (m_blocks[n].Intersects(extra[k]))
            {
                if (m_blocks[n].Contains(extra[k]))
                {
                    extra.RemoveAt(k);
                    k--;
                    continue;
                }
                else if (extra[k].Contains(m_blocks[n]))
                {
                    m_blocks.RemoveAt(n);
                    n = -1;
                    break;
                }
                else if (m_blocks[n].IsLarger(extra[k]) > 0)
                {
                    done = m_blocks[n].Combine(extra[k], top, bottom, left, right);
                    if (done)
                    {
                        extra.RemoveAt(k);
                        k--;
                    }
                }
                else
                {
                    done = extra[k].Combine(m_blocks[n], top, bottom, left, right);
                    if (done)
                    {
                        m_blocks.RemoveAt(n);
                        n = -1;
                    }
                }
            }

            if (done)
            {
                if (!top.IsEmpty())    extra.Add(top);
                if (!bottom.IsEmpty()) extra.Add(bottom);
                if (!left.IsEmpty())   extra.Add(left);
                if (!right.IsEmpty())  extra.Add(right);
                //DoMinimize( extra );
                if (n == -1)
                    break;
            }
        }
    }

    if (extra.GetCount() > 0u)
    {
        WX_APPEND_ARRAY(m_blocks, extra);
        if (combineNow)
            Minimize();

        return true;
    }

    return false;
}
Beispiel #24
0
wxBlockDoubleSelectionIterator::wxBlockDoubleSelectionIterator( const wxArrayBlockDouble &blocks )
{
    WX_APPEND_ARRAY(m_blocks, blocks);
    m_blocks.Sort(wxblockdouble_sort_topleft_bottomright);
    Reset();
}
Beispiel #25
0
wxBlockDoubleSelectionIterator::wxBlockDoubleSelectionIterator( const wxBlockDoubleSelection &sel )
{
    WX_APPEND_ARRAY(m_blocks, sel.GetBlockArray());
    m_blocks.Sort(wxblockdouble_sort_topleft_bottomright);
    Reset();
}
Beispiel #26
0
void FbAuthListModel::Append(const wxArrayInt &items)
{
	WX_APPEND_ARRAY(m_items, items);
}