File: n_colors.sru
Size: 10300
Date: Mon, 31 Dec 2018 21:14:38 +0100
$PBExportHeader$n_colors.sru
forward
global type n_colors from nonvisualobject
end type
end forward

global type n_colors from nonvisualobject autoinstantiate
end type

type prototypes
Function Long GetSystemColor( &
   Integer nIndex &
   ) Library "user32.dll" Alias For "GetSysColor"

end prototypes

type variables
// PowerBuilder Colors
Constant Long PB_BLACK = 0
Constant Long PB_WHITE = 16777215
Constant Long PB_RED = 255
Constant Long PB_FUCHSIA = 16711935
Constant Long PB_LIME = 65280
Constant Long PB_YELLOW = 65535
Constant Long PB_BLUE = 16711680
Constant Long PB_AQUA = 16776960
Constant Long PB_MAROON = 128
Constant Long PB_PURPLE = 8388736
Constant Long PB_GREEN = 32768
Constant Long PB_OLIVE = 32896
Constant Long PB_NAVY = 8388608
Constant Long PB_TEAL = 8421376
Constant Long PB_GRAY = 8421504
Constant Long PB_SILVER = 12632256
Constant Long PB_MINT = 12639424
Constant Long PB_SKY = 15780518
Constant Long PB_CREAM = 15793151
Constant Long PB_MEDIUMGRAY = 10789024
Constant Long PB_WINDOW_BACKGROUND = 1073741824
Constant Long PB_WINDOW_TEXT = 33554432
Constant Long PB_APPLICATION_WORKSPACE = 268435456
Constant Long PB_BUTTON_FACE = 67108864
Constant Long PB_SCROLL_BAR = 134217728
Constant Long PB_DESKTOP = 134217729
Constant Long PB_ACTIVE_TITLE_BAR = 134217730
Constant Long PB_INACTIVE_TITLE_BAR = 134217731
Constant Long PB_MENU_BAR = 134217732
Constant Long PB_WINDOW_FRAME = 134217734
Constant Long PB_MENU_TEXT = 134217735
Constant Long PB_ACTIVE_TITLE_BAR_TEXT = 134217737
Constant Long PB_ACTIVE_BORDER = 134217738
Constant Long PB_INACTIVE_BORDER = 134217739
Constant Long PB_HIGHLIGHT = 134217741
Constant Long PB_HIGHLIGHT_TEXT = 134217742
Constant Long PB_BUTTON_SHADOW = 134217744
Constant Long PB_DISABLED_TEXT = 134217745
Constant Long PB_BUTTON_TEXT = 134217746
Constant Long PB_INACTIVE_TITLE_BAR_TEXT = 134217747
Constant Long PB_BUTTON_HIGHLIGHT = 134217748
Constant Long PB_BUTTON_DARK_SHADOW = 134217749
Constant Long PB_BUTTON_LIGHT_SHADOW = 134217750
Constant Long PB_TOOLTIP_TEXT = 134217751
Constant Long PB_TOOLTIP = 134217752
Constant Long PB_LINK = 134217856
Constant Long PB_LINK_HOVER = 134217857
Constant Long PB_LINK_ACTIVE = 134217858
Constant Long PB_LINK_VISITED = 134217859

