I append a NoteBook->PAGE
to the Page->GRID
at (2,2) of the grid I add ScrolledWindow
. Inside ScrolledWindow
I added Viewport
inside which I add DrawingArea
.
On just defining the function on_draw
I get a complete blank screen.
I am not even calling queue_draw
.
And on_draw
function has no statements inside it
Here’s the code on how I have placed the widgets using a function on a class
// Creating new page tab label
Gtk::Label *cameraName = new Gtk::Label(camString);
// Create a new grid
Gtk::Grid *newGrid = new Gtk::Grid();
// Create a new scrolled window
// Gtk::ScrolledWindow *newScrollWindow = new Gtk::ScrolledWindow();
// Create a viewport
Gtk::Viewport *newViewPort = new Gtk::Viewport(Gtk::Adjustment::create(0,0,0, 0.5),Gtk::Adjustment::create(0,0,0, 0.5));
// Create a new DrawingArea
Gtk::DrawingArea *newDrawingArea = new Gtk::DrawingArea();
/////////////////////////////////////////////////////////////////////////
cameraNotebook->append_page(*newGrid,camString);
newGrid->attach(*Gtk::manage(new Gtk::ScrolledWindow()),2,2,1,1);
newViewPort->add(*newDrawingArea);
newDrawingArea->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK);
// Here, you get a raw pointer to a widget:
Gtk::Widget* pWidget = newGrid->get_child_at(2, 2);
// We cast it to its most derived type:
Gtk::ScrolledWindow* pScrolledWindow = dynamic_cast<Gtk::ScrolledWindow*>(pWidget);
if(pScrolledWindow)
{ //Some property changes to the scrollWindow }
Inside the same class I have a member function called bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
On just having a function without anything mentioned inside the function like this
bool CameraApplicationWindow::on_draw(const Cairo::RefPtr<Cairo::Context>& cr){
std::cout<<"Inside on_draw"<<std::endl;
}
Code gets complied, on executing the output file.
I get a black screen on the GUI,
and on terminal only Inside on_draw gets printed again and again.
What am I doing wrong?