Example #1
0
/** Load the icon for a client. */
void LoadIcon(ClientNode *np)
{

   IconPathNode *ip;

   Assert(np);

   SetIconSize();

   /* If client already has an icon, destroy it first. */
   DestroyIcon(np->icon);
   np->icon = NULL;

   /* Attempt to read _NET_WM_ICON for an icon */
   ReadNetWMIcon(np);
   if(np->icon) {
      return;
   }

   /* Attempt to find an icon for this program in the icon directory */
   if(np->instanceName) {
      for(ip = iconPaths; ip; ip = ip->next) {

#ifdef USE_PNG
         np->icon = LoadSuffixedIcon(ip->path, np->instanceName, ".png");
         if(np->icon) {
            return;
         }
#endif

#ifdef USE_XPM
         np->icon = LoadSuffixedIcon(ip->path, np->instanceName, ".xpm");
         if(np->icon) {
            return;
         }
#endif

#ifdef USE_JPEG
         np->icon = LoadSuffixedIcon(ip->path, np->instanceName, ".jpg");
         if(np->icon) {
            return;
         }
#endif

#ifdef USE_ICONS
         np->icon = LoadSuffixedIcon(ip->path, np->instanceName, ".xbm");
         if(np->icon) {
            return;
         }
#endif

      }
   }

   /* Load the default icon */
   np->icon = GetDefaultIcon();

}
Example #2
0
void CDreamSkinWindow::GetDefaultItem(SKINITEM *pItem, COLORREF clrBk, COLORREF clrTxt, COLORREF clrBd, int nWidthBd)
{
	pItem->nDefault = 1;
	GetDefaultBackground(&pItem->skinBk, clrBk);

	GetDefaultBorder(&pItem->skinLBorder, clrBd, nWidthBd);
	GetDefaultBorder(&pItem->skinRBorder, clrBd, nWidthBd);
	GetDefaultBorder(&pItem->skinTBorder, clrBd, nWidthBd);
	GetDefaultBorder(&pItem->skinBBorder, clrBd, nWidthBd);

	GetDefaultText(&pItem->skinTxt, clrTxt);
	GetDefaultIcon(&pItem->skinIcon, clrTxt);
}
Example #3
0
File: frame.cpp Project: EdgarTx/wx
bool wxFrame::HandlePaint()
{
    RECT rect;
    if ( ::GetUpdateRect(GetHwnd(), &rect, FALSE) )
    {
#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
        if ( m_iconized )
        {
            const wxIcon& icon = GetIcon();
            HICON hIcon = icon.Ok() ? GetHiconOf(icon)
                                    : (HICON)GetDefaultIcon();

            // Hold a pointer to the dc so long as the OnPaint() message
            // is being processed
            PAINTSTRUCT ps;
            HDC hdc = ::BeginPaint(GetHwnd(), &ps);

            // Erase background before painting or we get white background
            MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L);

            if ( hIcon )
            {
                RECT rect;
                ::GetClientRect(GetHwnd(), &rect);

                // FIXME: why hardcoded?
                static const int icon_width = 32;
                static const int icon_height = 32;

                int icon_x = (int)((rect.right - icon_width)/2);
                int icon_y = (int)((rect.bottom - icon_height)/2);

                ::DrawIcon(hdc, icon_x, icon_y, hIcon);
            }

            ::EndPaint(GetHwnd(), &ps);

            return true;
        }
        else
 #endif
        {
            return wxWindow::HandlePaint();
        }
    }
    else
    {
        // nothing to paint - processed
        return true;
    }
}
Example #4
0
File: icon.c Project: Miteam/jwm
/** Load the icon for a client. */
void LoadIcon(ClientNode *np)
{
   /* If client already has an icon, destroy it first. */
   DestroyIcon(np->icon);
   np->icon = NULL;

   /* Attempt to read _NET_WM_ICON for an icon. */
   np->icon = ReadNetWMIcon(np->window);
   if(np->icon) {
      return;
   }
   if(np->owner != None) {
      np->icon = ReadNetWMIcon(np->owner);
      if(np->icon) {
         return;
      }
   }

   /* Attempt to read an icon from XWMHints. */
   np->icon = ReadWMHintIcon(np->window);
   if(np->icon) {
      return;
   }
   if(np->owner != None) {
      np->icon = ReadNetWMIcon(np->owner);
      if(np->icon) {
         return;
      }
   }

   /* Attempt to read an icon based on the window name. */
   if(np->instanceName) {
      np->icon = LoadNamedIcon(np->instanceName, 1, 1);
      if(np->icon) {
         return;
      }
   }

   /* Load the default icon */
   np->icon = GetDefaultIcon();
}
Example #5
0
/** Draw a specific task bar. */
void Render(const TaskBarType *bp)
{
   TaskEntry *tp;
   char *displayName;
   ButtonNode button;
   int x, y;

   if(JUNLIKELY(shouldExit)) {
      return;
   }

   ClearTrayDrawable(bp->cp);
   if(!taskEntries) {
      UpdateSpecificTray(bp->cp->tray, bp->cp);
      return;
   }

   ResetButton(&button, bp->cp->pixmap);
   button.border = settings.trayDecorations == DECO_MOTIF;
   button.font = FONT_TASKLIST;
   button.height = bp->itemHeight;
   button.width = bp->itemWidth;
   button.text = NULL;

   x = 0;
   y = 0;
   for(tp = taskEntries; tp; tp = tp->next) {

      if(!ShouldShowEntry(tp)) {
         continue;
      }

      /* Check for an active or urgent window and count clients. */
      ClientEntry *cp;
      unsigned clientCount = 0;
      button.type = BUTTON_TASK;
      for(cp = tp->clients; cp; cp = cp->next) {
         if(ShouldFocus(cp->client, 0)) {
            const char flash = (cp->client->state.status & STAT_FLASH) != 0;
            const char active = (cp->client->state.status & STAT_ACTIVE)
               && IsClientOnCurrentDesktop(cp->client);
            if(flash || active) {
               if(button.type == BUTTON_TASK) {
                  button.type = BUTTON_TASK_ACTIVE;
               } else {
                  button.type = BUTTON_TASK;
               }
            }
            clientCount += 1;
         }
      }
      button.x = x;
      button.y = y;
      if(!tp->clients->client->icon) {
         button.icon = GetDefaultIcon();
      } else {
         button.icon = tp->clients->client->icon;
      }
      displayName = NULL;
      if(tp->clients->client->className && settings.groupTasks) {
         if(clientCount != 1) {
            const size_t len = strlen(tp->clients->client->className) + 16;
            displayName = Allocate(len);
            snprintf(displayName, len, "%s (%u)",
                     tp->clients->client->className, clientCount);
            button.text = displayName;
         } else {
            button.text = tp->clients->client->className;
         }
      } else {
         button.text = tp->clients->client->name;
      }
      DrawButton(&button);
      if(displayName) {
         Release(displayName);
      }

      if(bp->layout == LAYOUT_HORIZONTAL) {
         x += bp->itemWidth;
      } else {
         y += bp->itemHeight;
      }
   }

   UpdateSpecificTray(bp->cp->tray, bp->cp);

}
Example #6
0
/** Show the menu associated with a task list item. */
void ShowClientList(TaskBarType *bar, TaskEntry *tp)
{
   Menu *menu;
   MenuItem *item;
   ClientEntry *cp;

   const ScreenType *sp;
   int x, y;
   Window w;

   if(settings.groupTasks) {

      menu = Allocate(sizeof(Menu));
      menu->itemHeight = 0;
      menu->items = NULL;
      menu->label = NULL;

      item = CreateMenuItem(MENU_ITEM_NORMAL);
      item->name = CopyString(_("Close"));
      item->action.type = MA_CLOSE | MA_GROUP_MASK;
      item->action.context = tp;
      item->next = menu->items;
      menu->items = item;

      item = CreateMenuItem(MENU_ITEM_NORMAL);
      item->name = CopyString(_("Minimize"));
      item->action.type = MA_MINIMIZE | MA_GROUP_MASK;
      item->action.context = tp;
      item->next = menu->items;
      menu->items = item;

      item = CreateMenuItem(MENU_ITEM_NORMAL);
      item->name = CopyString(_("Restore"));
      item->action.type = MA_RESTORE | MA_GROUP_MASK;
      item->action.context = tp;
      item->next = menu->items;
      menu->items = item;

      item = CreateMenuItem(MENU_ITEM_SUBMENU);
      item->name = CopyString(_("Send To"));
      item->action.type = MA_SENDTO_MENU | MA_GROUP_MASK;
      item->action.context = tp;
      item->next = menu->items;
      menu->items = item;

      /* Load the separator and group actions. */
      item = CreateMenuItem(MENU_ITEM_SEPARATOR);
      item->next = menu->items;
      menu->items = item;

      /* Load the clients into the menu. */
      for(cp = tp->clients; cp; cp = cp->next) {
         if(!ShouldFocus(cp->client, 0)) {
            continue;
         }
         item = CreateMenuItem(MENU_ITEM_NORMAL);
         if(cp->client->state.status & STAT_MINIMIZED) {
            size_t len = 0;
            if(cp->client->name) {
               len = strlen(cp->client->name);
            }
            item->name = Allocate(len + 3);
            item->name[0] = '[';
            memcpy(&item->name[1], cp->client->name, len);
            item->name[len + 1] = ']';
            item->name[len + 2] = 0;
         } else {
            item->name = CopyString(cp->client->name);
         }
         item->icon = cp->client->icon ? cp->client->icon : GetDefaultIcon();
         item->action.type = MA_EXECUTE;
         item->action.context = cp->client;
         item->next = menu->items;
         menu->items = item;
      }
   } else {
      /* Not grouping clients. */
      menu = CreateWindowMenu(tp->clients->client);
   }

   /* Initialize and position the menu. */
   InitializeMenu(menu);
   sp = GetCurrentScreen(bar->cp->screenx, bar->cp->screeny);
   GetMousePosition(&x, &y, &w);
   if(bar->layout == LAYOUT_HORIZONTAL) {
      if(bar->cp->screeny + bar->cp->height / 2 < sp->y + sp->height / 2) {
         /* Bottom of the screen: menus go up. */
         y = bar->cp->screeny + bar->cp->height;
      } else {
         /* Top of the screen: menus go down. */
         y = bar->cp->screeny - menu->height;
      }
      x -= menu->width / 2;
      x = Max(x, sp->x);
   } else {
      if(bar->cp->screenx + bar->cp->width / 2 < sp->x + sp->width / 2) {
         /* Left side: menus go right. */
         x = bar->cp->screenx + bar->cp->width;
      } else {
         /* Right side: menus go left. */
         x = bar->cp->screenx - menu->width;
      }
      y -= menu->height / 2;
      y = Max(y, sp->y);
   }

   ShowMenu(menu, RunTaskBarCommand, x, y, 0);

   DestroyMenu(menu);

}
int GetDefaultFileIconIndex(void)
{
	return GetDefaultIcon(DEFAULT_ICON_FILE);
}
int GetDefaultFolderIconIndex(void)
{
	return GetDefaultIcon(DEFAULT_ICON_FOLDER);
}
Example #9
0
WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
    WXLRESULT rc = 0;
    bool processed = false;

    switch ( message )
    {
        case WM_CLOSE:
            // if we can't close, tell the system that we processed the
            // message - otherwise it would close us
            processed = !Close();
            break;

        case WM_SIZE:
            processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
            break;

        case WM_COMMAND:
            {
                WORD id, cmd;
                WXHWND hwnd;
                UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam,
                              &id, &hwnd, &cmd);

                HandleCommand(id, cmd, (WXHWND)hwnd);

                // don't pass WM_COMMAND to the base class whether we processed
                // it or not because we did generate an event for it (our
                // HandleCommand() calls the base class version) and we must
                // not do it again or the handlers which skip the event would
                // be called twice
                processed = true;
            }
            break;

        case WM_INITMENUPOPUP:
        case WM_UNINITMENUPOPUP:
            // We get these messages from the menu bar even if the menu is
            // disabled, which is unexpected, so ignore them in this case.
            if ( wxMenuBar* mbar = GetMenuBar() )
            {
                const int pos = mbar->MSWGetTopMenuPos((WXHMENU)wParam);
                if ( pos != wxNOT_FOUND && !mbar->IsEnabledTop(pos) )
                {
                    // This event comes from a disabled top level menu, don't
                    // handle it.
                    return MSWDefWindowProc(message, wParam, lParam);
                }
            }
            break;

        case WM_QUERYDRAGICON:
            {
                const wxIcon& icon = GetIcon();
                HICON hIcon = icon.IsOk() ? GetHiconOf(icon)
                                        : (HICON)GetDefaultIcon();
                rc = (WXLRESULT)hIcon;
                processed = rc != 0;
            }
            break;
    }
