Italic Text in Userlist?

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Gratch06
Posts: 141
Joined: 2003-05-25 06:48
Location: USA

Italic Text in Userlist?

Post by Gratch06 » 2003-07-06 06:25

Working on getting a client/server combo going that supports knowing which users are /away and which are not. The way that I'd LIKE to do it is to adjust the userlist to show all users that are /away in italics. What kind of framework would be needed to change a username to italic when it is added to the userlist? I would assume the areas I'd want to work in would be UsersFrame::addUser and UsersFrame::updateUser, though HOW exactly to do it is beyond me. This delves into wtlport (so far as *I* can tell), and I just got "kind of" lost looking at it :)

Code: Select all

UsersFrame::updateUser   ctrlUsers.SetItemText(i, 1, aUser->isOnline() ? CSTRING(ONLINE) : CSTRING(OFFLINE) );
ctrlUsers.SetItemText(i, 2, (aUser->getLastHubName() + " (" + aUser->getLastHubIp() + ")").c_str());

Something to do with the parameters on SetItemText is my bet, but what, I'm not sure. Thanks again.

-Gratch06

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-08 02:46
Location: .pa.us

Post by GargoyleMT » 2003-07-06 18:46

This isn't a real answer, just a cusory one. to get you in the right direction. Mainly, because I've never done this myself.

You'll need to change the control from a standard edit control to a rich text control that will allow you to experiment with formatting options. This is the same type of control that's used in oDC or CZDC for main chat, that allows text colorizing, etc.

Gratch06
Posts: 141
Joined: 2003-05-25 06:48
Location: USA

Post by Gratch06 » 2003-07-09 21:57

OK, I did some backtracking and here's what I came up with...

The list is of type ExListViewCtrl. HubFrame class, private section:

Code: Select all

   ExListViewCtrl ctrlUsers;

I would assume (after finding that UsersFrame.h refers to Favorite Users and not to the userlist (DOH)) that this is the list we're talking about. This list control internally uses standard textboxes (rather than the RichEdit ones) and I'm really not in the mood to remake the WHOLE class just to get one column (usernames) reading as rich text... That's my next step though, unless there is something that I am TOTALLY overlooking (which is really quite possible...). Any insights?

Current (bad) plan of action:
Make an ExListViewCtrlRich class and base it on the other ExListViewCtrl class, but adjust (at least) the first column to RichText. Lots and lots of work :).

:idea: What about the Transfer Pane? Where is the code located for the Transfer pane (at the bottom of the screen, Uploads and downloads). I have the oDC source, so I can see how that was handled and implemented and aim for something similar (since it is rich text in oDC and BCDC for that matter).

-Gratch06

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-08 02:46
Location: .pa.us

Post by GargoyleMT » 2003-07-09 23:46

Gratch06 wrote: :idea: What about the Transfer Pane? Where is the code located for the Transfer pane (at the bottom of the screen, Uploads and downloads).


Take a look in MainFrm.h:441 or so (in my mod - the normal might vary)

Code: Select all

   ExListViewCtrl ctrlTransfers;


Square one, or square two? ;-)

Gratch06
Posts: 141
Joined: 2003-05-25 06:48
Location: USA

Post by Gratch06 » 2003-07-11 04:29

OK, I've got an away flag reading correctly on the user, but for some reason it updates all or nothing....this here executes every time a user is added to the userlist:

Code: Select all

bool HubFrame::updateUser(const User::Ptr& u, bool sorted /* = false */, UserInfo* ui /* = NULL */) {
   //ctrlUsers.SetTextColor(WinUtil::textColor); //Gratch away
   bool userAway = (u->isSet(User::AWAY));
   if (userAway){
      ctrlUsers.SetTextColor(OperaLib::blendColors(WinUtil::bgColor, WinUtil::textColor, 0.8)); //Gratch away
   } else {
      ctrlUsers.SetTextColor(WinUtil::textColor); //Gratch away
   }
.....

Notes: The flag IS picking up correctly...tested that
Opera's libraries are working correctly.

Question: is the userlist an all or nothing kind of deal? Can I set just one item to be dimmed? or is it for all items, period. I'm noticing that the list is always set to the status of the final users data that I receive...leading me to believe that this is the issue....If that is the case, any other solutions?

-Gratch06

Gratch06
Posts: 141
Joined: 2003-05-25 06:48
Location: USA

Post by Gratch06 » 2003-07-11 19:40

from altctrls.h, in the wtlport library:

Code: Select all

   BOOL SetTextColor(COLORREF cr)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (BOOL)::SendMessage(m_hWnd, LVM_SETTEXTCOLOR, 0, cr);
   }


Where does this SendMessage actually go to? a good bit of this is that I've now reached beyond my knowledge in C++ programming. The only other instances I see of this are in the .asm (I would assume assembly language) files........Is there the possibility of adding another function into the ExListViewCtrl class that would make ONLY that text item dimmed (color changed).

from oDC...this is where he dims a download if it is not active (thus making a mixed list of sorts)
(Edit:added reference)
MainFrame.cpp, line 1545 or so (on oDC)

Code: Select all

LRESULT MainFrame::onCustomDraw(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) {
    CRect rc;
    LPNMLVCUSTOMDRAW cd = (LPNMLVCUSTOMDRAW)pnmh;
...
...
else if (cd->iSubItem == COLUMN_FILE || cd->iSubItem == COLUMN_SIZE || cd->iSubItem == COLUMN_PATH) {
         ItemInfo* ii = (ItemInfo*)cd->nmcd.lItemlParam;
         if (ii->type == ItemInfo::TYPE_DOWNLOAD && ii->status != ItemInfo::STATUS_RUNNING) {
            cd->clrText = OperaLib::blendColors(WinUtil::bgColor, WinUtil::textColor, 0.6);
            return CDRF_NEWFONT;
         }
      }
Can a similar method be used?

-Gratch06

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-08 02:46
Location: .pa.us

Post by GargoyleMT » 2003-07-19 21:27

Gratch06 wrote:Where does this SendMessage actually go to?


Well, into the comctl32 DLL of course. :)

I've done a little playing with regular list-views on my own, but not for this purpose, and nothing seems relevant to your questions...

Who is online

Users browsing this forum: Google [Bot] and 0 guests