c_cpp Macros.h

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp Macros.h相关的知识,希望对你有一定的参考价值。

#define ApplicationDelegate                 ((AppDelegate *)[[UIApplication sharedApplication] delegate])
#define UserDefaults                        [NSUserDefaults standardUserDefaults]
#define NotificationCenter                  [NSNotificationCenter defaultCenter]
#define SharedApplication                   [UIApplication sharedApplication]
#define Bundle                              [NSBundle mainBundle]
#define MainScreen                          [UIScreen mainScreen]
#define ShowNetworkActivityIndicator()      [UIApplication sharedApplication].networkActivityIndicatorVisible = YES
#define HideNetworkActivityIndicator()      [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
#define NetworkActivityIndicatorVisible(x)  [UIApplication sharedApplication].networkActivityIndicatorVisible = x
#define NavBar                              self.navigationController.navigationBar
#define TabBar                              self.tabBarController.tabBar
#define NavBarHeight                        self.navigationController.navigationBar.bounds.size.height
#define TabBarHeight                        self.tabBarController.tabBar.bounds.size.height
#define ScreenWidth                         [[UIScreen mainScreen] bounds].size.width
#define ScreenHeight                        [[UIScreen mainScreen] bounds].size.height
#define TouchHeightDefault                  44
#define TouchHeightSmall                    32
#define ViewWidth(v)                        v.frame.size.width
#define ViewHeight(v)                       v.frame.size.height
#define ViewX(v)                            v.frame.origin.x
#define ViewY(v)                            v.frame.origin.y
#define SelfViewWidth                       self.view.bounds.size.width
#define SelfViewHeight                      self.view.bounds.size.height
#define RectX(f)                            f.origin.x
#define RectY(f)                            f.origin.y
#define RectWidth(f)                        f.size.width
#define RectHeight(f)                       f.size.height
#define RectSetWidth(f, w)                  CGRectMake(RectX(f), RectY(f), w, RectHeight(f))
#define RectSetHeight(f, h)                 CGRectMake(RectX(f), RectY(f), RectWidth(f), h)
#define RectSetX(f, x)                      CGRectMake(x, RectY(f), RectWidth(f), RectHeight(f))
#define RectSetY(f, y)                      CGRectMake(RectX(f), y, RectWidth(f), RectHeight(f))
#define RectSetSize(f, w, h)                CGRectMake(RectX(f), RectY(f), w, h)
#define RectSetOrigin(f, x, y)              CGRectMake(x, y, RectWidth(f), RectHeight(f))
#define DATE_COMPONENTS                     NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit
#define TIME_COMPONENTS                     NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit
#define FlushPool(p)                        [p drain]; p = [[NSAutoreleasePool alloc] init]
#define RGB(r, g, b)                        [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0]
#define RGBA(r, g, b, a)                    [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define HEXCOLOR(c)                         [UIColor colorWithRed:((c>>16)&0xFF)/255.0 green:((c>>8)&0xFF)/255.0 blue:(c&0xFF)/255.0 alpha:1.0];

#define IBOutletProperty @property (strong, nonatomic) IBOutlet
#define StrongProperty @property (strong, nonatomic)
#define AssignProperty @property (assign, nonatomic)
#define WeakProperty @property (nonatomic, weak)
#define DelegateProperty @property (nonatomic, weak) id delegate

//
//  Macros.h
//
//  Created by John Iacoviello on 11/26/11.
//

// Constants
#define APP_VERSION                             [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]
#define APP_NAME                                [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]
#define APP_DELEGATE                            [[UIApplication sharedApplication] delegate]
#define USER_DEFAULTS                           [NSUserDefaults standardUserDefaults]
#define APPLICATION                             [UIApplication sharedApplication]
#define BUNDLE                                  [NSBundle mainBundle]
#define MAIN_SCREEN                             [UIScreen mainScreen]
#define FILE_MANAGER                            [NSFileManager defaultManager]
#define DOCUMENTS_DIR                           [[FILE_MANAGER URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]
#define NAV_BAR                                 self.navigationController.navigationBar
#define TAB_BAR                                 self.tabBarController.tabBar
#define DATE_COMPONENTS                         NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit
#define IS_PAD                                  ([[UIDevice currentDevice] interfaceIdiom] == UIUserInterfaceIdiomPad)

// Props
#define ScreenWidth                             [MAIN_SCREEN bounds].size.width
#define ScreenHeight                            [MAIN_SCREEN bounds].size.height
#define NavBarHeight                            self.navigationController.navigationBar.bounds.size.height
#define TabBarHeight                            self.tabBarController.tabBar.bounds.size.height
#define SelfBoundsWidth                         self.bounds.size.width
#define SelfBoundsHeight                        self.bounds.size.height
#define SelfFrameWidth                          self.frame.size.width
#define SelfFrameHeight                         self.frame.size.height
#define SelfViewBoundsWidth                     self.view.bounds.size.width
#define SelfViewBoundsHeight                    self.view.bounds.size.height
#define SelfViewFrameWidth                      self.view.frame.size.width
#define SelfViewFrameHeight                     self.view.frame.size.height
#define SelfX                                   self.frame.origin.x
#define SelfY                                   self.frame.origin.y
#define SelfViewX                               self.view.frame.origin.x
#define SelfViewY                               self.view.frame.origin.y