#if wxUSE_TASKBARBUTTON
    if ( message == wxMsgTaskbarButtonCreated )
    {
        if ( m_taskBarButton )
            m_taskBarButton->Realize();

        processed = true;
    }
#endif

    if ( !processed )
        rc = wxFrameBase::MSWWindowProc(message, wParam, lParam);

    return rc;
}
	void CreateSmileyButton(void)
	{
		doSmileyButton = opt.ButtonStatus != 0;
		OldButtonPlace = opt.ButtonStatus == 2;

		SmileyPackType* SmileyPack = GetSmileyPack(ProtocolName, hContact);
		doSmileyButton &= SmileyPack != NULL && SmileyPack->VisibleSmileyCount() != 0;

		bool showButtonLine;
		if (IsOldSrmm()) {
			isSplit = db_get_b(NULL,"SRMsg","Split", TRUE) != 0;

			doSmileyReplace = (isSplit || !isSend);
			doSmileyButton &= isSplit ||  isSend;
			showButtonLine = db_get_b(NULL, "SRMsg", "ShowButtonLine", TRUE) != 0;
		}
		else {
			doSmileyReplace = true;
			OldButtonPlace = false;
			showButtonLine = db_get_b(NULL, "SRMM", "ShowButtonLine", TRUE) != 0;
		}

		doSmileyButton &= OldButtonPlace || showButtonLine;

		if (ProtocolName[0] != 0) {
			INT_PTR cap = CallProtoService(ProtocolName, PS_GETCAPS, PFLAGNUM_1, 0);
			doSmileyButton  &= ((cap & (PF1_IMSEND | PF1_CHAT)) != 0);
			doSmileyReplace &= ((cap & (PF1_IMRECV | PF1_CHAT)) != 0);
		}

		if (doSmileyButton && opt.PluginSupportEnabled) {
			//create smiley button
			RECT rect = CalcSmileyButtonPos();

			hSmlButton = CreateWindowEx(
				WS_EX_LEFT | WS_EX_NOPARENTNOTIFY | WS_EX_TOPMOST,
				MIRANDABUTTONCLASS,
				_T("S"),
				WS_CHILD|WS_VISIBLE|WS_TABSTOP, // window style
				rect.left,                      // horizontal position of window
				rect.top,                       // vertical position of window
				rect.bottom - rect.top + 1,     // window width
				rect.bottom - rect.top + 1,     // window height
				GetParent(LButton),             // handle to parent or owner window
				(HMENU) IDC_SMLBUTTON,          // menu handle or child identifier
				NULL,                           // handle to application instance
				NULL);                          // window-creation data

			// Conversion to bitmap done to prevent Miranda from scaling the image
			SmileyType* sml = FindButtonSmiley(SmileyPack);
			if (sml != NULL) {
				hSmlBmp = sml->GetBitmap(GetSysColor(COLOR_BTNFACE), 0, 0);
				SendMessage(hSmlButton, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hSmlBmp);
			}
			else {
				hSmlIco = GetDefaultIcon(); 
				SendMessage(hSmlButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hSmlIco);
			}

			SendMessage(hSmlButton, BUTTONADDTOOLTIP, (WPARAM)LPGEN("Show smiley selection window"), 0);
			SendMessage(hSmlButton, BUTTONSETASFLATBTN, TRUE, 0);
		}
	}
