mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
*CtrlLib, Draw: Fixed issues with menu and dark themes in Ubuntu (RM Bug #5)
git-svn-id: svn://ultimatepp.org/upp/trunk@3125 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
4fdf4bb530
commit
093cad7882
12 changed files with 1971 additions and 1978 deletions
|
|
@ -128,4 +128,9 @@ int Grayscale(const Color& c)
|
|||
return (77 * c.GetR() + 151 * c.GetG() + 28 * c.GetB()) >> 8;
|
||||
}
|
||||
|
||||
bool IsDark(Color c)
|
||||
{
|
||||
return Grayscale(c) < 80;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ Color Blend(Color c1, Color c2, int alpha = 128);
|
|||
String ColorToHtml(Color color);
|
||||
|
||||
int Grayscale(const Color& c);
|
||||
bool IsDark(Color c);
|
||||
|
||||
|
||||
inline bool operator==(const Value& v, Color x) { return v == x.operator Value(); }
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ MTrand::MTrand()
|
|||
#ifdef PLATFORM_POSIX
|
||||
int fd = open("/dev/urandom", O_RDONLY);
|
||||
read(fd, seed, sizeof(seed));
|
||||
close(fd);
|
||||
#else
|
||||
for(int i = 0; i < 1024; i++) {
|
||||
Uuid uuid;
|
||||
|
|
|
|||
|
|
@ -1884,6 +1884,11 @@ ckPaint]()&]
|
|||
[s7;i1120;a17; [*/ Return value]-|BackPaint(NOBACKPAINT).&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Ctrl`:`:BackPaintHint`(`):%- [_^Ctrl^ Ctrl][@(0.0.255) `&]_[* BackPaintHint]()&]
|
||||
[s2; Activates FULLBACKPAINT mode if computer is a `"decent machine`"
|
||||
(simple heurestics to identify fast enough PC with enough memory).&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Ctrl`:`:GetBackPaint`(`)const:%- [@(0.0.255) int]_[* GetBackPaint]()_[@(0.0.255) const
|
||||
]&]
|
||||
[s7;i1120;a17; [*/ Return value]-|Current back`-paint mode of Ctrl.&]
|
||||
|
|
|
|||
|
|
@ -1191,7 +1191,7 @@ void ChHostSkin()
|
|||
Image mimg = GetGTK(popup, 0, 2, "menu", GTK_BGBOX, 32, 32);
|
||||
Color c = mimg[16][16];
|
||||
Value rlook;
|
||||
if(!IsNull(c) && Diff(c, SColorPaper()) < 200)
|
||||
if(!IsNull(c)/* && Diff(c, SColorPaper()) < 200*/)
|
||||
SColorMenu_Write(c);
|
||||
{
|
||||
MenuBar::Style& s = MenuBar::StyleDefault().Write();
|
||||
|
|
|
|||
|
|
@ -1,183 +1,181 @@
|
|||
#include "CtrlLib.h"
|
||||
|
||||
#ifndef CtrlCore_MenuImp_h
|
||||
#define CtrlCore_MenuImp_h
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
class MenuItemBase : public Ctrl, public Bar::Item
|
||||
{
|
||||
public:
|
||||
virtual Bar::Item& Text(const char *text);
|
||||
virtual Bar::Item& Key(dword key);
|
||||
virtual Bar::Item& Image(const UPP::Image& img);
|
||||
virtual Bar::Item& Enable(bool _enable);
|
||||
virtual Bar::Item& Tip(const char *tip);
|
||||
virtual Bar::Item& Help(const char *help);
|
||||
virtual Bar::Item& Topic(const char *help);
|
||||
virtual Bar::Item& Description(const char *desc);
|
||||
virtual Bar::Item& Check(bool check);
|
||||
virtual Bar::Item& Radio(bool check);
|
||||
|
||||
virtual String GetDesc() const;
|
||||
virtual dword GetAccessKeys() const;
|
||||
virtual void AssignAccessKeys(dword used);
|
||||
|
||||
protected:
|
||||
enum {
|
||||
NOTHING, CHECK0, CHECK1, RADIO0, RADIO1
|
||||
};
|
||||
|
||||
enum {
|
||||
NORMAL, HIGHLIGHT, PUSH
|
||||
};
|
||||
|
||||
String text;
|
||||
dword accel;
|
||||
int state;
|
||||
int leftgap, textgap;
|
||||
Font font;
|
||||
bool isenabled;
|
||||
byte type;
|
||||
int accesskey;
|
||||
Size maxiconsize;
|
||||
const MenuBar::Style *style;
|
||||
|
||||
public:
|
||||
virtual void SyncState() = 0;
|
||||
|
||||
void DrawMenuText(Draw& w, int x, int y, const String& s, Font f, bool enabled, bool hl,
|
||||
Color color, Color hlcolor);
|
||||
void PaintTopItem(Draw& w, int state);
|
||||
|
||||
bool IsItemEnabled() const { return isenabled; }
|
||||
String GetText() const { return text; }
|
||||
MenuItemBase& LeftGap(int cx) { leftgap = cx; return *this; }
|
||||
MenuItemBase& TextGap(int cx) { textgap = cx; return *this; }
|
||||
MenuItemBase& SetFont(Font f) { font = f; return *this; }
|
||||
MenuItemBase& Style(const MenuBar::Style *s) { style = s; return *this; }
|
||||
Font GetFont() const { return font; }
|
||||
MenuItemBase& MaxIconSize(Size sz) { maxiconsize = sz; return *this; }
|
||||
|
||||
MenuItemBase();
|
||||
};
|
||||
|
||||
void DrawMenuText(Draw& w, int x, int y, const String& s, Font f, bool enabled,
|
||||
bool highlight, int mn, Color color, Color hltext);
|
||||
|
||||
class MenuItem : public MenuItemBase {
|
||||
public:
|
||||
virtual void Paint(Draw& w);
|
||||
virtual void MouseEnter(Point, dword);
|
||||
virtual void MouseLeave();
|
||||
virtual Size GetMinSize() const;
|
||||
virtual void LeftUp(Point, dword);
|
||||
virtual void RightUp(Point, dword);
|
||||
virtual void GotFocus();
|
||||
virtual void LostFocus();
|
||||
virtual bool Key(dword key, int count);
|
||||
virtual bool HotKey(dword key);
|
||||
virtual void SyncState();
|
||||
|
||||
virtual Bar::Item& Image(const UPP::Image& img);
|
||||
|
||||
private:
|
||||
UPP::Image licon, ricon;
|
||||
|
||||
void SendHelpLine();
|
||||
void ClearHelpLine();
|
||||
|
||||
protected:
|
||||
virtual int GetVisualState();
|
||||
|
||||
public:
|
||||
MenuItem& RightImage(const UPP::Image& img);
|
||||
};
|
||||
|
||||
class SubMenuBase {
|
||||
protected:
|
||||
MenuBar menu;
|
||||
Callback1<Bar&> proc;
|
||||
MenuBar *parentmenu;
|
||||
|
||||
void Pull(Ctrl *item, Point p, Size sz);
|
||||
|
||||
public:
|
||||
virtual void Pull() = 0;
|
||||
|
||||
void SetParent(MenuBar *m) { parentmenu = m; menu.MaxIconSize(m->GetMaxIconSize()); }
|
||||
void Set(Callback1<Bar&> _submenu) { proc = _submenu; }
|
||||
Callback1<Bar&> Get() { return proc; }
|
||||
|
||||
SubMenuBase() { parentmenu = NULL; }
|
||||
virtual ~SubMenuBase() {}
|
||||
};
|
||||
|
||||
class SubMenuItem : public MenuItem, public SubMenuBase {
|
||||
public:
|
||||
virtual void MouseEnter(Point, dword);
|
||||
virtual void MouseLeave();
|
||||
virtual void GotFocus();
|
||||
virtual bool HotKey(dword key);
|
||||
virtual bool Key(dword key, int count);
|
||||
virtual int GetVisualState();
|
||||
virtual void Pull();
|
||||
|
||||
protected:
|
||||
enum {
|
||||
TIMEID_PULL = BarCtrl::TIMEID_COUNT,
|
||||
TIMEID_COUNT
|
||||
};
|
||||
|
||||
public:
|
||||
typedef SubMenuItem CLASSNAME;
|
||||
|
||||
SubMenuItem();
|
||||
};
|
||||
|
||||
class TopSubMenuItem : public MenuItemBase, public SubMenuBase {
|
||||
public:
|
||||
virtual void Paint(Draw& w);
|
||||
virtual void MouseEnter(Point, dword);
|
||||
virtual void MouseLeave();
|
||||
virtual void GotFocus();
|
||||
virtual void LostFocus();
|
||||
virtual void LeftDown(Point, dword);
|
||||
virtual void SyncState();
|
||||
virtual Size GetMinSize() const;
|
||||
virtual bool Key(dword key, int);
|
||||
virtual bool HotKey(dword key);
|
||||
virtual void Pull();
|
||||
|
||||
private:
|
||||
int GetState();
|
||||
|
||||
public:
|
||||
TopSubMenuItem() { NoInitFocus(); }
|
||||
};
|
||||
|
||||
class TopMenuItem : public MenuItemBase {
|
||||
public:
|
||||
virtual void Paint(Draw& w);
|
||||
virtual void MouseEnter(Point, dword);
|
||||
virtual void MouseLeave();
|
||||
virtual void LeftUp(Point, dword);
|
||||
virtual void LeftDown(Point, dword);
|
||||
virtual void GotFocus();
|
||||
virtual void LostFocus();
|
||||
virtual bool Key(dword key, int count);
|
||||
virtual Size GetMinSize() const;
|
||||
virtual void SyncState();
|
||||
|
||||
static int GetStdHeight(Font font = StdFont());
|
||||
|
||||
private:
|
||||
int GetState();
|
||||
|
||||
public:
|
||||
TopMenuItem() { NoInitFocus(); }
|
||||
};
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
#include "CtrlLib.h"
|
||||
|
||||
#ifndef CtrlCore_MenuImp_h
|
||||
#define CtrlCore_MenuImp_h
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
class MenuItemBase : public Ctrl, public Bar::Item
|
||||
{
|
||||
public:
|
||||
virtual Bar::Item& Text(const char *text);
|
||||
virtual Bar::Item& Key(dword key);
|
||||
virtual Bar::Item& Image(const UPP::Image& img);
|
||||
virtual Bar::Item& Enable(bool _enable);
|
||||
virtual Bar::Item& Tip(const char *tip);
|
||||
virtual Bar::Item& Help(const char *help);
|
||||
virtual Bar::Item& Topic(const char *help);
|
||||
virtual Bar::Item& Description(const char *desc);
|
||||
virtual Bar::Item& Check(bool check);
|
||||
virtual Bar::Item& Radio(bool check);
|
||||
|
||||
virtual String GetDesc() const;
|
||||
virtual dword GetAccessKeys() const;
|
||||
virtual void AssignAccessKeys(dword used);
|
||||
|
||||
protected:
|
||||
enum {
|
||||
NOTHING, CHECK0, CHECK1, RADIO0, RADIO1
|
||||
};
|
||||
|
||||
enum {
|
||||
NORMAL, HIGHLIGHT, PUSH
|
||||
};
|
||||
|
||||
String text;
|
||||
dword accel;
|
||||
int state;
|
||||
int leftgap, textgap;
|
||||
Font font;
|
||||
bool isenabled;
|
||||
byte type;
|
||||
int accesskey;
|
||||
Size maxiconsize;
|
||||
const MenuBar::Style *style;
|
||||
|
||||
public:
|
||||
virtual void SyncState() = 0;
|
||||
|
||||
void DrawMenuText(Draw& w, int x, int y, const String& s, Font f, bool enabled, bool hl,
|
||||
Color color, Color hlcolor);
|
||||
void PaintTopItem(Draw& w, int state);
|
||||
|
||||
bool IsItemEnabled() const { return isenabled; }
|
||||
String GetText() const { return text; }
|
||||
MenuItemBase& LeftGap(int cx) { leftgap = cx; return *this; }
|
||||
MenuItemBase& TextGap(int cx) { textgap = cx; return *this; }
|
||||
MenuItemBase& SetFont(Font f) { font = f; return *this; }
|
||||
MenuItemBase& Style(const MenuBar::Style *s) { style = s; return *this; }
|
||||
Font GetFont() const { return font; }
|
||||
MenuItemBase& MaxIconSize(Size sz) { maxiconsize = sz; return *this; }
|
||||
bool InOpaqueBar() const;
|
||||
|
||||
MenuItemBase();
|
||||
};
|
||||
|
||||
class MenuItem : public MenuItemBase {
|
||||
public:
|
||||
virtual void Paint(Draw& w);
|
||||
virtual void MouseEnter(Point, dword);
|
||||
virtual void MouseLeave();
|
||||
virtual Size GetMinSize() const;
|
||||
virtual void LeftUp(Point, dword);
|
||||
virtual void RightUp(Point, dword);
|
||||
virtual void GotFocus();
|
||||
virtual void LostFocus();
|
||||
virtual bool Key(dword key, int count);
|
||||
virtual bool HotKey(dword key);
|
||||
virtual void SyncState();
|
||||
|
||||
virtual Bar::Item& Image(const UPP::Image& img);
|
||||
|
||||
private:
|
||||
UPP::Image licon, ricon;
|
||||
|
||||
void SendHelpLine();
|
||||
void ClearHelpLine();
|
||||
|
||||
protected:
|
||||
virtual int GetVisualState();
|
||||
|
||||
public:
|
||||
MenuItem& RightImage(const UPP::Image& img);
|
||||
};
|
||||
|
||||
class SubMenuBase {
|
||||
protected:
|
||||
MenuBar menu;
|
||||
Callback1<Bar&> proc;
|
||||
MenuBar *parentmenu;
|
||||
|
||||
void Pull(Ctrl *item, Point p, Size sz);
|
||||
|
||||
public:
|
||||
virtual void Pull() = 0;
|
||||
|
||||
void SetParent(MenuBar *m) { parentmenu = m; menu.MaxIconSize(m->GetMaxIconSize()); }
|
||||
void Set(Callback1<Bar&> _submenu) { proc = _submenu; }
|
||||
Callback1<Bar&> Get() { return proc; }
|
||||
|
||||
SubMenuBase() { parentmenu = NULL; }
|
||||
virtual ~SubMenuBase() {}
|
||||
};
|
||||
|
||||
class SubMenuItem : public MenuItem, public SubMenuBase {
|
||||
public:
|
||||
virtual void MouseEnter(Point, dword);
|
||||
virtual void MouseLeave();
|
||||
virtual void GotFocus();
|
||||
virtual bool HotKey(dword key);
|
||||
virtual bool Key(dword key, int count);
|
||||
virtual int GetVisualState();
|
||||
virtual void Pull();
|
||||
|
||||
protected:
|
||||
enum {
|
||||
TIMEID_PULL = BarCtrl::TIMEID_COUNT,
|
||||
TIMEID_COUNT
|
||||
};
|
||||
|
||||
public:
|
||||
typedef SubMenuItem CLASSNAME;
|
||||
|
||||
SubMenuItem();
|
||||
};
|
||||
|
||||
class TopSubMenuItem : public MenuItemBase, public SubMenuBase {
|
||||
public:
|
||||
virtual void Paint(Draw& w);
|
||||
virtual void MouseEnter(Point, dword);
|
||||
virtual void MouseLeave();
|
||||
virtual void GotFocus();
|
||||
virtual void LostFocus();
|
||||
virtual void LeftDown(Point, dword);
|
||||
virtual void SyncState();
|
||||
virtual Size GetMinSize() const;
|
||||
virtual bool Key(dword key, int);
|
||||
virtual bool HotKey(dword key);
|
||||
virtual void Pull();
|
||||
|
||||
private:
|
||||
int GetState();
|
||||
|
||||
public:
|
||||
TopSubMenuItem() { NoInitFocus(); }
|
||||
};
|
||||
|
||||
class TopMenuItem : public MenuItemBase {
|
||||
public:
|
||||
virtual void Paint(Draw& w);
|
||||
virtual void MouseEnter(Point, dword);
|
||||
virtual void MouseLeave();
|
||||
virtual void LeftUp(Point, dword);
|
||||
virtual void LeftDown(Point, dword);
|
||||
virtual void GotFocus();
|
||||
virtual void LostFocus();
|
||||
virtual bool Key(dword key, int count);
|
||||
virtual Size GetMinSize() const;
|
||||
virtual void SyncState();
|
||||
|
||||
static int GetStdHeight(Font font = StdFont());
|
||||
|
||||
private:
|
||||
int GetState();
|
||||
|
||||
public:
|
||||
TopMenuItem() { NoInitFocus(); }
|
||||
};
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,42 +0,0 @@
|
|||
#include "Draw.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
CH_COLOR(SBlack, Black());
|
||||
CH_COLOR(SGray, Gray());
|
||||
CH_COLOR(SLtGray, LtGray());
|
||||
CH_COLOR(SWhiteGray, WhiteGray());
|
||||
CH_COLOR(SWhite, White());
|
||||
CH_COLOR(SRed, Red());
|
||||
CH_COLOR(SGreen, Green());
|
||||
CH_COLOR(SBrown, Brown());
|
||||
CH_COLOR(SBlue, Blue());
|
||||
CH_COLOR(SMagenta, Magenta());
|
||||
CH_COLOR(SCyan, Cyan());
|
||||
CH_COLOR(SYellow, Yellow());
|
||||
CH_COLOR(SLtRed, LtRed());
|
||||
CH_COLOR(SLtGreen, LtGreen());
|
||||
CH_COLOR(SLtYellow, LtYellow());
|
||||
CH_COLOR(SLtBlue, LtBlue());
|
||||
CH_COLOR(SLtMagenta, LtMagenta());
|
||||
CH_COLOR(SLtCyan, LtCyan());
|
||||
|
||||
CH_COLOR(SColorPaper, White());
|
||||
CH_COLOR(SColorFace, LtGray());
|
||||
CH_COLOR(SColorText, Black());
|
||||
CH_COLOR(SColorHighlight, Blue());
|
||||
CH_COLOR(SColorHighlightText, White());
|
||||
CH_COLOR(SColorMenu, LtGray());
|
||||
CH_COLOR(SColorMenuText, Black());
|
||||
CH_COLOR(SColorInfo, LtYellow());
|
||||
CH_COLOR(SColorInfoText, Black());
|
||||
CH_COLOR(SColorDisabled, Gray());
|
||||
CH_COLOR(SColorLight, White());
|
||||
CH_COLOR(SColorShadow, Gray());
|
||||
CH_COLOR(SColorMark, LtBlue());
|
||||
CH_COLOR(SColorLabel, Black()); //////////////
|
||||
|
||||
CH_COLOR(SColorLtFace, Blend(SColorFace, SColorLight));
|
||||
CH_COLOR(SColorDkShadow, Blend(SColorShadow, SColorText));
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
1782
uppsrc/Draw/Draw.h
1782
uppsrc/Draw/Draw.h
File diff suppressed because it is too large
Load diff
|
|
@ -1,42 +1,43 @@
|
|||
#include "Draw.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
CH_COLOR(SBlack, Black());
|
||||
CH_COLOR(SGray, Gray());
|
||||
CH_COLOR(SLtGray, LtGray());
|
||||
CH_COLOR(SWhiteGray, WhiteGray());
|
||||
CH_COLOR(SWhite, White());
|
||||
CH_COLOR(SRed, Red());
|
||||
CH_COLOR(SGreen, Green());
|
||||
CH_COLOR(SBrown, Brown());
|
||||
CH_COLOR(SBlue, Blue());
|
||||
CH_COLOR(SMagenta, Magenta());
|
||||
CH_COLOR(SCyan, Cyan());
|
||||
CH_COLOR(SYellow, Yellow());
|
||||
CH_COLOR(SLtRed, LtRed());
|
||||
CH_COLOR(SLtGreen, LtGreen());
|
||||
CH_COLOR(SLtYellow, LtYellow());
|
||||
CH_COLOR(SLtBlue, LtBlue());
|
||||
CH_COLOR(SLtMagenta, LtMagenta());
|
||||
CH_COLOR(SLtCyan, LtCyan());
|
||||
|
||||
CH_COLOR(SColorPaper, White());
|
||||
CH_COLOR(SColorFace, LtGray());
|
||||
CH_COLOR(SColorText, Black());
|
||||
CH_COLOR(SColorHighlight, Blue());
|
||||
CH_COLOR(SColorHighlightText, White());
|
||||
CH_COLOR(SColorMenu, LtGray());
|
||||
CH_COLOR(SColorMenuText, Black());
|
||||
CH_COLOR(SColorInfo, LtYellow());
|
||||
CH_COLOR(SColorInfoText, Black());
|
||||
CH_COLOR(SColorDisabled, Gray());
|
||||
CH_COLOR(SColorLight, White());
|
||||
CH_COLOR(SColorShadow, Gray());
|
||||
CH_COLOR(SColorMark, LtBlue());
|
||||
|
||||
CH_COLOR(SColorLtFace, Blend(SColorFace, SColorLight));
|
||||
CH_COLOR(SColorDkShadow, Blend(SColorShadow, SColorText));
|
||||
CH_COLOR(SColorLabel, SColorText());
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
#include "Draw.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
CH_COLOR(SBlack, Black());
|
||||
CH_COLOR(SGray, Gray());
|
||||
CH_COLOR(SLtGray, LtGray());
|
||||
CH_COLOR(SWhiteGray, WhiteGray());
|
||||
CH_COLOR(SWhite, White());
|
||||
CH_COLOR(SRed, Red());
|
||||
CH_COLOR(SGreen, Green());
|
||||
CH_COLOR(SBrown, Brown());
|
||||
CH_COLOR(SBlue, Blue());
|
||||
CH_COLOR(SMagenta, Magenta());
|
||||
CH_COLOR(SCyan, Cyan());
|
||||
CH_COLOR(SYellow, Yellow());
|
||||
CH_COLOR(SLtRed, LtRed());
|
||||
CH_COLOR(SLtGreen, LtGreen());
|
||||
CH_COLOR(SLtYellow, LtYellow());
|
||||
CH_COLOR(SLtBlue, LtBlue());
|
||||
CH_COLOR(SLtMagenta, LtMagenta());
|
||||
CH_COLOR(SLtCyan, LtCyan());
|
||||
|
||||
CH_COLOR(SColorPaper, White());
|
||||
CH_COLOR(SColorFace, LtGray());
|
||||
CH_COLOR(SColorText, Black());
|
||||
CH_COLOR(SColorHighlight, Blue());
|
||||
CH_COLOR(SColorHighlightText, White());
|
||||
CH_COLOR(SColorMenu, LtGray());
|
||||
CH_COLOR(SColorMenuText, Black());
|
||||
CH_COLOR(SColorInfo, LtYellow());
|
||||
CH_COLOR(SColorInfoText, Black());
|
||||
CH_COLOR(SColorDisabled, Gray());
|
||||
CH_COLOR(SColorLight, White());
|
||||
CH_COLOR(SColorShadow, Gray());
|
||||
CH_COLOR(SColorMark, IsDark(SColorPaper()) ? LtYellow() : LtBlue());
|
||||
CH_COLOR(SColorMenuMark, IsDark(SColorMenu()) ? LtYellow() : LtBlue());
|
||||
|
||||
CH_COLOR(SColorLtFace, Blend(SColorFace, SColorLight));
|
||||
CH_COLOR(SColorDkShadow, Blend(SColorShadow, SColorText));
|
||||
CH_COLOR(SColorLabel, SColorText());
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -1,201 +1,201 @@
|
|||
/*
|
||||
* inttypes.h
|
||||
*
|
||||
* Small ersatz subset of <inttypes.h>, deriving the types from
|
||||
* <limits.h>.
|
||||
*
|
||||
* Important: the preprocessor may truncate numbers too large for it.
|
||||
* Therefore, test the signed types only ... truncation won't generate
|
||||
* a 01111111... bit pattern.
|
||||
*/
|
||||
|
||||
#ifndef INTTYPES_H
|
||||
#define INTTYPES_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
/*** 64-bit type: long or long long ***/
|
||||
|
||||
/* Some old versions of gcc <limits.h> omit LLONG_MAX */
|
||||
#ifndef LLONG_MAX
|
||||
# ifdef __LONG_LONG_MAX__
|
||||
# define LLONG_MAX __LONG_LONG_MAX__
|
||||
# else
|
||||
# define LLONG_MAX 0 /* Assume long long is unusable */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if LONG_MAX == 9223372036854775807L
|
||||
|
||||
/* long is 64 bits */
|
||||
typedef signed long int64_t;
|
||||
typedef unsigned long uint64_t;
|
||||
#define _scn64 "l"
|
||||
#define _pri64 "l"
|
||||
#define INT64_C(x) x ## L
|
||||
#define UINT64_C(x) x ## UL
|
||||
|
||||
#elif LLONG_MAX == 9223372036854775807LL
|
||||
|
||||
/* long long is 64 bits */
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
#define _scn64 "ll"
|
||||
#define _pri64 "ll"
|
||||
#define INT64_C(x) x ## LL
|
||||
#define UINT64_C(x) x ## ULL
|
||||
|
||||
#else
|
||||
|
||||
#error "Neither long nor long long is 64 bits in size"
|
||||
|
||||
#endif
|
||||
|
||||
/*** 32-bit type: int or long ***/
|
||||
|
||||
#if INT_MAX == 2147483647
|
||||
|
||||
/* int is 32 bits */
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
#define _scn32 ""
|
||||
#define _pri32 ""
|
||||
#define INT32_C(x) x
|
||||
#define UINT32_C(x) x ## U
|
||||
|
||||
#elif LONG_MAX == 2147483647L
|
||||
|
||||
/* long is 32 bits */
|
||||
typedef signed long int32_t;
|
||||
typedef unsigned long uint32_t;
|
||||
#define _scn32 "l"
|
||||
#define _pri32 "l"
|
||||
#define INT32_C(x) x ## L
|
||||
#define UINT32_C(x) x ## UL
|
||||
|
||||
#else
|
||||
|
||||
#error "Neither int nor long is 32 bits in size"
|
||||
|
||||
#endif
|
||||
|
||||
/*** 16-bit size: int or short ***/
|
||||
|
||||
#if INT_MAX == 32767
|
||||
|
||||
/* int is 16 bits */
|
||||
typedef signed int int16_t;
|
||||
typedef unsigned int uint16_t;
|
||||
#define _scn16 ""
|
||||
#define _pri16 ""
|
||||
#define INT16_C(x) x
|
||||
#define UINT16_C(x) x ## U
|
||||
|
||||
#elif SHRT_MAX == 32767
|
||||
|
||||
/* short is 16 bits */
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
#define _scn16 "h"
|
||||
#define _pri16 ""
|
||||
#define INT16_C(x) x
|
||||
#define UINT16_C(x) x ## U
|
||||
|
||||
#else
|
||||
|
||||
#error "Neither short nor int is 16 bits in size"
|
||||
|
||||
#endif
|
||||
|
||||
/*** 8-bit size: char ***/
|
||||
|
||||
#if SCHAR_MAX == 127
|
||||
|
||||
/* char is 8 bits */
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
#define _scn8 "hh"
|
||||
#define _pri8 ""
|
||||
#define INT8_C(x) x
|
||||
#define UINT8_C(x) x ## U
|
||||
|
||||
#else
|
||||
|
||||
#error "char is not 8 bits in size"
|
||||
|
||||
#endif
|
||||
|
||||
/* The rest of this is common to all models */
|
||||
|
||||
#define PRId8 _pri8 "d"
|
||||
#define PRId16 _pri16 "d"
|
||||
#define PRId32 _pri32 "d"
|
||||
#define PRId64 _pri64 "d"
|
||||
|
||||
#define PRIi8 _pri8 "i"
|
||||
#define PRIi16 _pri16 "i"
|
||||
#define PRIi32 _pri32 "i"
|
||||
#define PRIi64 _pri64 "i"
|
||||
|
||||
#define PRIo8 _pri8 "o"
|
||||
#define PRIo16 _pri16 "o"
|
||||
#define PRIo32 _pri32 "o"
|
||||
#define PRIo64 _pri64 "o"
|
||||
|
||||
#define PRIu8 _pri8 "u"
|
||||
#define PRIu16 _pri16 "u"
|
||||
#define PRIu32 _pri32 "u"
|
||||
#define PRIu64 _pri64 "u"
|
||||
|
||||
#define PRIx8 _pri8 "x"
|
||||
#define PRIx16 _pri16 "x"
|
||||
#define PRIx32 _pri32 "x"
|
||||
#define PRIx64 _pri64 "x"
|
||||
|
||||
#define PRIX8 _pri8 "X"
|
||||
#define PRIX16 _pri16 "X"
|
||||
#define PRIX32 _pri32 "X"
|
||||
#define PRIX64 _pri64 "X"
|
||||
|
||||
#define SCNd8 _scn8 "d"
|
||||
#define SCNd16 _scn16 "d"
|
||||
#define SCNd32 _scn32 "d"
|
||||
#define SCNd64 _scn64 "d"
|
||||
|
||||
#define SCNi8 _scn8 "i"
|
||||
#define SCNi16 _scn16 "i"
|
||||
#define SCNi32 _scn32 "i"
|
||||
#define SCNi64 _scn64 "i"
|
||||
|
||||
#define SCNo8 _scn8 "o"
|
||||
#define SCNo16 _scn16 "o"
|
||||
#define SCNo32 _scn32 "o"
|
||||
#define SCNo64 _scn64 "o"
|
||||
|
||||
#define SCNu8 _scn8 "u"
|
||||
#define SCNu16 _scn16 "u"
|
||||
#define SCNu32 _scn32 "u"
|
||||
#define SCNu64 _scn64 "u"
|
||||
|
||||
#define SCNx8 _scn8 "x"
|
||||
#define SCNx16 _scn16 "x"
|
||||
#define SCNx32 _scn32 "x"
|
||||
#define SCNx64 _scn64 "x"
|
||||
|
||||
#define INT8_MIN INT8_C(-128)
|
||||
#define INT8_MAX INT8_C(127)
|
||||
#define UINT8_MAX UINT8_C(255)
|
||||
|
||||
#define INT16_MIN INT16_C(-32768)
|
||||
#define INT16_MAX INT16_C(32767)
|
||||
#define UINT16_MAX UINT16_C(65535)
|
||||
|
||||
#define INT32_MIN INT32_C(-2147483648)
|
||||
#define INT32_MAX INT32_C(2147483647)
|
||||
#define UINT32_MAX UINT32_C(4294967295)
|
||||
|
||||
#define INT64_MIN INT64_C(-9223372036854775808)
|
||||
#define INT64_MAX INT64_C(9223372036854775807)
|
||||
#define UINT64_MAX UINT64_C(18446744073709551615)
|
||||
|
||||
#endif /* INTTYPES_H */
|
||||
/*
|
||||
* inttypes.h
|
||||
*
|
||||
* Small ersatz subset of <inttypes.h>, deriving the types from
|
||||
* <limits.h>.
|
||||
*
|
||||
* Important: the preprocessor may truncate numbers too large for it.
|
||||
* Therefore, test the signed types only ... truncation won't generate
|
||||
* a 01111111... bit pattern.
|
||||
*/
|
||||
|
||||
#ifndef INTTYPES_H
|
||||
#define INTTYPES_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
/*** 64-bit type: long or long long ***/
|
||||
|
||||
/* Some old versions of gcc <limits.h> omit LLONG_MAX */
|
||||
#ifndef LLONG_MAX
|
||||
# ifdef __LONG_LONG_MAX__
|
||||
# define LLONG_MAX __LONG_LONG_MAX__
|
||||
# else
|
||||
# define LLONG_MAX 0 /* Assume long long is unusable */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if LONG_MAX == 9223372036854775807L
|
||||
|
||||
/* long is 64 bits */
|
||||
typedef signed long int64_t;
|
||||
typedef unsigned long uint64_t;
|
||||
#define _scn64 "l"
|
||||
#define _pri64 "l"
|
||||
#define INT64_C(x) x ## L
|
||||
#define UINT64_C(x) x ## UL
|
||||
|
||||
#elif LLONG_MAX == 9223372036854775807LL
|
||||
|
||||
/* long long is 64 bits */
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
#define _scn64 "ll"
|
||||
#define _pri64 "ll"
|
||||
#define INT64_C(x) x ## LL
|
||||
#define UINT64_C(x) x ## ULL
|
||||
|
||||
#else
|
||||
|
||||
#error "Neither long nor long long is 64 bits in size"
|
||||
|
||||
#endif
|
||||
|
||||
/*** 32-bit type: int or long ***/
|
||||
|
||||
#if INT_MAX == 2147483647
|
||||
|
||||
/* int is 32 bits */
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
#define _scn32 ""
|
||||
#define _pri32 ""
|
||||
#define INT32_C(x) x
|
||||
#define UINT32_C(x) x ## U
|
||||
|
||||
#elif LONG_MAX == 2147483647L
|
||||
|
||||
/* long is 32 bits */
|
||||
typedef signed long int32_t;
|
||||
typedef unsigned long uint32_t;
|
||||
#define _scn32 "l"
|
||||
#define _pri32 "l"
|
||||
#define INT32_C(x) x ## L
|
||||
#define UINT32_C(x) x ## UL
|
||||
|
||||
#else
|
||||
|
||||
#error "Neither int nor long is 32 bits in size"
|
||||
|
||||
#endif
|
||||
|
||||
/*** 16-bit size: int or short ***/
|
||||
|
||||
#if INT_MAX == 32767
|
||||
|
||||
/* int is 16 bits */
|
||||
typedef signed int int16_t;
|
||||
typedef unsigned int uint16_t;
|
||||
#define _scn16 ""
|
||||
#define _pri16 ""
|
||||
#define INT16_C(x) x
|
||||
#define UINT16_C(x) x ## U
|
||||
|
||||
#elif SHRT_MAX == 32767
|
||||
|
||||
/* short is 16 bits */
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
#define _scn16 "h"
|
||||
#define _pri16 ""
|
||||
#define INT16_C(x) x
|
||||
#define UINT16_C(x) x ## U
|
||||
|
||||
#else
|
||||
|
||||
#error "Neither short nor int is 16 bits in size"
|
||||
|
||||
#endif
|
||||
|
||||
/*** 8-bit size: char ***/
|
||||
|
||||
#if SCHAR_MAX == 127
|
||||
|
||||
/* char is 8 bits */
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
#define _scn8 "hh"
|
||||
#define _pri8 ""
|
||||
#define INT8_C(x) x
|
||||
#define UINT8_C(x) x ## U
|
||||
|
||||
#else
|
||||
|
||||
#error "char is not 8 bits in size"
|
||||
|
||||
#endif
|
||||
|
||||
/* The rest of this is common to all models */
|
||||
|
||||
#define PRId8 _pri8 "d"
|
||||
#define PRId16 _pri16 "d"
|
||||
#define PRId32 _pri32 "d"
|
||||
#define PRId64 _pri64 "d"
|
||||
|
||||
#define PRIi8 _pri8 "i"
|
||||
#define PRIi16 _pri16 "i"
|
||||
#define PRIi32 _pri32 "i"
|
||||
#define PRIi64 _pri64 "i"
|
||||
|
||||
#define PRIo8 _pri8 "o"
|
||||
#define PRIo16 _pri16 "o"
|
||||
#define PRIo32 _pri32 "o"
|
||||
#define PRIo64 _pri64 "o"
|
||||
|
||||
#define PRIu8 _pri8 "u"
|
||||
#define PRIu16 _pri16 "u"
|
||||
#define PRIu32 _pri32 "u"
|
||||
#define PRIu64 _pri64 "u"
|
||||
|
||||
#define PRIx8 _pri8 "x"
|
||||
#define PRIx16 _pri16 "x"
|
||||
#define PRIx32 _pri32 "x"
|
||||
#define PRIx64 _pri64 "x"
|
||||
|
||||
#define PRIX8 _pri8 "X"
|
||||
#define PRIX16 _pri16 "X"
|
||||
#define PRIX32 _pri32 "X"
|
||||
#define PRIX64 _pri64 "X"
|
||||
|
||||
#define SCNd8 _scn8 "d"
|
||||
#define SCNd16 _scn16 "d"
|
||||
#define SCNd32 _scn32 "d"
|
||||
#define SCNd64 _scn64 "d"
|
||||
|
||||
#define SCNi8 _scn8 "i"
|
||||
#define SCNi16 _scn16 "i"
|
||||
#define SCNi32 _scn32 "i"
|
||||
#define SCNi64 _scn64 "i"
|
||||
|
||||
#define SCNo8 _scn8 "o"
|
||||
#define SCNo16 _scn16 "o"
|
||||
#define SCNo32 _scn32 "o"
|
||||
#define SCNo64 _scn64 "o"
|
||||
|
||||
#define SCNu8 _scn8 "u"
|
||||
#define SCNu16 _scn16 "u"
|
||||
#define SCNu32 _scn32 "u"
|
||||
#define SCNu64 _scn64 "u"
|
||||
|
||||
#define SCNx8 _scn8 "x"
|
||||
#define SCNx16 _scn16 "x"
|
||||
#define SCNx32 _scn32 "x"
|
||||
#define SCNx64 _scn64 "x"
|
||||
|
||||
#define INT8_MIN INT8_C(-128)
|
||||
#define INT8_MAX INT8_C(127)
|
||||
#define UINT8_MAX UINT8_C(255)
|
||||
|
||||
#define INT16_MIN INT16_C(-32768)
|
||||
#define INT16_MAX INT16_C(32767)
|
||||
#define UINT16_MAX UINT16_C(65535)
|
||||
|
||||
#define INT32_MIN INT32_C(-2147483648)
|
||||
#define INT32_MAX INT32_C(2147483647)
|
||||
#define UINT32_MAX UINT32_C(4294967295)
|
||||
|
||||
#define INT64_MIN INT64_C(-9223372036854775808)
|
||||
#define INT64_MAX INT64_C(9223372036854775807)
|
||||
#define UINT64_MAX UINT64_C(18446744073709551615)
|
||||
|
||||
#endif /* INTTYPES_H */
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@
|
|||
#include "ndisasm.h"
|
||||
|
||||
extern "C" {
|
||||
#undef INT64_MIN
|
||||
#undef INT64_MAX
|
||||
#undef UINT64_MAX
|
||||
|
||||
#include "lib/compiler.h"
|
||||
#include "lib/inttypes.h"
|
||||
#include "lib/disasm.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue