DropObject.st
author Claus Gittinger <cg@exept.de>
Sat, 19 Apr 1997 15:44:35 +0200
changeset 546 a71c15f2330c
parent 403 cdcee4daddef
child 547 7764165d89b8
permissions -rw-r--r--
added comments & docu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
     1
"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
     3
              All Rights Reserved
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
     4
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
     5
 This software is furnished under a license and may be used
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
     6
 only in accordance with the terms of that license and with the
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
     9
 other person.  No title to or ownership of the software is
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    10
 hereby transferred.
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    11
"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    12
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    13
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    14
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    15
Object subclass:#DropObject
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    16
	instanceVariableNames:'theObject'
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    17
	classVariableNames:''
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    18
	poolDictionaries:''
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    19
	category:'Interface-Support'
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    20
!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    21
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
    22
DropObject class instanceVariableNames:'DisplayObject'
cdcee4daddef preliminary
ca
parents: 396
diff changeset
    23
cdcee4daddef preliminary
ca
parents: 396
diff changeset
    24
"
cdcee4daddef preliminary
ca
parents: 396
diff changeset
    25
 The following class instance variables are inherited by this class:
cdcee4daddef preliminary
ca
parents: 396
diff changeset
    26
cdcee4daddef preliminary
ca
parents: 396
diff changeset
    27
	Object - 
cdcee4daddef preliminary
ca
parents: 396
diff changeset
    28
"
cdcee4daddef preliminary
ca
parents: 396
diff changeset
    29
!
cdcee4daddef preliminary
ca
parents: 396
diff changeset
    30
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    31
DropObject subclass:#Text
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    32
	instanceVariableNames:''
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    33
	classVariableNames:''
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    34
	poolDictionaries:''
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    35
	privateIn:DropObject
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    36
!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    37
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    38
DropObject subclass:#Image
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    39
	instanceVariableNames:''
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    40
	classVariableNames:''
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    41
	poolDictionaries:''
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    42
	privateIn:DropObject
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    43
!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    44
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    45
DropObject subclass:#Color
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
    46
	instanceVariableNames:''
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    47
	classVariableNames:''
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    48
	poolDictionaries:''
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    49
	privateIn:DropObject
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    50
!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    51
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    52
DropObject subclass:#File
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    53
	instanceVariableNames:'info isHtmlFile isImageFile isPrintable'
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    54
	classVariableNames:''
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    55
	poolDictionaries:''
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    56
	privateIn:DropObject
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    57
!
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    58
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    59
!DropObject class methodsFor:'documentation'!
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    60
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    61
copyright
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    62
"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    63
 COPYRIGHT (c) 1997 by eXept Software AG
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    64
              All Rights Reserved
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    65
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    66
 This software is furnished under a license and may be used
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    67
 only in accordance with the terms of that license and with the
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    68
 inclusion of the above copyright notice.   This software may not
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    69
 be provided or otherwise made available to, or used by, any
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    70
 other person.  No title to or ownership of the software is
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    71
 hereby transferred.
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    72
"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    73
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    74
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    75
!
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    76
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    77
documentation
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    78
"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    79
    instances of myself and subclasses wrap objects which are being
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    80
    dragged (and dropped).
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    81
    Any object can be dragged, but for some often encountered types,
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    82
    specialized subclasses are provided, which react to certain queries.
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    83
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    84
    [see also:]
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    85
        DragAndDropManager
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    86
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    87
    [author:]
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    88
        Claus Atzkern
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    89
"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
    90
! !
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    91
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    92
!DropObject class methodsFor:'instance creation'!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    93
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    94
new:someThing
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    95
    "create an instance dependant on something
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    96
    "
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    97
    |cls|
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    98
bd27655f4354 intitial checkin
ca
parents:
diff changeset
    99
               someThing isColor             ifTrue:[cls := Color
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   100
    ] ifFalse:[someThing isImageOrForm       ifTrue:[cls := Image
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   101
    ] ifFalse:[(someThing isKindOf:Filename) ifTrue:[cls := File
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   102
    ] ifFalse:[cls isString                  ifTrue:[cls := Text
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   103
    ] ifFalse:[
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   104
        cls := DropObject
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   105
    ]]]].
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   106
        
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   107
  ^ cls new theObject:someThing
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   108
!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   109
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   110
newColor:aColor
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   111
    ^ Color new theObject:aColor
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   112
!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   113
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   114
newFile:aFilename
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   115
    ^ File new theObject:aFilename
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   116
!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   117
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   118
newImage:anImageOrForm
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   119
    ^ Image new theObject:anImageOrForm
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   120
!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   121
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   122
newText:aTextOrString
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   123
    ^ Text new theObject:aTextOrString
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   124
! !
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   125
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   126
!DropObject class methodsFor:'defaults'!
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   127
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   128
displayObject
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   129
    "return some object which is shown while dragging;
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   130
     here an image based upon my displayObjectName is returned.
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   131
     Either this method or #displayObjectName is usually redefined
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   132
     in subclasses"
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   133
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   134
    DisplayObject notNil ifTrue:[
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   135
        ^ DisplayObject
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   136
    ].
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   137
    DisplayObject := Smalltalk::Image fromFile:(self displayObjectName).
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   138
    ^ DisplayObject
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   139
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   140
    "Modified: 19.4.1997 / 13:04:05 / cg"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   141