Example #11
0
WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
    WXLRESULT rc = 0;
    bool processed = false;

    switch ( message )
    {
        case WM_CLOSE:
            // if we can't close, tell the system that we processed the
            // message - otherwise it would close us
            processed = !Close();
            break;

        case WM_SIZE:
            processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
            break;

        case WM_COMMAND:
            {
                WORD id, cmd;
                WXHWND hwnd;
                UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam,
                              &id, &hwnd, &cmd);

                HandleCommand(id, cmd, (WXHWND)hwnd);

                // don't pass WM_COMMAND to the base class whether we processed
                // it or not because we did generate an event for it (our
                // HandleCommand() calls the base class version) and we must
                // not do it again or the handlers which skip the event would
                // be called twice
                processed = true;
            }
            break;

#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
#if wxUSE_MENUS
        case WM_INITMENUPOPUP:
            processed = HandleInitMenuPopup((WXHMENU) wParam);
            break;

        case WM_MENUSELECT:
            {
                WXWORD item, flags;
                WXHMENU hmenu;
                UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu);

                processed = HandleMenuSelect(item, flags, hmenu);
            }
            break;

        case WM_EXITMENULOOP:
            processed = HandleMenuLoop(wxEVT_MENU_CLOSE, (WXWORD)wParam);
            break;
