Login | Register
My pages Projects Community openCollabNet

algierlib
Wiki: HowTo/LayoutSendMessage

Edit this page | HowTo | Links to this page | Page information | Attachments | Refresh page

 

How-to layout a Send Message

The code example works only with version 0.6.0 and later.

   1 #include <algier/window.hpp>
   2 #include <algier/label.hpp>
   3 #include <algier/field.hpp>
   4 #include <algier/button.hpp>
   5 #include <algier/layout.hpp>
   6 
   7 using namespace algier;
   8 
   9 int main()
  10 {
  11         window_ptr wnd(frame::create(L"Send Message"));
  12 
  13         // Main panel for the form
  14         panel_ptr main_panel(panel::create());
  15         wnd->attach(main_panel);
  16 
  17         main_panel->attach(label::create(L"From:")));
  18         main_panel->attach(textfield::create(40)));
  19         main_panel->attach(label::create(L"Subject:")));
  20         main_panel->attach(textfield::create(40)));
  21         main_panel->attach(label::create(L"Message:")));
  22         main_panel->attach(textarea::create(40,15)));
  23         
  24         std::tr1::array<algier::form_spec, 6> specs = { 
  25                 best,  stretch, 
  26                 best,  stretch,
  27                 best,  stretch
  28         };
  29 
  30         layout_ptr form(make_form_layout(2, specs.begin(), specs.end()));
  31         main_panel->relayout(form);
  32 
  33         // Panel for buttons
  34         panel_ptr button_panel(panel::create());
  35         wnd->attach(button_panel);
  36 
  37         button_panel->attach(action_button::create(L"Send")));
  38         button_panel->attach(action_button::create(L"Cancel")));
  39 
  40         button_panel->relayout(layout_ptr(new flow_layout(right, 5)));
  41 
  42         // Layout for the frame-window
  43         border_layout_ptr frame_layout(new border_layout());
  44         frame_layout->place(main_panel, center);
  45         frame_layout->place(button_panel, bottom);
  46 
  47         wnd->relayout(frame_layout);
  48         wnd->show();
  49 
  50         join();
  51 }

HowTo/LayoutSendMessage (last edited 2011-03-03 12:02:30 -0800 by ?amin)