// Web Colors
Constant Long ALICE_BLUE = 16775408
Constant Long ANTIQUE_WHITE = 14150650
Constant Long AQUAMARINE = 13959039
Constant Long AZURE = 16777200
Constant Long BEIGE = 14480885
Constant Long BISQUE = 12903679
Constant Long BLACK = 0
Constant Long BLANCHED_ALMOND = 13495295
Constant Long BLUE = 16711680
Constant Long BLUE_VIOLET = 14822282
Constant Long BROWN = 32896
Constant Long BURLYWOOD = 8894686
Constant Long CADET_BLUE = 10526303
Constant Long CHARTREUSE = 65407
Constant Long CHOCOLATE = 1993170
Constant Long CORAL = 5275647
Constant Long CORNFLOWER_BLUE = 15570276
Constant Long CORNSILK = 14481663
Constant Long CYAN = 16776960
Constant Long DARK_BLUE = 8388608
Constant Long DARK_BROWN = 4210752
Constant Long DARK_CYAN = 8421376
Constant Long DARK_GOLDENROD = 755384
Constant Long DARK_GRAY = 8421504
Constant Long DARK_GREEN = 32768
Constant Long DARK_KHAKI = 7059389
Constant Long DARK_MAGENTA = 8388736
Constant Long DARK_OLIVE_GREEN = 3107669
Constant Long DARK_ORANGE = 36095
Constant Long DARK_ORCHID = 13382297
Constant Long DARK_RED = 128
Constant Long DARK_SALMON = 8034025
Constant Long DARK_SEA_GREEN = 9419919
Constant Long DARK_SLATE_BLUE = 9125192
Constant Long DARK_SLATE_GRAY = 5197615
Constant Long DARK_TURQUOISE = 13749760
Constant Long DARK_VIOLET = 13828244
Constant Long DEEP_PINK = 9639167
Constant Long DEEP_SKY_BLUE = 16760576
Constant Long DIM_GRAY = 6908265
Constant Long DODGER_BLUE = 16748574
Constant Long FIRE_BRICK = 2237106
Constant Long FLORAL_WHITE = 15792895
Constant Long FOREST_GREEN = 2263842
Constant Long GAINSBORO = 14474460
Constant Long GHOST_WHITE = 16775416
Constant Long GOLD = 55295
Constant Long GOLDENROD = 2139610
Constant Long GRAY = 12632256
Constant Long GREEN = 65280
Constant Long GREEN_YELLOW = 3145645
Constant Long HONEYDEW = 15794160
Constant Long HOT_PINK = 11823615
Constant Long INDIAN_RED = 6053069
Constant Long IVORY = 15794175
Constant Long KHAKI = 9234160
Constant Long LAVENDER = 16443110
Constant Long LAVENDER_BLUSH = 16118015
Constant Long LAWN_GREEN = 64636
Constant Long LEMON_CHIFFON = 13499135
Constant Long LIGHT_BLUE = 15128749
Constant Long LIGHT_BROWN = 4163021
Constant Long LIGHT_CORAL = 8421616
Constant Long LIGHT_CYAN = 16777184
Constant Long LIGHT_GOLDENROD = 8576494
Constant Long LIGHT_GOLDENROD_YELLLOW = 13826810
Constant Long LIGHT_GRAY = 12632256
Constant Long LIGHT_PINK = 12695295
Constant Long LIGHT_SALMON = 8036607
Constant Long LIGHT_SEA_GREEN = 11186720
Constant Long LIGHT_SKY_BLUE = 16436871
Constant Long LIGHT_SLATE_BLUE = 16740484
Constant Long LIGHT_SLATE_GRAY = 10061943
Constant Long LIGHT_STEEL_BLUE = 14599344
Constant Long LIGHT_YELLOW = 14745599
Constant Long LIME_GREEN = 3329330
Constant Long LINEN = 15134970
Constant Long MAGENTA = 16711935
Constant Long MAROON = 6303920
Constant Long MEDIUM_AQUAMARINE = 11193702
Constant Long MEDIUM_BLUE = 13434880
Constant Long MEDIUM_ORCHID = 13850042
Constant Long MEDIUM_PURPLE = 14381203
Constant Long MEDIUM_SEA_GREEN = 7451452
Constant Long MEDIUM_SLATE_BLUE = 15624315
Constant Long MEDIUM_SPRING_GREEN = 10156544
Constant Long MEDIUM_TURQUOISE = 13422920
Constant Long MEDIUM_VOILET_RED = 8721863
Constant Long MIDNIGHT_BLUE = 7346457
Constant Long MINT_CREAM = 16449525
Constant Long MISTY_ROSE = 14804223
Constant Long MOCCASIN = 11920639
Constant Long NAVAJO_WHITE = 11394815
Constant Long OLD_LACE = 15136253
Constant Long OLIVE = 32832
Constant Long OLIVE_DRAB = 2330219
Constant Long ORANGE = 42495
Constant Long ORANGE_RED = 17919
Constant Long ORCHID = 14053594
Constant Long PALE_GOLDENROD = 11200750
Constant Long PALE_GREEN = 10025880
Constant Long PALE_TURQUOISE = 15658671
Constant Long PALE_VIOLET_RED = 9662683
Constant Long PAPAYA_WHIP = 14020607
Constant Long PEACH_PUFF = 12180223
Constant Long PINK = 13353215
Constant Long PLUM = 14524637
Constant Long POWDER_BLUE = 15130800
Constant Long PURPLE = 15736992
Constant Long RED = 255
Constant Long ROSY_BROWN = 9408444
Constant Long ROYAL_BLUE = 14772545
Constant Long RUST = 1252800
Constant Long SADDLE_BROWN = 1262987
Constant Long SALMON = 7504122
Constant Long SANDY_BROWN = 6333684
Constant Long SEA_GREEN = 5737262
Constant Long SEASHELL = 15660543
Constant Long SIENNA = 2970272
Constant Long SKY_BLUE = 15453831
Constant Long SLATE_BLUE = 13458026
Constant Long SLATE_GRAY = 9470064
Constant Long SNOW = 16448255
Constant Long SPRING_GREEN = 8388352
Constant Long STEEL_BLUE = 11829830
Constant Long TAN = 9221330
Constant Long THISTLE = 14204888
Constant Long TOMATO = 4678655
Constant Long TURQUOISE = 13688896
Constant Long VIOLET = 15631086
Constant Long VIOLET_RED = 9445584
Constant Long WHEAT = 11788021
Constant Long WHITE = 16777215
Constant Long WHITE_SMOKE = 16119285
Constant Long YELLOW = 65535
Constant Long YELLOW_GREEN = 3329434

