Example #1
0
bool wxToolBar::DeleteTool(
  int                               nId
)
{
    bool                            bOk = wxToolBarBase::DeleteTool(nId);

    if (bOk)
    {
        Realize();
    }
    return bOk;
} // end of wxToolBar::DeleteTool
Example #2
0
bool wxToolBar::DeleteToolByPos(
  size_t                            nPos
)
{
    bool                            bOk = wxToolBarBase::DeleteToolByPos(nPos);

    if (bOk)
    {
        Realize();
    }
    return bOk;
} // end of wxToolBar::DeleteTool
Example #3
0
wxToolBarToolBase* wxToolBar::InsertSeparator(
  size_t                            nPos
)
{
    wxToolBarToolBase*              pTool = wxToolBarBase::InsertSeparator(nPos);

    if (m_bInitialized)
    {
        Realize();
        Refresh();
    }
    return pTool;
} // end of wxToolBar::InsertSeparator
Example #4
0
	void SelectItem(wxAuiToolBarItem* item)
	{
		Realize();

		// Simulate click event so tool gets properly selected.
		wxRect itemRect = item->GetSizerItem()->GetRect();
		
		wxMouseEvent e;
		e.SetPosition(itemRect.GetPosition());

		wxAuiToolBar::OnLeftDown(e);
		wxAuiToolBar::OnLeftUp(e);
	}
