BMenuItem also draws ctrl bitmap if needed, BTextView::AutoResize implemented more correctly
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16577 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
da2e259d76
commit
2c11ec31c8
|
@ -8,7 +8,7 @@ enum menu_actions {
|
|||
};
|
||||
|
||||
|
||||
const static char *kEmptyMenuLabel = "<empty>";
|
||||
#define kEmptyMenuLabel "<empty>"
|
||||
|
||||
|
||||
#endif // __MENU_PRIVATE_H
|
||||
|
|
|
@ -4090,15 +4090,13 @@ BTextView::UpdateScrollbars()
|
|||
void
|
||||
BTextView::AutoResize(bool doredraw)
|
||||
{
|
||||
// TODO: What about fContainerView ? Should we resize it as well ?
|
||||
if (fResizable) {
|
||||
float width = 0;
|
||||
for (int32 i = 0; i < CountLines(); i++)
|
||||
width = max_c(width, LineWidth(i));
|
||||
|
||||
ResizeTo(width, max_c(Bounds().Height(), TextHeight(0, CountLines())));
|
||||
if (fContainerView)
|
||||
fContainerView->ResizeTo(Bounds().Width(), Bounds().Height());
|
||||
BView *viewToResize = fContainerView != NULL ? fContainerView : this;
|
||||
viewToResize->ResizeTo(width, max_c(Bounds().Height(), TextHeight(0, CountLines())));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1816,7 +1816,7 @@ BMenu::UpdateWindowViewSize(bool upWind)
|
|||
window->ResizeTo(Bounds().Width() + 2, Bounds().Height() + 2);
|
||||
else {
|
||||
CacheFontInfo();
|
||||
window->ResizeTo(StringWidth("<empty>") + 4, fFontHeight + 6);
|
||||
window->ResizeTo(StringWidth(kEmptyMenuLabel) + 5, fFontHeight + 6);
|
||||
}
|
||||
window->MoveTo(frame.LeftTop());
|
||||
}
|
||||
|
|
|
@ -647,14 +647,17 @@ BMenuItem::SetSuper(BMenu *super)
|
|||
|
||||
|
||||
void
|
||||
BMenuItem::Select(bool on)
|
||||
BMenuItem::Select(bool selected)
|
||||
{
|
||||
if (fSelected == selected)
|
||||
return;
|
||||
|
||||
if (Submenu()) {
|
||||
fSelected = on;
|
||||
Highlight(on);
|
||||
fSelected = selected;
|
||||
Highlight(selected);
|
||||
} else if (IsEnabled()) {
|
||||
fSelected = on;
|
||||
Highlight(on);
|
||||
fSelected = selected;
|
||||
Highlight(selected);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -704,26 +707,42 @@ BMenuItem::DrawShortcutSymbol()
|
|||
|
||||
where -= BPoint(20, 10);
|
||||
|
||||
// TODO: Do this in a better way
|
||||
bool altAsCommandKey = true;
|
||||
key_map *keys = NULL;
|
||||
char *chars;
|
||||
get_key_map(&keys, &chars);
|
||||
if (keys == NULL || keys->left_command_key != 0x5d || keys->right_command_key != 0x5f)
|
||||
altAsCommandKey = false;
|
||||
free(chars);
|
||||
free(keys);
|
||||
|
||||
if (fModifiers & B_COMMAND_KEY) {
|
||||
key_map *keys;
|
||||
char *chars;
|
||||
get_key_map(&keys, &chars);
|
||||
BRect rect(0,0,16,10);
|
||||
BBitmap control(rect, B_COLOR_8_BIT);
|
||||
|
||||
// TODO: isn't there a better way to do this?
|
||||
if (keys != NULL
|
||||
&& keys->left_command_key == 0x5d && keys->right_command_key == 0x5f)
|
||||
if (altAsCommandKey)
|
||||
control.SetBits(kAltBits, kAltLength, 0, B_COLOR_8_BIT);
|
||||
else
|
||||
control.SetBits(kCtrlBits, kCtrlLength, 0, B_COLOR_8_BIT);
|
||||
fSuper->DrawBitmap(&control, where);
|
||||
|
||||
where.x -= rect.Width();
|
||||
|
||||
free(chars);
|
||||
free(keys);
|
||||
where.x -= rect.Width() + 1;
|
||||
}
|
||||
|
||||
if (fModifiers & B_CONTROL_KEY) {
|
||||
BRect rect(0,0,16,10);
|
||||
BBitmap control(rect, B_COLOR_8_BIT);
|
||||
|
||||
if (altAsCommandKey)
|
||||
control.SetBits(kCtrlBits, kCtrlLength, 0, B_COLOR_8_BIT);
|
||||
else
|
||||
control.SetBits(kAltBits, kAltLength, 0, B_COLOR_8_BIT);
|
||||
fSuper->DrawBitmap(&control, where);
|
||||
|
||||
where.x -= rect.Width() + 1;
|
||||
}
|
||||
|
||||
if (fModifiers & B_SHIFT_KEY) {
|
||||
BRect rect(0,0,21,10);
|
||||
BBitmap shift(rect, B_COLOR_8_BIT);
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
// TODO: Add scrollers
|
||||
|
||||
#include <Menu.h>
|
||||
#include <MenuWindow.h>
|
||||
|
||||
#include <MenuPrivate.h>
|
||||
#include <MenuWindow.h>
|
||||
#include <WindowPrivate.h>
|
||||
|
||||
|
||||
|
@ -96,7 +97,7 @@ BMenuFrame::Draw(BRect updateRect)
|
|||
font_height height;
|
||||
GetFontHeight(&height);
|
||||
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT));
|
||||
DrawString("<empty>", BPoint(2, ceilf(height.ascent + 2)));
|
||||
DrawString(kEmptyMenuLabel, BPoint(3, ceilf(height.ascent + 2)));
|
||||
}
|
||||
|
||||
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));
|
||||
|
|
Loading…
Reference in New Issue