Пример #1
0
//Standard contructor
DeviceToolBar::DeviceToolBar()
: ToolBar(DeviceBarID, _("Device"), wxT("Device"), true)
{
   mPlayBitmap = NULL;
   mRecordBitmap = NULL;
}
Пример #2
0
bool wxGenericDirDialog::Create(wxWindow* parent,
                                const wxString& title,
                                const wxString& defaultPath, long style,
                                const wxPoint& pos,
                                const wxSize& sz,
                                const wxString& name)
{
    wxBusyCursor cursor;

    parent = GetParentForModalDialog(parent, style);

    if (!wxDirDialogBase::Create(parent, title, defaultPath, style, pos, sz, name))
        return false;

    m_path = defaultPath;
    if (m_path == wxT("~"))
        wxGetHomeDir(&m_path);
    if (m_path == wxT("."))
        m_path = wxGetCwd();

    wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );

    // smartphones does not support or do not waste space for wxButtons
#if defined(__SMARTPHONE__)

    wxMenu *dirMenu = new wxMenu;
    dirMenu->Append(ID_GO_HOME, _("Home"));

    if (!HasFlag(wxDD_DIR_MUST_EXIST))
    {
        dirMenu->Append(ID_NEW, _("New directory"));
    }

    dirMenu->AppendCheckItem(ID_SHOW_HIDDEN, _("Show hidden directories"));
    dirMenu->AppendSeparator();
    dirMenu->Append(wxID_CANCEL, _("Cancel"));

#else

    // 0) 'New' and 'Home' Buttons
    wxSizer* buttonsizer = new wxBoxSizer( wxHORIZONTAL );

    // VS: 'Home directory' concept is unknown to MS-DOS
#if !defined(__DOS__)
    wxBitmapButton* homeButton =
        new wxBitmapButton(this, ID_GO_HOME,
                           wxArtProvider::GetBitmap(wxART_GO_HOME, wxART_BUTTON));
    buttonsizer->Add( homeButton, 0, wxLEFT|wxRIGHT, 10 );
#endif

    // I'm not convinced we need a New button, and we tend to get annoying
    // accidental-editing with label editing enabled.
    if (!HasFlag(wxDD_DIR_MUST_EXIST))
    {
        wxBitmapButton* newButton =
            new wxBitmapButton(this, ID_NEW,
                               wxArtProvider::GetBitmap(wxART_NEW_DIR, wxART_BUTTON));
        buttonsizer->Add( newButton, 0, wxRIGHT, 10 );
#if wxUSE_TOOLTIPS
        newButton->SetToolTip(_("Create new directory"));
#endif
    }

#if wxUSE_TOOLTIPS
    homeButton->SetToolTip(_("Go to home directory"));
#endif

    topsizer->Add( buttonsizer, 0, wxTOP | wxALIGN_RIGHT, 10 );

#endif // __SMARTPHONE__/!__SMARTPHONE__

    // 1) dir ctrl
    m_dirCtrl = NULL; // this is necessary, event handler called from
    // wxGenericDirCtrl would crash otherwise!
    long dirStyle = wxDIRCTRL_DIR_ONLY | wxDEFAULT_CONTROL_BORDER;

#ifdef __WXMSW__
    if (!HasFlag(wxDD_DIR_MUST_EXIST))
    {
        // Only under Windows do we need the wxTR_EDIT_LABEL tree control style
        // before we can call EditLabel (required for "New directory")
        dirStyle |= wxDIRCTRL_EDIT_LABELS;
    }
#endif

    m_dirCtrl = new wxGenericDirCtrl(this, ID_DIRCTRL,
                                     m_path, wxDefaultPosition,
                                     wxSize(300, 200),
                                     dirStyle);

    wxSizerFlags flagsBorder2;
    flagsBorder2.DoubleBorder(wxTOP | wxLEFT | wxRIGHT);

    topsizer->Add(m_dirCtrl, wxSizerFlags(flagsBorder2).Proportion(1).Expand());

#ifndef __SMARTPHONE__
    // TODO: Make this an option depending on a flag?
    wxCheckBox *
    check = new wxCheckBox(this, ID_SHOW_HIDDEN, _("Show &hidden directories"));
    topsizer->Add(check, wxSizerFlags(flagsBorder2).Right());
#endif // !__SMARTPHONE__

    // 2) text ctrl
    m_input = new wxTextCtrl( this, ID_TEXTCTRL, m_path, wxDefaultPosition );
    topsizer->Add(m_input, wxSizerFlags(flagsBorder2).Expand());

    // 3) buttons if any
    wxSizer *buttonSizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL);
    if ( buttonSizer )
    {
        topsizer->Add(buttonSizer, wxSizerFlags().Expand().DoubleBorder());
    }

#ifdef __SMARTPHONE__
    // overwrite menu set by CreateSeparatedButtonSizer() call above
    SetRightMenu(wxID_ANY, _("Options"), dirMenu);
#endif

    m_input->SetFocus();

    SetAutoLayout( true );
    SetSizer( topsizer );

    topsizer->SetSizeHints( this );
    topsizer->Fit( this );

    Centre( wxBOTH );

    return true;
}
Пример #3
0
#include "wx/valgen.h"
#include "wx/valtext.h"
#include "wx/valnum.h"

#ifndef wxHAS_IMAGES_IN_RESOURCES
    #include "../sample.xpm"
#endif

// ----------------------------------------------------------------------------
// Global data
// ----------------------------------------------------------------------------

MyData g_data;

wxString g_listbox_choices[] =
    {wxT("one"),  wxT("two"),  wxT("three")};

wxString g_combobox_choices[] =
    {wxT("yes"), wxT("no (doesn't validate)"), wxT("maybe (doesn't validate)")};

wxString g_radiobox_choices[] =
    {wxT("green"), wxT("yellow"), wxT("red")};

// ----------------------------------------------------------------------------
// MyData
// ----------------------------------------------------------------------------

MyData::MyData()
{
    // This string will be passed to an alpha-only validator, which
    // will complain because spaces aren't alpha. Note that validation
Пример #4
0
DlgPass::DlgPass()
                : wxDialog(DlgPass::Parent, -1, wxT("Nau - Pass"),wxDefaultPosition,wxDefaultSize,wxRESIZE_BORDER|wxDEFAULT_DIALOG_STYLE),
				m_Name("Pass Dialog")
{

	m_Parent = DlgPass::Parent;
	wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);

	/* ----------------------------------------------------------------
	                             Toolbar
	-----------------------------------------------------------------*/

    // load the image wanted on the toolbar
    //wxBitmap newImage(wxT("bitmaps/new.bmp"), wxBITMAP_TYPE_BMP);
    //wxBitmap cutImage(wxT("bitmaps/cut.bmp"), wxBITMAP_TYPE_BMP);

//	wxBitmap aboutImage = wxBITMAP(help) ;

    // create the toolbar and add our 1 tool to it
 /*   m_toolbar = new wxToolBar(this,TOOLBAR_ID);
	long tstyle = m_toolbar->GetWindowStyle();
	tstyle |= wxTB_TEXT;
	m_toolbar->SetWindowStyle(tstyle);
    m_toolbar->AddTool(PIPELINE_NEW, _("New"), newImage, _("New Pipeline"));
    m_toolbar->AddTool(PIPELINE_REMOVE, _("Remove"), cutImage, _("Remove Pipeline"));

 	m_toolbar->AddSeparator();
    m_toolbar->AddTool(PASS_NEW, _("New"), newImage, _("New Pass"));
    m_toolbar->AddTool(PASS_REMOVE, _("Remove"), cutImage, _("Remove Pass"));

	m_toolbar->EnableTool(PIPELINE_REMOVE, FALSE);

	m_toolbar->Realize();


	sizer->Add(m_toolbar,0,wxGROW |wxALL, 1);
*/
	/* ----------------------------------------------------------------
	                             Pipelines and Passes
	-----------------------------------------------------------------*/

	m_PipelineList = new wxComboBox(this,DLG_MI_COMBO_PIPELINE,wxT(""),wxDefaultPosition,wxDefaultSize,0,NULL,wxCB_READONLY );
	m_PassList = new wxComboBox(this,DLG_MI_COMBO_PASS,wxT(""),wxDefaultPosition,wxDefaultSize,0,NULL,wxCB_READONLY );

	wxBoxSizer *sizer1 = new wxBoxSizer(wxHORIZONTAL);
	wxStaticText *stg1 =  new wxStaticText(this,-1,wxT("Pipeline: "));

	sizer1->Add(stg1,0,wxGROW |wxALL, 5);
	sizer1->Add(m_PipelineList,0,wxGROW |wxALL,5);
	wxStaticText *stg2 =  new wxStaticText(this,-1,wxT("Pass: "******"Pass Properties"));
	wxSizer *sizerS = new wxStaticBoxSizer(sb,wxVERTICAL);

		m_PG = new wxPropertyGridManager(this, DLG_MI_PG,
				wxDefaultPosition, wxDefaultSize,
				// These and other similar styles are automatically
				// passed to the embedded wxPropertyGrid.
				wxPG_BOLD_MODIFIED|wxPG_SPLITTER_AUTO_CENTER|
				// Plus defaults.
				wxPGMAN_DEFAULT_STYLE
           );

		// dummy prop
		m_PG->AddPage(wxT("Properties"));
		m_PG->Append(new wxPGProperty(wxT("Parameters"), wxPG_LABEL));
		m_PG->Append(new wxFloatProperty(wxT("alpha"),wxPG_LABEL, 0.0f));

	sizerS->Add(m_PG, 1, wxGROW | wxALL, 5);


	/* ----------------------------------------------------------------
								Activate button
	-----------------------------------------------------------------*/

	wxBoxSizer *sizH3 = new wxBoxSizer(wxHORIZONTAL);
	m_BActivate = new wxButton(this, DLG_BUTTON_ACTIVATE, wxT("Activate Pipeline"));
	m_ActivePipText = new wxStaticText(this, wxID_ANY, wxT("..."));
	sizH3->Add(m_BActivate, 0, wxALL | wxGROW | wxHORIZONTAL , 5);
	sizH3->Add(m_ActivePipText, 0, wxALL | wxGROW | wxHORIZONTAL , 5);


	/* ----------------------------------------------------------------
	                             End
	-----------------------------------------------------------------*/


	sizer->Add(sizerS,1,wxGROW | wxALL,5);
	sizer->Add(sizH3, 0, wxALL | wxGROW | wxHORIZONTAL, 15);
	//sizer->Add(5,5,0, wxGROW | wxALL,5);

    SetAutoLayout(TRUE);
    SetSizer(sizer);

    sizer->SetSizeHints(this);
    sizer->Fit(this);

}
Пример #5
0
void RadarCanvas::Render(wxPaintEvent &evt) {
  int w, h;

  if (!IsShown() || !m_pi->m_initialized) {
    return;
  }

  GetClientSize(&w, &h);
  wxPaintDC(this);  // only to be used in paint events. use wxClientDC to paint
                    // outside the paint event

  if (!m_pi->m_opengl_mode) {
    LOG_DIALOG(wxT("BR24radar_pi: %s cannot render non-OpenGL mode"), m_ri->m_name.c_str());
    return;
  }
  if (!m_pi->m_opencpn_gl_context && !m_pi->m_opencpn_gl_context_broken) {
    LOG_DIALOG(wxT("BR24radar_pi: %s skip render as no context known yet"), m_ri->m_name.c_str());
    return;
  }
  LOG_DIALOG(wxT("BR24radar_pi: %s render OpenGL canvas %d by %d "), m_ri->m_name.c_str(), w, h);

  SetCurrent(*m_context);

  glPushMatrix();
  glPushAttrib(GL_ALL_ATTRIB_BITS);

  wxFont font = GetOCPNGUIScaledFont_PlugIn(_T("StatusBar"));
  m_FontNormal.Build(font);
  wxFont bigFont = GetOCPNGUIScaledFont_PlugIn(_T("Dialog"));
  bigFont.SetPointSize(bigFont.GetPointSize() + 2);
  bigFont.SetWeight(wxFONTWEIGHT_BOLD);
  m_FontBig.Build(bigFont);
  bigFont.SetPointSize(bigFont.GetPointSize() + 2);
  bigFont.SetWeight(wxFONTWEIGHT_NORMAL);
  m_FontMenu.Build(bigFont);
  bigFont.SetPointSize(bigFont.GetPointSize() + 10);
  bigFont.SetWeight(wxFONTWEIGHT_BOLD);
  m_FontMenuBold.Build(bigFont);

  glClearColor(0.0f, 0.0f, 0.0f, 1.0f);                // Black Background
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  // Clear the canvas
  glEnable(GL_TEXTURE_2D);                             // Enable textures
  glEnable(GL_COLOR_MATERIAL);
  glEnable(GL_BLEND);
  // glDisable(GL_DEPTH_TEST);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

  glViewport(0, 0, w, h);
  glMatrixMode(GL_PROJECTION);  // Next two operations on the project matrix stack
  glLoadIdentity();             // Reset projection matrix stack
  glOrtho(0, w, h, 0, -1, 1);
  glMatrixMode(GL_MODELVIEW);  // Reset matrick stack target back to GL_MODELVIEW

  RenderRangeRingsAndHeading(w, h);
  Render_EBL_VRM(w, h);

  glViewport(0, 0, w, h);
  glMatrixMode(GL_PROJECTION);  // Next two operations on the project matrix stack
  glLoadIdentity();             // Reset projection matrix stack
  if (w >= h) {
    glScaled(1.0, (float)-w / h, 1.0);
  } else {
    glScaled((float)h / w, -1.0, 1.0);
  }
  glMatrixMode(GL_MODELVIEW);  // Reset matrick stack target back to GL_MODELVIEW

  m_ri->RenderRadarImage(wxPoint(0, 0), 1.0, 0.0, false);

  glViewport(0, 0, w, h);
  glMatrixMode(GL_PROJECTION);  // Next two operations on the project matrix stack
  glLoadIdentity();             // Reset projection matrix stack
  glOrtho(0, w, h, 0, -1, 1);
  glMatrixMode(GL_MODELVIEW);  // Reset matrick stack target back to GL_MODELVIEW

  glEnable(GL_TEXTURE_2D);

  RenderTexts(w, h);
  RenderCursor(w, h);

#ifdef NEVER
  glDisable(GL_TEXTURE_2D);

  glMatrixMode(GL_PROJECTION);  // Next two operations on the project matrix stack
  glLoadIdentity();             // Reset projection matrix stack
  glMatrixMode(GL_MODELVIEW);   // Reset matrick stack target back to GL_MODELVIEW
#endif

  glPopAttrib();
  glPopMatrix();
  glFlush();
  glFinish();
  SwapBuffers();

  if (m_pi->m_opencpn_gl_context) {
    SetCurrent(*m_pi->m_opencpn_gl_context);
  } else {
    SetCurrent(*m_zero_context);  // Make sure OpenCPN -at least- doesn't overwrite our context info
  }
}
Пример #6
0
wxString GroupCell::ToTeX(bool all, wxString imgDir, wxString filename, int *imgCounter)
{
  wxString str;

  // pagebreak
  if (m_groupType == GC_TYPE_PAGEBREAK) {
    str = wxT("\\pagebreak\n");
  }

  // IMAGE CELLS
  else if (m_groupType == GC_TYPE_IMAGE && imgDir != wxEmptyString) {
    MathCell *copy = m_output->Copy(false);
    (*imgCounter)++;
    wxString image = filename + wxString::Format(wxT("_%d.png"), *imgCounter);
    wxString file = imgDir + wxT("/") + image;

    Bitmap bmp;
    bmp.SetData(copy);

    if (!wxDirExists(imgDir))
      wxMkdir(imgDir);

    if (bmp.ToFile(file))
    {
      str << wxT("\\begin{figure}[htb]\n")
          << wxT("  \\begin{center}\n")
          << wxT("    \\includegraphics{")
          << filename << wxT("_img/") << image << wxT("}\n")
          << wxT("  \\caption{") << PrepareForTeX(m_input->m_next->GetValue()) << wxT("}\n")
          << wxT("  \\end{center}\n")
          << wxT("\\end{figure}");
    }
  }
  else if (m_groupType == GC_TYPE_IMAGE)
    str << wxT("\n\\vert|<<GRAPHICS>>|\n");

  // CODE CELLS
  else if (m_groupType == GC_TYPE_CODE) {
    // Input cells
    str = wxT("\n\\noindent\n%%%%%%%%%%%%%%%\n")
          wxT("%%% INPUT:\n")
          wxT("\\begin{minipage}[t]{8ex}{\\color{red}\\bf\n")
          wxT("\\begin{verbatim}\n") +
          m_input->ToString(false) +
          wxT("\n\\end{verbatim}}\n\\end{minipage}");

    if (m_input->m_next!=NULL)
    {
      str += wxT("\n\\begin{minipage}[t]{\\textwidth}{\\color{blue}\n\\begin{verbatim}\n") +
             m_input->m_next->ToString(true) +
             wxT("\n\\end{verbatim}}\n\\end{minipage}");
    }

    str += wxT("\n");

    if (m_output != NULL) {
      str += wxT("%%% OUTPUT:\n");
      // Need to define labelcolor if this is Copy as LaTeX!
      if (imgCounter == NULL)
        str += wxT("\\definecolor{labelcolor}{RGB}{100,0,0}\n");
      str += wxT("\\begin{math}\\displaystyle\n");
      MathCell *tmp = m_output;

      while (tmp != NULL) {

        if (tmp->GetType() == MC_TYPE_IMAGE || tmp->GetType() == MC_TYPE_SLIDE)
        {
          if (imgDir != wxEmptyString)
          {
            MathCell *copy = tmp->Copy(false);
            (*imgCounter)++;
            wxString image = filename + wxString::Format(wxT("_%d.png"), *imgCounter);
            wxString file = imgDir + wxT("/") + image;

            Bitmap bmp;
            bmp.SetData(copy);

            if (!wxDirExists(imgDir))
              if (!wxMkdir(imgDir))
                continue;

            if (bmp.ToFile(file))
              str += wxT("\\includegraphics[width=9cm]{") +
                  filename + wxT("_img/") + image + wxT("}");
          }
          else
            str << wxT("\n\\verb|<<GRAPHICS>>|\n");
        }

        else if (tmp->GetStyle() == TS_LABEL)
        {
          if (str.Right(13) != wxT("displaystyle\n"))
            str += wxT("\n\\end{math}\n\n\\begin{math}\\displaystyle\n");
          str += wxT("\\parbox{8ex}{\\color{labelcolor}") + tmp->ToTeX(false) + wxT("}\n");
        }

        else
          str += tmp->ToTeX(false);

        tmp = tmp->m_nextToDraw;
      }
      str += wxT("\n\\end{math}\n%%%%%%%%%%%%%%%\n");
    }
  }

  // TITLES, SECTIONS, SUBSECTIONS, TEXT
  else if (GetEditable() != NULL && !m_hide) {
    str = GetEditable()->ToTeX(true);
    switch (GetEditable()->GetStyle()) {
      case TS_TITLE:
        str = wxT("\n\\pagebreak{}\n{\\Huge {\\sc ") + PrepareForTeX(str) + wxT("}}\n");
        str += wxT("\\setcounter{section}{0}\n\\setcounter{subsection}{0}\n");
        str += wxT("\\setcounter{figure}{0}\n\n");
        break;
      case TS_SECTION:
        str = wxT("\n\\section{") + PrepareForTeX(str) + wxT("}\n\n");
        break;
      case TS_SUBSECTION:
        str = wxT("\n\\subsection{") + PrepareForTeX(str) + wxT("}\n\n");
        break;
      default:
        if (str.StartsWith(wxT("TeX:")))
          str = str.Mid(5, str.Length());
        else {
          str = PrepareForTeX(str);
        }
        break;
    }
  }

  return str + MathCell::ToTeX(all);
}
Пример #7
0
void 
DlgPass::updatePipelines() {

	std::vector<std::string> pips;
	RENDERMANAGER->getPipelineNames(&pips);
	std::vector<std::string>::iterator iter;

	//wxString sel = m_PipelineList->GetStringSelection();
	wxString sel = wxString(RENDERMANAGER->getActivePipelineName());
	m_PipelineList->Clear();
	for (iter = pips.begin(); iter != pips.end(); ++iter)
		m_PipelineList->Append(wxString(iter->c_str()));

	if (! m_PipelineList->SetStringSelection(sel)) 
		m_PipelineList->SetSelection(0);

	sel = m_PipelineList->GetStringSelection();
	m_ActivePipText->SetLabelText(sel);
	std::string pipName = std::string(sel.mb_str());

	std::shared_ptr<Pipeline> &pip = RENDERMANAGER->getPipeline(pipName);

	std::vector<std::string> passes;
	pip->getPassNames(&passes);

	sel = m_PassList->GetStringSelection();
	m_PassList->Clear();

	for (auto &name:passes)
		m_PassList->Append(wxString(name.c_str()));

	if (! m_PassList->SetStringSelection(sel))
		m_PassList->SetSelection(0);
		
	Pass *p = getPass();


	m_PG->ClearPage(0);

		m_PG->Append(new wxStringProperty(wxT("Class"), wxPG_LABEL, wxT("")));
		m_PG->DisableProperty(wxT("Class"));

		m_pgCamList.Add(wxT("dummy"));
		m_pgPropCam = new wxEnumProperty(wxT("Camera"),wxPG_LABEL,m_pgCamList);
		m_PG->Append(m_pgPropCam);
		
		m_pgViewportList.Add(wxT("From Camera"));
		m_pgPropViewport = new wxEnumProperty(wxT("Viewport"),wxPG_LABEL,m_pgViewportList);
		m_PG->Append(m_pgPropViewport);

		m_PG->Append(new wxBoolProperty(wxT("Use Render Target"), wxPG_LABEL, true));
		m_PG->SetPropertyAttribute( wxT("Use Render Target"),
                              wxPG_BOOL_USE_CHECKBOX,
                              true );

		m_pgRenderTargetList.Add(wxT("None"));
		m_pgPropRenderTarget = new wxEnumProperty(wxT("Render Target"),wxPG_LABEL,m_pgRenderTargetList);
		m_PG->Append(m_pgPropRenderTarget);

	updateLists(p);
	setupGrid();
	updateProperties(p) ;
}
Пример #8
0
    wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
    wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
    wxFLAGS_MEMBER(wxVSCROLL)
    wxFLAGS_MEMBER(wxHSCROLL)

    wxFLAGS_MEMBER(wxST_NO_AUTORESIZE)
    wxFLAGS_MEMBER(wxALIGN_LEFT)
    wxFLAGS_MEMBER(wxALIGN_RIGHT)
    wxFLAGS_MEMBER(wxALIGN_CENTRE)

wxEND_FLAGS( wxStaticTextStyle )

IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticText, wxControl,"wx/stattext.h")

wxBEGIN_PROPERTIES_TABLE(wxStaticText)
    wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
    wxPROPERTY_FLAGS( WindowStyle , wxStaticTextStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
wxEND_PROPERTIES_TABLE()

wxBEGIN_HANDLERS_TABLE(wxStaticText)
wxEND_HANDLERS_TABLE()

wxCONSTRUCTOR_6( wxStaticText , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle )
#else
IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
#endif

bool wxStaticText::Create(wxWindow *parent,
                          wxWindowID id,
                          const wxString& label,
                          const wxPoint& pos,
Пример #9
0
wxIcon* IconGetter::GetDocumentIcon(const wxString& filePath, int iconSize) {
  #ifdef __WINDOWS__

  // Get the file type from the file extension
  wxFileType* fileType = NULL;

  wxFileName filename = wxFileName(filePath);
  wxString fileExtension = filename.GetExt();
  if (fileExtension != wxEmptyString) {
    fileType = wxTheMimeTypesManager->GetFileTypeFromExtension(fileExtension);
  }

  if (!fileType) {
    // The file type is not registered on the system, so try to get the default
    // icon from shell32.dll (works on Windows XP - not sure on Vista)

    // LPTSTR is wchar_t if UNICODE is enabled, or a char otherwise
    LPTSTR buffer = new TCHAR[MAX_PATH];
    int success = GetSystemDirectory(buffer, MAX_PATH);    

    // Convert the LPTSTR to a char*
    char cString[MAX_PATH];
    wcstombs(cString, buffer, MAX_PATH);
    wxDELETE(buffer);

    wxString shell32Path;
    if (success) {
      shell32Path = wxString::FromAscii(cString);
      shell32Path += wxT("\\SHELL32.DLL");
    } else {
      // If we couldn't get the system directory, try to guess it.
      // If the file doesn't exist, GetExecutableIcon() will return wxNullIcon
      shell32Path = wxT("C:\\WINDOWS\\SYSTEM32\\SHELL32.DLL");
    }

    return GetExecutableIcon(shell32Path, iconSize);
  }

  // Try to get the icon location from the file type
  wxIconLocation iconLocation;
  bool success = fileType->GetIcon(&iconLocation);

  // Fixes a bug in wxWidgets: Sometime the icon is negative, in which case the wxIconLocation will be invalid
  if (iconLocation.GetIndex() < 0) iconLocation.SetIndex(0);

  // Fixes a bug in wxWidgets: The filename is sometime surrounded by quotes, and so the wxIconLocation will
  // again be invalid. We remove the quotes below:
  wxString iconLocFile = iconLocation.GetFileName();
  while (iconLocFile[0] == _T('"')) iconLocFile = iconLocFile.Mid(1, iconLocFile.Len());
  while (iconLocFile[iconLocFile.Len() - 1] == _T('"')) iconLocFile = iconLocFile.Mid(0, iconLocFile.Len() - 1);
  iconLocation.SetFileName(iconLocFile);

  wxDELETE(fileType);

  if (success) {
    wxIcon* icon = new wxIcon(iconLocation);
    icon->SetSize(iconSize, iconSize);
    return icon;
  } else {

    // If we couldn't find the icon at this stage, look for it in the registry. The icon file path
    // may be stored in many different places. We need to look in:
    //
    // HKEY_CLASSES_ROOT\.<extension>\DefaultIcon\<defaultValue>
    // HKEY_CLASSES_ROOT\<documentType>\DefaultIcon\<defaultValue>
    // HKEY_CLASSES_ROOT\CLSID\<classId>\DefaultIcon\<defaultValue>
    //
    // The document type can be read at HKEY_CLASSES_ROOT\.<extension>\<defaultValue>
    // The class ID is (sometime) at HKEY_CLASSES_ROOT\<documentType>\CLSID\<defaultValue>
    // 
    // Note: all the DefaultIcon values already seem to be handled by wxWidgets so we
    // only care about the CLSID case below.
    // 
    // If there is no class ID, we could also look in:
    // HKEY_CLASSES_ROOT\<documentType>\shell\open\command
    // then get the associated executable from there and, finally, get the icon.
    // This is currently not implemented.
    //
    // Finally, some icons are displayed using an icon handler that can be found at:
    // HKEY_CLASSES_ROOT\<documentType>\ShellEx\IconHandler\<defaultValue>
    // This is a special module which displays the icon depending on the file content. It
    // may actually display two different icons for the same file extension. For example,
    // a C# .sln file is going to be displayed differently than a C++ .sln file. These cases
    // are hopefully rare enough to ignore them.

    wxRegKey* regKey = new wxRegKey(_T("HKEY_CLASSES_ROOT\\.") + fileExtension);
    wxString iconPath;

    if (regKey->Exists()) {
      wxString extensionLink = regKey->QueryDefaultValue();    

      if (extensionLink != wxEmptyString) {
        wxDELETE(regKey);
        regKey = new wxRegKey(_T("HKEY_CLASSES_ROOT\\") + extensionLink + _T("\\CLSID"));

        if (regKey->Exists()) {
          wxString classIdLink = regKey->QueryDefaultValue();

          if (classIdLink != wxEmptyString) {
            wxDELETE(regKey);
            regKey = new wxRegKey(_T("HKEY_CLASSES_ROOT\\CLSID\\") + classIdLink + _T("\\DefaultIcon"));
            
            if (regKey->Exists()) {
              iconPath = regKey->QueryDefaultValue();
            }            
          }
        }   
      }
    }

    wxDELETE(regKey);
     
    if (iconPath != wxEmptyString) {
      // The icon path may be specified with coma or followed by the icon index, as in:
      // c:\WINDOWS\Installer\{AC76BA86-7AD7-1033-7B44-A90000000001}\PDFFile_8.ico,0
      // So we need to split the string and extract the file path and index.

      wxArrayString splitted;

      if (iconPath.Find(_T(';')) != wxNOT_FOUND) {
        StringUtil::Split(iconPath, splitted, _T(";"));
      } else {
        StringUtil::Split(iconPath, splitted, _T(","));
      }
      
      iconPath = splitted[0];
      long iconIndex = 0;

      // If the conversion to long fails, we default to "0" which should be safe
      if (splitted.Count() > 1) splitted[1].ToLong(&iconIndex);
      
      // Sometime, the icon index is negative, for example for .resx files. Not sure
      // why since the icon actually displayed by Windows is at index 0.
      if (iconIndex < 0) iconIndex = 0;

      wxFileName f(iconPath);
      wxString e = f.GetExt().Lower();
      // Normally, it shouldn't be anything other than ico, exe or dll. If it is, we just return NULL for now.
      if (e == _T("ico") || e == _T("exe") || e == _T("dll")) return IconGetter::GetExecutableIcon(iconPath, iconSize, iconIndex);
    }

  }
  
  #endif // __WINDOWS__
  
  return NULL;
}
Пример #10
0
wxString wxStandardPaths::GetDataDir() const
{
    return GetInstallPrefix() + wxT("\\data");
}
Пример #11
0
wxString wxStandardPaths::GetUserDataDir() const
{
    return AppendAppInfo(wxFileName::GetHomeDir() + wxT("\\."));
}
Пример #12
0
/* Read a gerber file, RS274D or RS274X format.
 */
bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName,
                                           const wxString& D_Code_FullFileName )
{
    int      G_command = 0;        // command number for G commands like G04
    int      D_commande = 0;       // command number for D commands like D02

    char     line[GERBER_BUFZ];

    wxString msg;
    char*    text;
    int layer;         // current layer used in GerbView

    layer = getActiveLayer();

    if( g_GERBER_List[layer] == NULL )
    {
        g_GERBER_List[layer] = new GERBER_IMAGE( this, layer );
    }

    GERBER_IMAGE* gerber = g_GERBER_List[layer];
    ClearMessageList( );

    /* Set the gerber scale: */
    gerber->ResetDefaultValues();

    /* Read the gerber file */
    gerber->m_Current_File = wxFopen( GERBER_FullFileName, wxT( "rt" ) );
    if( gerber->m_Current_File == 0 )
    {
        msg.Printf( _( "File <%s> not found" ), GetChars( GERBER_FullFileName ) );
        DisplayError( this, msg, 10 );
        return false;
    }

    gerber->m_FileName = GERBER_FullFileName;

    wxString path = wxPathOnly( GERBER_FullFileName );
    if( path != wxEmptyString )
        wxSetWorkingDirectory( path );

    SetLocaleTo_C_standard();

    while( true )
    {
        if( fgets( line, sizeof(line), gerber->m_Current_File ) == NULL )
        {
            if( gerber->m_FilesPtr == 0 )
                break;

            fclose( gerber->m_Current_File );

            gerber->m_FilesPtr--;
            gerber->m_Current_File =
                gerber->m_FilesList[gerber->m_FilesPtr];

            continue;
        }

        text = StrPurge( line );

        while( text && *text )
        {
            switch( *text )
            {
            case ' ':
            case '\r':
            case '\n':
                text++;
                break;

            case '*':       // End command
                gerber->m_CommandState = END_BLOCK;
                text++;
                break;

            case 'M':       // End file
                gerber->m_CommandState = CMD_IDLE;
                while( *text )
                    text++;
                break;

            case 'G':    /* Line type Gxx : command */
                G_command = gerber->GCodeNumber( text );
                gerber->Execute_G_Command( text, G_command );
                break;

            case 'D':       /* Line type Dxx : Tool selection (xx > 0) or
                             * command if xx = 0..9 */
                D_commande = gerber->DCodeNumber( text );
                gerber->Execute_DCODE_Command( text, D_commande );
                break;

            case 'X':
            case 'Y':                   /* Move or draw command */
                gerber->m_CurrentPos = gerber->ReadXYCoord( text );
                if( *text == '*' )      // command like X12550Y19250*
                {
                    gerber->Execute_DCODE_Command( text,
                                                   gerber->m_Last_Pen_Command );
                }
                break;

            case 'I':
            case 'J':       /* Auxiliary Move command */
                gerber->m_IJPos = gerber->ReadIJCoord( text );
                if( *text == '*' )      // command like X35142Y15945J504*
                {
                    gerber->Execute_DCODE_Command( text,
                                                   gerber->m_Last_Pen_Command );
                }
                break;

            case '%':
                if( gerber->m_CommandState != ENTER_RS274X_CMD )
                {
                    gerber->m_CommandState = ENTER_RS274X_CMD;
                    gerber->ReadRS274XCommand( line, text );
                }
                else        //Error
                {
                    ReportMessage( wxT("Expected RS274X Command")  );
                    gerber->m_CommandState = CMD_IDLE;
                    text++;
                }
                break;

            default:
                text++;
                msg.Printf( wxT("Unexpected symbol <%c>"), *text );
                ReportMessage( msg );
                break;
            }
        }
    }
    fclose( gerber->m_Current_File );
    SetLocaleTo_Default();

    gerber->m_InUse = true;

    // Display errors list
    if( m_Messages.size() > 0 )
    {
        HTML_MESSAGE_BOX dlg( this, _("Errors") );
        dlg.ListSet(m_Messages);
        dlg.ShowModal();
    }

    /* if the gerber file is only a RS274D file
     * (i.e. without any aperture information), wran the user:
     */
    if( !gerber->m_Has_DCode )
    {
        msg = _("Warning: this file has no D-Code definition\n"
                "It is perhaps an old RS274D file\n"
                "Therefore the size of items is undefined");
        wxMessageBox( msg );
    }

    return true;
}
void PCB_EDIT_FRAME::OnUpdateShowMicrowaveToolbar( wxUpdateUIEvent& aEvent )
{
    aEvent.Check( m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).IsShown() );
}
void PCB_EDIT_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent )
{
    aEvent.Check( m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).IsShown() );
}
Пример #15
0
GroupCell::GroupCell(int groupType, wxString initString) : MathCell()
{
  m_input = NULL;
  m_output = NULL;
  m_hiddenTree = NULL;
  m_outputRect.x = -1;
  m_outputRect.y = -1;
  m_outputRect.width = 0;
  m_outputRect.height = 0;
  m_group = this;
  m_forceBreakLine = true;
  m_breakLine = true;
  m_type = MC_TYPE_GROUP;
  m_indent = MC_GROUP_LEFT_INDENT;
  m_hide = false;
  m_working = false;
  m_groupType = groupType;
  m_lastInOutput = NULL;
  m_appendedCells = NULL;

  // set up cell depending on groupType, so we have a working cell
  if (groupType != GC_TYPE_PAGEBREAK) {
    if (groupType == GC_TYPE_CODE)
      m_input = new TextCell(EMPTY_INPUT_LABEL);
    else
      m_input = new TextCell(wxT(" "));

    m_input->SetType(MC_TYPE_MAIN_PROMPT);
  }

  bool match = true;
  wxConfig::Get()->Read(wxT("matchParens"), &match);
  EditorCell *editor = new EditorCell();
  editor->SetMatchParens(match);

  switch (groupType) {
    case GC_TYPE_CODE:
      editor->SetType(MC_TYPE_INPUT);
      AppendInput(editor);
      break;
    case GC_TYPE_TEXT:
      m_input->SetType(MC_TYPE_TEXT);
      editor->SetType(MC_TYPE_TEXT);
      AppendInput(editor);
      break;
    case GC_TYPE_TITLE:
      m_input->SetType(MC_TYPE_TITLE);
      editor->SetType(MC_TYPE_TITLE);
      AppendInput(editor);
      break;
    case GC_TYPE_SECTION:
      m_input->SetType(MC_TYPE_SECTION);
      editor->SetType(MC_TYPE_SECTION);
      AppendInput(editor);
      break;
    case GC_TYPE_SUBSECTION:
      m_input->SetType(MC_TYPE_SUBSECTION);
      editor->SetType(MC_TYPE_SUBSECTION);
      AppendInput(editor);
      break;
    case GC_TYPE_IMAGE:
      m_input->SetType(MC_TYPE_TEXT);
      editor->SetType(MC_TYPE_TEXT);
      editor->SetValue(wxEmptyString);
      AppendInput(editor);
      break;
    default:
      delete editor;
      editor = NULL;
      break;
  }

  if (editor != NULL)
    editor->SetValue(initString);

  // when creating an image cell, if a string is provided
  // it loads an image (without deleting it)
  if ((groupType == GC_TYPE_IMAGE) && (initString.Length() > 0)) {
    ImgCell *ic = new ImgCell(initString, false);
    AppendOutput(ic);
  }

  SetParent(this, false);
}
Пример #16
0
void wxHIDJoystick::MakeCookies(CFArrayRef Array)
{
    int i, nUsage, nPage;

    for (i = 0; i < CFArrayGetCount(Array); ++i)
    {
        const void* ref = CFDictionaryGetValue(
                (CFDictionaryRef)CFArrayGetValueAtIndex(Array, i),
                CFSTR(kIOHIDElementKey)
                                              );

        if (ref != NULL)
        {
            MakeCookies((CFArrayRef) ref);
    }
        else
        {
            CFNumberGetValue(
                (CFNumberRef)
                    CFDictionaryGetValue(
                        (CFDictionaryRef) CFArrayGetValueAtIndex(Array, i),
                        CFSTR(kIOHIDElementUsageKey)
                                        ),
                kCFNumberIntType,
                &nUsage    );

            CFNumberGetValue(
                (CFNumberRef)
                    CFDictionaryGetValue(
                        (CFDictionaryRef) CFArrayGetValueAtIndex(Array, i),
                        CFSTR(kIOHIDElementUsagePageKey)
                                        ),
                kCFNumberIntType,
                &nPage     );

#if 0
            wxLogSysError(wxT("[%i][%i]"), nUsage, nPage);
#endif
            if (nPage == kHIDPage_Button && nUsage <= 40)
                AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), nUsage-1 );
            else if (nPage == kHIDPage_GenericDesktop)
            {
                //axis...
                switch(nUsage)
                {
                    case kHIDUsage_GD_X:
                        AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_X);
                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                                 CFSTR(kIOHIDElementMaxKey),
                                                 &m_nXMax);
                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                                 CFSTR(kIOHIDElementMinKey),
                                                 &m_nXMin);
                        break;
                    case kHIDUsage_GD_Y:
                        AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_Y);
                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                                 CFSTR(kIOHIDElementMaxKey),
                                                 &m_nYMax);
                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                                 CFSTR(kIOHIDElementMinKey),
                                                 &m_nYMin);
                        break;
                    case kHIDUsage_GD_Z:
                        AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_Z);
                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                                 CFSTR(kIOHIDElementMaxKey),
                                                 &m_nZMax);
                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                                 CFSTR(kIOHIDElementMinKey),
                                                 &m_nZMin);
                        break;
                    default:
                        break;
                }
            }
            else if (nPage == kHIDPage_Simulation && nUsage == kHIDUsage_Sim_Rudder)
            {
                //rudder...
                AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_RUDDER );
                wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                         CFSTR(kIOHIDElementMaxKey),
                                         &m_nRudderMax);
                wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                         CFSTR(kIOHIDElementMinKey),
                                         &m_nRudderMin);
            }
        }
    }
}
Пример #17
0
wxString GroupCell::PrepareForTeX(wxString str)
{
#if !wxUSE_UNICODE
  wxString str1(str.wc_str(wxConvLocal), wxConvUTF8);
#else
  wxString str1(str);
#endif

  str1.Replace(wxT("\\"), wxT("\\verb|\\|"));
  str1.Replace(wxT("_"), wxT("\\_"));
  str1.Replace(wxT("%"), wxT("\\%"));
  str1.Replace(wxT("{"), wxT("\\{"));
  str1.Replace(wxT("}"), wxT("\\}"));
  str1.Replace(wxT("^"), wxT("\\verb|^|"));
  str1.Replace(wxT(">"), wxT("\\verb|>|"));
  str1.Replace(wxT("<"), wxT("\\verb|<|"));

#if !wxUSE_UNICODE
  wxString str2(str1.wc_str(wxConvUTF8), wxConvLocal);
#else
  wxString str2(str1);
#endif

  return str2;
}
Пример #18
0
//---------------------------------------------------------------------------
// wxJoystickThread::Entry
//
// Thread procedure
//
// Runs a CFRunLoop for polling. Basically, it sets the HID queue to
// call wxJoystickThread::HIDCallback in the context of this thread
// when something changes on the device. It polls as long as the user
// wants, or a certain amount if the user wants to "block". Note that
// we don't actually block here since this is in a secondary thread.
//---------------------------------------------------------------------------
void* wxJoystickThread::Entry()
{
    CFRunLoopSourceRef pRLSource = NULL;

    if ((*m_hid->GetQueue())->createAsyncEventSource(
                    m_hid->GetQueue(), &pRLSource) != kIOReturnSuccess )
    {
        wxLogSysError(wxT("Couldn't create async event source"));
        return NULL;
    }

    wxASSERT(pRLSource != NULL);

    //attach runloop source to main run loop in thread
    CFRunLoopRef pRL = CFRunLoopGetCurrent();
    CFRunLoopAddSource(pRL, pRLSource, kCFRunLoopDefaultMode);
    wxASSERT( CFRunLoopContainsSource(pRL, pRLSource, kCFRunLoopDefaultMode) );


    if( (*m_hid->GetQueue())->setEventCallout(m_hid->GetQueue(),
          wxJoystickThread::HIDCallback, this, this) != kIOReturnSuccess )
    {
        wxLogSysError(wxT("Could not set event callout for queue"));
        return NULL;
    }

    if( (*m_hid->GetQueue())->start(m_hid->GetQueue()) != kIOReturnSuccess )
    {
        wxLogSysError(wxT("Could not start queue"));
        return NULL;
    }

    double dTime;

    while(true)
    {
        if (TestDestroy())
            break;

        if (m_polling)
            dTime = 0.0001 * m_polling;
        else
            dTime = 0.0001 * 10;  // check at least every 10 msec in "blocking" case

        //true just "handles and returns" - false forces it to stay the time
        //amount
#if 1
        CFRunLoopRunInMode(kCFRunLoopDefaultMode, dTime, true);
#else
        IOReturn ret = NULL;
        HIDCallback(this, ret, this, this);
        Sleep(3000);
#endif
    }

    wxASSERT( CFRunLoopContainsSource(pRL, pRLSource, kCFRunLoopDefaultMode) );

    CFRunLoopRemoveSource(pRL, pRLSource, kCFRunLoopDefaultMode);
    CFRelease(pRLSource);

    return NULL;
}
Пример #19
0
// ToXML
// writes a groupcell in the form of
// <cell type="code" hide="true">
// --contents--
// </cell>
wxString GroupCell::ToXML(bool all)
{
  wxString str;
  str = wxT("\n<cell"); // start opening tag
  // write "type" according to m_groupType
  switch (m_groupType) {
    case GC_TYPE_CODE:
      str += wxT(" type=\"code\"");
      break;
    case GC_TYPE_IMAGE:
      str += wxT(" type=\"image\"");
      break;
    case GC_TYPE_TEXT:
      str += wxT(" type=\"text\"");
      break;
    case GC_TYPE_TITLE:
      str += wxT(" type=\"title\"");
      break;
    case GC_TYPE_SECTION:
      str += wxT(" type=\"section\"");
      break;
    case GC_TYPE_SUBSECTION:
      str += wxT(" type=\"subsection\"");
      break;
    case GC_TYPE_PAGEBREAK:
      {
        str += wxT(" type=\"pagebreak\"/>");
        return str + MathCell::ToXML(all);
      }
      break;
    default:
      str += wxT(" type=\"unknown\"");
      break;
  }

  // write hidden status
  if (m_hide)
    str += wxT(" hide=\"true\"");
  str += wxT(">\n");

  MathCell *input = GetInput();
  MathCell *output = GetLabel();
  // write contents
  switch (m_groupType) {
    case GC_TYPE_CODE:
      if (input != NULL) {
        str += wxT("<input>\n");
        str += input->ToXML(false);
        str += wxT("</input>");
      }
      if (output != NULL) {
        str += wxT("\n<output>\n");
        str += wxT("<mth>") + output->ToXML(true) + wxT("</mth>");
        str += wxT("\n</output>");
      }
      break;
    case GC_TYPE_IMAGE:
      if (input != NULL)
        str += input->ToXML(false);
      if (output != NULL)
        str += output->ToXML(true);
      break;
    case GC_TYPE_TEXT:
      if (input)
        str += input->ToXML(false);
      break;
    case GC_TYPE_TITLE:
    case GC_TYPE_SECTION:
    case GC_TYPE_SUBSECTION:
      if (input)
        str += input->ToXML(false);
      if (m_hiddenTree) {
        str += wxT("<fold>");
        GroupCell *tmp = m_hiddenTree;
        while (tmp) {
          str += tmp->ToXML(false);
          tmp = dynamic_cast<GroupCell*>(tmp->m_next);
        }
        str += wxT("</fold>");
      }
      break;
    default:
      if (output != NULL)
        str += output->ToXML(false);
      break;
  }
  str += wxT("\n</cell>\n");

  return str + MathCell::ToXML(all);
}
Пример #20
0
//---------------------------------------------------------------------------
// wxJoystickThread::HIDCallback (static)
//
// Callback for the native HID device when it recieves input.
//
// This is where the REAL dirty work gets done.
//
// 1) Loops through each event the queue has recieved
// 2) First, checks if the thread that is running the loop for
//    the polling has ended - if so it breaks out
// 3) Next, it checks if there was an error getting this event from
//    the HID queue, if there was, it logs an error and returns
// 4) Now it does the real dirty work by getting the button states
//    from cookies 0-40 and axes positions/states from cookies 40-50
//    in the native HID device by quering cookie values.
// 5) Sends the event to the polling window (if any)
// 6) Gets the next event and goes back to (1)
//---------------------------------------------------------------------------
/*static*/ void wxJoystickThread::HIDCallback(void* WXUNUSED(target),
                                              IOReturn WXUNUSED(res),
                                              void* context,
                                              void* WXUNUSED(sender))
{
    IOHIDEventStruct hidevent;
    AbsoluteTime bogustime = {0,0};
    IOReturn ret;
    wxJoystickThread* pThis = (wxJoystickThread*) context;
    wxHIDJoystick* m_hid = pThis->m_hid;

    //Get the "first" event from the queue
    //bogustime tells it we don't care at what time to start
    //where it gets the next from
    ret = (*m_hid->GetQueue())->getNextEvent(m_hid->GetQueue(),
                    &hidevent, bogustime, 0);

    while (ret != kIOReturnUnderrun)
    {
        if (pThis->TestDestroy())
            break;

        if(ret != kIOReturnSuccess)
        {
            wxLogSysError(wxString::Format(wxT("wxJoystick Error:[%i]"), ret));
            return;
        }

        wxJoystickEvent wxevent;

        //Find the cookie that changed
        int nIndex = 0;
        IOHIDElementCookie* pCookies = m_hid->GetCookies();
        while(nIndex < 50)
        {
            if(hidevent.elementCookie == pCookies[nIndex])
                break;

            ++nIndex;
        }

        //debugging stuff
#if 0
        if(nIndex == 50)
        {
            wxLogSysError(wxString::Format(wxT("wxJoystick Out Of Bounds Error")));
            break;
        }
#endif

        //is the cookie a button?
        if (nIndex < 40)
        {
            if (hidevent.value)
            {
                pThis->m_buttons |= (1 << nIndex);
                wxevent.SetEventType(wxEVT_JOY_BUTTON_DOWN);
            }
            else
            {
                pThis->m_buttons &= ~(1 << nIndex);
                wxevent.SetEventType(wxEVT_JOY_BUTTON_UP);
            }

            wxevent.SetButtonChange(nIndex+1);
        }
        else if (nIndex == wxJS_AXIS_X)
        {
            pThis->m_lastposition.x = hidevent.value;
            wxevent.SetEventType(wxEVT_JOY_MOVE);
            pThis->m_axe[0] = hidevent.value;
        }
        else if (nIndex == wxJS_AXIS_Y)
        {
            pThis->m_lastposition.y = hidevent.value;
            wxevent.SetEventType(wxEVT_JOY_MOVE);
            pThis->m_axe[1] = hidevent.value;
        }
        else if (nIndex == wxJS_AXIS_Z)
        {
            wxevent.SetEventType(wxEVT_JOY_ZMOVE);
            pThis->m_axe[2] = hidevent.value;
        }
        else
            wxevent.SetEventType(wxEVT_JOY_MOVE);

        Nanoseconds timestamp = AbsoluteToNanoseconds(hidevent.timestamp);

        wxULongLong llTime(timestamp.hi, timestamp.lo);

        llTime /= 1000000;

        wxevent.SetTimestamp(llTime.GetValue());
        wxevent.SetJoystick(pThis->m_joystick);
        wxevent.SetButtonState(pThis->m_buttons);
        wxevent.SetPosition(pThis->m_lastposition);
        wxevent.SetZPosition(pThis->m_axe[2]);
        wxevent.SetEventObject(pThis->m_catchwin);

        if (pThis->m_catchwin)
            pThis->m_catchwin->GetEventHandler()->AddPendingEvent(wxevent);

        ret = (*m_hid->GetQueue())->getNextEvent(m_hid->GetQueue(),
                    &hidevent, bogustime, 0);
    }
}
Пример #21
0
void DlgPass::updateProperties(Pass *p) {

	//
	m_PG->SetPropertyValue(wxT("Class"), wxString(p->getClassName().c_str()));

	// CAMERA
	if (p->getClassName() == "quad")
		m_PG->DisableProperty(wxT("Camera"));
	else
		m_PG->EnableProperty(wxT("Camera"));

	m_PG->SetPropertyValue(wxT("Camera"), wxString(p->getCameraName().c_str()));

	// VIEWPORT
	std::shared_ptr<Viewport> v = p->getViewport();

	if (p->hasRenderTarget() && p->isRenderTargetEnabled()) {
		m_PG->SetPropertyValue(wxT("Viewport"), wxT("From Render Target"));
		m_PG->DisableProperty(wxT("Viewport"));
	}
	else if (!v) {
		m_PG->EnableProperty(wxT("Viewport"));
		m_PG->SetPropertyValue(wxT("Viewport"), wxT("From Camera"));
	}
	else {
		m_PG->EnableProperty(wxT("Viewport"));
		m_PG->SetPropertyValue(wxT("Viewport"), wxString(v->getName().c_str()));
	}

	// RENDER TARGET
	if (RESOURCEMANAGER->getNumRenderTargets()) {
		m_PG->EnableProperty(wxT("Render Target"));
		m_PG->EnableProperty(wxT("Use Render Target"));
	}
	else {
		m_PG->DisableProperty(wxT("Render Target"));
		m_PG->DisableProperty(wxT("Use Render Target"));
	}

	if (p->hasRenderTarget())
		m_PG->SetPropertyValue(wxT("Render Target"), wxString(p->getRenderTarget()->getName().c_str()));
	else
		m_PG->SetPropertyValue(wxT("Render Target"), wxT("None"));
		
	m_PG->SetPropertyValue(wxT("Use Render Target"),p->isRenderTargetEnabled());

	// SCENES
	std::vector<std::string> names;
	RENDERMANAGER->getAllSceneNames(&names);
	std::vector<std::string>::iterator iter;
	bool b;

	for (iter = names.begin(); iter != names.end(); ++iter) {

		if (p->hasScene(*iter))
			b = true;
		else
			b = false;
		wxString str(wxT("Scenes."));
		str.Append(wxString(*iter).c_str());
		m_PG->SetPropertyValue(str, b);
	}

	// LIGHTS
	std::vector<std::string> lNames;
	RENDERMANAGER->getLightNames(&lNames);

	for (auto & name:lNames) {

		if (p->hasLight(name))
			b = true;
		else
			b = false;
		wxString str(wxT("Lights."));
		wxString aux(name.c_str());
		str.Append(wxString(name.c_str()));
		m_PG->SetPropertyValue(str, b);
	}

	if (m_PG->GetPropertyByName(wxT("Material Maps")))
		m_PG->DeleteProperty(wxT("Material Maps"));

	std::map<std::string, nau::material::MaterialID> mm = p->getMaterialMap();

	wxPGProperty *pgMM;
	pgMM = m_PG->Append(new wxPGProperty(wxT("Material Maps"), wxPG_LABEL));

	std::map<std::string, nau::material::MaterialID>::iterator iterMM = mm.begin();
	MaterialID mid;
	wxString mName,propName;

	if (mm.size() != 0 && iterMM->first == "*") {
		mid = iterMM->second;
		mName = wxString(mid.getLibName().c_str());
		mName.append(wxT("::"));
		mName.append(wxString(mid.getMaterialName().c_str()));
		m_PG->AppendIn(pgMM, new wxEnumProperty(wxT("*"), wxPG_LABEL,m_pgMaterialListPlus));
		propName = wxT("Material Maps.*");
		m_PG->SetPropertyValue(propName, mName);

		++iterMM;
	}
	else {
		m_PG->AppendIn(pgMM, new wxEnumProperty(wxT("*"), wxPG_LABEL,m_pgMaterialListPlus));
		propName = wxT("Material Maps.*");
		m_PG->SetPropertyValue(propName, wxT("None"));	
	}

	for ( ; iterMM != mm.end() ; ++iterMM) {

		mid = iterMM->second;
		mName = wxString(mid.getLibName().c_str());
		mName.append(wxT("::"));
		mName.append(wxString(mid.getMaterialName().c_str()));
		m_PG->AppendIn(pgMM, new wxEnumProperty(wxString(iterMM->first.c_str()), wxPG_LABEL,m_pgMaterialList));
		propName = wxT("Material Maps.");
		propName.append(wxString(iterMM->first.c_str()));
		m_PG->SetPropertyValue(propName, mName);
		//property name is the first value of the map, the prop value is the second value of the map
	}

	PropertyManager::updateGrid(m_PG, Pass::GetAttribs(), (AttributeValues *)p);

	Refresh();

	//m_PG->RefreshGrid();//->Refresh();
}
/* Must be called on a click on the left toolbar (options toolbar
 * Update variables according to tools states
 */
