Mail: sizing/placing cleanup.
* Don't set a default fixed font size - just use the default fixed font. * The preferences and signature window no longer have a default size, and position, either. Instead, they are placed over the active window. * Fixed spacing in the preferences window. * Converted the signature window to use the layout API. * Minor cleanup.
This commit is contained in:
+50
-52
@@ -122,25 +122,22 @@ TMailApp::TMailApp()
|
|||||||
fPeopleGroups(fPeopleQueryList)
|
fPeopleGroups(fPeopleQueryList)
|
||||||
{
|
{
|
||||||
// set default values
|
// set default values
|
||||||
fContentFont.SetSize(12.0);
|
|
||||||
fAutoMarkRead = true;
|
fAutoMarkRead = true;
|
||||||
fSignature = (char*)malloc(strlen(B_TRANSLATE("None")) + 1);
|
fSignature = (char*)malloc(strlen(B_TRANSLATE("None")) + 1);
|
||||||
strcpy(fSignature, B_TRANSLATE("None"));
|
strcpy(fSignature, B_TRANSLATE("None"));
|
||||||
fReplyPreamble = strdup(B_TRANSLATE("%e wrote:\\n"));
|
fReplyPreamble = strdup(B_TRANSLATE("%e wrote:\\n"));
|
||||||
|
|
||||||
fMailWindowFrame.Set(0, 0, 0, 0);
|
fMailWindowFrame.Set(0, 0, 0, 0);
|
||||||
fSignatureWindowFrame.Set(6, TITLE_BAR_HEIGHT, 6 + kSigWidth,
|
|
||||||
TITLE_BAR_HEIGHT + kSigHeight);
|
|
||||||
fPrefsWindowPos.Set(6, TITLE_BAR_HEIGHT);
|
|
||||||
|
|
||||||
const BCharacterSet *defaultComposeEncoding =
|
const BCharacterSet* defaultComposeEncoding
|
||||||
BCharacterSetRoster::FindCharacterSetByName(
|
= BCharacterSetRoster::FindCharacterSetByName(B_TRANSLATE_COMMENT(
|
||||||
B_TRANSLATE_COMMENT("UTF-8", "This string is used as a key to set "
|
"UTF-8", "This string is used as a key to set default message "
|
||||||
"default message compose encoding. It must be correct IANA name from "
|
"compose encoding. It must be correct IANA name from "
|
||||||
"http://cgit.haiku-os.org/haiku/tree/src/kits/textencoding"
|
"http://cgit.haiku-os.org/haiku/tree/src/kits/textencoding"
|
||||||
"/character_sets.cpp Translate it only if you want to change default "
|
"/character_sets.cpp Translate it only if you want to change "
|
||||||
"message compose encoding for your locale. If you don't know what is "
|
"default message compose encoding for your locale. If you don't "
|
||||||
"it and why it may needs changing, just leave \"UTF-8\"."));
|
"know what is it and why it may needs changing, just leave "
|
||||||
|
"\"UTF-8\"."));
|
||||||
if (defaultComposeEncoding != NULL)
|
if (defaultComposeEncoding != NULL)
|
||||||
fMailCharacterSet = defaultComposeEncoding->GetConversionID();
|
fMailCharacterSet = defaultComposeEncoding->GetConversionID();
|
||||||
|
|
||||||
@@ -325,15 +322,21 @@ TMailApp::MessageReceived(BMessage *msg)
|
|||||||
if (fPrefsWindow)
|
if (fPrefsWindow)
|
||||||
fPrefsWindow->Activate(true);
|
fPrefsWindow->Activate(true);
|
||||||
else {
|
else {
|
||||||
fPrefsWindow = new TPrefsWindow(BRect(fPrefsWindowPos.x,
|
fPrefsWindow = new TPrefsWindow(fPrefsWindowPos,
|
||||||
fPrefsWindowPos.y, fPrefsWindowPos.x + PREF_WIDTH,
|
|
||||||
fPrefsWindowPos.y + PREF_HEIGHT),
|
|
||||||
&fContentFont, NULL, &fWrapMode, &fAttachAttributes,
|
&fContentFont, NULL, &fWrapMode, &fAttachAttributes,
|
||||||
&fColoredQuotes, &fDefaultAccount, &fUseAccountFrom,
|
&fColoredQuotes, &fDefaultAccount, &fUseAccountFrom,
|
||||||
&fReplyPreamble, &fSignature, &fMailCharacterSet,
|
&fReplyPreamble, &fSignature, &fMailCharacterSet,
|
||||||
&fWarnAboutUnencodableCharacters,
|
&fWarnAboutUnencodableCharacters,
|
||||||
&fStartWithSpellCheckOn, &fAutoMarkRead,
|
&fStartWithSpellCheckOn, &fAutoMarkRead,
|
||||||
&fShowToolBar);
|
&fShowToolBar);
|
||||||
|
if (fPrefsWindowPos.x <= 0 || fPrefsWindowPos.y <= 0) {
|
||||||
|
TMailWindow* window = _ActiveWindow();
|
||||||
|
if (window != NULL)
|
||||||
|
fPrefsWindow->CenterIn(window->Frame());
|
||||||
|
else
|
||||||
|
fPrefsWindow->CenterOnScreen();
|
||||||
|
}
|
||||||
|
fPrefsWindow->MoveOnScreen();
|
||||||
fPrefsWindow->Show();
|
fPrefsWindow->Show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -341,10 +344,8 @@ TMailApp::MessageReceived(BMessage *msg)
|
|||||||
case PREFS_CHANGED:
|
case PREFS_CHANGED:
|
||||||
{
|
{
|
||||||
// Notify all Mail windows
|
// Notify all Mail windows
|
||||||
TMailWindow *window;
|
for (int32 i = 0; i < fWindowList.CountItems(); i++) {
|
||||||
for (int32 i = 0; (window=(TMailWindow *)fWindowList.ItemAt(i))
|
TMailWindow* window = (TMailWindow*)fWindowList.ItemAt(i);
|
||||||
!= NULL; i++)
|
|
||||||
{
|
|
||||||
window->Lock();
|
window->Lock();
|
||||||
window->UpdatePreferences();
|
window->UpdatePreferences();
|
||||||
window->UpdateViews();
|
window->UpdateViews();
|
||||||
@@ -358,10 +359,18 @@ TMailApp::MessageReceived(BMessage *msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case M_EDIT_SIGNATURE:
|
case M_EDIT_SIGNATURE:
|
||||||
if (fSigWindow)
|
if (fSigWindow != NULL)
|
||||||
fSigWindow->Activate(true);
|
fSigWindow->Activate(true);
|
||||||
else {
|
else {
|
||||||
fSigWindow = new TSignatureWindow(fSignatureWindowFrame);
|
fSigWindow = new TSignatureWindow(fSignatureWindowFrame);
|
||||||
|
if (!fSignatureWindowFrame.IsValid()) {
|
||||||
|
TMailWindow* window = _ActiveWindow();
|
||||||
|
if (window != NULL)
|
||||||
|
fSigWindow->CenterIn(window->Frame());
|
||||||
|
else
|
||||||
|
fSigWindow->CenterOnScreen();
|
||||||
|
}
|
||||||
|
fSigWindow->MoveOnScreen();
|
||||||
fSigWindow->Show();
|
fSigWindow->Show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -372,7 +381,7 @@ TMailApp::MessageReceived(BMessage *msg)
|
|||||||
|
|
||||||
case REFS_RECEIVED:
|
case REFS_RECEIVED:
|
||||||
if (msg->HasPointer("window")) {
|
if (msg->HasPointer("window")) {
|
||||||
msg->FindPointer("window", (void **)&window);
|
msg->FindPointer("window", (void**)&window);
|
||||||
BMessage message(*msg);
|
BMessage message(*msg);
|
||||||
window->PostMessage(&message, window);
|
window->PostMessage(&message, window);
|
||||||
}
|
}
|
||||||
@@ -382,8 +391,8 @@ TMailApp::MessageReceived(BMessage *msg)
|
|||||||
switch (msg->FindInt32("kind")) {
|
switch (msg->FindInt32("kind")) {
|
||||||
case MAIL_WINDOW:
|
case MAIL_WINDOW:
|
||||||
{
|
{
|
||||||
TMailWindow *window;
|
TMailWindow* window;
|
||||||
if( msg->FindPointer( "window", (void **)&window ) == B_OK )
|
if( msg->FindPointer("window", (void**)&window) == B_OK)
|
||||||
fWindowList.RemoveItem(window);
|
fWindowList.RemoveItem(window);
|
||||||
fWindowCount--;
|
fWindowCount--;
|
||||||
break;
|
break;
|
||||||
@@ -739,6 +748,18 @@ TMailApp::_CheckForSpamFilterExistence()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TMailWindow*
|
||||||
|
TMailApp::_ActiveWindow()
|
||||||
|
{
|
||||||
|
for (int32 i = 0; i < fWindowList.CountItems(); i++) {
|
||||||
|
TMailWindow* window = (TMailWindow*)fWindowList.ItemAt(i);
|
||||||
|
if (window->IsActive())
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TMailApp::SetPrintSettings(const BMessage* printSettings)
|
TMailApp::SetPrintSettings(const BMessage* printSettings)
|
||||||
{
|
{
|
||||||
@@ -1091,42 +1112,18 @@ TMailWindow*
|
|||||||
TMailApp::NewWindow(const entry_ref* ref, const char* to, bool resend,
|
TMailApp::NewWindow(const entry_ref* ref, const char* to, bool resend,
|
||||||
BMessenger* trackerMessenger)
|
BMessenger* trackerMessenger)
|
||||||
{
|
{
|
||||||
BScreen screen(B_MAIN_SCREEN_ID);
|
float fontFactor = be_plain_font->Size() / 12.0f;
|
||||||
BRect screenFrame = screen.Frame();
|
|
||||||
|
|
||||||
BRect r;
|
BRect r;
|
||||||
if (fMailWindowFrame.Width() < 64 || fMailWindowFrame.Height() < 20) {
|
if (fMailWindowFrame.Width() < 64 || fMailWindowFrame.Height() < 20) {
|
||||||
// default size
|
// default size
|
||||||
r.Set(6, TITLE_BAR_HEIGHT, 6 + WIND_WIDTH,
|
r.Set(40 * fontFactor, 40 * fontFactor, fontFactor * (40 + WIND_WIDTH),
|
||||||
TITLE_BAR_HEIGHT + WIND_HEIGHT);
|
fontFactor * (40 + WIND_HEIGHT));
|
||||||
} else
|
} else
|
||||||
r = fMailWindowFrame;
|
r = fMailWindowFrame;
|
||||||
|
|
||||||
// make sure the window is not larger than the screen space
|
|
||||||
if (r.Height() > screenFrame.Height())
|
|
||||||
r.bottom = r.top + screenFrame.Height();
|
|
||||||
if (r.Width() > screenFrame.Width())
|
|
||||||
r.bottom = r.top + screenFrame.Width();
|
|
||||||
|
|
||||||
// cascading windows
|
// cascading windows
|
||||||
r.OffsetBy(((fWindowCount + 5) % 10) * 15 - 75,
|
r.OffsetBy(fontFactor * (((fWindowCount + 5) % 10) * 15 - 75),
|
||||||
((fWindowCount + 5) % 10) * 15 - 75);
|
fontFactor * (((fWindowCount + 5) % 10) * 15 - 75));
|
||||||
|
|
||||||
// make sure the window is still on screen
|
|
||||||
if (r.left - 6 < screenFrame.left)
|
|
||||||
r.OffsetTo(screenFrame.left + 8, r.top);
|
|
||||||
|
|
||||||
if (r.left + 20 > screenFrame.right)
|
|
||||||
r.OffsetTo(6, r.top);
|
|
||||||
|
|
||||||
if (r.top - 26 < screenFrame.top)
|
|
||||||
r.OffsetTo(r.left, screenFrame.top + 26);
|
|
||||||
|
|
||||||
if (r.top + 20 > screenFrame.bottom)
|
|
||||||
r.OffsetTo(r.left, TITLE_BAR_HEIGHT);
|
|
||||||
|
|
||||||
if (r.Width() < WIND_WIDTH)
|
|
||||||
r.right = r.left + WIND_WIDTH;
|
|
||||||
|
|
||||||
fWindowCount++;
|
fWindowCount++;
|
||||||
|
|
||||||
@@ -1148,6 +1145,7 @@ TMailApp::NewWindow(const entry_ref* ref, const char* to, bool resend,
|
|||||||
&fContentFont, resend, trackerMessenger);
|
&fContentFont, resend, trackerMessenger);
|
||||||
fWindowList.AddItem(window);
|
fWindowList.AddItem(window);
|
||||||
|
|
||||||
|
window->MoveOnScreen();
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ class TMailApp : public BApplication {
|
|||||||
private:
|
private:
|
||||||
void _ClearPrintSettings();
|
void _ClearPrintSettings();
|
||||||
void _CheckForSpamFilterExistence();
|
void _CheckForSpamFilterExistence();
|
||||||
|
TMailWindow* _ActiveWindow();
|
||||||
|
|
||||||
status_t GetSettingsPath(BPath &path);
|
status_t GetSettingsPath(BPath &path);
|
||||||
status_t LoadOldSettings();
|
status_t LoadOldSettings();
|
||||||
|
|||||||
@@ -39,10 +39,8 @@ All rights reserved.
|
|||||||
|
|
||||||
|
|
||||||
#define MAX_DICTIONARIES 8
|
#define MAX_DICTIONARIES 8
|
||||||
#define TITLE_BAR_HEIGHT 25
|
|
||||||
#define WIND_WIDTH 457
|
#define WIND_WIDTH 457
|
||||||
#define WIND_HEIGHT 400
|
#define WIND_HEIGHT 500
|
||||||
#define RIGHT_BOUNDARY 8191
|
|
||||||
#define SEPARATOR_MARGIN 7
|
#define SEPARATOR_MARGIN 7
|
||||||
#define QUOTE "> "
|
#define QUOTE "> "
|
||||||
|
|
||||||
|
|||||||
+24
-33
@@ -64,26 +64,14 @@ using namespace BPrivate;
|
|||||||
|
|
||||||
#define B_TRANSLATION_CONTEXT "Mail"
|
#define B_TRANSLATION_CONTEXT "Mail"
|
||||||
|
|
||||||
#define BUTTON_WIDTH 70
|
enum P_MESSAGES {
|
||||||
#define BUTTON_HEIGHT 20
|
P_OK = 128, P_CANCEL, P_REVERT, P_FONT,
|
||||||
#define ITEM_SPACE 6
|
P_SIZE, P_LEVEL, P_WRAP, P_ATTACH_ATTRIBUTES,
|
||||||
|
P_SIG, P_ENC, P_WARN_UNENCODABLE,
|
||||||
#define OK_BUTTON_X1 (PREF_WIDTH - BUTTON_WIDTH - 6)
|
P_SPELL_CHECK_START_ON, P_BUTTON_BAR,
|
||||||
#define OK_BUTTON_X2 (OK_BUTTON_X1 + BUTTON_WIDTH)
|
P_ACCOUNT, P_REPLYTO, P_REPLY_PREAMBLE,
|
||||||
|
P_COLORED_QUOTES, P_MARK_READ
|
||||||
#define REVERT_BUTTON_X1 8
|
};
|
||||||
#define REVERT_BUTTON_X2 (REVERT_BUTTON_X1 + BUTTON_WIDTH)
|
|
||||||
|
|
||||||
enum P_MESSAGES {P_OK = 128, P_CANCEL, P_REVERT, P_FONT,
|
|
||||||
P_SIZE, P_LEVEL, P_WRAP, P_ATTACH_ATTRIBUTES,
|
|
||||||
P_SIG, P_ENC, P_WARN_UNENCODABLE,
|
|
||||||
P_SPELL_CHECK_START_ON, P_BUTTON_BAR,
|
|
||||||
P_ACCOUNT, P_REPLYTO, P_REPLY_PREAMBLE,
|
|
||||||
P_COLORED_QUOTES, P_MARK_READ};
|
|
||||||
|
|
||||||
extern BPoint prefs_window;
|
|
||||||
|
|
||||||
//#pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@@ -96,12 +84,17 @@ add_menu_to_layout(BMenuField* menu, BGridLayout* layout, int32& row)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TPrefsWindow::TPrefsWindow(BRect rect, BFont* font, int32* level, bool* wrap,
|
// #pragma mark -
|
||||||
bool* attachAttributes, bool* cquotes, int32* account, int32* replyTo,
|
|
||||||
char** preamble, char** sig, uint32* encoding, bool* warnUnencodable,
|
|
||||||
bool* spellCheckStartOn, bool* autoMarkRead, uint8* buttonBar)
|
TPrefsWindow::TPrefsWindow(BPoint leftTop, BFont* font, int32* level,
|
||||||
|
bool* wrap, bool* attachAttributes, bool* cquotes, int32* account,
|
||||||
|
int32* replyTo, char** preamble, char** sig, uint32* encoding,
|
||||||
|
bool* warnUnencodable, bool* spellCheckStartOn, bool* autoMarkRead,
|
||||||
|
uint8* buttonBar)
|
||||||
:
|
:
|
||||||
BWindow(rect, B_TRANSLATE("Mail preferences"),
|
BWindow(BRect(leftTop.x, leftTop.y, leftTop.x + 100, leftTop.y + 100),
|
||||||
|
B_TRANSLATE("Mail preferences"),
|
||||||
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
|
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
|
||||||
| B_AUTO_UPDATE_SIZE_LIMITS),
|
| B_AUTO_UPDATE_SIZE_LIMITS),
|
||||||
|
|
||||||
@@ -149,16 +142,14 @@ TPrefsWindow::TPrefsWindow(BRect rect, BFont* font, int32* level, bool* wrap,
|
|||||||
|
|
||||||
// group boxes
|
// group boxes
|
||||||
|
|
||||||
const float kSpacing = 8;
|
BGridView* interfaceView = new BGridView();
|
||||||
|
|
||||||
BGridView* interfaceView = new BGridView(kSpacing, kSpacing);
|
|
||||||
BGridLayout* interfaceLayout = interfaceView->GridLayout();
|
BGridLayout* interfaceLayout = interfaceView->GridLayout();
|
||||||
interfaceLayout->SetInsets(kSpacing, kSpacing, kSpacing, kSpacing);
|
BGridView* mailView = new BGridView();
|
||||||
BGridView* mailView = new BGridView(kSpacing, kSpacing);
|
|
||||||
BGridLayout* mailLayout = mailView->GridLayout();
|
BGridLayout* mailLayout = mailView->GridLayout();
|
||||||
mailLayout->SetInsets(kSpacing, kSpacing, kSpacing, kSpacing);
|
|
||||||
|
|
||||||
|
interfaceLayout->SetInsets(B_USE_DEFAULT_SPACING);
|
||||||
interfaceLayout->AlignLayoutWith(mailLayout, B_HORIZONTAL);
|
interfaceLayout->AlignLayoutWith(mailLayout, B_HORIZONTAL);
|
||||||
|
mailLayout->SetInsets(B_USE_DEFAULT_SPACING);
|
||||||
|
|
||||||
BBox* interfaceBox = new BBox(B_FANCY_BORDER, interfaceView);
|
BBox* interfaceBox = new BBox(B_FANCY_BORDER, interfaceView);
|
||||||
interfaceBox->SetLabel(B_TRANSLATE("User interface"));
|
interfaceBox->SetLabel(B_TRANSLATE("User interface"));
|
||||||
@@ -266,12 +257,12 @@ TPrefsWindow::TPrefsWindow(BRect rect, BFont* font, int32* level, bool* wrap,
|
|||||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||||
.Add(interfaceBox)
|
.Add(interfaceBox)
|
||||||
.Add(mailBox)
|
.Add(mailBox)
|
||||||
.AddGroup(B_HORIZONTAL, 0)
|
.AddGroup(B_HORIZONTAL)
|
||||||
.Add(fRevert)
|
.Add(fRevert)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.Add(cancelButton)
|
.Add(cancelButton)
|
||||||
.Add(okButton)
|
.Add(okButton)
|
||||||
.End()
|
.End()
|
||||||
.SetInsets(B_USE_WINDOW_SPACING);
|
.SetInsets(B_USE_WINDOW_SPACING);
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ class BTextControl;
|
|||||||
#define ACCOUNT_USE_DEFAULT 0
|
#define ACCOUNT_USE_DEFAULT 0
|
||||||
#define ACCOUNT_FROM_MAIL 1
|
#define ACCOUNT_FROM_MAIL 1
|
||||||
|
|
||||||
#define PREF_WIDTH 340
|
|
||||||
#define PREF_HEIGHT 330
|
|
||||||
|
|
||||||
struct EncodingItem {
|
struct EncodingItem {
|
||||||
char* name;
|
char* name;
|
||||||
@@ -60,7 +58,7 @@ extern const EncodingItem kEncodings[];
|
|||||||
|
|
||||||
class TPrefsWindow : public BWindow {
|
class TPrefsWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
TPrefsWindow(BRect rect, BFont* font,
|
TPrefsWindow(BPoint leftTop, BFont* font,
|
||||||
int32* level, bool* warp,
|
int32* level, bool* warp,
|
||||||
bool* attachAttributes, bool* cquotes,
|
bool* attachAttributes, bool* cquotes,
|
||||||
int32* account, int32* replyTo,
|
int32* account, int32* replyTo,
|
||||||
@@ -91,7 +89,7 @@ private:
|
|||||||
BPopUpMenu* _BuildAutoMarkReadMenu(
|
BPopUpMenu* _BuildAutoMarkReadMenu(
|
||||||
bool autoMarkRead);
|
bool autoMarkRead);
|
||||||
BPopUpMenu* _BuildButtonBarMenu(uint8 show);
|
BPopUpMenu* _BuildButtonBarMenu(uint8 show);
|
||||||
|
|
||||||
BPopUpMenu* _BuildBoolMenu(uint32 msg,
|
BPopUpMenu* _BuildBoolMenu(uint32 msg,
|
||||||
const char* boolItem, bool isTrue);
|
const char* boolItem, bool isTrue);
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ Settings::Settings()
|
|||||||
fMailCharacterSet(B_MS_WINDOWS_CONVERSION),
|
fMailCharacterSet(B_MS_WINDOWS_CONVERSION),
|
||||||
fContentFont(be_fixed_font)
|
fContentFont(be_fixed_font)
|
||||||
{
|
{
|
||||||
fContentFont.SetSize(12.0);
|
|
||||||
fSignature = B_TRANSLATE("None");
|
fSignature = B_TRANSLATE("None");
|
||||||
|
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
|
|||||||
+112
-150
@@ -32,6 +32,7 @@ countries. Other brand product names are registered trademarks or trademarks
|
|||||||
of their respective holders. All rights reserved.
|
of their respective holders. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "Signature.h"
|
#include "Signature.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -39,9 +40,11 @@ of their respective holders. All rights reserved.
|
|||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
|
||||||
#include <Clipboard.h>
|
#include <Clipboard.h>
|
||||||
#include <InterfaceKit.h>
|
#include <Directory.h>
|
||||||
|
#include <LayoutBuilder.h>
|
||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
#include <StorageKit.h>
|
#include <ScrollView.h>
|
||||||
|
#include <StringView.h>
|
||||||
|
|
||||||
#include "MailApp.h"
|
#include "MailApp.h"
|
||||||
#include "MailPopUpMenu.h"
|
#include "MailPopUpMenu.h"
|
||||||
@@ -53,24 +56,24 @@ of their respective holders. All rights reserved.
|
|||||||
#define B_TRANSLATION_CONTEXT "Mail"
|
#define B_TRANSLATION_CONTEXT "Mail"
|
||||||
|
|
||||||
|
|
||||||
extern BRect signature_window;
|
const float kSigHeight = 250;
|
||||||
extern const char *kUndoStrings[];
|
const float kSigWidth = 300;
|
||||||
extern const char *kRedoStrings[];
|
|
||||||
|
extern const char* kUndoStrings[];
|
||||||
|
extern const char* kRedoStrings[];
|
||||||
|
|
||||||
|
|
||||||
TSignatureWindow::TSignatureWindow(BRect rect)
|
TSignatureWindow::TSignatureWindow(BRect rect)
|
||||||
:
|
:
|
||||||
BWindow (rect, B_TRANSLATE("Signatures"), B_TITLED_WINDOW, 0),
|
BWindow(rect, B_TRANSLATE("Signatures"), B_TITLED_WINDOW,
|
||||||
|
B_AUTO_UPDATE_SIZE_LIMITS),
|
||||||
fFile(NULL)
|
fFile(NULL)
|
||||||
{
|
{
|
||||||
BMenu *menu;
|
BMenuItem* item;
|
||||||
BMenuBar *menu_bar;
|
|
||||||
BMenuItem *item;
|
|
||||||
|
|
||||||
BRect r = Bounds();
|
// Set up the menu
|
||||||
/*** Set up the menus ****/
|
BMenuBar* menuBar = new BMenuBar("MenuBar");
|
||||||
menu_bar = new BMenuBar(r, "MenuBar");
|
BMenu* menu = new BMenu(B_TRANSLATE("Signature"));
|
||||||
menu = new BMenu(B_TRANSLATE("Signature"));
|
|
||||||
menu->AddItem(fNew = new BMenuItem(B_TRANSLATE("New"),
|
menu->AddItem(fNew = new BMenuItem(B_TRANSLATE("New"),
|
||||||
new BMessage(M_NEW), 'N'));
|
new BMessage(M_NEW), 'N'));
|
||||||
fSignature = new TMenu(B_TRANSLATE("Open"), INDEX_SIGNATURE, M_SIGNATURE);
|
fSignature = new TMenu(B_TRANSLATE("Open"), INDEX_SIGNATURE, M_SIGNATURE);
|
||||||
@@ -80,7 +83,7 @@ TSignatureWindow::TSignatureWindow(BRect rect)
|
|||||||
new BMessage(M_SAVE), 'S'));
|
new BMessage(M_SAVE), 'S'));
|
||||||
menu->AddItem(fDelete = new BMenuItem(B_TRANSLATE("Delete"),
|
menu->AddItem(fDelete = new BMenuItem(B_TRANSLATE("Delete"),
|
||||||
new BMessage(M_DELETE), 'T'));
|
new BMessage(M_DELETE), 'T'));
|
||||||
menu_bar->AddItem(menu);
|
menuBar->AddItem(menu);
|
||||||
|
|
||||||
menu = new BMenu(B_TRANSLATE("Edit"));
|
menu = new BMenu(B_TRANSLATE("Edit"));
|
||||||
menu->AddItem(fUndo = new BMenuItem(B_TRANSLATE("Undo"),
|
menu->AddItem(fUndo = new BMenuItem(B_TRANSLATE("Undo"),
|
||||||
@@ -100,22 +103,20 @@ TSignatureWindow::TSignatureWindow(BRect rect)
|
|||||||
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Select all"),
|
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Select all"),
|
||||||
new BMessage(M_SELECT), 'A'));
|
new BMessage(M_SELECT), 'A'));
|
||||||
item->SetTarget(NULL, this);
|
item->SetTarget(NULL, this);
|
||||||
menu_bar->AddItem(menu);
|
menuBar->AddItem(menu);
|
||||||
|
|
||||||
AddChild(menu_bar);
|
fSigView = new TSignatureView();
|
||||||
/**** Done with the menu set up *****/
|
|
||||||
|
|
||||||
/**** Add on the panel, giving it the width and at least one vertical pixel *****/
|
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
||||||
fSigView = new TSignatureView(BRect(0, menu_bar->Frame().bottom+1,
|
.Add(menuBar)
|
||||||
rect.Width(), menu_bar->Frame().bottom+2));
|
.Add(fSigView);
|
||||||
AddChild(fSigView);
|
|
||||||
|
|
||||||
/* resize the window to the correct height */
|
if (!rect.IsValid()) {
|
||||||
fSigView->SetResizingMode(B_FOLLOW_NONE);
|
float fontFactor = be_plain_font->Size() / 12.0f;
|
||||||
ResizeTo(rect.Width()-2, fSigView->Frame().bottom-2);
|
ResizeTo(kSigWidth * fontFactor, kSigHeight * fontFactor);
|
||||||
fSigView->SetResizingMode(B_FOLLOW_ALL);
|
// TODO: this should work, too, but doesn't
|
||||||
|
//ResizeToPreferred();
|
||||||
SetSizeLimits(kSigWidth, RIGHT_BOUNDARY, r.top + 100, RIGHT_BOUNDARY);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -127,37 +128,37 @@ TSignatureWindow::~TSignatureWindow()
|
|||||||
void
|
void
|
||||||
TSignatureWindow::MenusBeginning()
|
TSignatureWindow::MenusBeginning()
|
||||||
{
|
{
|
||||||
int32 finish = 0;
|
|
||||||
int32 start = 0;
|
|
||||||
BTextView *text_view;
|
|
||||||
|
|
||||||
fDelete->SetEnabled(fFile);
|
fDelete->SetEnabled(fFile);
|
||||||
fSave->SetEnabled(IsDirty());
|
fSave->SetEnabled(IsDirty());
|
||||||
fUndo->SetEnabled(false); // ***TODO***
|
fUndo->SetEnabled(false); // ***TODO***
|
||||||
|
|
||||||
text_view = (BTextView *)fSigView->fName->ChildAt(0);
|
BTextView* textView = fSigView->fName->TextView();
|
||||||
if (text_view->IsFocus())
|
int32 finish = 0;
|
||||||
text_view->GetSelection(&start, &finish);
|
int32 start = 0;
|
||||||
|
if (textView->IsFocus())
|
||||||
|
textView->GetSelection(&start, &finish);
|
||||||
else
|
else
|
||||||
fSigView->fTextView->GetSelection(&start, &finish);
|
fSigView->fTextView->GetSelection(&start, &finish);
|
||||||
|
|
||||||
fCut->SetEnabled(start != finish);
|
fCut->SetEnabled(start != finish);
|
||||||
fCopy->SetEnabled(start != finish);
|
fCopy->SetEnabled(start != finish);
|
||||||
|
|
||||||
fNew->SetEnabled(text_view->TextLength() | fSigView->fTextView->TextLength());
|
fNew->SetEnabled(textView->TextLength()
|
||||||
|
| fSigView->fTextView->TextLength());
|
||||||
be_clipboard->Lock();
|
be_clipboard->Lock();
|
||||||
fPaste->SetEnabled(be_clipboard->Data()->HasData("text/plain", B_MIME_TYPE));
|
fPaste->SetEnabled(be_clipboard->Data()->HasData("text/plain",
|
||||||
|
B_MIME_TYPE));
|
||||||
be_clipboard->Unlock();
|
be_clipboard->Unlock();
|
||||||
|
|
||||||
// Undo stuff
|
// Undo stuff
|
||||||
bool isRedo = false;
|
bool isRedo = false;
|
||||||
undo_state undoState = B_UNDO_UNAVAILABLE;
|
undo_state undoState = B_UNDO_UNAVAILABLE;
|
||||||
|
|
||||||
BTextView *focusTextView = dynamic_cast<BTextView *>(CurrentFocus());
|
BTextView *focusTextView = dynamic_cast<BTextView *>(CurrentFocus());
|
||||||
if (focusTextView != NULL)
|
if (focusTextView != NULL)
|
||||||
undoState = focusTextView->UndoState(&isRedo);
|
undoState = focusTextView->UndoState(&isRedo);
|
||||||
|
|
||||||
fUndo->SetLabel((isRedo) ? kRedoStrings[undoState] : kUndoStrings[undoState]);
|
fUndo->SetLabel(isRedo ? kRedoStrings[undoState] : kUndoStrings[undoState]);
|
||||||
fUndo->SetEnabled(undoState != B_UNDO_UNAVAILABLE);
|
fUndo->SetEnabled(undoState != B_UNDO_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,24 +166,19 @@ TSignatureWindow::MenusBeginning()
|
|||||||
void
|
void
|
||||||
TSignatureWindow::MessageReceived(BMessage* msg)
|
TSignatureWindow::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
char *sig;
|
switch (msg->what) {
|
||||||
char name[B_FILE_NAME_LENGTH];
|
|
||||||
BFont *font;
|
|
||||||
BTextView *text_view;
|
|
||||||
entry_ref ref;
|
|
||||||
off_t size;
|
|
||||||
|
|
||||||
switch(msg->what) {
|
|
||||||
case CHANGE_FONT:
|
case CHANGE_FONT:
|
||||||
|
{
|
||||||
|
BFont* font;
|
||||||
msg->FindPointer("font", (void **)&font);
|
msg->FindPointer("font", (void **)&font);
|
||||||
fSigView->fTextView->SetFontAndColor(font);
|
fSigView->fTextView->SetFontAndColor(font);
|
||||||
fSigView->fTextView->Invalidate(fSigView->fTextView->Bounds());
|
fSigView->fTextView->Invalidate(fSigView->fTextView->Bounds());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case M_NEW:
|
case M_NEW:
|
||||||
if (Clear()) {
|
if (Clear()) {
|
||||||
fSigView->fName->SetText("");
|
fSigView->fName->SetText("");
|
||||||
// fSigView->fTextView->SetText(NULL, (int32)0);
|
|
||||||
fSigView->fTextView->SetText("");
|
fSigView->fTextView->SetText("");
|
||||||
fSigView->fName->MakeFocus(true);
|
fSigView->fName->MakeFocus(true);
|
||||||
}
|
}
|
||||||
@@ -201,7 +197,7 @@ TSignatureWindow::MessageReceived(BMessage* msg)
|
|||||||
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
alert->SetShortcut(0, B_ESCAPE);
|
alert->SetShortcut(0, B_ESCAPE);
|
||||||
int32 choice = alert->Go();
|
int32 choice = alert->Go();
|
||||||
|
|
||||||
if (choice == 0)
|
if (choice == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -217,22 +213,29 @@ TSignatureWindow::MessageReceived(BMessage* msg)
|
|||||||
}
|
}
|
||||||
case M_SIGNATURE:
|
case M_SIGNATURE:
|
||||||
if (Clear()) {
|
if (Clear()) {
|
||||||
|
entry_ref ref;
|
||||||
msg->FindRef("ref", &ref);
|
msg->FindRef("ref", &ref);
|
||||||
fEntry.SetTo(&ref);
|
fEntry.SetTo(&ref);
|
||||||
fFile = new BFile(&ref, O_RDWR);
|
fFile = new BFile(&ref, O_RDWR);
|
||||||
if (fFile->InitCheck() == B_NO_ERROR) {
|
if (fFile->InitCheck() == B_OK) {
|
||||||
fFile->ReadAttr(INDEX_SIGNATURE, B_STRING_TYPE, 0, name, sizeof(name));
|
char name[B_FILE_NAME_LENGTH];
|
||||||
|
fFile->ReadAttr(INDEX_SIGNATURE, B_STRING_TYPE, 0, name,
|
||||||
|
sizeof(name));
|
||||||
fSigView->fName->SetText(name);
|
fSigView->fName->SetText(name);
|
||||||
|
|
||||||
|
off_t size;
|
||||||
fFile->GetSize(&size);
|
fFile->GetSize(&size);
|
||||||
sig = (char *)malloc(size);
|
char* sig = (char*)malloc(size);
|
||||||
|
if (sig == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
size = fFile->Read(sig, size);
|
size = fFile->Read(sig, size);
|
||||||
fSigView->fTextView->SetText(sig, size);
|
fSigView->fTextView->SetText(sig, size);
|
||||||
fSigView->fName->MakeFocus(true);
|
fSigView->fName->MakeFocus(true);
|
||||||
text_view = (BTextView *)fSigView->fName->ChildAt(0);
|
BTextView* textView = fSigView->fName->TextView();
|
||||||
text_view->Select(0, text_view->TextLength());
|
textView->Select(0, textView->TextLength());
|
||||||
fSigView->fTextView->fDirty = false;
|
fSigView->fTextView->fDirty = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
fFile = NULL;
|
fFile = NULL;
|
||||||
beep();
|
beep();
|
||||||
BAlert* alert = new BAlert("",
|
BAlert* alert = new BAlert("",
|
||||||
@@ -275,12 +278,10 @@ TSignatureWindow::FrameResized(float width, float height)
|
|||||||
void
|
void
|
||||||
TSignatureWindow::Show()
|
TSignatureWindow::Show()
|
||||||
{
|
{
|
||||||
BTextView *text_view;
|
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
text_view = (BTextView *)fSigView->fName->TextView();
|
BTextView* textView = (BTextView *)fSigView->fName->TextView();
|
||||||
fSigView->fName->MakeFocus(true);
|
fSigView->fName->MakeFocus(true);
|
||||||
text_view->Select(0, text_view->TextLength());
|
textView->Select(0, textView->TextLength());
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
BWindow::Show();
|
BWindow::Show();
|
||||||
@@ -290,8 +291,6 @@ TSignatureWindow::Show()
|
|||||||
bool
|
bool
|
||||||
TSignatureWindow::Clear()
|
TSignatureWindow::Clear()
|
||||||
{
|
{
|
||||||
int32 result;
|
|
||||||
|
|
||||||
if (IsDirty()) {
|
if (IsDirty()) {
|
||||||
beep();
|
beep();
|
||||||
BAlert *alert = new BAlert("",
|
BAlert *alert = new BAlert("",
|
||||||
@@ -303,7 +302,7 @@ TSignatureWindow::Clear()
|
|||||||
alert->SetShortcut(0, B_ESCAPE);
|
alert->SetShortcut(0, B_ESCAPE);
|
||||||
alert->SetShortcut(1, 'd');
|
alert->SetShortcut(1, 'd');
|
||||||
alert->SetShortcut(2, 's');
|
alert->SetShortcut(2, 's');
|
||||||
result = alert->Go();
|
int32 result = alert->Go();
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
return false;
|
return false;
|
||||||
if (result == 2)
|
if (result == 2)
|
||||||
@@ -320,17 +319,16 @@ TSignatureWindow::Clear()
|
|||||||
bool
|
bool
|
||||||
TSignatureWindow::IsDirty()
|
TSignatureWindow::IsDirty()
|
||||||
{
|
{
|
||||||
char name[B_FILE_NAME_LENGTH];
|
if (fFile != NULL) {
|
||||||
|
char name[B_FILE_NAME_LENGTH];
|
||||||
if (fFile) {
|
|
||||||
fFile->ReadAttr(INDEX_SIGNATURE, B_STRING_TYPE, 0, name, sizeof(name));
|
fFile->ReadAttr(INDEX_SIGNATURE, B_STRING_TYPE, 0, name, sizeof(name));
|
||||||
if ((strcmp(name, fSigView->fName->Text())) || (fSigView->fTextView->fDirty))
|
if (strcmp(name, fSigView->fName->Text()) != 0
|
||||||
return true;
|
|| fSigView->fTextView->fDirty) {
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ((strlen(fSigView->fName->Text())) ||
|
|
||||||
(fSigView->fTextView->TextLength()))
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
} else if (fSigView->fName->Text()[0] != '\0'
|
||||||
|
|| fSigView->fTextView->TextLength() != 0) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -400,83 +398,57 @@ err_exit:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//====================================================================
|
// #pragma mark -
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
TSignatureView::TSignatureView(BRect rect)
|
TSignatureView::TSignatureView()
|
||||||
: BBox(rect, "SigView", B_FOLLOW_ALL, B_WILL_DRAW)
|
:
|
||||||
|
BGridView("SigView")
|
||||||
{
|
{
|
||||||
|
GridLayout()->SetInsets(B_USE_DEFAULT_SPACING);
|
||||||
|
|
||||||
|
BStringView* nameLabel = new BStringView("NameLabel",
|
||||||
|
B_TRANSLATE("Title:"));
|
||||||
|
nameLabel->SetAlignment(B_ALIGN_RIGHT);
|
||||||
|
GridLayout()->AddView(nameLabel, 0, 0);
|
||||||
|
|
||||||
|
fName = new TNameControl("", new BMessage(NAME_FIELD));
|
||||||
|
GridLayout()->AddItem(fName->CreateTextViewLayoutItem(), 1, 0);
|
||||||
|
|
||||||
|
BStringView* signatureLabel = new BStringView("SigLabel",
|
||||||
|
B_TRANSLATE("Signature:"));
|
||||||
|
signatureLabel->SetAlignment(B_ALIGN_RIGHT);
|
||||||
|
GridLayout()->AddView(signatureLabel, 0, 1);
|
||||||
|
|
||||||
|
fTextView = new TSigTextView();
|
||||||
|
|
||||||
|
font_height fontHeight;
|
||||||
|
fTextView->GetFontHeight(&fontHeight);
|
||||||
|
float lineHeight = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent);
|
||||||
|
|
||||||
|
BScrollView* scroller = new BScrollView("SigScroller", fTextView, 0,
|
||||||
|
false, true);
|
||||||
|
scroller->SetExplicitPreferredSize(
|
||||||
|
BSize(fTextView->StringWidth("W") * 30, lineHeight * 6));
|
||||||
|
|
||||||
|
GridLayout()->AddView(scroller, 1, 1, 1, 2);
|
||||||
|
|
||||||
|
GridLayout()->AddItem(BSpaceLayoutItem::CreateGlue(), 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TSignatureView::AttachedToWindow()
|
TSignatureView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
BRect rect = Bounds();
|
|
||||||
float name_text_length = StringWidth(B_TRANSLATE("Title:"));
|
|
||||||
float sig_text_length = StringWidth(B_TRANSLATE("Signature:"));
|
|
||||||
float divide_length;
|
|
||||||
|
|
||||||
if (name_text_length > sig_text_length)
|
|
||||||
divide_length = name_text_length;
|
|
||||||
else
|
|
||||||
divide_length = sig_text_length;
|
|
||||||
|
|
||||||
rect.InsetBy(8,0);
|
|
||||||
rect.top+= 8;
|
|
||||||
|
|
||||||
fName = new TNameControl(rect, B_TRANSLATE("Title:"),
|
|
||||||
new BMessage(NAME_FIELD));
|
|
||||||
AddChild(fName);
|
|
||||||
|
|
||||||
fName->SetDivider(divide_length + 10);
|
|
||||||
fName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
|
|
||||||
|
|
||||||
rect.OffsetBy(0,fName->Bounds().Height()+5);
|
|
||||||
rect.bottom = rect.top + kSigHeight;
|
|
||||||
rect.left = fName->TextView()->Frame().left;
|
|
||||||
|
|
||||||
BRect text = rect;
|
|
||||||
text.OffsetTo(10,0);
|
|
||||||
fTextView = new TSigTextView(rect, text);
|
|
||||||
BScrollView *scroller = new BScrollView("SigScroller", fTextView, B_FOLLOW_ALL, 0, false, true);
|
|
||||||
AddChild(scroller);
|
|
||||||
scroller->ResizeBy(-1 * scroller->ScrollBar(B_VERTICAL)->Frame().Width() - 9, 0);
|
|
||||||
scroller->MoveBy(7,0);
|
|
||||||
|
|
||||||
/* back up a bit to make room for the label */
|
|
||||||
|
|
||||||
rect = scroller->Frame();
|
|
||||||
BStringView *stringView = new BStringView(rect, "SigLabel",
|
|
||||||
B_TRANSLATE("Signature:"));
|
|
||||||
AddChild(stringView);
|
|
||||||
|
|
||||||
float tWidth, tHeight;
|
|
||||||
stringView->GetPreferredSize(&tWidth, &tHeight);
|
|
||||||
|
|
||||||
/* the 5 is for the spacer in the TextView */
|
|
||||||
|
|
||||||
rect.OffsetBy(-1 *(tWidth) - 5, 0);
|
|
||||||
rect.right = rect.left + tWidth;
|
|
||||||
rect.bottom = rect.top + tHeight;
|
|
||||||
|
|
||||||
stringView->MoveTo(rect.LeftTop());
|
|
||||||
stringView->ResizeTo(rect.Width(), rect.Height());
|
|
||||||
|
|
||||||
/* Resize the View to the correct height */
|
|
||||||
scroller->SetResizingMode(B_FOLLOW_NONE);
|
|
||||||
ResizeTo(Frame().Width(), scroller->Frame().bottom + 8);
|
|
||||||
scroller->SetResizingMode(B_FOLLOW_ALL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//====================================================================
|
// #pragma mark -
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
TNameControl::TNameControl(BRect rect, const char *label, BMessage *msg)
|
TNameControl::TNameControl(const char* label, BMessage* invocationMessage)
|
||||||
:BTextControl(rect, "", label, "", msg, B_FOLLOW_LEFT_RIGHT)
|
:
|
||||||
|
BTextControl("", label, "", invocationMessage)
|
||||||
{
|
{
|
||||||
strcpy(fLabel, label);
|
strcpy(fLabel, label);
|
||||||
}
|
}
|
||||||
@@ -487,13 +459,12 @@ TNameControl::AttachedToWindow()
|
|||||||
{
|
{
|
||||||
BTextControl::AttachedToWindow();
|
BTextControl::AttachedToWindow();
|
||||||
|
|
||||||
SetDivider(StringWidth(fLabel) + 6);
|
|
||||||
TextView()->SetMaxBytes(B_FILE_NAME_LENGTH - 1);
|
TextView()->SetMaxBytes(B_FILE_NAME_LENGTH - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TNameControl::MessageReceived(BMessage *msg)
|
TNameControl::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case M_SELECT:
|
case M_SELECT:
|
||||||
@@ -506,27 +477,18 @@ TNameControl::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//====================================================================
|
// #pragma mark -
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
TSigTextView::TSigTextView(BRect frame, BRect text)
|
TSigTextView::TSigTextView()
|
||||||
:BTextView(frame, "SignatureView", text, B_FOLLOW_ALL, B_NAVIGABLE | B_WILL_DRAW)
|
:
|
||||||
|
BTextView("SignatureView", B_NAVIGABLE | B_WILL_DRAW)
|
||||||
{
|
{
|
||||||
fDirty = false;
|
fDirty = false;
|
||||||
SetDoesUndo(true);
|
SetDoesUndo(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TSigTextView::FrameResized(float /*width*/, float /*height*/)
|
|
||||||
{
|
|
||||||
BRect r(Bounds());
|
|
||||||
r.InsetBy(3, 3);
|
|
||||||
SetTextRect(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TSigTextView::DeleteText(int32 offset, int32 len)
|
TSigTextView::DeleteText(int32 offset, int32 len)
|
||||||
{
|
{
|
||||||
|
|||||||
+20
-30
@@ -31,22 +31,16 @@ 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Signature.h
|
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _SIGNATURE_H
|
#ifndef _SIGNATURE_H
|
||||||
#define _SIGNATURE_H
|
#define _SIGNATURE_H
|
||||||
|
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Beep.h>
|
#include <Beep.h>
|
||||||
#include <Box.h>
|
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <Font.h>
|
#include <Font.h>
|
||||||
#include <fs_index.h>
|
#include <fs_index.h>
|
||||||
|
#include <GridView.h>
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
@@ -56,9 +50,6 @@ All rights reserved.
|
|||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
const float kSigHeight = 200;
|
|
||||||
const float kSigWidth = 457;
|
|
||||||
|
|
||||||
|
|
||||||
#define INDEX_SIGNATURE "_signature"
|
#define INDEX_SIGNATURE "_signature"
|
||||||
|
|
||||||
@@ -98,48 +89,47 @@ private:
|
|||||||
TSignatureView *fSigView;
|
TSignatureView *fSigView;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
|
|
||||||
class TSignatureView : public BBox {
|
class TSignatureView : public BGridView {
|
||||||
public:
|
public:
|
||||||
TSignatureView(BRect);
|
TSignatureView();
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
|
|
||||||
TNameControl *fName;
|
TNameControl* fName;
|
||||||
TSigTextView *fTextView;
|
TSigTextView* fTextView;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float fOffset;
|
float fOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
//====================================================================
|
|
||||||
|
|
||||||
class TNameControl : public BTextControl {
|
class TNameControl : public BTextControl {
|
||||||
public:
|
public:
|
||||||
TNameControl(BRect, const char*, BMessage*);
|
TNameControl(const char* label,
|
||||||
virtual void AttachedToWindow();
|
BMessage* invocationMessage);
|
||||||
virtual void MessageReceived(BMessage*);
|
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char fLabel[100];
|
char fLabel[100];
|
||||||
};
|
};
|
||||||
|
|
||||||
//====================================================================
|
|
||||||
|
|
||||||
class TSigTextView : public BTextView {
|
class TSigTextView : public BTextView {
|
||||||
public:
|
public:
|
||||||
TSigTextView(BRect, BRect);
|
TSigTextView();
|
||||||
void FrameResized(float width, float height);
|
|
||||||
|
|
||||||
virtual void DeleteText(int32, int32);
|
virtual void DeleteText(int32 offset, int32 length);
|
||||||
virtual void KeyDown(const char*, int32);
|
virtual void KeyDown(const char*, int32);
|
||||||
virtual void InsertText(const char*, int32, int32, const text_run_array*);
|
virtual void InsertText(const char*, int32, int32,
|
||||||
virtual void MessageReceived(BMessage*);
|
const text_run_array*);
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
bool fDirty;
|
bool fDirty;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TSignatureView *fParent;
|
TSignatureView* fParent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // #ifndef _SIGNATURE_H
|
#endif // #ifndef _SIGNATURE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user