src/hbcore/cssparser/hbstyleloader.cpp
changeset 0 16d8024aca5e
child 1 f7ac710697a9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbCore module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 
       
    26 #include "hbstyleloader.h"
       
    27 #include "hblayeredstyleloader_p.h"
       
    28 #include "hbwidgetstyleloader_p.h"
       
    29 
       
    30 /*!
       
    31 	@beta
       
    32     @hbcore
       
    33     \class HbStyleLoader
       
    34     \brief allows an application to override platform layout and stylesheet definitions
       
    35 
       
    36     HbStyleLoader allows an application to register and unregister stylesheet files (CSS)
       
    37     and layout definition files (WidgetML). 
       
    38 
       
    39     Any stylesheet and layout definitions registered will be then be accessed by subsequent
       
    40     attempts to apply widget styles using HbStyle, (in cases where the style depends on the
       
    41     defined stylesheet or layout properties). So, once you have registered a stylesheet or
       
    42     a layout definition, you will need to cause widgets in your application to be repolished
       
    43     before they will detect the changes.
       
    44 
       
    45     For any stylesheet or layout definitions registered that correspond to similar properties
       
    46     defined by the platform, the properties registered by the application will take precedence.
       
    47     In case of CSS normal rules for stylesheet precedence apply. For example, selectors that
       
    48     are at least equally specific and define the same properties will override those equivalent
       
    49     platform property definitions.
       
    50 
       
    51     In order to remove stylesheets or layout definitions that were previously registered,
       
    52     the same filename should be provided to the corresponding unregister method. Again,
       
    53     a repolish is needed in order to detect the changes.
       
    54 
       
    55     Any stylesheets and layout definitions that remain registered will automatically be
       
    56     destroyed on application exit.
       
    57 */
       
    58 
       
    59 /*!
       
    60     Register application specific WidgetML or CSS file, a directory,
       
    61     or a file path pattern.
       
    62     
       
    63     \a filePath can be
       
    64     - a single CSS file, where the file name must end with ".css", e.g. "myapplication.css", or
       
    65     - a single WidgetML, where the file name must end with "classname.widgetml", e.g. "mywidget.widgetml", or
       
    66     - a directory, when all files matching to above rules will be registered, or
       
    67     - a file path pattern, where the file path must contain (one or several occurances of) "%w". When
       
    68     searching for the style files the wildcard ("%w") will be replaced by classname and the file
       
    69     extensions will be added to the path. This happens for all the widgets existing in the application
       
    70     (even for the standard widgets) E.g. if the file path pattern is "myapp\%w\%w" the following
       
    71     files will be searched for: "myapp\mywidget\mywidget.css", "myapp\mywidget\mywidget.widgetml",
       
    72     "myapp\hbpushbutton\hbpushbutton.css", "myapp\hbpushbutton\hbpushbutton.widgetml", etc. Normally
       
    73     file path pattern is used only for platform style definition. Other kind of usage may cause 
       
    74     significant perfomrance hit.
       
    75     \sa unregisterFilePath
       
    76 */
       
    77 bool HbStyleLoader::registerFilePath(const QString &filePath)
       
    78 {
       
    79     return HbWidgetStyleLoader::instance()->addFilePath(
       
    80         filePath,
       
    81         HbLayeredStyleLoader::Concern_All,
       
    82         HbLayeredStyleLoader::Priority_Application);
       
    83 }
       
    84 
       
    85 /*!
       
    86     Register application specific WidgetML or CSS file, a directory,
       
    87     or a file path pattern.
       
    88 
       
    89     \a filePath should be the same as with registerFilePath
       
    90     \sa registerFilePath
       
    91 */
       
    92 bool HbStyleLoader::unregisterFilePath(const QString &filePath)
       
    93 {
       
    94     return HbWidgetStyleLoader::instance()->removeFilePath(
       
    95         filePath,
       
    96         HbLayeredStyleLoader::Concern_All,
       
    97         HbLayeredStyleLoader::Priority_Application);
       
    98 }