void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
    int id = event.GetId();
    bool state = event.IsChecked();
    DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions();

    switch( id )
    {
    case ID_TB_OPTIONS_DRC_OFF:
        g_Drc_On = !state;

        if( GetToolId() == ID_TRACK_BUTT )
        {
            if( g_Drc_On )
                m_canvas->SetCursor( wxCURSOR_PENCIL );
            else
                m_canvas->SetCursor( wxCURSOR_QUESTION_ARROW );
        }
        break;

    case ID_TB_OPTIONS_SHOW_RATSNEST:
        SetElementVisibility( RATSNEST_VISIBLE, state );

        if( state && (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
            Compile_Ratsnest( NULL, true );

        m_canvas->Refresh();
        break;

    case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST:
        displ_opts->m_Show_Module_Ratsnest = state; // TODO: see if we can use the visibility list
        break;

    case ID_TB_OPTIONS_AUTO_DEL_TRACK:
        g_AutoDeleteOldTrack = state;
        break;

    case ID_TB_OPTIONS_SHOW_ZONES:
        displ_opts->m_DisplayZonesMode = 0;
        m_canvas->Refresh();
        break;

    case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
        displ_opts->m_DisplayZonesMode = 1;
        m_canvas->Refresh();
        break;

    case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
        displ_opts->m_DisplayZonesMode = 2;
        m_canvas->Refresh();
        break;

    case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
        displ_opts->m_DisplayViaFill = !state;
        m_canvas->Refresh();
        break;

    case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
        displ_opts->m_DisplayPcbTrackFill = !state;
        m_canvas->Refresh();
        break;

    case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
    {
        displ_opts->m_ContrastModeDisplay = state;
        m_canvas->Refresh();
        break;
    }

    case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE:
        m_show_microwave_tools = state;
        m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).Show( m_show_microwave_tools );
        m_auimgr.Update();

        GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR,
                        m_show_microwave_tools ?
                        _( "Hide Microwave Toolbar" ): _( "Show Microwave Toolbar" ));
        break;

    case ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR:
        // show auxiliary Vertical layers and visibility manager toolbar
        m_show_layer_manager_tools = state;
        m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
        m_auimgr.Update();

        GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
                                m_show_layer_manager_tools ?
                                _( "Hide &Layers Manager" ) : _( "Show &Layers Manager" ) );
        break;

    default:
        DisplayError( this,
                      wxT( "PCB_EDIT_FRAME::OnSelectOptionToolbar error \n (event not handled!)" ) );
        break;
    }
}
Пример #23
0
void 
DlgPass::OnProcessPGChange( wxPropertyGridEvent& e)
{
	Pass *p = getPass();

	wxString name,subname,value;
	std::string mat,lib;
	name = e.GetPropertyName();
	int index;
	index = e.GetPropertyValue().GetInteger();

	if (name == wxT("Camera")) {
		value = m_pgCamList.GetLabel(index);
		p->setCamera(std::string(value.mb_str()));	
	}
	else if (name == wxT("Viewport")) {
		if (index == 0)
			p->setViewport(RENDERMANAGER->getCamera(p->getCameraName())->getViewport());
		else {
			value = m_pgViewportList.GetLabel(index-1);
			p->setViewport(RENDERMANAGER->getViewport(std::string(value.mb_str())));
		}
	}
	else if (name == wxT("Use Render Target")) {
		p->enableRenderTarget(0 != e.GetPropertyValue().GetBool());
	}
	else if (name == wxT("Render Target")) {
		value = e.GetPropertyValue().GetString();
		if (value == wxT("None")) {
			p->setRenderTarget(NULL);
			m_PG->SetPropertyValue(wxT("Viewport"),wxT("From Camera"));
			m_PG->EnableProperty(wxT("Viewport"));
		}
		else {
			m_PG->SetPropertyValue(wxT("Viewport"), wxT("From Render Target"));
			m_PG->DisableProperty(wxT("Viewport"));
			p->setRenderTarget(RESOURCEMANAGER->getRenderTarget(std::string(value.mb_str())));
		}
	}
	//else if (name == wxT("Clear Color")) 
	//	p->setPropb(Pass::COLOR_CLEAR, (0 != e.GetPropertyValue().GetBool()));
	//else if (name == wxT("Clear Depth"))
	//	p->setPropb(Pass::DEPTH_CLEAR, (0 != e.GetPropertyValue().GetBool()));
	
	else if (name.substr(0,6) == wxT("Lights")) {

		subname = name.substr(7,std::string::npos);
		bool b = 0 != e.GetPropertyValue().GetBool();
		if (b)
			p->addLight(std::string(subname.mb_str()));
		else
			p->removeLight(std::string(subname.mb_str()));
	}
	else if (name.substr(0,6) == wxT("Scenes")) {

		subname = name.substr(7,std::string::npos);
		bool b = 0 != e.GetPropertyValue().GetBool();
		if (b)
			p->addScene(std::string(subname.mb_str()));
		else
			p->removeScene(std::string(subname.mb_str()));
	}
	else if (name.substr(0,13) == wxT("Material Maps")) { // Material Maps

		subname = name.substr(14, std::string::npos);
		if (subname == wxT("*"))
			value = m_pgMaterialListPlus.GetLabel(e.GetPropertyValue().GetInteger());
		else
			value = m_pgMaterialList.GetLabel(e.GetPropertyValue().GetInteger());
		mat = std::string(value.AfterLast(':').mb_str());
		lib = std::string(value.BeforeFirst(':').mb_str());

		if (subname == wxT("*")) {
			if (mat == "*") {
				p->remapAll(lib);
				updateMats(p);
			}
			else if (value != wxT("None")) {
				p->remapAll(lib,mat);
				updateMats(p);
			}
		}
		else
			p->remapMaterial(std::string(subname.c_str()),lib,mat);
	}
	else
		PropertyManager::updateProp(m_PG, name.ToStdString(), Pass::GetAttribs(), (AttributeValues *)p);

	//else if (name.substr(0,10) == wxT("Parameters")) {

	//	subname = name.substr(11, std::string::npos);
	//	p->setParam(std::string(subname.mb_str()), (float)(e.GetPropertyValue().GetDouble()));
	//
	//} 
}
Пример #24
0
// Get PID and name of each process that has our DLL loaded.
static bool GetProcesses(std::vector<ProcessInfo>& processes)
{
   // PSAPI function pointers.
   BOOL (WINAPI* lpfEnumProcesses)(DWORD*, DWORD, DWORD*);
   BOOL (WINAPI* lpfEnumProcessModules)(HANDLE, HMODULE*, DWORD, LPDWORD );
   DWORD (WINAPI* lpfGetModuleBaseName)(HANDLE, HMODULE, LPCTSTR, DWORD);
   
   bool found = false;
         
   // Load library and get function pointers.
   HINSTANCE hInstLib = LoadLibraryA("PSAPI.DLL");
   if (!hInstLib)
   {
       DBG("Failed to load PSAPI.DLL");
       return false;
   }
   
   // Get procedure addresses.
   lpfEnumProcesses = (BOOL (WINAPI*)(DWORD*,DWORD,DWORD*)) GetProcAddress(hInstLib, "EnumProcesses");
   lpfEnumProcessModules = (BOOL (WINAPI*)(HANDLE, HMODULE*, DWORD, LPDWORD)) GetProcAddress( hInstLib, "EnumProcessModules" );
   lpfGetModuleBaseName =(DWORD (WINAPI*)(HANDLE, HMODULE, LPCTSTR, DWORD )) GetProcAddress( hInstLib, "GetModuleBaseNameW" );

   if (!lpfEnumProcesses ||
       !lpfEnumProcessModules ||
       !lpfGetModuleBaseName)
   {
       DBG("GetProcAddress failed");
       FreeLibrary(hInstLib);
       return false;
   }

   DWORD pidList[1000];
   DWORD iCbneeded;
   if (!lpfEnumProcesses(pidList, sizeof(pidList), &iCbneeded))
   {
       DBG("EnumProcesses failed");
       FreeLibrary(hInstLib);
       return false;
   }

   // How many processes are there?
   int iNumProc = iCbneeded/sizeof(DWORD);

   // Get and match the name of each process
   for (int i = 0; i < iNumProc; ++i)
   {
       // First, get a handle to the process
       HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pidList[i]);
       if (processHandle)
       {
           // Get modules loaded by process
           int maxModules = 1000;
           HMODULE* hMod = 0;
           while (1)
           {
               hMod = new HMODULE[maxModules];
               // Determine number of modules
               if (!lpfEnumProcessModules(processHandle, hMod, maxModules*sizeof(HMODULE), &iCbneeded))
               {
                   DWORD err = GetLastError();
                   if (err = ERROR_PARTIAL_COPY)
                   {
                       // This means that we are looking at the SYSTEM process. Skip it.
                       delete[] hMod;
                       hMod = 0;
                       break;
                   }
               }
               else if (iCbneeded <= maxModules*sizeof(HMODULE))
                   break;
               delete[] hMod;
               if (maxModules > 50000)
               {
                   DBG("maxModules: " << maxModules);
                   return false; // This is getting ridiculous...
               }
           }
           if (!hMod)
               continue;
           // Explorer?
           TCHAR executableName[MAX_PATH];
           if (!lpfGetModuleBaseName(processHandle, hMod[0], executableName, MAX_PATH))
           {
               DBG("GetModuleBaseName failed for process " << pidList[i]);
               return false;
           }
           //DBG("PROCESS " << wxAscii(executableName));
           if (!_tcsicmp(executableName, wxT("explorer.exe")))
           {
               // Explorer must always be killed
               processes.push_back(ProcessInfo(pidList[i], executableName, wxT("")));
               continue;
           }
           // Check if any of the modules are our DLL
           int numModules = iCbneeded/sizeof(HMODULE);
           for (int j = 1; j < numModules; ++j)
           {
               TCHAR name[MAX_PATH];
               if (!lpfGetModuleBaseName(processHandle, hMod[j], name, MAX_PATH))
               {
                   DBG("GetModuleBaseName failed for module " << j);
                   return false;
               }
               if (!_tcsicmp(name, wxT("tortoiseshell.dll")) ||
                   !_tcsicmp(name, wxT("tortoiseshell64.dll")))
               {
                   DBG("Process " << pidList[i] << " has " << wxAscii(name) << " loaded");
                   // Yes, this process must be terminated
                   windowTitle.clear();
                   EnumWindows(EnumWindowsCallback, pidList[i]);
                   processes.push_back(ProcessInfo(pidList[i], executableName, windowTitle));
               }
           }
           delete[] hMod;
           CloseHandle(processHandle);
       }
   }
   FreeLibrary(hInstLib);
   DBG("GetProcesses SUCCESS");
   return true;
}
Пример #25
0
void RadarCanvas::OnMove(wxMoveEvent &evt) {
  wxPoint pos = m_parent->GetPosition();
  LOG_DIALOG(wxT("BR24radar_pi: %s move OpenGL canvas to %d, %d"), m_ri->m_name.c_str(), pos.x, pos.y);
}
Пример #26
0
int SetupHelperApp::OnRun()
{
#ifdef _WIN64
    DBG("--- x64 SetupHelper");
#else
    DBG("--- x86 SetupHelper");
#endif
    
    if (__argc < 3)
        return -1;

    std::vector<ProcessInfo> processes;
    DBG("Get processes (1)"); 
    if (!GetProcesses(processes))
        return -1;
    DBG("Got processes (1):");
    for (size_t i = 0; i < processes.size(); ++i)
    {
        DBG(i << ": " << processes[i].pid);
    }

    // Kill all Explorer and cvslock processes
    
    for (size_t i = 0; i < processes.size(); ++i)
    {
        if (!_tcsicmp(processes[i].image.c_str(), wxT("explorer.exe")))
        {
            DBG("Killing Explorer");
            // Show dialog
            wxProgressDialog* dlg = new wxProgressDialog(wxT("TortoiseCVS Setup"), wxText(__argv[1]));
            dlg->Show();
            // Kill Explorer
            TerminateProcess(processes[i]);
            int i = 0;
            while (IsProcessRunning(processes[i].pid) && (i < 50))
            {
                dlg->Update((i+1)*100/50);
                Sleep(50);
            }
            
            // Avoid the Active Desktop error message
            HKEY hKey;
            if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
                              0, KEY_WRITE, &hKey))
            {
                DWORD data = 0;
                RegSetValueExA(hKey, "FaultKey", 0, REG_DWORD, reinterpret_cast<BYTE*>(&data), sizeof(DWORD));
            }

            dlg->Destroy();
        }
        else if (!_tcsicmp(processes[i].image.c_str(), wxT("cvslock.exe")))
        {
            // Kill CVSNT lock service
            TerminateProcess(processes[i]);
        }
    }

    // Show dialog
    wxProgressDialog* dlg = new wxProgressDialog(wxT("TortoiseCVS Setup"), wxText(__argv[1]));
    dlg->Show();

    // Wait for Explorer restart
    for (int i = 0; i < 50; ++i)
    {
       if (IsExplorerRunning())
          break;
       dlg->Update((i+1)*100/50);
       Sleep(50);
    }
    if (!IsExplorerRunning())
    {
       dlg->Update(0);
       STARTUPINFOA startupinfo;
       startupinfo.cb = sizeof(STARTUPINFOA);
       startupinfo.lpReserved = 0;
       startupinfo.lpDesktop = 0;
       startupinfo.lpTitle = 0;
       startupinfo.dwFlags = 0;
       startupinfo.cbReserved2 = 0;
       startupinfo.lpReserved2 = 0;
       PROCESS_INFORMATION processinfo;
       CreateProcessA(0, "explorer.exe", 0, 0, FALSE, 0, 0, 0, &startupinfo, &processinfo);
       CloseHandle(processinfo.hProcess);
       CloseHandle(processinfo.hThread);
       for (int i = 0; i < 10; ++i)
       {
          Sleep(50);
          dlg->Update((i+1)*100/10);
       }
    }
    dlg->Destroy();
    
    DBG("Check remaining processes");
    bool anyLeft = true;
    while (anyLeft)
    {
        processes.clear();
        DBG("Get processes (2)");
        if (!GetProcesses(processes))
            return -1;
        DBG("Got processes (2):");
        for (size_t i = 0; i < processes.size(); ++i)
        {
            DBG(i << ": " << processes[i].pid);
        }
        
        anyLeft = false;
        for (size_t i = 0; i < processes.size(); ++i)
        {
            if (_tcsicmp(processes[i].image.c_str(), wxT("explorer.exe")))
            {
                anyLeft = true;
                // Ask user to close application
                wxString msg;
                msg << wxT("The application ");
                if (processes[i].title.empty())
                {
                    // No title found (may be minimized to tray etc.)
                    msg << processes[i].image;
                }
                else
                    msg << wxT("'") << processes[i].title << wxT("' (") << processes[i].image << wxT(")");
                msg << wxT("\nneeds to be closed before TortoiseCVS setup can continue.\n")
                    << wxT("Please close the application and click OK, or click Cancel to leave the process ")
                    << wxT("running.\nIn the latter case, you will be required to reboot Windows after installation.");
                if (MessageBox(0, msg.c_str(), wxT("TortoiseCVS Setup"), MB_OKCANCEL | MB_ICONINFORMATION) == IDCANCEL)
                    return 1;
            }
        }
    }

    DBG("Loop done");

    if (__argv[2][0] == 'b')
        return 0;

    // Delete any renamed DLL's
    // TODO: Make this work even when installing to a different directory
    std::string rootDir(GetRootDir());
    std::string src(rootDir);
    src += "TortoiseShell.dll_renamed";
    DBG("Deleting " << src);
    DeleteFileA(src.c_str());
    src = rootDir;
    src += "TortoiseShell64.dll_renamed";
    DBG("Deleting " << src);
    DeleteFileA(src.c_str());
    src = rootDir;
    src += "TortoiseAct.exe_renamed";
    DBG("Deleting " << src);
    DeleteFileA(src.c_str());

    DBG("Exit: 0");
    return 0;
}
Пример #27
0
void ItemContainerWidgetsPage::StartTest(const wxString& label)
{
    m_container->Clear();
    wxLogMessage(wxT("Test - %s:"), label.c_str());
}
Пример #28
0
#ifdef __BORLANDC__
    #pragma hdrstop