// Utils
#define clamp(n,min,max)                        ((n < min) ? min : (n > max) ? max : n)
#define distance(a,b)                           sqrtf((a-b) * (a-b))
#define point(x,y)                              CGPointMake(x, y)
#define append(a,b)                             [a stringByAppendingString:b];
#define fileExistsAtPath(path)                  [FILE_MANAGER fileExistsAtPath: path]

// Colors
#define hex_rgba(c)                             [UIColor colorWithRed:((c>>24)&0xFF)/255.0 green:((c>>16)&0xFF)/255.0 blue:((c>>8)&0xFF)/255.0 alpha:((c)&0xFF)/255.0]
#define hex_rgb(c)                              [UIColor colorWithRed:((c>>16)&0xFF)/255.0 green:((c>>8)&0xFF)/255.0 blue:((c)&0xFF)/255.0 alpha:1.0]

// Views Getters
#define frameWidth(v)                           v.frame.size.width
#define frameHeight(v)                          v.frame.size.height
#define boundsWidth(v)                          v.bounds.size.width
#define boundsHeight(v)                         v.bounds.size.height
#define posX(v)                                 v.frame.origin.x
#define posY(v)                                 v.frame.origin.y

// View Setters
#define setPosX(v,x)                            v.frame = CGRectMake(x, posY(v), frameWidth(v), frameHeight(v))
#define setPosY(v,y)                            v.frame = CGRectMake(posX(v), y, frameWidth(v), frameHeight(v))
#define setFramePosition(v,x,y)                 v.frame = CGRectMake(x, y, frameWidth(v), frameHeight(v))
#define setFrameSize(v,w,h)                     v.frame = CGRectMake(posX(v), posY(v), w, h)
#define setBoundsPosition(v,x,y)                v.bounds = CGRectMake(x, y, boundsWidth(v), boundsHeight(v))
#define setBoundsSize(v,w,h)                    v.bounds = CGRectMake(posX(v), posY(v), w, h)

// View Transformations
#define rotate(v,r)                             v.transform = CGAffineTransformMakeRotation(r / 180.0 * M_PI)
#define scale(v,sx,sy)                          v.transform = CGAffineTransformMakeScale(sx, sy)
#define animate(dur,curve,anims)                [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:dur]; [UIView setAnimationCurve:curve]; anims; [UIView commitAnimations]

// Notifications
#define addEventListener(id,s,n,o)              [[NSNotificationCenter defaultCenter] addObserver:id selector:s name:n object:o]
#define removeEventListener(id,n,o)             [[NSNotificationCenter defaultCenter] removeObserver:id name:n object:o]
#define dispatchEvent(n,o)                      [[NSNotificationCenter defaultCenter] postNotificationName:n object:o]
#define dispatchEventWithData(n,o,d)            [[NSNotificationCenter defaultCenter] postNotificationName:n object:o userInfo:d]

// User Defaults
#define boolForKey(k)                           [USER_DEFAULTS boolForKey:k]
#define floatForKey(k)                          [USER_DEFAULTS floatForKey:k]
#define integerForKey(k)                        [USER_DEFAULTS integerForKey:k]
#define objectForKey(k)                         [USER_DEFAULTS objectForKey:k]
#define doubleForKey(k)                         [USER_DEFAULTS doubleForKey:k]
#define urlForKey(k)                            [USER_DEFAULTS urlForKey:k]
#define setBoolForKey(v, k)                     [USER_DEFAULTS setBool:v forKey:k]
#define setFloatForKey(v, k)                    [USER_DEFAULTS setFloat:v forKey:k]
#define setIntegerForKey(v, k)                  [USER_DEFAULTS setInteger:v forKey:k]
#define setObjectForKey(v, k)                   [USER_DEFAULTS setObject:v forKey:k]
#define setDoubleForKey(v, k)                   [USER_DEFAULTS setDouble:v forKey:k]
#define setURLForKey(v, k)                      [USER_DEFAULTS setURL:v forKey:k]
#define saveUserDefaults()                      [USER_DEFAULTS synchronize]

// NSLog only in debug mode
#if DEBUG == 1
    #define Log(...) NSLog(__VA_ARGS__)
#else
    #define Log(...) do {} while (0)
#endif

以上是关于c_cpp Macros.h的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp Macros.h

大家快过来看看这个macros.h文件哪里有错误呢?用keil编译提示有错误……我找不出来

AVR BOOT

AVR单片机 电压显示

急求AVR单片机8515简单程序

ROS turtlebot_follower :让机器人跟随我们移动