!
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   142
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   143
displayObject:aDisplayObject
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   144
    "set the object which is shown while dragging;
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   145
     this object must understand #displayOn:x:y: (i.e. the displayObject
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   146
     protocol). The object is kept per class for ALL future drag operations.
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   147
     Useful to change the default images in subclasses."
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   148
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   149
    DisplayObject := aDisplayObject
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   150
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   151
    "Modified: 19.4.1997 / 15:42:10 / cg"
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   152
!
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   153
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   154
displayObjectName
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   155
    "return the name of a bitmap image file, which is used 
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   156
     during a drag.
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   157
     Here, a dummy file is returned."
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   158
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   159
    ^ 'bitmaps/xpmBitmaps/plain_pixmaps/balloon3.xpm'
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   160
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   161
    "Modified: 19.4.1997 / 13:54:13 / cg"
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   162
! !
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   163
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   164
!DropObject methodsFor:'accessing'!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   165
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   166
theObject
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   167
    "return the real object represented by the receiver"
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   168
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   169
    ^ theObject
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   170
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   171
    "Modified: 19.4.1997 / 12:53:01 / cg"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   172
!
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   173
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   174
theObject:something
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   175
    "set the real object represented by the receiver"
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   176
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   177
    theObject := something.
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   178
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   179
    "Modified: 19.4.1997 / 12:53:10 / cg"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   180
! !
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   181
396
77043c4aca02 checkin from browser
ca
parents: 395
diff changeset
   182
!DropObject methodsFor:'queries'!
77043c4aca02 checkin from browser
ca
parents: 395
diff changeset
   183
77043c4aca02 checkin from browser
ca
parents: 395
diff changeset
   184
displayObject
77043c4aca02 checkin from browser
ca
parents: 395
diff changeset
   185
    "return my graphical representation - here a default is returned"
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   186
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   187
    ^ self class displayObject
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   188
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   189
    "Modified: 19.4.1997 / 12:52:41 / cg"
396
77043c4aca02 checkin from browser
ca
parents: 395
diff changeset
   190
! !
77043c4aca02 checkin from browser
ca
parents: 395
diff changeset
   191
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   192
!DropObject methodsFor:'testing'!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   193
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   194
isColorObject
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   195
    "return true, if the dropObject represents a color"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   196
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   197
    ^ false
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   198
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   199
    "Modified: 19.4.1997 / 12:52:36 / cg"
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   200
!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   201
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   202
isFileObject
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   203
    "return true, if the dropObject represents some file or directory"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   204
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   205
    ^ false
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   206
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   207
    "Modified: 19.4.1997 / 12:52:29 / cg"
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   208
!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   209
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   210
isImageObject
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   211
    "return true, if the dropObject represents some image"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   212
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   213
    ^ false
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   214
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   215
    "Modified: 19.4.1997 / 12:52:22 / cg"
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   216
!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   217
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   218
isTextObject
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   219
    "return true, if the dropObject represents some text"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   220
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   221
    ^ false
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   222
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   223
    "Modified: 19.4.1997 / 12:52:17 / cg"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   224
! !
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   225
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   226
!DropObject::Text class methodsFor:'defaults'!
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   227
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   228
displayObjectName
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   229
    ^ 'bitmaps/xpmBitmaps/document_images/yellow_file_text_grab.xpm'
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   230
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   231
    "Modified: 19.4.1997 / 15:40:33 / cg"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   232
! !
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   233
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   234
!DropObject::Text methodsFor:'testing'!
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   235
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   236
isTextObject
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   237
    "return true, if the dropObject represents some text"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   238
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   239
    ^ true
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   240
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   241
    "Modified: 19.4.1997 / 12:52:08 / cg"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   242
! !
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   243
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   244
!DropObject::Image class methodsFor:'defaults'!
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   245
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   246
displayObjectName
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   247
    "return the name of a bitmap image file, which is used 
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   248
     during a drag."
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   249
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   250
    ^ 'bitmaps/xpmBitmaps/misc_tools/picture.xpm'
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   251
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   252
    "Modified: 19.4.1997 / 15:38:02 / cg"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   253
! !
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   254
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   255
!DropObject::Image methodsFor:'testing'!
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   256
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   257
isImageObject
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   258
    "return true, if the dropObject represents an image"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   259
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   260
    ^ true
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   261
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   262
    "Modified: 19.4.1997 / 12:51:28 / cg"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   263
! !
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   264
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   265
!DropObject::Color class methodsFor:'defaults'!
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   266
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   267
displayObjectName
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   268
    "return the name of a bitmap image file, which is used 
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   269
     during a drag."
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   270
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   271
    ^ 'bitmaps/xpmBitmaps/misc_tools/color_wheel.xpm'
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   272
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   273
    "Modified: 19.4.1997 / 15:38:12 / cg"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   274
