Fix the keyboard focus order by changing how and in which order things are

created.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8862 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin
2004-09-06 14:43:42 +00:00
parent 606359d937
commit a68b2eb2ce
2 changed files with 89 additions and 94 deletions
@@ -18,39 +18,46 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
: BWindow(BRect(100, 100, 600, 600), title, B_TITLED_WINDOW, : BWindow(BRect(100, 100, 600, 600), title, B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
{ {
BMenu *menu; BMenu *show_menu;
BBox *box, *line; // *group BMenu *profiles_menu;
BMenuField *menu_field;
BBox *top_box, *bottom_box, *line; // *group
BButton *button; BButton *button;
BCheckBox *check; BCheckBox *check;
BRect r; BRect r;
float w, h; float x, w, h;
float x, y;
// float min_w, min_h;
// TODO: cleanup this mess!
show_menu = new BPopUpMenu("<please select me!>");
BuildShowMenu(show_menu, SHOW_MSG);
#define H_MARGIN 10 #define H_MARGIN 10
#define V_MARGIN 10 #define V_MARGIN 10
#define SMALL_MARGIN 3 #define SMALL_MARGIN 3
box = new BBox(Bounds(), NULL, B_FOLLOW_ALL, // Resize the window to minimal width
ResizeTo(fMinAddonViewRect.Width() + 2 * H_MARGIN, Bounds().Height());
top_box = new BBox(Bounds(), NULL, B_FOLLOW_NONE,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
B_PLAIN_BORDER); B_PLAIN_BORDER);
AddChild(box); AddChild(top_box);
r = box->Bounds(); r = top_box->Bounds();
r.InsetBy(H_MARGIN, V_MARGIN); r.InsetBy(H_MARGIN, V_MARGIN);
// ---- Profiles section // ---- Profiles section
menu = new BPopUpMenu("<none>"); profiles_menu = new BPopUpMenu("<none>");
fProfilesMenu = new BMenuField(r, "profiles_menu", PROFILE_LABEL, menu); menu_field = new BMenuField(r, "profiles_menu", PROFILE_LABEL, profiles_menu);
fProfilesMenu->SetFont(be_bold_font); menu_field->SetFont(be_bold_font);
fProfilesMenu->SetDivider(be_bold_font->StringWidth(PROFILE_LABEL "#")); menu_field->SetDivider(be_bold_font->StringWidth(PROFILE_LABEL "#"));
box->AddChild(fProfilesMenu); top_box->AddChild(menu_field);
// fProfilesMenu->SetViewColor((rand() % 256), (rand() % 256), (rand() % 256)); // menu_field->SetViewColor((rand() % 256), (rand() % 256), (rand() % 256));
menu_field->ResizeToPreferred();
fProfilesMenu->ResizeToPreferred(); menu_field->GetPreferredSize(&w, &h);
fProfilesMenu->GetPreferredSize(&w, &h);
button = new BButton(r, "manage_profiles", MANAGE_PROFILES_LABEL, button = new BButton(r, "manage_profiles", MANAGE_PROFILES_LABEL,
new BMessage(MANAGE_PROFILES_MSG), new BMessage(MANAGE_PROFILES_MSG),
@@ -58,103 +65,97 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
button->GetPreferredSize(&w, &h); button->GetPreferredSize(&w, &h);
button->ResizeToPreferred(); button->ResizeToPreferred();
button->MoveTo(r.right - w, r.top); button->MoveTo(r.right - w, r.top);
box->AddChild(button); top_box->AddChild(button);
fManageProfilesButton = button;
r.top += h + V_MARGIN; r.top += h + V_MARGIN;
// ---- Separator line between Profiles section and Settings section // ---- Separator line between Profiles section and Settings section
line = new BBox(BRect(r.left, r.top, r.right, r.top + 1), NULL, line = new BBox(BRect(r.left, r.top, r.right, r.top + 1), NULL,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP ); B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
box->AddChild(line); top_box->AddChild(line);
BuildProfilesMenu(menu, SELECT_PROFILE_MSG); BuildProfilesMenu(profiles_menu, SELECT_PROFILE_MSG);
r.top += 2 + V_MARGIN;
// ---- Settings section
// Make the show popup field half the whole width and centered
menu_field = new BMenuField(r, "show_menu", SHOW_LABEL, show_menu);
menu_field->SetFont(be_plain_font);
menu_field->SetDivider(be_plain_font->StringWidth(SHOW_LABEL "#"));
top_box->AddChild(menu_field);
// menu_field->SetViewColor((rand() % 256), (rand() % 256), (rand() % 256));
menu_field->ResizeToPreferred();
menu_field->GetPreferredSize(&w, &h);
r.top += h+1 + V_MARGIN;
r = fMinAddonViewRect.OffsetByCopy(H_MARGIN, r.top);
fPanel = new BBox(r, "showview_box", B_FOLLOW_NONE,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
B_PLAIN_BORDER);
top_box->AddChild(fPanel);
top_box->ResizeTo(Bounds().Width(), r.bottom + 1 + V_MARGIN);
r.top += V_MARGIN;
// ---- Bottom globals buttons section // ---- Bottom globals buttons section
#if 1
r = Bounds();
r.top = top_box->Frame().bottom + 1;
bottom_box = new BBox(r, NULL, B_FOLLOW_NONE,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
B_PLAIN_BORDER);
AddChild(bottom_box);
r.OffsetTo(0, 0);
r.InsetBy(H_MARGIN, V_MARGIN);
check = new BCheckBox(r, "dont_touch", DONT_TOUCH_LABEL, check = new BCheckBox(r, "dont_touch", DONT_TOUCH_LABEL,
new BMessage(DONT_TOUCH_MSG), new BMessage(DONT_TOUCH_MSG),
B_FOLLOW_BOTTOM | B_FOLLOW_LEFT); B_FOLLOW_TOP | B_FOLLOW_LEFT);
check->GetPreferredSize(&w, &h); check->GetPreferredSize(&w, &h);
check->ResizeToPreferred(); check->ResizeToPreferred();
check->SetValue(B_CONTROL_ON); check->SetValue(B_CONTROL_ON);
check->MoveTo(H_MARGIN, r.bottom - h); check->MoveTo(H_MARGIN, r.top);
box->AddChild(check); bottom_box->AddChild(check);
#endif
button = new BButton(r, "apply_now", APPLY_NOW_LABEL, button = new BButton(r, "apply_now", APPLY_NOW_LABEL,
new BMessage(APPLY_NOW_MSG), new BMessage(APPLY_NOW_MSG),
B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT); B_FOLLOW_TOP | B_FOLLOW_RIGHT);
button->GetPreferredSize(&w, &h); button->GetPreferredSize(&w, &h);
button->ResizeToPreferred(); button->ResizeToPreferred();
x = r.right - w; x = r.right - w;
button->MoveTo(x, r.bottom - h); button->MoveTo(x, r.top);
box->AddChild(button); bottom_box->AddChild(button);
fApplyNowButton = button; fApplyNowButton = button;
button = new BButton(r, "revert", REVERT_LABEL, button = new BButton(r, "revert", REVERT_LABEL,
new BMessage(REVERT_MSG), new BMessage(REVERT_MSG),
B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT); B_FOLLOW_TOP | B_FOLLOW_RIGHT);
button->GetPreferredSize(&w, &h); button->GetPreferredSize(&w, &h);
button->ResizeToPreferred(); button->ResizeToPreferred();
button->MoveTo(x - w - SMALL_MARGIN, r.bottom - h); button->MoveTo(x - w - SMALL_MARGIN, r.top);
box->AddChild(button); bottom_box->AddChild(button);
fRevertButton = button; fRevertButton = button;
fRevertButton->SetEnabled(false); fRevertButton->SetEnabled(false);
// ---- Separator line between settings section and bottom buttons sections r.bottom = r.top + h;
r.InsetBy(-H_MARGIN, -V_MARGIN);
y = r.bottom - h - V_MARGIN; bottom_box->ResizeTo(Bounds().Width(), r.Height());
line = new BBox(BRect(-1, y, Bounds().right + 1, y + 1), NULL,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM ); // Set default/minimal window size
box->AddChild(line); ResizeTo(Bounds().Width(), bottom_box->Frame().bottom);
SetSizeLimits(Bounds().Width(), 20000, Bounds().Height(), 20000);
r.bottom = y - V_MARGIN;
// Enable boxes resizing modes
// ---- Show settings section top_box->SetResizingMode(B_FOLLOW_ALL);
fPanel->SetResizingMode(B_FOLLOW_ALL);
menu = new BPopUpMenu("<nothing>"); bottom_box->SetResizingMode(B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT);
// Make the show popup field half the whole width and centered
fShowMenu = new BMenuField(r, "show_menu", SHOW_LABEL, menu);
fShowMenu->SetFont(be_plain_font);
fShowMenu->SetDivider(be_plain_font->StringWidth(SHOW_LABEL "#"));
box->AddChild(fShowMenu);
// fShowMenu->SetViewColor((rand() % 256), (rand() % 256), (rand() % 256));
fShowMenu->ResizeToPreferred();
fShowMenu->GetPreferredSize(&w, &h);
BuildShowMenu(menu, SHOW_MSG);
#if 0
button = new BButton(r, "help", HELP_LABEL,
new BMessage(HELP_MSG),
B_FOLLOW_TOP | B_FOLLOW_RIGHT);
button->GetPreferredSize(&w, &h);
button->ResizeToPreferred();
button->MoveTo(r.right - w, r.top);
box->AddChild(button);
fHelpButton = button;
#endif
r.top += h + V_MARGIN;
r.left = H_MARGIN;
fPanel = new BBox(r, "showview_box", B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
B_PLAIN_BORDER);
box->AddChild(fPanel);
fAddonView = NULL; fAddonView = NULL;
ResizeTo(fMinAddonViewRect.Width() + 2 * H_MARGIN, fMinAddonViewRect.Height());
SetSizeLimits(Bounds().Width(), 20000, Bounds().Height(), 20000);
} }
@@ -180,6 +181,7 @@ void NetworkSetupWindow::MessageReceived
) )
{ {
switch (msg->what) { switch (msg->what) {
/*
case NEW_PROFILE_MSG: case NEW_PROFILE_MSG:
break; break;
@@ -198,7 +200,7 @@ void NetworkSetupWindow::MessageReceived
alert->Go(); alert->Go();
break; break;
} }
*/
case SELECT_PROFILE_MSG: { case SELECT_PROFILE_MSG: {
BPath name; BPath name;
const char *path; const char *path;
@@ -213,7 +215,6 @@ void NetworkSetupWindow::MessageReceived
is_default = (strcmp(name.Leaf(), "default") == 0); is_default = (strcmp(name.Leaf(), "default") == 0);
is_current = (strcmp(name.Leaf(), "current") == 0); is_current = (strcmp(name.Leaf(), "current") == 0);
// fDeleteProfileButton->SetEnabled(!is_default);
fApplyNowButton->SetEnabled(!is_current); fApplyNowButton->SetEnabled(!is_current);
break; break;
} }
@@ -341,7 +342,7 @@ void NetworkSetupWindow::BuildShowMenu
// Nowhere to search addons!!! // Nowhere to search addons!!!
return; return;
fMinAddonViewRect.Set(0, 0, 200, 200); fMinAddonViewRect.Set(0, 0, 200, 200); // Minimum size
search_paths = strdup(search_paths); search_paths = strdup(search_paths);
search_path = strtok_r(search_paths, ":", &next_path_token); search_path = strtok_r(search_paths, ":", &next_path_token);
@@ -53,18 +53,12 @@ class NetworkSetupWindow : public BWindow
void BuildProfilesMenu(BMenu *menu, int32 msg); void BuildProfilesMenu(BMenu *menu, int32 msg);
void BuildShowMenu(BMenu *menu, int32 msg); void BuildShowMenu(BMenu *menu, int32 msg);
BMenuField *fProfilesMenu; BButton * fHelpButton;
BMenuField *fShowMenu; BButton * fRevertButton;
BButton *fManageProfilesButton; BButton * fApplyNowButton;
// BButton *fNewProfileButton;
// BButton *fCopyProfileButton;
// BButton *fDeleteProfileButton;
BButton *fHelpButton;
BButton *fRevertButton;
BButton *fApplyNowButton;
BBox *fPanel; BBox * fPanel;
BView *fAddonView; BView * fAddonView;
BRect fMinAddonViewRect; BRect fMinAddonViewRect;
}; };