コード例 #1
0
ファイル: PlayerIcon.cpp プロジェクト: Salamek/Shadow-of-Dust
/*
===============
idPlayerIcon::Draw
===============
*/
void idPlayerIcon::Draw( idPlayer *player, const idVec3 &origin ) {
	idPlayer *localPlayer = gameLocal.GetLocalPlayer();
	if ( !localPlayer || !localPlayer->GetRenderView() ) {
		FreeIcon();
		return;
	}

	idMat3 axis = localPlayer->GetRenderView()->viewaxis;

	if ( player->isLagged && !player->spectating ) {
		// create the icon if necessary, or update if already created
		if ( !CreateIcon( player, ICON_LAG, origin, axis ) ) {
			UpdateIcon( player, origin, axis );
		}
	} else if ( player->isChatting && !player->spectating ) {
		if ( !CreateIcon( player, ICON_CHAT, origin, axis ) ) {
			UpdateIcon( player, origin, axis );
		}
#ifdef CTF
	} else if ( g_CTFArrows.GetBool() && gameLocal.mpGame.IsGametypeFlagBased() && gameLocal.GetLocalPlayer() && player->team == gameLocal.GetLocalPlayer()->team && !player->IsHidden() && !player->AI_DEAD ) {
		int icon = ICON_TEAM_RED + player->team;

		if ( icon != ICON_TEAM_RED && icon != ICON_TEAM_BLUE )
			return;

		if ( !CreateIcon( player, ( playerIconType_t )icon, origin, axis ) ) {
			UpdateIcon( player, origin, axis );
		}
#endif
	} else {
		FreeIcon();
	}
}
コード例 #2
0
ファイル: UICellCustomItems.cpp プロジェクト: 2asoft/xray
void CUIWeaponCellItem::Update()
{
	bool b						= Heading();
	inherited::Update			();
	
	bool bForceReInitAddons		= (b!=Heading());

	if (object()->SilencerAttachable())
	{
		if (object()->IsSilencerAttached())
		{
			if (!GetIcon(eSilencer) || bForceReInitAddons)
			{
				CreateIcon	(eSilencer);
				InitAddon	(GetIcon(eSilencer), *object()->GetSilencerName(), m_addon_offset[eSilencer], Heading());
			}
		}
		else
		{
			if (m_addons[eSilencer])
				DestroyIcon(eSilencer);
		}
	}

	if (object()->ScopeAttachable()){
		if (object()->IsScopeAttached())
		{
			if (!GetIcon(eScope) || bForceReInitAddons)
			{
				CreateIcon	(eScope);
				InitAddon	(GetIcon(eScope), *object()->GetScopeName(), m_addon_offset[eScope], Heading());
			}
		}
		else
		{
			if (m_addons[eScope])
				DestroyIcon(eScope);
		}
	}

	if (object()->GrenadeLauncherAttachable()){
		if (object()->IsGrenadeLauncherAttached())
		{
			if (!GetIcon(eLauncher) || bForceReInitAddons)
			{
				CreateIcon	(eLauncher);
				InitAddon	(GetIcon(eLauncher), *object()->GetGrenadeLauncherName(), m_addon_offset[eLauncher], Heading());
			}
		}
		else
		{
			if (m_addons[eLauncher])
				DestroyIcon(eLauncher);
		}
	}
}
コード例 #3
0
ファイル: WindowImplWin32.cpp プロジェクト: Aiscky/Zappy
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetIcon
////////////////////////////////////////////////////////////
void WindowImplWin32::SetIcon(unsigned int Width, unsigned int Height, const Uint8* Pixels)
{
    // First destroy the previous one
    if (myIcon)
        DestroyIcon(myIcon);

    // Windows wants BGRA pixels : swap red and blue channels
    std::vector<Uint8> IconPixels(Width * Height * 4);
    for (std::size_t i = 0; i < IconPixels.size() / 4; ++i)
    {
        IconPixels[i * 4 + 0] = Pixels[i * 4 + 2];
        IconPixels[i * 4 + 1] = Pixels[i * 4 + 1];
        IconPixels[i * 4 + 2] = Pixels[i * 4 + 0];
        IconPixels[i * 4 + 3] = Pixels[i * 4 + 3];
    }

    // Create the icon from the pixels array
    myIcon = CreateIcon(GetModuleHandle(NULL), Width, Height, 1, 32, NULL, &IconPixels[0]);

    // Set it as both big and small icon of the window
    if (myIcon)
    {
        SendMessage(myHandle, WM_SETICON, ICON_BIG,   (LPARAM)myIcon);
        SendMessage(myHandle, WM_SETICON, ICON_SMALL, (LPARAM)myIcon);
    }
    else
    {
        std::cerr << "Failed to set the window's icon" << std::endl;
    }
}
コード例 #4
0
ファイル: list-view.cpp プロジェクト: ChoccyHobNob/DiCE
void pListView::setImage(unsigned row, unsigned column, const nall::image& image) {
  QTreeWidgetItem* item = qtListView->topLevelItem(row);
  if(item) {
    if(image.empty() == 0) item->setIcon(column, CreateIcon(image));
    if(image.empty() == 1) item->setIcon(column, QIcon());
  }
}
コード例 #5
0
ファイル: icon.c プロジェクト: KarlGodt/jwm
/** Create an icon from XPM image data. */
IconNode *CreateIconFromData(const char *name, char **data)
{

   ImageNode *image;
   IconNode *result;

   Assert(name);
   Assert(data);

   /* Check if this icon has already been loaded */
   result = FindIcon(name);
   if(result) {
      return result;
   }

   image = LoadImageFromData(data);
   if(image) {
      result = CreateIcon();
      result->name = CopyString(name);
      result->images = image;
      InsertIcon(result);
      return result;
   } else {
      return NULL;
   }

}
コード例 #6
0
BOOL CGeneralMsgBox::OnInitDialog()
{
  if (!CDialog::OnInitDialog())
    return FALSE;

  SetWindowText(m_strTitle);

  // Getting the base dialog unit used in pixel <-> d.u. conversion
  CRect rc(0, 0, CX_DLGUNIT_BASE, CY_DLGUNIT_BASE);
  MapDialogRect(rc);

  m_dimDlgUnit = rc.Size();

  // Creating the nested controls
  CreateRtfCtrl();
  CreateIcon();
  CreateBtns();

  // Updating the layout - preparing to show
  UpdateLayout();

  // Disabling the ESC key
  if (m_uiEscCmdId == (UINT)IDC_STATIC)
    ModifyStyle(WS_SYSMENU, NULL);

  // Focusing and setting the defaul button
  if (m_uiDefCmdId != (UINT)IDC_STATIC) {
    GetDlgItem(m_uiDefCmdId)->SetFocus();
    SetDefID(m_uiDefCmdId);

    return FALSE;
  }

  return TRUE;
}
コード例 #7
0
ファイル: icon.c プロジェクト: KarlGodt/jwm
/** Create an icon from the specified file. */
IconNode *CreateIconFromFile(const char *fileName,
                             char save, char preserveAspect)
{

   ImageNode *image;
   IconNode *result;

   if(!fileName) {
      return NULL;
   }

   /* Check if this icon has already been loaded */
   result = FindIcon(fileName);
   if(result) {
      return result;
   }

   image = LoadImage(fileName);
   if(image) {
      result = CreateIcon();
      result->preserveAspect = preserveAspect;
      result->images = image;
      if(save) {
         result->name = CopyString(fileName);
         InsertIcon(result);
      }
      return result;
   } else {
      return NULL;
   }

}
コード例 #8
0
ファイル: list-view.cpp プロジェクト: Brunnis/bsnes-mercury
void pListView::setImage(unsigned selection, unsigned position, const nall::image& image) {
  QTreeWidgetItem* item = qtListView->topLevelItem(selection);
  if(item) {
    if(image.empty() == 0) item->setIcon(position, CreateIcon(image));
    if(image.empty() == 1) item->setIcon(position, QIcon());
  }
}
コード例 #9
0
ファイル: msgs.cpp プロジェクト: slotwin/miranda-ng
void TSAPI CreateImageList(BOOL bInitial)
{
	int cxIcon = GetSystemMetrics(SM_CXSMICON);
	int cyIcon = GetSystemMetrics(SM_CYSMICON);

	/*
	 * the imagelist is now a fake. It is still needed to provide the tab control with a
	 * image list handle. This will make sure that the tab control will reserve space for
	 * an icon on each tab. This is a blank and empty icon
	 */

	if (bInitial) {
		PluginConfig.g_hImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 0);
		HICON hIcon = CreateIcon(g_hInst, 16, 16, 1, 4, NULL, NULL);
		ImageList_AddIcon(PluginConfig.g_hImageList, hIcon);
		DestroyIcon(hIcon);
	}

	PluginConfig.g_IconFileEvent = LoadSkinnedIcon(SKINICON_EVENT_FILE);
	PluginConfig.g_IconMsgEvent = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE);
	PluginConfig.g_IconMsgEventBig = LoadSkinnedIconBig(SKINICON_EVENT_MESSAGE);
	if ((HICON)CALLSERVICE_NOTFOUND == PluginConfig.g_IconMsgEventBig)
		PluginConfig.g_IconMsgEventBig = 0;
	PluginConfig.g_IconTypingEventBig = LoadSkinnedIconBig(SKINICON_OTHER_TYPING);
	if ((HICON)CALLSERVICE_NOTFOUND == PluginConfig.g_IconTypingEventBig)
		PluginConfig.g_IconTypingEventBig = 0;
	PluginConfig.g_IconSend = PluginConfig.g_buttonBarIcons[9];
	PluginConfig.g_IconTypingEvent = PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING];
}
コード例 #10
0
void CRemoteTreeView::CreateImageList()
{
	wxSize s = CThemeProvider::GetIconSize(iconSizeSmall);
	m_pImageList = new wxImageList(s.x, s.y, true, 4);

	// Normal directory
	int index = GetIconIndex(iconType::dir, _T("{78013B9C-3532-4fe1-A418-5CD1955127CC}"), false);
	m_pImageList->Add(CreateIcon(index));
	m_pImageList->Add(CreateIcon(index, _T("ART_UNKNOWN")));

	// Opened directory
	index = GetIconIndex(iconType::opened_dir, _T("{78013B9C-3532-4fe1-A418-5CD1955127CC}"), false);
	m_pImageList->Add(CreateIcon(index));
	m_pImageList->Add(CreateIcon(index, _T("ART_UNKNOWN")));

	SetImageList(m_pImageList);
}
コード例 #11
0
void pRadioButton::setImage(const image& image, Orientation orientation) {
  qtRadioButton->setIconSize(QSize(image.width, image.height));
  qtRadioButton->setIcon(CreateIcon(image));
  qtRadioButton->setStyleSheet("text-align: top;");
  switch(orientation) {
  case Orientation::Horizontal: qtRadioButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); break;
  case Orientation::Vertical:   qtRadioButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);  break;
  }
}
コード例 #12
0
ファイル: shell.c プロジェクト: AlexSteel/wine
static HICON convert_icon_to_32( HICON16 icon16 )
{
    CURSORICONINFO *info = GlobalLock16( icon16 );
    void *and_bits = info + 1;
    void *xor_bits = (BYTE *)and_bits + info->nHeight * 2 * ((info->nWidth + 15) / 16);
    HICON ret = CreateIcon( 0, info->nWidth, info->nHeight, info->bPlanes, info->bBitsPerPixel,
                            and_bits, xor_bits );
    GlobalUnlock16( icon16 );
    return ret;
}
コード例 #13
0
ファイル: icon.c プロジェクト: Miteam/jwm
/** Create an icon from XPM image data. */
IconNode *GetDefaultIcon(void)
{
   static const char * const name = "default";
   const unsigned width = 8;
   const unsigned height = 8;
   const unsigned border = 1;
   ImageNode *image;
   IconNode *result;
   unsigned bytes;
   unsigned x, y;

   /* Check if this icon has already been loaded */
   result = FindIcon(name);
   if(result) {
      return result;
   }

   /* Allocate image data. */
   bytes = (width * height + 7) / 8;
   image = CreateImage(width, height, 1);
   memset(image->data, 0, bytes);
#ifdef USE_XRENDER
   image->render = 0;
#endif

   /* Allocate the icon node. */
   result = CreateIcon(image);
   result->name = CopyString(name);
   result->images = image;
   InsertIcon(result);

   /* Draw the icon. */
   for(y = border; y < height - border; y++) {
      const unsigned pixel_left = y * width + border;
      const unsigned pixel_right = y * width + width - 1 - border;
      const unsigned offset_left = pixel_left / 8;
      const unsigned mask_left = 1 << (pixel_left % 8);
      const unsigned offset_right = pixel_right / 8;
      const unsigned mask_right = 1 << (pixel_right % 8);
      image->data[offset_left] |= mask_left;
      image->data[offset_right] |= mask_right;
   }
   for(x = border; x < width - border; x++) {
      const unsigned pixel_top = x + border * width;
      const unsigned pixel_bottom = x + width * (height - 1 - border);
      const unsigned offset_top = pixel_top / 8;
      const unsigned mask_top = 1 << (pixel_top % 8);
      const unsigned offset_bottom = pixel_bottom / 8;
      const unsigned mask_bottom = 1 << (pixel_bottom % 8);
      image->data[offset_top] |= mask_top;
      image->data[offset_bottom] |= mask_bottom;
   }

   return result;
}
コード例 #14
0
/*
===============
idPlayerIcon::Draw
===============
*/
void idPlayerIcon::Draw( idPlayer *player, const idVec3 &origin ) {
	idPlayer *localPlayer = gameLocal.GetLocalPlayer();
	if( !localPlayer || !localPlayer->GetRenderView() ) {
		FreeIcon();
		return;
	}
	idMat3 axis = localPlayer->GetRenderView()->viewaxis;
	if( player->isLagged ) {
		// create the icon if necessary, or update if already created
		if( !CreateIcon( player, ICON_LAG, origin, axis ) ) {
			UpdateIcon( player, origin, axis );
		}
	} else if( player->isChatting ) {
		if( !CreateIcon( player, ICON_CHAT, origin, axis ) ) {
			UpdateIcon( player, origin, axis );
		}
	} else {
		FreeIcon();
	}
}
コード例 #15
0
ファイル: BlobMgmt.cpp プロジェクト: sylarhl/sqlgoy
void
BlobMgmt::MoveDialog()
{
	HICON hicon;

	//Set icon for dialog	
	hicon = CreateIcon(IDI_MYSQL);
	SendMessage(m_hwnddlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hicon);

	SetInitPos(m_hwnddlg, BLOBVIEWER_SECTION);
	//SetDialogPos(m_hwnddlg, BLOBVIEWER_SECTION);
}
コード例 #16
0
LRESULT CXTPTaskDialogFrame::OnDialogUpdateIcon(WPARAM wParam, LPARAM lParam)
{
    if (wParam == TDIE_ICON_MAIN)
    {
        SAFE_DELETE_HICON(m_hIconMain);
        m_hIconMain = CreateIcon((HICON)lParam, (PCWSTR)lParam, m_sizeIconMain, IsMainIconHandleUsed());

        RecalcLayout();
        return TRUE;
    }

    if (wParam == TDIE_ICON_FOOTER)
    {
        SAFE_DELETE_HICON(m_hIconFooter);
        m_hIconFooter = CreateIcon((HICON)lParam, (PCWSTR)lParam, m_sizeIconFooter, IsFooterIconHandleUsed());

        RecalcLayout();
        return TRUE;
    }

    return FALSE;
}
コード例 #17
0
ファイル: icon.c プロジェクト: Miteam/jwm
IconNode *CreateIconFromDrawable(Drawable d, Pixmap mask)
{
   ImageNode *image;

   image = LoadImageFromDrawable(d, mask);
   if(image) {
      IconNode *result = CreateIcon(image);
      result->images = image;
      return result;
   } else {
      return NULL;
   }
}
コード例 #18
0
/*!	\function	CategoryMenuItem::CategoryMenuItem
 *	\brief		Constructor.
 *	\param[in]	labelIn 		Reference to BString that defines the label of the Category.
 *	\param[in]	color		Color associated with the current Category.
 *	\param[in]	message		Message sent on invocation of this item.
 *	\note		Differences from standard BMenuItem constructor
 *				CategoryMenuItem actively rejects the shortcuts and modifiers, therefore
 *				they're not accepted even in standard constructor. Additionally,
 *				function "SetShortcut" is overloaded with empty body.
 */