! !
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   275
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   276
!DropObject::Color methodsFor:'testing'!
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   277
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   278
isColorObject
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   279
    "return true, if the dropObject represents a color"
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   280
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   281
    ^ true
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   282
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   283
    "Modified: 19.4.1997 / 12:51:57 / cg"
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   284
! !
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   285
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   286
!DropObject::File class methodsFor:'defaults'!
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   287
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   288
displayObjectName
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   289
    "return the name of a bitmap image file, which is used 
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   290
     during a drag."
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   291
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   292
    ^ 'bitmaps/xpmBitmaps/document_images/xfm_file.xpm'
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   293
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   294
    "Modified: 19.4.1997 / 15:38:07 / cg"
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   295
! !
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   296
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   297
!DropObject::File methodsFor:'accessing'!
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   298
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   299
theObject:aPathname
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   300
    |f path|
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   301
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   302
    f := aPathname asFilename.
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   303
    path := f pathName.
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   304
    info := f info.
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   305
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   306
    super theObject:f
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   307
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   308
    "Modified: 19.4.1997 / 12:49:17 / cg"
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   309
! !
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   310
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   311
!DropObject::File methodsFor:'queries'!
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   312
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   313
exists
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   314
    "returns true if the file or directory exists
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   315
    "
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   316
    ^ info notNil
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   317
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   318
    "Modified: 19.4.1997 / 12:49:30 / cg"
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   319
!
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   320
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   321
isDirectory
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   322
    "checks whether file is a directory
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   323
    "
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   324
    ^ (info notNil and:[info type == #directory])
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   325
!
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   326
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   327
isHtmlFile
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   328
    "checks whether file is an html file
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   329
    "
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   330
    |suffixes pathName|
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   331
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   332
    isHtmlFile isNil ifTrue:[
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   333
        (info isNil or:[self isDirectory]) ifTrue:[
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   334
            isHtmlFile := false
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   335
        ] ifFalse:[
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   336
            pathName   := theObject asString.
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   337
            suffixes   := #( '.html' '.htm' '.HTML' '.HTM' ).
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   338
            isHtmlFile := (suffixes findFirst:[:el|pathName endsWith:el]) ~~ 0
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   339
        ]
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   340
    ].
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   341
    ^ isHtmlFile
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   342
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   343
    "Modified: 19.4.1997 / 12:49:37 / cg"
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   344
!
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   345
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   346
isImageFile
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   347
    "returns true if file is an image file
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   348
    "
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   349
    |pathName|
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   350
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   351
    isImageFile isNil ifTrue:[
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   352
        (info isNil or:[self isDirectory]) ifTrue:[
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   353
            isImageFile := false
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   354
        ] ifFalse:[
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   355
            pathName    := theObject asString.
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   356
            isImageFile := Image isImageFileSuffix:(pathName asFilename suffix).
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   357
        ]
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   358
    ].
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   359
    ^ isImageFile
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   360
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   361
    "Modified: 19.4.1997 / 12:50:58 / cg"
403
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   362
!
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   363
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   364
isPrintable
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   365
    "returns false if file contains non printable characters
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   366
    "
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   367
    |stream buff size|
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   368
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   369
    isPrintable isNil ifTrue:[
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   370
        isPrintable := false.
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   371
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   372
        (info isNil or:[self isDirectory]) ifFalse:[
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   373
            stream := FileStream readonlyFileNamed:(theObject pathName).
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   374
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   375
            stream isNil ifFalse:[
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   376
                buff := String new:300.
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   377
                size := stream nextBytes:300 into:buff.
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   378
                stream close.
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   379
            ].
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   380
            1 to:size do:[:i|
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   381
                (buff at:i) isPrintable ifFalse:[
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   382
                    ^ isPrintable
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   383
                ]
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   384
            ].
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   385
            isPrintable := true
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   386
        ]
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   387
    ].
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   388
    ^ isPrintable
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   389
! !
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   390
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   391
!DropObject::File methodsFor:'testing'!
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   392
cdcee4daddef preliminary
ca
parents: 396
diff changeset
   393
isFileObject
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   394
    "return true, if the dropObject represents a file- or directory"
396
77043c4aca02 checkin from browser
ca
parents: 395
diff changeset
   395
77043c4aca02 checkin from browser
ca
parents: 395
diff changeset
   396
    ^ true
77043c4aca02 checkin from browser
ca
parents: 395
diff changeset
   397
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   398
    "Modified: 19.4.1997 / 12:51:49 / cg"
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   399
! !
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   400
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   401
!DropObject class methodsFor:'documentation'!
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   402
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   403
version
546
a71c15f2330c added comments & docu
Claus Gittinger <cg@exept.de>
parents: 403
diff changeset
   404
    ^ '$Header: /cvs/stx/stx/libview2/DropObject.st,v 1.4 1997-04-19 13:44:35 cg Exp $'
395
bd27655f4354 intitial checkin
ca
parents:
diff changeset
   405
! !