* Removed VIEW_COLOR definition, and also fixed its former usages to use
ui_color(B_PANEL_BACKGROUND_COLOR) instead. * Cleanup, simplified TStatusWindow. * Did not fix font sensitivity issues in TStatusWindow (but that's also not for Ryan, as MDR should stay compilable on R5 as well for now). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20067 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
eccc7665b5
commit
f7f2fd3533
@ -120,19 +120,17 @@ GetTrackerIcon(BMimeType &type, BBitmap *icon, icon_size iconSize)
|
|||||||
|
|
||||||
|
|
||||||
TEnclosuresView::TEnclosuresView(BRect rect, BRect wind_rect)
|
TEnclosuresView::TEnclosuresView(BRect rect, BRect wind_rect)
|
||||||
: BView(rect, "m_enclosures", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW),
|
: BView(rect, "m_enclosures", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW),
|
||||||
fFocus(false)
|
fFocus(false)
|
||||||
{
|
{
|
||||||
rgb_color c;
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
c.red = c.green = c.blue = VIEW_COLOR;
|
|
||||||
SetViewColor(c);
|
|
||||||
|
|
||||||
BFont font = *be_plain_font;
|
BFont font = *be_plain_font;
|
||||||
font.SetSize(FONT_SIZE);
|
font.SetSize(FONT_SIZE);
|
||||||
font_height fHeight;
|
font_height fHeight;
|
||||||
font.GetHeight(&fHeight);
|
font.GetHeight(&fHeight);
|
||||||
fOffset = 12;
|
fOffset = 12;
|
||||||
|
|
||||||
BRect r;
|
BRect r;
|
||||||
r.left = ENCLOSE_TEXT_H + font.StringWidth(
|
r.left = ENCLOSE_TEXT_H + font.StringWidth(
|
||||||
MDR_DIALECT_CHOICE ("Enclosures: ","添付ファイル")) + 5;
|
MDR_DIALECT_CHOICE ("Enclosures: ","添付ファイル")) + 5;
|
||||||
@ -166,16 +164,13 @@ TEnclosuresView::~TEnclosuresView()
|
|||||||
void
|
void
|
||||||
TEnclosuresView::Draw(BRect where)
|
TEnclosuresView::Draw(BRect where)
|
||||||
{
|
{
|
||||||
float offset;
|
|
||||||
BFont font = *be_plain_font;
|
|
||||||
|
|
||||||
BView::Draw(where);
|
BView::Draw(where);
|
||||||
|
|
||||||
|
BFont font = *be_plain_font;
|
||||||
font.SetSize(FONT_SIZE);
|
font.SetSize(FONT_SIZE);
|
||||||
SetFont(&font);
|
SetFont(&font);
|
||||||
SetHighColor(0, 0, 0);
|
SetHighColor(0, 0, 0);
|
||||||
SetLowColor(VIEW_COLOR, VIEW_COLOR, VIEW_COLOR);
|
SetLowColor(ViewColor());
|
||||||
|
|
||||||
offset = 12;
|
|
||||||
|
|
||||||
font_height fHeight;
|
font_height fHeight;
|
||||||
font.GetHeight(&fHeight);
|
font.GetHeight(&fHeight);
|
||||||
|
@ -60,7 +60,6 @@ All rights reserved.
|
|||||||
#define WIND_HEIGHT 400
|
#define WIND_HEIGHT 400
|
||||||
#define RIGHT_BOUNDARY 8191
|
#define RIGHT_BOUNDARY 8191
|
||||||
#define SEPARATOR_MARGIN 7
|
#define SEPARATOR_MARGIN 7
|
||||||
#define VIEW_COLOR 216
|
|
||||||
#define FONT_SIZE 11.0
|
#define FONT_SIZE 11.0
|
||||||
#define QUOTE "> "
|
#define QUOTE "> "
|
||||||
|
|
||||||
|
@ -32,105 +32,109 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
//
|
#include "Mail.h"
|
||||||
// Status.cpp
|
#include "Status.h"
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------
|
#include <Button.h>
|
||||||
|
#include <Directory.h>
|
||||||
|
#include <FindDirectory.h>
|
||||||
|
#include <fs_index.h>
|
||||||
|
#include <Node.h>
|
||||||
|
#include <NodeInfo.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <Query.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
#include <Volume.h>
|
||||||
|
#include <VolumeRoster.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <StorageKit.h>
|
|
||||||
|
|
||||||
#include "Mail.h"
|
#define STATUS_TEXT "Status:"
|
||||||
#include "Status.h"
|
#define STATUS_FIELD_H 10
|
||||||
|
#define STATUS_FIELD_V 8
|
||||||
|
#define STATUS_FIELD_WIDTH (STATUS_WIDTH - STATUS_FIELD_H)
|
||||||
|
#define STATUS_FIELD_HEIGHT 16
|
||||||
|
|
||||||
|
#define BUTTON_WIDTH 70
|
||||||
|
#define BUTTON_HEIGHT 20
|
||||||
|
|
||||||
|
#define S_OK_BUTTON_X1 (STATUS_WIDTH - BUTTON_WIDTH - 6)
|
||||||
|
#define S_OK_BUTTON_Y1 (STATUS_HEIGHT - (BUTTON_HEIGHT + 10))
|
||||||
|
#define S_OK_BUTTON_X2 (S_OK_BUTTON_X1 + BUTTON_WIDTH)
|
||||||
|
#define S_OK_BUTTON_Y2 (S_OK_BUTTON_Y1 + BUTTON_HEIGHT)
|
||||||
|
#define S_OK_BUTTON_TEXT "OK"
|
||||||
|
|
||||||
|
#define S_CANCEL_BUTTON_X1 (S_OK_BUTTON_X1 - (BUTTON_WIDTH + 10))
|
||||||
|
#define S_CANCEL_BUTTON_Y1 S_OK_BUTTON_Y1
|
||||||
|
#define S_CANCEL_BUTTON_X2 (S_CANCEL_BUTTON_X1 + BUTTON_WIDTH)
|
||||||
|
#define S_CANCEL_BUTTON_Y2 S_OK_BUTTON_Y2
|
||||||
|
#define S_CANCEL_BUTTON_TEXT "Cancel"
|
||||||
|
|
||||||
|
enum status_messages {
|
||||||
|
STATUS = 128,
|
||||||
|
OK,
|
||||||
|
CANCEL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//====================================================================
|
TStatusWindow::TStatusWindow(BRect rect, BMessenger target, const char* status)
|
||||||
|
: BWindow(rect, "", B_MODAL_WINDOW, B_NOT_RESIZABLE),
|
||||||
TStatusWindow::TStatusWindow(BRect rect, BWindow *window, const char *status)
|
fTarget(target)
|
||||||
: BWindow(rect, "", B_MODAL_WINDOW, B_NOT_RESIZABLE)
|
|
||||||
{
|
{
|
||||||
BRect r(0, 0, STATUS_WIDTH, STATUS_HEIGHT);
|
BView* view = new BView(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
|
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
AddChild(view);
|
||||||
|
|
||||||
r.InsetBy(-1, -1);
|
|
||||||
fView = new TStatusView(r, window, status);
|
|
||||||
Lock();
|
|
||||||
AddChild(fView);
|
|
||||||
Unlock();
|
|
||||||
Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//====================================================================
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
TStatusView::TStatusView(BRect rect, BWindow *window, const char *status)
|
|
||||||
: BBox(rect, "", B_FOLLOW_ALL, B_WILL_DRAW)
|
|
||||||
{
|
|
||||||
fWindow = window;
|
|
||||||
fString = status;
|
|
||||||
|
|
||||||
SetViewColor(VIEW_COLOR, VIEW_COLOR, VIEW_COLOR);
|
|
||||||
|
|
||||||
BFont font = *be_plain_font;
|
|
||||||
font.SetSize(FONT_SIZE);
|
|
||||||
SetFont(&font);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TStatusView::AttachedToWindow()
|
|
||||||
{
|
|
||||||
BRect r(STATUS_FIELD_H, STATUS_FIELD_V,
|
BRect r(STATUS_FIELD_H, STATUS_FIELD_V,
|
||||||
STATUS_FIELD_WIDTH, STATUS_FIELD_V + STATUS_FIELD_HEIGHT);
|
STATUS_FIELD_WIDTH, STATUS_FIELD_V + STATUS_FIELD_HEIGHT);
|
||||||
|
|
||||||
fStatus = new BTextControl(r, "", STATUS_TEXT, fString, new BMessage(STATUS));
|
fStatus = new BTextControl(r, "", STATUS_TEXT, status, new BMessage(STATUS));
|
||||||
AddChild(fStatus);
|
view->AddChild(fStatus);
|
||||||
|
|
||||||
BFont font = *be_plain_font;
|
fStatus->SetDivider(fStatus->StringWidth(STATUS_TEXT) + 6);
|
||||||
font.SetSize(FONT_SIZE);
|
|
||||||
fStatus->SetFont(&font);
|
|
||||||
fStatus->SetDivider(StringWidth(STATUS_TEXT) + 6);
|
|
||||||
fStatus->BTextControl::MakeFocus(true);
|
fStatus->BTextControl::MakeFocus(true);
|
||||||
|
|
||||||
r.Set(S_OK_BUTTON_X1, S_OK_BUTTON_Y1, S_OK_BUTTON_X2, S_OK_BUTTON_Y2);
|
r.Set(S_OK_BUTTON_X1, S_OK_BUTTON_Y1, S_OK_BUTTON_X2, S_OK_BUTTON_Y2);
|
||||||
BButton *button = new BButton(r, "", S_OK_BUTTON_TEXT, new BMessage(OK));
|
BButton *button = new BButton(r, "", S_OK_BUTTON_TEXT, new BMessage(OK));
|
||||||
AddChild(button);
|
view->AddChild(button);
|
||||||
button->SetTarget(this);
|
|
||||||
button->MakeDefault(true);
|
button->MakeDefault(true);
|
||||||
|
|
||||||
r.Set(S_CANCEL_BUTTON_X1, S_CANCEL_BUTTON_Y1, S_CANCEL_BUTTON_X2, S_CANCEL_BUTTON_Y2);
|
r.Set(S_CANCEL_BUTTON_X1, S_CANCEL_BUTTON_Y1, S_CANCEL_BUTTON_X2, S_CANCEL_BUTTON_Y2);
|
||||||
button = new BButton(r, "", S_CANCEL_BUTTON_TEXT, new BMessage(CANCEL));
|
button = new BButton(r, "", S_CANCEL_BUTTON_TEXT, new BMessage(CANCEL));
|
||||||
AddChild(button);
|
view->AddChild(button);
|
||||||
button->SetTarget(this);
|
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TStatusWindow::~TStatusWindow()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TStatusView::MessageReceived(BMessage *msg)
|
TStatusWindow::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
char name[B_FILE_NAME_LENGTH];
|
switch (msg->what) {
|
||||||
char new_name[B_FILE_NAME_LENGTH];
|
|
||||||
int32 index = 0;
|
|
||||||
uint32 loop;
|
|
||||||
status_t result;
|
|
||||||
BDirectory dir;
|
|
||||||
BEntry entry;
|
|
||||||
BFile file;
|
|
||||||
BNodeInfo *node;
|
|
||||||
BPath path;
|
|
||||||
|
|
||||||
switch (msg->what)
|
|
||||||
{
|
|
||||||
case STATUS:
|
case STATUS:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OK:
|
case OK:
|
||||||
if (!Exists(fStatus->Text())) {
|
{
|
||||||
|
if (!_Exists(fStatus->Text())) {
|
||||||
|
int32 index = 0;
|
||||||
|
uint32 loop;
|
||||||
|
status_t result;
|
||||||
|
BDirectory dir;
|
||||||
|
BEntry entry;
|
||||||
|
BFile file;
|
||||||
|
BNodeInfo* node;
|
||||||
|
BPath path;
|
||||||
|
|
||||||
find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
|
find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
|
||||||
dir.SetTo(path.Path());
|
dir.SetTo(path.Path());
|
||||||
if (dir.FindEntry("bemail", &entry) == B_NO_ERROR)
|
if (dir.FindEntry("bemail", &entry) == B_NO_ERROR)
|
||||||
@ -144,6 +148,9 @@ TStatusView::MessageReceived(BMessage *msg)
|
|||||||
else
|
else
|
||||||
dir.CreateDirectory("status", &dir);
|
dir.CreateDirectory("status", &dir);
|
||||||
if (dir.InitCheck() == B_NO_ERROR) {
|
if (dir.InitCheck() == B_NO_ERROR) {
|
||||||
|
char name[B_FILE_NAME_LENGTH];
|
||||||
|
char newName[B_FILE_NAME_LENGTH];
|
||||||
|
|
||||||
sprintf(name, "%s", fStatus->Text());
|
sprintf(name, "%s", fStatus->Text());
|
||||||
if (strlen(name) > B_FILE_NAME_LENGTH - 10)
|
if (strlen(name) > B_FILE_NAME_LENGTH - 10)
|
||||||
name[B_FILE_NAME_LENGTH - 10] = 0;
|
name[B_FILE_NAME_LENGTH - 10] = 0;
|
||||||
@ -151,40 +158,41 @@ TStatusView::MessageReceived(BMessage *msg)
|
|||||||
if (name[loop] == '/')
|
if (name[loop] == '/')
|
||||||
name[loop] = '\\';
|
name[loop] = '\\';
|
||||||
}
|
}
|
||||||
strcpy(new_name, name);
|
strcpy(newName, name);
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((result = dir.CreateFile(new_name, &file, true)) == B_NO_ERROR)
|
if ((result = dir.CreateFile(newName, &file, true)) == B_NO_ERROR)
|
||||||
break;
|
break;
|
||||||
if (result != EEXIST)
|
if (result != EEXIST)
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
sprintf(new_name, "%s_%ld", name, index++);
|
sprintf(newName, "%s_%ld", name, index++);
|
||||||
}
|
}
|
||||||
dir.FindEntry(new_name, &entry);
|
dir.FindEntry(newName, &entry);
|
||||||
node = new BNodeInfo(&file);
|
node = new BNodeInfo(&file);
|
||||||
node->SetType("text/plain");
|
node->SetType("text/plain");
|
||||||
delete node;
|
delete node;
|
||||||
file.Write(fStatus->Text(), strlen(fStatus->Text()) + 1);
|
file.Write(fStatus->Text(), strlen(fStatus->Text()) + 1);
|
||||||
file.SetSize(file.Position());
|
file.SetSize(file.Position());
|
||||||
file.WriteAttr(INDEX_STATUS, B_STRING_TYPE, 0, fStatus->Text(),
|
file.WriteAttr(INDEX_STATUS, B_STRING_TYPE, 0, fStatus->Text(),
|
||||||
strlen(fStatus->Text()) + 1);
|
strlen(fStatus->Text()) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err_exit:
|
err_exit:
|
||||||
{
|
{
|
||||||
BMessage closeCstmMsg(M_CLOSE_CUSTOM);
|
BMessage close(M_CLOSE_CUSTOM);
|
||||||
closeCstmMsg.AddString("status", fStatus->Text());
|
close.AddString("status", fStatus->Text());
|
||||||
fWindow->PostMessage(&closeCstmMsg);
|
fTarget.SendMessage(&close);
|
||||||
// will fall through
|
// will fall through
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case CANCEL:
|
case CANCEL:
|
||||||
Window()->Quit();
|
Quit();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TStatusView::Exists(const char *status)
|
TStatusWindow::_Exists(const char* status)
|
||||||
{
|
{
|
||||||
BVolume volume;
|
BVolume volume;
|
||||||
BVolumeRoster().GetBootVolume(&volume);
|
BVolumeRoster().GetBootVolume(&volume);
|
||||||
|
@ -31,89 +31,33 @@ of Be Incorporated in the United States and other countries. Other brand product
|
|||||||
names are registered trademarks or trademarks of their respective holders.
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Status.h
|
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _STATUS_H
|
#ifndef _STATUS_H
|
||||||
#define _STATUS_H
|
#define _STATUS_H
|
||||||
|
|
||||||
#include <Beep.h>
|
|
||||||
#include <Box.h>
|
#include <Messenger.h>
|
||||||
#include <Button.h>
|
|
||||||
#include <fs_index.h>
|
|
||||||
#include <Node.h>
|
|
||||||
#include <NodeInfo.h>
|
|
||||||
#include <Path.h>
|
|
||||||
#include <Query.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <Volume.h>
|
|
||||||
#include <VolumeRoster.h>
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define INDEX_STATUS "_status"
|
||||||
|
|
||||||
#define STATUS_WIDTH 220
|
#define STATUS_WIDTH 220
|
||||||
#define STATUS_HEIGHT 80
|
#define STATUS_HEIGHT 80
|
||||||
|
|
||||||
#define STATUS_TEXT "Status:"
|
|
||||||
#define STATUS_FIELD_H 10
|
|
||||||
#define STATUS_FIELD_V 8
|
|
||||||
#define STATUS_FIELD_WIDTH (STATUS_WIDTH - STATUS_FIELD_H)
|
|
||||||
#define STATUS_FIELD_HEIGHT 16
|
|
||||||
|
|
||||||
#define BUTTON_WIDTH 70
|
class TStatusWindow : public BWindow {
|
||||||
#define BUTTON_HEIGHT 20
|
|
||||||
|
|
||||||
#define S_OK_BUTTON_X1 (STATUS_WIDTH - BUTTON_WIDTH - 6)
|
|
||||||
#define S_OK_BUTTON_Y1 (STATUS_HEIGHT - (BUTTON_HEIGHT + 10))
|
|
||||||
#define S_OK_BUTTON_X2 (S_OK_BUTTON_X1 + BUTTON_WIDTH)
|
|
||||||
#define S_OK_BUTTON_Y2 (S_OK_BUTTON_Y1 + BUTTON_HEIGHT)
|
|
||||||
#define S_OK_BUTTON_TEXT "OK"
|
|
||||||
|
|
||||||
#define S_CANCEL_BUTTON_X1 (S_OK_BUTTON_X1 - (BUTTON_WIDTH + 10))
|
|
||||||
#define S_CANCEL_BUTTON_Y1 S_OK_BUTTON_Y1
|
|
||||||
#define S_CANCEL_BUTTON_X2 (S_CANCEL_BUTTON_X1 + BUTTON_WIDTH)
|
|
||||||
#define S_CANCEL_BUTTON_Y2 S_OK_BUTTON_Y2
|
|
||||||
#define S_CANCEL_BUTTON_TEXT "Cancel"
|
|
||||||
|
|
||||||
#define INDEX_STATUS "_status"
|
|
||||||
|
|
||||||
enum status_messages {
|
|
||||||
STATUS = 128,
|
|
||||||
OK,
|
|
||||||
CANCEL
|
|
||||||
};
|
|
||||||
|
|
||||||
class TStatusView;
|
|
||||||
|
|
||||||
//====================================================================
|
|
||||||
|
|
||||||
class TStatusWindow : public BWindow
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
TStatusWindow(BRect, BWindow *, const char *status);
|
TStatusWindow(BRect frame, BMessenger target, const char* status);
|
||||||
|
virtual ~TStatusWindow();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TStatusView *fView;
|
bool _Exists(const char* status);
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
BMessenger fTarget;
|
||||||
|
BTextControl* fStatus;
|
||||||
class TStatusView : public BBox
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TStatusView(BRect, BWindow *, const char *);
|
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
virtual void MessageReceived(BMessage *);
|
|
||||||
bool Exists(const char *);
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char *fString;
|
|
||||||
BTextControl *fStatus;
|
|
||||||
BWindow *fWindow;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // #ifndef _STATUS_H
|
#endif // #ifndef _STATUS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user