CategoryMenuItem::CategoryMenuItem( BString& labelIn, const rgb_color color, BMessage* message )
	:
	BMenuItem( labelIn.String(), message ),
	icon( NULL )
{
	this->icon = CreateIcon( color, NULL );
	if ( !this->icon )
	{
		/* Panic! */
		exit(1);
	}

}	// <-- end of constructor of CategoryMenuItem
コード例 #19
0
VOID
SaveAs( VOID )
{
    if( GetFilename( File, GetString( MSG_PROJECT_SAVEAS ) + 2, FREQF_SAVE ) )
    {
        if( SaveConfig( File ) )
        {
            if( CreateIcons )
            {
                CreateIcon( File );
            }
        }
    }
}
コード例 #20
0
/*!
 *	\brief		Constructor.
 *	\details	Constructor from reference to category.
 *	\param[in]	categoryIn	The category
 *	\param[in]	message		The message to be sent
 */
CategoryMenuItem::CategoryMenuItem( const Category &categoryIn,
									BMessage* message )
	:
	BMenuItem( categoryIn.categoryName.String(), message ),
	icon( NULL ),
	currentColor( categoryIn.categoryColor )
{
	this->icon = CreateIcon( categoryIn.categoryColor, NULL );
	if ( !this->icon )
	{
		/* Panic! */
		exit(1);
	}	
}	// <-- end of constructor from reference to Category.
コード例 #21
0
ファイル: EndpointInfo.cpp プロジェクト: mmanley/Antares
EndpointInfo::EndpointInfo(int32 id)
    : m_id(id), m_icon(NULL)
{
    BMidiRoster* roster = BMidiRoster::MidiRoster();
    if (roster) {
        BMidiEndpoint* endpoint = roster->FindEndpoint(id);
        if (endpoint) {
            printf("endpoint %ld = %p\n", id, endpoint);
            BMessage msg;
            if (endpoint->GetProperties(&msg) == B_OK) {
                m_icon = CreateIcon(&msg, DISPLAY_ICON_SIZE);
            }
            endpoint->Release();
        }
    }
}
コード例 #22
0
ファイル: icon.c プロジェクト: Miteam/jwm
/** Load an icon from a file. */
IconNode *LoadNamedIcon(const char *name, char save, char preserveAspect)
{

   IconNode *icon;
   IconPathNode *ip;

   Assert(name);

   /* If no icon is specified, return an empty icon. */
   if(name[0] == 0) {
      return &emptyIcon;
   }

   /* See if this icon has already been loaded. */
   icon = FindIcon(name);
   if(icon) {
      return icon;
   }

   /* Check for an absolute file name. */
   if(name[0] == '/') {
      ImageNode *image = LoadImage(name, 0, 0, 1);
      if(image) {
         icon = CreateIcon(image);
         icon->preserveAspect = preserveAspect;
         icon->name = CopyString(name);
         if(save) {
            InsertIcon(icon);
         }
         DestroyImage(image);
         return icon;
      } else {
         return &emptyIcon;
      }
   }

   /* Try icon paths. */
   for(ip = iconPaths; ip; ip = ip->next) {
      icon = LoadNamedIconHelper(name, ip->path, save, preserveAspect);
      if(icon) {
         return icon;
      }
   }

   /* The default icon. */
   return NULL;
}
コード例 #23
0
/*!	\function		CategoryListView::Update
 *	\brief			Calculates the new height of the item upon font update.
 *	\details		Also recreates the icon.
 */