#endif // wxUSE_MENUS

        case WM_QUERYDRAGICON:
            {
                const wxIcon& icon = GetIcon();
                HICON hIcon = icon.IsOk() ? GetHiconOf(icon)
                                        : (HICON)GetDefaultIcon();
                rc = (WXLRESULT)hIcon;
                processed = rc != 0;
            }
            break;
#endif // !__WXMICROWIN__
    }

    if ( !processed )
        rc = wxFrameBase::MSWWindowProc(message, wParam, lParam);

    return rc;
}
Example #12
0
File: frame.cpp Project: EdgarTx/wx
WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
    WXLRESULT rc = 0;
    bool processed = false;

    switch ( message )
    {
        case WM_CLOSE:
            // if we can't close, tell the system that we processed the
            // message - otherwise it would close us
            processed = !Close();
            break;

        case WM_SIZE:
            processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
            break;

        case WM_COMMAND:
            {
                WORD id, cmd;
                WXHWND hwnd;
                UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam,
                              &id, &hwnd, &cmd);

                processed = HandleCommand(id, cmd, (WXHWND)hwnd);
            }
            break;

        case WM_PAINT:
            processed = HandlePaint();
            break;

        case WM_INITMENUPOPUP:
            processed = HandleInitMenuPopup((WXHMENU) wParam);
            break;

#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
        case WM_MENUSELECT:
            {
                WXWORD item, flags;
                WXHMENU hmenu;
                UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu);

                processed = HandleMenuSelect(item, flags, hmenu);
            }
            break;

        case WM_EXITMENULOOP:
            processed = HandleMenuLoop(wxEVT_MENU_CLOSE, (WXWORD)wParam);
            break;

        case WM_QUERYDRAGICON:
            {
                const wxIcon& icon = GetIcon();
                HICON hIcon = icon.Ok() ? GetHiconOf(icon)
                                        : (HICON)GetDefaultIcon();
                rc = (long)hIcon;
                processed = rc != 0;
            }
            break;
#endif // !__WXMICROWIN__
    }

    if ( !processed )
        rc = wxFrameBase::MSWWindowProc(message, wParam, lParam);

    return rc;
}