Ticket #3825: People[#3825]2.patch
File People[#3825]2.patch, 2.9 KB (added by , 14 years ago) |
---|
-
BFSBackup/haiku/haiku/src/apps/people/TTextControl.h
13 13 #ifndef TEXTCONTROL_H 14 14 #define TEXTCONTROL_H 15 15 16 #ifndef B_URL_MIME 17 #define B_URL_MIME "application/x-vnd.Be.URL." 18 #endif 19 16 20 #include <TextControl.h> 17 21 18 22 class TTextControl : public BTextControl { … … 22 26 ~TTextControl(); 23 27 24 28 virtual void AttachedToWindow(void); 29 virtual void MouseDown(BPoint); 25 30 26 31 bool Changed(void); 27 32 void Revert(void); 28 33 void Update(void); 34 void LoadLabels(const char*); 29 35 30 36 private: 37 BRect VisibleLabelBounds() const; 31 38 char *fOriginal; 32 39 }; 33 40 -
BFSBackup/haiku/haiku/src/apps/people/TTextControl.cpp
10 10 This file may be used under the terms of the Be Sample Code License. 11 11 */ 12 12 13 #include <Roster.h> 14 #include <StorageKit.h> 15 #include <support/String.h> 16 13 17 #include <string.h> 14 18 #include <malloc.h> 15 19 #include <Font.h> 16 20 21 #include "PeopleApp.h" 17 22 #include "TTextControl.h" 18 23 19 24 … … 57 62 } 58 63 59 64 65 void 66 TTextControl::MouseDown(BPoint mousePosition) 67 { 68 if(VisibleLabelBounds().Contains(mousePosition)) 69 LoadLabels(Text()); 70 else 71 BTextControl::MouseDown(mousePosition); 72 } 73 74 60 75 bool 61 76 TTextControl::Changed(void) 62 77 { … … 78 93 fOriginal = (char *)realloc(fOriginal, strlen(Text()) + 1); 79 94 strcpy(fOriginal, Text()); 80 95 } 96 97 98 void 99 TTextControl::LoadLabels(const char *fLabel) 100 { 101 BString argument(fLabel); 102 103 if (BString(gFields[F_URL].name).Append(":") == Label()) { 104 105 if (argument.IFindFirst ("www") == 0) 106 argument.Prepend ("http://"); 107 else if (argument.IFindFirst ("ftp") == 0) 108 argument.Prepend ("ftp://"); 109 110 const char *args[] = {argument.String(), 0}; 111 112 if (argument.IFindFirst("http://") == 0 113 || argument.IFindFirst("ftp://") == 0) { 114 BString mimeType = B_URL_MIME; 115 mimeType.Append(argument, argument.FindFirst(':')); 116 if (!BMimeType::IsValid(mimeType.String())) 117 return; 118 be_roster->Launch(mimeType.String(), 1, const_cast<char **>(args)); 119 } 120 } 121 122 if (BString(gFields[F_EMAIL].name).Append(":") == Label()) { 123 124 if (argument.IFindFirst ("mailto:") != 0 && argument != "") 125 argument.Prepend("mailto:"); 126 127 if (argument != "") { 128 const char *args[] = {argument.String(), 0}; 129 be_roster->Launch ("text/x-email", 1, const_cast<char **>(args)); 130 } 131 } 132 133 } 134 135 136 BRect 137 TTextControl::VisibleLabelBounds() const 138 { 139 BRect bounds(Bounds()); 140 bounds.right = Divider(); 141 bounds.left = bounds.right - StringWidth(Label()); 142 return bounds; 143 }