Sign up

problem when resizing Notebook with Grid

I have a problem when resizing the notebook The grid stays as it should when resizing horizontally, but distorts when expanded vertically. The parent/child relationship is as follows:

main
auto app = Gtk::Application::create(argc, argv, "my.gtkmm.spreadsheet");

 class NBkSprdSht : public Gtk::ApplicationWindow
       class MySprdSht : public Gtk::Frame
             Gtk::Box  m_VBox;    // container for HBox_1 & scrolled win
                  Gtk::ScrolledWindow  m_scrolled_window;  // container for HBox_2
                       Gtk::Box  m_HBox_2;   // container for the side & grid body
                            Gtk::Grid  m_grid_body;  // main spreadsheet body
                                 Gtk::Entry  *m_cell;  // cells in the grid body

<img src="/C/Users/jms_sr/Capture-1.PNG" alt="alt text" title="Title" />

<img src="/C/Users/jms_sr/Capture-2.PNG" alt="alt text" title="Title" />

The problem is I cannot seem to get the Gtk::Entry objects to stay fixed in size like the buttons do. Below is a code snippet where I attach my Gtk::Entry M_cell's:

<code>

m_grid_body.set_vexpand_set(false);
m_grid_body.set_vexpand(false);

m_scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
m_scrolled_window.set_size_request( frame_Width, -1 );
m_scrolled_window.set_margin_end(left_margin);
m_scrolled_window.set_margin_bottom(0);
m_scrolled_window.set_shadow_type(Gtk::SHADOW_ETCHED_OUT);
m_scrolled_window.set_name("scrolled-window");
m_VBox.set_orientation(Gtk::ORIENTATION_VERTICAL);
m_VBox.set_homogeneous(false);
m_VBox.set_vexpand(false);
m_VBox.set_vexpand_set(false);
m_HBox_1.set_homogeneous(false);
m_HBox_2.set_homogeneous(false);
m_HBox_2.set_vexpand(false);
m_HBox_2.set_vexpand_set(false);

add( m_VBox );				// add m_VBox as child of MySprdSht

m_VBox.pack_start( m_HBox_1, Gtk::PACK_SHRINK, 0);
m_VBox.pack_start( m_scrolled_window, Gtk::PACK_EXPAND_WIDGET, 0);

m_scrolled_window.add( m_HBox_2 );

m_HBox_2.pack_start(m_grid_SideLbl, Gtk::PACK_SHRINK, 0);
m_HBox_2.pack_start(m_grid_body, Gtk::PACK_SHRINK, 0);
	
// setup cells
for(r = 0; r < minrows; ++r) {
	for(c = 0; c < cols; ++c) {
		i = cols*r+c;
		m_grid_body.attach(m_cell[i], c, r, 1, 1);
		m_cell[i].set_input_purpose(Gtk::INPUT_PURPOSE_NUMBER);
		m_cell[i].set_max_length(WIDTH);
		m_cell[i].set_width_chars(WIDTH);
		m_cell[i].set_alignment(0.5);
		m_cell[i].set_vexpand_set(false);
		m_cell[i].set_vexpand(false);
		m_cell[i].set_name( "grid-body" );
	}
}

</code>

Re: problem when resizing Notebook with Grid

sorry, I did not realize this forum is dedicated to D. If anyone can help, I'd appreciate it though.

Re: problem when resizing Notebook with Grid

On 17-05-18 06:52, John Siino wrote:

sorry, I did not realize this forum is dedicated to D. If anyone can help, I'd appreciate it though.

That's correct, you might want to upload the screenshots somewhere if
you want other people to be able to view them.