Index: HubFrame.cpp =================================================================== RCS file: /cvsroot/dcplusplus/dcplusplus/windows/HubFrame.cpp,v retrieving revision 1.61 diff -u -r1.61 HubFrame.cpp --- HubFrame.cpp 3 May 2004 12:38:05 -0000 1.61 +++ HubFrame.cpp 18 May 2004 14:41:54 -0000 @@ -44,6 +44,7 @@ { CreateSimpleStatusBar(ATL_IDS_IDLEMESSAGE, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP); ctrlStatus.Attach(m_hWndStatusBar); + statusContainer.SubclassWindow(ctrlStatus.m_hWnd); ctrlClient.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | ES_MULTILINE | ES_NOHIDESEL | ES_READONLY, WS_EX_CLIENTEDGE); @@ -78,6 +79,11 @@ ctrlShowUsers.SetCheck(BOOLSETTING(GET_USER_INFO) ? BST_CHECKED : BST_UNCHECKED); showUsersContainer.SubclassWindow(ctrlShowUsers.m_hWnd); + ctrlClear.Create(ctrlStatus.m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | BS_PUSHBUTTON, 0, IDC_CLEAR); + ctrlClear.SetWindowText("Clear"); + ctrlClear.SetFont(WinUtil::systemFont); + clearContainer.SubclassWindow(ctrlClear.m_hWnd); + WinUtil::splitTokens(columnIndexes, SETTING(HUBFRAME_ORDER), COLUMN_LAST); WinUtil::splitTokens(columnSizes, SETTING(HUBFRAME_WIDTHS), COLUMN_LAST); @@ -314,6 +320,11 @@ return 0; } +LRESULT HubFrame::onClear(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { + ctrlClient.SetWindowText(""); + return 0; +} + bool HubFrame::updateUser(const User::Ptr& u) { int i = findUser(u); @@ -399,8 +410,8 @@ SetWindowText(x->c_str()); delete x; } else if(wParam == STATS) { - ctrlStatus.SetText(1, (Util::toString(client->getUserCount()) + " " + STRING(HUB_USERS)).c_str()); - ctrlStatus.SetText(2, Util::formatBytes(client->getAvailable()).c_str()); + ctrlStatus.SetText(HUBUSERCOUNT, (Util::toString(client->getUserCount()) + " " + STRING(HUB_USERS)).c_str()); + ctrlStatus.SetText(HUBSHARECOUNT, Util::formatBytes(client->getAvailable()).c_str()); } else if(wParam == GET_PASSWORD) { if(client->getPassword().size() > 0) { client->password(client->getPassword()); @@ -441,27 +452,58 @@ UpdateBarsPosition(rect, bResizeBars); if(ctrlStatus.IsWindow()) { + ////////// + // Format of original status bar + // + // -------------------------------------------------------------------- + // | Log messages | X Users | Y Bytes | Checkbox| + // -------------------------------------------------------------------- + // Section A Sect B Sect C Sect D + // w[0] w[1] w[2] w[3] + // + // Sections B, C and D are fixed length. Section A is variable length. + ////////// + + ////////// + // Format of my revised status bar + // + // -------------------------------------------------------------------- + // | Clear | Log messages | X Users | Y Bytes | Checkbox| + // -------------------------------------------------------------------- + // SectA Section B Sect C Sect D Sect E + // w[0] w[1] w[2] w[3] w[4] + // + // Sections A, C, D and E are fixed length. Section B is variable length. + ////////// CRect sr; - int w[4]; + int w[5]; ctrlStatus.GetClientRect(sr); + // tmp = length to allocate to three sections on the right int tmp = (sr.Width()) > 332 ? 232 : ((sr.Width() > 132) ? sr.Width()-100 : 32); + int clearButtonWidth = 50; - w[0] = sr.right - tmp; - w[1] = w[0] + (tmp-32)/2; - w[2] = w[0] + (tmp-32); - w[3] = w[2] + 16; + w[0] = clearButtonWidth; + w[1] = sr.right - tmp; + w[2] = w[1] + (tmp-32)/2; // 32 = length of checkbox section + w[3] = w[1] + (tmp-32); // 32 = length of checkbox section + w[4] = w[3] + 16; - ctrlStatus.SetParts(4, w); + ctrlStatus.SetParts(5, w); - ctrlLastLines.SetMaxTipWidth(w[0]); + ctrlLastLines.SetMaxTipWidth(w[1]); ctrlLastLines.SetWindowPos(HWND_TOPMOST, sr.left, sr.top, sr.Width(), sr.Height(), SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // Strange, can't get the correct width of the last field... - ctrlStatus.GetRect(2, sr); + ctrlStatus.GetRect(3, sr); sr.left = sr.right + 2; sr.right = sr.left + 16; ctrlShowUsers.MoveWindow(sr); + + // Add the "Clear" button at the start of the line. + sr.left = 0; + sr.right = w[0]; + ctrlClear.MoveWindow(sr); } int h = WinUtil::fontHeight + 4; @@ -1017,7 +1059,8 @@ void HubFrame::addClientLine(const string& aLine, bool inChat /* = true */) { string line = "[" + Util::getShortTimeString() + "] " + aLine; - ctrlStatus.SetText(0, line.c_str()); + // The first param says which index of th "array" the message should be written to + ctrlStatus.SetText(HUBMESSAGES, line.c_str()); while(lastLinesList.size() + 1 > MAX_CLIENT_LINES) lastLinesList.erase(lastLinesList.begin()); lastLinesList.push_back(line); Index: HubFrame.h =================================================================== RCS file: /cvsroot/dcplusplus/dcplusplus/windows/HubFrame.h,v retrieving revision 1.45 diff -u -r1.45 HubFrame.h --- HubFrame.h 30 Apr 2004 07:14:56 -0000 1.45 +++ HubFrame.h 18 May 2004 14:41:55 -0000 @@ -45,6 +45,9 @@ public: DECLARE_FRAME_WND_CLASS_EX("HubFrame", IDR_HUB, 0, COLOR_3DFACE); + // Used to identify the different sections of the status bar + enum StatusColumns {CHATCLEARBUTTON = 0, HUBMESSAGES, HUBUSERCOUNT, HUBSHARECOUNT, SHOWUSERCHECKBOX}; + typedef CSplitterImpl splitBase; typedef MDITabChildWindowImpl baseClass; typedef UCHandler ucBase; @@ -76,6 +79,7 @@ CHAIN_MSG_MAP(baseClass) CHAIN_MSG_MAP(splitBase) ALT_MSG_MAP(EDIT_MESSAGE_MAP) + COMMAND_ID_HANDLER(IDC_CLEAR, onClear) MESSAGE_HANDLER(WM_CHAR, onChar) MESSAGE_HANDLER(WM_KEYDOWN, onChar) MESSAGE_HANDLER(WM_KEYUP, onChar) @@ -100,6 +104,7 @@ LRESULT onTabContextMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/); LRESULT onChar(UINT uMsg, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled); LRESULT onShowUsers(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled); + LRESULT onClear(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT onFollow(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT onLButton(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled); LRESULT onEnterUsers(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/); @@ -240,7 +245,9 @@ updateUsers(false), curCommandPosition(0), ctrlMessageContainer("edit", this, EDIT_MESSAGE_MAP), showUsersContainer("BUTTON", this, EDIT_MESSAGE_MAP), - clientContainer("edit", this, EDIT_MESSAGE_MAP) + clientContainer("edit", this, EDIT_MESSAGE_MAP), + clearContainer("BUTTON", this, EDIT_MESSAGE_MAP), + statusContainer(STATUSCLASSNAME, this, EDIT_MESSAGE_MAP) { client = ClientManager::getInstance()->getClient(aServer); client->setNick(aNick.empty() ? SETTING(NICK) : aNick); @@ -282,15 +289,24 @@ CContainedWindow ctrlMessageContainer; CContainedWindow clientContainer; CContainedWindow showUsersContainer; + CContainedWindow clearContainer; + CContainedWindow statusContainer; CMenu userMenu; CMenu tabMenu; + // The "Show User List" check box CButton ctrlShowUsers; + // Button below hub chat, used to clear the chat + CButton ctrlClear; + // The chat text area window CEdit ctrlClient; + // The message text box CEdit ctrlMessage; + // The user list typedef TypedListViewCtrl CtrlUsers; CtrlUsers ctrlUsers; + CStatusBarCtrl ctrlStatus; bool closed; Index: resource.h =================================================================== RCS file: /cvsroot/dcplusplus/dcplusplus/windows/resource.h,v retrieving revision 1.46 diff -u -r1.46 resource.h --- resource.h 3 May 2004 12:38:05 -0000 1.46 +++ resource.h 18 May 2004 14:42:02 -0000 @@ -236,6 +236,7 @@ #define IDC_SETTINGS_HUB 1205 #define IDC_SETTINGS_TO 1206 #define IDC_RESULT 1207 +#define IDC_CLEAR 1208 #define IDC_REFRESH_FILE_LIST 1210 #define IDC_SETTINGS_ONCE 1212 #define IDC_OPEN_DOWNLOADS 1213