tbx  0.7.6
fileinfo.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2010 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 /*
26  * fileinfo.h
27  *
28  * Created on: 01-Jul-2010
29  * Author: alanb
30  */
31 
32 #ifndef TBX_FILEINFO_H_
33 #define TBX_FILEINFO_H_
34 
35 #include "showfullobject.h"
36 #include "listener.h"
37 #include "window.h"
38 #include "path.h"
39 
40 namespace tbx {
41 
42 // Listeners
43 class AboutToBeShownListener;
44 class HasBeenHiddenListener;
45 
46 namespace res
47 {
48  class ResFileInfo;
49 }
50 
56 {
57 public:
58  enum { TOOLBOX_CLASS = 0x82ac0 };
59 
65  FileInfo() {};
74  FileInfo(const FileInfo &other) : ShowFullObject(other._handle) {}
85  FileInfo(const Object &other) : ShowFullObject(other) {check_toolbox_class(FileInfo::TOOLBOX_CLASS);}
93  FileInfo(const std::string &template_name) : ShowFullObject(template_name) {check_toolbox_class(FileInfo::TOOLBOX_CLASS);}
100  FileInfo(const res::ResFileInfo &object_template);
101 
110  FileInfo &operator=(const FileInfo &other) {_handle = other.handle(); return *this;}
122  FileInfo &operator=(const Object &other) {_handle = other.handle(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
130  bool operator==(const Object &other) const {return (_handle == other.handle());}
138  bool operator!=(const Object &other) const {return (_handle != other.handle());}
139 
140 
141  // Properties
145  Window window() const {return Window((ObjectId)int_property(0));}
146 
150  void modified(bool value) {bool_property(1, value);}
151 
155  bool modified() const {return bool_property(2);}
156 
161 
165  int file_type() const {return int_property(4);}
166 
167 
171  void file_name(std::string name) {string_property(5, name);}
172 
176  std::string file_name() const {return string_property(6);}
177 
181  int file_name_length() const {return string_property_length(6);}
182 
186  void file_size(int size) {int_property(7, size);}
187 
191  int file_size() const {return int_property(8);}
192 
196  void date(const UTCTime &date);
197 
201  UTCTime date() const;
202 
206  void title(std::string name) {string_property(11, name);}
207 
211  std::string title() const {return string_property(12);}
212 
216  int title_length() const {return string_property_length(12);}
217 
218  // Listeners
223 };
224 
225 
226 }
227 
228 #endif /* TBX_FILEINFO_H_ */
tbx::FileInfo::operator=
FileInfo & operator=(const Object &other)
Assign this FileInfo from an Object that refers to a FileInfo.
Definition: fileinfo.h:122
tbx::FileInfo::add_about_to_be_shown_listener
void add_about_to_be_shown_listener(AboutToBeShownListener *listener)
This event is raised just before the FileInfo underlying window is about to be shown.
Definition: fileinfo.cc:75
tbx::Object::int_property
int int_property(int property_id) const
Return the value of a property that returns an integer.
Definition: object.cc:477
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::FileInfo::window
Window window() const
Return the underlying toolbox window used to implement the FileInfo object.
Definition: fileinfo.h:145
tbx::FileInfo
Class to show a toolbox FileInfo object.
Definition: fileinfo.h:56
tbx::Object::handle
ObjectId handle() const
Return the underlying toolbox object id this object references.
Definition: object.h:93
tbx::UTCTime
Class to handle the 5 byte times.
Definition: path.h:52
tbx::FileInfo::title
void title(std::string name)
Set the title.
Definition: fileinfo.h:206
tbx::FileInfo::operator!=
bool operator!=(const Object &other) const
Check if this FileInfo does not refers to the same underlying toolbox object as another.
Definition: fileinfo.h:138
tbx::FileInfo::file_type
void file_type(int file_type)
Set the file type.
Definition: fileinfo.h:160
tbx::FileInfo::modified
void modified(bool value)
Set to indicate the file has been modified.
Definition: fileinfo.h:150
tbx::Object::_handle
ObjectId _handle
Handle for toolbox object.
Definition: object.h:175
tbx::FileInfo::FileInfo
FileInfo(const Object &other)
Construct a FileInfo from an Object that refers to a FileInfo.
Definition: fileinfo.h:85
tbx::Object::string_property
std::string string_property(int property_id) const
Return the value of a property that returns text.
Definition: object.cc:519
tbx::Window
The Window object represents a toolbox window.
Definition: window.h:70
tbx::FileInfo::date
UTCTime date() const
Get the date.
Definition: fileinfo.cc:59
tbx::HasBeenHiddenListener
Listener for an object has been hidden event.
Definition: hasbeenhiddenlistener.h:36
tbx::FileInfo::FileInfo
FileInfo()
Construct creates an unassigned FileInfo.
Definition: fileinfo.h:65
tbx::Object::string_property_length
int string_property_length(int property_id) const
Gets the size of a string properties buffer.
Definition: object.cc:572
tbx::FileInfo::file_name_length
int file_name_length() const
Return the length of the file name.
Definition: fileinfo.h:181
tbx::FileInfo::remove_has_been_hidden_listener
void remove_has_been_hidden_listener(HasBeenHiddenListener *listener)
Remove has been hidden listener.
Definition: fileinfo.cc:99
tbx::FileInfo::FileInfo
FileInfo(const std::string &template_name)
Create a FileInfo from the named template.
Definition: fileinfo.h:93
tbx::FileInfo::remove_about_to_be_shown_listener
void remove_about_to_be_shown_listener(AboutToBeShownListener *listener)
Remove about to be shown listener.
Definition: fileinfo.cc:83
tbx::FileInfo::file_size
int file_size() const
Get the file size.
Definition: fileinfo.h:191
tbx::Object::check_toolbox_class
void check_toolbox_class(int class_id) const
Check if this objects toolbox class is as specified.
Definition: object.cc:122
tbx::FileInfo::file_name
std::string file_name() const
Return the file name.
Definition: fileinfo.h:176
tbx::AboutToBeShownListener
Listener for about to be shown event.
Definition: abouttobeshownlistener.h:77
tbx::FileInfo::operator=
FileInfo & operator=(const FileInfo &other)
Assign this FileInfo from another.
Definition: fileinfo.h:110
tbx::Object
Class to manipulate a toolbox object.
Definition: object.h:51
tbx::FileInfo::modified
bool modified() const
Read modified flag from dialogue box.
Definition: fileinfo.h:155
tbx::FileInfo::FileInfo
FileInfo(const FileInfo &other)
Construct a FileInfo from another FileInfo.
Definition: fileinfo.h:74
tbx::ShowFullObject
Objects derived from this class can be shown with there full location and size specified as well as t...
Definition: showfullobject.h:41
tbx::FileInfo::title_length
int title_length() const
Return the length of the title.
Definition: fileinfo.h:216
tbx::res::ResFileInfo
Class for FileInfo object template.
Definition: resfileinfo.h:39
tbx::ObjectId
unsigned int ObjectId
Type for underlying toolbox object id.
Definition: handles.h:31
tbx::Object::bool_property
bool bool_property(int property_id) const
Get a boolean property from the toolbox Cobject.
Definition: object.cc:595
tbx::FileInfo::file_type
int file_type() const
Get the file type.
Definition: fileinfo.h:165
tbx::FileInfo::file_size
void file_size(int size)
Set the file size.
Definition: fileinfo.h:186
tbx::FileInfo::title
std::string title() const
Return the title.
Definition: fileinfo.h:211
tbx::FileInfo::operator==
bool operator==(const Object &other) const
Check if this FileInfo refers to the same underlying toolbox object as another.
Definition: fileinfo.h:130
tbx::FileInfo::file_name
void file_name(std::string name)
Set the file name.
Definition: fileinfo.h:171
tbx::FileInfo::add_has_been_hidden_listener
void add_has_been_hidden_listener(HasBeenHiddenListener *listener)
This event is raised after the FileInfo dialog has been completed.
Definition: fileinfo.cc:91