本文整理汇总了C++中gdk::Rectangle::get_width方法的典型用法代码示例。如果您正苦于以下问题:C++ Rectangle::get_width方法的具体用法?C++ Rectangle::get_width怎么用?C++ Rectangle::get_width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdk::Rectangle
的用法示例。
在下文中一共展示了Rectangle::get_width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: boundToScreenCoordinates
void GazeTracker::boundToScreenCoordinates(Point &estimate) {
int numMonitors = Gdk::Screen::get_default()->get_n_monitors();
Gdk::Rectangle monitorGeometry;
Glib::RefPtr<Gdk::Screen> screen = Gdk::Display::get_default()->get_default_screen();
// Geometry of main monitor
screen->get_monitor_geometry(numMonitors - 1, monitorGeometry);
// If x or y coordinates are outside screen boundaries, correct them
if (estimate.x < monitorGeometry.get_x()) {
estimate.x = monitorGeometry.get_x();
}
if (estimate.y < monitorGeometry.get_y()) {
estimate.y = monitorGeometry.get_y();
}
if (estimate.x >= monitorGeometry.get_x() + monitorGeometry.get_width()) {
estimate.x = monitorGeometry.get_x() + monitorGeometry.get_width();
}
if (estimate.y >= monitorGeometry.get_y() + monitorGeometry.get_height()) {
estimate.y = monitorGeometry.get_y() + monitorGeometry.get_height();
}
}
示例2: do_render
void EmblemCellRenderer::do_render(const Cairo::RefPtr<Cairo::Context>& context, int widget, int background_area, Gdk::Rectangle &cell_area, int flags) {
context->translate(cell_area.get_x(), cell_area.get_y());
context->rectangle(0, 0, cell_area.get_width(), cell_area.get_height());
context->clip();
// TODO: Incorporate padding
context->push_group();
if (!this->_icon_name.empty()) {
Glib::RefPtr<Gdk::Pixbuf> pixbuf = this->_get_pixbuf(this->_icon_name, this->_icon_size);
context->set_operator(Cairo::OPERATOR_SOURCE);
// Assumes square icons; may break if we don't get the requested size
int height_offset = int((cell_area.get_height() - pixbuf->get_height())/2);
Gdk::Cairo::set_source_pixbuf(context, pixbuf, 0, height_offset);
context->rectangle(0, height_offset,
pixbuf->get_width(), pixbuf->get_height());
context->fill();
if (this->_tint_color) {
Gdk::RGBA* c = this->_tint_color;
gushort r = c->get_red();
gushort g = c->get_green();
gushort b = c->get_blue();
// Figure out the difference between our tint colour and an
// empirically determined (i.e., guessed) satisfying luma and
// adjust the base colours accordingly
double luma = (r + r + b + g + g + g) / 6.;
double extra_luma = (1.2 - luma) / 3.;
r = std::min(r + extra_luma, 1.);
g = std::min(g + extra_luma, 1.);
b = std::min(b + extra_luma, 1.);
context->set_source_rgba(r, g, b, 0.4);
context->set_operator(Cairo::OPERATOR_ATOP);
context->paint();
}
if (!this->_emblem_name.empty()) {
Glib::RefPtr<Gdk::Pixbuf> pixbuf = this->_get_pixbuf(this->_emblem_name, this->_emblem_size);
int x_offset = this->_icon_size - this->_emblem_size;
context->set_operator(Cairo::OPERATOR_OVER);
Gdk::Cairo::set_source_pixbuf(context, pixbuf, x_offset, 0);
context->rectangle(x_offset, 0,
cell_area.get_width(), this->_emblem_size);
context->fill();
}
}
context->pop_group_to_source();
context->set_operator(Cairo::OPERATOR_OVER);
context->paint();
}
示例3: sample_width
void
studio::render_gradient_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Gradient &gradient)
{
int height = ca.get_height();
int width = ca.get_width()-4;
float sample_width(1.0f/(float)width);
Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
const Color bg1(0.25, 0.25, 0.25);
const Color bg2(0.5, 0.5, 0.5);
Gdk::Color gdk_c;
int i;
for(i=0;i<width;i++)
{
const Color c(gradient(float(i)/float(width),sample_width));
const Color c1(Color::blend(c,bg1,1.0).clamped());
const Color c2(Color::blend(c,bg2,1.0).clamped());
gushort r1(256*App::gamma.r_F32_to_U8(c1.get_r()));
gushort g1(256*App::gamma.g_F32_to_U8(c1.get_g()));
gushort b1(256*App::gamma.b_F32_to_U8(c1.get_b()));
gushort r2(256*App::gamma.r_F32_to_U8(c2.get_r()));
gushort g2(256*App::gamma.g_F32_to_U8(c2.get_g()));
gushort b2(256*App::gamma.b_F32_to_U8(c2.get_b()));
if((i*2/height)&1)
{
gdk_c.set_rgb(r1,g1,b1);
gc->set_rgb_fg_color(gdk_c);
window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);
gdk_c.set_rgb(r2,g2,b2);
gc->set_rgb_fg_color(gdk_c);
window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
}
else
{
gdk_c.set_rgb(r2,g2,b2);
gc->set_rgb_fg_color(gdk_c);
window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);
gdk_c.set_rgb(r1,g1,b1);
gc->set_rgb_fg_color(gdk_c);
window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
}
}
gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, ca.get_width()-3, height-3);
gc->set_rgb_fg_color(Gdk::Color("#000000"));
window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), ca.get_width()-1, height-1);
}
示例4: GlobalMainFrame
// Construct the dialog
LightTextureChooser::LightTextureChooser()
: gtkutil::BlockingTransientWindow(_("Choose texture"), GlobalMainFrame().getTopLevelWindow()),
_selector(Gtk::manage(new ShaderSelector(this, getPrefixList(), true))) // true >> render a light texture
{
// Set the default size of the window
Gdk::Rectangle rect;
if (GlobalGroupDialog().getDialogWindow()->is_visible())
{
rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalGroupDialog().getDialogWindow());
}
else
{
rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalMainFrame().getTopLevelWindow());
}
set_default_size(static_cast<int>(rect.get_width()*0.6f), static_cast<int>(rect.get_height()*0.6f));
// Construct main VBox, and pack in ShaderSelector and buttons panel
Gtk::VBox* vbx = Gtk::manage(new Gtk::VBox(false, 6));
vbx->pack_start(*_selector, true, true, 0);
vbx->pack_start(createButtons(), false, false, 0);
add(*vbx);
}
示例5: ChooseEntity
std::string EntityChooser::ChooseEntity(const std::string& preSelectedEntity)
{
gtkutil::Dialog dlg(_("Select Entity"), GlobalMainFrame().getTopLevelWindow());
Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalMainFrame().getTopLevelWindow());
dlg.set_default_size(static_cast<int>(rect.get_width()/2), static_cast<int>(2*rect.get_height()/3));
// Instantiate a new chooser class
EntityChooserPtr chooser(new EntityChooser);
chooser->setSelectedEntity(preSelectedEntity);
// add this to the dialog window
IDialog::Handle handle = dlg.addElement(chooser);
if (dlg.run() == IDialog::RESULT_OK)
{
return dlg.getElementValue(handle);
}
else
{
// Cancelled
return "";
}
}
示例6: makeLUT
Gui_DisplayBaseClass::Gui_DisplayBaseClass(Gui_ProcessorHandler& processor_hand):
m_processor_hand(processor_hand),
m_deco(this,processor_hand,m_show_idx,m_show_point,m_ROI),
m_ROI(cv::Point(0,0),cv::Point(0,0)),
m_draw_result(false),
m_alph_mask(128),
m_show_idx(-1),m_show_point(false),m_show_mask(true),
m_cursor(Gdk::CROSS)
{
this->add_events( Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK );
this->signal_scroll_event().connect( sigc::mem_fun( *this, &Gui_DisplayBaseClass::on_scroll) );
this->signal_button_press_event().connect( sigc::mem_fun( *this, &Gui_DisplayBaseClass::on_click) );
m_color.set_rgb_p(0.2,0.2,0.2);
this->modify_bg(Gtk::STATE_NORMAL,m_color);
m_processor_hand.signal_state().connect( sigc::mem_fun(*this,&Gui_DisplayBaseClass::myRedraw));
Glib::RefPtr< Gdk::Screen > screen = Gdk::Screen::get_default();
Gdk::Rectangle rect;
screen->get_monitor_geometry(screen->get_primary_monitor(),rect);
set_size_request(rect.get_width()/4,rect.get_height()/4);
makeLUT();
}
示例7: queueDrawIfNeccesary
bool MouseAwareTreeView::queueDrawIfNeccesary(int32_t x, int32_t y, Glib::ustring* pPath)
{
Gtk::TreeModel::Path mousePath;
Gtk::TreeViewColumn* pColumn;
Gdk::Rectangle rect;
convert_bin_window_to_widget_coords (x, y, m_MouseInfo.x, m_MouseInfo.y);
if (get_path_at_pos(x, y, mousePath, pColumn, x, y))
{
int32_t offsetX, offsetY;
convert_bin_window_to_widget_coords(0, 0, offsetX, offsetY);
m_MouseInfo.x -= offsetX;
m_MouseInfo.y -= offsetY;
get_cell_area(mousePath, *pColumn, rect);
queue_draw_area(rect.get_x() + offsetX, rect.get_y() + offsetY, rect.get_width(), rect.get_height());
if (rect.get_y() != m_CurrentCell)
{
m_CurrentCell = rect.get_y();
m_CellChanged = true;
}
if (pPath)
{
*pPath = mousePath.to_string();
}
return true;
}
return false;
}
示例8: GlobalMainFrame
MD5AnimationViewer::MD5AnimationViewer() :
gtkutil::BlockingTransientWindow(_("MD5 Animation Viewer"), GlobalMainFrame().getTopLevelWindow()),
_modelList(Gtk::TreeStore::create(_modelColumns)),
_modelPopulator(_modelList),
_animList(Gtk::ListStore::create(_animColumns)),
_preview(new AnimationPreview)
{
// Set the default border width in accordance to the HIG
set_border_width(12);
set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);
// Set the default size of the window
const Glib::RefPtr<Gtk::Window>& mainWindow = GlobalMainFrame().getTopLevelWindow();
Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(mainWindow);
int height = static_cast<int>(rect.get_height() * 0.6f);
set_default_size(
static_cast<int>(rect.get_width() * 0.8f), height
);
// Set the default size of the window
_preview->setSize(rect.get_width() * 0.2f, height);
// Main dialog vbox
Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox(false, 12));
// Create a horizontal box to pack the treeview on the left and the preview on the right
Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox(false, 6));
hbox->pack_start(createListPane(), true, true, 0);
Gtk::VBox* previewBox = Gtk::manage(new Gtk::VBox(false, 0));
previewBox->pack_start(*_preview, true, true, 0);
hbox->pack_start(*previewBox, true, true, 0);
vbox->pack_start(*hbox, true, true, 0);
vbox->pack_end(createButtons(), false, false, 0);
// Add main vbox to dialog
add(*vbox);
// Populate with model names
populateModelList();
}
示例9: getObjectAtPos
bool LinkHints::getObjectAtPos(gdouble x, gdouble y, ObjectType *obj) {
for(iterator h = begin(); h != end(); h++) {
Gdk::Rectangle r = (*h)->drawRect();
if(x >= r.get_x() && y >= r.get_y() && x <= r.get_x() + r.get_width() && y <= r.get_y() + r.get_height()) {
*obj = ObjectType(*h);
return true;
}
}
return false;
}
示例10: dibujar
bool GraficoDeTorta::dibujar(const Cairo::RefPtr<Cairo::Context>& contexto){
Gdk::Rectangle rect = dibujo->get_allocation();
Pango::FontDescription font;
font.set_family("Monospace");
font.set_weight(Pango::WEIGHT_BOLD);
if(stock.size() == 0) return false;
contexto->set_source_rgb(1.0,1.0,1.0);
contexto->paint();
int total = 0;
for(unsigned int i = 0; i < stock.size(); i++){
total += stock[i].second;
}
float step = 2*M_PI/total;
total = 0;
float angulo0=0;
for(unsigned int i = 0; i < stock.size(); i++){
float angulo1 = step*stock[i].second + angulo0;
dibujarArco(contexto,rect.get_width()/2-rect.get_width()/4,rect.get_height()/2,rect.get_width()<rect.get_height()?rect.get_width()/4:rect.get_height()/4,angulo0,angulo1,red[i],green[i],blue[i]);
angulo0 = angulo1;
}
Glib::RefPtr<Pango::Layout> layout;
std::stringstream s;
for(unsigned int i = 0; i < stock.size(); i++){
s.str("");
s << stock[i].first << "\t" << stock[i].second;
layout = dibujo->create_pango_layout(s.str());
layout -> set_font_description(font);
int t_width, t_height;
layout->get_pixel_size(t_width,t_height);
contexto->set_source_rgb(0,0,0);
contexto -> move_to((rect.get_width())/2,15*(i+1)+5);
layout -> show_in_cairo_context(contexto);
contexto -> set_source_rgb(red[i],green[i],blue[i]);
contexto -> rectangle(rect.get_width()/2+80,15*(i+1)+5,30,15);
contexto -> fill();
}
return true;
}
示例11: drawButton
void ItemView::drawButton(const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Image* image, Gdk::Rectangle rect)
{
const Glib::RefPtr<Gdk::Pixbuf> icon = image->get_pixbuf();
const int iconLeft = rect.get_x() + (rect.get_width() * 0.5) - (icon->get_width() * 0.5);
const int iconTop = rect.get_y() + (rect.get_height() * 0.5) - (icon->get_height() * 0.5);
Gdk::Cairo::set_source_pixbuf(cr, icon, iconLeft, iconTop);
cr->rectangle(iconLeft, iconTop, icon->get_width(), icon->get_height());
cr->fill();
}
示例12: isHit
bool ItemView::isHit(GdkEventButton* event, Gdk::Rectangle& rect)
{
const int left = rect.get_x();
const int top = rect.get_y();
const int right = left + rect.get_width();
const int bottom = top + rect.get_height();
if (event->x > left && event->x < right)
if (event->y > top && event->y < bottom)
return true;
return false;}
示例13: GlobalMainFrame
ParticlesChooser::ParticlesChooser() :
gtkutil::BlockingTransientWindow(_("Choose particles"), GlobalMainFrame().getTopLevelWindow()),
_particlesList(Gtk::ListStore::create(COLUMNS())),
_selectedParticle(""),
_preview(new gtkutil::ParticlePreview)
{
set_border_width(12);
// Set the default size of the window
const Glib::RefPtr<Gtk::Window>& mainWindow = GlobalMainFrame().getTopLevelWindow();
Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(mainWindow);
int height = static_cast<int>(rect.get_height() * 0.6f);
set_default_size(
static_cast<int>(rect.get_width() * 0.4f), height
);
// Set the default size of the window
_preview->setSize(rect.get_width() * 0.2f, height);
// Main dialog vbox
Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox(false, 12));
// Create a horizontal box to pack the treeview on the left and the preview on the right
Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox(false, 6));
hbox->pack_start(createTreeView(), true, true, 0);
Gtk::VBox* previewBox = Gtk::manage(new Gtk::VBox(false, 0));
previewBox->pack_start(*_preview, true, true, 0);
hbox->pack_start(*previewBox, true, true, 0);
vbox->pack_start(*hbox, true, true, 0);
vbox->pack_end(createButtons(), false, false, 0);
// Add main vbox to dialog
add(*vbox);
}
示例14: GlobalMainFrame
// Create GTK stuff in c-tor
OverlayDialog::OverlayDialog() :
PersistentTransientWindow(_(DIALOG_TITLE), GlobalMainFrame().getTopLevelWindow(), true),
_callbackActive(false)
{
set_border_width(12);
// Set default size
Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalMainFrame().getTopLevelWindow());
set_default_size(static_cast<int>(rect.get_width()/3), -1);
// Pack in widgets
Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox(false, 12));
vbox->pack_start(createWidgets(), true, true, 0);
vbox->pack_end(createButtons(), false, false, 0);
add(*vbox);
}
示例15: GlobalMainFrame
// Constructor
SoundChooser::SoundChooser() :
BlockingTransientWindow(_("Choose sound"), GlobalMainFrame().getTopLevelWindow()),
_treeStore(Gtk::TreeStore::create(_columns)),
_treeView(NULL),
_preview(Gtk::manage(new SoundShaderPreview))
{
set_border_width(12);
set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);
// Set the default size of the window
Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalMainFrame().getTopLevelWindow());
set_default_size(rect.get_width() / 2, rect.get_height() / 2);
// Main vbox
Gtk::VBox* vbx = Gtk::manage(new Gtk::VBox(false, 12));
vbx->pack_start(createTreeView(), true, true, 0);
vbx->pack_start(*_preview, false, false, 0);
vbx->pack_start(createButtons(), false, false, 0);
add(*vbx);
}