void 	CategoryListItem::Update( BView* owner, const BFont* font )
{
	// Update the height and width of the item.
	BListItem::Update( owner, font );
	
	// The width of the item may require update.
	int squareSize = ceilf( this->Height() - 2 );	//!< Side of the icon's square.
	int labelSize = font->StringWidth( this->currentLabel.String() );
	if ( this->Width() < ( labelSize + squareSize + SPACING * 4 ) )
	{
		this->SetWidth( labelSize + squareSize + SPACING * 4 );
	}

	// The icon may require an update too.
	this->icon = CreateIcon( currentColor, this->icon );
	
}	// <-- end of function CategoryListItem::Update
コード例 #24
0
/*!
 *	\brief			Constructor from a Category
 *	\details		Includes preparations for multilevel categories
 *	\param[in]	cat		The reference to a category
 *	\param[in]	level	Currently unused
 *	\param[in]	expanded	Currently unused
 */
CategoryListItem::CategoryListItem( const Category &cat, int level, bool expanded )
	:
	BListItem( level, expanded ),
	currentColor( cat.categoryColor ),
	currentLabel( cat.categoryName ),
	icon( NULL )
{
	// Creating of the icon depends on height of the item, thus calculate the height first.
	font_height	fh;
	BFont font(be_plain_font);
	font.GetHeight( &fh );
	SetHeight( ceilf( fh.ascent + fh.descent + fh.leading ) );
	
	GetItemWidth();
	
	// Creating the icon. It's a constant, therefore may be created 
	//	immediately after creation of the item. On color update it will be updated too.
	this->icon = CreateIcon( cat.categoryColor, NULL );
	
}	// <-- end of default constructor for CategoryListItem
コード例 #25
0
ファイル: Acting.cpp プロジェクト: godole/Memory
bool CActing::Acting(shared_ptr<Behavior> a_Behavior, CCPoint a_Pos)
{
	if (m_nBehaviorCount > m_nMaxBehaviorCount && !Behavior::k_bIsDoing)
		return false;

	if (a_Behavior->Action(a_Pos))
	{
		m_listBehavior.push_back(a_Behavior);
		CreateIcon(a_Behavior->getIconFileName());
		m_nBehaviorCount++;
		if (m_nBehaviorCount > 3)
		{
			RemoveFirstMemory();
		}
		SortIcon();
		return true;
	}

	return false;
}
コード例 #26
0
/*!
 *	\brief		Constructor.
 *	\details	Constructor from pointer to category.
 *	\param[in]	categoryIn	The category
 *	\param[in]	message		The message to be sent
 */
