Project

General

Profile

Statistics
| Revision:

vdfsplat / AppSrc / cDebugCJCommandBarSystem.pkg @ 67

History | View | Annotate | Download (4.84 KB)

1
//TH-Header
2
//*****************************************************************************************
3
// Copyright (c)  2013 Antwise Solutions
4
// All rights reserved.
5
//
6
// $FileName    : cDebugCJCommandBarSystem
7
// $ProjectName : Vdf Splat Debugger
8
// $Authors     : Wil van Antwerpen
9
// $Created     : 12.15.2013  02:28
10
// $Type        : GPLv2
11
//
12
// Contents:
13
//
14
//*****************************************************************************************
15
//TH-RevisionStart
16
//TH-RevisionEnd             
17

    
18
// these are all the packages used in a standard MDI menubar/toolbar system
19

    
20
Use cCJCommandBarSystem.pkg
21
Use cCJStandardMenuItemClasses.pkg
22
Use cCJAboutMenuItem.pkg
23
Use cDebugCJMenuItemClasses.pkg
24
Use cCJMDIWindowsMenuItem.pkg
25

    
26

    
27
//
28
Class cDebugCJCommandBarSystem is a cCJCommandBarSystem
29
  Procedure Construct_Object
30
    forward send Construct_Object
31
    
32
    Set pbTimerUpdate To True // must set this to dynamically update enabled state
33
  End_Procedure // Construct_Object
34

    
35

    
36
  // Code copied in from VDF17.1 to overcome the extremely ugly icons.
37
  // Auto excluded for higher VDF versions that have this fix already
38
#IF (FMAC_VERSION < 17)
39
//****** COPY CODE STARTS
40
    // Adds an image to imagelist. Pass if bmp or icon, the image name and the Id and image type (normal, disabled, etc.)
41
    // With Bitmaps this will first look for the resource then search for the file in the file path.
42
    // With Icons it checks for the file first (explained below)
43
    // return Image Id if success
44
    Function AddImageType Boolean bIsIcon String sImage Integer iId Integer eImageType Returns Integer
45
        Handle hBitmap
46
        Variant vImageManager
47
        Handle hoImageIcons
48
        Integer iVoid
49
        Boolean bOk 
50
        String sFileImage
51
        
52
        If (iId=0) Begin
53
            Get piLastImageId to iId
54
            Increment iId
55
            Set piLastImageId to iId
56
        End
57
        
58
        Get Create U_cCJImageManagerIcons to hoImageIcons
59
        Get ComIcons to vImageManager
60
        Set pvComObject of hoImageIcons to vImageManager
61

    
62
        // if an icon we will always try to load from a file first. Loading from a file works better than
63
        // the internal resource load because the internal load only finds the first image. If the ico has
64
        // multiple images (which CJ can use) all of the extra images are lost
65
        
66
        // if an Icon - load from file first then load from resource
67
        If bIsIcon Begin
68
            Get_File_Path sImage to sFileImage // find path in DFPATH, if appropriate
69
            If (sFileImage<>"") Begin
70
                Send ComLoadIcon of hoImageIcons sFileImage iId eImageType
71
                Move True to bOk
72
            End
73
            Else Begin
74
                Move (LoadImage(GetModuleHandle(0), sImage, IMAGE_ICON, 0, 0, 0)) to hBitmap
75
                If hBitmap Begin
76
                    // this works with alpha blends - even when passed false
77
                    Send ComAddIconHandle hBitmap iId eImageType False
78
                    Move (DestroyIcon(hBitmap)) to iVoid
79
                    Move True to bOk
80
                End
81
            End
82
        End
83
        // if a bitmap - load from resource first then from file
84
        Else Begin
85
            Move (LoadImage(GetModuleHandle(0), sImage, IMAGE_BITMAP, 0, 0, 0)) to hBitmap
86

    
87
            If (hBitmap=0) Begin // the bitmap was not in the EXE resource
88
                Get_File_Path sImage to sFileImage // find path in DFPATH, if appropriate
89
 
90
                If (sFileImage <>"") Begin // The image was found!
91
//                    Move (LoadImage(0, sFileImage, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)) to hBitmap
92
                    Send ComLoadBitmap of hoImageIcons sFileImage iId eImageType
93
                    Move True to bOk
94
                End
95
            End
96
    
97
            If hBitmap Begin
98
                Send ComAddBitmap of hoImageIcons hBitmap iId eImageType False
99
                Move (DeleteObject(hBitmap)) to iVoid
100
                Move True to bOk
101
            End
102
        End
103

    
104
        Send destroy of hoImageIcons
105

    
106
        Function_Return (If(bOk, iId, 0))
107
    End_Procedure
108
    
109
    // Adds an image to imagelist. 
110
    // We assume that this is an icon unless the .bmp extension is passed. 
111
    // return True if success
112
    Function AddImage String sImage Integer iId Integer eImageType Returns Integer
113
        Boolean bIsIcon
114
        // Command Bars support many graphics formats including .bmp, .gif, .jpg etc.
115
        // These are all non-icon formats...
116
//        Move (Pos(".bmp", Lowercase(sImage)) = 0) to bIsIcon
117
        Move (Right(Lowercase(sImage), 4) = ".ico") to bIsIcon
118
        Get AddImageType bIsIcon sImage iId eImageType to iId
119
        Function_Return iId
120
    End_Procedure
121
//****** COPY CODE ENDS
122
#ENDIF
123

    
124
  
125
End_Class // cImageEditCJCommandBarSystem