From faef1e541324d87f985923d48436a208edb2ff55 Mon Sep 17 00:00:00 2001 From: shatty Date: Sat, 26 Oct 2002 03:33:06 +0000 Subject: [PATCH] from sample code git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1676 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/people/Jamfile | 13 + src/apps/people/LICENSE | 31 ++ src/apps/people/People.rsrc | Bin 0 -> 4289 bytes src/apps/people/PeopleApp.cpp | 386 ++++++++++++++++++++++ src/apps/people/PeopleApp.h | 73 +++++ src/apps/people/PeopleView.cpp | 538 +++++++++++++++++++++++++++++++ src/apps/people/PeopleView.h | 106 ++++++ src/apps/people/PeopleWindow.cpp | 285 ++++++++++++++++ src/apps/people/PeopleWindow.h | 54 ++++ src/apps/people/PersonIcons.h | 97 ++++++ src/apps/people/README | 15 + src/apps/people/TTextControl.cpp | 76 +++++ src/apps/people/TTextControl.h | 36 +++ src/apps/people/main.cpp | 24 ++ 14 files changed, 1734 insertions(+) create mode 100644 src/apps/people/Jamfile create mode 100644 src/apps/people/LICENSE create mode 100644 src/apps/people/People.rsrc create mode 100644 src/apps/people/PeopleApp.cpp create mode 100644 src/apps/people/PeopleApp.h create mode 100644 src/apps/people/PeopleView.cpp create mode 100644 src/apps/people/PeopleView.h create mode 100644 src/apps/people/PeopleWindow.cpp create mode 100644 src/apps/people/PeopleWindow.h create mode 100644 src/apps/people/PersonIcons.h create mode 100644 src/apps/people/README create mode 100644 src/apps/people/TTextControl.cpp create mode 100644 src/apps/people/TTextControl.h create mode 100644 src/apps/people/main.cpp diff --git a/src/apps/people/Jamfile b/src/apps/people/Jamfile new file mode 100644 index 0000000000..027ee33ff5 --- /dev/null +++ b/src/apps/people/Jamfile @@ -0,0 +1,13 @@ +SubDir OBOS_TOP src apps people ; + +AddResources People : People.rsrc ; + +App People : main.cpp + PeopleApp.cpp + PeopleView.cpp + PeopleWindow.cpp + TTextControl.cpp + ; + +LinkSharedOSLibs People : be tracker ; + diff --git a/src/apps/people/LICENSE b/src/apps/people/LICENSE new file mode 100644 index 0000000000..86a4268fa9 --- /dev/null +++ b/src/apps/people/LICENSE @@ -0,0 +1,31 @@ +---------------------- +Be Sample Code License +---------------------- + +Copyright 1991-1999, Be Incorporated. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions, and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/apps/people/People.rsrc b/src/apps/people/People.rsrc new file mode 100644 index 0000000000000000000000000000000000000000..3753fc4200a582b71abb74bd198c4a4ba9ef1bd9 GIT binary patch literal 4289 zcmeHKziU%b6u$4}rHzR;FW@W1)KbAg!CIw@bTDnwBt()X^p)D^kQ9wrENyIyv|!*0 zLKg>dba8Mg;^0uBgF=@$3A(rlqO0=!0}=x9JMTx5rtei8q7FIm-o591-}!M*Zpg`% zmCaMDg|%BXIh)tSZ%h+jZ!ie-B4ZCu*W~L1P>|N@7#Us_O{#G?j7jffq!!c7K+8C z#TyIjiz~~c8zc9YZ=MeqMl#V%lEu>Di}(c#;n9Ef1Ybm*of&qoZx#z{Fe>|9i-py- zm1Wqw(y0z`*Ky2DSM%Ie<(lWwI^}`Rx$7)uraI^1mkG}DE=vzWfbZ4hYxhAF$j?~! z^EL4&Cx2iR@1s7G32)w$zhP_hM-JEpE_@xtb58enz2F9SUe@b_KiM(k$ws`lXUGTo zF!6vrq&ZG=@6=%1wd%({!-XeHm??Kn|BU6&#nB1iMPo*+^QM3H5<*H$lCsA6t1ai5 ze;huFe8STmn$02?u%{W*te0Z^9T7$5IV6)590+(sM}ia#g@VcveU7vvi8}6c#3f~r z5;)?bN9k95jyS6@ug~Kco`otU`c(0nkq_S&pabV2Q5d^If+t&%dNv>L>dLxZh4Q-b|1I;&FTrU8XiAq@j` zy)-Mu?{xh#v|eQ6WR^RQx-XoQ-s}Tf)AqqPJ3*CCW->7>^vAV_`NPq)Iu27VmYj^M zjZ>r&k!cVLc-&0ZNvUylb}E;Mq^BD!T`^da$x0q%A^Mz|(8U6cgmcjuHPI3*rN-kX lO*DhW63J+8Hk*mI7M4;?mcWiRf~kpkqpGcu4|hOezW^QS;h6vc literal 0 HcmV?d00001 diff --git a/src/apps/people/PeopleApp.cpp b/src/apps/people/PeopleApp.cpp new file mode 100644 index 0000000000..059276a5da --- /dev/null +++ b/src/apps/people/PeopleApp.cpp @@ -0,0 +1,386 @@ +//-------------------------------------------------------------------- +// +// PeopleApp.cpp +// +// Written by: Robert Polic +// +//-------------------------------------------------------------------- +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "PeopleApp.h" +#include "PeopleWindow.h" +#include "PersonIcons.h" + +//==================================================================== + +TPeopleApp::TPeopleApp(void) + :BApplication(APP_SIG) +{ + bool valid = FALSE; + const char *str; + int32 index = 0; + BBitmap large_icon(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1), B_COLOR_8_BIT); + BBitmap mini_icon(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_COLOR_8_BIT); + BDirectory dir; + BEntry entry; + BMessage msg; + BMessage info; + BMimeType mime; + BPath path; + BPoint pos; + BVolume vol; + BVolumeRoster roster; +// TPeopleWindow *window; + + fHaveWindow = FALSE; + + fPosition.Set(6, TITLE_BAR_HEIGHT, 6 + WIND_WIDTH, TITLE_BAR_HEIGHT + WIND_HEIGHT); + pos = fPosition.LeftTop(); + + find_directory(B_USER_SETTINGS_DIRECTORY, &path, true); + dir.SetTo(path.Path()); + if (dir.FindEntry("People_data", &entry) == B_NO_ERROR) { + fPrefs = new BFile(&entry, O_RDWR); + if (fPrefs->InitCheck() == B_NO_ERROR) { + fPrefs->Read(&pos, sizeof(BPoint)); + if (BScreen(B_MAIN_SCREEN_ID).Frame().Contains(pos)) + fPosition.OffsetTo(pos); + } + } + else { + fPrefs = new BFile(); + if (dir.CreateFile("People_data", fPrefs) != B_NO_ERROR) { + delete fPrefs; + fPrefs = NULL; + } + } + + roster.GetBootVolume(&vol); + fs_create_index(vol.Device(), P_NAME, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_COMPANY, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_ADDRESS, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_CITY, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_STATE, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_ZIP, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_COUNTRY, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_HPHONE, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_WPHONE, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_FAX, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_EMAIL, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_URL, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_GROUP, B_STRING_TYPE, 0); + fs_create_index(vol.Device(), P_NICKNAME, B_STRING_TYPE, 0); + + // install person mime type + mime.SetType(B_PERSON_MIMETYPE); + if (mime.IsInstalled()) { + if (mime.GetAttrInfo(&info) == B_NO_ERROR) { + while (info.FindString("attr:name", index++, &str) == B_NO_ERROR) { + if (!strcmp(str, P_NAME)) { + valid = TRUE; + break; + } + } + if (!valid) + mime.Delete(); + } + } + if (!valid) { + mime.Install(); + large_icon.SetBits(kLargePersonIcon, large_icon.BitsLength(), 0, B_COLOR_8_BIT); + mini_icon.SetBits(kSmallPersonIcon, mini_icon.BitsLength(), 0, B_COLOR_8_BIT); + mime.SetShortDescription("Person"); + mime.SetLongDescription("Contact information for a person."); + mime.SetIcon(&large_icon, B_LARGE_ICON); + mime.SetIcon(&mini_icon, B_MINI_ICON); + mime.SetPreferredApp(APP_SIG); + + // add relevant person fields to meta-mime type + msg.AddString("attr:public_name", "Contact Name"); + msg.AddString("attr:name", P_NAME); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 120); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "Company"); + msg.AddString("attr:name", P_COMPANY); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 120); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "Address"); + msg.AddString("attr:name", P_ADDRESS); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 120); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "City"); + msg.AddString("attr:name", P_CITY); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 90); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "State"); + msg.AddString("attr:name", P_STATE); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 50); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "Zip"); + msg.AddString("attr:name", P_ZIP); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 50); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "Country"); + msg.AddString("attr:name", P_COUNTRY); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 120); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "Home Phone"); + msg.AddString("attr:name", P_HPHONE); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 90); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "Work Phone"); + msg.AddString("attr:name", P_WPHONE); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 90); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "Fax"); + msg.AddString("attr:name", P_FAX); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 90); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "E-mail"); + msg.AddString("attr:name", P_EMAIL); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 120); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "URL"); + msg.AddString("attr:name", P_URL); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 120); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "Group"); + msg.AddString("attr:name", P_GROUP); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 120); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + msg.AddString("attr:public_name", "Nickname"); + msg.AddString("attr:name", P_NICKNAME); + msg.AddInt32("attr:type", B_STRING_TYPE); + msg.AddBool("attr:viewable", true); + msg.AddBool("attr:editable", true); + msg.AddInt32("attr:width", 120); + msg.AddInt32("attr:alignment", B_ALIGN_LEFT); + msg.AddBool("attr:extra", false); + + mime.SetAttrInfo(&msg); + } +} + +//-------------------------------------------------------------------- + +TPeopleApp::~TPeopleApp(void) +{ + if (fPrefs) + delete fPrefs; +} + +//-------------------------------------------------------------------- + +void TPeopleApp::AboutRequested(void) +{ + (new BAlert("", "...by Robert Polic", "Big Deal"))->Go(); +} + +//-------------------------------------------------------------------- + +void TPeopleApp::ArgvReceived(int32 argc, char **argv) +{ + char *arg; + int32 index; + int32 loop; + TPeopleWindow *window = NULL; + + for (loop = 1; loop < argc; loop++) { + arg = argv[loop]; + if (!strncmp(P_NAME, arg, strlen(P_NAME))) + index = F_NAME; + else if (!strncmp(P_COMPANY, arg, strlen(P_COMPANY))) + index = F_COMPANY; + else if (!strncmp(P_ADDRESS, arg, strlen(P_ADDRESS))) + index = F_ADDRESS; + else if (!strncmp(P_CITY, arg, strlen(P_CITY))) + index = F_CITY; + else if (!strncmp(P_STATE, arg, strlen(P_STATE))) + index = F_STATE; + else if (!strncmp(P_ZIP, arg, strlen(P_ZIP))) + index = F_ZIP; + else if (!strncmp(P_COUNTRY, arg, strlen(P_COUNTRY))) + index = F_COUNTRY; + else if (!strncmp(P_HPHONE, arg, strlen(P_HPHONE))) + index = F_HPHONE; + else if (!strncmp(P_WPHONE, arg, strlen(P_WPHONE))) + index = F_WPHONE; + else if (!strncmp(P_FAX, arg, strlen(P_FAX))) + index = F_FAX; + else if (!strncmp(P_EMAIL, arg, strlen(P_EMAIL))) + index = F_EMAIL; + else if (!strncmp(P_URL, arg, strlen(P_URL))) + index = F_URL; + else if (!strncmp(P_GROUP, arg, strlen(P_GROUP))) + index = F_GROUP; + else if (!strncmp(P_NICKNAME, arg, strlen(P_NICKNAME))) + index = F_NICKNAME; + else + index = F_END; + + if (index != F_END) { + if (!window) + window = NewWindow(); + while(*arg != ' ') + arg++; + arg++; + window->SetField(index, arg); + } + } +} + +//-------------------------------------------------------------------- + +void TPeopleApp::MessageReceived(BMessage *msg) +{ + switch (msg->what) { + case M_NEW: + NewWindow(); + break; + + default: + BApplication::MessageReceived(msg); + } +} + +//-------------------------------------------------------------------- + +void TPeopleApp::RefsReceived(BMessage *msg) +{ + int32 item = 0; + BFile file; + entry_ref ref; + TPeopleWindow *window; + + while (msg->HasRef("refs", item)) { + msg->FindRef("refs", item++, &ref); + if ((window = FindWindow(ref))) + window->Activate(TRUE); + else { + file.SetTo(&ref, O_RDONLY); + if (file.InitCheck() == B_NO_ERROR) + NewWindow(&ref); + } + } +} + +//-------------------------------------------------------------------- + +void TPeopleApp::ReadyToRun(void) +{ + if (!fHaveWindow) + NewWindow(); +} + +//-------------------------------------------------------------------- + +TPeopleWindow* TPeopleApp::NewWindow(entry_ref *ref) +{ + TPeopleWindow *window; + + window = new TPeopleWindow(fPosition, "New Person", ref); + window->Show(); + fHaveWindow = TRUE; + fPosition.OffsetBy(20, 20); + + if (fPosition.bottom > BScreen(B_MAIN_SCREEN_ID).Frame().bottom) + fPosition.OffsetTo(fPosition.left, TITLE_BAR_HEIGHT); + if (fPosition.right > BScreen(B_MAIN_SCREEN_ID).Frame().right) + fPosition.OffsetTo(6, fPosition.top); + + return window; +} + +//-------------------------------------------------------------------- + +TPeopleWindow* TPeopleApp::FindWindow(entry_ref ref) +{ + int32 index = 0; + TPeopleWindow *window; + + while ((window = (TPeopleWindow *)WindowAt(index++))) { + if ((window->FindView("PeopleView")) && (window->fRef) && (*(window->fRef) == ref)) + return window; + } + return NULL; +} diff --git a/src/apps/people/PeopleApp.h b/src/apps/people/PeopleApp.h new file mode 100644 index 0000000000..ce40cc78b0 --- /dev/null +++ b/src/apps/people/PeopleApp.h @@ -0,0 +1,73 @@ +//-------------------------------------------------------------------- +// +// PeopleApp.h +// +// Written by: Robert Polic +// +//-------------------------------------------------------------------- +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#ifndef PEOPLEAPP_H +#define PEOPLEAPP_H + +#define B_PERSON_MIMETYPE "application/x-person" +#define APP_SIG "application/x-vnd.Be-PEPL" + +#define P_NAME "META:name" +#define P_NICKNAME "META:nickname" +#define P_COMPANY "META:company" +#define P_ADDRESS "META:address" +#define P_CITY "META:city" +#define P_STATE "META:state" +#define P_ZIP "META:zip" +#define P_COUNTRY "META:country" +#define P_HPHONE "META:hphone" +#define P_WPHONE "META:wphone" +#define P_FAX "META:fax" +#define P_EMAIL "META:email" +#define P_URL "META:url" +#define P_GROUP "META:group" + +enum MESSAGES {M_NEW = 128, M_SAVE, M_SAVE_AS, M_REVERT, + M_UNDO, M_SELECT, M_GROUP_MENU, M_DIRTY, + M_NAME, M_NICKNAME, M_COMPANY, M_ADDRESS, + M_CITY, M_STATE, M_ZIP, M_COUNTRY, M_HPHONE, + M_WPHONE, M_FAX, M_EMAIL, M_URL, M_GROUP}; + +enum FIELDS {F_NAME = 0, F_NICKNAME, F_COMPANY, F_ADDRESS, + F_CITY, F_STATE, F_ZIP, F_COUNTRY, F_HPHONE, + F_WPHONE, F_FAX, F_EMAIL, F_URL, F_GROUP, F_END}; + +class TPeopleWindow; + + +//==================================================================== + +#include + +class TPeopleApp : public BApplication { + +private: + + bool fHaveWindow; + BRect fPosition; + +public: + + BFile *fPrefs; + + TPeopleApp(void); + ~TPeopleApp(void); + virtual void AboutRequested(void); + virtual void ArgvReceived(int32, char**); + virtual void MessageReceived(BMessage*); + virtual void RefsReceived(BMessage*); + virtual void ReadyToRun(void); + TPeopleWindow *FindWindow(entry_ref); + TPeopleWindow *NewWindow(entry_ref* = NULL); +}; + +#endif /* PEOPLEAPP_H */ diff --git a/src/apps/people/PeopleView.cpp b/src/apps/people/PeopleView.cpp new file mode 100644 index 0000000000..32ee080c68 --- /dev/null +++ b/src/apps/people/PeopleView.cpp @@ -0,0 +1,538 @@ +//-------------------------------------------------------------------- +// +// PeopleView.cpp +// +// Written by: Robert Polic +// +//-------------------------------------------------------------------- +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "PeopleView.h" +#include "TTextControl.h" + +//==================================================================== + +TPeopleView::TPeopleView(BRect rect, char *title, entry_ref *ref) + :BView(rect, title, B_FOLLOW_ALL, B_WILL_DRAW) +{ + if (ref) + fFile = new BFile(ref, O_RDWR); + else + fFile = NULL; +} + +//-------------------------------------------------------------------- + +TPeopleView::~TPeopleView(void) +{ + if (fFile) + delete fFile; +} + +//-------------------------------------------------------------------- + +void TPeopleView::AttachedToWindow(void) +{ + char *text; + float offset; + BBox *box; + BFont font = *be_plain_font; + BMenuField *field; + BRect r; + rgb_color c; + attr_info info; + + c.red = c.green = c.blue = VIEW_COLOR; + SetViewColor(c); + + r = Bounds(); + r.InsetBy(-1, -1); + box = new BBox(r); + AddChild(box); + + offset = font.StringWidth(HPHONE_TEXT) + 18; + + text = (char *)malloc(1); + text[0] = 0; + r.Set(offset - font.StringWidth(NAME_TEXT) - 11, NAME_V, + NAME_H + NAME_WIDTH, NAME_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_NAME, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_NAME, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_NAME] = new TTextControl(r, NAME_TEXT, 256, + text, M_DIRTY, M_NAME); + fField[F_NAME]->SetTarget(this); + box->AddChild(fField[F_NAME]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(offset - font.StringWidth(NICKNAME_TEXT) - 11, NICKNAME_V, + NICKNAME_H + NICKNAME_WIDTH, NICKNAME_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_NICKNAME, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_NICKNAME, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_NICKNAME] = new TTextControl(r, NICKNAME_TEXT, 256, + text, M_DIRTY, M_NICKNAME); + fField[F_NICKNAME]->SetTarget(this); + box->AddChild(fField[F_NICKNAME]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(offset - font.StringWidth(COMPANY_TEXT) - 11, COMPANY_V, + COMPANY_H + COMPANY_WIDTH, COMPANY_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_COMPANY, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_COMPANY, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_COMPANY] = new TTextControl(r, COMPANY_TEXT, 256, + text, M_DIRTY, M_COMPANY); + fField[F_COMPANY]->SetTarget(this); + box->AddChild(fField[F_COMPANY]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(offset - font.StringWidth(ADDRESS_TEXT) - 11, ADDRESS_V, + ADDRESS_H + ADDRESS_WIDTH, ADDRESS_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_ADDRESS, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_ADDRESS, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_ADDRESS] = new TTextControl(r, ADDRESS_TEXT, 256, + text, M_DIRTY, M_ADDRESS); + fField[F_ADDRESS]->SetTarget(this); + box->AddChild(fField[F_ADDRESS]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(offset - font.StringWidth(CITY_TEXT) - 11, CITY_V, + CITY_H + CITY_WIDTH, CITY_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_CITY, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_CITY, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_CITY] = new TTextControl(r, CITY_TEXT, 256, + text, M_DIRTY, M_CITY); + fField[F_CITY]->SetTarget(this); + box->AddChild(fField[F_CITY]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(offset - font.StringWidth(STATE_TEXT) - 11, STATE_V, + STATE_H + STATE_WIDTH, STATE_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_STATE, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_STATE, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_STATE] = new TTextControl(r, STATE_TEXT, 256, + text, M_DIRTY, M_STATE); + fField[F_STATE]->SetTarget(this); + box->AddChild(fField[F_STATE]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(ZIP_H + 11, ZIP_V, + ZIP_H + ZIP_WIDTH, ZIP_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_ZIP, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_ZIP, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_ZIP] = new TTextControl(r, ZIP_TEXT, 256, + text, M_DIRTY, M_ZIP); + fField[F_ZIP]->SetTarget(this); + box->AddChild(fField[F_ZIP]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(offset - font.StringWidth(COUNTRY_TEXT) - 11, COUNTRY_V, + COUNTRY_H + COUNTRY_WIDTH, COUNTRY_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_COUNTRY, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_COUNTRY, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_COUNTRY] = new TTextControl(r, COUNTRY_TEXT, 256, + text, M_DIRTY, M_COUNTRY); + fField[F_COUNTRY]->SetTarget(this); + box->AddChild(fField[F_COUNTRY]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(offset - font.StringWidth(HPHONE_TEXT) - 11, HPHONE_V, + HPHONE_H + HPHONE_WIDTH, HPHONE_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_HPHONE, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_HPHONE, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_HPHONE] = new TTextControl(r, HPHONE_TEXT, 256, + text, M_DIRTY, M_HPHONE); + fField[F_HPHONE]->SetTarget(this); + box->AddChild(fField[F_HPHONE]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(offset - font.StringWidth(WPHONE_TEXT) - 11, WPHONE_V, + WPHONE_H + WPHONE_WIDTH, WPHONE_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_WPHONE, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_WPHONE, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_WPHONE] = new TTextControl(r, WPHONE_TEXT, 256, + text, M_DIRTY, M_WPHONE); + fField[F_WPHONE]->SetTarget(this); + box->AddChild(fField[F_WPHONE]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(offset - font.StringWidth(FAX_TEXT) - 11, FAX_V, + FAX_H + FAX_WIDTH, FAX_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_FAX, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_FAX, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_FAX] = new TTextControl(r, FAX_TEXT, 256, + text, M_DIRTY, M_FAX); + fField[F_FAX]->SetTarget(this); + box->AddChild(fField[F_FAX]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(offset - font.StringWidth(EMAIL_TEXT) - 11, EMAIL_V, + EMAIL_H + EMAIL_WIDTH, EMAIL_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_EMAIL, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_EMAIL, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_EMAIL] = new TTextControl(r, EMAIL_TEXT, 256, + text, M_DIRTY, M_EMAIL); + fField[F_EMAIL]->SetTarget(this); + box->AddChild(fField[F_EMAIL]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(offset - font.StringWidth(URL_TEXT) - 11, URL_V, + URL_H + URL_WIDTH, URL_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_URL, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_URL, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_URL] = new TTextControl(r, URL_TEXT, 256, + text, M_DIRTY, M_URL); + fField[F_URL]->SetTarget(this); + box->AddChild(fField[F_URL]); + + text = (char *)realloc(text, 1); + text[0] = 0; + r.Set(offset - 11, GROUP_V, + GROUP_H + GROUP_WIDTH, GROUP_V + TEXT_HEIGHT); + if (fFile) { + if (fFile->GetAttrInfo(P_GROUP, &info) == B_NO_ERROR) { + text = (char *)realloc(text, info.size); + fFile->ReadAttr(P_GROUP, B_STRING_TYPE, 0, text, info.size); + } + } + fField[F_GROUP] = new TTextControl(r, "", 256, + text, M_DIRTY, M_GROUP); + fField[F_GROUP]->SetTarget(this); + box->AddChild(fField[F_GROUP]); + free(text); + + r.right = r.left + 3; + r.left = r.right - font.StringWidth(GROUP_TEXT) - 20; + r.top -= 1; + fGroups = new BPopUpMenu("Group"); + fGroups->SetRadioMode(FALSE); + field = new BMenuField(r, "", "", fGroups); + field->SetDivider(0.0); + field->SetFont(&font); + field->SetEnabled(TRUE); + box->AddChild(field); + + fField[F_NAME]->MakeFocus(); +} + +//-------------------------------------------------------------------- + +void TPeopleView::MessageReceived(BMessage* msg) +{ + int32 loop; + BTextView *text; + + switch (msg->what) { + case M_SAVE: + Save(); + break; + + case M_REVERT: + for (loop = 0; loop < F_END; loop++) + fField[loop]->Revert(); + break; + + case M_SELECT: + for (loop = 0; loop < F_END; loop++) { + text = (BTextView *)fField[loop]->ChildAt(0); + if (text->IsFocus()) { + text->Select(0, text->TextLength()); + break; + } + } + break; + } +} + +//-------------------------------------------------------------------- + +void TPeopleView::BuildGroupMenu(void) +{ + char *offset; + char str[256]; + char *text; + char *text1; + int32 count = 0; + int32 index; + BEntry entry; + BFile file; + BMessage *msg; + BMenuItem *item; + BQuery query; + BVolume vol; + BVolumeRoster volume; + attr_info info; + + while ((item = fGroups->ItemAt(0))) { + fGroups->RemoveItem(item); + delete item; + } + + volume.GetBootVolume(&vol); + query.SetVolume(&vol); + sprintf(str, "%s=*", P_GROUP); + query.SetPredicate(str); + query.Fetch(); + + while (query.GetNextEntry(&entry) == B_NO_ERROR) { + file.SetTo(&entry, O_RDONLY); + if ((file.InitCheck() == B_NO_ERROR) && + (file.GetAttrInfo(P_GROUP, &info) == B_NO_ERROR) && + (info.size > 1)) { + text = (char *)malloc(info.size); + text1 = text; + file.ReadAttr(P_GROUP, B_STRING_TYPE, 0, text, info.size); + while (1) { + if ((offset = strstr(text, ","))) + *offset = 0; + if (!fGroups->FindItem(text)) { + index = 0; + while ((item = fGroups->ItemAt(index))) { + if (strcmp(text, item->Label()) < 0) + break; + index++; + } + msg = new BMessage(M_GROUP_MENU); + msg->AddString("group", text); + fGroups->AddItem(new BMenuItem(text, msg), index); + count++; + } + if (offset) { + text = offset + 1; + while (*text == ' ') + text++; + } + else + break; + } + free(text1); + } + } + + if (!count) { + fGroups->AddItem(item = new BMenuItem("none", new BMessage(M_GROUP_MENU))); + item->SetEnabled(FALSE); + } +} + +//-------------------------------------------------------------------- + +bool TPeopleView::CheckSave(void) +{ + int32 loop; + + for (loop = 0; loop < F_END; loop++) + if (fField[loop]->Changed()) + return TRUE; + return FALSE; +} + +//-------------------------------------------------------------------- + +const char* TPeopleView::GetField(int32 index) +{ + if (index < F_END) + return fField[index]->Text(); + else + return NULL; +} + +//-------------------------------------------------------------------- + +void TPeopleView::NewFile(entry_ref *ref) +{ + if (fFile) + delete fFile; + fFile = new BFile(ref, O_RDWR); + Save(); +} + +//-------------------------------------------------------------------- + +void TPeopleView::Save(void) +{ + const char *text; + + text = fField[F_NAME]->Text(); + fFile->WriteAttr(P_NAME, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_NAME]->Update(); + + text = fField[F_COMPANY]->Text(); + fFile->WriteAttr(P_COMPANY, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_COMPANY]->Update(); + + text = fField[F_ADDRESS]->Text(); + fFile->WriteAttr(P_ADDRESS, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_ADDRESS]->Update(); + + text = fField[F_CITY]->Text(); + fFile->WriteAttr(P_CITY, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_CITY]->Update(); + + text = fField[F_STATE]->Text(); + fFile->WriteAttr(P_STATE, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_STATE]->Update(); + + text = fField[F_ZIP]->Text(); + fFile->WriteAttr(P_ZIP, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_ZIP]->Update(); + + text = fField[F_COUNTRY]->Text(); + fFile->WriteAttr(P_COUNTRY, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_COUNTRY]->Update(); + + text = fField[F_HPHONE]->Text(); + fFile->WriteAttr(P_HPHONE, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_HPHONE]->Update(); + + text = fField[F_WPHONE]->Text(); + fFile->WriteAttr(P_WPHONE, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_WPHONE]->Update(); + + text = fField[F_FAX]->Text(); + fFile->WriteAttr(P_FAX, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_FAX]->Update(); + + text = fField[F_EMAIL]->Text(); + fFile->WriteAttr(P_EMAIL, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_EMAIL]->Update(); + + text = fField[F_URL]->Text(); + fFile->WriteAttr(P_URL, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_URL]->Update(); + + text = fField[F_GROUP]->Text(); + fFile->WriteAttr(P_GROUP, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_GROUP]->Update(); + + text = fField[F_NICKNAME]->Text(); + fFile->WriteAttr(P_NICKNAME, B_STRING_TYPE, 0, text, strlen(text) + 1); + fField[F_NICKNAME]->Update(); +} + +//-------------------------------------------------------------------- + +void TPeopleView::SetField(int32 index, char *data, bool update) +{ + int32 end; + int32 start; + BTextView *text; + + Window()->Lock(); + if (update) { + fField[index]->SetText(data); + fField[index]->Update(); + } + else { + text = (BTextView *)fField[index]->ChildAt(0); + text->GetSelection(&start, &end); + if (start != end) { + text->Delete(); + text->Insert(data); + } + else if ((end = text->TextLength())) { + text->Select(end, end); + text->Insert(","); + text->Insert(data); + text->Select(text->TextLength(), text->TextLength()); + } + else + fField[index]->SetText(data); + } + Window()->Unlock(); +} + +//-------------------------------------------------------------------- + +bool TPeopleView::TextSelected(void) +{ + int32 end; + int32 loop; + int32 start; + BTextView *text; + + for (loop = 0; loop < F_END; loop++) { + text = (BTextView *)fField[loop]->ChildAt(0); + text->GetSelection(&start, &end); + if (start != end) + return TRUE; + } + return FALSE; +} diff --git a/src/apps/people/PeopleView.h b/src/apps/people/PeopleView.h new file mode 100644 index 0000000000..b5fe6ee85e --- /dev/null +++ b/src/apps/people/PeopleView.h @@ -0,0 +1,106 @@ +//-------------------------------------------------------------------- +// +// PeopleView.h +// +// Written by: Robert Polic +// +//-------------------------------------------------------------------- +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#ifndef PEOPLEVIEW_H +#define PEOPLEVIEW_H + +#include "PeopleApp.h" + +#define TEXT_HEIGHT 16 +#define NAME_H 10 +#define NAME_V 10 +#define NAME_WIDTH 300 +#define NAME_TEXT "Name" +#define NICKNAME_H 10 +#define NICKNAME_V (NAME_V + 25) +#define NICKNAME_WIDTH 300 +#define NICKNAME_TEXT "Nickname" +#define COMPANY_H 10 +#define COMPANY_V (NICKNAME_V + 25) +#define COMPANY_WIDTH 300 +#define COMPANY_TEXT "Company" +#define ADDRESS_H 10 +#define ADDRESS_V (COMPANY_V + 25) +#define ADDRESS_WIDTH 300 +#define ADDRESS_TEXT "Address" +#define CITY_H 10 +#define CITY_V (ADDRESS_V + 25) +#define CITY_WIDTH 300 +#define CITY_TEXT "City" +#define STATE_H 10 +#define STATE_V (CITY_V + 25) +#define STATE_WIDTH 175 +#define STATE_TEXT "State" +#define ZIP_H (STATE_H + STATE_WIDTH) +#define ZIP_V (CITY_V + 25) +#define ZIP_WIDTH 125 +#define ZIP_TEXT "Zip" +#define COUNTRY_H 10 +#define COUNTRY_V (ZIP_V + 25) +#define COUNTRY_WIDTH 300 +#define COUNTRY_TEXT "Country" +#define HPHONE_H 10 +#define HPHONE_V (COUNTRY_V + 25) +#define HPHONE_WIDTH 300 +#define HPHONE_TEXT "Home Phone" +#define WPHONE_H 10 +#define WPHONE_V (HPHONE_V + 25) +#define WPHONE_WIDTH 300 +#define WPHONE_TEXT "Work Phone" +#define FAX_H 10 +#define FAX_V (WPHONE_V + 25) +#define FAX_WIDTH 300 +#define FAX_TEXT "Fax" +#define EMAIL_H 10 +#define EMAIL_V (FAX_V + 25) +#define EMAIL_WIDTH 300 +#define EMAIL_TEXT "E-mail" +#define URL_H 10 +#define URL_V (EMAIL_V + 25) +#define URL_WIDTH 300 +#define URL_TEXT "URL" +#define GROUP_H 10 +#define GROUP_V (URL_V + 25) +#define GROUP_WIDTH 300 +#define GROUP_TEXT "Group" + +#define VIEW_COLOR 216 + +class TTextControl; + + +//==================================================================== + +class TPeopleView : public BView { + +private: + + BFile *fFile; + BPopUpMenu *fGroups; + TTextControl *fField[F_END]; + +public: + + TPeopleView(BRect, char*, entry_ref*); + ~TPeopleView(void); + virtual void AttachedToWindow(void); + virtual void MessageReceived(BMessage*); + void BuildGroupMenu(void); + bool CheckSave(void); + const char* GetField(int32); + void NewFile(entry_ref*); + void Save(void); + void SetField(int32, char*, bool); + bool TextSelected(void); +}; + +#endif /* PEOPLEVIEW_H */ diff --git a/src/apps/people/PeopleWindow.cpp b/src/apps/people/PeopleWindow.cpp new file mode 100644 index 0000000000..b60ae763a9 --- /dev/null +++ b/src/apps/people/PeopleWindow.cpp @@ -0,0 +1,285 @@ +//-------------------------------------------------------------------- +// +// PeopleWindow.cpp +// +// Written by: Robert Polic +// +//-------------------------------------------------------------------- +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "PeopleApp.h" +#include "PeopleView.h" +#include "PeopleWindow.h" + +//==================================================================== + +TPeopleWindow::TPeopleWindow(BRect rect, char *title, entry_ref *ref) + :BWindow(rect, title, B_TITLED_WINDOW, B_NOT_RESIZABLE | + B_NOT_ZOOMABLE) +{ + BMenu *menu; + BMenuBar *menu_bar; + BMenuItem *item; + BRect r; + + fPanel = NULL; + + r.Set(0, 0, 32767, 15); + menu_bar = new BMenuBar(r, ""); + menu = new BMenu("File"); + menu->AddItem(item = new BMenuItem("New Person", new BMessage(M_NEW), 'N')); + item->SetTarget(NULL, be_app); + menu->AddItem(new BMenuItem("Close", new BMessage(B_CLOSE_REQUESTED), 'W')); + menu->AddSeparatorItem(); + menu->AddItem(fSave = new BMenuItem("Save", new BMessage(M_SAVE), 'S')); + fSave->SetEnabled(FALSE); + menu->AddItem(new BMenuItem("Save As"B_UTF8_ELLIPSIS, new BMessage(M_SAVE_AS))); + menu->AddItem(fRevert = new BMenuItem("Revert", new BMessage(M_REVERT), 'R')); + fRevert->SetEnabled(FALSE); + menu->AddSeparatorItem(); + menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); + menu_bar->AddItem(menu); + + menu = new BMenu("Edit"); + menu->AddItem(fUndo = new BMenuItem("Undo", new BMessage(M_UNDO), 'Z')); + menu->AddSeparatorItem(); + menu->AddItem(fCut = new BMenuItem("Cut", new BMessage(B_CUT), 'X')); + fCut->SetTarget(NULL, this); + menu->AddItem(fCopy = new BMenuItem("Copy", new BMessage(B_COPY), 'C')); + fCopy->SetTarget(NULL, this); + menu->AddItem(fPaste = new BMenuItem("Paste", new BMessage(B_PASTE), 'V')); + fPaste->SetTarget(NULL, this); + menu->AddItem(item = new BMenuItem("Select All", new BMessage(M_SELECT), 'A')); + item->SetTarget(NULL, this); + menu_bar->AddItem(menu); + AddChild(menu_bar); + + if (ref) { + fRef = new entry_ref(*ref); + SetTitle(ref->name); + } + else + fRef = NULL; + + r = Frame(); + r.OffsetTo(0, menu_bar->Bounds().bottom + 1); + fView = new TPeopleView(r, "PeopleView", fRef); + + ResizeBy(0, menu_bar->Bounds().bottom + 1); + Lock(); + AddChild(fView); + Unlock(); +} + +//-------------------------------------------------------------------- + +TPeopleWindow::~TPeopleWindow(void) +{ + if (fRef) + delete fRef; + if (fPanel) + delete fPanel; +} + +//-------------------------------------------------------------------- + +void TPeopleWindow::MenusBeginning(void) +{ + bool enabled; + + enabled = fView->CheckSave(); + fSave->SetEnabled(enabled); + fRevert->SetEnabled(enabled); + + fUndo->SetEnabled(FALSE); + enabled = fView->TextSelected(); + fCut->SetEnabled(enabled); + fCopy->SetEnabled(enabled); + + be_clipboard->Lock(); + fPaste->SetEnabled(be_clipboard->Data()->HasData("text/plain", B_MIME_TYPE)); + be_clipboard->Unlock(); + + fView->BuildGroupMenu(); +} + +//-------------------------------------------------------------------- + +void TPeopleWindow::MessageReceived(BMessage* msg) +{ + char str[256]; + entry_ref dir; + BDirectory directory; + BEntry entry; + BFile file; + BNodeInfo *node; + + switch(msg->what) { + case M_SAVE: + if (!fRef) { + SaveAs(); + break; + } + case M_REVERT: + case M_SELECT: + fView->MessageReceived(msg); + break; + + case M_SAVE_AS: + SaveAs(); + break; + + case M_GROUP_MENU: + { + char *name = NULL; + msg->FindString("group", (const char **)&name); + fView->SetField(F_GROUP, name, FALSE); + break; + } + case B_SAVE_REQUESTED: + if (msg->FindRef("directory", &dir) == B_NO_ERROR) { + const char *name = NULL; + msg->FindString("name", &name); + directory.SetTo(&dir); + if (directory.InitCheck() == B_NO_ERROR) { + directory.CreateFile(name, &file); + if (file.InitCheck() == B_NO_ERROR) { + node = new BNodeInfo(&file); + node->SetType("application/x-person"); + delete node; + + directory.FindEntry(name, &entry); + entry.GetRef(&dir); + if (fRef) + delete fRef; + fRef = new entry_ref(dir); + SetTitle(fRef->name); + fView->NewFile(fRef); + } + else { + sprintf(str, "Could not create %s.", name); + (new BAlert("", str, "Sorry"))->Go(); + } + } + } + break; + + default: + BWindow::MessageReceived(msg); + } +} + +//-------------------------------------------------------------------- + +bool TPeopleWindow::QuitRequested(void) +{ + int32 count = 0; + int32 index = 0; + BPoint pos; + BRect r; + status_t result; + TPeopleWindow *window; + + if (fView->CheckSave()) { + result = (new BAlert("", "Save changes before quitting?", + "Cancel", "Quit", "Save"))->Go(); + if (result == 2) { + if (fRef) + fView->Save(); + else { + SaveAs(); + return FALSE; + } + } + else if (result == 0) + return FALSE; + } + + while ((window = (TPeopleWindow *)be_app->WindowAt(index++))) { + if (window->FindView("PeopleView")) + count++; + } + + if (count == 1) { + r = Frame(); + pos = r.LeftTop(); + if (((TPeopleApp*)be_app)->fPrefs) { + ((TPeopleApp*)be_app)->fPrefs->Seek(0, 0); + ((TPeopleApp*)be_app)->fPrefs->Write(&pos, sizeof(BPoint)); + } + be_app->PostMessage(B_QUIT_REQUESTED); + } + return TRUE; +} + +//-------------------------------------------------------------------- + +void TPeopleWindow::DefaultName(char *name) +{ + strncpy(name, fView->GetField(F_NAME), B_FILE_NAME_LENGTH); + while (*name) { + if (*name == '/') + *name = '-'; + name++; + } +} + +//-------------------------------------------------------------------- + +void TPeopleWindow::SetField(int32 index, char *text) +{ + fView->SetField(index, text, TRUE); +} + +//-------------------------------------------------------------------- + +void TPeopleWindow::SaveAs(void) +{ + char name[B_FILE_NAME_LENGTH]; + BDirectory dir; + BEntry entry; + BMessenger window(this); + BPath path; + + DefaultName(name); + if (!fPanel) { + fPanel = new BFilePanel(B_SAVE_PANEL, &window); + fPanel->SetSaveText(name); + find_directory(B_USER_DIRECTORY, &path, true); + dir.SetTo(path.Path()); + if (dir.FindEntry("people", &entry) == B_NO_ERROR) + fPanel->SetPanelDirectory(&entry); + else if (dir.CreateDirectory("people", &dir) == B_NO_ERROR) { + dir.GetEntry(&entry); + fPanel->SetPanelDirectory(&entry); + } + } + else if (fPanel->Window()->Lock()) { + if (!fPanel->Window()->IsHidden()) + fPanel->Window()->Activate(); + else + fPanel->SetSaveText(name); + fPanel->Window()->Unlock(); + } + + if (fPanel->Window()->Lock()) { + if (fPanel->Window()->IsHidden()) + fPanel->Window()->Show(); + fPanel->Window()->Unlock(); + } +} diff --git a/src/apps/people/PeopleWindow.h b/src/apps/people/PeopleWindow.h new file mode 100644 index 0000000000..fee86eac0d --- /dev/null +++ b/src/apps/people/PeopleWindow.h @@ -0,0 +1,54 @@ +//-------------------------------------------------------------------- +// +// PeopleWindow.h +// +// Written by: Robert Polic +// +//-------------------------------------------------------------------- +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#ifndef PEOPLEWINDOW_H +#define PEOPLEWINDOW_H + +#define TITLE_BAR_HEIGHT 25 +#define WIND_WIDTH 321 +#define WIND_HEIGHT 340 + +class TPeopleView; +class BFilePanel; +class BMenuItem; + +#include +//==================================================================== + +class TPeopleWindow : public BWindow { + +private: + + BFilePanel *fPanel; + BMenuItem *fCopy; + BMenuItem *fCut; + BMenuItem *fPaste; + BMenuItem *fRevert; + BMenuItem *fSave; + BMenuItem *fUndo; + TPeopleView *fView; + +public: + + entry_ref *fRef; + + TPeopleWindow(BRect, char*, entry_ref*); + ~TPeopleWindow(void); + virtual void MenusBeginning(void); + virtual void MessageReceived(BMessage*); + virtual bool QuitRequested(void); + void DefaultName(char*); + void SetField(int32, char*); + void SaveAs(void); +}; + +#endif /* PEOPLEWINDOW_H */ diff --git a/src/apps/people/PersonIcons.h b/src/apps/people/PersonIcons.h new file mode 100644 index 0000000000..65740c3861 --- /dev/null +++ b/src/apps/people/PersonIcons.h @@ -0,0 +1,97 @@ +//-------------------------------------------------------------------- +// +// PersonIcons.h +// +// Written by: Robert Polic +// +//-------------------------------------------------------------------- +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +const uint8 kLargePersonIcon [] = { + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x02,0x02,0x00,0x08,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x04,0x1b,0x18,0x11,0x08,0x02,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x04,0x1b,0x3f,0x3f,0x1b,0x15,0x09,0x00, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x02,0x1b,0x3f,0x3f,0x1b,0x15,0x0b,0x00, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x04,0x15,0x1c,0x1b,0x18,0x11,0x08,0x00, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x02,0x08,0x15,0x16,0x15,0x0b,0x08,0x00, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0x00,0x0a,0x0b,0x08,0x0b,0x00,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x3f,0xf9,0x7d,0x00,0x00,0x00,0x00,0x7d,0x00, + 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0x3f,0x3f,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d, + 0xf9,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0x3f,0x3f,0xf9,0xf9,0xf9,0xf9, + 0x7d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0x3f,0x3f,0xf9,0x7d, + 0x7d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x7d,0x7d, + 0x7d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x7d,0x7d, + 0x7d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x7d,0x7d, + 0x7d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x7d,0x7d, + 0x7d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x7d,0x7d, + 0x7d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x7d,0x7d, + 0xc5,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x7d,0xc5, + 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xc5,0xf9,0xf9,0xf9,0xc5,0xc5, + 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xc5,0xf9,0xf9,0xc5,0xc5,0x7d, + 0x00,0x0a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xc5,0xf9,0xf9,0x7d,0x7d,0x7d, + 0x00,0x0a,0x0b,0x0a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xc5,0xf9,0xf9,0x7d,0x7d,0x7d, + 0x00,0x0a,0x0b,0x0a,0x0b,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xc5,0xf9,0xf9,0x7d,0x7d,0x7d, + 0x00,0x0a,0x0b,0x0a,0x0b,0x0b,0x0a,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xc5,0xf9,0xf9,0x7d,0x7d,0x7d, + 0x00,0x0a,0x0b,0x0a,0x0b,0x0b,0x0a,0x0b,0x0b,0x0a,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xc5,0xf9,0xf9,0x7d,0x7d,0x7d, + 0x00,0x0a,0x0b,0x0a,0x0b,0x0b,0x0a,0x0b,0x0b,0x0a,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xc5,0xf9,0xf9,0x7d,0x7d,0x7d, + 0x00,0x0a,0x0b,0x0a,0x0b,0x0b,0x0a,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xf9,0xc5,0xf9,0xf9,0x7d,0x7d,0x7d, + 0x00,0x0a,0x0b,0x0a,0x0b,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xf9,0xf9,0x7d,0x7d,0x00, + 0x0a,0x0b,0x0a,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x0a, + 0x0b,0x0a,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff +}; + +const uint8 kSmallPersonIcon [] = { + 0xff,0xff,0xff,0xff,0xff,0x02,0x02,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0x04,0x15,0x1e,0x15,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0x02,0x1d,0x1e,0x1c,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0x00,0x15,0x1b,0x16,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0x00,0xfa,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0x00,0xf9,0xf9,0xfa,0xfa,0xfa,0xfa,0x00,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0x7d,0x7d,0x00,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0x7d,0x7d,0x00,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0x7d,0x7d,0x00,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0x7d,0x7d,0x00,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0x7d,0x7d,0x00,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0x7d,0x7d,0x00,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0x7d,0x7d,0x00,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0x7d,0x7d,0x00,0x0a,0x0b,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0x00,0x00,0xf9,0x7d,0x7d,0x00,0x0a,0x0b,0x0a,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x0a,0x0b,0x0a,0x0b,0xff,0xff,0xff +}; diff --git a/src/apps/people/README b/src/apps/people/README new file mode 100644 index 0000000000..99f56f0c18 --- /dev/null +++ b/src/apps/people/README @@ -0,0 +1,15 @@ +People -- README + +This directory contains the source code for building +the standard People application that ships with BeOS. +You can use this application to create Person records, +which can be dropped into BeMail headers (see the +BeOS User's Guide Chap. 4: Sending Mail) and other +applications. + +Ostensibly, this application reveals how the Person +record is stored, but it also demonstrates how to +use the BeOS file type database in an application. + +Owen Smith +July 1998 \ No newline at end of file diff --git a/src/apps/people/TTextControl.cpp b/src/apps/people/TTextControl.cpp new file mode 100644 index 0000000000..a73c381392 --- /dev/null +++ b/src/apps/people/TTextControl.cpp @@ -0,0 +1,76 @@ +//-------------------------------------------------------------------- +// +// TTextControl.cpp +// +// Written by: Robert Polic +// +//-------------------------------------------------------------------- +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#include +#include +#include + +#include "TTextControl.h" + +//==================================================================== + +TTextControl::TTextControl(BRect r, char *label, int32 length, + char *text, int32 mod_msg, int32 msg) + :BTextControl(r, "", label, text, new BMessage(msg)) +{ + SetModificationMessage(new BMessage(mod_msg)); + + fLabel = (char *)malloc(strlen(label) + 1); + strcpy(fLabel, label); + fOriginal = (char *)malloc(strlen(text) + 1); + strcpy(fOriginal, text); + fLength = length; +} + +//-------------------------------------------------------------------- + +TTextControl::~TTextControl(void) +{ + free(fLabel); + free(fOriginal); +} + +//-------------------------------------------------------------------- + +void TTextControl::AttachedToWindow(void) +{ + BTextView *text; + + BTextControl::AttachedToWindow(); + + SetDivider(StringWidth(fLabel) + 7); + text = (BTextView *)ChildAt(0); + text->SetMaxBytes(fLength - 1); +} + +//-------------------------------------------------------------------- + +bool TTextControl::Changed(void) +{ + return strcmp(fOriginal, Text()); +} + +//-------------------------------------------------------------------- + +void TTextControl::Revert(void) +{ + if (Changed()) + SetText(fOriginal); +} + +//-------------------------------------------------------------------- + +void TTextControl::Update(void) +{ + fOriginal = (char *)realloc(fOriginal, strlen(Text()) + 1); + strcpy(fOriginal, Text()); +} diff --git a/src/apps/people/TTextControl.h b/src/apps/people/TTextControl.h new file mode 100644 index 0000000000..76d348ae06 --- /dev/null +++ b/src/apps/people/TTextControl.h @@ -0,0 +1,36 @@ +//-------------------------------------------------------------------- +// +// TextControl.h +// +// Written by: Robert Polic +// +//-------------------------------------------------------------------- +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#ifndef TEXTCONTROL_H +#define TEXTCONTROL_H + +#include + +class TTextControl : public BTextControl { + +private: + + char *fLabel; + char *fOriginal; + int32 fLength; + +public: + + TTextControl(BRect, char*, int32, char*, int32, int32); + ~TTextControl(void); + virtual void AttachedToWindow(void); + bool Changed(void); + void Revert(void); + void Update(void); +}; + +#endif /* TEXTCONTROL_H */ diff --git a/src/apps/people/main.cpp b/src/apps/people/main.cpp new file mode 100644 index 0000000000..fe50b822bb --- /dev/null +++ b/src/apps/people/main.cpp @@ -0,0 +1,24 @@ +//-------------------------------------------------------------------- +// +// main.cpp +// +// Written by: Robert Polic +// +//-------------------------------------------------------------------- +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#include "PeopleApp.h" + +int main(void) +{ + TPeopleApp *app; + + app = new TPeopleApp(); + app->Run(); + + delete app; + return B_NO_ERROR; +}