@@ -26,8 +26,8 @@ AppWindow::AppWindow():
2626 , value_x(0.0 )
2727 , value_y(0.0 )
2828 , value_z(0.0 )
29- , layout_main()
30- , layout_display()
29+ , layout_main(Gtk::ORIENTATION_VERTICAL )
30+ , layout_display(Gtk::ORIENTATION_VERTICAL )
3131 , layout_buttons()
3232 , display_area()
3333 , radix_label_obj(" b" )
@@ -76,6 +76,7 @@ AppWindow::AppWindow():
7676 , &btn_num_e_obj
7777 , &btn_num_f_obj
7878 }}
79+ , txt_str_top(" " )
7980{
8081 set_title (" Simple Calculator" );
8182
@@ -140,7 +141,7 @@ AppWindow::AppWindow():
140141 layout_buttons.attach (btn_alt_dot_obj, 1 , 4 , 1 , 1 );
141142 layout_buttons.attach (btn_alt_inv_obj, 4 , 4 , 1 , 1 );
142143
143-
144+ display_area. set_size_request ( 360 , 120 );
144145 display_area.signal_draw ().connect (sigc::mem_fun (*this , &AppWindow::handle_display_update), false );
145146
146147 layout_display.pack_start (display_area);
@@ -172,31 +173,31 @@ bool AppWindow::handle_display_update(
172173{
173174 display_area_allocation = display_area.get_allocation ();
174175 int const area_x_full = display_area_allocation.get_width ();
175- int const area_y_full = display_area_allocation.get_height ();
176+ // int const area_y_full = display_area_allocation.get_height();
176177
177- int const lft_x = (0 );
178- int const top_y = (0 );
178+ // int const lft_x = (0);
179+ // int const top_y = (0);
179180
180- int const center_x = (area_x_full / 2 );
181- int const center_y = (area_y_full / 2 );
181+ // int const center_x = (area_x_full / 2);
182+ // int const center_y = (area_y_full / 2);
182183
183- // int const rght_x = (area_x_full);
184- int const bot_y = (area_y_full);
184+ // // int const rght_x = (area_x_full);
185+ // int const bot_y = (area_y_full);
185186
186- draw_context_ptr->set_line_width (10.0 );
187- draw_context_ptr->set_source_rgb (0.8 , 0.0 , 0.5 );
188- draw_context_ptr->move_to (lft_x, top_y);
189- draw_context_ptr->line_to (center_x, center_y);
190- draw_context_ptr->line_to (lft_x, bot_y);
191- draw_context_ptr->stroke ();
187+ // draw_context_ptr->set_line_width(10.0);
188+ // draw_context_ptr->set_source_rgb(0.8, 0.0, 0.5);
189+ // draw_context_ptr->move_to(lft_x, top_y);
190+ // draw_context_ptr->line_to(center_x, center_y);
191+ // draw_context_ptr->line_to(lft_x, bot_y);
192+ // draw_context_ptr->stroke();
192193
193194 Pango::FontDescription font;
194195
195196 font.set_family (" Monospace" );
196197 font.set_weight (Pango::WEIGHT_BOLD);
197198
198199 // http://developer.gnome.org/pangomm/unstable/classPango_1_1Layout.html
199- auto layout = create_pango_layout (" Calculator Test " );
200+ auto layout = create_pango_layout (txt_str_top. c_str () );
200201
201202 layout->set_font_description (font);
202203
@@ -261,9 +262,9 @@ bool AppWindow::handle_radix_change(
261262 */
262263void AppWindow::handle_btn_0 ()
263264{
264- std::cout
265- << " Yo! "
266- << std::endl ;
265+ txt_str_top. append ( " 0 " );
266+
267+ display_area. queue_draw () ;
267268
268269 return ;
269270}
@@ -273,6 +274,10 @@ void AppWindow::handle_btn_0()
273274 */
274275void AppWindow::handle_btn_1 ()
275276{
277+ txt_str_top.append (" 1" );
278+
279+ display_area.queue_draw ();
280+
276281 return ;
277282}
278283
@@ -281,6 +286,10 @@ void AppWindow::handle_btn_1()
281286 */
282287void AppWindow::handle_btn_2 ()
283288{
289+ txt_str_top.append (" 2" );
290+
291+ display_area.queue_draw ();
292+
284293 return ;
285294}
286295
@@ -289,6 +298,10 @@ void AppWindow::handle_btn_2()
289298 */
290299void AppWindow::handle_btn_3 ()
291300{
301+ txt_str_top.append (" 3" );
302+
303+ display_area.queue_draw ();
304+
292305 return ;
293306}
294307
@@ -297,6 +310,10 @@ void AppWindow::handle_btn_3()
297310 */
298311void AppWindow::handle_btn_4 ()
299312{
313+ txt_str_top.append (" 4" );
314+
315+ display_area.queue_draw ();
316+
300317 return ;
301318}
302319
@@ -305,6 +322,10 @@ void AppWindow::handle_btn_4()
305322 */
306323void AppWindow::handle_btn_5 ()
307324{
325+ txt_str_top.append (" 5" );
326+
327+ display_area.queue_draw ();
328+
308329 return ;
309330}
310331
@@ -313,22 +334,34 @@ void AppWindow::handle_btn_5()
313334 */
314335void AppWindow::handle_btn_6 ()
315336{
337+ txt_str_top.append (" 6" );
338+
339+ display_area.queue_draw ();
340+
316341 return ;
317342}
318343
319344/* *
320345 * @brief { item_description }
321346 */
322- void AppWindow::handle_btn_8 ()
347+ void AppWindow::handle_btn_7 ()
323348{
349+ txt_str_top.append (" 7" );
350+
351+ display_area.queue_draw ();
352+
324353 return ;
325354}
326355
327356/* *
328357 * @brief { item_description }
329358 */
330- void AppWindow::handle_btn_7 ()
359+ void AppWindow::handle_btn_8 ()
331360{
361+ txt_str_top.append (" 8" );
362+
363+ display_area.queue_draw ();
364+
332365 return ;
333366}
334367
@@ -337,6 +370,10 @@ void AppWindow::handle_btn_7()
337370 */
338371void AppWindow::handle_btn_9 ()
339372{
373+ txt_str_top.append (" 9" );
374+
375+ display_area.queue_draw ();
376+
340377 return ;
341378}
342379
@@ -345,6 +382,10 @@ void AppWindow::handle_btn_9()
345382 */
346383void AppWindow::handle_btn_a ()
347384{
385+ txt_str_top.append (" A" );
386+
387+ display_area.queue_draw ();
388+
348389 return ;
349390}
350391
@@ -353,6 +394,10 @@ void AppWindow::handle_btn_a()
353394 */
354395void AppWindow::handle_btn_b ()
355396{
397+ txt_str_top.append (" B" );
398+
399+ display_area.queue_draw ();
400+
356401 return ;
357402}
358403
@@ -361,6 +406,10 @@ void AppWindow::handle_btn_b()
361406 */
362407void AppWindow::handle_btn_c ()
363408{
409+ txt_str_top.append (" C" );
410+
411+ display_area.queue_draw ();
412+
364413 return ;
365414}
366415
@@ -369,6 +418,10 @@ void AppWindow::handle_btn_c()
369418 */
370419void AppWindow::handle_btn_d ()
371420{
421+ txt_str_top.append (" D" );
422+
423+ display_area.queue_draw ();
424+
372425 return ;
373426}
374427
@@ -377,6 +430,10 @@ void AppWindow::handle_btn_d()
377430 */
378431void AppWindow::handle_btn_e ()
379432{
433+ txt_str_top.append (" E" );
434+
435+ display_area.queue_draw ();
436+
380437 return ;
381438}
382439
@@ -385,5 +442,9 @@ void AppWindow::handle_btn_e()
385442 */
386443void AppWindow::handle_btn_f ()
387444{
445+ txt_str_top.append (" F" );
446+
447+ display_area.queue_draw ();
448+
388449 return ;
389450}
0 commit comments