#endif

// for all others, include the necessary headers
#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif

#include "wx/wfstream.h"

#include "bstream.h"

#define DATABUFFER_SIZE     1024

static const wxString FILENAME_FFILEINSTREAM = wxT("ffileinstream.test");
static const wxString FILENAME_FFILEOUTSTREAM = wxT("ffileoutstream.test");

///////////////////////////////////////////////////////////////////////////////
// The test case
//
// Try to fully test wxFFileInputStream and wxFFileOutputStream

class ffileStream : public BaseStreamTestCase<wxFFileInputStream, wxFFileOutputStream>
{
public:
    ffileStream();
    virtual ~ffileStream();

    CPPUNIT_TEST_SUITE(ffileStream);
        // Base class stream tests the ffileStream supports.
Пример #29
0
MyDialog::MyDialog( wxWindow *parent, const wxString& title,
                    const wxPoint& pos, const wxSize& size, const long WXUNUSED(style) ) :
    wxDialog(parent, VALIDATE_DIALOG_ID, title, pos, size, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
{
    // setup the flex grid sizer
    // -------------------------

    wxFlexGridSizer *flexgridsizer = new wxFlexGridSizer(3, 2, 5, 5);

    // Create and add controls to sizers. Note that a member variable
    // of g_data is bound to each control upon construction. There is
    // currently no easy way to substitute a different validator or a
    // different transfer variable after a control has been constructed.

    // Pointers to some of these controls are saved in member variables
    // so that we can use them elsewhere, like this one.
    m_text = new wxTextCtrl(this, VALIDATE_TEXT, wxEmptyString,
                            wxDefaultPosition, wxDefaultSize, 0,
                            wxTextValidator(wxFILTER_ALPHA, &g_data.m_string));
    m_text->SetToolTip("uses wxTextValidator with wxFILTER_ALPHA");
    flexgridsizer->Add(m_text, 1, wxGROW);


    // Now set a wxTextValidator with an explicit list of characters NOT allowed:
    wxTextValidator textVal(wxFILTER_EMPTY|wxFILTER_EXCLUDE_LIST, &g_data.m_string2);
    textVal.SetCharExcludes("bcwyz");
    wxTextCtrl* txt2 =
             new wxTextCtrl(this, VALIDATE_TEXT2, wxEmptyString,
                            wxDefaultPosition, wxDefaultSize, 0, textVal);
    txt2->SetToolTip("uses wxTextValidator with wxFILTER_EMPTY|wxFILTER_EXCLUDE_LIST (to exclude 'bcwyz')");
    flexgridsizer->Add(txt2, 1, wxGROW);

    flexgridsizer->Add(new wxListBox((wxWindow*)this, VALIDATE_LIST,
                        wxDefaultPosition, wxDefaultSize,
                        3, g_listbox_choices, wxLB_MULTIPLE,
                        wxGenericValidator(&g_data.m_listbox_choices)),
                       1, wxGROW);

    m_combobox = new wxComboBox(this, VALIDATE_COMBO, wxEmptyString,
                                wxDefaultPosition, wxDefaultSize,
                                3, g_combobox_choices, 0L,
                                MyComboBoxValidator(&g_data.m_combobox_choice));
    m_combobox->SetToolTip("uses a custom validator (MyComboBoxValidator)");
    flexgridsizer->Add(m_combobox, 1, wxALIGN_CENTER);

    // This wxCheckBox* doesn't need to be assigned to any pointer
    // because we don't use it elsewhere--it can be anonymous.
    // We don't need any such pointer to query its state, which
    // can be gotten directly from g_data.
    flexgridsizer->Add(new wxCheckBox(this, VALIDATE_CHECK, wxT("Sample checkbox"),
                        wxDefaultPosition, wxDefaultSize, 0,
                        wxGenericValidator(&g_data.m_checkbox_state)),
                       1, wxALIGN_CENTER|wxALL, 15);

    flexgridsizer->AddGrowableCol(0);
    flexgridsizer->AddGrowableCol(1);
    flexgridsizer->AddGrowableRow(1);


    // setup the button sizer
    // ----------------------

    wxStdDialogButtonSizer *btn = new wxStdDialogButtonSizer();
    btn->AddButton(new wxButton(this, wxID_OK));
    btn->AddButton(new wxButton(this, wxID_CANCEL));
    btn->Realize();

    // setup a sizer with the controls for numeric validators
    // ------------------------------------------------------

    wxIntegerValidator<int> valInt(&g_data.m_intValue,
                                   wxNUM_VAL_THOUSANDS_SEPARATOR |
                                   wxNUM_VAL_ZERO_AS_BLANK);
    valInt.SetMin(0); // Only allow positive numbers

    m_numericTextInt = new wxTextCtrl
                           (
                                this,
                                wxID_ANY,
                                "",
                                wxDefaultPosition,
                                wxDefaultSize,
                                wxTE_RIGHT,
                                valInt
                            );
    m_numericTextInt->SetToolTip("uses wxIntegerValidator to accept positive "
                                 "integers only");

    m_numericTextDouble = new wxTextCtrl
                              (
                                this,
                                wxID_ANY,
                                "",
                                wxDefaultPosition,
                                wxDefaultSize,
                                wxTE_RIGHT,
                                wxMakeFloatingPointValidator
                                (
                                    3,
                                    &g_data.m_doubleValue,
                                    wxNUM_VAL_THOUSANDS_SEPARATOR |
                                    wxNUM_VAL_NO_TRAILING_ZEROES
                                )
                              );
    m_numericTextDouble->SetToolTip("uses wxFloatingPointValidator with 3 decimals");
    wxBoxSizer *numSizer = new wxBoxSizer( wxHORIZONTAL );
    numSizer->Add( m_numericTextInt, 1, wxALL, 10 );
    numSizer->Add( m_numericTextDouble, 1, wxALL, 10 );



    // setup the main sizer
    // --------------------

    wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL );

    mainsizer->Add(flexgridsizer, 1, wxGROW | wxALL, 10);

    mainsizer->Add(new wxRadioBox((wxWindow*)this, VALIDATE_RADIO, wxT("Pick a color"),
                                    wxDefaultPosition, wxDefaultSize,
                                    3, g_radiobox_choices, 1, wxRA_SPECIFY_ROWS,
                                    wxGenericValidator(&g_data.m_radiobox_choice)),
                   0, wxGROW | wxLEFT|wxBOTTOM|wxRIGHT, 10);

    mainsizer->Add( numSizer, 0, wxGROW | wxALL );

    mainsizer->Add(btn, 0, wxGROW | wxALL, 10);

    SetSizer(mainsizer);
    mainsizer->SetSizeHints(this);

    // make the dialog a bit bigger than its minimal size:
    SetSize(GetBestSize()*1.5);
}
Пример #30
0
void DeviceToolBar::FillHostDevices()
{
   const std::vector<DeviceSourceMap> &inMaps  = DeviceManager::Instance()->GetInputDeviceMaps();
   const std::vector<DeviceSourceMap> &outMaps = DeviceManager::Instance()->GetOutputDeviceMaps();

   //read what is in the prefs
   wxString host = gPrefs->Read(wxT("/AudioIO/Host"), wxT(""));
   size_t i;
   int foundHostIndex = -1;

   // if the host is not in the hosts combo then we rescanned.
   // set it to blank so we search for another host.
   if (mHost->FindString(host) == wxNOT_FOUND)
      host = wxT("");

   for (i = 0; i < outMaps.size(); i++) {
      if (outMaps[i].hostString == host) {
         foundHostIndex = outMaps[i].hostIndex;
         break;
      }
   }

   if (foundHostIndex == -1) {
      for (i = 0; i < inMaps.size(); i++) {
         if (inMaps[i].hostString == host) {
            foundHostIndex = inMaps[i].hostIndex;
            break;
         }
      }
   }

   // If no host was found based on the prefs device host, load the first available one
   if (foundHostIndex == -1) {
      if (outMaps.size())
         foundHostIndex = outMaps[0].hostIndex;
      else if (inMaps.size())
         foundHostIndex = inMaps[0].hostIndex;
   }

   // Make sure in/out are clear in case no host was found
   mInput->Clear();
   mOutput->Clear();

   // If we still have no host it means no devices, in which case do nothing.
   if (foundHostIndex == -1)
      return;

   // Repopulate the Input/Output device list available to the user
   for (i = 0; i < inMaps.size(); i++) {
      if (foundHostIndex == inMaps[i].hostIndex) {
         mInput->Append(MakeDeviceSourceString(&inMaps[i]));
         if (host == wxT("")) {
            host = inMaps[i].hostString;
            gPrefs->Write(wxT("/AudioIO/Host"), host);
            mHost->SetStringSelection(host);
         }
      }
   }
   mInput->Enable(mInput->GetCount() ? true : false);

   mInput->InvalidateBestSize();
   mInput->SetMaxSize(mInput->GetBestSize());

   for (i = 0; i < outMaps.size(); i++) {
      if (foundHostIndex == outMaps[i].hostIndex) {
         mOutput->Append(MakeDeviceSourceString(&outMaps[i]));
         if (host == wxT("")) {
            host = outMaps[i].hostString;
            gPrefs->Write(wxT("/AudioIO/Host"), host);
            gPrefs->Flush();
            mHost->SetStringSelection(host);
         }
      }
   }
   mOutput->Enable(mOutput->GetCount() ? true : false);

   mOutput->InvalidateBestSize();
   mOutput->SetMaxSize(mOutput->GetBestSize());

   // The setting of the Device is left up to OnChoice
}