Example #5
0
void wxRibbonButtonBar::ClearButtons()
{
    m_layouts_valid = false;
    size_t count = m_buttons.GetCount();
    size_t i;
    for(i = 0; i < count; ++i)
    {
        wxRibbonButtonBarButtonBase* button = m_buttons.Item(i);
        delete button;
    }
    m_buttons.Clear();
    Realize();
}
Example #6
0
void SjCoverBrowser::OnDropImage(SjDataObject* data, int mouseX, int mouseY)
{
	SjCol* cover;
	long found = FindCover(mouseX, mouseY, &cover);
	if( found == FOUND_COVER && cover->m_rowCount > 0 )
	{
		if( cover->m_rows[0]->OnDropData(data) )
		{
			Realize(false, true /*keep col index*/);
			m_window->Refresh();
			m_window->Update();
		}
	}
}
Example #7
0
MyToolBar1::MyToolBar1( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxToolBar( parent, id, pos, size, style )
{
	ComposeNew = new wxStaticText( this, wxID_ANY, wxT("Compose New  "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
	ComposeNew->Wrap( -1 );
	AddControl( ComposeNew ); 
	wxString MessageTypeChoices[] = { wxT("Letter") };
	int MessageTypeNChoices = sizeof( MessageTypeChoices ) / sizeof( wxString );
	MessageType = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, MessageTypeNChoices, MessageTypeChoices, 0 );
	MessageType->SetSelection( 0 );
	MessageType->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
	AddControl( MessageType );
	
	Realize();
}
Example #8
0
wxToolBarToolBase* wxToolBar::InsertControl(
  size_t                            nPos
, wxControl*                        pControl
)
{
    wxToolBarToolBase*              pTool = wxToolBarBase::InsertControl( nPos
                                                                         ,pControl
                                                                        );
    if (m_bInitialized)
    {
        Realize();
        Refresh();
    }
    return pTool;
} // end of wxToolBar::InsertControl
Example #9
0
void wxGISToolBar::AddCommand(ICommand* pCmd)
{
	switch(pCmd->GetKind())
	{
	case enumGISCommandMenu:
		return;
	case enumGISCommandSeparator:
	case enumGISCommandCheck:
	case enumGISCommandRadio:
	case enumGISCommandNormal:
		{
		wxBitmap Bitmap = pCmd->GetBitmap();
		if(!Bitmap.IsOk())
			Bitmap = wxBitmap(default_16_xpm);

		AddTool(pCmd->GetID(), wxStripMenuCodes(pCmd->GetCaption()), Bitmap, wxBitmap(), (wxItemKind)pCmd->GetKind(), pCmd->GetTooltip(), pCmd->GetMessage(), NULL);
		}
		break;
	case enumGISCommandControl:
		{
			IToolControl* pToolCtrl = dynamic_cast<IToolControl*>(pCmd);
			if(pToolCtrl)
			{
				IToolBarControl* pToolBarControl = pToolCtrl->GetControl();
				wxControl* pControl = dynamic_cast<wxControl*>(pToolBarControl);
				if(pControl)
				{
					if(pToolCtrl->HasToolLabel())
					{
						wxString sToolLabel = pToolCtrl->GetToolLabel();
						AddLabel(wxID_ANY, sToolLabel, sToolLabel.Len() * 5);
					}
					pControl->Reparent(this);
					AddControl(pControl);
					//add ctrl to remove map
					m_RemControlMap[m_CommandArray.size()] = pToolBarControl;
				}
				else return;
			}
			else return;
		}
		break;
	default: return;
	}
	wxGISCommandBar::AddCommand(pCmd);
	Realize();
}
Example #10
0
void CToolBar::MakeDropdownTool(int id)
{
	wxToolBarToolBase* pOldTool = FindById(id);
	if (!pOldTool)
		return;

	wxToolBarToolBase* pTool = new wxToolBarToolBase(0, id,
		pOldTool->GetLabel(), pOldTool->GetNormalBitmap(), pOldTool->GetDisabledBitmap(),
		wxITEM_DROPDOWN, NULL, pOldTool->GetShortHelp(), pOldTool->GetLongHelp());

	int pos = GetToolPos(id);
	wxASSERT(pos != wxNOT_FOUND);

	DeleteToolByPos(pos);
	InsertTool(pos, pTool);
	Realize();
}
Example #11
0
HRPosToolBar::HRPosToolBar(wxWindow *parent)
: wxToolBar(parent, wxID_ANY, wxPoint(20,20)/*DefaultPosition*/,
	wxSize(parent->GetSize().GetWidth(), 30), wxBORDER_NONE|wxTB_HORIZONTAL|wxTB_NODIVIDER|wxTB_FLAT|wxTB_TEXT|wxTAB_TRAVERSAL )
{
  try
  {
	SetToolBitmapSize(wxSize(30, 30));
	AddTool(1, local->get("HR_f", "add_pos", "Add"), HR_tool(2));  //BITMAP_TYPE_BMP
	AddTool(3, local->get("HR_f", "edit_pos", "Edit"), HR_tool(1));  //BITMAP_TYPE_BMP
	AddTool(2, local->get("HR_f", "del_pos", "Delete"), HR_tool(0));

	AddSeparator();
	
	if (!(users->user().administrator())) 
	{
		EnableTool(1, false);
		EnableTool(2, false);
		EnableTool(3, false);
	}

	if (!positionrole->loaded()) positionrole->load_positionrole();
	wxString pposition [1000];
	for ( int i=0; i< positionrole->size(); i++) pposition[i] = to_uc(positionrole->get_name(i));
	lb_position = new HRListBox(parent, positionrole->size(), pposition);
	wxCommandEvent evt = wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED, 0);  
	lb_position->OnClickPos(evt);
	lb_position->Select(0);
	pos = 0;

	Realize();
  }
  catch(exception_t &e)
  {
	wxMessageBox(to_uc(e.message()));
  }
  catch(std::exception &e)
  {
	wxMessageBox(to_uc(e.what()));
  }
  catch(...)
  {
	exception_t e(5022, "unexpected error", "HRPosToolBar::HRPosToolBar");
	wxMessageBox(to_uc(e.message()));
  }
}
Example #12
0
void wxRibbonToolBar::SetRows(int nMin, int nMax)
{
    if(nMax == -1)
        nMax = nMin;

    wxASSERT(1 <= nMin);
    wxASSERT(nMin <= nMax);

    m_nrows_min = nMin;
    m_nrows_max = nMax;

    delete[] m_sizes;
    m_sizes = new wxSize[m_nrows_max - m_nrows_min + 1];
    for(int i = m_nrows_min; i <= m_nrows_max; ++i)
        m_sizes[i - m_nrows_min] = wxSize(0, 0);

    Realize();
}
Example #13
0
bool wxRibbonButtonBar::DeleteButton(int button_id)
{
    size_t count = m_buttons.GetCount();
    size_t i;
    for(i = 0; i < count; ++i)
    {
        wxRibbonButtonBarButtonBase* button = m_buttons.Item(i);
        if(button->id == button_id)
        {
            m_layouts_valid = false;
            m_buttons.RemoveAt(i);
            Realize();
            Refresh();
            return true;
        }
    }
    return false;
}
Example #14
0
void wxMainToolBar::InitToolBar()
{
   // set up the toolbar controls
   int ipos = 0;
   if(m_first_dpos == 0) {
      ipos += InsertObject(ipos);
      ipos += InsertType(ipos);
      ipos += InsertBin(ipos); // we need to be able to set binning always
      m_first_dpos = ipos;
   }

   if(m_first_dpos > 0) {
      int ntools = GetToolsCount();
      size_t max_pos = ntools-1;

      // Delete the camera dependent tools
      for(size_t ipos=max_pos; ipos>m_first_dpos; ipos--) {
         DeleteToolByPos(ipos);
      }

      // clear references to the deleted tools
      m_zoomSpin = 0;
      m_temp_text = 0;
   }

   wxCamera* camera = wxF()->cam();
   if(camera && camera->IsArtcam()) {
      ipos = m_first_dpos;
      ipos += InsertZoom(ipos);
      ipos += InsertSubframe(ipos);
      ipos += InsertRestartExposure(ipos);
      ipos += InsertCooling(ipos);
   }
   //20080525:BM try to support more webcam
   else if(camera && camera->IsWebcam()) {
      ipos = m_first_dpos;
      ipos += InsertZoom(ipos);
      ipos += InsertSubframe(ipos);
   }

	Realize();

	CamEnable();
}
Example #15
0
wxMailboxToolBar::wxMailboxToolBar(wxWindow *parent, wxWindowID id)
 : wxToolBar(parent, id, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL | wxNO_BORDER | wxTB_TEXT)
{
	AddTool(0, _("Get Mail"), getIcon(_("mail_get"), 32));
	AddSeparator();AddSeparator();AddSeparator();

	AddTool(0, _("Delete"), getIcon(_("mail_delete"), 32));
	AddTool(0, _("Junk"), getIcon(_("anti_spam"), 32));
	AddSeparator();AddSeparator();AddSeparator();

	AddTool(0, _("Reply"), getIcon(_("mail_reply"), 32));
	AddTool(0, _("Reply All"), getIcon(_("mail_replyall"), 32));
	AddTool(0, _("Forward"), getIcon(_("mail_forward"), 32));
	AddSeparator();AddSeparator();AddSeparator();

	AddTool(0, _("Write"), getIcon(_("mail_new"), 32));

	Realize();
}
Example #16
0
bool CToolBar::ShowTool(int id)
{
	int offset = 0;

	for (auto iter = m_hidden_tools.begin(); iter != m_hidden_tools.end(); ++iter) {
		if (iter->second->GetId() != id) {
			offset++;
			continue;
		}

		InsertTool(iter->first - offset, iter->second);
		Realize();
		m_hidden_tools.erase(iter);

		return true;
	}

	return false;
}
Example #17
0
void wxRibbonBar::ClearPages()
{
    size_t i;
    for(i=0; i<m_pages.GetCount(); i++)
    {
        wxRibbonPage *page = m_pages.Item(i).page;
        // Schedule page object for destruction and not destroying directly
        // as this function can be called in an event handler and page functions
        // can be called afeter removing.
        // Like in wxRibbonButtonBar::OnMouseUp
        if(!wxTheApp->IsScheduledForDestruction(page))
        {
            wxTheApp->ScheduleForDestruction(page);
        }
    }
    m_pages.Empty();
    Realize();
    m_current_page = -1;
    Refresh();
}
Example #18
0
int wxMainToolBar::InsertZoom(int pos)
{
	wxStaticText* tool_text = new wxStaticText(this, wxNewId(), _("Zoom"), wxDefaultPosition, wxDefaultSize, 0);
  	m_zoomSpin = new wxSpinCtrlDbl(this, ID_ZOOM_SPIN, _T("1.0"), wxDefaultPosition,wxSize(60,-1), 0, 0, 100, 0, _("Zoom"));

   m_zoomSpin->SetRange(0.01,5.0);
   m_zoomSpin->SetValue(1.0);
   m_zoomSpin->SetIncrement(0.1);
   m_zoomSpin->SetFormat(_T("%.3lf"));

   int ipos = pos;

   // Separator, leading text + spinctrl
   InsertSeparator(ipos++);
   InsertControl(ipos++,tool_text);
   InsertControl(ipos++,m_zoomSpin);
   InsertTool(ipos++,ID_UNZOOM, _("Undo Zoom"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_UNDO")),wxART_TOOLBAR,wxSize(15,16)), wxNullBitmap, wxITEM_NORMAL, _("Undo Zoom"), wxEmptyString);
   SetToolShortHelp(ID_ZOOM_SPIN,_("Zoom factor"));
   Realize();

   return (ipos-pos);
}
Example #19
0
// This code originally came from GIMP -- gimppalette-import.c
// I don't think they'd recognize it anymore.
wxString thPaletteData::Import(wxString filename)
{
    int         number_of_colors;
    int         i, j;
    /*Maximum valid file size: 256 * 4 * 3 + 256 * 2  ~= 3650 bytes */
    wxString    msg;
    wxTextFile  lines(filename);
    int         color_ints[3];

    lines.Open();
    if (lines[0] != _T("JASC-PAL")) // signature
        return _T("First line should be \"JASC-PAL\".");
    if (lines[1] != _T("0100")) // version
        return _T("Second line should be \"0100\".");

    number_of_colors = _tstoi(lines[2]);
    wxStringTokenizer st;

    for (i = 0; i < number_of_colors; i++)
    {
        const int line = i + 3;
        if (line >= (int)lines.GetLineCount())
            return wxString::Format(_T("File too short.  Expected %d more colors."), number_of_colors - i);

        st.SetString(lines[line]);
        if (st.CountTokens() != 3)
            return _T("Corrupted palette file.");

        for (j = 0; j < 3; j++)
        {
           color_ints[j] = _tstoi(st.GetNextToken());
           if (color_ints[j] < 0 || color_ints[j] > 255)
               return _T("Corrupted palette file.");
        }
        Add(i, RGB(color_ints[0], color_ints[2], color_ints[2]));
    }
    Realize();
    return wxEmptyString;
}
Example #20
0
int wxMainToolBar::InsertBin(int pos)
{
	wxStaticText* tool_text = new wxStaticText(this, wxNewId(), _("Bin"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
   m_binChoice = new wxChoice(this, ID_BIN_CHOICE, wxDefaultPosition, wxSize(60,-1), 0, 0, 0, wxDefaultValidator, _T("Binning"));
   m_binChoice->Append(_("1:1"));
   m_binChoice->Append(_("2:2"));
   m_binChoice->Append(_("3:3"));
   m_binChoice->Append(_("4:4"));
   m_binChoice->Append(_("5:5"));
   m_binChoice->Append(_("6:6"));
   m_binChoice->SetSelection(wxArtcam::DefaultBinning()-1);

   int ipos = pos;

   // Separator, leading text + binning choice box
   InsertSeparator(ipos++);
   InsertControl(ipos++,tool_text);
   InsertControl(ipos++,m_binChoice);
   SetToolShortHelp(ID_BIN_CHOICE,_("Binning level"));
   Realize();

   return (ipos-pos);
}
Example #21
0
void wxMainToolBar::UpdateTemp()
{
   if(m_temp_text) {
      if(wxCamera* camera = wxF()->cam()) {
         if(camera->HasCooling()) {
            bool do_realize = false;

            // update the temperature text if changed
            wxString temp_txt =  wxString::Format(_T("%5.1lf")+Celsius,camera->Temperature() );
            wxString cur_txt = m_temp_text->GetLabel();
            if(temp_txt != cur_txt) {
               m_temp_text->SetLabel(temp_txt);
               do_realize = true;
            }

            // update the temperature button icon if status has changed
            const char** bitmap = 0;
            ECoolingStatus cstat = camera->CoolingStatus();
            if(m_cstat != cstat) {
               switch(cstat) {
                  case ECS_Off:     { bitmap = &temp_red_15x16_xpm[0]; break; }
                  case ECS_Cooling: { bitmap = &temp_yellow_15x16_xpm[0];  break; } // Red means target not reached
                  case ECS_Holding: { bitmap = &temp_blue_15x16_xpm[0];  break; }   // Blue
                  case ECS_Warmup:  { bitmap = &heat_15x16_xpm[0];      break; }
                  default:          { bitmap = &temp_red_15x16_xpm[0];        }     // Red (should not happen..)
               };
               SetToolNormalBitmap(ID_SET_TEMP,wxBitmap(bitmap));
               m_cstat = cstat;
               do_realize = true;
            }

            if(do_realize)Realize();
         }
      }
   }
}
void MainToolBar::set_properties()
{
#ifdef __WXMAC__
	SetToolBitmapSize(wxSize(96, 24));
    AddTool(IDM_MENU, wxT("Menu"), wxBitmap(menu_xpm), wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
	AddSeparator();
    AddTool(IDM_SHOW_DESK, wxT("Desk"), wxBitmap(desk_xpm), wxNullBitmap, wxITEM_RADIO, wxT(""), wxT(""));
    AddTool(IDM_SHOW_DESK_SETUP, wxT("Desk Setup"), wxBitmap(desk_setup_xpm), wxNullBitmap, wxITEM_RADIO, wxT(""), wxT(""));
    AddTool(IDM_SHOW_FUNCTION_SETUP, wxT("Function Setup"), wxBitmap(function_setup_xpm), wxNullBitmap, wxITEM_RADIO, wxT(""), wxT(""));
    AddSeparator();
    AddTool(IDM_IO_SETUP, wxT("IO Setup"), wxBitmap(io_setup_xpm), wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
    AddTool(IDM_GROUP_SETUP, wxT("Group Setup"), wxBitmap(group_setup_xpm), wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
    AddTool(IDM_CHANNEL_SETUP, wxT("Channel Setup"), wxBitmap(channel_setup_xpm), wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
    AddTool(IDM_LIBRARY, wxT("Library"), wxBitmap(library_xpm), wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
    AddTool(IDM_DMX_PATCH, wxT("DMX Patch"), wxBitmap(dmx_patch_xpm), wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
    AddSeparator();
    AddTool(IDM_SETUP_OUTPUT, wxT("Setup Output"), wxBitmap(setup_output_xpm), wxNullBitmap, wxITEM_CHECK, wxT(""), wxT(""));
#else
 	SetToolBitmapSize(wxSize(0, 0));
    AddTool(IDM_MENU, wxT("Menu"), wxNullBitmap, wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
	AddSeparator();
    AddTool(IDM_SHOW_DESK, wxT("Desk"), wxNullBitmap, wxNullBitmap, wxITEM_RADIO, wxT(""), wxT(""));
    AddTool(IDM_SHOW_DESK_SETUP, wxT("Desk Setup"), wxNullBitmap, wxNullBitmap, wxITEM_RADIO, wxT(""), wxT(""));
    AddTool(IDM_SHOW_FUNCTION_SETUP, wxT("Function Setup"), wxNullBitmap, wxNullBitmap, wxITEM_RADIO, wxT(""), wxT(""));
    AddSeparator();
    AddTool(IDM_IO_SETUP, wxT("IO Setup"), wxNullBitmap, wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
    AddTool(IDM_GROUP_SETUP, wxT("Group Setup"), wxNullBitmap, wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
    AddTool(IDM_CHANNEL_SETUP, wxT("Channel Setup"), wxNullBitmap, wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
    AddTool(IDM_LIBRARY, wxT("Library"), wxNullBitmap, wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
    AddTool(IDM_DMX_PATCH, wxT("DMX Patch"), wxNullBitmap, wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
    AddSeparator();
    AddTool(IDM_SETUP_OUTPUT, wxT("Setup Output"), wxNullBitmap, wxNullBitmap, wxITEM_CHECK, wxT(""), wxT(""));
#endif
	
    Realize();
}
Example #23
0
void wxExOptionsToolBar::AddControls(bool realize)
{
  const wxWindowID ID_VIEW_PROCESS = NewControlId();
  
  // 0   1      2     3       4        5
  // id, label, name, config, tooltip, default
  for (const auto& it : std::vector<std::tuple<int, wxString, wxString, wxString, wxString, bool>> {
    std::make_tuple(ID_VIEW_PROCESS, _("Process"), "PROCESS", "ViewProcess", _("View process"), false),
    std::make_tuple(NewControlId(), "Hex", "HEX", "HexMode", _("Open in hex mode"), false),
    std::make_tuple(NewControlId(), "Sync", "SYNC", "AllowSync", _("Synchronize modified files"), true)})
  {
    if (std::get<0>(it) == ID_VIEW_PROCESS && wxExProcess::GetShell() == nullptr)
    {
      continue;
    }
    
    wxCheckBox* cb = new wxCheckBox(this, std::get<0>(it), std::get<1>(it));
    m_CheckBoxes.emplace_back(cb);
#if wxUSE_TOOLTIPS
    cb->SetToolTip(std::get<4>(it));
#endif
    cb->SetValue(wxConfigBase::Get()->ReadBool(std::get<3>(it), std::get<5>(it)));
    cb->SetName(std::get<2>(it));
    AddControl(cb);
    Bind(wxEVT_CHECKBOX, [=](wxCommandEvent& event) {
      wxConfigBase::Get()->Write(std::get<3>(it), cb->GetValue());
      if (event.GetId() == ID_VIEW_PROCESS)
      {
        GetFrame()->ShowPane("PROCESS", cb->GetValue());};}, std::get<0>(it));
  }

  if (realize)
  {
    Realize();
  }
}
Example #24
0
/*
** At startup we create a physical heap; while this is fine, the idea
** of protection is closely tied to that of stretches. Hence this function
**   (a) 'frees' the memory underneath the heap, and
**   (b) allocates it again through the stretch allocator.
** This allows us to map it read/write for us, and read-only to everyone else.
*/
void MapInitialHeap(HeapMod_clp hmod, Heap_clp heap, Frames_clp frames, 
		    word_t heap_size, ProtectionDomain_ID pdom)
{
    Stretch_clp str;
    Heap_cl *realheap; 
    addr_t a;

    a = (addr_t)((size_t)heap & ~(FRAME_SIZE-1));

    Frames$Free(frames, a, heap_size);
    str = STR_NEW_R(Pvs(salloc), heap_size);
    ASSERT_ADDRESS(str, a);

    realheap = HeapMod$Realize(hmod, heap, str);

    if(realheap != heap) 
	eprintf("WARNING: HeapMod$Realize(%p) => %p\n", 
		heap, realheap);

    
    /* Map our heap as local read/write */
    STR_SETPROT(str, pdom, (SET_ELEM(Stretch_Right_Read)|
			    SET_ELEM(Stretch_Right_Write)));
}
Example #25
0
void wxRibbonButtonBar::SetArtProvider(wxRibbonArtProvider* art)
{
    if(art == m_art)
    {
        return;
    }

    wxRibbonControl::SetArtProvider(art);

    wxClientDC temp_dc(this);
    size_t btn_count = m_buttons.Count();
    size_t btn_i;
    for(btn_i = 0; btn_i < btn_count; ++btn_i)
    {
        wxRibbonButtonBarButtonBase* base = m_buttons.Item(btn_i);

        FetchButtonSizeInfo(base, wxRIBBON_BUTTONBAR_BUTTON_SMALL, temp_dc);
        FetchButtonSizeInfo(base, wxRIBBON_BUTTONBAR_BUTTON_MEDIUM, temp_dc);
        FetchButtonSizeInfo(base, wxRIBBON_BUTTONBAR_BUTTON_LARGE, temp_dc);
    }

    m_layouts_valid = false;
    Realize();
}
/** Draws the Control on the Output Display */
void MapControl::Draw(unsigned short XWin, unsigned short YWin)
{
	if (!Width || !Height) {
		return;
	}
	if (Owner->Visible!=WINDOW_VISIBLE) {
		return;
	}

	if (Changed) {
		Realize();
		Changed = false;
	}

	// we're going to paint over labels/etc, so they need to repaint!
	bool seen_this = false;
	unsigned int i;
	for (i = 0; i < Owner->GetControlCount(); i++) {
		Control *ctrl = Owner->GetControl(i);
		if (!ctrl) continue;

		// we could try working out which controls overlap,
		// but the later controls are cheap to paint..
		if (ctrl == this) { seen_this = true; continue; }
		if (!seen_this) continue;

		ctrl->Changed = true;
	}

	Video* video = core->GetVideoDriver();
	Region r( XWin + XPos, YWin + YPos, Width, Height );

	if (MapMOS) {
		video->BlitSprite( MapMOS, MAP_TO_SCREENX(0), MAP_TO_SCREENY(0), true, &r );
	}

	if (core->FogOfWar&FOG_DRAWFOG)
		DrawFog(XWin, YWin);

	Region vp = video->GetViewport();

	vp.x = GAME_TO_SCREENX(vp.x);
	vp.y = GAME_TO_SCREENY(vp.y);
	vp.w = ViewWidth;
	vp.h = ViewHeight;

	if ((vp.x + vp.w) >= MAP_TO_SCREENX( Width ))
		vp.w = MAP_TO_SCREENX( Width ) - vp.x;
	if ((vp.y + vp.h) >= MAP_TO_SCREENY( Height ))
		vp.h = MAP_TO_SCREENY( Height ) - vp.y;

	video->DrawRect( vp, colors[green], false, false );

	// Draw PCs' ellipses
	Game *game = core->GetGame();
	i = game->GetPartySize(true);
	while (i--) {
		Actor* actor = game->GetPC( i, true );
		if (MyMap->HasActor(actor) ) {
			video->DrawEllipse( (short) GAME_TO_SCREENX(actor->Pos.x), (short) GAME_TO_SCREENY(actor->Pos.y), 3, 2, actor->Selected ? colors[green] : colors[darkgreen], false );
		}
	}
	// Draw Map notes, could be turned off in bg2
	// we use the common control value to handle it, because then we
	// don't need another interface
	if (Value!=MAP_NO_NOTES) {
		i = MyMap -> GetMapNoteCount();
		while (i--) {
			MapNote * mn = MyMap -> GetMapNote(i);
			Sprite2D *anim = Flag[mn->color&7];
			Point pos = mn->Pos;
			if (convertToGame) {
				vp.x = GAME_TO_SCREENX(mn->Pos.x);
				vp.y = GAME_TO_SCREENY(mn->Pos.y);
			} else { //pst style
				vp.x = MAP_TO_SCREENX(mn->Pos.x);
				vp.y = MAP_TO_SCREENY(mn->Pos.y);
				pos.x = pos.x * MAP_MULT / MAP_DIV;
				pos.y = pos.y * MAP_MULT / MAP_DIV;
			}

			//Skip unexplored map notes
			bool visible = MyMap->IsVisible( pos, true );
			if (!visible)
				continue;

			if (anim) {
				video->BlitSprite( anim, vp.x - anim->Width/2, vp.y - anim->Height/2, true, &r );
			} else {
				video->DrawEllipse( (short) vp.x, (short) vp.y, 6, 5, colors[mn->color&7], false );
			}
		}
	}
}
Example #27
0
wxExFindToolBar::wxExFindToolBar(
  wxExManagedFrame* frame,
  wxWindowID id,
  const wxPoint& pos,
  const wxSize& size,
  long style)
  : wxExToolBar(frame, id, pos, size, style)
{
  const wxWindowID ID_MATCH_WHOLE_WORD = NewControlId();
  const wxWindowID ID_MATCH_CASE = NewControlId();
  const wxWindowID ID_REGULAR_EXPRESSION = NewControlId();

  wxExFindTextCtrl* findCtrl = new wxExFindTextCtrl(this, GetFrame());
  wxCheckBox* matchCase = new wxCheckBox(this, 
    ID_MATCH_CASE, wxExFindReplaceData::Get()->GetTextMatchCase());
  wxCheckBox* matchWholeWord = new wxCheckBox(this, 
    ID_MATCH_WHOLE_WORD, wxExFindReplaceData::Get()->GetTextMatchWholeWord());
  wxCheckBox* isRegularExpression = new wxCheckBox(this, 
    ID_REGULAR_EXPRESSION, wxExFindReplaceData::Get()->GetTextRegEx());

#if wxUSE_TOOLTIPS
  matchCase->SetToolTip(_("Search case sensitive"));
  matchWholeWord->SetToolTip(_("Search matching words"));
  isRegularExpression->SetToolTip(_("Search using regular expressions"));
#endif

  matchCase->SetValue(wxExFindReplaceData::Get()->MatchCase());
  matchWholeWord->SetValue(wxExFindReplaceData::Get()->MatchWord());
  isRegularExpression->SetValue(wxExFindReplaceData::Get()->UseRegEx());

  // And place the controls on the toolbar.
  AddControl(findCtrl);

  AddTool(
    wxID_DOWN, 
    wxEmptyString, 
    wxArtProvider::GetBitmap(wxART_GO_DOWN, wxART_TOOLBAR),
    _("Find next"));
  AddTool(
    wxID_UP, 
    wxEmptyString, 
    wxArtProvider::GetBitmap(wxART_GO_UP, wxART_TOOLBAR),
    _("Find previous"));

  AddControl(matchWholeWord);
  AddControl(matchCase);
  AddControl(isRegularExpression);

  Realize();
  
  Bind(wxEVT_CHECKBOX, [=](wxCommandEvent& event) {
    wxExFindReplaceData::Get()->SetMatchWord(
      matchWholeWord->GetValue());}, ID_MATCH_WHOLE_WORD);
  Bind(wxEVT_CHECKBOX, [=](wxCommandEvent& event) {
    wxExFindReplaceData::Get()->SetMatchCase(
      matchCase->GetValue());}, ID_MATCH_CASE);
  Bind(wxEVT_CHECKBOX, [=](wxCommandEvent& event) {
    wxExFindReplaceData::Get()->SetUseRegEx(
      isRegularExpression->GetValue());}, ID_REGULAR_EXPRESSION);
      
  Bind(wxEVT_MENU, [=](wxCommandEvent& event) {
    findCtrl->Find(true);}, wxID_DOWN);
  Bind(wxEVT_MENU, [=](wxCommandEvent& event) {
    findCtrl->Find(false);}, wxID_UP);

  Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) {
    event.Enable(!findCtrl->GetValue().empty());}, wxID_DOWN);
  Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) {
    event.Enable(!findCtrl->GetValue().empty());}, wxID_UP);
}
Example #28
0
void wxToolbook::OnIdle(wxIdleEvent& event)
{
    if (m_needsRealizing)
        Realize();
    event.Skip();
}
Example #29
0
static int Start(dtaudio_output_t *aout) {
    SLresult result;

    aout_sys_t *sys = (aout_sys_t *) aout->ao_priv;
    dtaudio_para_t *para = &aout->para;

    // configure audio source - this defines the number of samples you can enqueue.
    SLDataLocator_AndroidSimpleBufferQueue loc_bufq = {
            SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,
            OPENSLES_BUFFERS
    };

    int mask;

    if (para->dst_channels > 1)
        mask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
    else
        mask = SL_SPEAKER_FRONT_CENTER;


    SLDataFormat_PCM format_pcm;
    format_pcm.formatType = SL_DATAFORMAT_PCM;
    format_pcm.numChannels = para->dst_channels;
    //format_pcm.samplesPerSec    = ((SLuint32) para->dst_samplerate * 1000) ;
    format_pcm.samplesPerSec = ((SLuint32) convertSampleRate(para->dst_samplerate));
    format_pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
    format_pcm.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16;
    format_pcm.channelMask = mask;
    format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;

    SLDataSource audioSrc = {&loc_bufq, &format_pcm};

    // configure audio sink
    SLDataLocator_OutputMix loc_outmix = {
            SL_DATALOCATOR_OUTPUTMIX,
            sys->outputMixObject
    };
    SLDataSink audioSnk = {&loc_outmix, NULL};

    //create audio player
    const SLInterfaceID ids2[] = {sys->SL_IID_ANDROIDSIMPLEBUFFERQUEUE, sys->SL_IID_VOLUME};
    static const SLboolean req2[] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
    result = CreateAudioPlayer(sys->engineEngine, &sys->playerObject, &audioSrc,
                               &audioSnk, sizeof(ids2) / sizeof(*ids2),
                               ids2, req2);
    if (unlikely(result != SL_RESULT_SUCCESS)) { // error
        return -1;
        /* Try again with a more sensible samplerate */
#if 0
        fmt->i_rate = 44100;
        format_pcm.samplesPerSec = ((SLuint32) 44100 * 1000) ;
        result = CreateAudioPlayer(sys->engineEngine, &sys->playerObject, &audioSrc,
                &audioSnk, sizeof(ids2) / sizeof(*ids2),
                ids2, req2);
#endif
    }
    CHECK_OPENSL_ERROR("Failed to create audio player");

    result = Realize(sys->playerObject, SL_BOOLEAN_FALSE);
    CHECK_OPENSL_ERROR("Failed to realize player object.");

    result = GetInterface(sys->playerObject, sys->SL_IID_PLAY, &sys->playerPlay);
    CHECK_OPENSL_ERROR("Failed to get player interface.");

    result = GetInterface(sys->playerObject, sys->SL_IID_VOLUME, &sys->volumeItf);
    CHECK_OPENSL_ERROR("failed to get volume interface.");

    result = GetInterface(sys->playerObject, sys->SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
                          &sys->playerBufferQueue);
    CHECK_OPENSL_ERROR("Failed to get buff queue interface");

    result = RegisterCallback(sys->playerBufferQueue, PlayedCallback,
                              (void *) aout);
    CHECK_OPENSL_ERROR("Failed to register buff queue callback.");

    // set the player's state to playing
    result = SetPlayState(sys->playerPlay, SL_PLAYSTATE_PLAYING);
    CHECK_OPENSL_ERROR("Failed to switch to playing state");

    /* XXX: rounding shouldn't affect us at normal sampling rate */
    sys->rate = para->dst_samplerate;
    sys->samples_per_buf = OPENSLES_BUFLEN * para->dst_samplerate / 1000;
    sys->buf = malloc(OPENSLES_BUFFERS * sys->samples_per_buf * bytesPerSample(aout));
    if (!sys->buf)
        goto error;

    sys->started = 0;
    sys->next_buf = 0;

    sys->samples = 0;
    SetPositionUpdatePeriod(sys->playerPlay, AOUT_MIN_PREPARE_TIME * 1000 / CLOCK_FREQ);
    return 0;

    error:
    if (sys->playerObject) {
        Destroy(sys->playerObject);
        sys->playerObject = NULL;
    }

    return -1;
}
Example #30
0
static int Open(dtaudio_output_t *aout) {
    aout_sys_t *sys;
    SLresult result;

    dtaudio_para_t *para = &aout->para;
    sys = (aout_sys_t *) malloc(sizeof(*sys));
    if (unlikely(sys == NULL))
        return -1;

    sys->p_so_handle = dlopen("libOpenSLES.so", RTLD_NOW);
    if (sys->p_so_handle == NULL) {
        goto error;
    }

    sys->slCreateEnginePtr = dlsym(sys->p_so_handle, "slCreateEngine");
    if (unlikely(sys->slCreateEnginePtr == NULL)) {
        goto error;
    }

#define OPENSL_DLSYM(dest, name)                       \
    do {                                                       \
        const SLInterfaceID *sym = dlsym(sys->p_so_handle, "SL_IID_"name);        \
        if (unlikely(sym == NULL))                             \
        {                                                      \
            goto error;                                        \
        }                                                      \
        sys->dest = *sym;                                           \
    } while(0)

    OPENSL_DLSYM(SL_IID_ANDROIDSIMPLEBUFFERQUEUE, "ANDROIDSIMPLEBUFFERQUEUE");
    OPENSL_DLSYM(SL_IID_ENGINE, "ENGINE");
    OPENSL_DLSYM(SL_IID_PLAY, "PLAY");
    OPENSL_DLSYM(SL_IID_VOLUME, "VOLUME");
#undef OPENSL_DLSYM

    // create engine
    result = sys->slCreateEnginePtr(&sys->engineObject, 0, NULL, 0, NULL, NULL);
    CHECK_OPENSL_ERROR("Failed to create engine");

    // realize the engine in synchronous mode
    result = Realize(sys->engineObject, SL_BOOLEAN_FALSE);
    CHECK_OPENSL_ERROR("Failed to realize engine");

    // get the engine interface, needed to create other objects
    result = GetInterface(sys->engineObject, sys->SL_IID_ENGINE, &sys->engineEngine);
    CHECK_OPENSL_ERROR("Failed to get the engine interface");

    // create output mix, with environmental reverb specified as a non-required interface
    const SLInterfaceID ids1[] = {sys->SL_IID_VOLUME};
    const SLboolean req1[] = {SL_BOOLEAN_FALSE};
    result = CreateOutputMix(sys->engineEngine, &sys->outputMixObject, 1, ids1, req1);
    CHECK_OPENSL_ERROR("Failed to create output mix");

    // realize the output mix in synchronous mode
    result = Realize(sys->outputMixObject, SL_BOOLEAN_FALSE);
    CHECK_OPENSL_ERROR("Failed to realize output mix");

    dt_lock_init(&sys->lock, NULL);

    if (buf_init(&sys->dbt, para->dst_samplerate * 4 / 10) < 0) // 100ms
        return -1;
    aout->ao_priv = (void *) sys;
    return 0;

    error:
    if (sys->outputMixObject)
        Destroy(sys->outputMixObject);
    if (sys->engineObject)
        Destroy(sys->engineObject);
    if (sys->p_so_handle)
        dlclose(sys->p_so_handle);
    free(sys);
    return -1;
}