CategoryMenuItem::CategoryMenuItem( const Category *categoryIn,
									BMessage* message )
	:
	BMenuItem( "", message ),
	icon( NULL )
{
	if ( !categoryIn )
	{
		/* Received NULL instead of category - can't continue. */
		return;
	}
	BMenuItem::SetLabel( ( categoryIn->categoryName ).String() );
	currentColor = categoryIn->categoryColor;
	this->icon = CreateIcon( categoryIn->categoryColor, NULL );
	if ( !this->icon )
	{
		/* Panic! */
		exit(1);
	}	
}	// <-- end of constructor from pointer to Category.
コード例 #27
0
ファイル: icon.c プロジェクト: Miteam/jwm
/** Helper for loading icons by name. */
IconNode *LoadNamedIconHelper(const char *name, const char *path,
                              char save, char preserveAspect)
{
   IconNode *result;
   char *temp;
   const unsigned nameLength = strlen(name);
   const unsigned pathLength = strlen(path);
   unsigned i, has_extension = 0;
   ImageNode *image;

   temp = AllocateStack(nameLength + pathLength + MAX_EXTENSION_LENGTH + 1);
   memcpy(&temp[0], path, pathLength);
   memcpy(&temp[pathLength], name, nameLength+1);

   result = NULL;
   size_t templen = pathLength + nameLength;
   for(i = 1; i < EXTENSION_COUNT; i++){
      if (!strcmp(ICON_EXTENSIONS[i],temp+templen-strlen(ICON_EXTENSIONS[i]))){ 
         has_extension = 1;
         break; 
      }
   }
   if (has_extension){
      image = LoadImage(temp, 0, 0, 1);
   }else for(i = 0; i < EXTENSION_COUNT; i++) {
      const unsigned len = strlen(ICON_EXTENSIONS[i]);
      memcpy(&temp[templen], ICON_EXTENSIONS[i], len + 1);
      image = LoadImage(temp, 0, 0, 1);
      if (image) break;
   }
   if (image) {
      result = CreateIcon(image);
      result->preserveAspect = preserveAspect;
      result->name = CopyString(temp);
      if (save) InsertIcon(result);
      DestroyImage(image);
   }
   ReleaseStack(temp);

   return result;
}
コード例 #28
0
ファイル: main_window.cpp プロジェクト: zhangsoledad/tdesktop
MainWindow::MainWindow() : QWidget()
, _positionUpdatedTimer(this)
, _body(this)
, _icon(CreateIcon())
, _titleText(qsl("Telegram")) {
	subscribe(Theme::Background(), [this](const Theme::BackgroundUpdate &data) {
		if (data.paletteChanged()) {
			if (_title) {
				_title->update();
			}
			updatePalette();
		}
	});
	subscribe(Global::RefUnreadCounterUpdate(), [this] { updateUnreadCounter(); });
	subscribe(Global::RefWorkMode(), [this](DBIWorkMode mode) { workmodeUpdated(mode); });
	subscribe(Messenger::Instance().authSessionChanged(), [this] { checkAuthSession(); });
	checkAuthSession();

	_isActiveTimer.setCallback([this] { updateIsActive(0); });
	_inactivePressTimer.setCallback([this] { setInactivePress(false); });
}
コード例 #29
0
ファイル: icon.c プロジェクト: KarlGodt/jwm
IconNode *LoadSuffixedIcon(const char *path, const char *name,
                           const char *suffix)
{

   IconNode *result;
   ImageNode *image;
   char *iconName;
   unsigned int len;

   Assert(path);
   Assert(name);
   Assert(suffix);

   len = strlen(name) + strlen(path) + strlen(suffix);
   iconName = Allocate(len + 1);
   strcpy(iconName, path);
   strcat(iconName, name);
   strcat(iconName, suffix);

   result = FindIcon(iconName);
   if(result) {
      Release(iconName);
      return result;
   }

   image = LoadImage(iconName);
   if(image) {
      result = CreateIcon();
      result->name = iconName;
      result->images = image;
      InsertIcon(result);
      return result;
   } else {
      Release(iconName);
      return NULL;
   }

}
コード例 #30
0
ファイル: Window.c プロジェクト: jordanfin/aoc
////////////////////////////////////////////////////////////
/// Change the window's icon
////////////////////////////////////////////////////////////
void WindowSetIcon(UInt32 Width, UInt32 Height, UInt8* Pixels)
{
	Int32 i;
	UInt8 * IconPixels;

    // First destroy the previous one
    if (WindowIcon)
        DestroyIcon(WindowIcon);

	IconPixels = (UInt8*)malloc(Width * Height * 4);

    // Windows wants BGRA pixels : swap red and blue channels
    for (i = 0; i < sizeof(IconPixels) / 4; ++i)
    {
        IconPixels[i * 4 + 0] = Pixels[i * 4 + 2];
        IconPixels[i * 4 + 1] = Pixels[i * 4 + 1];
        IconPixels[i * 4 + 2] = Pixels[i * 4 + 0];
        IconPixels[i * 4 + 3] = Pixels[i * 4 + 3];
    }

    // Create the icon from the pixels array
    WindowIcon = CreateIcon(GetModuleHandle(NULL), Width, Height, 1, 32, NULL, &IconPixels[0]);

    // Set it as both big and small icon of the window
    if (WindowIcon)
    {
        SendMessage(WindowhWnd, WM_SETICON, ICON_BIG,   (LPARAM)WindowIcon);
        SendMessage(WindowhWnd, WM_SETICON, ICON_SMALL, (LPARAM)WindowIcon);
    }
    else
    {
        MessageError("WindowSetIcon", "Failed to set the window's icon.");
    }

	free(IconPixels);
}