end variables

forward prototypes
public subroutine splitrgb (long al_color, ref unsignedinteger aui_red, ref unsignedinteger aui_green, ref unsignedinteger aui_blue)
public function long getpbcolor (long al_color)
end prototypes

public subroutine splitrgb (long al_color, ref unsignedinteger aui_red, ref unsignedinteger aui_green, ref unsignedinteger aui_blue);// -----------------------------------------------------------------------------
// SCRIPT:     n_colors.SplitRGB
//
// PURPOSE:    This function splits color into Red/Green/Blue.
//
// ARGUMENTS:  al_color    - The color value to be split
//             aui_red     - The RED value (by ref)
//             aui_green   - The GREEN value (by ref)
//             aui_blue    - The BLUE value (by ref)
//
// DATE        PROG/ID     DESCRIPTION OF CHANGE / REASON
// ----------  --------    -----------------------------------------------------
// 07/26/2013  RolandS     Initial coding
// -----------------------------------------------------------------------------

aui_Red = Mod(al_Color, 256)
aui_Red *= 256

al_Color /= 256
aui_Green   = Mod(al_Color, 256)
aui_Green *= 256

aui_Blue = al_Color / 256
aui_Blue *= 256

end subroutine

public function long getpbcolor (long al_color);// -----------------------------------------------------------------------------
// SCRIPT:     n_colors.GetPBColor
//
// PURPOSE:    This function gets system colors from PowerBuilder colors.
//
// ARGUMENTS:  al_color - PowerBuilder Color Code
//
// RETURN:     The color value
//
// DATE        PROG/ID     DESCRIPTION OF CHANGE / REASON
// ----------  --------    -----------------------------------------------------
// 07/26/2013  RolandS     Initial coding
// -----------------------------------------------------------------------------

Long ll_color, ll_SysColor

choose case al_color
   case 1073741824   // Window Background
      ll_color = GetSystemColor(5)     // COLOR_WINDOW
   case 33554432     // Window Text
      ll_color = GetSystemColor(8)     // COLOR_WINDOWTEXT
   case 268435456    // Application Workspace
      ll_color = GetSystemColor(12)    // COLOR_APPWORKSPACE
   case 67108864     // Button Face
      ll_color = GetSystemColor(15)    // COLOR_BTNFACE
   case 134217856    // Link
      ll_color = 16711680              // Blue
   case 134217857    // Link Hover
      ll_color = 255                   // Red
   case 134217858    // Link Active
      ll_color = 8388736               // Purple
   case 134217859    // Link Visited
      ll_color = 8388736               // Purple
   case else
      ll_SysColor = al_color - 16777216
      If ll_SysColor < 0 Then
         // Actual Color
         ll_color = al_color
      Else
         If al_color > 134217728 Then
            // System Color not listed above
            ll_SysColor = al_color - 134217728
            ll_color = GetSystemColor(ll_SysColor)
         Else
            // IDE Custom Color
            ll_color = ll_SysColor
         End If
      End If
end choose

Return ll_color

end function

on n_colors.create
call super::create
TriggerEvent( this, "constructor" )
end on

on n_colors.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on