Subversion Repositories Filer-Free

Rev

Rev 38 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 38 Rev 49
Line 9... Line 9...
9
#include "oslib/osbyte.h"
9
#include "oslib/osbyte.h"
10
#include "oslib/wimp.h"
10
#include "oslib/wimp.h"
11
#include "oslib/wimpspriteop.h"
11
#include "oslib/wimpspriteop.h"
12
#include "oslib/dragasprite.h"
12
#include "oslib/dragasprite.h"
13
 
13
 
-
 
14
#include "template_loader.h"
14
#include "application.h"
15
#include "application.h"
15
#include "save_dbox.h"
16
#include "save_dbox.h"
16
#include "filer_window.h"
17
#include "filer_window.h"
17
 
18
 
18
save_dbox::save_dbox(application* app,const char* tplname,
19
save_dbox::save_dbox(application* app,const char* tplname,
19
        const char* pathname):
20
        const char* pathname):
20
        template_window(app,tplname,pathname),
21
        window(app),
21
        _owner(0)
22
        _owner(0)
-
 
23
{
-
 
24
        // Load template.
-
 
25
        template_loader loader(tplname,pathname);
-
 
26
 
-
 
27
        // Transfer ownership of workspace from loader to window.
-
 
28
        _workspace=loader.workspace();
-
 
29
        wimp_window& wblock=loader;
-
 
30
 
-
 
31
        // For some unknown reason the sprite name is not indirected, making
-
 
32
        // it impossible to change by normal means.  This is overridden here
-
 
33
        // to make it an indirected sprite icon.
-
 
34
        wimp_icon& iblock=wblock.icons[icon_sprite];
-
 
35
        size_t sprite_length=0;
-
 
36
        while (sprite_length<12)
-
 
37
        {
-
 
38
                if (iblock.data.sprite[sprite_length]<0x20) break;
-
 
39
                _sprite_name_buffer[sprite_length]=iblock.data.sprite[sprite_length];
-
 
40
                ++sprite_length;
22
{}
41
        }
-
 
42
        _sprite_name_buffer[sprite_length]=0;
-
 
43
 
-
 
44
        iblock.flags|=wimp_ICON_INDIRECTED;
-
 
45
        iblock.data.indirected_sprite.id=
-
 
46
                reinterpret_cast<osspriteop_id>(_sprite_name_buffer);
-
 
47
        iblock.data.indirected_sprite.area=
-
 
48
                reinterpret_cast<osspriteop_area*>(1);
-
 
49
        iblock.data.indirected_sprite.size=sizeof(_sprite_name_buffer);
-
 
50
 
-
 
51
        // Create window.
-
 
52
        create_window(wblock);
-
 
53
}
23
 
54
 
24
void save_dbox::handle_mouse_click(wimp_pointer& block)
55
void save_dbox::handle_mouse_click(wimp_pointer& block)
25
{
56
{
26
        switch (block.i)
57
        switch (block.i)
27
        {
58
        {
Line 110... Line 141...
110
                // Get name of sprite to be dragged.  This is most easily achieved
141
                // Get name of sprite to be dragged.  This is most easily achieved
111
                // by inspecting the icon from which the drag will begin.
142
                // by inspecting the icon from which the drag will begin.
112
                wimp_icon_state state;
143
                wimp_icon_state state;
113
                state.i=icon_sprite;
144
                state.i=icon_sprite;
114
                get_icon_state(state);
145
                get_icon_state(state);
115
                char* _sprite_name=state.icon.data.text;
146
                char* sprite_name=state.icon.data.indirected_text.text;
116
                char sprite_name[12+1];
-
 
117
                std::memcpy(sprite_name,_sprite_name,12);
-
 
118
                sprite_name[12]=0;
-
 
119
 
147
 
120
                // Get eigenvalues for the current screen mode.
148
                // Get eigenvalues for the current screen mode.
121
                int xeig=0;
149
                int xeig=0;
122
                int yeig=0;
150
                int yeig=0;
123
                os_read_mode_variable(os_CURRENT_MODE,os_MODEVAR_XEIG_FACTOR,&xeig);
151
                os_read_mode_variable(os_CURRENT_MODE,os_MODEVAR_XEIG_FACTOR,&xeig);
Line 213... Line 241...
213
void save_dbox::filer_action(const char* pathname)
241
void save_dbox::filer_action(const char* pathname)
214
{}
242
{}
215
 
243
 
216
void save_dbox::owner(filer_window* owner)
244
void save_dbox::owner(filer_window* owner)
217
{
245
{
-
 
246
        // No action unless owner has changed.
-
 
247
        if (owner!=_owner)
-
 
248
        {
218
        // Change owner.
249
                // Set new owner.
219
        _owner=owner;
250
                _owner=owner;
220
 
251
 
221
        // Reset pathname.
252
                // Reset pathname.
222
        wimp_icon_state state;
253
                wimp_icon_state state;
223
        state.i=icon_pathname;
254
                state.i=icon_pathname;
224
        get_icon_state(state);
255
                get_icon_state(state);
225
        char* pathname=state.icon.data.indirected_text.text;
256
                char* pathname=state.icon.data.indirected_text.text;
226
        *pathname=0;
257
                *pathname=0;
-
 
258
        }
227
}
259
}