-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added classes to represent a toolbar button. This is a base class tha…
…t can be extended. The alternative to a button is a separator hence the separation.
- Loading branch information
1 parent
cb03452
commit 7ed67c2
Showing
3 changed files
with
535 additions
and
1 deletion.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
src/BetterControls/BetterToolbar/Items/BetterToolbarButton.NativeStructure.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
namespace BetterControls | ||
{ | ||
/// <summary> | ||
/// Extend this class to create a toolbar item that is a button. | ||
/// </summary> | ||
partial class BetterToolbarButton | ||
{ | ||
/// <summary> | ||
/// <inheritdoc/> | ||
/// </summary> | ||
/// <returns><inheritdoc/></returns> | ||
internal override NativeMethods.TBBUTTON ComputeTbButton() | ||
{ | ||
NativeMethods.TBBUTTON structure = base.ComputeTbButton(); | ||
|
||
structure.fsStyle |= NativeMethods.BTNS_AUTOSIZE; | ||
|
||
if (ShowImage) | ||
structure.iBitmap = ImageIndexer.ComputedIndex; | ||
if (Enabled) | ||
structure.fsState |= NativeMethods.TBSTATE_ENABLED; | ||
if (Pressed) | ||
structure.fsState |= NativeMethods.TBSTATE_PRESSED; | ||
|
||
structure.iString = _stringIndex = OwnerToolbar.AddString(Text); | ||
|
||
return structure; | ||
} | ||
|
||
/// <summary> | ||
/// <inheritdoc/> | ||
/// </summary> | ||
/// <returns><inheritdoc/></returns> | ||
internal override NativeMethods.TBBUTTONINFO ComputeTbButtonInfo() | ||
{ | ||
NativeMethods.TBBUTTONINFO structure = base.ComputeTbButtonInfo(); | ||
|
||
structure.dwMask |= NativeMethods.TBIF_IMAGE | NativeMethods.TBIF_STATE | NativeMethods.TBIF_STYLE; | ||
|
||
if (ShowImage) | ||
structure.iImage = ImageIndexer.ComputedIndex; | ||
if (Enabled) | ||
structure.fsState |= NativeMethods.TBSTATE_ENABLED; | ||
if (Pressed) | ||
structure.fsState |= NativeMethods.TBSTATE_PRESSED; | ||
|
||
structure.dwMask |= NativeMethods.TBIF_TEXT; | ||
|
||
structure.pszText = Marshal.StringToHGlobalAuto(Text); | ||
|
||
_previousText = Text; | ||
|
||
return structure; | ||
} | ||
} | ||
} |
Oops, something went wrong.